[llvm-commits] [llvm-gcc-4.2] r43913 [44/80] - in /llvm-gcc-4.2/trunk: boehm-gc/ boehm-gc/Mac_files/ boehm-gc/cord/ boehm-gc/doc/ boehm-gc/include/ boehm-gc/include/private/ boehm-gc/tests/ libffi/ libffi/include/ libffi/src/ libffi/src/alpha/ libffi/src/arm/ libffi/src/cris/ libffi/src/frv/ libffi/src/ia64/ libffi/src/m32r/ libffi/src/m68k/ libffi/src/mips/ libffi/src/pa/ libffi/src/powerpc/ libffi/src/s390/ libffi/src/sh/ libffi/src/sh64/ libffi/src/sparc/ libffi/src/x86/ libffi/testsuite/ libffi/testsuite/config/ li...

Bill Wendling isanbard at gmail.com
Thu Nov 8 14:57:11 PST 2007


Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/TreeSet.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/TreeSet.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/TreeSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/TreeSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,416 @@
+/* TreeSet.java -- a class providing a TreeMap-backed SortedSet
+   Copyright (C) 1999, 2000, 2001, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+/**
+ * This class provides a TreeMap-backed implementation of the SortedSet
+ * interface. The elements will be sorted according to their <i>natural
+ * order</i>, or according to the provided <code>Comparator</code>.<p>
+ *
+ * Most operations are O(log n), but there is so much overhead that this
+ * makes small sets expensive. Note that the ordering must be <i>consistent
+ * with equals</i> to correctly implement the Set interface. If this
+ * condition is violated, the set is still well-behaved, but you may have
+ * suprising results when comparing it to other sets.<p>
+ *
+ * This implementation is not synchronized. If you need to share this between
+ * multiple threads, do something like:<br>
+ * <code>SortedSet s
+ *       = Collections.synchronizedSortedSet(new TreeSet(...));</code><p>
+ *
+ * The iterators are <i>fail-fast</i>, meaning that any structural
+ * modification, except for <code>remove()</code> called on the iterator
+ * itself, cause the iterator to throw a
+ * <code>ConcurrentModificationException</code> rather than exhibit
+ * non-deterministic behavior.
+ *
+ * @author Jon Zeppieri
+ * @author Bryce McKinlay
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Collection
+ * @see Set
+ * @see HashSet
+ * @see LinkedHashSet
+ * @see Comparable
+ * @see Comparator
+ * @see Collections#synchronizedSortedSet(SortedSet)
+ * @see TreeMap
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class TreeSet extends AbstractSet
+  implements SortedSet, Cloneable, Serializable
+{
+  /**
+   * Compatible with JDK 1.2.
+   */
+  private static final long serialVersionUID = -2479143000061671589L;
+
+  /**
+   * The SortedMap which backs this Set.
+   */
+  // Not final because of readObject. This will always be one of TreeMap or
+  // TreeMap.SubMap, which both extend AbstractMap.
+  private transient SortedMap map;
+
+  /**
+   * Construct a new TreeSet whose backing TreeMap using the "natural"
+   * ordering of keys. Elements that are not mutually comparable will cause
+   * ClassCastExceptions down the road.
+   *
+   * @see Comparable
+   */
+  public TreeSet()
+  {
+    map = new TreeMap();
+  }
+
+  /**
+   * Construct a new TreeSet whose backing TreeMap uses the supplied
+   * Comparator. Elements that are not mutually comparable will cause
+   * ClassCastExceptions down the road.
+   *
+   * @param comparator the Comparator this Set will use
+   */
+  public TreeSet(Comparator comparator)
+  {
+    map = new TreeMap(comparator);
+  }
+
+  /**
+   * Construct a new TreeSet whose backing TreeMap uses the "natural"
+   * orering of the keys and which contains all of the elements in the
+   * supplied Collection. This runs in n*log(n) time.
+   *
+   * @param collection the new Set will be initialized with all
+   *        of the elements in this Collection
+   * @throws ClassCastException if the elements of the collection are not
+   *         comparable
+   * @throws NullPointerException if the collection is null
+   * @see Comparable
+   */
+  public TreeSet(Collection collection)
+  {
+    map = new TreeMap();
+    addAll(collection);
+  }
+
+  /**
+   * Construct a new TreeSet, using the same key ordering as the supplied
+   * SortedSet and containing all of the elements in the supplied SortedSet.
+   * This constructor runs in linear time.
+   *
+   * @param sortedSet the new TreeSet will use this SortedSet's comparator
+   *        and will initialize itself with all its elements
+   * @throws NullPointerException if sortedSet is null
+   */
+  public TreeSet(SortedSet sortedSet)
+  {
+    map = new TreeMap(sortedSet.comparator());
+    Iterator itr = sortedSet.iterator();
+    ((TreeMap) map).putKeysLinear(itr, sortedSet.size());
+  }
+
+  /**
+   * This private constructor is used to implement the subSet() calls around
+   * a backing TreeMap.SubMap.
+   *
+   * @param backingMap the submap
+   */
+  private TreeSet(SortedMap backingMap)
+  {
+    map = backingMap;
+  }
+
+  /**
+   * Adds the spplied Object to the Set if it is not already in the Set;
+   * returns true if the element is added, false otherwise.
+   *
+   * @param obj the Object to be added to this Set
+   * @throws ClassCastException if the element cannot be compared with objects
+   *         already in the set
+   */
+  public boolean add(Object obj)
+  {
+    return map.put(obj, "") == null;
+  }
+
+  /**
+   * Adds all of the elements in the supplied Collection to this TreeSet.
+   *
+   * @param c The collection to add
+   * @return true if the Set is altered, false otherwise
+   * @throws NullPointerException if c is null
+   * @throws ClassCastException if an element in c cannot be compared with
+   *         objects already in the set
+   */
+  public boolean addAll(Collection c)
+  {
+    boolean result = false;
+    int pos = c.size();
+    Iterator itr = c.iterator();
+    while (--pos >= 0)
+      result |= (map.put(itr.next(), "") == null);
+    return result;
+  }
+
+  /**
+   * Removes all elements in this Set.
+   */
+  public void clear()
+  {
+    map.clear();
+  }
+
+  /**
+   * Returns a shallow copy of this Set. The elements are not cloned.
+   *
+   * @return the cloned set
+   */
+  public Object clone()
+  {
+    TreeSet copy = null;
+    try
+      {
+        copy = (TreeSet) super.clone();
+        // Map may be either TreeMap or TreeMap.SubMap, hence the ugly casts.
+        copy.map = (SortedMap) ((AbstractMap) map).clone();
+      }
+    catch (CloneNotSupportedException x)
+      {
+        // Impossible result.
+      }
+    return copy;
+  }
+
+  /**
+   * Returns this Set's comparator.
+   *
+   * @return the comparator, or null if the set uses natural ordering
+   */
+  public Comparator comparator()
+  {
+    return map.comparator();
+  }
+
+  /**
+   * Returns true if this Set contains the supplied Object, false otherwise.
+   *
+   * @param obj the Object to check for
+   * @return true if it is in the set
+   * @throws ClassCastException if obj cannot be compared with objects
+   *         already in the set
+   */
+  public boolean contains(Object obj)
+  {
+    return map.containsKey(obj);
+  }
+
+  /**
+   * Returns the first (by order) element in this Set.
+   *
+   * @return the first element
+   * @throws NoSuchElementException if the set is empty
+   */
+  public Object first()
+  {
+    return map.firstKey();
+  }
+
+  /**
+   * Returns a view of this Set including all elements less than
+   * <code>to</code>. The returned set is backed by the original, so changes
+   * in one appear in the other. The subset will throw an
+   * {@link IllegalArgumentException} for any attempt to access or add an
+   * element beyond the specified cutoff. The returned set does not include
+   * the endpoint; if you want inclusion, pass the successor element.
+   *
+   * @param to the (exclusive) cutoff point
+   * @return a view of the set less than the cutoff
+   * @throws ClassCastException if <code>to</code> is not compatible with
+   *         the comparator (or is not Comparable, for natural ordering)
+   * @throws NullPointerException if to is null, but the comparator does not
+   *         tolerate null elements
+   */
+  public SortedSet headSet(Object to)
+  {
+    return new TreeSet(map.headMap(to));
+  }
+
+  /**
+   * Returns true if this Set has size 0, false otherwise.
+   *
+   * @return true if the set is empty
+   */
+  public boolean isEmpty()
+  {
+    return map.isEmpty();
+  }
+
+  /**
+   * Returns in Iterator over the elements in this TreeSet, which traverses
+   * in ascending order.
+   *
+   * @return an iterator
+   */
+  public Iterator iterator()
+  {
+    return map.keySet().iterator();
+  }
+
+  /**
+   * Returns the last (by order) element in this Set.
+   *
+   * @return the last element
+   * @throws NoSuchElementException if the set is empty
+   */
+  public Object last()
+  {
+    return map.lastKey();
+  }
+
+  /**
+   * If the supplied Object is in this Set, it is removed, and true is
+   * returned; otherwise, false is returned.
+   *
+   * @param obj the Object to remove from this Set
+   * @return true if the set was modified
+   * @throws ClassCastException if obj cannot be compared to set elements
+   */
+  public boolean remove(Object obj)
+  {
+    return map.remove(obj) != null;
+  }
+
+  /**
+   * Returns the number of elements in this Set
+   *
+   * @return the set size
+   */
+  public int size()
+  {
+    return map.size();
+  }
+
+  /**
+   * Returns a view of this Set including all elements greater or equal to
+   * <code>from</code> and less than <code>to</code> (a half-open interval).
+   * The returned set is backed by the original, so changes in one appear in
+   * the other. The subset will throw an {@link IllegalArgumentException}
+   * for any attempt to access or add an element beyond the specified cutoffs.
+   * The returned set includes the low endpoint but not the high; if you want
+   * to reverse this behavior on either end, pass in the successor element.
+   *
+   * @param from the (inclusive) low cutoff point
+   * @param to the (exclusive) high cutoff point
+   * @return a view of the set between the cutoffs
+   * @throws ClassCastException if either cutoff is not compatible with
+   *         the comparator (or is not Comparable, for natural ordering)
+   * @throws NullPointerException if from or to is null, but the comparator
+   *         does not tolerate null elements
+   * @throws IllegalArgumentException if from is greater than to
+   */
+  public SortedSet subSet(Object from, Object to)
+  {
+    return new TreeSet(map.subMap(from, to));
+  }
+
+  /**
+   * Returns a view of this Set including all elements greater or equal to
+   * <code>from</code>. The returned set is backed by the original, so
+   * changes in one appear in the other. The subset will throw an
+   * {@link IllegalArgumentException} for any attempt to access or add an
+   * element beyond the specified cutoff. The returned set includes the
+   * endpoint; if you want to exclude it, pass in the successor element.
+   *
+   * @param from the (inclusive) low cutoff point
+   * @return a view of the set above the cutoff
+   * @throws ClassCastException if <code>from</code> is not compatible with
+   *         the comparator (or is not Comparable, for natural ordering)
+   * @throws NullPointerException if from is null, but the comparator
+   *         does not tolerate null elements
+   */
+  public SortedSet tailSet(Object from)
+  {
+    return new TreeSet(map.tailMap(from));
+  }
+
+  /**
+   * Serializes this object to the given stream.
+   *
+   * @param s the stream to write to
+   * @throws IOException if the underlying stream fails
+   * @serialData the <i>comparator</i> (Object), followed by the set size
+   *             (int), the the elements in sorted order (Object)
+   */
+  private void writeObject(ObjectOutputStream s) throws IOException
+  {
+    s.defaultWriteObject();
+    Iterator itr = map.keySet().iterator();
+    int pos = map.size();
+    s.writeObject(map.comparator());
+    s.writeInt(pos);
+    while (--pos >= 0)
+      s.writeObject(itr.next());
+  }
+
+  /**
+   * Deserializes this object from the given stream.
+   *
+   * @param s the stream to read from
+   * @throws ClassNotFoundException if the underlying stream fails
+   * @throws IOException if the underlying stream fails
+   * @serialData the <i>comparator</i> (Object), followed by the set size
+   *             (int), the the elements in sorted order (Object)
+   */
+  private void readObject(ObjectInputStream s)
+    throws IOException, ClassNotFoundException
+  {
+    s.defaultReadObject();
+    Comparator comparator = (Comparator) s.readObject();
+    int size = s.readInt();
+    map = new TreeMap(comparator);
+    ((TreeMap) map).putFromObjStream(s, size, false);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/UUID.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/UUID.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/UUID.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/UUID.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,383 @@
+/* UUID.java -- Class that represents a UUID object.
+   Copyright (C) 2006  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+import java.io.Serializable;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * This class represents a 128-bit UUID value.
+ * 
+ * There are several types of UUID, and while this class can be used to store
+ * them, only the Leach-Salz (variant 2) UUID specified in RFC-4122 will 
+ * give meaningful results from the method calls.
+ * See: http://tools.ietf.org/html/4122 for the details
+ *
+ * The format of a Leach-Salz (variant 2) time-based (version 1) UUID 
+ * is as follows:
+ * time_low - upper 32 bits of the most significant 64 bits,
+ *            this is the least-significant part of the timestamp.
+ *
+ * time_mid - bits 16-31 of the most significant 64 bits,
+ *            this is the middle portion of the timestamp. 
+ *
+ * version  - bits 8-15 of the most significant 64 bits. 
+ *
+ * time_hi  - bits 0-7 of the most significant 64 bits,
+ *            the most significant portion of the timestamp.
+ *
+ * clock_and_reserved  - bits 48-63 of the least significant 64 bits.
+ *                       a variable number of bits hold the variant 
+ *                       (see the spec)
+ * 
+ * node identifier     - bits 0-47 of the least signficant 64 bits.
+ *
+ * These fields are valid only for version 1, in the remaining versions,
+ * only the version and variant fields are set, all others are used for data.
+ *
+ * @since 1.5
+ * @author Sven de Marothy
+ */
+public final class UUID 
+  extends Object 
+  implements Serializable, Comparable // genericizeme!
+{
+  private static final long serialVersionUID = -4856846361193249489L;
+
+  /**
+   * Serialized field - most significant 64 bits.
+   */
+  private long mostSigBits;
+
+  /**
+   * Serialized field - least significant 64 bits.
+   */
+  private long leastSigBits;
+
+  /**
+   * Random-number generator.
+   */
+  private static transient Random r = new Random();
+
+  /**
+   * Constructs a new UUID.
+   *
+   * @since 1.5
+   */
+  public UUID(long mostSigBits, long leastSigBits)
+  {
+    this.mostSigBits = mostSigBits;
+    this.leastSigBits = leastSigBits;
+  }
+ 
+  /**
+   * Returns the clock-sequence value of this UUID.
+   * This field only exists in a time-based (version 1) UUID.
+   *
+   * @throws UnsupportedOperationException if the UUID type is not 1.
+   * @returns an int containing the clock-sequence value.
+   */
+  public int clockSequence()
+  {
+    if( version() != 1 )
+      throw new UnsupportedOperationException("Not a type 1 UUID");
+    return (int)((leastSigBits & 0x3FFF000000000000L) >> 48);
+  }
+
+  /**
+   * Compare this UUID to another.
+   * The comparison is performed as between two 128-bit integers.
+   *
+   * @return -1 if this < val, 0 if they are equal, 1 if this > val.
+   */
+  public int compareTo(Object val)
+  {
+    return compareTo((UUID)val);
+  }
+
+  /**
+   * Compare this UUID to another.
+   * The comparison is performed as between two 128-bit integers.
+   *
+   * @return -1 if this < val, 0 if they are equal, 1 if this > val.
+   */
+  public int compareTo(UUID o)
+  {
+    if( mostSigBits < o.mostSigBits )
+      return -1;
+    if( mostSigBits > o.mostSigBits )
+      return 1;
+    if( leastSigBits < o.leastSigBits )
+      return -1;
+    if( leastSigBits > o.mostSigBits )
+      return 1;
+    return 0;
+  }
+
+  /**
+   * Compare a (UUID) object to this one
+   */
+  public boolean equals(Object obj)
+  {
+    if( !(obj instanceof UUID ) )
+      return false;
+    return ( ((UUID)obj).mostSigBits == mostSigBits && 
+	     ((UUID)obj).leastSigBits == leastSigBits );
+  }
+
+  /**
+   * Creates a UUID object from a Sting representation.
+   *
+   * For the format of the string,
+   * @see #toString()
+   *
+   * @return a new UUID object.
+   */
+  public static UUID fromString(String name)
+  {
+    StringTokenizer st = new StringTokenizer( name.trim(), "-" );
+    if( st.countTokens() < 5 )
+      throw new IllegalArgumentException( "Incorrect UUID string"+
+					  " representation:"+name );
+
+    long msb = (Long.parseLong(st.nextToken(), 16) << 32); // time low
+    msb |= (Long.parseLong(st.nextToken(), 16) << 16); // time mid
+    msb |= Long.parseLong(st.nextToken(), 16); // time high
+
+    long lsb = (Long.parseLong(st.nextToken(), 16) << 48); // clock
+    lsb |= Long.parseLong(st.nextToken(), 16); // node
+
+    return new UUID(msb, lsb);
+  }
+
+  /**
+   * Returns a String representation of the UUID.
+   *
+   * The format of the standard string representation (given in RFC4122) is:
+   *
+   * time-low "-" time-mid "-"
+   * time-high-and-version "-"
+   * clock-seq-and-reserved
+   * clock-seq-low "-" node
+   *
+   * Where each field is represented as a hex string.
+   *
+   * @return the String representation.
+   */
+  public String toString()
+  {
+    return // time-low first
+      padHex( (( mostSigBits & 0xFFFFFFFF00000000L) >> 32) & 0xFFFFFFFFL, 8)
+      + "-" + // then time-mid
+      padHex( (( mostSigBits & 0xFFFF0000L ) >> 16), 4 ) 
+      + "-" + // time-high
+      padHex( ( mostSigBits & 0x0000000000000000FFFFL ), 4 ) 
+      + "-" + // clock (note - no reason to separate high and low here)
+      padHex( (((leastSigBits & 0xFFFF000000000000L) >> 48) & 0xFFFF), 4 ) 
+      + "-" + // finally the node value.
+      padHex(leastSigBits & 0xFFFFFFFFFFFFL, 12); 
+  }
+
+  /**
+   * Returns the least significant 64 bits of the UUID as a <code>long</code>.
+   */ 
+  public long getLeastSignificantBits()
+  {
+    return leastSigBits;
+  }
+
+  /**
+   * Returns the most significant 64 bits of the UUID as a <code>long</code>.
+   */ 
+  public long getMostSignificantBits()
+  {
+    return mostSigBits;
+  }
+
+  /**
+   * Returns a hash of this UUID.
+   */
+  public int hashCode()
+  {
+    int l1 = (int)(leastSigBits & 0xFFFFFFFFL);
+    int l2 = (int)((leastSigBits & 0xFFFFFFFF00000000L) >> 32);
+    int m1 = (int)(mostSigBits & 0xFFFFFFFFL);
+    int m2 = (int)((mostSigBits & 0xFFFFFFFF00000000L) >> 32);
+
+    return (l1 ^ l2) ^ (m1 ^ m2);
+  }
+
+  /**
+   * Creates a UUID version 3 object (name based with MD5 hashing)
+   * from a series of bytes representing a name.
+   */
+  public static UUID nameUUIDFromBytes(byte[] name)
+  {    
+    long msb, lsb;
+    byte[] hash;
+
+    try
+      {
+	MessageDigest md5 = MessageDigest.getInstance("MD5");
+	hash = md5.digest( name );
+      } 
+    catch (NoSuchAlgorithmException e) 
+      {
+	throw new UnsupportedOperationException("No MD5 algorithm available.");
+      }
+	
+    msb = ((hash[0] & 0xFFL) << 56) | ((hash[1] & 0xFFL) << 48) |
+      ((hash[2] & 0xFFL) << 40) | ((hash[3] & 0xFFL) << 32) |
+      ((hash[4] & 0xFFL) << 24) | ((hash[5] & 0xFFL) << 16) |
+      ((hash[6] & 0xFFL) << 8) | (hash[7] & 0xFFL);
+
+    lsb = ((hash[8] & 0xFFL) << 56) | ((hash[9] & 0xFFL) << 48) |
+      ((hash[10] & 0xFFL) << 40) | ((hash[11] & 0xFFL) << 32) |
+      ((hash[12] & 0xFFL) << 24) | ((hash[13] & 0xFFL) << 16) |
+      ((hash[14] & 0xFFL) << 8) | (hash[15] & 0xFFL);
+
+    lsb &= 0x3FFFFFFFFFFFFFFFL; 
+    lsb |= 0x8000000000000000L; // set top two bits to variant 2
+
+    msb &= 0xFFFFFFFFFFFF0FFFL; 
+    msb |= 0x3000; // Version 3; 
+
+    return new UUID(msb, lsb);
+  }
+
+  /**
+   * Returns the 48-bit node value in a long. 
+   * This field only exists in a time-based (version 1) UUID.
+   *
+   * @throws UnsupportedOperationException if the UUID type is not 1.
+   * @returns a long with the node value in the lower 48 bits.
+   */
+  public long node() 
+  {
+    if( version() != 1 )
+      throw new UnsupportedOperationException("Not a type 1 UUID");
+    return (leastSigBits & 0xFFFFFFFFFFFFL);
+  }
+
+  /**
+   * Returns the 60-bit timestamp value of the UUID in a long. 
+   * This field only exists in a time-based (version 1) UUID.
+   *
+   * @throws UnsupportedOperationException if the UUID type is not 1.
+   * @returns a long with the timestamp value.
+   */
+  public long timestamp()
+  {
+    if( version() != 1 )
+      throw new UnsupportedOperationException("Not a type 1 UUID");
+    long time = (( mostSigBits & 0xFFFFFFFF00000000L) >> 32);
+    time |= (( mostSigBits & 0xFFFF0000L ) << 16);
+    long time_hi = ( mostSigBits & 0xFFFL );
+    time |= (time_hi << 48);
+    return time;
+  }
+
+  /**
+   * Generate a Leach-Salz (Variant 2) randomly generated (version 4)
+   * UUID.
+   *
+   */
+  public static UUID randomUUID()
+  {  
+    long lsb = r.nextLong(); 
+    long msb = r.nextLong();
+
+    lsb &= 0x3FFFFFFFFFFFFFFFL; 
+    lsb |= 0x8000000000000000L; // set top two bits to variant 2
+
+    msb &= 0xFFFFFFFFFFFF0FFFL; 
+    msb |= 0x4000; // Version 4; 
+
+    return new UUID( msb, lsb );
+  }
+
+  /**
+   * Returns a hex String from l, padded to n spaces.
+   */
+  private String padHex( long l, int n )
+  {
+    String s = Long.toHexString( l );
+    while( s.length() < n )
+      s = "0" + s;
+    return s;
+  }
+
+  /**
+   * Returns the variant of the UUID
+   *
+   * This may be:
+   * 0 = Reserved for NCS backwards-compatibility
+   * 2 = Leach-Salz (supports the other methods in this class)
+   * 6 = Reserved for Microsoft backwards-compatibility
+   * 7 = (reserved for future use)
+   */
+  public int variant()
+  {
+    // Get the top 3 bits (not all may be part of the variant)
+    int v = (int)((leastSigBits & 0xE000000000000000L) >> 61);
+    if( (v & 0x04) == 0 ) // msb of the variant is 0
+      return 0;
+    if( (v & 0x02) == 0 ) // variant is 0 1 (Leach-Salz)
+      return 2;
+    return v; // 6 or 7 
+  }
+
+  /**
+   * Returns the version # of the UUID.
+   *
+   * Valid version numbers for a variant 2 UUID are:
+   * 1 = Time based UUID
+   * 2 = DCE security UUID
+   * 3 = Name-based UUID using MD5 hashing
+   * 4 = Randomly generated UUID
+   * 5 = Name-based UUID using SHA-1 hashing
+   *
+   * @return the version number
+   */
+  public int version()
+  {
+    return (int)((mostSigBits & 0xF000L) >> 12);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/UnknownFormatConversionException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/UnknownFormatConversionException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/UnknownFormatConversionException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/UnknownFormatConversionException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,86 @@
+/* UnknownFormatConversionException.java
+   Copyright (C) 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/** 
+ * Thrown when a {@link Formatter} is supplied with an
+ * unknown conversion.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5 
+ */
+public class UnknownFormatConversionException 
+  extends IllegalFormatException
+{
+  private static final long serialVersionUID = 19060418L;
+
+  /**
+   * The unknown conversion.
+   *
+   * @serial the unknown conversion.
+   */
+  // Note: name fixed by serialization.
+  private String s;
+
+  /**
+   * Constructs a new <code>UnknownFormatConversionException</code>
+   * for the specified conversion string.
+   *
+   * @param s the conversion string.
+   * @throws NullPointerException if the conversion string is null.
+   */
+  public UnknownFormatConversionException(String s)
+  {
+    super("Unknown format conversion: " + s);
+    if (s == null)
+      throw new NullPointerException("The conversion string is null.");
+    this.s = s;
+  }
+
+  /**
+   * Returns the conversion string.
+   *
+   * @return the conversion string.
+   */
+  public String getConversion()
+  {
+    return s;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/UnknownFormatFlagsException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/UnknownFormatFlagsException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/UnknownFormatFlagsException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/UnknownFormatFlagsException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,88 @@
+/* UnknownFormatFlagsException.java
+   Copyright (C) 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/** 
+ * Thrown when a {@link Formatter} is supplied with an
+ * unknown flag.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5 
+ */
+public class UnknownFormatFlagsException 
+  extends IllegalFormatException
+{
+  private static final long serialVersionUID = 19370506L;
+
+  /**
+   * The set of flags containing the unknown flag.
+   *
+   * @serial the unknown conversion.
+   */
+  // Note: name fixed by serialization.
+  private String flags;
+
+  /**
+   * Constructs a new <code>UnknownFormatFlagsException</code>
+   * which specifies that the supplied set of flags contains a
+   * unknown.
+   *
+   * @param flags the flags containing a unknown.
+   * @throws NullPointerException if <code>flags</code> is null.
+   */
+  public UnknownFormatFlagsException(String s)
+  {
+    super("Unknown flag passed in " + s);
+    if (s == null)
+      throw new
+	NullPointerException("Null flags value passed to constructor.");
+    this.flags = s;
+  }
+
+  /**
+   * Returns the flags which contain a unknown.
+   *
+   * @return the flags.
+   */
+  public String getFlags()
+  {
+    return flags;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/Vector.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/Vector.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/Vector.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/Vector.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,933 @@
+/* Vector.java -- Class that provides growable arrays.
+   Copyright (C) 1998, 1999, 2000, 2001, 2004, 2005, 2006,  
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Array;
+
+/**
+ * The <code>Vector</code> classes implements growable arrays of Objects.
+ * You can access elements in a Vector with an index, just as you
+ * can in a built in array, but Vectors can grow and shrink to accommodate
+ * more or fewer objects.<p>
+ *
+ * Vectors try to mantain efficiency in growing by having a
+ * <code>capacityIncrement</code> that can be specified at instantiation.
+ * When a Vector can no longer hold a new Object, it grows by the amount
+ * in <code>capacityIncrement</code>. If this value is 0, the vector doubles in
+ * size.<p>
+ *
+ * Vector implements the JDK 1.2 List interface, and is therefore a fully
+ * compliant Collection object. The iterators are fail-fast - if external
+ * code structurally modifies the vector, any operation on the iterator will
+ * then throw a {@link ConcurrentModificationException}. The Vector class is
+ * fully synchronized, but the iterators are not. So, when iterating over a
+ * vector, be sure to synchronize on the vector itself.  If you don't want the
+ * expense of synchronization, use ArrayList instead. On the other hand, the
+ * Enumeration of elements() is not thread-safe, nor is it fail-fast; so it
+ * can lead to undefined behavior even in a single thread if you modify the
+ * vector during iteration.<p>
+ *
+ * Note: Some methods, especially those specified by List, specify throwing
+ * {@link IndexOutOfBoundsException}, but it is easier to implement by
+ * throwing the subclass {@link ArrayIndexOutOfBoundsException}. Others
+ * directly specify this subclass.
+ *
+ * @author Scott G. Miller
+ * @author Bryce McKinlay
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Collection
+ * @see List
+ * @see ArrayList
+ * @see LinkedList
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public class Vector extends AbstractList
+  implements List, RandomAccess, Cloneable, Serializable
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -2767605614048989439L;
+
+  /**
+   * The internal array used to hold members of a Vector. The elements are
+   * in positions 0 through elementCount - 1, and all remaining slots are null.
+   * @serial the elements
+   */
+  protected Object[] elementData;
+
+  /**
+   * The number of elements currently in the vector, also returned by
+   * {@link #size}.
+   * @serial the size
+   */
+  protected int elementCount;
+
+  /**
+   * The amount the Vector's internal array should be increased in size when
+   * a new element is added that exceeds the current size of the array,
+   * or when {@link #ensureCapacity} is called. If <= 0, the vector just
+   * doubles in size.
+   * @serial the amount to grow the vector by
+   */
+  protected int capacityIncrement;
+
+  /**
+   * Constructs an empty vector with an initial size of 10, and
+   * a capacity increment of 0
+   */
+  public Vector()
+  {
+    this(10, 0);
+  }
+
+  /**
+   * Constructs a vector containing the contents of Collection, in the
+   * order given by the collection.
+   *
+   * @param c collection of elements to add to the new vector
+   * @throws NullPointerException if c is null
+   * @since 1.2
+   */
+  public Vector(Collection c)
+  {
+    elementCount = c.size();
+    elementData = c.toArray(new Object[elementCount]);
+  }
+
+  /**
+   * Constructs a Vector with the initial capacity and capacity
+   * increment specified.
+   *
+   * @param initialCapacity the initial size of the Vector's internal array
+   * @param capacityIncrement the amount the internal array should be
+   *        increased by when necessary, 0 to double the size
+   * @throws IllegalArgumentException if initialCapacity < 0
+   */
+  public Vector(int initialCapacity, int capacityIncrement)
+  {
+    if (initialCapacity < 0)
+      throw new IllegalArgumentException();
+    elementData = new Object[initialCapacity];
+    this.capacityIncrement = capacityIncrement;
+  }
+
+  /**
+   * Constructs a Vector with the initial capacity specified, and a capacity
+   * increment of 0 (double in size).
+   *
+   * @param initialCapacity the initial size of the Vector's internal array
+   * @throws IllegalArgumentException if initialCapacity < 0
+   */
+  public Vector(int initialCapacity)
+  {
+    this(initialCapacity, 0);
+  }
+
+  /**
+   * Copies the contents of the Vector into the provided array.  If the
+   * array is too small to fit all the elements in the Vector, an 
+   * {@link IndexOutOfBoundsException} is thrown without modifying the array.  
+   * Old elements in the array are overwritten by the new elements.
+   *
+   * @param a target array for the copy
+   * @throws IndexOutOfBoundsException the array is not large enough
+   * @throws NullPointerException the array is null
+   * @see #toArray(Object[])
+   */
+  public synchronized void copyInto(Object[] a)
+  {
+    System.arraycopy(elementData, 0, a, 0, elementCount);
+  }
+
+  /**
+   * Trims the Vector down to size.  If the internal data array is larger
+   * than the number of Objects its holding, a new array is constructed
+   * that precisely holds the elements. Otherwise this does nothing.
+   */
+  public synchronized void trimToSize()
+  {
+    // Don't bother checking for the case where size() == the capacity of the
+    // vector since that is a much less likely case; it's more efficient to
+    // not do the check and lose a bit of performance in that infrequent case
+
+    Object[] newArray = new Object[elementCount];
+    System.arraycopy(elementData, 0, newArray, 0, elementCount);
+    elementData = newArray;
+  }
+
+  /**
+   * Ensures that <code>minCapacity</code> elements can fit within this Vector.
+   * If <code>elementData</code> is too small, it is expanded as follows:
+   * If the <code>elementCount + capacityIncrement</code> is adequate, that
+   * is the new size. If <code>capacityIncrement</code> is non-zero, the
+   * candidate size is double the current. If that is not enough, the new
+   * size is <code>minCapacity</code>.
+   *
+   * @param minCapacity the desired minimum capacity, negative values ignored
+   */
+  public synchronized void ensureCapacity(int minCapacity)
+  {
+    if (elementData.length >= minCapacity)
+      return;
+
+    int newCapacity;
+    if (capacityIncrement <= 0)
+      newCapacity = elementData.length * 2;
+    else
+      newCapacity = elementData.length + capacityIncrement;
+
+    Object[] newArray = new Object[Math.max(newCapacity, minCapacity)];
+
+    System.arraycopy(elementData, 0, newArray, 0, elementCount);
+    elementData = newArray;
+  }
+
+  /**
+   * Explicitly sets the size of the vector (but not necessarily the size of
+   * the internal data array). If the new size is smaller than the old one,
+   * old values that don't fit are lost. If the new size is larger than the
+   * old one, the vector is padded with null entries.
+   *
+   * @param newSize The new size of the internal array
+   * @throws ArrayIndexOutOfBoundsException if the new size is negative
+   */
+  public synchronized void setSize(int newSize)
+  {
+    // Don't bother checking for the case where size() == the capacity of the
+    // vector since that is a much less likely case; it's more efficient to
+    // not do the check and lose a bit of performance in that infrequent case
+    modCount++;
+    ensureCapacity(newSize);
+    if (newSize < elementCount)
+      Arrays.fill(elementData, newSize, elementCount, null);
+    elementCount = newSize;
+  }
+
+  /**
+   * Returns the size of the internal data array (not the amount of elements
+   * contained in the Vector).
+   *
+   * @return capacity of the internal data array
+   */
+  public synchronized int capacity()
+  {
+    return elementData.length;
+  }
+
+  /**
+   * Returns the number of elements stored in this Vector.
+   *
+   * @return the number of elements in this Vector
+   */
+  public synchronized int size()
+  {
+    return elementCount;
+  }
+
+  /**
+   * Returns true if this Vector is empty, false otherwise
+   *
+   * @return true if the Vector is empty, false otherwise
+   */
+  public synchronized boolean isEmpty()
+  {
+    return elementCount == 0;
+  }
+
+  /**
+   * Returns an Enumeration of the elements of this Vector. The enumeration
+   * visits the elements in increasing index order, but is NOT thread-safe.
+   *
+   * @return an Enumeration
+   * @see #iterator()
+   */
+  // No need to synchronize as the Enumeration is not thread-safe!
+  public Enumeration elements()
+  {
+    return new Enumeration()
+    {
+      private int i = 0;
+
+      public boolean hasMoreElements()
+      {
+        return i < elementCount;
+      }
+
+      public Object nextElement()
+      {
+        if (i >= elementCount)
+          throw new NoSuchElementException();
+        return elementData[i++];
+      }
+    };
+  }
+
+  /**
+   * Returns true when <code>elem</code> is contained in this Vector.
+   *
+   * @param elem the element to check
+   * @return true if the object is contained in this Vector, false otherwise
+   */
+  public boolean contains(Object elem)
+  {
+    return indexOf(elem, 0) >= 0;
+  }
+
+  /**
+   * Returns the first occurrence of <code>elem</code> in the Vector, or -1 if
+   * <code>elem</code> is not found.
+   *
+   * @param elem the object to search for
+   * @return the index of the first occurrence, or -1 if not found
+   */
+  public int indexOf(Object elem)
+  {
+    return indexOf(elem, 0);
+  }
+
+  /**
+   * Searches the vector starting at <code>index</code> for object
+   * <code>elem</code> and returns the index of the first occurrence of this
+   * Object.  If the object is not found, or index is larger than the size
+   * of the vector, -1 is returned.
+   *
+   * @param e the Object to search for
+   * @param index start searching at this index
+   * @return the index of the next occurrence, or -1 if it is not found
+   * @throws IndexOutOfBoundsException if index < 0
+   */
+  public synchronized int indexOf(Object e, int index)
+  {
+    for (int i = index; i < elementCount; i++)
+      if (equals(e, elementData[i]))
+        return i;
+    return -1;
+  }
+
+  /**
+   * Returns the last index of <code>elem</code> within this Vector, or -1
+   * if the object is not within the Vector.
+   *
+   * @param elem the object to search for
+   * @return the last index of the object, or -1 if not found
+   */
+  public int lastIndexOf(Object elem)
+  {
+    return lastIndexOf(elem, elementCount - 1);
+  }
+
+  /**
+   * Returns the index of the first occurrence of <code>elem</code>, when
+   * searching backwards from <code>index</code>.  If the object does not
+   * occur in this Vector, or index is less than 0, -1 is returned.
+   *
+   * @param e the object to search for
+   * @param index the index to start searching in reverse from
+   * @return the index of the Object if found, -1 otherwise
+   * @throws IndexOutOfBoundsException if index >= size()
+   */
+  public synchronized int lastIndexOf(Object e, int index)
+  {
+    checkBoundExclusive(index);
+    for (int i = index; i >= 0; i--)
+      if (equals(e, elementData[i]))
+        return i;
+    return -1;
+  }
+
+  /**
+   * Returns the Object stored at <code>index</code>.
+   *
+   * @param index the index of the Object to retrieve
+   * @return the object at <code>index</code>
+   * @throws ArrayIndexOutOfBoundsException index < 0 || index >= size()
+   * @see #get(int)
+   */
+  public synchronized Object elementAt(int index)
+  {
+    checkBoundExclusive(index);
+    return elementData[index];
+  }
+
+  /**
+   * Returns the first element (index 0) in the Vector.
+   *
+   * @return the first Object in the Vector
+   * @throws NoSuchElementException the Vector is empty
+   */
+  public synchronized Object firstElement()
+  {
+    if (elementCount == 0)
+      throw new NoSuchElementException();
+
+    return elementData[0];
+  }
+
+  /**
+   * Returns the last element in the Vector.
+   *
+   * @return the last Object in the Vector
+   * @throws NoSuchElementException the Vector is empty
+   */
+  public synchronized Object lastElement()
+  {
+    if (elementCount == 0)
+      throw new NoSuchElementException();
+
+    return elementData[elementCount - 1];
+  }
+
+  /**
+   * Changes the element at <code>index</code> to be <code>obj</code>
+   *
+   * @param obj the object to store
+   * @param index the position in the Vector to store the object
+   * @throws ArrayIndexOutOfBoundsException the index is out of range
+   * @see #set(int, Object)
+   */
+  public void setElementAt(Object obj, int index)
+  {
+    set(index, obj);
+  }
+
+  /**
+   * Removes the element at <code>index</code>, and shifts all elements at
+   * positions greater than index to their index - 1.
+   *
+   * @param index the index of the element to remove
+   * @throws ArrayIndexOutOfBoundsException index < 0 || index >= size();
+   * @see #remove(int)
+   */
+  public void removeElementAt(int index)
+  {
+    remove(index);
+  }
+
+  /**
+   * Inserts a new element into the Vector at <code>index</code>.  Any elements
+   * at or greater than index are shifted up one position.
+   *
+   * @param obj the object to insert
+   * @param index the index at which the object is inserted
+   * @throws ArrayIndexOutOfBoundsException index < 0 || index > size()
+   * @see #add(int, Object)
+   */
+  public synchronized void insertElementAt(Object obj, int index)
+  {
+    checkBoundInclusive(index);
+    if (elementCount == elementData.length)
+      ensureCapacity(elementCount + 1);
+    modCount++;
+    System.arraycopy(elementData, index, elementData, index + 1,
+                     elementCount - index);
+    elementCount++;
+    elementData[index] = obj;
+  }
+
+  /**
+   * Adds an element to the Vector at the end of the Vector.  The vector
+   * is increased by ensureCapacity(size() + 1) if needed.
+   *
+   * @param obj the object to add to the Vector
+   */
+  public synchronized void addElement(Object obj)
+  {
+    if (elementCount == elementData.length)
+      ensureCapacity(elementCount + 1);
+    modCount++;
+    elementData[elementCount++] = obj;
+  }
+
+  /**
+   * Removes the first (the lowest index) occurrence of the given object from
+   * the Vector. If such a remove was performed (the object was found), true
+   * is returned. If there was no such object, false is returned.
+   *
+   * @param obj the object to remove from the Vector
+   * @return true if the Object was in the Vector, false otherwise
+   * @see #remove(Object)
+   */
+  public synchronized boolean removeElement(Object obj)
+  {
+    int idx = indexOf(obj, 0);
+    if (idx >= 0)
+      {
+        remove(idx);
+        return true;
+      }
+    return false;
+  }
+
+  /**
+   * Removes all elements from the Vector.  Note that this does not
+   * resize the internal data array.
+   *
+   * @see #clear()
+   */
+  public synchronized void removeAllElements()
+  {
+    if (elementCount == 0)
+      return;
+
+    modCount++;
+    Arrays.fill(elementData, 0, elementCount, null);
+    elementCount = 0;
+  }
+
+  /**
+   * Creates a new Vector with the same contents as this one. The clone is
+   * shallow; elements are not cloned.
+   *
+   * @return the clone of this vector
+   */
+  public synchronized Object clone()
+  {
+    try
+      {
+        Vector clone = (Vector) super.clone();
+        clone.elementData = (Object[]) elementData.clone();
+        return clone;
+      }
+    catch (CloneNotSupportedException ex)
+      {
+        // Impossible to get here.
+        throw new InternalError(ex.toString());
+      }
+  }
+
+  /**
+   * Returns an Object array with the contents of this Vector, in the order
+   * they are stored within this Vector.  Note that the Object array returned
+   * is not the internal data array, and that it holds only the elements
+   * within the Vector.  This is similar to creating a new Object[] with the
+   * size of this Vector, then calling Vector.copyInto(yourArray).
+   *
+   * @return an Object[] containing the contents of this Vector in order
+   * @since 1.2
+   */
+  public synchronized Object[] toArray()
+  {
+    Object[] newArray = new Object[elementCount];
+    copyInto(newArray);
+    return newArray;
+  }
+
+  /**
+   * Returns an array containing the contents of this Vector.
+   * If the provided array is large enough, the contents are copied
+   * into that array, and a null is placed in the position size().
+   * In this manner, you can obtain the size of a Vector by the position
+   * of the null element, if you know the vector does not itself contain
+   * null entries.  If the array is not large enough, reflection is used
+   * to create a bigger one of the same runtime type.
+   *
+   * @param a an array to copy the Vector into if large enough
+   * @return an array with the contents of this Vector in order
+   * @throws ArrayStoreException the runtime type of the provided array
+   *         cannot hold the elements of the Vector
+   * @throws NullPointerException if <code>a</code> is null
+   * @since 1.2
+   */
+  public synchronized Object[] toArray(Object[] a)
+  {
+    if (a.length < elementCount)
+      a = (Object[]) Array.newInstance(a.getClass().getComponentType(),
+                                       elementCount);
+    else if (a.length > elementCount)
+      a[elementCount] = null;
+    System.arraycopy(elementData, 0, a, 0, elementCount);
+    return a;
+  }
+
+  /**
+   * Returns the element at position <code>index</code>.
+   *
+   * @param index the position from which an element will be retrieved
+   * @return the element at that position
+   * @throws ArrayIndexOutOfBoundsException index < 0 || index >= size()
+   * @since 1.2
+   */
+  public Object get(int index)
+  {
+    return elementAt(index);
+  }
+
+  /**
+   * Puts <code>element</code> into the Vector at position <code>index</code>
+   * and returns the Object that previously occupied that position.
+   *
+   * @param index the index within the Vector to place the Object
+   * @param element the Object to store in the Vector
+   * @return the previous object at the specified index
+   * @throws ArrayIndexOutOfBoundsException index < 0 || index >= size()
+   * @since 1.2
+   */
+  public synchronized Object set(int index, Object element)
+  {
+    checkBoundExclusive(index);
+    Object temp = elementData[index];
+    elementData[index] = element;
+    return temp;
+  }
+
+  /**
+   * Adds an object to the Vector.
+   *
+   * @param o the element to add to the Vector
+   * @return true, as specified by List
+   * @since 1.2
+   */
+  public boolean add(Object o)
+  {
+    addElement(o);
+    return true;
+  }
+
+  /**
+   * Removes the given Object from the Vector.  If it exists, true
+   * is returned, if not, false is returned.
+   *
+   * @param o the object to remove from the Vector
+   * @return true if the Object existed in the Vector, false otherwise
+   * @since 1.2
+   */
+  public boolean remove(Object o)
+  {
+    return removeElement(o);
+  }
+
+  /**
+   * Adds an object at the specified index.  Elements at or above
+   * index are shifted up one position.
+   *
+   * @param index the index at which to add the element
+   * @param element the element to add to the Vector
+   * @throws ArrayIndexOutOfBoundsException index < 0 || index > size()
+   * @since 1.2
+   */
+  public void add(int index, Object element)
+  {
+    insertElementAt(element, index);
+  }
+
+  /**
+   * Removes the element at the specified index, and returns it.
+   *
+   * @param index the position from which to remove the element
+   * @return the object removed
+   * @throws ArrayIndexOutOfBoundsException index < 0 || index >= size()
+   * @since 1.2
+   */
+  public synchronized Object remove(int index)
+  {
+    checkBoundExclusive(index);
+    Object temp = elementData[index];
+    modCount++;
+    elementCount--;
+    if (index < elementCount)
+      System.arraycopy(elementData, index + 1, elementData, index,
+                       elementCount - index);
+    elementData[elementCount] = null;
+    return temp;
+  }
+
+  /**
+   * Clears all elements in the Vector and sets its size to 0.
+   */
+  public void clear()
+  {
+    removeAllElements();
+  }
+
+  /**
+   * Returns true if this Vector contains all the elements in c.
+   *
+   * @param c the collection to compare to
+   * @return true if this vector contains all elements of c
+   * @throws NullPointerException if c is null
+   * @since 1.2
+   */
+  public synchronized boolean containsAll(Collection c)
+  {
+    // Here just for the sychronization.
+    return super.containsAll(c);
+  }
+
+  /**
+   * Appends all elements of the given collection to the end of this Vector.
+   * Behavior is undefined if the collection is modified during this operation
+   * (for example, if this == c).
+   *
+   * @param c the collection to append
+   * @return true if this vector changed, in other words c was not empty
+   * @throws NullPointerException if c is null
+   * @since 1.2
+   */
+  public synchronized boolean addAll(Collection c)
+  {
+    return addAll(elementCount, c);
+  }
+
+  /**
+   * Remove from this vector all elements contained in the given collection.
+   *
+   * @param c the collection to filter out
+   * @return true if this vector changed
+   * @throws NullPointerException if c is null
+   * @since 1.2
+   */
+  public synchronized boolean removeAll(Collection c)
+  {
+    if (c == null)
+      throw new NullPointerException();
+
+    int i;
+    int j;
+    for (i = 0; i < elementCount; i++)
+      if (c.contains(elementData[i]))
+        break;
+    if (i == elementCount)
+      return false;
+
+    modCount++;
+    for (j = i++; i < elementCount; i++)
+      if (! c.contains(elementData[i]))
+        elementData[j++] = elementData[i];
+    elementCount -= i - j;
+    return true;
+  }
+
+  /**
+   * Retain in this vector only the elements contained in the given collection.
+   *
+   * @param c the collection to filter by
+   * @return true if this vector changed
+   * @throws NullPointerException if c is null
+   * @since 1.2
+   */
+  public synchronized boolean retainAll(Collection c)
+  {
+    if (c == null)
+      throw new NullPointerException();
+
+    int i;
+    int j;
+    for (i = 0; i < elementCount; i++)
+      if (! c.contains(elementData[i]))
+        break;
+    if (i == elementCount)
+      return false;
+
+    modCount++;
+    for (j = i++; i < elementCount; i++)
+      if (c.contains(elementData[i]))
+        elementData[j++] = elementData[i];
+    elementCount -= i - j;
+    return true;
+  }
+
+  /**
+   * Inserts all elements of the given collection at the given index of
+   * this Vector. Behavior is undefined if the collection is modified during
+   * this operation (for example, if this == c).
+   *
+   * @param c the collection to append
+   * @return true if this vector changed, in other words c was not empty
+   * @throws NullPointerException if c is null
+   * @throws ArrayIndexOutOfBoundsException index < 0 || index > size()
+   * @since 1.2
+   */
+  public synchronized boolean addAll(int index, Collection c)
+  {
+    checkBoundInclusive(index);
+    Iterator itr = c.iterator();
+    int csize = c.size();
+
+    modCount++;
+    ensureCapacity(elementCount + csize);
+    int end = index + csize;
+    if (elementCount > 0 && index != elementCount)
+      System.arraycopy(elementData, index,
+		       elementData, end, elementCount - index);
+    elementCount += csize;
+    for ( ; index < end; index++)
+      elementData[index] = itr.next();
+    return (csize > 0);
+  }
+
+  /**
+   * Compares this to the given object.
+   *
+   * @param o the object to compare to
+   * @return true if the two are equal
+   * @since 1.2
+   */
+  public synchronized boolean equals(Object o)
+  {
+    // Here just for the sychronization.
+    return super.equals(o);
+  }
+
+  /**
+   * Computes the hashcode of this object.
+   *
+   * @return the hashcode
+   * @since 1.2
+   */
+  public synchronized int hashCode()
+  {
+    // Here just for the sychronization.
+    return super.hashCode();
+  }
+
+  /**
+   * Returns a string representation of this Vector in the form
+   * "[element0, element1, ... elementN]".
+   *
+   * @return the String representation of this Vector
+   */
+  public synchronized String toString()
+  {
+    // Here just for the sychronization.
+    return super.toString();
+  }
+
+  /**
+   * 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 is modifiable, and changes in one
+   * reflect in the other. 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>
+   *
+   * @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 vector
+   * @throws IndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > size()
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @see ConcurrentModificationException
+   * @since 1.2
+   */
+  public synchronized List subList(int fromIndex, int toIndex)
+  {
+    List sub = super.subList(fromIndex, toIndex);
+    // We must specify the correct object to synchronize upon, hence the
+    // use of a non-public API
+    return new Collections.SynchronizedList(this, sub);
+  }
+
+  /**
+   * Removes a range of elements from this list.
+   * Does nothing when toIndex is equal to fromIndex.
+   *
+   * @param fromIndex the index to start deleting from (inclusive)
+   * @param toIndex the index to delete up to (exclusive)
+   * @throws IndexOutOfBoundsException if fromIndex > toIndex
+   */
+  // This does not need to be synchronized, because it is only called through
+  // clear() of a sublist, and clear() had already synchronized.
+  protected void removeRange(int fromIndex, int toIndex)
+  {
+    int change = toIndex - fromIndex;
+    if (change > 0)
+      {
+        modCount++;
+        System.arraycopy(elementData, toIndex, elementData, fromIndex,
+                         elementCount - toIndex);
+        int save = elementCount;
+        elementCount -= change;
+        Arrays.fill(elementData, elementCount, save, null);
+      }
+    else if (change < 0)
+      throw new IndexOutOfBoundsException();
+  }
+
+  /**
+   * Checks that the index is in the range of possible elements (inclusive).
+   *
+   * @param index the index to check
+   * @throws ArrayIndexOutOfBoundsException if index > size
+   */
+  private void checkBoundInclusive(int index)
+  {
+    // Implementation note: we do not check for negative ranges here, since
+    // use of a negative index will cause an ArrayIndexOutOfBoundsException
+    // with no effort on our part.
+    if (index > elementCount)
+      throw new ArrayIndexOutOfBoundsException(index + " > " + elementCount);
+  }
+
+  /**
+   * Checks that the index is in the range of existing elements (exclusive).
+   *
+   * @param index the index to check
+   * @throws ArrayIndexOutOfBoundsException if index >= size
+   */
+  private void checkBoundExclusive(int index)
+  {
+    // Implementation note: we do not check for negative ranges here, since
+    // use of a negative index will cause an ArrayIndexOutOfBoundsException
+    // with no effort on our part.
+    if (index >= elementCount)
+      throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount);
+  }
+
+  /**
+   * Serializes this object to the given stream.
+   *
+   * @param s the stream to write to
+   * @throws IOException if the underlying stream fails
+   * @serialData just calls default write function
+   */
+  private synchronized void writeObject(ObjectOutputStream s)
+    throws IOException
+  {
+    s.defaultWriteObject();
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/WeakHashMap.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/WeakHashMap.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/WeakHashMap.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/WeakHashMap.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,878 @@
+/* WeakHashMap -- a hashtable that keeps only weak references
+   to its keys, allowing the virtual machine to reclaim them
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+
+/**
+ * A weak hash map has only weak references to the key. This means that it
+ * allows the key to be garbage collected if it is not used otherwise. If
+ * this happens, the entry will eventually disappear from the map,
+ * asynchronously.
+ *
+ * <p>A weak hash map makes most sense when the keys doesn't override the
+ * <code>equals</code> method: If there is no other reference to the
+ * key nobody can ever look up the key in this table and so the entry
+ * can be removed.  This table also works when the <code>equals</code>
+ * method is overloaded, such as String keys, but you should be prepared
+ * to deal with some entries disappearing spontaneously.
+ *
+ * <p>Other strange behaviors to be aware of: The size of this map may
+ * spontaneously shrink (even if you use a synchronized map and synchronize
+ * it); it behaves as if another thread removes entries from this table
+ * without synchronization.  The entry set returned by <code>entrySet</code>
+ * has similar phenomenons: The size may spontaneously shrink, or an
+ * entry, that was in the set before, suddenly disappears.
+ *
+ * <p>A weak hash map is not meant for caches; use a normal map, with
+ * soft references as values instead, or try {@link LinkedHashMap}.
+ *
+ * <p>The weak hash map supports null values and null keys.  The null key
+ * is never deleted from the map (except explictly of course). The
+ * performance of the methods are similar to that of a hash map.
+ *
+ * <p>The value objects are strongly referenced by this table.  So if a
+ * value object maintains a strong reference to the key (either direct
+ * or indirect) the key will never be removed from this map.  According
+ * to Sun, this problem may be fixed in a future release.  It is not
+ * possible to do it with the jdk 1.2 reference model, though.
+ *
+ * @author Jochen Hoenicke
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ *
+ * @see HashMap
+ * @see WeakReference
+ * @see LinkedHashMap
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class WeakHashMap extends AbstractMap implements Map
+{
+  // WARNING: WeakHashMap is a CORE class in the bootstrap cycle. See the
+  // comments in vm/reference/java/lang/Runtime for implications of this fact.
+
+  /**
+   * The default capacity for an instance of HashMap.
+   * Sun's documentation mildly suggests that this (11) is the correct
+   * value.
+   */
+  private static final int DEFAULT_CAPACITY = 11;
+
+  /**
+   * The default load factor of a HashMap.
+   */
+  private static final float DEFAULT_LOAD_FACTOR = 0.75F;
+
+  /**
+   * This is used instead of the key value <i>null</i>.  It is needed
+   * to distinguish between an null key and a removed key.
+   */
+  // Package visible for use by nested classes.
+  static final Object NULL_KEY = new Object()
+  {
+    /**
+     * Sets the hashCode to 0, since that's what null would map to.
+     * @return the hash code 0
+     */
+    public int hashCode()
+    {
+      return 0;
+    }
+
+    /**
+     * Compares this key to the given object. Normally, an object should
+     * NEVER compare equal to null, but since we don't publicize NULL_VALUE,
+     * it saves bytecode to do so here.
+     * @return true iff o is this or null
+     */
+    public boolean equals(Object o)
+    {
+      return null == o || this == o;
+    }
+  };
+
+  /**
+   * The reference queue where our buckets (which are WeakReferences) are
+   * registered to.
+   */
+  private final ReferenceQueue queue;
+
+  /**
+   * The number of entries in this hash map.
+   */
+  // Package visible for use by nested classes.
+  int size;
+
+  /**
+   * The load factor of this WeakHashMap.  This is the maximum ratio of
+   * size versus number of buckets.  If size grows the number of buckets
+   * must grow, too.
+   */
+  private float loadFactor;
+
+  /**
+   * The rounded product of the capacity (i.e. number of buckets) and
+   * the load factor. When the number of elements exceeds the
+   * threshold, the HashMap calls <code>rehash()</code>.
+   */
+  private int threshold;
+
+  /**
+   * The number of structural modifications.  This is used by
+   * iterators, to see if they should fail.  This doesn't count
+   * the silent key removals, when a weak reference is cleared
+   * by the garbage collection.  Instead the iterators must make
+   * sure to have strong references to the entries they rely on.
+   */
+  // Package visible for use by nested classes.
+  int modCount;
+
+  /**
+   * The entry set.  There is only one instance per hashmap, namely
+   * theEntrySet.  Note that the entry set may silently shrink, just
+   * like the WeakHashMap.
+   */
+  private final class WeakEntrySet extends AbstractSet
+  {
+    /**
+     * Non-private constructor to reduce bytecode emitted.
+     */
+    WeakEntrySet()
+    {
+    }
+
+    /**
+     * Returns the size of this set.
+     *
+     * @return the set size
+     */
+    public int size()
+    {
+      return size;
+    }
+
+    /**
+     * Returns an iterator for all entries.
+     *
+     * @return an Entry iterator
+     */
+    public Iterator iterator()
+    {
+      return new Iterator()
+      {
+        /**
+         * The entry that was returned by the last
+         * <code>next()</code> call.  This is also the entry whose
+         * bucket should be removed by the <code>remove</code> call. <br>
+         *
+         * It is null, if the <code>next</code> method wasn't
+         * called yet, or if the entry was already removed.  <br>
+         *
+         * Remembering this entry here will also prevent it from
+         * being removed under us, since the entry strongly refers
+         * to the key.
+         */
+        WeakBucket.WeakEntry lastEntry;
+
+        /**
+         * The entry that will be returned by the next
+         * <code>next()</code> call.  It is <code>null</code> if there
+         * is no further entry. <br>
+         *
+         * Remembering this entry here will also prevent it from
+         * being removed under us, since the entry strongly refers
+         * to the key.
+         */
+        WeakBucket.WeakEntry nextEntry = findNext(null);
+
+        /**
+         * The known number of modification to the list, if it differs
+         * from the real number, we throw an exception.
+         */
+        int knownMod = modCount;
+
+        /**
+         * Check the known number of modification to the number of
+         * modifications of the table.  If it differs from the real
+         * number, we throw an exception.
+         * @throws ConcurrentModificationException if the number
+         *         of modifications doesn't match.
+         */
+        private void checkMod()
+        {
+          // This method will get inlined.
+          cleanQueue();
+          if (knownMod != modCount)
+            throw new ConcurrentModificationException(knownMod + " != "
+                                                      + modCount);
+        }
+
+        /**
+         * Get a strong reference to the next entry after
+         * lastBucket.
+         * @param lastEntry the previous bucket, or null if we should
+         * get the first entry.
+         * @return the next entry.
+         */
+        private WeakBucket.WeakEntry findNext(WeakBucket.WeakEntry lastEntry)
+        {
+          int slot;
+          WeakBucket nextBucket;
+          if (lastEntry != null)
+            {
+              nextBucket = lastEntry.getBucket().next;
+              slot = lastEntry.getBucket().slot;
+            }
+          else
+            {
+              nextBucket = buckets[0];
+              slot = 0;
+            }
+
+          while (true)
+            {
+              while (nextBucket != null)
+                {
+                  WeakBucket.WeakEntry entry = nextBucket.getEntry();
+                  if (entry != null)
+                    // This is the next entry.
+                    return entry;
+
+                  // Entry was cleared, try next.
+                  nextBucket = nextBucket.next;
+                }
+
+              slot++;
+              if (slot == buckets.length)
+                // No more buckets, we are through.
+                return null;
+
+              nextBucket = buckets[slot];
+            }
+        }
+
+        /**
+         * Checks if there are more entries.
+         * @return true, iff there are more elements.
+         */
+        public boolean hasNext()
+        {
+          return nextEntry != null;
+        }
+
+        /**
+         * Returns the next entry.
+         * @return the next entry.
+         * @throws ConcurrentModificationException if the hash map was
+         *         modified.
+         * @throws NoSuchElementException if there is no entry.
+         */
+        public Object next()
+        {
+          checkMod();
+          if (nextEntry == null)
+            throw new NoSuchElementException();
+          lastEntry = nextEntry;
+          nextEntry = findNext(lastEntry);
+          return lastEntry;
+        }
+
+        /**
+         * Removes the last returned entry from this set.  This will
+         * also remove the bucket of the underlying weak hash map.
+         * @throws ConcurrentModificationException if the hash map was
+         *         modified.
+         * @throws IllegalStateException if <code>next()</code> was
+         *         never called or the element was already removed.
+         */
+        public void remove()
+        {
+          checkMod();
+          if (lastEntry == null)
+            throw new IllegalStateException();
+          modCount++;
+          internalRemove(lastEntry.getBucket());
+          lastEntry = null;
+          knownMod++;
+        }
+      };
+    }
+  }
+
+  /**
+   * A bucket is a weak reference to the key, that contains a strong
+   * reference to the value, a pointer to the next bucket and its slot
+   * number. <br>
+   *
+   * It would be cleaner to have a WeakReference as field, instead of
+   * extending it, but if a weak reference gets cleared, we only get
+   * the weak reference (by queue.poll) and wouldn't know where to
+   * look for this reference in the hashtable, to remove that entry.
+   *
+   * @author Jochen Hoenicke
+   */
+  private static class WeakBucket extends WeakReference
+  {
+    /**
+     * The value of this entry.  The key is stored in the weak
+     * reference that we extend.
+     */
+    Object value;
+
+    /**
+     * The next bucket describing another entry that uses the same
+     * slot.
+     */
+    WeakBucket next;
+
+    /**
+     * The slot of this entry. This should be
+     * <code>Math.abs(key.hashCode() % buckets.length)</code>.
+     *
+     * But since the key may be silently removed we have to remember
+     * the slot number.
+     *
+     * If this bucket was removed the slot is -1.  This marker will
+     * prevent the bucket from being removed twice.
+     */
+    int slot;
+
+    /**
+     * Creates a new bucket for the given key/value pair and the specified
+     * slot.
+     * @param key the key
+     * @param queue the queue the weak reference belongs to
+     * @param value the value
+     * @param slot the slot.  This must match the slot where this bucket
+     *        will be enqueued.
+     */
+    public WeakBucket(Object key, ReferenceQueue queue, Object value,
+                      int slot)
+    {
+      super(key, queue);
+      this.value = value;
+      this.slot = slot;
+    }
+
+    /**
+     * This class gives the <code>Entry</code> representation of the
+     * current bucket.  It also keeps a strong reference to the
+     * key; bad things may happen otherwise.
+     */
+    class WeakEntry implements Map.Entry
+    {
+      /**
+       * The strong ref to the key.
+       */
+      Object key;
+
+      /**
+       * Creates a new entry for the key.
+       * @param key the key
+       */
+      public WeakEntry(Object key)
+      {
+        this.key = key;
+      }
+
+      /**
+       * Returns the underlying bucket.
+       * @return the owning bucket
+       */
+      public WeakBucket getBucket()
+      {
+        return WeakBucket.this;
+      }
+
+      /**
+       * Returns the key.
+       * @return the key
+       */
+      public Object getKey()
+      {
+        return key == NULL_KEY ? null : key;
+      }
+
+      /**
+       * Returns the value.
+       * @return the value
+       */
+      public Object getValue()
+      {
+        return value;
+      }
+
+      /**
+       * This changes the value.  This change takes place in
+       * the underlying hash map.
+       * @param newVal the new value
+       * @return the old value
+       */
+      public Object setValue(Object newVal)
+      {
+        Object oldVal = value;
+        value = newVal;
+        return oldVal;
+      }
+
+      /**
+       * The hashCode as specified in the Entry interface.
+       * @return the hash code
+       */
+      public int hashCode()
+      {
+        return key.hashCode() ^ WeakHashMap.hashCode(value);
+      }
+
+      /**
+       * The equals method as specified in the Entry interface.
+       * @param o the object to compare to
+       * @return true iff o represents the same key/value pair
+       */
+      public boolean equals(Object o)
+      {
+        if (o instanceof Map.Entry)
+          {
+            Map.Entry e = (Map.Entry) o;
+            return WeakHashMap.equals(getKey(), e.getKey())
+              && WeakHashMap.equals(value, e.getValue());
+          }
+        return false;
+      }
+
+      public String toString()
+      {
+        return getKey() + "=" + value;
+      }
+    }
+
+    /**
+     * This returns the entry stored in this bucket, or null, if the
+     * bucket got cleared in the mean time.
+     * @return the Entry for this bucket, if it exists
+     */
+    WeakEntry getEntry()
+    {
+      final Object key = this.get();
+      if (key == null)
+        return null;
+      return new WeakEntry(key);
+    }
+  }
+
+  /**
+   * The entry set returned by <code>entrySet()</code>.
+   */
+  private final WeakEntrySet theEntrySet;
+
+  /**
+   * The hash buckets.  These are linked lists. Package visible for use in
+   * nested classes.
+   */
+  WeakBucket[] buckets;
+
+  /**
+   * Creates a new weak hash map with default load factor and default
+   * capacity.
+   */
+  public WeakHashMap()
+  {
+    this(DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR);
+  }
+
+  /**
+   * Creates a new weak hash map with default load factor and the given
+   * capacity.
+   * @param initialCapacity the initial capacity
+   * @throws IllegalArgumentException if initialCapacity is negative
+   */
+  public WeakHashMap(int initialCapacity)
+  {
+    this(initialCapacity, DEFAULT_LOAD_FACTOR);
+  }
+
+  /**
+   * Creates a new weak hash map with the given initial capacity and
+   * load factor.
+   * @param initialCapacity the initial capacity.
+   * @param loadFactor the load factor (see class description of HashMap).
+   * @throws IllegalArgumentException if initialCapacity is negative, or
+   *         loadFactor is non-positive
+   */
+  public WeakHashMap(int initialCapacity, float loadFactor)
+  {
+    // Check loadFactor for NaN as well.
+    if (initialCapacity < 0 || ! (loadFactor > 0))
+      throw new IllegalArgumentException();
+    if (initialCapacity == 0)
+      initialCapacity = 1;
+    this.loadFactor = loadFactor;
+    threshold = (int) (initialCapacity * loadFactor);
+    theEntrySet = new WeakEntrySet();
+    queue = new ReferenceQueue();
+    buckets = new WeakBucket[initialCapacity];
+  }
+
+  /**
+   * Construct a new WeakHashMap with the same mappings as the given map.
+   * The WeakHashMap has a default load factor of 0.75.
+   *
+   * @param m the map to copy
+   * @throws NullPointerException if m is null
+   * @since 1.3
+   */
+  public WeakHashMap(Map m)
+  {
+    this(m.size(), DEFAULT_LOAD_FACTOR);
+    putAll(m);
+  }
+
+  /**
+   * Simply hashes a non-null Object to its array index.
+   * @param key the key to hash
+   * @return its slot number
+   */
+  private int hash(Object key)
+  {
+    return Math.abs(key.hashCode() % buckets.length);
+  }
+
+  /**
+   * Cleans the reference queue.  This will poll all references (which
+   * are WeakBuckets) from the queue and remove them from this map.
+   * This will not change modCount, even if it modifies the map.  The
+   * iterators have to make sure that nothing bad happens.  <br>
+   *
+   * Currently the iterator maintains a strong reference to the key, so
+   * that is no problem.
+   */
+  // Package visible for use by nested classes.
+  void cleanQueue()
+  {
+    Object bucket = queue.poll();
+    while (bucket != null)
+      {
+        internalRemove((WeakBucket) bucket);
+        bucket = queue.poll();
+      }
+  }
+
+  /**
+   * Rehashes this hashtable.  This will be called by the
+   * <code>add()</code> method if the size grows beyond the threshold.
+   * It will grow the bucket size at least by factor two and allocates
+   * new buckets.
+   */
+  private void rehash()
+  {
+    WeakBucket[] oldBuckets = buckets;
+    int newsize = buckets.length * 2 + 1; // XXX should be prime.
+    threshold = (int) (newsize * loadFactor);
+    buckets = new WeakBucket[newsize];
+
+    // Now we have to insert the buckets again.
+    for (int i = 0; i < oldBuckets.length; i++)
+      {
+        WeakBucket bucket = oldBuckets[i];
+        WeakBucket nextBucket;
+        while (bucket != null)
+          {
+            nextBucket = bucket.next;
+
+            Object key = bucket.get();
+            if (key == null)
+              {
+                // This bucket should be removed; it is probably
+                // already on the reference queue.  We don't insert it
+                // at all, and mark it as cleared.
+                bucket.slot = -1;
+                size--;
+              }
+            else
+              {
+                // Add this bucket to its new slot.
+                int slot = hash(key);
+                bucket.slot = slot;
+                bucket.next = buckets[slot];
+                buckets[slot] = bucket;
+              }
+            bucket = nextBucket;
+          }
+      }
+  }
+
+  /**
+   * Finds the entry corresponding to key.  Since it returns an Entry
+   * it will also prevent the key from being removed under us.
+   * @param key the key, may be null
+   * @return The WeakBucket.WeakEntry or null, if the key wasn't found.
+   */
+  private WeakBucket.WeakEntry internalGet(Object key)
+  {
+    if (key == null)
+      key = NULL_KEY;
+    int slot = hash(key);
+    WeakBucket bucket = buckets[slot];
+    while (bucket != null)
+      {
+        WeakBucket.WeakEntry entry = bucket.getEntry();
+        if (entry != null && equals(key, entry.key))
+          return entry;
+
+        bucket = bucket.next;
+      }
+    return null;
+  }
+
+  /**
+   * Adds a new key/value pair to the hash map.
+   * @param key the key. This mustn't exists in the map. It may be null.
+   * @param value the value.
+   */
+  private void internalAdd(Object key, Object value)
+  {
+    if (key == null)
+      key = NULL_KEY;
+    int slot = hash(key);
+    WeakBucket bucket = new WeakBucket(key, queue, value, slot);
+    bucket.next = buckets[slot];
+    buckets[slot] = bucket;
+    size++;
+  }
+
+  /**
+   * Removes a bucket from this hash map, if it wasn't removed before
+   * (e.g. one time through rehashing and one time through reference queue).
+   * Package visible for use in nested classes.
+   *
+   * @param bucket the bucket to remove.
+   */
+  void internalRemove(WeakBucket bucket)
+  {
+    int slot = bucket.slot;
+    if (slot == -1)
+      // This bucket was already removed.
+      return;
+
+    // Mark the bucket as removed.  This is necessary, since the
+    // bucket may be enqueued later by the garbage collection, and
+    // internalRemove will be called a second time.
+    bucket.slot = -1;
+
+    WeakBucket prev = null;
+    WeakBucket next = buckets[slot];
+    while (next != bucket)
+      {
+         if (next == null) throw new InternalError("WeakHashMap in incosistent state");
+         prev = next; 
+         next = prev.next;
+      }
+    if (prev == null)
+      buckets[slot] = bucket.next;
+    else 
+      prev.next = bucket.next;
+
+    size--;
+  }
+
+  /**
+   * Returns the size of this hash map.  Note that the size() may shrink
+   * spontaneously, if the some of the keys were only weakly reachable.
+   * @return the number of entries in this hash map.
+   */
+  public int size()
+  {
+    cleanQueue();
+    return size;
+  }
+
+  /**
+   * Tells if the map is empty.  Note that the result may change
+   * spontanously, if all of the keys were only weakly reachable.
+   * @return true, iff the map is empty.
+   */
+  public boolean isEmpty()
+  {
+    cleanQueue();
+    return size == 0;
+  }
+
+  /**
+   * Tells if the map contains the given key.  Note that the result
+   * may change spontanously, if the key was only weakly
+   * reachable.
+   * @param key the key to look for
+   * @return true, iff the map contains an entry for the given key.
+   */
+  public boolean containsKey(Object key)
+  {
+    cleanQueue();
+    return internalGet(key) != null;
+  }
+
+  /**
+   * Gets the value the key is mapped to.
+   * @return the value the key was mapped to.  It returns null if
+   *         the key wasn't in this map, or if the mapped value was
+   *         explicitly set to null.
+   */
+  public Object get(Object key)
+  {
+    cleanQueue();
+    WeakBucket.WeakEntry entry = internalGet(key);
+    return entry == null ? null : entry.getValue();
+  }
+
+  /**
+   * Adds a new key/value mapping to this map.
+   * @param key the key, may be null
+   * @param value the value, may be null
+   * @return the value the key was mapped to previously.  It returns
+   *         null if the key wasn't in this map, or if the mapped value
+   *         was explicitly set to null.
+   */
+  public Object put(Object key, Object value)
+  {
+    cleanQueue();
+    WeakBucket.WeakEntry entry = internalGet(key);
+    if (entry != null)
+      return entry.setValue(value);
+
+    modCount++;
+    if (size >= threshold)
+      rehash();
+
+    internalAdd(key, value);
+    return null;
+  }
+
+  /**
+   * Removes the key and the corresponding value from this map.
+   * @param key the key. This may be null.
+   * @return the value the key was mapped to previously.  It returns
+   *         null if the key wasn't in this map, or if the mapped value was
+   *         explicitly set to null.
+   */
+  public Object remove(Object key)
+  {
+    cleanQueue();
+    WeakBucket.WeakEntry entry = internalGet(key);
+    if (entry == null)
+      return null;
+
+    modCount++;
+    internalRemove(entry.getBucket());
+    return entry.getValue();
+  }
+
+  /**
+   * Returns a set representation of the entries in this map.  This
+   * set will not have strong references to the keys, so they can be
+   * silently removed.  The returned set has therefore the same
+   * strange behaviour (shrinking size(), disappearing entries) as
+   * this weak hash map.
+   * @return a set representation of the entries.
+   */
+  public Set entrySet()
+  {
+    cleanQueue();
+    return theEntrySet;
+  }
+
+  /**
+   * Clears all entries from this map.
+   */
+  public void clear()
+  {
+    super.clear();
+  }
+
+  /**
+   * Returns true if the map contains at least one key which points to
+   * the specified object as a value.  Note that the result
+   * may change spontanously, if its key was only weakly reachable.
+   * @param value the value to search for
+   * @return true if it is found in the set.
+   */
+  public boolean containsValue(Object value)
+  {
+    cleanQueue();
+    return super.containsValue(value);
+  }
+
+  /**
+   * Returns a set representation of the keys in this map.  This
+   * set will not have strong references to the keys, so they can be
+   * silently removed.  The returned set has therefore the same
+   * strange behaviour (shrinking size(), disappearing entries) as
+   * this weak hash map.
+   * @return a set representation of the keys.
+   */
+  public Set keySet()
+  {
+    cleanQueue();
+    return super.keySet();
+  }
+
+  /**
+   * Puts all of the mappings from the given map into this one. If the
+   * key already exists in this map, its value is replaced.
+   * @param m the map to copy in
+   */
+  public void putAll(Map m)
+  {
+    super.putAll(m);
+  }
+
+  /**
+   * Returns a collection representation of the values in this map.  This
+   * collection will not have strong references to the keys, so mappings
+   * can be silently removed.  The returned collection has therefore the same
+   * strange behaviour (shrinking size(), disappearing entries) as
+   * this weak hash map.
+   * @return a collection representation of the values.
+   */
+  public Collection values()
+  {
+    cleanQueue();
+    return super.values();
+  }
+} // class WeakHashMap

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/Attributes.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/Attributes.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/Attributes.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/Attributes.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,629 @@
+/* Attributes.java -- Represents attribute name/value pairs from a Manifest
+   Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.jar;
+
+import gnu.java.util.jar.JarUtils;
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Represents attribute name/value pairs from a Manifest as a Map.
+ * The names of an attribute are represented by the
+ * <code>Attributes.Name</code> class and should confirm to the restrictions
+ * described in that class. Note that the Map interface that Attributes
+ * implements allows you to put names and values into the attribute that don't
+ * follow these restriction (and are not really Atrribute.Names, but if you do
+ * that it might cause undefined behaviour later).
+ * <p>
+ * If you use the constants defined in the inner class Name then you can be
+ * sure that you always access the right attribute names. This makes
+ * manipulating the Attributes more or less type safe.
+ * <p>
+ * Most of the methods are wrappers to implement the Map interface. The really
+ * useful and often used methods are <code>getValue(Name)</code> and
+ * <code>getValue(String)</code>. If you actually want to set attributes you
+ * may want to use the <code>putValue(String, String)</code> method
+ * (sorry there is no public type safe <code>putValue(Name, String)</code>
+ * method).
+ *
+ * @see java.util.jar.Attributes.Name
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+public class Attributes
+  implements Cloneable, java.util.Map // Fully qualified for jikes 1.22
+{
+
+  // Fields
+
+  /**
+   * The map that holds all the attribute name/value pairs. In this
+   * implementation it is actually a Hashtable, but that can be different in
+   * other implementations.
+   */
+  protected Map map;
+
+  // Inner class
+
+  /**
+   * Represents a name of a Manifest Attribute. Defines a couple of well
+   * know names for the general main attributes, stand alone application
+   * attributes, applet attributes, extension identification attributes,
+   * package versioning and sealing attributes, file contents attributes,
+   * bean objects attribute and signing attributes. See the 
+   * 
+   * <p>The characters of a Name must obey the following restrictions:</p>
+   * 
+   * <ul>
+   * <li>Must contain at least one character</li>
+   * <li>The first character must be alphanumeric (a-z, A-Z, 0-9)</li>
+   * <li>All other characters must be alphanumeric, a '-' or a '_'</li>
+   * </ul>
+   * 
+   * <p>When comparing Names (with <code>equals</code>) all characters are
+   * converted to lowercase. But you can get the original case sensitive
+   * string with the <code>toString()</code> method.</p>
+   *
+   * <p>Most important attributes have a constant defined in this
+   * class. Some other attributes used in Manifest files are:
+   * <ul>
+   * <li> "Created-By" - General main attribute, tool and version
+   * that created this Manifest file.</li>
+   * <li> "Java-Bean" - Bean objects attribute, whether the entry is a Bean.
+   * Value is either "true" or "false".</li>
+   * <li> "Magic" - Signing attribute, application specific signing attribute.
+   * Must be understood by the manifest parser when present to validate the
+   * jar (entry).</li>
+   * </ul>
+   *
+   * @since 1.2
+   * @author Mark Wielaard (mark at klomp.org)
+   */
+  public static class Name
+  {
+    // General Main Attributes
+
+    /**
+     * General main attribute -
+     * the version of this Manifest file.
+     */
+    public static final Name MANIFEST_VERSION = new Name(JarUtils.MANIFEST_VERSION);
+    
+    /**
+     * General main attribute -
+     * the version of the jar file signature.
+     */
+    public static final Name SIGNATURE_VERSION = new Name(JarUtils.SIGNATURE_VERSION);
+    
+    /**
+     * General main attribute -
+     * (relative) file paths of the libraries/classpaths that the Classes in
+     * this jar file depend on. Paths are separated by spaces.
+     */
+    public static final Name CLASS_PATH = new Name("Class-Path");
+
+    /**
+     * Stand alone application attribute -
+     * the entry (without the .class ending) that is the main
+     * class of this jar file.
+     */
+    public static final Name MAIN_CLASS = new Name("Main-Class");
+
+    /**
+     * Applet attribute -
+     * a list of extension libraries that the applet in this
+     * jar file depends on.
+     * For every named extension there should be some Attributes in the
+     * Manifest manifest file with the following Names:
+     * <ul>
+     * <li> <extension>-Extension-Name:
+     * unique name of the extension</li>
+     * <li> <extension>-Specification-Version:
+     * minimum specification version</li>
+     * <li> <extension>-Implementation-Version:
+     * minimum implementation version</li>
+     * <li> <extension>-Implementation-Vendor-Id:
+     * unique id of implementation vendor</li>
+     * <li> <extension>-Implementation-URL:
+     * where the latest version of the extension library can be found</li>
+     * </ul>
+     */
+    public static final Name EXTENSION_LIST = new Name("Extension-List");
+
+    /**
+     * Extension identification attribute -
+     * the name if the extension library contained in the jar.
+     */
+    public static final Name EXTENSION_NAME = new Name("Extension-Name");
+    
+    /**
+     * Extension identification attribute -
+     * synonym for <code>EXTENSTION_NAME</code>.
+     */
+    public static final Name EXTENSION_INSTALLATION = EXTENSION_NAME;
+
+    // Package versioning and sealing attributes
+    
+    /**
+     * Package versioning -
+     * name of extension library contained in this jar.
+     */
+    public static final Name IMPLEMENTATION_TITLE
+      = new Name("Implementation-Title");
+    
+    /**
+     * Package versioning -
+     * version of the extension library contained in this jar.
+     */
+    public static final Name IMPLEMENTATION_VERSION
+      = new Name("Implementation-Version");
+    
+    /**
+     * Package versioning -
+     * name of extension library creator contained in this jar.
+     */
+    public static final Name IMPLEMENTATION_VENDOR
+      = new Name("Implementation-Vendor");
+    
+    /**
+     * Package versioning -
+     * unique id of extension library creator.
+     */
+    public static final Name IMPLEMENTATION_VENDOR_ID
+      = new Name("Implementation-Vendor-Id");
+    
+    /**
+     * Package versioning -
+     * location where this implementation can be downloaded.
+     */
+    public static final Name IMPLEMENTATION_URL
+      = new Name("Implementation-URL");
+    
+    /**
+     * Package versioning -
+     * title of the specification contained in this jar.
+     */
+    public static final Name SPECIFICATION_TITLE
+      = new Name("Specification-Title");
+
+    /**
+     * Package versioning -
+     * version of the specification contained in this jar.
+     */
+    public static final Name SPECIFICATION_VERSION
+      = new Name("Specification-Version");
+
+    /**
+     * Package versioning -
+     * organisation that maintains the specification contains in this
+     * jar.
+     */
+    public static final Name SPECIFICATION_VENDOR
+      = new Name("Specification-Vendor");
+
+    /**
+     * Package sealing -
+     * whether (all) package(s) is(/are) sealed. Value is either "true"
+     * or "false".
+     */
+    public static final Name SEALED = new Name("Sealed");
+
+    /**
+     * File contents attribute -
+     * Mime type and subtype for the jar entry.
+     */
+    public static final Name CONTENT_TYPE = new Name("Content-Type");
+
+    /** The (lowercase) String representation of this Name */
+    private final String name;
+
+    /** The original String given to the constructor */
+    private final String origName;
+
+    // Constructor
+
+    /**
+     * Creates a new Name from the given String.
+     * Throws an IllegalArgumentException if the given String is empty or
+     * contains any illegal Name characters.
+     * 
+     * @param name the name of the new Name
+     * @exception IllegalArgumentException if name isn't a valid String
+     * representation of a Name
+     * @exception NullPointerException if name is null
+     */
+    public Name(String name) throws IllegalArgumentException,
+      NullPointerException
+    {
+      // name must not be null
+      // this will throw a NullPointerException if it is
+      char chars[] = name.toCharArray();
+
+      // there must be at least one character
+      if (chars.length == 0)
+	throw new
+	  IllegalArgumentException
+	  ("There must be at least one character in a name");
+
+      // first character must be alphanum
+      char c = chars[0];
+      if (!((c >= 'a' && c <= 'z') ||
+	    (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')))
+	throw new
+	  IllegalArgumentException("First character must be alphanum");
+
+      // all other characters must be alphanums, '-' or '_'
+      for (int i = 1; i < chars.length; i++)
+	{
+	  c = chars[i];
+	  if (!((c >= 'a' && c <= 'z') ||
+		(c >= 'A' && c <= 'Z') ||
+		(c >= '0' && c <= '9') || (c == '-') || (c == '_')))
+	    throw new
+	      IllegalArgumentException
+	      ("Characters must be alphanums, '-' or '_'");
+	}
+
+      // Still here? Then convert to lower case and be done.
+      // Store the original name for toString();
+      this.origName = name;
+      this.name = name.toLowerCase();
+    }
+
+    /**
+     * Returns the hash code of the (lowercase) String representation of
+     * this Name.
+     */
+    public int hashCode()
+    {
+      return name.hashCode();
+    }
+
+    /**
+     * Checks if another object is equal to this Name object.
+     * Another object is equal to this Name object if it is an instance of
+     * Name and the (lowercase) string representation of the name is equal.
+     */
+    public boolean equals(Object o)
+    {
+      // Quick and dirty check
+      if (name == o)
+	return true;
+
+      try
+	{
+	  // Note that the constructor already converts the strings to
+	  // lowercase.
+	  String otherName = ((Name) o).name;
+	  return name.equals(otherName);
+	}
+      catch (ClassCastException cce)
+	{
+	  return false;
+	}
+      catch (NullPointerException npe)
+	{
+	  return false;
+	}
+    }
+
+    /**
+     * Returns the string representation of this Name as given to the
+     * constructor (not neccesarily the lower case representation).
+     */
+    public String toString()
+    {
+      return origName;
+    }
+  }
+
+  // Constructors
+
+  /**
+   * Creates an empty Attributes map.
+   */
+  public Attributes()
+  {
+    map = new Hashtable();
+  }
+
+  /**
+   * Creates an empty Attributes map with the given initial size.
+   * @param size the initial size of the underlying map
+   */
+  public Attributes(int size)
+  {
+    map = new Hashtable(size);
+  }
+
+  /**
+   * Creates an Attributes map with the initial values taken from another
+   * Attributes map.
+   * @param attr Attributes map to take the initial values from
+   */
+  public Attributes(Attributes attr)
+  {
+    map = new Hashtable(attr.map);
+  }
+
+  // Methods
+
+  /**
+   * Gets the value of an attribute name given as a String.
+   *
+   * @param name a String describing the Name to look for
+   * @return the value gotten from the map of null when not found
+   */
+  public String getValue(String name)
+  {
+    return (String) get(new Name(name));
+  }
+
+  /**
+   * Gets the value of the given attribute name.
+   *
+   * @param name the Name to look for
+   * @return the value gotten from the map of null when not found
+   */
+  public String getValue(Name name)
+  {
+    return (String) get(name);
+  }
+
+  /**
+   * Stores an attribute name (represented by a String) and value in this
+   * Attributes map.
+   * When the (case insensitive string) name already exists the value is
+   * replaced and the old value is returned.
+   *
+   * @param name a (case insensitive) String representation of the attribite
+   * name to add/replace
+   * @param value the (new) value of the attribute name
+   * @returns the old value of the attribute name or null if it didn't exist
+   * yet
+   */
+  public String putValue(String name, String value)
+  {
+    return putValue(new Name(name), value);
+  }
+
+  /**
+   * Stores an attribute name (represented by a String) and value in this
+   * Attributes map.
+   * When the name already exists the value is replaced and the old value
+   * is returned.
+   *
+   * @param name the attribite name to add/replace
+   * @param value the (new) value of the attribute name
+   * @returns the old value of the attribute name or null if it didn't exist
+   * yet
+   */
+  private String putValue(Name name, String value)
+  {
+    return (String) put(name, value);
+  }
+
+  // Methods from Cloneable interface
+
+  /**
+   * Return a clone of this attribute map.
+   */
+  public Object clone()
+  {
+    return new Attributes(this);
+  }
+
+  // Methods from Map interface
+
+  /**
+   * Removes all attributes.
+   */
+  public void clear()
+  {
+    map.clear();
+  }
+
+  /**
+   * Checks to see if there is an attribute with the specified name.
+   * XXX - what if the object is a String?
+   *
+   * @param attrName the name of the attribute to check
+   * @return true if there is an attribute with the specified name, false
+   * otherwise
+   */
+  public boolean containsKey(Object attrName)
+  {
+    return map.containsKey(attrName);
+  }
+
+  /**
+   * Checks to see if there is an attribute name with the specified value.
+   *
+   * @param attrValue the value of a attribute to check
+   * @return true if there is an attribute name with the specified value,
+   * false otherwise
+   */
+  public boolean containsValue(Object attrValue)
+  {
+    return map.containsValue(attrValue);
+  }
+
+  /**
+   * Gives a Set of attribute name and values pairs as MapEntries.
+   * @see java.util.Map.Entry
+   * @see java.util.Map#entrySet()
+   *
+   * @return a set of attribute name value pairs
+   */
+  public Set entrySet()
+  {
+    return map.entrySet();
+  }
+
+  /**
+   * Checks to see if two Attributes are equal. The supplied object must be
+   * a real instance of Attributes and contain the same attribute name/value
+   * pairs.
+   *
+   * @param o another Attribute object which should be checked for equality
+   * @return true if the object is an instance of Attributes and contains the
+   * same name/value pairs, false otherwise
+   */
+  public boolean equals(Object o)
+  {
+    // quick and dirty check
+    if (this == o)
+      return true;
+
+    try
+      {
+	return map.equals(((Attributes) o).map);
+      }
+    catch (ClassCastException cce)
+      {
+	return false;
+      }
+    catch (NullPointerException npe)
+      {
+	return false;
+      }
+  }
+
+  /**
+   * Gets the value of a specified attribute name.
+   * XXX - what if the object is a String?
+   *
+   * @param attrName the name of the attribute we want the value of
+   * @return the value of the specified attribute name or null when there is
+   * no such attribute name
+   */
+  public Object get(Object attrName)
+  {
+    return map.get(attrName);
+  }
+
+  /**
+   * Returns the hashcode of the attribute name/value map.
+   */
+  public int hashCode()
+  {
+    return map.hashCode();
+  }
+
+  /**
+   * Returns true if there are no attributes set, false otherwise.
+   */
+  public boolean isEmpty()
+  {
+    return map.isEmpty();
+  }
+
+  /**
+   * Gives a Set of all the values of defined attribute names.
+   */
+  public Set keySet()
+  {
+    return map.keySet();
+  }
+
+  /**
+   * Adds or replaces a attribute name/value pair.
+   * XXX - What if the name is a string? What if the name is neither a Name
+   * nor a String? What if the value is not a string?
+   *
+   * @param name the name of the attribute
+   * @param value the (new) value of the attribute
+   * @return the old value of the attribute or null when there was no old
+   * attribute with this name
+   */
+  public Object put(Object name, Object value)
+  {
+    return map.put(name, value);
+  }
+
+  /**
+   * Adds or replaces all attribute name/value pairs from another
+   * Attributes object to this one. The supplied Map must be an instance of
+   * Attributes.
+   *
+   * @param attr the Attributes object to merge with this one
+   * @exception ClassCastException if the supplied map is not an instance of
+   * Attributes
+   */
+  public void putAll(Map attr)
+  {
+    if (!(attr instanceof Attributes))
+      {
+	throw new
+	  ClassCastException("Supplied Map is not an instance of Attributes");
+      }
+    map.putAll(attr);
+  }
+
+  /**
+   * Remove a attribute name/value pair.
+   * XXX - What if the name is a String?
+   *
+   * @param name the name of the attribute name/value pair to remove
+   * @return the old value of the attribute or null if the attribute didn't
+   * exist
+   */
+  public Object remove(Object name)
+  {
+    return map.remove(name);
+  }
+
+  /**
+   * Returns the number of defined attribute name/value pairs.
+   */
+  public int size()
+  {
+    return map.size();
+  }
+
+  /**
+   * Returns all the values of the defined attribute name/value pairs as a
+   * Collection.
+   */
+  public Collection values()
+  {
+    return map.values();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarEntry.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarEntry.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarEntry.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarEntry.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,165 @@
+/* JarEntry.java - Represents an entry in a jar file
+   Copyright (C) 2000 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.jar;
+
+import java.io.IOException;
+import java.security.cert.Certificate;
+import java.util.zip.ZipEntry;
+
+/**
+ * Extension to a ZipEntry that contains manifest attributes and certificates.
+ * Both the Atrributes and the Certificates can be null when not set.
+ * Note that the <code>getCertificates()</code> method only returns a
+ * valid value after all of the data of the entry has been read.
+ * <p>
+ * There are no public methods to set the attributes or certificate of an
+ * Entru. Only JarEntries created by the classes in <code>java.util.jar</code>
+ * will have these properties set.
+ *
+ * @since 1.2
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+
+public class JarEntry extends ZipEntry
+{
+  // (Package local) fields
+
+  Attributes attr;
+  Certificate certs[];
+
+  // Constructors
+
+  /**
+   * Creates a new JarEntry with the specified name and no attributes or
+   * or certificates. Calls <code>super(name)</code> so all other (zip)entry
+   * fields are null or -1.
+   *
+   * @param name the name of the new jar entry
+   * @exception NullPointerException when the supplied name is null
+   * @exception IllegalArgumentException when the supplied name is longer
+   * than 65535 bytes
+   */
+  public JarEntry(String name) throws NullPointerException,
+    IllegalArgumentException
+  {
+    super(name);
+    attr = null;
+    certs = null;
+  }
+
+  /**
+   * Creates a new JarEntry with the specified ZipEntry as template for
+   * all properties of the entry. Both attributes and certificates will be
+   * null.
+   *
+   * @param entry the ZipEntry whose fields should be copied
+   */
+  public JarEntry(ZipEntry entry)
+  {
+    super(entry);
+    attr = null;
+    certs = null;
+  }
+
+  /**
+   * Creates a new JarEntry with the specified JarEntry as template for
+   * all properties of the entry.
+   *
+   * @param entry the jarEntry whose fields should be copied
+   */
+  public JarEntry(JarEntry entry)
+  {
+    super(entry);
+    try
+      {
+	attr = entry.getAttributes();
+      }
+    catch (IOException _)
+      {
+      }
+    certs = entry.getCertificates();
+  }
+
+  // Methods
+
+  /**
+   * Returns a copy of the Attributes set for this entry.
+   * When no Attributes are set in the manifest null is returned.
+   *
+   * @return a copy of the Attributes set for this entry
+   * @exception IOException This will never be thrown. It is here for
+   * binary compatibility.
+   */
+  public Attributes getAttributes() throws IOException
+  {
+    if (attr != null)
+      {
+	return (Attributes) attr.clone();
+      }
+    else
+      {
+	return null;
+      }
+  }
+
+  /**
+   * Returns a copy of the certificates set for this entry.
+   * When no certificates are set or when not all data of this entry has
+   * been read null is returned.
+   * <p>
+   * To make sure that this call returns a valid value you must read all
+   * data from the JarInputStream for this entry.
+   * When you don't need the data for an entry but want to know the
+   * certificates that are set for the entry then you can skip all data by
+   * calling <code>skip(entry.getSize())</code> on the JarInputStream for
+   * the entry.
+   *
+   * @return a copy of the certificates set for this entry
+   */
+  public Certificate[] getCertificates()
+  {
+    if (certs != null)
+      {
+	return (Certificate[])certs.clone();
+      }
+    else
+      {
+	return null;
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,77 @@
+/* JarException.java -- thrown to indicate an problem with a jar file
+   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.jar;
+
+import java.util.zip.ZipException;
+
+/**
+ * This exception is thrown to indicate an problem with a jar file.
+ * Note that none of the methods in the java.util.jar package actually declare
+ * to throw this exception, most just declare that they throw an IOException
+ * which is super class of JarException.
+ *
+ * @author Mark Wielaard (mark at klomp.org)
+ * @since 1.2
+ */
+public class JarException extends ZipException
+{
+  /**
+   * Compatible with JDK 1.2+.
+   */
+  private static final long serialVersionUID = 7159778400963954473L;
+
+  /**
+   * Create a new JarException without a descriptive error message.
+   */
+  public JarException()
+  {
+  }
+
+  /**
+   * Create a new JarException with a descriptive error message indicating
+   * what went wrong. This message can later be retrieved by calling the
+   * <code>getMessage()</code> method.
+   *
+   * @param message The descriptive error message
+   * @see #getMessage()
+   */
+  public JarException(String message)
+  {
+    super(message);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarFile.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarFile.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarFile.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarFile.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1069 @@
+/* JarFile.java - Representation of a jar file
+   Copyright (C) 2000, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.jar;
+
+import gnu.java.io.Base64InputStream;
+import gnu.java.security.OID;
+import gnu.java.security.pkcs.PKCS7SignedData;
+import gnu.java.security.pkcs.SignerInfo;
+import gnu.java.security.provider.Gnu;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.InvalidKeyException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.Signature;
+import java.security.SignatureException;
+import java.security.cert.CRLException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+
+/**
+ * Representation of a jar file.
+ * <p>
+ * Note that this class is not a subclass of java.io.File but a subclass of
+ * java.util.zip.ZipFile and you can only read JarFiles with it (although
+ * there are constructors that take a File object).
+ *
+ * @since 1.2
+ * @author Mark Wielaard (mark at klomp.org)
+ * @author Casey Marshall (csm at gnu.org) wrote the certificate and entry
+ *  verification code.
+ */
+public class JarFile extends ZipFile
+{
+  // Fields
+
+  /** The name of the manifest entry: META-INF/MANIFEST.MF */
+  public static final String MANIFEST_NAME = "META-INF/MANIFEST.MF";
+
+  /** The META-INF directory entry. */
+  private static final String META_INF = "META-INF/";
+
+  /** The suffix for PKCS7 DSA signature entries. */
+  private static final String PKCS7_DSA_SUFFIX = ".DSA";
+
+  /** The suffix for PKCS7 RSA signature entries. */
+  private static final String PKCS7_RSA_SUFFIX = ".RSA";
+
+  /** The suffix for digest attributes. */
+  private static final String DIGEST_KEY_SUFFIX = "-Digest";
+
+  /** The suffix for signature files. */
+  private static final String SF_SUFFIX = ".SF";
+
+  /**
+   * The security provider to use for signature verification.
+   * We need a known fallback to be able to read any signed jar file
+   * (which might contain the user selected security provider).
+   * This is package-private to avoid accessor methods for inner classes.
+   */
+  static final Gnu provider = new Gnu();
+
+  // Signature OIDs.
+  private static final OID MD2_OID = new OID("1.2.840.113549.2.2");
+  private static final OID MD4_OID = new OID("1.2.840.113549.2.4");
+  private static final OID MD5_OID = new OID("1.2.840.113549.2.5");
+  private static final OID SHA1_OID = new OID("1.3.14.3.2.26");
+  private static final OID DSA_ENCRYPTION_OID = new OID("1.2.840.10040.4.1");
+  private static final OID RSA_ENCRYPTION_OID = new OID("1.2.840.113549.1.1.1");
+
+  /**
+   * The manifest of this file, if any, otherwise null.
+   * Read when first needed.
+   */
+  private Manifest manifest;
+
+  /** Whether to verify the manifest and all entries. */
+  boolean verify;
+
+  /** Whether the has already been loaded. */
+  private boolean manifestRead = false;
+
+  /** Whether the signature files have been loaded. */
+  boolean signaturesRead = false;
+
+  /**
+   * A map between entry names and booleans, signaling whether or
+   * not that entry has been verified.
+   * Only be accessed with lock on this JarFile*/
+  HashMap verified = new HashMap();
+
+  /**
+   * A mapping from entry name to certificates, if any.
+   * Only accessed with lock on this JarFile.
+   */
+  HashMap entryCerts;
+
+  static boolean DEBUG = false;
+  static void debug(Object msg)
+  {
+    System.err.print(JarFile.class.getName());
+    System.err.print(" >>> ");
+    System.err.println(msg);
+  }
+
+  // Constructors
+
+  /**
+   * Creates a new JarFile. All jar entries are verified (when a Manifest file
+   * for this JarFile exists). You need to actually open and read the complete
+   * jar entry (with <code>getInputStream()</code>) to check its signature.
+   *
+   * @param fileName the name of the file to open
+   * @exception FileNotFoundException if the fileName cannot be found
+   * @exception IOException if another IO exception occurs while reading
+   */
+  public JarFile(String fileName) throws FileNotFoundException, IOException
+  {
+    this(fileName, true);
+  }
+
+  /**
+   * Creates a new JarFile. If verify is true then all jar entries are
+   * verified (when a Manifest file for this JarFile exists). You need to
+   * actually open and read the complete jar entry
+   * (with <code>getInputStream()</code>) to check its signature.
+   *
+   * @param fileName the name of the file to open
+   * @param verify checks manifest and entries when true and a manifest
+   * exists, when false no checks are made
+   * @exception FileNotFoundException if the fileName cannot be found
+   * @exception IOException if another IO exception occurs while reading
+   */
+  public JarFile(String fileName, boolean verify) throws
+    FileNotFoundException, IOException
+  {
+    super(fileName);
+    if (verify)
+      {
+	manifest = readManifest();
+	verify();
+      }
+  }
+
+  /**
+   * Creates a new JarFile. All jar entries are verified (when a Manifest file
+   * for this JarFile exists). You need to actually open and read the complete
+   * jar entry (with <code>getInputStream()</code>) to check its signature.
+   *
+   * @param file the file to open as a jar file
+   * @exception FileNotFoundException if the file does not exits
+   * @exception IOException if another IO exception occurs while reading
+   */
+  public JarFile(File file) throws FileNotFoundException, IOException
+  {
+    this(file, true);
+  }
+
+  /**
+   * Creates a new JarFile. If verify is true then all jar entries are
+   * verified (when a Manifest file for this JarFile exists). You need to
+   * actually open and read the complete jar entry
+   * (with <code>getInputStream()</code>) to check its signature.
+   *
+   * @param file the file to open to open as a jar file
+   * @param verify checks manifest and entries when true and a manifest
+   * exists, when false no checks are made
+   * @exception FileNotFoundException if file does not exist
+   * @exception IOException if another IO exception occurs while reading
+   */
+  public JarFile(File file, boolean verify) throws FileNotFoundException,
+    IOException
+  {
+    super(file);
+    if (verify)
+      {
+	manifest = readManifest();
+	verify();
+      }
+  }
+
+  /**
+   * Creates a new JarFile with the indicated mode. If verify is true then
+   * all jar entries are verified (when a Manifest file for this JarFile
+   * exists). You need to actually open and read the complete jar entry
+   * (with <code>getInputStream()</code>) to check its signature.
+   * manifest and if the manifest exists and verify is true verfies it.
+   *
+   * @param file the file to open to open as a jar file
+   * @param verify checks manifest and entries when true and a manifest
+   * exists, when false no checks are made
+   * @param mode either ZipFile.OPEN_READ or
+   *             (ZipFile.OPEN_READ | ZipFile.OPEN_DELETE)
+   * @exception FileNotFoundException if the file does not exist
+   * @exception IOException if another IO exception occurs while reading
+   * @exception IllegalArgumentException when given an illegal mode
+   * 
+   * @since 1.3
+   */
+  public JarFile(File file, boolean verify, int mode) throws
+    FileNotFoundException, IOException, IllegalArgumentException
+  {
+    super(file, mode);
+    if (verify)
+      {
+	manifest = readManifest();
+	verify();
+      }
+  }
+
+  // Methods
+
+  /**
+   * XXX - should verify the manifest file
+   */
+  private void verify()
+  {
+    // only check if manifest is not null
+    if (manifest == null)
+      {
+	verify = false;
+	return;
+      }
+
+    verify = true;
+    // XXX - verify manifest
+  }
+
+  /**
+   * Parses and returns the manifest if it exists, otherwise returns null.
+   */
+  private Manifest readManifest()
+  {
+    try
+      {
+	ZipEntry manEntry = super.getEntry(MANIFEST_NAME);
+	if (manEntry != null)
+	  {
+	    InputStream in = super.getInputStream(manEntry);
+	    manifestRead = true;
+	    return new Manifest(in);
+	  }
+	else
+	  {
+	    manifestRead = true;
+	    return null;
+	  }
+      }
+    catch (IOException ioe)
+      {
+	manifestRead = true;
+	return null;
+      }
+  }
+
+  /**
+   * Returns a enumeration of all the entries in the JarFile.
+   * Note that also the Jar META-INF entries are returned.
+   *
+   * @exception IllegalStateException when the JarFile is already closed
+   */
+  public Enumeration entries() throws IllegalStateException
+  {
+    return new JarEnumeration(super.entries(), this);
+  }
+
+  /**
+   * Wraps a given Zip Entries Enumeration. For every zip entry a
+   * JarEntry is created and the corresponding Attributes are looked up.
+   */
+  private static class JarEnumeration implements Enumeration
+  {
+
+    private final Enumeration entries;
+    private final JarFile jarfile;
+
+    JarEnumeration(Enumeration e, JarFile f)
+    {
+      entries = e;
+      jarfile = f;
+    }
+
+    public boolean hasMoreElements()
+    {
+      return entries.hasMoreElements();
+    }
+
+    public Object nextElement()
+    {
+      ZipEntry zip = (ZipEntry) entries.nextElement();
+      JarEntry jar = new JarEntry(zip);
+      Manifest manifest;
+      try
+	{
+	  manifest = jarfile.getManifest();
+	}
+      catch (IOException ioe)
+	{
+	  manifest = null;
+	}
+
+      if (manifest != null)
+	{
+	  jar.attr = manifest.getAttributes(jar.getName());
+	}
+
+      synchronized(jarfile)
+	{
+	  if (jarfile.verify && !jarfile.signaturesRead)
+	    try
+	      {
+		jarfile.readSignatures();
+	      }
+	    catch (IOException ioe)
+	      {
+		if (JarFile.DEBUG)
+		  {
+		    JarFile.debug(ioe);
+		    ioe.printStackTrace();
+		  }
+		jarfile.signaturesRead = true; // fudge it.
+	      }
+
+	  // Include the certificates only if we have asserted that the
+	  // signatures are valid. This means the certificates will not be
+	  // available if the entry hasn't been read yet.
+	  if (jarfile.entryCerts != null
+	      && jarfile.verified.get(zip.getName()) == Boolean.TRUE)
+	    {
+	      Set certs = (Set) jarfile.entryCerts.get(jar.getName());
+	      if (certs != null)
+		jar.certs = (Certificate[])
+		  certs.toArray(new Certificate[certs.size()]);
+	    }
+	}
+      return jar;
+    }
+  }
+
+  /**
+   * XXX
+   * It actually returns a JarEntry not a zipEntry
+   * @param name XXX
+   */
+  public synchronized ZipEntry getEntry(String name)
+  {
+    ZipEntry entry = super.getEntry(name);
+    if (entry != null)
+      {
+	JarEntry jarEntry = new JarEntry(entry);
+	Manifest manifest;
+	try
+	  {
+	    manifest = getManifest();
+	  }
+	catch (IOException ioe)
+	  {
+	    manifest = null;
+	  }
+
+	if (manifest != null)
+	  {
+	    jarEntry.attr = manifest.getAttributes(name);
+          }
+
+	if (verify && !signaturesRead)
+	  try
+	    {
+	      readSignatures();
+	    }
+	  catch (IOException ioe)
+	    {
+	      if (DEBUG)
+		{
+		  debug(ioe);
+		  ioe.printStackTrace();
+		}
+	      signaturesRead = true;
+	    }
+	// See the comments in the JarEnumeration for why we do this
+	// check.
+	if (DEBUG)
+	  debug("entryCerts=" + entryCerts + " verified " + name
+		+ " ? " + verified.get(name));
+	if (entryCerts != null && verified.get(name) == Boolean.TRUE)
+	  {
+	    Set certs = (Set) entryCerts.get(name);
+	    if (certs != null)
+	      jarEntry.certs = (Certificate[])
+		certs.toArray(new Certificate[certs.size()]);
+	  }
+	return jarEntry;
+      }
+    return null;
+  }
+
+  /**
+   * Returns an input stream for the given entry. If configured to
+   * verify entries, the input stream returned will verify them while
+   * the stream is read, but only on the first time.
+   *
+   * @param entry The entry to get the input stream for.
+   * @exception ZipException XXX
+   * @exception IOException XXX
+   */
+  public synchronized InputStream getInputStream(ZipEntry entry) throws
+    ZipException, IOException
+  {
+    // If we haven't verified the hash, do it now.
+    if (!verified.containsKey(entry.getName()) && verify)
+      {
+        if (DEBUG)
+          debug("reading and verifying " + entry);
+        return new EntryInputStream(entry, super.getInputStream(entry), this);
+      }
+    else
+      {
+        if (DEBUG)
+          debug("reading already verified entry " + entry);
+        if (verify && verified.get(entry.getName()) == Boolean.FALSE)
+          throw new ZipException("digest for " + entry + " is invalid");
+        return super.getInputStream(entry);
+      }
+  }
+
+  /**
+   * Returns the JarEntry that belongs to the name if such an entry
+   * exists in the JarFile. Returns null otherwise
+   * Convenience method that just casts the result from <code>getEntry</code>
+   * to a JarEntry.
+   *
+   * @param name the jar entry name to look up
+   * @return the JarEntry if it exists, null otherwise
+   */
+  public JarEntry getJarEntry(String name)
+  {
+    return (JarEntry) getEntry(name);
+  }
+
+  /**
+   * Returns the manifest for this JarFile or null when the JarFile does not
+   * contain a manifest file.
+   */
+  public synchronized Manifest getManifest() throws IOException
+  {
+    if (!manifestRead)
+      manifest = readManifest();
+
+    return manifest;
+  }
+
+  // Only called with lock on this JarFile.
+  // Package private for use in inner classes.
+  void readSignatures() throws IOException
+  {
+    Map pkcs7Dsa = new HashMap();
+    Map pkcs7Rsa = new HashMap();
+    Map sigFiles = new HashMap();
+
+    // Phase 1: Read all signature files. These contain the user
+    // certificates as well as the signatures themselves.
+    for (Enumeration e = super.entries(); e.hasMoreElements(); )
+      {
+        ZipEntry ze = (ZipEntry) e.nextElement();
+        String name = ze.getName();
+        if (name.startsWith(META_INF))
+          {
+            String alias = name.substring(META_INF.length());
+            if (alias.lastIndexOf('.') >= 0)
+              alias = alias.substring(0, alias.lastIndexOf('.'));
+
+            if (name.endsWith(PKCS7_DSA_SUFFIX) || name.endsWith(PKCS7_RSA_SUFFIX))
+              {
+                if (DEBUG)
+                  debug("reading PKCS7 info from " + name + ", alias=" + alias);
+                PKCS7SignedData sig = null;
+                try
+                  {
+                    sig = new PKCS7SignedData(super.getInputStream(ze));
+                  }
+                catch (CertificateException ce)
+                  {
+                    IOException ioe = new IOException("certificate parsing error");
+                    ioe.initCause(ce);
+                    throw ioe;
+                  }
+                catch (CRLException crle)
+                  {
+                    IOException ioe = new IOException("CRL parsing error");
+                    ioe.initCause(crle);
+                    throw ioe;
+                  }
+                if (name.endsWith(PKCS7_DSA_SUFFIX))
+                  pkcs7Dsa.put(alias, sig);
+                else if (name.endsWith(PKCS7_RSA_SUFFIX))
+                  pkcs7Rsa.put(alias, sig);
+              }
+            else if (name.endsWith(SF_SUFFIX))
+              {
+                if (DEBUG)
+                  debug("reading signature file for " + alias + ": " + name);
+                Manifest sf = new Manifest(super.getInputStream(ze));
+                sigFiles.put(alias, sf);
+                if (DEBUG)
+                  debug("result: " + sf);
+              }
+          }
+      }
+
+    // Phase 2: verify the signatures on any signature files.
+    Set validCerts = new HashSet();
+    Map entryCerts = new HashMap();
+    for (Iterator it = sigFiles.entrySet().iterator(); it.hasNext(); )
+      {
+        int valid = 0;
+        Map.Entry e = (Map.Entry) it.next();
+        String alias = (String) e.getKey();
+
+        PKCS7SignedData sig = (PKCS7SignedData) pkcs7Dsa.get(alias);
+        if (sig != null)
+          {
+            Certificate[] certs = sig.getCertificates();
+            Set signerInfos = sig.getSignerInfos();
+            for (Iterator it2 = signerInfos.iterator(); it2.hasNext(); )
+              verify(certs, (SignerInfo) it2.next(), alias, validCerts);
+          }
+
+        sig = (PKCS7SignedData) pkcs7Rsa.get(alias);
+        if (sig != null)
+          {
+            Certificate[] certs = sig.getCertificates();
+            Set signerInfos = sig.getSignerInfos();
+            for (Iterator it2 = signerInfos.iterator(); it2.hasNext(); )
+              verify(certs, (SignerInfo) it2.next(), alias, validCerts);
+          }
+
+        // It isn't a signature for anything. Punt it.
+        if (validCerts.isEmpty())
+          {
+            it.remove();
+            continue;
+          }
+
+        entryCerts.put(e.getValue(), new HashSet(validCerts));
+        validCerts.clear();
+      }
+
+    // Phase 3: verify the signature file signatures against the manifest,
+    // mapping the entry name to the target certificates.
+    this.entryCerts = new HashMap();
+    for (Iterator it = entryCerts.entrySet().iterator(); it.hasNext(); )
+      {
+        Map.Entry e = (Map.Entry) it.next();
+        Manifest sigfile = (Manifest) e.getKey();
+        Map entries = sigfile.getEntries();
+        Set certificates = (Set) e.getValue();
+
+        for (Iterator it2 = entries.entrySet().iterator(); it2.hasNext(); )
+          {
+            Map.Entry e2 = (Map.Entry) it2.next();
+            String entryname = String.valueOf(e2.getKey());
+            Attributes attr = (Attributes) e2.getValue();
+            if (verifyHashes(entryname, attr))
+              {
+                if (DEBUG)
+                  debug("entry " + entryname + " has certificates " + certificates);
+                Set s = (Set) this.entryCerts.get(entryname);
+                if (s != null)
+                  s.addAll(certificates);
+                else
+                  this.entryCerts.put(entryname, new HashSet(certificates));
+              }
+          }
+      }
+
+    signaturesRead = true;
+  }
+
+  /**
+   * Tell if the given signer info is over the given alias's signature file,
+   * given one of the certificates specified.
+   */
+  private void verify(Certificate[] certs, SignerInfo signerInfo,
+                      String alias, Set validCerts)
+  {
+    Signature sig = null;
+    try
+      {
+        OID alg = signerInfo.getDigestEncryptionAlgorithmId();
+        if (alg.equals(DSA_ENCRYPTION_OID))
+          {
+            if (!signerInfo.getDigestAlgorithmId().equals(SHA1_OID))
+              return;
+            sig = Signature.getInstance("SHA1withDSA", provider);
+          }
+        else if (alg.equals(RSA_ENCRYPTION_OID))
+          {
+            OID hash = signerInfo.getDigestAlgorithmId();
+            if (hash.equals(MD2_OID))
+              sig = Signature.getInstance("md2WithRsaEncryption", provider);
+            else if (hash.equals(MD4_OID))
+              sig = Signature.getInstance("md4WithRsaEncryption", provider);
+            else if (hash.equals(MD5_OID))
+              sig = Signature.getInstance("md5WithRsaEncryption", provider);
+            else if (hash.equals(SHA1_OID))
+              sig = Signature.getInstance("sha1WithRsaEncryption", provider);
+            else
+              return;
+          }
+        else
+          {
+            if (DEBUG)
+              debug("unsupported signature algorithm: " + alg);
+            return;
+          }
+      }
+    catch (NoSuchAlgorithmException nsae)
+      {
+        if (DEBUG)
+          {
+            debug(nsae);
+            nsae.printStackTrace();
+          }
+        return;
+      }
+    ZipEntry sigFileEntry = super.getEntry(META_INF + alias + SF_SUFFIX);
+    if (sigFileEntry == null)
+      return;
+    for (int i = 0; i < certs.length; i++)
+      {
+        if (!(certs[i] instanceof X509Certificate))
+          continue;
+        X509Certificate cert = (X509Certificate) certs[i];
+        if (!cert.getIssuerX500Principal().equals(signerInfo.getIssuer()) ||
+            !cert.getSerialNumber().equals(signerInfo.getSerialNumber()))
+          continue;
+        try
+          {
+            sig.initVerify(cert.getPublicKey());
+            InputStream in = super.getInputStream(sigFileEntry);
+            if (in == null)
+              continue;
+            byte[] buf = new byte[1024];
+            int len = 0;
+            while ((len = in.read(buf)) != -1)
+              sig.update(buf, 0, len);
+            if (sig.verify(signerInfo.getEncryptedDigest()))
+              {
+                if (DEBUG)
+                  debug("signature for " + cert.getSubjectDN() + " is good");
+                validCerts.add(cert);
+              }
+          }
+        catch (IOException ioe)
+          {
+            continue;
+          }
+        catch (InvalidKeyException ike)
+          {
+            continue;
+          }
+        catch (SignatureException se)
+          {
+            continue;
+          }
+      }
+  }
+
+  /**
+   * Verifies that the digest(s) in a signature file were, in fact, made
+   * over the manifest entry for ENTRY.
+   *
+   * @param entry The entry name.
+   * @param attr The attributes from the signature file to verify.
+   */
+  private boolean verifyHashes(String entry, Attributes attr)
+  {
+    int verified = 0;
+
+    // The bytes for ENTRY's manifest entry, which are signed in the
+    // signature file.
+    byte[] entryBytes = null;
+    try
+      {
+	ZipEntry e = super.getEntry(entry);
+	if (e == null)
+	  {
+	    if (DEBUG)
+	      debug("verifyHashes: no entry '" + entry + "'");
+	    return false;
+	  }
+        entryBytes = readManifestEntry(e);
+      }
+    catch (IOException ioe)
+      {
+        if (DEBUG)
+          {
+            debug(ioe);
+            ioe.printStackTrace();
+          }
+        return false;
+      }
+
+    for (Iterator it = attr.entrySet().iterator(); it.hasNext(); )
+      {
+        Map.Entry e = (Map.Entry) it.next();
+        String key = String.valueOf(e.getKey());
+        if (!key.endsWith(DIGEST_KEY_SUFFIX))
+          continue;
+        String alg = key.substring(0, key.length() - DIGEST_KEY_SUFFIX.length());
+        try
+          {
+            byte[] hash = Base64InputStream.decode((String) e.getValue());
+            MessageDigest md = MessageDigest.getInstance(alg, provider);
+            md.update(entryBytes);
+            byte[] hash2 = md.digest();
+            if (DEBUG)
+              debug("verifying SF entry " + entry + " alg: " + md.getAlgorithm()
+                    + " expect=" + new java.math.BigInteger(hash).toString(16)
+                    + " comp=" + new java.math.BigInteger(hash2).toString(16));
+            if (!Arrays.equals(hash, hash2))
+              return false;
+            verified++;
+          }
+        catch (IOException ioe)
+          {
+            if (DEBUG)
+              {
+                debug(ioe);
+                ioe.printStackTrace();
+              }
+            return false;
+          }
+        catch (NoSuchAlgorithmException nsae)
+          {
+            if (DEBUG)
+              {
+                debug(nsae);
+                nsae.printStackTrace();
+              }
+            return false;
+          }
+      }
+
+    // We have to find at least one valid digest.
+    return verified > 0;
+  }
+
+  /**
+   * Read the raw bytes that comprise a manifest entry. We can't use the
+   * Manifest object itself, because that loses information (such as line
+   * endings, and order of entries).
+   */
+  private byte[] readManifestEntry(ZipEntry entry) throws IOException
+  {
+    InputStream in = super.getInputStream(super.getEntry(MANIFEST_NAME));
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    byte[] target = ("Name: " + entry.getName()).getBytes();
+    int t = 0, c, prev = -1, state = 0, l = -1;
+
+    while ((c = in.read()) != -1)
+      {
+//         if (DEBUG)
+//           debug("read "
+//                 + (c == '\n' ? "\\n" : (c == '\r' ? "\\r" : String.valueOf((char) c)))
+//                 + " state=" + state + " prev="
+//                 + (prev == '\n' ? "\\n" : (prev == '\r' ? "\\r" : String.valueOf((char) prev)))
+//                 + " t=" + t + (t < target.length ? (" target[t]=" + (char) target[t]) : "")
+//                 + " l=" + l);
+        switch (state)
+          {
+
+          // Step 1: read until we find the "target" bytes: the start
+          // of the entry we need to read.
+          case 0:
+            if (((byte) c) != target[t])
+              t = 0;
+            else
+              {
+                t++;
+                if (t == target.length)
+                  {
+                    out.write(target);
+                    state = 1;
+                  }
+              }
+            break;
+
+          // Step 2: assert that there is a newline character after
+          // the "target" bytes.
+          case 1:
+            if (c != '\n' && c != '\r')
+              {
+                out.reset();
+                t = 0;
+                state = 0;
+              }
+            else
+              {
+                out.write(c);
+                state = 2;
+              }
+            break;
+
+          // Step 3: read this whole entry, until we reach an empty
+          // line.
+          case 2:
+            if (c == '\n')
+              {
+                out.write(c);
+                // NL always terminates a line.
+                if (l == 0 || (l == 1 && prev == '\r'))
+                  return out.toByteArray();
+                l = 0;
+              }
+            else
+              {
+                // Here we see a blank line terminated by a CR,
+                // followed by the next entry. Technically, `c' should
+                // always be 'N' at this point.
+                if (l == 1 && prev == '\r')
+                  return out.toByteArray();
+                out.write(c);
+                l++;
+              }
+            prev = c;
+            break;
+
+          default:
+            throw new RuntimeException("this statement should be unreachable");
+          }
+      }
+
+    // The last entry, with a single CR terminating the line.
+    if (state == 2 && prev == '\r' && l == 0)
+      return out.toByteArray();
+
+    // We should not reach this point, we didn't find the entry (or, possibly,
+    // it is the last entry and is malformed).
+    throw new IOException("could not find " + entry + " in manifest");
+  }
+
+  /**
+   * A utility class that verifies jar entries as they are read.
+   */
+  private static class EntryInputStream extends FilterInputStream
+  {
+    private final JarFile jarfile;
+    private final long length;
+    private long pos;
+    private final ZipEntry entry;
+    private final byte[][] hashes;
+    private final MessageDigest[] md;
+    private boolean checked;
+
+    EntryInputStream(final ZipEntry entry,
+		     final InputStream in,
+		     final JarFile jar)
+      throws IOException
+    {
+      super(in);
+      this.entry = entry;
+      this.jarfile = jar;
+
+      length = entry.getSize();
+      pos = 0;
+      checked = false;
+
+      Attributes attr;
+      Manifest manifest = jarfile.getManifest();
+      if (manifest != null)
+	attr = manifest.getAttributes(entry.getName());
+      else
+	attr = null;
+      if (DEBUG)
+        debug("verifying entry " + entry + " attr=" + attr);
+      if (attr == null)
+        {
+          hashes = new byte[0][];
+          md = new MessageDigest[0];
+        }
+      else
+        {
+          List hashes = new LinkedList();
+          List md = new LinkedList();
+          for (Iterator it = attr.entrySet().iterator(); it.hasNext(); )
+            {
+              Map.Entry e = (Map.Entry) it.next();
+              String key = String.valueOf(e.getKey());
+              if (key == null)
+                continue;
+              if (!key.endsWith(DIGEST_KEY_SUFFIX))
+                continue;
+              hashes.add(Base64InputStream.decode((String) e.getValue()));
+              try
+                {
+                  int length = key.length() - DIGEST_KEY_SUFFIX.length();
+                  String alg = key.substring(0, length);
+                  md.add(MessageDigest.getInstance(alg, provider));
+                }
+              catch (NoSuchAlgorithmException nsae)
+                {
+                  IOException ioe = new IOException("no such message digest: " + key);
+                  ioe.initCause(nsae);
+                  throw ioe;
+                }
+            }
+          if (DEBUG)
+            debug("digests=" + md);
+          this.hashes = (byte[][]) hashes.toArray(new byte[hashes.size()][]);
+          this.md = (MessageDigest[]) md.toArray(new MessageDigest[md.size()]);
+        }
+    }
+
+    public boolean markSupported()
+    {
+      return false;
+    }
+
+    public void mark(int readLimit)
+    {
+    }
+
+    public void reset()
+    {
+    }
+
+    public int read() throws IOException
+    {
+      int b = super.read();
+      if (b == -1)
+        {
+          eof();
+          return -1;
+        }
+      for (int i = 0; i < md.length; i++)
+        md[i].update((byte) b);
+      pos++;
+      if (length > 0 && pos >= length)
+        eof();
+      return b;
+    }
+
+    public int read(byte[] buf, int off, int len) throws IOException
+    {
+      int count = super.read(buf, off, (int) Math.min(len, (length != 0
+                                                            ? length - pos
+                                                            : Integer.MAX_VALUE)));
+      if (count == -1 || (length > 0 && pos >= length))
+        {
+          eof();
+          return -1;
+        }
+      for (int i = 0; i < md.length; i++)
+        md[i].update(buf, off, count);
+      pos += count;
+      if (length != 0 && pos >= length)
+        eof();
+      return count;
+    }
+
+    public int read(byte[] buf) throws IOException
+    {
+      return read(buf, 0, buf.length);
+    }
+
+    public long skip(long bytes) throws IOException
+    {
+      byte[] b = new byte[1024];
+      long amount = 0;
+      while (amount < bytes)
+        {
+          int l = read(b, 0, (int) Math.min(b.length, bytes - amount));
+          if (l == -1)
+            break;
+          amount += l;
+        }
+      return amount;
+    }
+
+    private void eof() throws IOException
+    {
+      if (checked)
+        return;
+      checked = true;
+      for (int i = 0; i < md.length; i++)
+        {
+          byte[] hash = md[i].digest();
+          if (DEBUG)
+            debug("verifying " + md[i].getAlgorithm() + " expect="
+                  + new java.math.BigInteger(hashes[i]).toString(16)
+                  + " comp=" + new java.math.BigInteger(hash).toString(16));
+          if (!Arrays.equals(hash, hashes[i]))
+            {
+	      synchronized(jarfile)
+		{
+		  if (DEBUG)
+		    debug(entry + " could NOT be verified");
+		  jarfile.verified.put(entry.getName(), Boolean.FALSE);
+		}
+	      return;
+	      // XXX ??? what do we do here?
+	      // throw new ZipException("message digest mismatch");
+            }
+        }
+
+      synchronized(jarfile)
+	{
+	  if (DEBUG)
+	    debug(entry + " has been VERIFIED");
+	  jarfile.verified.put(entry.getName(), Boolean.TRUE);
+	}
+    }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarInputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarInputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,200 @@
+/* JarInputStream.java - InputStream for reading jar files
+   Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.jar;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+/**
+ * InputStream for reading jar files.
+ * XXX - verification of the signatures in the Manifest file is not yet
+ * implemented.
+ *
+ * @since 1.2
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+
+public class JarInputStream extends ZipInputStream
+{
+  // Fields
+
+  /** The manifest for this file or null when there was no manifest. */
+  private Manifest manifest;
+
+  /** The first real JarEntry for this file. Used by readManifest() to store
+     an entry that isn't the manifest but that should be returned by
+     getNextEntry next time it is called. Null when no firstEntry was read
+     while searching for the manifest entry, or when it has already been
+     returned by getNextEntry(). */
+  private JarEntry firstEntry;
+
+  // Constructors
+
+  /**
+   * Creates a new JarInputStream and tries to read the manifest.
+   * If such a manifest is present the JarInputStream tries to verify all
+   * the entry signatures while reading.
+   *
+   * @param in InputStream to read the jar from
+   * @exception IOException when an error occurs when opening or reading
+   */
+  public JarInputStream(InputStream in) throws IOException
+  {
+    this(in, true);
+  }
+
+  /**
+   * Creates a new JarInputStream and tries to read the manifest.
+   * If such a manifest is present and verify is true, the JarInputStream
+   * tries to verify all the entry signatures while reading.
+   *
+   * @param in InputStream to read the jar from
+   * @param verify whether or not to verify the manifest entries
+   * @exception IOException when an error occurs when opening or reading
+   */
+  public JarInputStream(InputStream in, boolean verify) throws IOException
+  {
+    super(in);
+    readManifest(verify);
+  }
+
+  // Methods
+
+  /**
+   * Set the manifest if found. Skips all entries that start with "META-INF/"
+   *
+   * @param verify when true (and a Manifest is found) checks the Manifest,
+   * when false no check is performed
+   * @exception IOException if an error occurs while reading
+   */
+  private void readManifest(boolean verify) throws IOException
+  {
+    firstEntry = (JarEntry) super.getNextEntry();
+    while ((firstEntry != null) &&
+	   firstEntry.getName().startsWith("META-INF/"))
+      {
+	if (firstEntry.getName().equals(JarFile.MANIFEST_NAME))
+	  {
+	    manifest = new Manifest(this);
+	  }
+	firstEntry = (JarEntry) super.getNextEntry();
+      }
+
+    if (verify)
+      {
+	// XXX
+      }
+  }
+
+  /**
+   * Creates a JarEntry for a particular name and consults the manifest
+   * for the Attributes of the entry.
+   * Used by <code>ZipEntry.getNextEntry()</code>
+   *
+   * @param name the name of the new entry
+   */
+  protected ZipEntry createZipEntry(String name)
+  {
+    ZipEntry zipEntry = super.createZipEntry(name);
+    JarEntry jarEntry = new JarEntry(zipEntry);
+    if (manifest != null)
+      {
+	jarEntry.attr = manifest.getAttributes(name);
+      }
+    return jarEntry;
+  }
+
+  /**
+   * Returns the Manifest for the jar file or null if there was no Manifest.
+   */
+  public Manifest getManifest()
+  {
+    return manifest;
+  }
+
+  /**
+   * Returns the next entry or null when there are no more entries.
+   * Does actually return a JarEntry, if you don't want to cast it yourself
+   * use <code>getNextJarEntry()</code>. Does not return any entries found
+   * at the beginning of the ZipFile that are special
+   * (those that start with "META-INF/").
+   *
+   * @exception IOException if an IO error occurs when reading the entry
+   */
+  public ZipEntry getNextEntry() throws IOException
+  {
+    ZipEntry entry;
+    if (firstEntry != null)
+      {
+	entry = firstEntry;
+	firstEntry = null;
+      }
+    else
+      {
+	entry = super.getNextEntry();
+      }
+    return entry;
+  }
+
+  /**
+   * Returns the next jar entry or null when there are no more entries.
+   *
+   * @exception IOException if an IO error occurs when reading the entry
+   */
+  public JarEntry getNextJarEntry() throws IOException
+  {
+    return (JarEntry) getNextEntry();
+  }
+
+  /**
+   * XXX
+   *
+   * @param buf XXX
+   * @param off XXX
+   * @param len XXX
+   * @return XXX
+   * @exception IOException XXX
+   */
+  public int read(byte[]buf, int off, int len) throws IOException
+  {
+    // XXX if (verify) {}
+    return super.read(buf, off, len);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarOutputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/JarOutputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,113 @@
+/* JarOutputStream.java - OutputStream for writing jar files
+   Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.jar;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * OutputStream for writing jar files.
+ * A special ZipOutputStream that can take JarEntries and can have a optional
+ * Manifest as first entry.
+ *
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+
+public class JarOutputStream extends ZipOutputStream
+{
+  // Constructors
+
+  /**
+   * Creates a new JarOutputStream without a manifest entry.
+   *
+   * @param out the stream to create the new jar on
+   * @exception IOException if something unexpected happend
+   */
+  public JarOutputStream(OutputStream out) throws IOException
+  {
+    this(out, null);
+  }
+
+  /**
+   * Creates a new JarOutputStream with a manifest entry.
+   * The manifest will be the first entry in the jar.
+   *
+   * @param out the stream to create the new jar on
+   * @param man the manifest that should be put in the jar file or null
+   * for no manifest entry
+   * @exception IOException if something unexpected happend
+   */
+  public JarOutputStream(OutputStream out, Manifest man) throws IOException
+  {
+    super(out);
+    if (man != null)
+      writeManifest(man);
+  }
+
+  // Methods
+
+  /**
+   * Writes the manifest to a new JarEntry in this JarOutputStream with as
+   * name JarFile.MANIFEST_NAME.
+   *
+   * @param manifest the non null manifest to be written
+   * @exception IOException if something unexpected happend
+   */
+  private void writeManifest(Manifest manifest) throws IOException
+  {
+    // Create a new Jar Entry for the Manifest
+    JarEntry entry = new JarEntry(JarFile.MANIFEST_NAME);
+    putNextEntry(entry);
+    manifest.write(this);
+    closeEntry();
+  }
+
+  /**
+   * Prepares the JarOutputStream for writing the next entry. 
+   * This implementation just calls <code>super.putNextEntry()</code>.
+   *
+   * @param entry The information for the next entry
+   * @exception IOException when some unexpected I/O exception occurred
+   */
+  public void putNextEntry(ZipEntry entry) throws IOException
+  {
+    super.putNextEntry(entry);	// XXX
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/Manifest.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/Manifest.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/Manifest.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/Manifest.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,213 @@
+/* Manifest.java -- Reads, writes and manipulates jar manifest files
+   Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.jar;
+
+import gnu.java.util.jar.JarUtils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Hashtable;
+import java.util.Map;
+
+/**
+ * Reads, writes and manipulaties jar manifest files.
+ * XXX
+ * 
+ * @since 1.2
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+public class Manifest implements Cloneable
+{
+  // Fields
+
+  /** The main attributes of the manifest (jar file). */
+  private final Attributes mainAttr;
+
+  /** A map of atrributes for all entries described in this Manifest. */
+  private final Map entries;
+
+  // Constructors
+
+  /**
+   * Creates a new empty Manifest.
+   */
+  public Manifest()
+  {
+    mainAttr = new Attributes();
+    entries = new Hashtable();
+  }
+
+  /**
+   * Creates a Manifest from the supplied input stream.
+   *
+   * @see #read(InputStream)
+   * @see #write(OutputStream)
+   *
+   * @param in the input stream to read the manifest from
+   * @exception IOException when an i/o exception occurs or the input stream
+   * does not describe a valid manifest
+   */
+  public Manifest(InputStream in) throws IOException
+  {
+    this();
+    read(in);
+  }
+
+  /**
+   * Creates a Manifest from another Manifest.
+   * Makes a deep copy of the main attributes, but a shallow copy of
+   * the other entries. This means that you can freely add, change or remove
+   * the main attributes or the entries of the new manifest without effecting
+   * the original manifest, but adding, changing or removing attributes from
+   * a particular entry also changes the attributes of that entry in the
+   * original manifest.
+   *
+   * @see #clone()
+   * @param man the Manifest to copy from
+   */
+  public Manifest(Manifest man)
+  {
+    mainAttr = new Attributes(man.getMainAttributes());
+    entries = new Hashtable(man.getEntries());
+  }
+
+  // Methods
+
+  /**
+   * Gets the main attributes of this Manifest.
+   */
+  public Attributes getMainAttributes()
+  {
+    return mainAttr;
+  }
+
+  /**
+   * Gets a map of entry Strings to Attributes for all the entries described
+   * in this manifest. Adding, changing or removing from this entries map
+   * changes the entries of this manifest.
+   */
+  public Map getEntries()
+  {
+    return entries;
+  }
+
+  /**
+   * Returns the Attributes associated with the Entry.
+   * <p>
+   * Implemented as:
+   * <code>return (Attributes)getEntries().get(entryName)</code>
+   *
+   * @param entryName the name of the entry to look up
+   * @return the attributes associated with the entry or null when none
+   */
+  public Attributes getAttributes(String entryName)
+  {
+    return (Attributes) getEntries().get(entryName);
+  }
+
+  /**
+   * Clears the main attributes and removes all the entries from the
+   * manifest.
+   */
+  public void clear()
+  {
+    mainAttr.clear();
+    entries.clear();
+  }
+
+  /**
+   * Read and merge a <code>Manifest</code> from the designated input stream.
+   * 
+   * @param in the input stream to read from.
+   * @throws IOException if an I/O related exception occurs during the process.
+   */
+  public void read(InputStream in) throws IOException
+  {
+    JarUtils.readMFManifest(getMainAttributes(), getEntries(), in);
+  }
+
+  /**
+   * Writes the contents of this <code>Manifest</code> to the designated
+   * output stream. Line-endings are platform-independent and consist of the
+   * 2-codepoint sequence <code>0x0D</code> and <code>0x0A</code>.
+   * 
+   * @param out the output stream to write this <code>Manifest</code> to.
+   * @throws IOException if an I/O related exception occurs during the process.
+   */
+  public void write(OutputStream out) throws IOException
+  {
+    JarUtils.writeMFManifest(getMainAttributes(), getEntries(), out);
+  }
+
+  /**
+   * Makes a deep copy of the main attributes, but a shallow copy of
+   * the other entries. This means that you can freely add, change or remove
+   * the main attributes or the entries of the new manifest without effecting
+   * the original manifest, but adding, changing or removing attributes from
+   * a particular entry also changes the attributes of that entry in the
+   * original manifest. Calls <CODE>new Manifest(this)</CODE>.
+   */
+  public Object clone()
+  {
+    return new Manifest(this);
+  }
+
+  /**
+   * Checks if another object is equal to this Manifest object.
+   * Another Object is equal to this Manifest object if it is an instance of
+   * Manifest and the main attributes and the entries of the other manifest
+   * are equal to this one.
+   */
+  public boolean equals(Object o)
+  {
+    return (o instanceof Manifest) &&
+      (mainAttr.equals(((Manifest) o).mainAttr)) &&
+      (entries.equals(((Manifest) o).entries));
+  }
+
+  /**
+   * Calculates the hash code of the manifest. Implemented by a xor of the
+   * hash code of the main attributes with the hash code of the entries map.
+   */
+  public int hashCode()
+  {
+    return mainAttr.hashCode() ^ entries.hashCode();
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/jar/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.util.jar package.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.util.jar</title></head>
+
+<body>
+<p>Utility classes for manipulating java archives
+(zip files with a manifest file with attributes).</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/ConsoleHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/ConsoleHandler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/ConsoleHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/ConsoleHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,125 @@
+/* ConsoleHandler.java -- a class for publishing log messages to System.err
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+/**
+ * A <code>ConsoleHandler</code> publishes log records to
+ * <code>System.err</code>.
+ *
+ * <p><strong>Configuration:</strong> Values of the subsequent
+ * <code>LogManager</code> properties are taken into consideration
+ * when a <code>ConsoleHandler</code> is initialized.
+ * If a property is not defined, or if it has an invalid
+ * value, a default is taken without an exception being thrown.
+ *
+ * <ul>
+ *
+ * <li><code>java.util.logging.ConsoleHandler.level</code> - specifies
+ *     the initial severity level threshold. Default value:
+ *     <code>Level.INFO</code>.</li>
+ *
+ * <li><code>java.util.logging.ConsoleHandler.filter</code> - specifies
+ *     the name of a Filter class. Default value: No Filter.</li>
+ *
+ * <li><code>java.util.logging.ConsoleHandler.formatter</code> - specifies
+ *     the name of a Formatter class. Default value:
+ *     <code>java.util.logging.SimpleFormatter</code>.</li>
+ *
+ * <li><code>java.util.logging.ConsoleHandler.encoding</code> - specifies
+ *     the name of the character encoding. Default value:
+ *     the default platform encoding.</li>
+ *
+ * </ul>
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public class ConsoleHandler
+  extends StreamHandler
+{
+  /**
+   * Constructs a <code>StreamHandler</code> that publishes
+   * log records to <code>System.err</code>.  The initial
+   * configuration is determined by the <code>LogManager</code>
+   * properties described above.
+   */
+  public ConsoleHandler()
+  {
+    super(System.err, "java.util.logging.ConsoleHandler", Level.INFO,
+	 /* formatter */ null, SimpleFormatter.class);
+  }
+
+
+  /**
+   * Forces any data that may have been buffered to the underlying
+   * output device, but does <i>not</i> close <code>System.err</code>.
+   *
+   * <p>In case of an I/O failure, the <code>ErrorManager</code>
+   * of this <code>ConsoleHandler</code> will be informed, but the caller
+   * of this method will not receive an exception.
+   */
+  public void close()
+  {
+    flush();
+  }
+
+
+  /**
+   * Publishes a <code>LogRecord</code> to the console, provided the
+   * record passes all tests for being loggable.
+   *
+   * <p>Most applications do not need to call this method directly.
+   * Instead, they will use use a <code>Logger</code>, which will
+   * create LogRecords and distribute them to registered handlers.
+   *
+   * <p>In case of an I/O failure, the <code>ErrorManager</code>
+   * of this <code>SocketHandler</code> will be informed, but the caller
+   * of this method will not receive an exception.
+   *
+   * <p>The GNU implementation of <code>ConsoleHandler.publish</code>
+   * calls flush() for every request to publish a record, so
+   * they appear immediately on the console.
+   *
+   * @param record the log event to be published.
+   */
+  public void publish(LogRecord record)
+  {
+    super.publish(record);
+    flush();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/ErrorManager.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/ErrorManager.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/ErrorManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/ErrorManager.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,194 @@
+/* ErrorManager.java --
+   A class for dealing with errors that a Handler encounters
+   during logging
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+/**
+ * An <code>ErrorManager</code> deals with errors that a <code>Handler</code>
+ * encounters while logging.
+ *
+ * @see Handler#setErrorManager(ErrorManager)
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public class ErrorManager
+{
+  /* The values have been taken from Sun's public J2SE 1.4 API
+   * documentation.
+   * See http://java.sun.com/j2se/1.4/docs/api/constant-values.html
+   */
+
+  /**
+   * Indicates that there was a failure that does not readily
+   * fall into any of the other categories.
+   */
+  public static final int GENERIC_FAILURE = 0;
+
+
+  /**
+   * Indicates that there was a problem upon writing to
+   * an output stream.
+   */
+  public static final int WRITE_FAILURE = 1;
+
+
+  /**
+   * Indicates that there was a problem upon flushing
+   * an output stream.
+   */
+  public static final int FLUSH_FAILURE = 2;
+
+
+  /**
+   * Indicates that there was a problem upon closing
+   * an output stream.
+   */
+  public static final int CLOSE_FAILURE = 3;
+
+    
+  /**
+   * Indicates that there was a problem upon opening
+   * an output stream.
+   */
+  public static final int OPEN_FAILURE = 4;
+
+
+  /**
+   * Indicates that there was a problem upon formatting
+   * the message of a log record.
+   */
+  public static final int FORMAT_FAILURE = 5;
+
+
+  /**
+   * Indicates whether the {@link #error} method of this ErrorManager
+   * has ever been used.
+   *
+   * Declared volatile in order to correctly support the
+   * double-checked locking idiom (once the revised Java Memory Model
+   * gets adopted); see Classpath bug #2944.
+   */
+  private volatile boolean everUsed = false;
+
+
+  public ErrorManager()
+  {
+  }
+
+
+  /**
+   * Reports an error that occured upon logging.  The default implementation
+   * emits the very first error to System.err, ignoring subsequent errors.
+   *
+   * @param message a message describing the error, or <code>null</code> if
+   *                there is no suitable description.
+   *
+   * @param ex      an exception, or <code>null</code> if the error is not
+   *                related to an exception.
+   *
+   * @param errorCode  one of the defined error codes, for example
+   *                   <code>ErrorManager.CLOSE_FAILURE</code>.
+   */
+  public void error(String message, Exception ex, int errorCode)
+  {
+    if (everUsed)
+      return;
+
+    synchronized (this)
+    {
+      /* The double check is intentional. If the first check was
+       * omitted, the monitor would have to be entered every time
+       * error() method was called. If the second check was
+       * omitted, the code below could be executed by multiple
+       * threads simultaneously.
+       *
+       * This is the 'double-checked locking' idiom, which is broken
+       * with the current version of the Java memory model.  However,
+       * we assume that JVMs will have adopted a revised version of
+       * the Java Memory Model by the time GNU Classpath gains
+       * widespread acceptance. See Classpath bug #2944.
+       */
+      if (everUsed)
+	return;
+
+      everUsed = true;
+    }
+
+    String codeMsg;
+    switch (errorCode)
+    {
+    case GENERIC_FAILURE:
+      codeMsg = "GENERIC_FAILURE";
+      break;
+
+    case WRITE_FAILURE:
+      codeMsg = "WRITE_FAILURE";
+      break;
+
+    case FLUSH_FAILURE:
+      codeMsg = "FLUSH_FAILURE";
+      break;
+
+    case CLOSE_FAILURE:
+      codeMsg = "CLOSE_FAILURE";
+      break;
+
+    case OPEN_FAILURE:
+      codeMsg = "OPEN_FAILURE";
+      break;
+
+    case FORMAT_FAILURE:
+      codeMsg = "FORMAT_FAILURE";
+      break;
+
+    default:
+      codeMsg = String.valueOf(errorCode);
+      break;
+    }
+
+    System.err.println("Error upon logging: " + codeMsg);
+    if ((message != null) && (message.length() > 0))
+      System.err.println(message);
+
+    if (ex != null)
+      ex.printStackTrace();
+  }
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/FileHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/FileHandler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/FileHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/FileHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,663 @@
+/* FileHandler.java -- a class for publishing log messages to log files
+   Copyright (C) 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+/**
+ * A <code>FileHandler</code> publishes log records to a set of log
+ * files.  A maximum file size can be specified; as soon as a log file
+ * reaches the size limit, it is closed and the next file in the set
+ * is taken.
+ *
+ * <p><strong>Configuration:</strong> Values of the subsequent
+ * <code>LogManager</code> properties are taken into consideration
+ * when a <code>FileHandler</code> is initialized.  If a property is
+ * not defined, or if it has an invalid value, a default is taken
+ * without an exception being thrown.
+ *
+ * <ul>
+ *
+ * <li><code>java.util.FileHandler.level</code> - specifies
+ *     the initial severity level threshold. Default value:
+ *     <code>Level.ALL</code>.</li>
+ *
+ * <li><code>java.util.FileHandler.filter</code> - specifies
+ *     the name of a Filter class. Default value: No Filter.</li>
+ *
+ * <li><code>java.util.FileHandler.formatter</code> - specifies
+ *     the name of a Formatter class. Default value:
+ *     <code>java.util.logging.XMLFormatter</code>.</li>
+ *
+ * <li><code>java.util.FileHandler.encoding</code> - specifies
+ *     the name of the character encoding. Default value:
+ *     the default platform encoding.</li>
+ *
+ * <li><code>java.util.FileHandler.limit</code> - specifies the number
+ *     of bytes a log file is approximately allowed to reach before it
+ *     is closed and the handler switches to the next file in the
+ *     rotating set.  A value of zero means that files can grow
+ *     without limit.  Default value: 0 (unlimited growth).</li>
+ *
+ * <li><code>java.util.FileHandler.count</code> - specifies the number
+ *     of log files through which this handler cycles.  Default value:
+ *     1.</li>
+ *
+ * <li><code>java.util.FileHandler.pattern</code> - specifies a
+ *     pattern for the location and name of the produced log files.
+ *     See the section on <a href="#filePatterns">file name
+ *     patterns</a> for details.  Default value:
+ *     <code>"%h/java%u.log"</code>.</li>
+ *
+ * <li><code>java.util.FileHandler.append</code> - specifies
+ *     whether the handler will append log records to existing
+ *     files, or whether the handler will clear log files
+ *     upon switching to them. Default value: <code>false</code>,
+ *     indicating that files will be cleared.</li>
+ *
+ * </ul>
+ *
+ * <p><a name="filePatterns"><strong>File Name Patterns:</strong></a>
+ * The name and location and log files are specified with pattern
+ * strings. The handler will replace the following character sequences
+ * when opening log files:
+ *
+ * <p><ul>
+ * <li><code>/</code> - replaced by the platform-specific path name
+ *     separator.  This value is taken from the system property
+ *     <code>file.separator</code>.</li>
+ *
+ * <li><code>%t</code> - replaced by the platform-specific location of
+ *     the directory intended for temporary files.  This value is
+ *     taken from the system property <code>java.io.tmpdir</code>.</li>
+ *
+ * <li><code>%h</code> - replaced by the location of the home
+ *     directory of the current user.  This value is taken from the
+ *     system property <code>user.home</code>.</li>
+ *
+ * <li><code>%g</code> - replaced by a generation number for
+ *     distinguisthing the individual items in the rotating set 
+ *     of log files.  The generation number cycles through the
+ *     sequence 0, 1, ..., <code>count</code> - 1.</li>
+ *
+ * <li><code>%u</code> - replaced by a unique number for
+ *     distinguisthing the output files of several concurrently
+ *     running processes.  The <code>FileHandler</code> starts
+ *     with 0 when it tries to open a log file.  If the file
+ *     cannot be opened because it is currently in use,
+ *     the unique number is incremented by one and opening
+ *     is tried again.  These steps are repeated until the
+ *     opening operation succeeds.
+ *
+ *     <p>FIXME: Is the following correct? Please review.  The unique
+ *     number is determined for each log file individually when it is
+ *     opened upon switching to the next file.  Therefore, it is not
+ *     correct to assume that all log files in a rotating set bear the
+ *     same unique number.
+ *
+ *     <p>FIXME: The Javadoc for the Sun reference implementation
+ *     says: "Note that the use of unique ids to avoid conflicts is
+ *     only guaranteed to work reliably when using a local disk file
+ *     system." Why? This needs to be mentioned as well, in case
+ *     the reviewers decide the statement is true.  Otherwise,
+ *     file a bug report with Sun.</li>
+ *
+ * <li><code>%%</code> - replaced by a single percent sign.</li>
+ * </ul>
+ *
+ * <p>If the pattern string does not contain <code>%g</code> and
+ * <code>count</code> is greater than one, the handler will append
+ * the string <code>.%g</code> to the specified pattern.
+ *
+ * <p>If the handler attempts to open a log file, this log file
+ * is being used at the time of the attempt, and the pattern string
+ * does not contain <code>%u</code>, the handler will append
+ * the string <code>.%u</code> to the specified pattern. This
+ * step is performed after any generation number has been
+ * appended.
+ *
+ * <p><em>Examples for the GNU platform:</em> 
+ *
+ * <p><ul>
+ *
+ * <li><code>%h/java%u.log</code> will lead to a single log file
+ *     <code>/home/janet/java0.log</code>, assuming <code>count</code>
+ *     equals 1, the user's home directory is
+ *     <code>/home/janet</code>, and the attempt to open the file
+ *     succeeds.</li>
+ *
+ * <li><code>%h/java%u.log</code> will lead to three log files
+ *     <code>/home/janet/java0.log.0</code>,
+ *     <code>/home/janet/java0.log.1</code>, and
+ *     <code>/home/janet/java0.log.2</code>,
+ *     assuming <code>count</code> equals 3, the user's home
+ *     directory is <code>/home/janet</code>, and all attempts
+ *     to open files succeed.</li>
+ *
+ * <li><code>%h/java%u.log</code> will lead to three log files
+ *     <code>/home/janet/java0.log.0</code>,
+ *     <code>/home/janet/java1.log.1</code>, and
+ *     <code>/home/janet/java0.log.2</code>,
+ *     assuming <code>count</code> equals 3, the user's home
+ *     directory is <code>/home/janet</code>, and the attempt
+ *     to open <code>/home/janet/java0.log.1</code> fails.</li>
+ *
+ * </ul>
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public class FileHandler
+  extends StreamHandler
+{
+  /**
+   * A literal that prefixes all file-handler related properties in the
+   * logging.properties file.
+   */
+  private static final String PROPERTY_PREFIX = "java.util.logging.FileHandler";
+  /**
+   * The name of the property to set for specifying a file naming (incl. path)
+   * pattern to use with rotating log files.
+   */
+  private static final String PATTERN_KEY = PROPERTY_PREFIX + ".pattern";
+  /**
+   * The default pattern to use when the <code>PATTERN_KEY</code> property was
+   * not specified in the logging.properties file.
+   */
+  private static final String DEFAULT_PATTERN = "%h/java%u.log";
+  /**
+   * The name of the property to set for specifying an approximate maximum
+   * amount, in bytes, to write to any one log output file. A value of zero
+   * (which is the default) implies a no limit.
+   */
+  private static final String LIMIT_KEY = PROPERTY_PREFIX + ".limit";
+  private static final int DEFAULT_LIMIT = 0;
+  /**
+   * The name of the property to set for specifying how many output files to
+   * cycle through. The default value is 1.
+   */
+  private static final String COUNT_KEY = PROPERTY_PREFIX + ".count";
+  private static final int DEFAULT_COUNT = 1;
+  /**
+   * The name of the property to set for specifying whether this handler should
+   * append, or not, its output to existing files. The default value is
+   * <code>false</code> meaning NOT to append.
+   */
+  private static final String APPEND_KEY = PROPERTY_PREFIX + ".append";
+  private static final boolean DEFAULT_APPEND = false;
+
+  /**
+   * The number of bytes a log file is approximately allowed to reach
+   * before it is closed and the handler switches to the next file in
+   * the rotating set.  A value of zero means that files can grow
+   * without limit.
+   */
+  private final int limit;
+
+
+ /**
+  * The number of log files through which this handler cycles.
+  */
+  private final int count;
+
+
+  /**
+   * The pattern for the location and name of the produced log files.
+   * See the section on <a href="#filePatterns">file name patterns</a>
+   * for details.
+   */
+  private final String pattern;
+
+
+  /**
+   * Indicates whether the handler will append log records to existing
+   * files (<code>true</code>), or whether the handler will clear log files
+   * upon switching to them (<code>false</code>).
+   */
+  private final boolean append;
+
+
+  /**
+   * The number of bytes that have currently been written to the stream.
+   * Package private for use in inner classes.
+   */
+  long written;
+
+
+  /**
+   * A linked list of files we are, or have written to. The entries
+   * are file path strings, kept in the order 
+   */
+  private LinkedList logFiles;
+
+
+  /**
+   * Constructs a <code>FileHandler</code>, taking all property values
+   * from the current {@link LogManager LogManager} configuration.
+   *
+   * @throws java.io.IOException FIXME: The Sun Javadoc says: "if
+   *         there are IO problems opening the files."  This conflicts
+   *         with the general principle that configuration errors do
+   *         not prohibit construction. Needs review.
+   *
+   * @throws SecurityException if a security manager exists and
+   *         the caller is not granted the permission to control
+   *         the logging infrastructure.
+   */
+  public FileHandler()
+    throws IOException, SecurityException
+  {
+    this(LogManager.getLogManager().getProperty(PATTERN_KEY),
+	 LogManager.getIntProperty(LIMIT_KEY, DEFAULT_LIMIT),
+	 LogManager.getIntProperty(COUNT_KEY, DEFAULT_COUNT),
+	 LogManager.getBooleanProperty(APPEND_KEY, DEFAULT_APPEND));
+  }
+
+
+  /* FIXME: Javadoc missing. */
+  public FileHandler(String pattern)
+    throws IOException, SecurityException
+  {
+    this(pattern, DEFAULT_LIMIT, DEFAULT_COUNT, DEFAULT_APPEND);
+  }
+
+
+  /* FIXME: Javadoc missing. */
+  public FileHandler(String pattern, boolean append)
+    throws IOException, SecurityException
+  {
+    this(pattern, DEFAULT_LIMIT, DEFAULT_COUNT, append);
+  }
+
+
+  /* FIXME: Javadoc missing. */
+  public FileHandler(String pattern, int limit, int count)
+    throws IOException, SecurityException
+  {
+    this(pattern, limit, count, 
+	 LogManager.getBooleanProperty(APPEND_KEY, DEFAULT_APPEND));
+  }
+
+
+  /**
+   * Constructs a <code>FileHandler</code> given the pattern for the
+   * location and name of the produced log files, the size limit, the
+   * number of log files thorough which the handler will rotate, and
+   * the <code>append</code> property.  All other property values are
+   * taken from the current {@link LogManager LogManager}
+   * configuration.
+   *
+   * @param pattern The pattern for the location and name of the
+   *        produced log files.  See the section on <a
+   *        href="#filePatterns">file name patterns</a> for details.
+   *        If <code>pattern</code> is <code>null</code>, the value is
+   *        taken from the {@link LogManager LogManager} configuration
+   *        property
+   *        <code>java.util.logging.FileHandler.pattern</code>.
+   *        However, this is a pecularity of the GNU implementation,
+   *        and Sun's API specification does not mention what behavior
+   *        is to be expected for <code>null</code>. Therefore,
+   *        applications should not rely on this feature.
+   *
+   * @param limit specifies the number of bytes a log file is
+   *        approximately allowed to reach before it is closed and the
+   *        handler switches to the next file in the rotating set.  A
+   *        value of zero means that files can grow without limit.
+   *
+   * @param count specifies the number of log files through which this
+   *        handler cycles.
+   *
+   * @param append specifies whether the handler will append log
+   *        records to existing files (<code>true</code>), or whether the
+   *        handler will clear log files upon switching to them
+   *        (<code>false</code>).
+   *
+   * @throws java.io.IOException FIXME: The Sun Javadoc says: "if
+   *         there are IO problems opening the files."  This conflicts
+   *         with the general principle that configuration errors do
+   *         not prohibit construction. Needs review.
+   *
+   * @throws SecurityException if a security manager exists and
+   *         the caller is not granted the permission to control
+   *         the logging infrastructure.
+   *         <p>FIXME: This seems in contrast to all other handler
+   *         constructors -- verify this by running tests against
+   *         the Sun reference implementation.
+   */
+  public FileHandler(String pattern,
+		     int limit,
+		     int count,
+		     boolean append)
+    throws IOException, SecurityException
+  {
+    super(/* output stream, created below */ null,
+	  PROPERTY_PREFIX,
+	  /* default level */ Level.ALL,
+	  /* formatter */ null,
+	  /* default formatter */ XMLFormatter.class);
+
+    if ((limit <0) || (count < 1))
+      throw new IllegalArgumentException();
+
+    this.pattern = pattern != null ? pattern : DEFAULT_PATTERN;
+    this.limit = limit;
+    this.count = count;
+    this.append = append;
+    this.written = 0;
+    this.logFiles = new LinkedList ();
+
+    setOutputStream (createFileStream (this.pattern, limit, count, append,
+                                       /* generation */ 0));
+  }
+
+
+  /* FIXME: Javadoc missing. */
+  private OutputStream createFileStream(String pattern,
+                                        int limit,
+                                        int count,
+                                        boolean append,
+                                        int generation)
+  {
+    String  path;
+    int     unique = 0;
+
+    /* Throws a SecurityException if the caller does not have
+     * LoggingPermission("control").
+     */
+    LogManager.getLogManager().checkAccess();
+
+    /* Default value from the java.util.logging.FileHandler.pattern
+     * LogManager configuration property.
+     */
+    if (pattern == null)
+      pattern = LogManager.getLogManager().getProperty(PATTERN_KEY);
+    if (pattern == null)
+      pattern = DEFAULT_PATTERN;
+
+    if (count > 1 && !has (pattern, 'g'))
+      pattern = pattern + ".%g";
+
+    do
+    {
+      path = replaceFileNameEscapes(pattern, generation, unique, count);
+
+      try
+      {
+	File file = new File(path);
+        if (!file.exists () || append)
+          {
+            FileOutputStream fout = new FileOutputStream (file, append);
+            // FIXME we need file locks for this to work properly, but they
+            // are not implemented yet in Classpath! Madness!
+//             FileChannel channel = fout.getChannel ();
+//             FileLock lock = channel.tryLock ();
+//             if (lock != null) // We've locked the file.
+//               {
+                if (logFiles.isEmpty ())
+                  logFiles.addFirst (path);
+                return new ostr (fout);
+//               }
+          }
+      }
+      catch (Exception ex)
+      {
+        reportError (null, ex, ErrorManager.OPEN_FAILURE);
+      }
+
+      unique = unique + 1;
+      if (!has (pattern, 'u'))
+        pattern = pattern + ".%u";
+    }
+    while (true);
+  }
+
+
+  /**
+   * Replaces the substrings <code>"/"</code> by the value of the
+   * system property <code>"file.separator"</code>, <code>"%t"</code>
+   * by the value of the system property
+   * <code>"java.io.tmpdir"</code>, <code>"%h"</code> by the value of
+   * the system property <code>"user.home"</code>, <code>"%g"</code>
+   * by the value of <code>generation</code>, <code>"%u"</code> by the
+   * value of <code>uniqueNumber</code>, and <code>"%%"</code> by a
+   * single percent character.  If <code>pattern</code> does
+   * <em>not</em> contain the sequence <code>"%g"</code>,
+   * the value of <code>generation</code> will be appended to
+   * the result.
+   *
+   * @throws NullPointerException if one of the system properties
+   *         <code>"file.separator"</code>,
+   *         <code>"java.io.tmpdir"</code>, or
+   *         <code>"user.home"</code> has no value and the
+   *         corresponding escape sequence appears in
+   *         <code>pattern</code>.
+   */
+  private static String replaceFileNameEscapes(String pattern,
+					       int generation,
+					       int uniqueNumber,
+					       int count)
+  {
+    StringBuffer buf = new StringBuffer(pattern);
+    String       replaceWith;
+    boolean      foundGeneration = false;
+
+    int pos = 0;
+    do
+    {
+      // Uncomment the next line for finding bugs.
+      // System.out.println(buf.substring(0,pos) + '|' + buf.substring(pos));
+      
+      if (buf.charAt(pos) == '/')
+      {
+	/* The same value is also provided by java.io.File.separator. */
+	replaceWith = System.getProperty("file.separator");
+	buf.replace(pos, pos + 1, replaceWith);
+	pos = pos + replaceWith.length() - 1;
+	continue;
+      }
+
+      if (buf.charAt(pos) == '%')
+      {
+        switch (buf.charAt(pos + 1))
+	{
+	case 't':
+	  replaceWith = System.getProperty("java.io.tmpdir");
+	  break;
+
+	case 'h':
+	  replaceWith = System.getProperty("user.home");
+	  break;
+
+	case 'g':
+	  replaceWith = Integer.toString(generation);
+	  foundGeneration = true;
+	  break;
+
+	case 'u':
+	  replaceWith = Integer.toString(uniqueNumber);
+	  break;
+
+	case '%':
+	  replaceWith = "%";
+	  break;
+
+	default:
+	  replaceWith = "??";
+	  break; // FIXME: Throw exception?
+	}
+
+	buf.replace(pos, pos + 2, replaceWith);
+	pos = pos + replaceWith.length() - 1;
+	continue;
+      }
+    }
+    while (++pos < buf.length() - 1);
+
+    if (!foundGeneration && (count > 1))
+    {
+      buf.append('.');
+      buf.append(generation);
+    }
+
+    return buf.toString();
+  }
+
+
+  /* FIXME: Javadoc missing. */
+  public void publish(LogRecord record)
+  {
+    if (limit > 0 && written >= limit)
+      rotate ();
+    super.publish(record);
+    flush ();
+  }
+
+  /**
+   * Rotates the current log files, possibly removing one if we
+   * exceed the file count.
+   */
+  private synchronized void rotate ()
+  {
+    if (logFiles.size () > 0)
+      {
+        File f1 = null;
+        ListIterator lit = null;
+
+        // If we reach the file count, ditch the oldest file.
+        if (logFiles.size () == count)
+          {
+            f1 = new File ((String) logFiles.getLast ());
+            f1.delete ();
+            lit = logFiles.listIterator (logFiles.size () - 1);
+          }
+        // Otherwise, move the oldest to a new location.
+        else
+          {
+            String path = replaceFileNameEscapes (pattern, logFiles.size (),
+                                                  /* unique */ 0, count);
+            f1 = new File (path);
+            logFiles.addLast (path);
+            lit = logFiles.listIterator (logFiles.size () - 1);
+          }
+
+        // Now rotate the files.
+        while (lit.hasPrevious ())
+          {
+            String s = (String) lit.previous ();
+            File f2 = new File (s);
+            f2.renameTo (f1);
+            f1 = f2;
+          }
+      }
+
+    setOutputStream (createFileStream (pattern, limit, count, append,
+                                       /* generation */ 0));
+
+    // Reset written count.
+    written = 0;
+  }
+
+  /**
+   * Tell if <code>pattern</code> contains the pattern sequence
+   * with character <code>escape</code>. That is, if <code>escape</code>
+   * is 'g', this method returns true if the given pattern contains
+   * "%g", and not just the substring "%g" (for example, in the case of
+   * "%%g").
+   *
+   * @param pattern The pattern to test.
+   * @param escape The escape character to search for.
+   * @return True iff the pattern contains the escape sequence with the
+   *  given character.
+   */
+  private static boolean has (final String pattern, final char escape)
+  {
+    final int len = pattern.length ();
+    boolean sawPercent = false;
+    for (int i = 0; i < len; i++)
+      {
+        char c = pattern.charAt (i);
+        if (sawPercent)
+          {
+            if (c == escape)
+              return true;
+            if (c == '%') // Double percent
+              {
+                sawPercent = false;
+                continue;
+              }
+          }
+        sawPercent = (c == '%');
+      }
+    return false;
+  }
+
+  /**
+   * An output stream that tracks the number of bytes written to it.
+   */
+  private final class ostr extends FilterOutputStream
+  {
+    private ostr (OutputStream out)
+    {
+      super (out);
+    }
+
+    public void write (final int b) throws IOException
+    {
+      out.write (b);
+      FileHandler.this.written++; // FIXME: synchronize?
+    }
+
+    public void write (final byte[] b) throws IOException
+    {
+      write (b, 0, b.length);
+    }
+
+    public void write (final byte[] b, final int offset, final int length)
+      throws IOException
+    {
+      out.write (b, offset, length);
+      FileHandler.this.written += length; // FIXME: synchronize?
+    }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Filter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Filter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Filter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Filter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,64 @@
+/* Filter.java -- an interface for filters that decide whether a
+   LogRecord should be published or discarded
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+/**
+ * By implementing the <code>Filter</code> interface, applications
+ * can control what is being logged based on arbitrary properties,
+ * not just the severity level.  Both <code>Handler</code> and
+ * <code>Logger</code> allow to register Filters whose
+ * <code>isLoggable</code> method will be called when a
+ * <code>LogRecord</code> has passed the test based on the
+ * severity level.
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public interface Filter
+{
+  /**
+   * Determines whether a LogRecord should be published or discarded.
+   *
+   * @param record the <code>LogRecord</code> to be inspected.
+   *
+   * @return <code>true</code> if the record should be published,
+   *         <code>false</code> if it should be discarded.
+   */
+  boolean isLoggable(LogRecord record);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Formatter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Formatter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Formatter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Formatter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,171 @@
+/* Formatter.java --
+   A class for formatting log messages by localizing message texts
+   and performing substitution of parameters
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+/**
+ * A <code>Formatter</code> supports handlers by localizing
+ * message texts and by subsituting parameter values for their
+ * placeholders.
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public abstract class Formatter
+{
+  /**
+   * Constructs a new Formatter.
+   */
+  protected Formatter()
+  {
+  }
+
+
+  /**
+   * Formats a LogRecord into a string.  Usually called by handlers
+   * which need a string for a log record, for example to append
+   * a record to a log file or to transmit a record over the network.
+   *
+   * @param record the log record for which a string form is requested.
+   */
+  public abstract String format(LogRecord record);
+
+
+  /**
+   * Returns a string that handlers are supposed to emit before
+   * the first log record.  The base implementation returns an
+   * empty string, but subclasses such as {@link XMLFormatter}
+   * override this method in order to provide a suitable header.
+   *
+   * @return a string for the header.
+   *
+   * @param handler the handler which will prepend the returned
+   *     string in front of the first log record.  This method
+   *     may inspect certain properties of the handler, for
+   *     example its encoding, in order to construct the header.
+   */
+  public String getHead(Handler handler)
+  {
+    return "";
+  }
+
+
+  /**
+   * Returns a string that handlers are supposed to emit after
+   * the last log record.  The base implementation returns an
+   * empty string, but subclasses such as {@link XMLFormatter}
+   * override this method in order to provide a suitable tail.
+   *
+   * @return a string for the header.
+   *
+   * @param handler the handler which will append the returned
+   *     string after the last log record.  This method
+   *     may inspect certain properties of the handler
+   *     in order to construct the tail.
+   */
+  public String getTail(Handler handler)
+  {
+    return "";
+  }
+
+
+  /**
+   * Formats the message part of a log record.
+   *
+   * <p>First, the Formatter localizes the record message to the
+   * default locale by looking up the message in the record's
+   * localization resource bundle.  If this step fails because there
+   * is no resource bundle associated with the record, or because the
+   * record message is not a key in the bundle, the raw message is
+   * used instead.
+   *
+   * <p>Second, the Formatter substitutes appropriate strings for
+   * the message parameters. If the record returns a non-empty
+   * array for <code>getParameters()</code> and the localized
+   * message string contains the character sequence "{0", the
+   * formatter uses <code>java.text.MessageFormat</code> to format
+   * the message.  Otherwise, no parameter substitution is performed.
+   *
+   * @param record the log record to be localized and formatted.
+   *
+   * @return the localized message text where parameters have been
+   *         substituted by suitable strings.
+   *
+   * @throws NullPointerException if <code>record</code>
+   *         is <code>null</code>.
+   */
+  public String formatMessage(LogRecord record)
+  {
+    String          msg;
+    ResourceBundle  bundle;
+    Object[]        params;
+
+    /* This will throw a NullPointerExceptionif record is null. */
+    msg = record.getMessage();
+    if (msg == null)
+      msg = "";
+
+    /* Try to localize the message. */
+    bundle = record.getResourceBundle();
+    if (bundle != null)
+    {
+      try
+      {
+	msg = bundle.getString(msg);
+      }
+      catch (java.util.MissingResourceException _)
+      {
+      }
+    }
+
+    /* Format the message if there are parameters. */
+    params = record.getParameters();
+    if ((params != null)
+	&& (params.length > 0)
+	&& (msg.indexOf("{0") >= 0))
+    {
+      msg = MessageFormat.format(msg, params);
+    }
+
+    return msg;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Handler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Handler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Handler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Handler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,386 @@
+/* Handler.java -- a class for publishing log messages
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * A <code>Handler</code> publishes <code>LogRecords</code> to
+ * a sink, for example a file, the console or a network socket.
+ * There are different subclasses of <code>Handler</code>
+ * to deal with different kinds of sinks.
+ *
+ * <p>FIXME: Are handlers thread-safe, or is the assumption that only
+ * loggers are, and a handler can belong only to one single logger? If
+ * the latter, should we enforce it? (Spec not clear). In any
+ * case, it needs documentation.
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public abstract class Handler
+{
+  Formatter     formatter;
+  Filter        filter;
+  Level         level;
+  ErrorManager  errorManager;
+  String        encoding;
+
+  /**
+   * Constructs a Handler with a logging severity level of
+   * <code>Level.ALL</code>, no formatter, no filter, and
+   * an instance of <code>ErrorManager</code> managing errors.
+   *
+   * <p><strong>Specification Note:</strong> The specification of the
+   * Java<sup>TM</sup> Logging API does not mention which character
+   * encoding is to be used by freshly constructed Handlers.  The GNU
+   * implementation uses the default platform encoding, but other
+   * Java implementations might behave differently.
+   *
+   * <p><strong>Specification Note:</strong> While a freshly constructed
+   * Handler is required to have <em>no filter</em> according to the
+   * specification, <code>null</code> is not a valid parameter for
+   * <code>Handler.setFormatter</code>.  Therefore, the following
+   * code will throw a <code>java.lang.NullPointerException</code>:
+   *
+   * <p><pre>Handler h = new MyConcreteSubclassOfHandler();
+h.setFormatter(h.getFormatter());</pre>
+   *
+   * It seems strange that a freshly constructed Handler is not
+   * supposed to provide a Formatter, but this is what the specification
+   * says.
+   */
+  protected Handler()
+  {
+    level = Level.ALL;
+  }
+
+
+  /**
+   * Publishes a <code>LogRecord</code> to an appropriate sink,
+   * provided the record passes all tests for being loggable.  The
+   * <code>Handler</code> will localize the message of the log
+   * record and substitute any message parameters.
+   *
+   * <p>Most applications do not need to call this method directly.
+   * Instead, they will use use a {@link Logger}, which will
+   * create LogRecords and distribute them to registered handlers.
+   *
+   * <p>In case of an I/O failure, the <code>ErrorManager</code>
+   * of this <code>Handler</code> will be informed, but the caller
+   * of this method will not receive an exception.
+   *
+   * @param record the log event to be published.
+   */
+  public abstract void publish(LogRecord record);
+
+
+  /**
+   * Forces any data that may have been buffered to the underlying
+   * output device.
+   *
+   * <p>In case of an I/O failure, the <code>ErrorManager</code>
+   * of this <code>Handler</code> will be informed, but the caller
+   * of this method will not receive an exception.
+   */
+  public abstract void flush();
+
+
+  /**
+   * Closes this <code>Handler</code> after having flushed
+   * the buffers.  As soon as <code>close</code> has been called,
+   * a <code>Handler</code> should not be used anymore. Attempts
+   * to publish log records, to flush buffers, or to modify the
+   * <code>Handler</code> in any other way may throw runtime
+   * exceptions after calling <code>close</code>.
+   *
+   * <p>In case of an I/O failure, the <code>ErrorManager</code>
+   * of this <code>Handler</code> will be informed, but the caller
+   * of this method will not receive an exception.
+   *
+   * @throws SecurityException if a security manager exists and
+   *         the caller is not granted the permission to control
+   *         the logging infrastructure.
+   */
+  public abstract void close()
+    throws SecurityException;
+
+
+  /**
+   * Returns the <code>Formatter</code> which will be used to
+   * localize the text of log messages and to substitute
+   * message parameters.  A <code>Handler</code> is encouraged,
+   * but not required to actually use an assigned
+   * <code>Formatter</code>.
+   *
+   * @return the <code>Formatter</code> being used, or
+   *         <code>null</code> if this <code>Handler</code>
+   *         does not use formatters and no formatter has
+   *         ever been set by calling <code>setFormatter</code>.
+   */
+  public Formatter getFormatter()
+  {
+    return formatter;
+  }
+
+
+  /**
+   * Sets the <code>Formatter</code> which will be used to
+   * localize the text of log messages and to substitute
+   * message parameters.  A <code>Handler</code> is encouraged,
+   * but not required to actually use an assigned
+   * <code>Formatter</code>.
+   *
+   * @param formatter the new <code>Formatter</code> to use.
+   *
+   * @throws SecurityException if a security manager exists and
+   *         the caller is not granted the permission to control
+   *         the logging infrastructure.
+   *
+   * @throws NullPointerException if <code>formatter</code> is
+   *         <code>null</code>.
+   */
+  public void setFormatter(Formatter formatter)
+    throws SecurityException
+  {
+    LogManager.getLogManager().checkAccess();
+    
+    /* Throws a NullPointerException if formatter is null. */
+    formatter.getClass();
+
+    this.formatter = formatter;
+  }
+
+
+  /**
+   * Returns the character encoding which this handler uses for publishing
+   * log records.
+   *
+   * @return the name of a character encoding, or <code>null</code>
+   *         for the default platform encoding.
+   */
+  public String getEncoding()
+  {
+    return encoding;
+  }
+
+
+  /**
+   * Sets the character encoding which this handler uses for publishing
+   * log records.  The encoding of a <code>Handler</code> must be
+   * set before any log records have been published.
+   *
+   * @param encoding the name of a character encoding, or <code>null</code>
+   *            for the default encoding.
+   *
+   * @exception SecurityException if a security manager exists and
+   *            the caller is not granted the permission to control
+   *            the logging infrastructure.
+   *
+   */
+  public void setEncoding(String encoding)
+    throws SecurityException, UnsupportedEncodingException
+  {
+    /* Should any developer ever change this implementation, they are
+     * advised to have a look at StreamHandler.setEncoding(String),
+     * which overrides this method without calling super.setEncoding.
+     */
+    LogManager.getLogManager().checkAccess();
+
+    /* Simple check for supported encodings. This is more expensive
+     * than it could be, but this method is overwritten by StreamHandler
+     * anyway.
+     */
+    if (encoding != null)
+      new String(new byte[0], encoding);
+
+    this.encoding = encoding;
+  }
+
+
+  /**
+   * Returns the <code>Filter</code> that currently controls which
+   * log records are being published by this <code>Handler</code>.
+   *
+   * @return the currently active <code>Filter</code>, or
+   *         <code>null</code> if no filter has been associated.
+   *         In the latter case, log records are filtered purely
+   *         based on their severity level.
+   */
+  public Filter getFilter()
+  {
+    return filter;
+  }
+
+
+  /**
+   * Sets the <code>Filter</code> for controlling which
+   * log records will be published by this <code>Handler</code>.
+   *
+   * @param filter the <code>Filter</code> to use, or
+   *         <code>null</code> to filter log records purely based
+   *         on their severity level.
+   */
+  public void setFilter(Filter filter)
+    throws SecurityException
+  {
+    LogManager.getLogManager().checkAccess();
+    this.filter = filter;
+  }
+
+
+  /**
+   * Returns the <code>ErrorManager</code> that currently deals
+   * with errors originating from this Handler.
+   *
+   * @exception SecurityException if a security manager exists and
+   *            the caller is not granted the permission to control
+   *            the logging infrastructure.
+   */
+  public ErrorManager getErrorManager()
+  {
+    LogManager.getLogManager().checkAccess();
+
+    /* Developers wanting to change the subsequent code should
+     * have a look at Handler.reportError -- it also can create
+     * an ErrorManager, but does so without checking permissions
+     * to control the logging infrastructure.
+     */
+    if (errorManager == null)
+      errorManager = new ErrorManager();
+
+    return errorManager;
+  }
+
+
+  public void setErrorManager(ErrorManager manager)
+  {
+    LogManager.getLogManager().checkAccess();
+
+    /* Make sure manager is not null. */
+    manager.getClass();
+
+    this.errorManager = manager;
+  }
+
+
+  protected void reportError(String message, Exception ex, int code)
+  {
+    if (errorManager == null)
+      errorManager = new ErrorManager();
+
+    errorManager.error(message, ex, code);
+  }
+
+
+  /**
+   * Returns the severity level threshold for this <code>Handler</code>
+   * All log records with a lower severity level will be discarded;
+   * a log record of the same or a higher level will be published
+   * unless an installed <code>Filter</code> decides to discard it.
+   *
+   * @return the severity level below which all log messages
+   *         will be discarded.
+   */
+  public Level getLevel()
+  {
+    return level;
+  }
+
+
+  /**
+   * Sets the severity level threshold for this <code>Handler</code>.
+   * All log records with a lower severity level will be discarded;
+   * a log record of the same or a higher level will be published
+   * unless an installed <code>Filter</code> decides to discard it.
+   *
+   * @param level the severity level below which all log messages
+   *              will be discarded.
+   *
+   * @exception SecurityException if a security manager exists and
+   *            the caller is not granted the permission to control
+   *            the logging infrastructure.
+   *
+   * @exception NullPointerException if <code>level</code> is
+   *            <code>null</code>.
+   */
+  public void setLevel(Level level)
+  {
+    LogManager.getLogManager().checkAccess();
+
+    /* Throw NullPointerException if level is null.  */
+    level.getClass();
+    this.level = level;
+  }
+
+
+  /**
+   * Checks whether a <code>LogRecord</code> would be logged
+   * if it was passed to this <code>Handler</code> for publication.
+   *
+   * <p>The <code>Handler</code> implementation considers a record as
+   * loggable if its level is greater than or equal to the severity
+   * level threshold.  In a second step, if a {@link Filter} has
+   * been installed, its {@link Filter#isLoggable(LogRecord) isLoggable}
+   * method is invoked. Subclasses of <code>Handler</code> can override
+   * this method to impose their own constraints.
+   *
+   * @param record the <code>LogRecord</code> to be checked.
+   *
+   * @return <code>true</code> if <code>record</code> would
+   *         be published by {@link #publish(LogRecord) publish},
+   *         <code>false</code> if it would be discarded.
+   *
+   * @see #setLevel(Level)
+   * @see #setFilter(Filter)
+   * @see Filter#isLoggable(LogRecord)
+   *
+   * @throws NullPointerException if <code>record</code>
+   *         is <code>null</code>.
+   */
+  public boolean isLoggable(LogRecord record)
+  {
+    if (record.getLevel().intValue() < level.intValue())
+      return false;
+    
+    if (filter != null)
+      return filter.isLoggable(record);
+    else
+      return true;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Level.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Level.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Level.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Level.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,417 @@
+/* Level.java -- a class for indicating logging levels
+   Copyright (C) 2002, 2005, 2006  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+import java.io.Serializable;
+import java.util.ResourceBundle;
+
+/**
+ * A class for indicating logging levels.  A number of commonly used
+ * levels is pre-defined (such as <code>java.util.logging.Level.INFO</code>),
+ * and applications should utilize those whenever possible.  For specialized
+ * purposes, however, applications can sub-class Level in order to define
+ * custom logging levels.
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public class Level implements Serializable
+{
+  /* The integer values are the same as in the Sun J2SE 1.4.
+   * They have been obtained with a test program. In J2SE 1.4.1,
+   * Sun has amended the API documentation; these values are now
+   * publicly documented.
+   */
+
+  /**
+   * The <code>OFF</code> level is used as a threshold for filtering
+   * log records, meaning that no message should be logged.
+   *
+   * @see Logger#setLevel(java.util.logging.Level)
+   */
+  public static final Level OFF = new Level ("OFF", Integer.MAX_VALUE);
+
+  /**
+   * Log records whose level is <code>SEVERE</code> indicate a serious
+   * failure that prevents normal program execution.  Messages at this
+   * level should be understandable to an inexperienced, non-technical
+   * end user.  Ideally, they explain in simple words what actions the
+   * user can take in order to resolve the problem.
+   */
+  public static final Level SEVERE = new Level ("SEVERE", 1000);
+
+
+  /**
+   * Log records whose level is <code>WARNING</code> indicate a
+   * potential problem that does not prevent normal program execution.
+   * Messages at this level should be understandable to an
+   * inexperienced, non-technical end user.  Ideally, they explain in
+   * simple words what actions the user can take in order to resolve
+   * the problem.
+   */
+  public static final Level WARNING = new Level ("WARNING", 900);
+
+
+  /**
+   * Log records whose level is <code>INFO</code> are used in purely
+   * informational situations that do not constitute serious errors or
+   * potential problems. In the default logging configuration, INFO
+   * messages will be written to the system console.  For this reason,
+   * the INFO level should be used only for messages that are
+   * important to end users and system administrators.  Messages at
+   * this level should be understandable to an inexperienced,
+   * non-technical user.
+   */
+  public static final Level INFO = new Level ("INFO", 800);
+
+
+  /**
+   * Log records whose level is <code>CONFIG</code> are used for
+   * describing the static configuration, for example the windowing
+   * environment, the operating system version, etc.
+   */
+  public static final Level CONFIG = new Level ("CONFIG", 700);
+
+
+  /**
+   * Log records whose level is <code>FINE</code> are typically used
+   * for messages that are relevant for developers using
+   * the component generating log messages.  Examples include minor,
+   * recoverable failures, or possible inefficiencies.
+   */
+  public static final Level FINE = new Level ("FINE", 500);
+
+
+  /**
+   * Log records whose level is <code>FINER</code> are intended for
+   * rather detailed tracing, for example entering a method, returning
+   * from a method, or throwing an exception.
+   */
+  public static final Level FINER = new Level ("FINER", 400);
+
+
+  /**
+   * Log records whose level is <code>FINEST</code> are used for
+   * highly detailed tracing, for example to indicate that a certain
+   * point inside the body of a method has been reached.
+   */
+  public static final Level FINEST = new Level ("FINEST", 300);
+
+
+  /**
+   * The <code>ALL</code> level is used as a threshold for filtering
+   * log records, meaning that every message should be logged.
+   *
+   * @see Logger#setLevel(java.util.logging.Level)
+   */
+  public static final Level ALL = new Level ("ALL", Integer.MIN_VALUE);
+
+
+  private static final Level[] knownLevels = {
+    ALL, FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE, OFF
+  };
+
+
+  /**
+   * The name of the Level without localizing it, for example
+   * "WARNING".
+   */
+  private String name;
+
+
+  /**
+   * The integer value of this <code>Level</code>.
+   */
+  private int value;
+
+
+  /**
+   * The name of the resource bundle used for localizing the level
+   * name, or <code>null</code> if the name does not undergo
+   * localization.
+   */
+  private String resourceBundleName;
+
+
+  /**
+   * Creates a logging level given a name and an integer value.
+   * It rarely is necessary to create custom levels,
+   * as most applications should be well served with one of the
+   * standard levels such as <code>Level.CONFIG</code>,
+   * <code>Level.INFO</code>, or <code>Level.FINE</code>.
+   *
+   * @param name the name of the level.
+   *
+   * @param value the integer value of the level.  Please note
+   *     that the Java<small><sup>TM</sup></small>
+   *     Logging API does not specify integer
+   *	 values for standard levels (such as
+   *	 Level.FINE).  Therefore, a custom
+   *	 level should pass an integer value that
+   *	 is calculated at run-time, e.g.
+   *	 <code>(Level.FINE.intValue() + Level.CONFIG.intValue())
+   *	 / 2</code> for a level between FINE and CONFIG.
+   */
+  protected Level(String name, int value)
+  {
+    this(name, value, null);
+  }
+
+
+  /**
+   * Create a logging level given a name, an integer value and a name
+   * of a resource bundle for localizing the level name.  It rarely
+   * is necessary to create custom levels, as most applications
+   * should be well served with one of the standard levels such as
+   * <code>Level.CONFIG</code>, <code>Level.INFO</code>, or
+   * <code>Level.FINE</code>.
+   *
+   * @param name the name of the level.
+   *
+   * @param value the integer value of the level.  Please note
+   *        that the Java<small><sup>TM</sup></small>
+   *	    Logging API does not specify integer
+   *	    values for standard levels (such as
+   *	    Level.FINE).  Therefore, a custom
+   *	    level should pass an integer value that
+   *	    is calculated at run-time, e.g.
+   *	    <code>(Level.FINE.intValue() + Level.CONFIG.intValue())
+   *	    / 2</code> for a level between FINE and CONFIG.
+   *
+   * @param resourceBundleName the name of a resource bundle
+   *       for localizing the level name, or <code>null</code>
+   *       if the name does not need to be localized.
+   */
+  protected Level(String name, int value, String resourceBundleName)
+  {
+    this.name = name;
+    this.value = value;
+    this.resourceBundleName = resourceBundleName;
+  }
+
+
+  static final long serialVersionUID = -8176160795706313070L;
+
+
+  /**
+   * Checks whether the Level has the same intValue as one of the
+   * pre-defined levels.  If so, the pre-defined level object is
+   * returned.
+   *
+   * <br/>Since the resource bundle name is not taken into
+   * consideration, it is possible to resolve Level objects that have
+   * been de-serialized by another implementation, even if the other
+   * implementation uses a different resource bundle for localizing
+   * the names of pre-defined levels.
+   */
+  private Object readResolve()
+  {
+    for (int i = 0; i < knownLevels.length; i++)
+      if (value == knownLevels[i].intValue())
+	return knownLevels[i];
+
+    return this;
+  }
+
+
+  /**
+   * Returns the name of the resource bundle used for localizing the
+   * level name.
+   *
+   * @return the name of the resource bundle used for localizing the
+   * level name, or <code>null</code> if the name does not undergo
+   * localization.
+   */
+  public String getResourceBundleName()
+  {
+    return resourceBundleName;
+  }
+
+
+  /**
+   * Returns the name of the Level without localizing it, for example
+   * "WARNING".
+   */
+  public String getName()
+  {
+    return name;
+  }
+
+
+  /**
+   * Returns the name of the Level after localizing it, for example
+   * "WARNUNG".
+   */
+  public String getLocalizedName()
+  {
+    String localizedName = null;
+
+    if (resourceBundleName != null)
+    {
+      try
+      {
+        ResourceBundle b = ResourceBundle.getBundle(resourceBundleName);
+	localizedName = b.getString(name);
+      }
+      catch (Exception _)
+      {
+      }
+    }
+
+    if (localizedName != null)
+      return localizedName;
+    else
+      return name;
+  }
+
+
+  /**
+   * Returns the name of the Level without localizing it, for example
+   * "WARNING".
+   */
+  public final String toString()
+  {
+    return getName();
+  }
+
+
+  /**
+   * Returns the integer value of the Level.
+   */
+  public final int intValue()
+  {
+    return value;
+  }
+
+
+  /**
+   * Returns one of the standard Levels given either its name or its
+   * integer value.  Custom subclasses of Level will not be returned
+   * by this method.
+   *
+   * @throws IllegalArgumentException if <code>name</code> is neither
+   * the name nor the integer value of one of the pre-defined standard
+   * logging levels.
+   *
+   * @throws NullPointerException if <code>name</code> is null.
+   *
+   */
+  public static Level parse(String name)
+    throws IllegalArgumentException
+  {
+    /* This will throw a NullPointerException if name is null,
+     * as required by the API specification.
+     */
+    name = name.intern();
+
+    for (int i = 0; i < knownLevels.length; i++)
+    {
+      // It's safe to use == instead of .equals here because only the
+      // standard logging levels will be returned by this method, and
+      // they are all created using string literals.
+      if (name == knownLevels[i].name)
+	return knownLevels[i];
+    }
+    
+    try
+    {
+      int num = Integer.parseInt(name);
+      for (int i = 0; i < knownLevels.length; i++)
+	if (num == knownLevels[i].value)
+	  return knownLevels[i];
+    }
+    catch (NumberFormatException _)
+    {
+    }
+
+    String msg = "Not the name of a standard logging level: \"" + name + "\"";
+    throw new IllegalArgumentException(msg);
+  }
+
+
+  /**
+   * Checks whether this Level's integer value is equal to that of
+   * another object.
+   *
+   * @return <code>true</code> if <code>other</code> is an instance of
+   *	 <code>java.util.logging.Level</code> and has the same integer
+   * value, <code>false</code> otherwise.
+   */
+  public boolean equals(Object other)
+  {
+    if (!(other instanceof Level))
+      return false;
+
+    return value == ((Level) other).value;
+  }
+
+
+  /**
+   * Returns a hash code for this Level which is based on its numeric
+   * value.
+   */
+  public int hashCode()
+  {
+    return value;
+  }  
+
+
+  /**
+   * Determines whether or not this Level is one of the standard
+   * levels specified in the Logging API.
+   *
+   * <p>This method is package-private because it is not part
+   * of the logging API specification.  However, an XMLFormatter
+   * is supposed to emit the numeric value for a custom log
+   * level, but the name for a pre-defined level. It seems
+   * cleaner to put this method to Level than to write some
+   * procedural code for XMLFormatter.
+   *
+   * @return <code>true</code> if this Level is a standard level,
+   *         <code>false</code> otherwise.
+   */
+  final boolean isStandardLevel()
+  {
+    for (int i = 0; i < knownLevels.length; i++)
+      if (knownLevels[i] == this)
+	return true;
+
+    return false;
+  }
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LogManager.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LogManager.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LogManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LogManager.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,979 @@
+/* LogManager.java -- a class for maintaining Loggers and managing
+   configuration properties
+   Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+import gnu.classpath.SystemProperties;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.ref.WeakReference;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+/**
+ * The <code>LogManager</code> maintains a hierarchical namespace
+ * of Logger objects and manages properties for configuring the logging
+ * framework. There exists only one single <code>LogManager</code>
+ * per virtual machine. This instance can be retrieved using the
+ * static method {@link #getLogManager()}.
+ *
+ * <p><strong>Configuration Process:</strong> The global LogManager
+ * object is created and configured when the class
+ * <code>java.util.logging.LogManager</code> is initialized.
+ * The configuration process includes the subsequent steps:
+ *
+ * <ul>
+ * <li>If the system property <code>java.util.logging.manager</code>
+ *     is set to the name of a subclass of
+ *     <code>java.util.logging.LogManager</code>, an instance of
+ *     that subclass is created and becomes the global LogManager.
+ *     Otherwise, a new instance of LogManager is created.</li>
+ * <li>The <code>LogManager</code> constructor tries to create
+ *     a new instance of the class specified by the system
+ *     property <code>java.util.logging.config.class</code>.
+ *     Typically, the constructor of this class will call
+ *     <code>LogManager.getLogManager().readConfiguration(java.io.InputStream)</code>
+ *     for configuring the logging framework.
+ *     The configuration process stops at this point if
+ *     the system property <code>java.util.logging.config.class</code>
+ *     is set (irrespective of whether the class constructor
+ *     could be called or an exception was thrown).</li>
+ *
+ * <li>If the system property <code>java.util.logging.config.class</code>
+ *     is <em>not</em> set, the configuration parameters are read in from
+ *     a file and passed to
+ *     {@link #readConfiguration(java.io.InputStream)}.
+ *     The name and location of this file are specified by the system
+ *     property <code>java.util.logging.config.file</code>.</li>
+ * <li>If the system property <code>java.util.logging.config.file</code>
+ *     is not set, however, the contents of the URL
+ *     "{gnu.classpath.home.url}/logging.properties" are passed to
+ *     {@link #readConfiguration(java.io.InputStream)}.
+ *     Here, "{gnu.classpath.home.url}" stands for the value of
+ *     the system property <code>gnu.classpath.home.url</code>.</li>
+ * </ul>
+ *
+ * <p>The <code>LogManager</code> has a level of <code>INFO</code> by
+ * default, and this will be inherited by <code>Logger</code>s unless they
+ * override it either by properties or programmatically.
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public class LogManager
+{
+  /**
+   * The object name for the logging management bean.
+   * @since 1.5
+   */
+  public static final String LOGGING_MXBEAN_NAME
+    = "java.util.logging:type=Logging";
+
+  /**
+   * The singleton LogManager instance.
+   */
+  private static LogManager logManager;
+
+  /**
+   * The singleton logging bean.
+   */
+  private static LoggingMXBean loggingBean;
+
+  /**
+   * The registered named loggers; maps the name of a Logger to
+   * a WeakReference to it.
+   */
+  private Map loggers;
+
+  /**
+   * The properties for the logging framework which have been
+   * read in last.
+   */
+  private Properties properties;
+
+  /**
+   * A delegate object that provides support for handling
+   * PropertyChangeEvents.  The API specification does not
+   * mention which bean should be the source in the distributed
+   * PropertyChangeEvents, but Mauve test code has determined that
+   * the Sun J2SE 1.4 reference implementation uses the LogManager
+   * class object. This is somewhat strange, as the class object
+   * is not the bean with which listeners have to register, but
+   * there is no reason for the GNU Classpath implementation to
+   * behave differently from the reference implementation in
+   * this case.
+   */
+  private final PropertyChangeSupport pcs = new PropertyChangeSupport( /* source bean */
+                                                                      LogManager.class);
+
+  protected LogManager()
+  {
+    loggers = new HashMap();
+  }
+
+  /**
+   * Returns the globally shared LogManager instance.
+   */
+  public static synchronized LogManager getLogManager()
+  {
+    if (logManager == null)
+      {
+        logManager = makeLogManager();
+        initLogManager();
+      }
+    return logManager;
+  }
+
+  private static final String MANAGER_PROPERTY = "java.util.logging.manager";
+
+  private static LogManager makeLogManager()
+  {
+    String managerClassName = SystemProperties.getProperty(MANAGER_PROPERTY);
+    LogManager manager = (LogManager) createInstance
+      (managerClassName, LogManager.class, MANAGER_PROPERTY);
+    if (manager == null)
+      manager = new LogManager();
+    return manager;
+  }
+
+  private static final String CONFIG_PROPERTY = "java.util.logging.config.class";
+
+  private static void initLogManager()
+  {
+    LogManager manager = getLogManager();
+    Logger.root.setLevel(Level.INFO);
+    manager.addLogger(Logger.root);
+
+    /* The Javadoc description of the class explains
+     * what is going on here.
+     */
+    Object configurator = createInstance(System.getProperty(CONFIG_PROPERTY),
+                                         /* must be instance of */ Object.class,
+                                         CONFIG_PROPERTY);
+
+    try
+      {
+        if (configurator == null)
+          manager.readConfiguration();
+      }
+    catch (IOException ex)
+      {
+        /* FIXME: Is it ok to ignore exceptions here? */
+      }
+  }
+
+  /**
+   * Registers a listener which will be notified when the
+   * logging properties are re-read.
+   */
+  public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
+  {
+    /* do not register null. */
+    listener.getClass();
+
+    pcs.addPropertyChangeListener(listener);
+  }
+
+  /**
+   * Unregisters a listener.
+   *
+   * If <code>listener</code> has not been registered previously,
+   * nothing happens.  Also, no exception is thrown if
+   * <code>listener</code> is <code>null</code>.
+   */
+  public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
+  {
+    if (listener != null)
+      pcs.removePropertyChangeListener(listener);
+  }
+
+  /**
+   * Adds a named logger.  If a logger with the same name has
+   * already been registered, the method returns <code>false</code>
+   * without adding the logger.
+   *
+   * <p>The <code>LogManager</code> only keeps weak references
+   * to registered loggers.  Therefore, names can become available
+   * after automatic garbage collection.
+   *
+   * @param logger the logger to be added.
+   *
+   * @return <code>true</code>if <code>logger</code> was added,
+   *         <code>false</code> otherwise.
+   *
+   * @throws NullPointerException if <code>name</code> is
+   *         <code>null</code>.
+   */
+  public synchronized boolean addLogger(Logger logger)
+  {
+    /* To developers thinking about to remove the 'synchronized'
+     * declaration from this method: Please read the comment
+     * in java.util.logging.Logger.getLogger(String, String)
+     * and make sure that whatever you change wrt. synchronization
+     * does not endanger thread-safety of Logger.getLogger.
+     * The current implementation of Logger.getLogger assumes
+     * that LogManager does its synchronization on the globally
+     * shared instance of LogManager.
+     */
+    String name;
+    WeakReference ref;
+
+    /* This will throw a NullPointerException if logger is null,
+     * as required by the API specification.
+     */
+    name = logger.getName();
+
+    ref = (WeakReference) loggers.get(name);
+    if (ref != null)
+      {
+	if (ref.get() != null)
+	  return false;
+
+	/* There has been a logger under this name in the past,
+	 * but it has been garbage collected.
+	 */
+	loggers.remove(ref);
+      }
+
+    /* Adding a named logger requires a security permission. */
+    if ((name != null) && ! name.equals(""))
+      checkAccess();
+
+    Logger parent = findAncestor(logger);
+    loggers.put(name, new WeakReference(logger));
+    if (parent != logger.getParent())
+      logger.setParent(parent);
+
+    // The level of the newly added logger must be specified.
+    // The easiest case is if there is a level for exactly this logger
+    // in the properties. If no such level exists the level needs to be 
+    // searched along the hirachy. So if there is a new logger 'foo.blah.blub'
+    // and an existing parent logger 'foo' the properties 'foo.blah.blub.level'
+    // and 'foo.blah.level' need to be checked. If both do not exist in the 
+    // properties the level of the new logger is set to 'null' (i.e. it uses the
+    // level of its parent 'foo').
+    Level logLevel = logger.getLevel();
+    String searchName = name;
+    String parentName = parent != null ? parent.getName() : "";
+    while (logLevel == null && ! searchName.equals(parentName))
+      {
+        logLevel = getLevelProperty(searchName + ".level", logLevel);
+        int index = searchName.lastIndexOf('.');
+        if(index > -1)
+          searchName = searchName.substring(0,index);
+        else
+          searchName = "";
+      }
+    logger.setLevel(logLevel);
+
+    /* It can happen that existing loggers should be children of
+     * the newly added logger. For example, assume that there
+     * already exist loggers under the names "", "foo", and "foo.bar.baz".
+     * When adding "foo.bar", the logger "foo.bar.baz" should change
+     * its parent to "foo.bar".
+     */
+    if (parent != Logger.root)
+      {
+	for (Iterator iter = loggers.keySet().iterator(); iter.hasNext();)
+	  {
+	    Logger possChild = (Logger) ((WeakReference) loggers.get(iter.next()))
+              .get();
+	    if ((possChild == null) || (possChild == logger)
+	        || (possChild.getParent() != parent))
+	      continue;
+
+	    if (! possChild.getName().startsWith(name))
+	      continue;
+
+	    if (possChild.getName().charAt(name.length()) != '.')
+	      continue;
+
+	    possChild.setParent(logger);
+	  }
+      }
+
+    return true;
+  }
+
+  /**
+   * Finds the closest ancestor for a logger among the currently
+   * registered ones.  For example, if the currently registered
+   * loggers have the names "", "foo", and "foo.bar", the result for
+   * "foo.bar.baz" will be the logger whose name is "foo.bar".
+   *
+   * @param child a logger for whose name no logger has been
+   *        registered.
+   *
+   * @return the closest ancestor for <code>child</code>,
+   *         or <code>null</code> if <code>child</code>
+   *         is the root logger.
+   *
+   * @throws NullPointerException if <code>child</code>
+   *         is <code>null</code>.
+   */
+  private synchronized Logger findAncestor(Logger child)
+  {
+    String childName = child.getName();
+    int childNameLength = childName.length();
+    Logger best = Logger.root;
+    int bestNameLength = 0;
+
+    Logger cand;
+    String candName;
+    int candNameLength;
+
+    if (child == Logger.root)
+      return null;
+
+    for (Iterator iter = loggers.keySet().iterator(); iter.hasNext();)
+      {
+	candName = (String) iter.next();
+	candNameLength = candName.length();
+
+	if (candNameLength > bestNameLength
+	    && childNameLength > candNameLength
+	    && childName.startsWith(candName)
+	    && childName.charAt(candNameLength) == '.')
+	  {
+	    cand = (Logger) ((WeakReference) loggers.get(candName)).get();
+	    if ((cand == null) || (cand == child))
+	      continue;
+
+	    bestNameLength = candName.length();
+	    best = cand;
+	  }
+      }
+
+    return best;
+  }
+
+  /**
+   * Returns a Logger given its name.
+   *
+   * @param name the name of the logger.
+   *
+   * @return a named Logger, or <code>null</code> if there is no
+   *     logger with that name.
+   *
+   * @throw java.lang.NullPointerException if <code>name</code>
+   *     is <code>null</code>.
+   */
+  public synchronized Logger getLogger(String name)
+  {
+    WeakReference ref;
+
+    /* Throw a NullPointerException if name is null. */
+    name.getClass();
+
+    ref = (WeakReference) loggers.get(name);
+    if (ref != null)
+      return (Logger) ref.get();
+    else
+      return null;
+  }
+
+  /**
+   * Returns an Enumeration of currently registered Logger names.
+   * Since other threads can register loggers at any time, the
+   * result could be different any time this method is called.
+   *
+   * @return an Enumeration with the names of the currently
+   *    registered Loggers.
+   */
+  public synchronized Enumeration getLoggerNames()
+  {
+    return Collections.enumeration(loggers.keySet());
+  }
+
+  /**
+   * Resets the logging configuration by removing all handlers for
+   * registered named loggers and setting their level to <code>null</code>.
+   * The level of the root logger will be set to <code>Level.INFO</code>.
+   *
+   * @throws SecurityException if a security manager exists and
+   *         the caller is not granted the permission to control
+   *         the logging infrastructure.
+   */
+  public synchronized void reset() throws SecurityException
+  {
+    /* Throw a SecurityException if the caller does not have the
+     * permission to control the logging infrastructure.
+     */
+    checkAccess();
+
+    properties = new Properties();
+
+    Iterator iter = loggers.values().iterator();
+    while (iter.hasNext())
+      {
+	WeakReference ref;
+	Logger logger;
+
+	ref = (WeakReference) iter.next();
+	if (ref != null)
+	  {
+	    logger = (Logger) ref.get();
+
+	    if (logger == null)
+	      iter.remove();
+	    else if (logger != Logger.root)
+	      {
+	        logger.resetLogger();
+	        logger.setLevel(null);
+	      }
+	  }
+      }
+
+    Logger.root.setLevel(Level.INFO);
+    Logger.root.resetLogger();
+  }
+
+  /**
+   * Configures the logging framework by reading a configuration file.
+   * The name and location of this file are specified by the system
+   * property <code>java.util.logging.config.file</code>.  If this
+   * property is not set, the URL
+   * "{gnu.classpath.home.url}/logging.properties" is taken, where
+   * "{gnu.classpath.home.url}" stands for the value of the system
+   * property <code>gnu.classpath.home.url</code>.
+   *
+   * <p>The task of configuring the framework is then delegated to
+   * {@link #readConfiguration(java.io.InputStream)}, which will
+   * notify registered listeners after having read the properties.
+   *
+   * @throws SecurityException if a security manager exists and
+   *         the caller is not granted the permission to control
+   *         the logging infrastructure, or if the caller is
+   *         not granted the permission to read the configuration
+   *         file.
+   *
+   * @throws IOException if there is a problem reading in the
+   *         configuration file.
+   */
+  public synchronized void readConfiguration()
+    throws IOException, SecurityException
+  {
+    String path;
+    InputStream inputStream;
+
+    path = System.getProperty("java.util.logging.config.file");
+    if ((path == null) || (path.length() == 0))
+      {
+        String url = (System.getProperty("gnu.classpath.home.url")
+                      + "/logging.properties");
+        try
+          {
+            inputStream = new URL(url).openStream();
+          } 
+        catch (Exception e)
+          {
+            inputStream=null;
+          }
+
+        // If no config file could be found use a default configuration.
+        if(inputStream == null)
+          {
+            String defaultConfig = "handlers = java.util.logging.ConsoleHandler   \n"
+              + ".level=INFO \n";
+            inputStream = new ByteArrayInputStream(defaultConfig.getBytes());
+          }
+      }
+    else
+      inputStream = new java.io.FileInputStream(path);
+
+    try
+      {
+        readConfiguration(inputStream);
+      }
+    finally
+      {
+        // Close the stream in order to save
+        // resources such as file descriptors.
+        inputStream.close();
+      }
+  }
+
+  public synchronized void readConfiguration(InputStream inputStream)
+    throws IOException, SecurityException
+  {
+    Properties newProperties;
+    Enumeration keys;
+
+    checkAccess();
+    newProperties = new Properties();
+    newProperties.load(inputStream);
+    reset();
+    this.properties = newProperties;
+    keys = newProperties.propertyNames();
+
+    while (keys.hasMoreElements())
+      {
+	String key = ((String) keys.nextElement()).trim();
+	String value = newProperties.getProperty(key);
+
+	if (value == null)
+	  continue;
+
+	value = value.trim();
+
+	if ("handlers".equals(key))
+	  {
+	    StringTokenizer tokenizer = new StringTokenizer(value);
+	    while (tokenizer.hasMoreTokens())
+	      {
+		String handlerName = tokenizer.nextToken();
+                Handler handler = (Handler)
+                  createInstance(handlerName, Handler.class, key);
+                Logger.root.addHandler(handler);
+	      }
+	  }
+
+	if (key.endsWith(".level"))
+	  {
+	    String loggerName = key.substring(0, key.length() - 6);
+	    Logger logger = getLogger(loggerName);
+
+	    if (logger == null)
+	      {
+		logger = Logger.getLogger(loggerName);
+		addLogger(logger);
+	      }
+            Level level = null;
+	    try
+              {
+                level = Level.parse(value);
+              }
+            catch (IllegalArgumentException e)
+              {
+                warn("bad level \'" + value + "\'", e);
+              }
+            if (level != null)
+              {
+                logger.setLevel(level);
+              }
+	    continue;
+	  }
+      }
+
+    /* The API specification does not talk about the
+     * property name that is distributed with the
+     * PropertyChangeEvent.  With test code, it could
+     * be determined that the Sun J2SE 1.4 reference
+     * implementation uses null for the property name.
+     */
+    pcs.firePropertyChange(null, null, null);
+  }
+
+  /**
+   * Returns the value of a configuration property as a String.
+   */
+  public synchronized String getProperty(String name)
+  {
+    if (properties != null)
+      return properties.getProperty(name);
+    else
+      return null;
+  }
+
+  /**
+   * Returns the value of a configuration property as an integer.
+   * This function is a helper used by the Classpath implementation
+   * of java.util.logging, it is <em>not</em> specified in the
+   * logging API.
+   *
+   * @param name the name of the configuration property.
+   *
+   * @param defaultValue the value that will be returned if the
+   *        property is not defined, or if its value is not an integer
+   *        number.
+   */
+  static int getIntProperty(String name, int defaultValue)
+  {
+    try
+      {
+	return Integer.parseInt(getLogManager().getProperty(name));
+      }
+    catch (Exception ex)
+      {
+	return defaultValue;
+      }
+  }
+
+  /**
+   * Returns the value of a configuration property as an integer,
+   * provided it is inside the acceptable range.
+   * This function is a helper used by the Classpath implementation
+   * of java.util.logging, it is <em>not</em> specified in the
+   * logging API.
+   *
+   * @param name the name of the configuration property.
+   *
+   * @param minValue the lowest acceptable value.
+   *
+   * @param maxValue the highest acceptable value.
+   *
+   * @param defaultValue the value that will be returned if the
+   *        property is not defined, or if its value is not an integer
+   *        number, or if it is less than the minimum value,
+   *        or if it is greater than the maximum value.
+   */
+  static int getIntPropertyClamped(String name, int defaultValue,
+                                   int minValue, int maxValue)
+  {
+    int val = getIntProperty(name, defaultValue);
+    if ((val < minValue) || (val > maxValue))
+      val = defaultValue;
+    return val;
+  }
+
+  /**
+   * Returns the value of a configuration property as a boolean.
+   * This function is a helper used by the Classpath implementation
+   * of java.util.logging, it is <em>not</em> specified in the
+   * logging API.
+   *
+   * @param name the name of the configuration property.
+   *
+   * @param defaultValue the value that will be returned if the
+   *        property is not defined, or if its value is neither
+   *        <code>"true"</code> nor <code>"false"</code>.
+   */
+  static boolean getBooleanProperty(String name, boolean defaultValue)
+  {
+    try
+      {
+	return (Boolean.valueOf(getLogManager().getProperty(name))).booleanValue();
+      }
+    catch (Exception ex)
+      {
+	return defaultValue;
+      }
+  }
+
+  /**
+   * Returns the value of a configuration property as a Level.
+   * This function is a helper used by the Classpath implementation
+   * of java.util.logging, it is <em>not</em> specified in the
+   * logging API.
+   *
+   * @param propertyName the name of the configuration property.
+   *
+   * @param defaultValue the value that will be returned if the
+   *        property is not defined, or if
+   *        {@link Level#parse(java.lang.String)} does not like
+   *        the property value.
+   */
+  static Level getLevelProperty(String propertyName, Level defaultValue)
+  {
+    try
+      {
+	return Level.parse(getLogManager().getProperty(propertyName));
+      }
+    catch (Exception ex)
+      {
+	return defaultValue;
+      }
+  }
+
+  /**
+   * Returns the value of a configuration property as a Class.
+   * This function is a helper used by the Classpath implementation
+   * of java.util.logging, it is <em>not</em> specified in the
+   * logging API.
+   *
+   * @param propertyName the name of the configuration property.
+   *
+   * @param defaultValue the value that will be returned if the
+   *        property is not defined, or if it does not specify
+   *        the name of a loadable class.
+   */
+  static final Class getClassProperty(String propertyName, Class defaultValue)
+  {
+    String propertyValue = logManager.getProperty(propertyName);
+
+    if (propertyValue != null)
+      try
+        {
+          return locateClass(propertyValue);
+        }
+      catch (ClassNotFoundException e)
+        {
+          warn(propertyName + " = " + propertyValue, e);
+        }
+
+    return defaultValue;
+  }
+
+  static final Object getInstanceProperty(String propertyName, Class ofClass,
+                                          Class defaultClass)
+  {
+    Class klass = getClassProperty(propertyName, defaultClass);
+    if (klass == null)
+      return null;
+
+    try
+      {
+        Object obj = klass.newInstance();
+        if (ofClass.isInstance(obj))
+          return obj;
+      }
+    catch (InstantiationException e)
+      {
+        warn(propertyName + " = " + klass.getName(), e);
+      }
+    catch (IllegalAccessException e)
+      {
+        warn(propertyName + " = " + klass.getName(), e);
+      }
+
+    if (defaultClass == null)
+      return null;
+
+    try
+      {
+	return defaultClass.newInstance();
+      }
+    catch (java.lang.InstantiationException ex)
+      {
+	throw new RuntimeException(ex.getMessage());
+      }
+    catch (java.lang.IllegalAccessException ex)
+      {
+	throw new RuntimeException(ex.getMessage());
+      }
+  }
+
+  /**
+   * An instance of <code>LoggingPermission("control")</code>
+   * that is shared between calls to <code>checkAccess()</code>.
+   */
+  private static final LoggingPermission controlPermission = new LoggingPermission("control",
+                                                                                   null);
+
+  /**
+   * Checks whether the current security context allows changing
+   * the configuration of the logging framework.  For the security
+   * context to be trusted, it has to be granted
+   * a LoggingPermission("control").
+   *
+   * @throws SecurityException if a security manager exists and
+   *         the caller is not granted the permission to control
+   *         the logging infrastructure.
+   */
+  public void checkAccess() throws SecurityException
+  {
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkPermission(controlPermission);
+  }
+
+  /**
+   * Creates a new instance of a class specified by name and verifies
+   * that it is an instance (or subclass of) a given type.
+   *
+   * @param className the name of the class of which a new instance
+   *        should be created.
+   *
+   * @param type the object created must be an instance of
+   * <code>type</code> or any subclass of <code>type</code>
+   *
+   * @param property the system property to reference in error
+   * messages
+   *
+   * @return the new instance, or <code>null</code> if
+   *         <code>className</code> is <code>null</code>, if no class
+   *         with that name could be found, if there was an error
+   *         loading that class, or if the constructor of the class
+   *         has thrown an exception.
+   */
+  private static final Object createInstance(String className, Class type,
+                                             String property)
+  {
+    Class klass = null;
+
+    if ((className == null) || (className.length() == 0))
+      return null;
+
+    try
+      {
+        klass = locateClass(className);
+        if (type.isAssignableFrom(klass))
+          return klass.newInstance();
+        warn(property, className, "not an instance of " + type.getName());
+      }
+    catch (ClassNotFoundException e)
+      {
+        warn(property, className, "class not found", e);
+      }
+    catch (IllegalAccessException e)
+      {
+        warn(property, className, "illegal access", e);
+      }
+    catch (InstantiationException e)
+      {
+        warn(property, className, e);
+      }
+    catch (java.lang.LinkageError e)
+      {
+        warn(property, className, "linkage error", e);
+      }
+
+    return null;
+  }
+
+  private static final void warn(String property, String klass, Throwable t)
+  {
+    warn(property, klass, null, t);
+  }
+
+  private static final void warn(String property, String klass, String msg)
+  {
+    warn(property, klass, msg, null);
+  }
+
+  private static final void warn(String property, String klass, String msg,
+                                 Throwable t)
+  {
+    warn("error instantiating '" + klass + "' referenced by " + property +
+         (msg == null ? "" : ", " + msg), t);
+  }
+
+  /**
+   * All debug warnings go through this method.
+   */
+
+  private static final void warn(String msg, Throwable t)
+  {
+    System.err.println("WARNING: " + msg);
+    if (t != null)
+      t.printStackTrace(System.err);
+  }
+
+  /**
+   * Locates a class by first checking the system class loader and
+   * then checking the context class loader.
+   *
+   * @param name the fully qualified name of the Class to locate
+   * @return Class the located Class
+   */
+
+  private static Class locateClass(String name) throws ClassNotFoundException
+  {
+    ClassLoader loader = Thread.currentThread().getContextClassLoader();
+    try
+      {
+        return Class.forName(name, true, loader);
+      }
+    catch (ClassNotFoundException e)
+      {
+        loader = ClassLoader.getSystemClassLoader();
+        return Class.forName(name, true, loader);
+      }
+  }
+
+  /**
+   * Return the logging bean.  There is a single logging bean per
+   * VM instance.
+   * @since 1.5
+   */
+  public static synchronized LoggingMXBean getLoggingMXBean()
+  {
+    if (loggingBean == null)
+      {
+        loggingBean = new LoggingMXBean()
+        {
+          public String getLoggerLevel(String logger)
+          {
+            LogManager mgr = getLogManager();
+            Logger l = mgr.getLogger(logger);
+            if (l == null)
+              return null;
+            Level lev = l.getLevel();
+            if (lev == null)
+              return "";
+            return lev.getName();
+          }
+
+          public List getLoggerNames()
+          {
+            LogManager mgr = getLogManager();
+            // This is inefficient, but perhaps better for maintenance.
+            return Collections.list(mgr.getLoggerNames());
+          }
+
+          public String getParentLoggerName(String logger)
+          {
+            LogManager mgr = getLogManager();
+            Logger l = mgr.getLogger(logger);
+            if (l == null)
+              return null;
+            l = l.getParent();
+            if (l == null)
+              return "";
+            return l.getName();
+          }
+
+          public void setLoggerLevel(String logger, String level)
+          {
+            LogManager mgr = getLogManager();
+            Logger l = mgr.getLogger(logger);
+            if (l == null)
+              throw new IllegalArgumentException("no logger named " + logger);
+            Level newLevel;
+            if (level == null)
+              newLevel = null;
+            else
+              newLevel = Level.parse(level);
+            l.setLevel(newLevel);
+          }
+        };
+      }
+    return loggingBean;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LogRecord.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LogRecord.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LogRecord.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LogRecord.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,672 @@
+/* LogRecord.java --
+   A class for the state associated with individual logging events
+   Copyright (C) 2002, 2003, 2004  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+import java.util.ResourceBundle;
+
+
+/**
+ * A <code>LogRecord</code> contains the state for an individual
+ * event to be logged.
+ *
+ * <p>As soon as a LogRecord instance has been handed over to the
+ * logging framework, applications should not manipulate it anymore.
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public class LogRecord
+  implements java.io.Serializable
+{
+  /**
+   * The severity level of this <code>LogRecord</code>.
+   */
+  private Level      level;
+
+
+  /**
+   * The sequence number of this <code>LogRecord</code>.
+   */
+  private long       sequenceNumber;
+
+
+  /**
+   * The name of the class that issued the logging request, or
+   * <code>null</code> if this information could not be obtained.
+   */
+  private String     sourceClassName;
+
+
+  /**
+   * The name of the method that issued the logging request, or
+   * <code>null</code> if this information could not be obtained.
+   */
+  private String sourceMethodName;
+
+
+  /**
+   * The message for this <code>LogRecord</code> before
+   * any localization or formatting.
+   */
+  private String message;
+
+
+  /**
+   * An identifier for the thread in which this <code>LogRecord</code>
+   * was created.  The identifier is not necessarily related to any
+   * thread identifiers used by the operating system.
+   */
+  private int threadID;
+
+
+  /**
+   * The time when this <code>LogRecord</code> was created,
+   * in milliseconds since the beginning of January 1, 1970.
+   */
+  private long millis;
+
+
+  /**
+   * The Throwable associated with this <code>LogRecord</code>, or
+   * <code>null</code> if the logged event is not related to an
+   * exception or error.
+   */
+  private Throwable thrown;
+
+
+  /**
+   * The name of the logger where this <code>LogRecord</code> has
+   * originated, or <code>null</code> if this <code>LogRecord</code>
+   * does not originate from a <code>Logger</code>.
+   */
+  private String  loggerName;
+
+
+  /**
+   * The name of the resource bundle used for localizing log messages,
+   * or <code>null</code> if no bundle has been specified.
+   */
+  private String resourceBundleName;
+
+  private transient Object[] parameters;
+
+  private transient ResourceBundle bundle;
+
+
+  /**
+   * Constructs a <code>LogRecord</code> given a severity level and
+   * an unlocalized message text.  In addition, the sequence number,
+   * creation time (as returned by <code>getMillis()</code>) and
+   * thread ID are assigned. All other properties are set to
+   * <code>null</code>.
+   *
+   * @param level the severity level, for example <code>Level.WARNING</code>.
+   *
+   * @param message the message text (which will be used as key
+   *                for looking up the localized message text
+   *                if a resource bundle has been associated). 
+   */
+  public LogRecord(Level level, String message)
+  {
+    this.level = level;
+    this.message = message;
+    this.millis = System.currentTimeMillis();
+
+    /* A subclass of java.lang.Thread could override hashCode(),
+     * in which case the result would not be guaranteed anymore
+     * to be unique among all threads.  While System.identityHashCode
+     * is not necessarily unique either, it at least cannot be
+     * overridden by user code.  However, is might be a good idea
+     * to use something better for generating thread IDs.
+     */
+    this.threadID = System.identityHashCode(Thread.currentThread());
+
+    sequenceNumber = allocateSeqNum();
+  }
+
+
+  /**
+   * Determined with the serialver tool of the Sun J2SE 1.4.
+   */
+  static final long serialVersionUID = 5372048053134512534L;
+
+  private void readObject(java.io.ObjectInputStream in)
+    throws java.io.IOException, java.lang.ClassNotFoundException
+  {
+    in.defaultReadObject();
+
+    /* We assume that future versions will be downwards compatible,
+     * so we can ignore the versions.
+     */
+    byte majorVersion = in.readByte();
+    byte minorVersion = in.readByte();
+
+    int numParams = in.readInt();
+    if (numParams >= 0)
+    {
+      parameters = new Object[numParams];
+      for (int i = 0; i < numParams; i++)
+	parameters[i] = in.readObject();
+    }
+  }
+
+
+  /**
+   * @serialData The default fields, followed by a major byte version
+   * number, followed by a minor byte version number, followed by
+   * information about the log record parameters.  If
+   * <code>parameters</code> is <code>null</code>, the integer -1 is
+   * written, otherwise the length of the <code>parameters</code>
+   * array (which can be zero), followed by the result of calling
+   * {@link Object#toString() toString()} on the parameter (or
+   * <code>null</code> if the parameter is <code>null</code>).
+   *
+   * <p><strong>Specification Note:</strong> The Javadoc for the
+   * Sun reference implementation does not specify the version
+   * number. FIXME: Reverse-engineer the JDK and file a bug
+   * report with Sun, asking for amendment of the specification.
+   */
+  private void writeObject(java.io.ObjectOutputStream out)
+    throws java.io.IOException
+  {
+    out.defaultWriteObject();
+
+    /* Major, minor version number: The Javadoc for J2SE1.4 does not
+     * specify the values.
+     */
+    out.writeByte(0);
+    out.writeByte(0);
+
+    if (parameters == null)
+      out.writeInt(-1);
+    else
+    {
+      out.writeInt(parameters.length);
+      for (int i = 0; i < parameters.length; i++)
+      {
+	if (parameters[i] == null)
+	  out.writeObject(null);
+	else
+	  out.writeObject(parameters[i].toString());
+      }
+    }
+  }
+
+
+  /**
+   * Returns the name of the logger where this <code>LogRecord</code>
+   * has originated.
+   *
+   * @return the name of the source {@link Logger}, or
+   *         <code>null</code> if this <code>LogRecord</code>
+   *         does not originate from a <code>Logger</code>.
+   */
+  public String getLoggerName()
+  {
+    return loggerName;
+  }
+
+
+  /**
+   * Sets the name of the logger where this <code>LogRecord</code>
+   * has originated.
+   *
+   * <p>As soon as a <code>LogRecord</code> has been handed over
+   * to the logging framework, applications should not modify it
+   * anymore.  Therefore, this method should only be called on
+   * freshly constructed LogRecords.
+   *
+   * @param name the name of the source logger, or <code>null</code> to
+   *             indicate that this <code>LogRecord</code> does not
+   *             originate from a <code>Logger</code>.
+   */
+  public void setLoggerName(String name)
+  {
+    loggerName = name;
+  }
+
+
+  /**
+   * Returns the resource bundle that is used when the message
+   * of this <code>LogRecord</code> needs to be localized.
+   *
+   * @return the resource bundle used for localization,
+   *         or <code>null</code> if this message does not need
+   *         to be localized.
+   */
+  public ResourceBundle getResourceBundle()
+  {
+    return bundle;
+  }
+
+
+  /**
+   * Sets the resource bundle that is used when the message
+   * of this <code>LogRecord</code> needs to be localized.
+   *
+   * <p>As soon as a <code>LogRecord</code> has been handed over
+   * to the logging framework, applications should not modify it
+   * anymore.  Therefore, this method should only be called on
+   * freshly constructed LogRecords.
+   *
+   * @param bundle  the resource bundle to be used, or
+   *                <code>null</code> to indicate that this
+   *                message does not need to be localized.
+   */
+  public void setResourceBundle(ResourceBundle bundle)
+  {
+    this.bundle = bundle;
+
+    /* FIXME: Is there a way to infer the name
+     * of a resource bundle from a ResourceBundle object?
+     */
+    this.resourceBundleName = null;
+  }
+
+
+  /**
+   * Returns the name of the resource bundle that is used when the
+   * message of this <code>LogRecord</code> needs to be localized.
+   *
+   * @return the name of the resource bundle used for localization,
+   *         or <code>null</code> if this message does not need
+   *         to be localized.
+   */
+  public String getResourceBundleName()
+  {
+    return resourceBundleName;
+  }
+
+
+  /**
+   * Sets the name of the resource bundle that is used when the
+   * message of this <code>LogRecord</code> needs to be localized.
+   *
+   * <p>As soon as a <code>LogRecord</code> has been handed over
+   * to the logging framework, applications should not modify it
+   * anymore.  Therefore, this method should only be called on
+   * freshly constructed LogRecords.
+   *
+   * @param name the name of the resource bundle to be used, or
+   *             <code>null</code> to indicate that this message
+   *             does not need to be localized.
+   */
+  public void setResourceBundleName(String name)
+  {
+    resourceBundleName = name;
+    bundle = null;
+    
+    try
+    {
+      if (resourceBundleName != null)
+	bundle = ResourceBundle.getBundle(resourceBundleName);
+    }
+    catch (java.util.MissingResourceException _)
+    {
+    }
+  }
+
+
+  /**
+   * Returns the level of the LogRecord.
+   *
+   * <p>Applications should be aware of the possibility that the
+   *  result is not necessarily one of the standard logging levels,
+   *  since the logging framework allows to create custom subclasses
+   *  of <code>java.util.logging.Level</code>.  Therefore, filters
+   *  should perform checks like <code>theRecord.getLevel().intValue()
+   *  == Level.INFO.intValue()</code> instead of <code>theRecord.getLevel()
+   *  == Level.INFO</code>.
+   */
+  public Level getLevel()
+  {
+    return level;
+  }
+
+
+  /**
+   * Sets the severity level of this <code>LogRecord</code> to a new
+   * value.
+   *
+   * <p>As soon as a <code>LogRecord</code> has been handed over
+   * to the logging framework, applications should not modify it
+   * anymore.  Therefore, this method should only be called on
+   * freshly constructed LogRecords.
+   *
+   * @param level the new severity level, for example
+   *              <code>Level.WARNING</code>.
+   */
+  public void setLevel(Level level)
+  {
+    this.level = level;
+  }
+
+
+  /**
+   * The last used sequence number for any LogRecord.
+   */
+  private static long lastSeqNum;
+
+
+  /**
+   * Allocates a sequence number for a new LogRecord.  This class
+   * method is only called by the LogRecord constructor.
+   */
+  private static synchronized long allocateSeqNum()
+  {
+    lastSeqNum += 1;
+    return lastSeqNum;
+  }
+
+
+  /**
+   * Returns the sequence number of this <code>LogRecord</code>.
+   */
+  public long getSequenceNumber()
+  {
+    return sequenceNumber;
+  }
+
+
+  /**
+   * Sets the sequence number of this <code>LogRecord</code> to a new
+   * value.
+   *
+   * <p>As soon as a <code>LogRecord</code> has been handed over
+   * to the logging framework, applications should not modify it
+   * anymore.  Therefore, this method should only be called on
+   * freshly constructed LogRecords.
+   *
+   * @param seqNum the new sequence number.
+   */
+  public void setSequenceNumber(long seqNum)
+  {
+    this.sequenceNumber = seqNum;
+  }
+
+
+  /**
+   * Returns the name of the class where the event being logged
+   * has had its origin.  This information can be passed as
+   * parameter to some logging calls, and in certain cases, the
+   * logging framework tries to determine an approximation
+   * (which may or may not be accurate).
+   * 
+   * @return the name of the class that issued the logging request,
+   *         or <code>null</code> if this information could not
+   *         be obtained.
+   */
+  public String getSourceClassName()
+  {
+    if (sourceClassName != null)
+      return sourceClassName;
+
+    /*  FIXME: Should infer this information from the call stack. */
+    return null;
+  }
+
+
+  /**
+   * Sets the name of the class where the event being logged
+   * has had its origin.
+   *
+   * <p>As soon as a <code>LogRecord</code> has been handed over
+   * to the logging framework, applications should not modify it
+   * anymore.  Therefore, this method should only be called on
+   * freshly constructed LogRecords.
+   * 
+   * @param sourceClassName the name of the class that issued the
+   *          logging request, or <code>null</code> to indicate that
+   *          this information could not be obtained.
+   */
+  public void setSourceClassName(String sourceClassName)
+  {
+    this.sourceClassName = sourceClassName;
+  }
+
+
+  /**
+   * Returns the name of the method where the event being logged
+   * has had its origin.  This information can be passed as
+   * parameter to some logging calls, and in certain cases, the
+   * logging framework tries to determine an approximation
+   * (which may or may not be accurate).
+   * 
+   * @return the name of the method that issued the logging request,
+   *         or <code>null</code> if this information could not
+   *         be obtained.
+   */
+  public String getSourceMethodName()
+  {
+    if (sourceMethodName != null)
+      return sourceMethodName;
+
+    /* FIXME: Should infer this information from the call stack. */
+    return null;
+  }
+
+
+  /**
+   * Sets the name of the method where the event being logged
+   * has had its origin.
+   *
+   * <p>As soon as a <code>LogRecord</code> has been handed over
+   * to the logging framework, applications should not modify it
+   * anymore.  Therefore, this method should only be called on
+   * freshly constructed LogRecords.
+   * 
+   * @param sourceMethodName the name of the method that issued the
+   *          logging request, or <code>null</code> to indicate that
+   *          this information could not be obtained.
+   */
+  public void setSourceMethodName(String sourceMethodName)
+  {
+    this.sourceMethodName = sourceMethodName;
+  }
+
+
+  /**
+   * Returns the message for this <code>LogRecord</code> before
+   * any localization or parameter substitution.
+   *
+   * <p>A {@link Logger} will try to localize the message
+   * if a resource bundle has been associated with this
+   * <code>LogRecord</code>.  In this case, the logger will call
+   * <code>getMessage()</code> and use the result as the key
+   * for looking up the localized message in the bundle.
+   * If no bundle has been associated, or if the result of
+   * <code>getMessage()</code> is not a valid key in the
+   * bundle, the logger will use the raw message text as
+   * returned by this method.
+   *
+   * @return the message text, or <code>null</code> if there
+   *         is no message text.
+   */
+  public String getMessage()
+  {
+    return message;
+  }
+
+
+  /**
+   * Sets the message for this <code>LogRecord</code>.
+   *
+   * <p>A <code>Logger</code> will try to localize the message
+   * if a resource bundle has been associated with this
+   * <code>LogRecord</code>.  In this case, the logger will call
+   * <code>getMessage()</code> and use the result as the key
+   * for looking up the localized message in the bundle.
+   * If no bundle has been associated, or if the result of
+   * <code>getMessage()</code> is not a valid key in the
+   * bundle, the logger will use the raw message text as
+   * returned by this method.
+   *
+   * <p>It is possible to set the message to either an empty String or
+   * <code>null</code>, although this does not make the the message
+   * very helpful to human users.
+   *
+   * @param message the message text (which will be used as key
+   *                for looking up the localized message text
+   *                if a resource bundle has been associated). 
+   */
+  public void setMessage(String message)
+  {
+    this.message = message;
+  }
+
+
+  /**
+   * Returns the parameters to the log message.
+   *
+   * @return the parameters to the message, or <code>null</code> if
+   *         the message has no parameters.
+   */
+  public Object[] getParameters()
+  {
+    return parameters;
+  }
+
+
+  /**
+   * Sets the parameters to the log message.
+   *
+   * <p>As soon as a <code>LogRecord</code> has been handed over
+   * to the logging framework, applications should not modify it
+   * anymore.  Therefore, this method should only be called on
+   * freshly constructed LogRecords.
+   *
+   * @param parameters the parameters to the message, or <code>null</code>
+   *                   to indicate that the message has no parameters.
+   */
+  public void setParameters(Object[] parameters)
+  {
+    this.parameters = parameters;
+  }
+
+
+  /**
+   * Returns an identifier for the thread in which this
+   * <code>LogRecord</code> was created.  The identifier is not
+   * necessarily related to any thread identifiers used by the
+   * operating system.
+   *
+   * @return an identifier for the source thread.
+   */
+  public int getThreadID()
+  {
+    return threadID;
+  }
+
+
+  /**
+   * Sets the identifier indicating in which thread this
+   * <code>LogRecord</code> was created.  The identifier is not
+   * necessarily related to any thread identifiers used by the
+   * operating system.
+   *
+   * <p>As soon as a <code>LogRecord</code> has been handed over
+   * to the logging framework, applications should not modify it
+   * anymore.  Therefore, this method should only be called on
+   * freshly constructed LogRecords.
+   *
+   * @param threadID the identifier for the source thread.
+   */
+  public void setThreadID(int threadID)
+  {
+    this.threadID = threadID;
+  }
+
+
+  /**
+   * Returns the time when this <code>LogRecord</code> was created.
+   *
+   * @return the time of creation in milliseconds since the beginning
+   *         of January 1, 1970.
+   */
+  public long getMillis()
+  {
+    return millis;
+  }
+
+
+  /**
+   * Sets the time when this <code>LogRecord</code> was created.
+   *
+   * <p>As soon as a <code>LogRecord</code> has been handed over
+   * to the logging framework, applications should not modify it
+   * anymore.  Therefore, this method should only be called on
+   * freshly constructed LogRecords.
+   *
+   * @param millis the time of creation in milliseconds since the
+   *               beginning of January 1, 1970.
+   */
+  public void setMillis(long millis)
+  {
+    this.millis = millis;
+  }
+
+
+  /**
+   * Returns the Throwable associated with this <code>LogRecord</code>,
+   * or <code>null</code> if the logged event is not related to an exception
+   * or error.
+   */
+  public Throwable getThrown()
+  {
+    return thrown;
+  }
+
+
+  /**
+   * Associates this <code>LogRecord</code> with an exception or error.
+   *
+   * <p>As soon as a <code>LogRecord</code> has been handed over
+   * to the logging framework, applications should not modify it
+   * anymore.  Therefore, this method should only be called on
+   * freshly constructed LogRecords.
+   *
+   * @param thrown the exception or error to associate with, or
+   *               <code>null</code> if this <code>LogRecord</code>
+   *               should be made unrelated to an exception or error.
+   */
+  public void setThrown(Throwable thrown)
+  {
+    this.thrown = thrown;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Logger.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Logger.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Logger.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/Logger.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1223 @@
+/* Logger.java -- a class for logging messages
+   Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+import java.util.List;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * A Logger is used for logging information about events. Usually, there
+ * is a seprate logger for each subsystem or component, although there
+ * is a shared instance for components that make only occasional use of
+ * the logging framework.
+ *
+ * <p>It is common to name a logger after the name of a corresponding
+ * Java package.  Loggers are organized into a hierarchical namespace;
+ * for example, the logger <code>"org.gnu.foo"</code> is the
+ * <em>parent</em> of logger <code>"org.gnu.foo.bar"</code>.
+ *
+ * <p>A logger for a named subsystem can be obtained through {@link
+ * java.util.logging.Logger#getLogger(java.lang.String)}.  However,
+ * only code which has been granted the permission to control the
+ * logging infrastructure will be allowed to customize that logger.
+ * Untrusted code can obtain a private, anonymous logger through
+ * {@link #getAnonymousLogger()} if it wants to perform any
+ * modifications to the logger.
+ *
+ * <p>FIXME: Write more documentation.
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public class Logger
+{
+
+  static final Logger root = new Logger("", null);
+
+  /**
+   * A logger provided to applications that make only occasional use
+   * of the logging framework, typically early prototypes.  Serious
+   * products are supposed to create and use their own Loggers, so
+   * they can be controlled individually.
+   */
+  public static final Logger global;
+
+  static
+    {
+      // Our class might be initialized from an unprivileged context
+      global = (Logger) AccessController.doPrivileged
+	(new PrivilegedAction()
+	  {
+	    public Object run()
+	    {
+	      return getLogger("global");
+	    }
+	  });
+    }
+
+
+  /**
+   * The name of the Logger, or <code>null</code> if the logger is
+   * anonymous.
+   *
+   * <p>A previous version of the GNU Classpath implementation granted
+   * untrusted code the permission to control any logger whose name
+   * was null.  However, test code revealed that the Sun J2SE 1.4
+   * reference implementation enforces the security control for any
+   * logger that was not created through getAnonymousLogger, even if
+   * it has a null name.  Therefore, a separate flag {@link
+   * Logger#anonymous} was introduced.
+   */
+  private final String name;
+
+
+  /**
+   * The name of the resource bundle used for localization.
+   *
+   * <p>This variable cannot be declared as <code>final</code>
+   * because its value can change as a result of calling
+   * getLogger(String,String).
+   */
+  private String resourceBundleName;
+
+
+  /**
+   * The resource bundle used for localization.
+   *
+   * <p>This variable cannot be declared as <code>final</code>
+   * because its value can change as a result of calling
+   * getLogger(String,String).
+   */
+  private ResourceBundle resourceBundle;
+
+  private Filter filter;
+
+  private final List handlerList = new java.util.ArrayList(4);
+  private Handler[] handlers = new Handler[0];
+
+  /**
+   * Indicates whether or not this logger is anonymous.  While
+   * a LoggingPermission is required for any modifications to
+   * a normal logger, untrusted code can obtain an anonymous logger
+   * and modify it according to its needs.
+   *
+   * <p>A previous version of the GNU Classpath implementation
+   * granted access to every logger whose name was null.
+   * However, test code revealed that the Sun J2SE 1.4 reference
+   * implementation enforces the security control for any logger
+   * that was not created through getAnonymousLogger, even
+   * if it has a null name.
+   */
+  private boolean anonymous;
+
+
+  private boolean useParentHandlers;
+
+  private Level level;
+
+  private Logger parent;
+
+  /**
+   * Constructs a Logger for a subsystem.  Most applications do not
+   * need to create new Loggers explicitly; instead, they should call
+   * the static factory methods
+   * {@link #getLogger(java.lang.String,java.lang.String) getLogger}
+   * (with ResourceBundle for localization) or
+   * {@link #getLogger(java.lang.String) getLogger} (without
+   * ResourceBundle), respectively.
+   *
+   * @param name the name for the logger, for example "java.awt"
+   *             or "com.foo.bar". The name should be based on
+   *             the name of the package issuing log records
+   *             and consist of dot-separated Java identifiers.
+   *
+   * @param resourceBundleName the name of a resource bundle
+   *        for localizing messages, or <code>null</code>
+   *	    to indicate that messages do not need to be localized.
+   *
+   * @throws java.util.MissingResourceException if
+   *         <code>resourceBundleName</code> is not <code>null</code>
+   *         and no such bundle could be located.
+   */
+  protected Logger(String name, String resourceBundleName)
+    throws MissingResourceException
+  {
+    this.name = name;
+    this.resourceBundleName = resourceBundleName;
+
+    if (resourceBundleName == null)
+      resourceBundle = null;
+    else
+      resourceBundle = ResourceBundle.getBundle(resourceBundleName);
+
+    level = null;
+
+    /* This is null when the root logger is being constructed,
+     * and the root logger afterwards.
+     */
+    parent = root;
+
+    useParentHandlers = (parent != null);
+  }
+
+
+
+  /**
+   * Finds a registered logger for a subsystem, or creates one in
+   * case no logger has been registered yet.
+   *
+   * @param name the name for the logger, for example "java.awt"
+   *             or "com.foo.bar". The name should be based on
+   *             the name of the package issuing log records
+   *             and consist of dot-separated Java identifiers.
+   *
+   * @throws IllegalArgumentException if a logger for the subsystem
+   *         identified by <code>name</code> has already been created,
+   *         but uses a a resource bundle for localizing messages.
+   *
+   * @throws NullPointerException if <code>name</code> is
+   *         <code>null</code>.
+   *
+   * @return a logger for the subsystem specified by <code>name</code>
+   *         that does not localize messages.
+   */
+  public static Logger getLogger(String name)
+  {
+    return getLogger(name, null);
+  }
+
+    
+  /**
+   * Finds a registered logger for a subsystem, or creates one in case
+   * no logger has been registered yet.
+   *
+   * <p>If a logger with the specified name has already been
+   * registered, the behavior depends on the resource bundle that is
+   * currently associated with the existing logger.
+   *
+   * <ul><li>If the existing logger uses the same resource bundle as
+   * specified by <code>resourceBundleName</code>, the existing logger
+   * is returned.</li>
+   *
+   * <li>If the existing logger currently does not localize messages,
+   * the existing logger is modified to use the bundle specified by
+   * <code>resourceBundleName</code>.  The existing logger is then
+   * returned.  Therefore, all subsystems currently using this logger
+   * will produce localized messages from now on.</li>
+   *
+   * <li>If the existing logger already has an associated resource
+   * bundle, but a different one than specified by
+   * <code>resourceBundleName</code>, an
+   * <code>IllegalArgumentException</code> is thrown.</li></ul>
+   *
+   * @param name the name for the logger, for example "java.awt"
+   *             or "org.gnu.foo". The name should be based on
+   *             the name of the package issuing log records
+   *             and consist of dot-separated Java identifiers.
+   *
+   * @param resourceBundleName the name of a resource bundle
+   *        for localizing messages, or <code>null</code>
+   *	    to indicate that messages do not need to be localized.
+   *
+   * @return a logger for the subsystem specified by <code>name</code>.
+   *
+   * @throws java.util.MissingResourceException if
+   *         <code>resourceBundleName</code> is not <code>null</code>
+   *         and no such bundle could be located.   
+   *
+   * @throws IllegalArgumentException if a logger for the subsystem
+   *         identified by <code>name</code> has already been created,
+   *         but uses a different resource bundle for localizing
+   *         messages.
+   *
+   * @throws NullPointerException if <code>name</code> is
+   *         <code>null</code>.
+   */
+  public static Logger getLogger(String name, String resourceBundleName)
+  {
+    LogManager lm = LogManager.getLogManager();
+    Logger     result;
+
+    /* Throw NullPointerException if name is null. */
+    name.getClass();
+
+    /* Without synchronized(lm), it could happen that another thread
+     * would create a logger between our calls to getLogger and
+     * addLogger.  While addLogger would indicate this by returning
+     * false, we could not be sure that this other logger was still
+     * existing when we called getLogger a second time in order
+     * to retrieve it -- note that LogManager is only allowed to
+     * keep weak references to registered loggers, so Loggers
+     * can be garbage collected at any time in general, and between
+     * our call to addLogger and our second call go getLogger
+     * in particular.
+     *
+     * Of course, we assume here that LogManager.addLogger etc.
+     * are synchronizing on the global LogManager object. There
+     * is a comment in the implementation of LogManager.addLogger
+     * referring to this comment here, so that any change in
+     * the synchronization of LogManager will be reflected here.
+     */
+    synchronized (lm)
+    {
+      result = lm.getLogger(name);
+      if (result == null)
+      {
+	boolean couldBeAdded;
+
+	result = new Logger(name, resourceBundleName);
+	couldBeAdded = lm.addLogger(result);
+	if (!couldBeAdded)
+	  throw new IllegalStateException("cannot register new logger");
+      }
+      else
+      {
+	/* The logger already exists. Make sure it uses
+	 * the same resource bundle for localizing messages.
+	 */
+	String existingBundleName = result.getResourceBundleName();
+
+	/* The Sun J2SE 1.4 reference implementation will return the
+	 * registered logger object, even if it does not have a resource
+	 * bundle associated with it. However, it seems to change the
+	 * resourceBundle of the registered logger to the bundle
+	 * whose name was passed to getLogger.
+	 */
+	if ((existingBundleName == null) && (resourceBundleName != null))
+	{
+	  /* If ResourceBundle.getBundle throws an exception, the
+	   * existing logger will be unchanged.  This would be
+	   * different if the assignment to resourceBundleName
+	   * came first.
+	   */
+	  result.resourceBundle = ResourceBundle.getBundle(resourceBundleName);
+	  result.resourceBundleName = resourceBundleName;
+	  return result;
+	}
+
+	if ((existingBundleName != resourceBundleName)
+	    && ((existingBundleName == null)
+		|| !existingBundleName.equals(resourceBundleName)))
+	{
+	  throw new IllegalArgumentException();
+	}
+      }
+    }
+
+    return result;
+  }
+
+  
+  /**
+   * Creates a new, unnamed logger.  Unnamed loggers are not
+   * registered in the namespace of the LogManager, and no special
+   * security permission is required for changing their state.
+   * Therefore, untrusted applets are able to modify their private
+   * logger instance obtained through this method.
+   *
+   * <p>The parent of the newly created logger will the the root
+   * logger, from which the level threshold and the handlers are
+   * inherited.
+   */
+  public static Logger getAnonymousLogger()
+  {
+    return getAnonymousLogger(null);
+  }
+
+
+  /**
+   * Creates a new, unnamed logger.  Unnamed loggers are not
+   * registered in the namespace of the LogManager, and no special
+   * security permission is required for changing their state.
+   * Therefore, untrusted applets are able to modify their private
+   * logger instance obtained through this method.
+   *
+   * <p>The parent of the newly created logger will the the root
+   * logger, from which the level threshold and the handlers are
+   * inherited.
+   *
+   * @param resourceBundleName the name of a resource bundle
+   *        for localizing messages, or <code>null</code>
+   *	    to indicate that messages do not need to be localized.
+   *
+   * @throws java.util.MissingResourceException if
+   *         <code>resourceBundleName</code> is not <code>null</code>
+   *         and no such bundle could be located.
+   */
+  public static Logger getAnonymousLogger(String resourceBundleName)
+    throws MissingResourceException
+  {
+    Logger  result;
+
+    result = new Logger(null, resourceBundleName);
+    result.anonymous = true;
+    return result;
+  }
+
+
+  /**
+   * Returns the name of the resource bundle that is being used for
+   * localizing messages.
+   *
+   * @return the name of the resource bundle used for localizing messages,
+   *         or <code>null</code> if the parent's resource bundle
+   *         is used for this purpose.
+   */
+  public synchronized String getResourceBundleName()
+  {
+    return resourceBundleName;
+  }
+
+
+  /**
+   * Returns the resource bundle that is being used for localizing
+   * messages.
+   *
+   * @return the resource bundle used for localizing messages,
+   *         or <code>null</code> if the parent's resource bundle
+   *         is used for this purpose.
+   */
+  public synchronized ResourceBundle getResourceBundle()
+  {
+    return resourceBundle;
+  }
+
+
+  /**
+   * Returns the severity level threshold for this <code>Handler</code>.
+   * All log records with a lower severity level will be discarded;
+   * a log record of the same or a higher level will be published
+   * unless an installed <code>Filter</code> decides to discard it.
+   *
+   * @return the severity level below which all log messages will be
+   *         discarded, or <code>null</code> if the logger inherits
+   *         the threshold from its parent.
+   */
+  public synchronized Level getLevel()
+  {
+    return level;
+  }
+
+
+  /**
+   * Returns whether or not a message of the specified level
+   * would be logged by this logger.
+   *
+   * @throws NullPointerException if <code>level</code>
+   *         is <code>null</code>.
+   */
+  public synchronized boolean isLoggable(Level level)
+  {
+    if (this.level != null)
+      return this.level.intValue() <= level.intValue();
+
+    if (parent != null)
+      return parent.isLoggable(level);
+    else
+      return false;
+  }
+
+
+  /**
+   * Sets the severity level threshold for this <code>Handler</code>.
+   * All log records with a lower severity level will be discarded
+   * immediately.  A log record of the same or a higher level will be
+   * published unless an installed <code>Filter</code> decides to
+   * discard it.
+   *
+   * @param level the severity level below which all log messages
+   *              will be discarded, or <code>null</code> to
+   *              indicate that the logger should inherit the
+   *              threshold from its parent.
+   *
+   * @throws SecurityException if this logger is not anonymous, a
+   *     security manager exists, and the caller is not granted
+   *     the permission to control the logging infrastructure by
+   *     having LoggingPermission("control").  Untrusted code can
+   *     obtain an anonymous logger through the static factory method
+   *     {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
+   */
+  public synchronized void setLevel(Level level)
+  {
+    /* An application is allowed to control an anonymous logger
+     * without having the permission to control the logging
+     * infrastructure.
+     */
+    if (!anonymous)
+      LogManager.getLogManager().checkAccess();
+
+    this.level = level;
+  }
+
+
+  public synchronized Filter getFilter()
+  {
+    return filter;
+  }
+
+
+  /**
+   * @throws SecurityException if this logger is not anonymous, a
+   *     security manager exists, and the caller is not granted
+   *     the permission to control the logging infrastructure by
+   *     having LoggingPermission("control").  Untrusted code can
+   *     obtain an anonymous logger through the static factory method
+   *     {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
+   */
+  public synchronized void setFilter(Filter filter)
+    throws SecurityException
+  {
+    /* An application is allowed to control an anonymous logger
+     * without having the permission to control the logging
+     * infrastructure.
+     */
+    if (!anonymous)
+      LogManager.getLogManager().checkAccess();
+
+    this.filter = filter;
+  }
+
+
+
+
+  /**
+   * Returns the name of this logger.
+   *
+   * @return the name of this logger, or <code>null</code> if
+   *         the logger is anonymous.
+   */
+  public String getName()
+  {
+    /* Note that the name of a logger cannot be changed during
+     * its lifetime, so no synchronization is needed.
+     */
+    return name;
+  }
+
+
+  /**
+   * Passes a record to registered handlers, provided the record
+   * is considered as loggable both by {@link #isLoggable(Level)}
+   * and a possibly installed custom {@link #setFilter(Filter) filter}.
+   *
+   * <p>If the logger has been configured to use parent handlers,
+   * the record will be forwarded to the parent of this logger
+   * in addition to being processed by the handlers registered with
+   * this logger.
+   *
+   * <p>The other logging methods in this class are convenience methods
+   * that merely create a new LogRecord and pass it to this method.
+   * Therefore, subclasses usually just need to override this single
+   * method for customizing the logging behavior.
+   *
+   * @param record the log record to be inspected and possibly forwarded.
+   */
+  public synchronized void log(LogRecord record)
+  {
+    if (!isLoggable(record.getLevel()))
+      return;
+
+    if ((filter != null) && !filter.isLoggable(record))
+      return;
+
+    /* If no logger name has been set for the log record,
+     * use the name of this logger.
+     */
+    if (record.getLoggerName() == null)
+      record.setLoggerName(name);
+
+    /* Avoid that some other thread is changing the logger hierarchy
+     * while we are traversing it.
+     */
+    synchronized (LogManager.getLogManager())
+    {
+      Logger curLogger = this;
+
+      do
+      {
+        /* The Sun J2SE 1.4 reference implementation seems to call the
+	 * filter only for the logger whose log method is called,
+	 * never for any of its parents.  Also, parent loggers publish
+	 * log record whatever their level might be.  This is pretty
+	 * weird, but GNU Classpath tries to be as compatible as
+	 * possible to the reference implementation.
+	 */
+        for (int i = 0; i < curLogger.handlers.length; i++)
+          curLogger.handlers[i].publish(record);
+
+	if (curLogger.getUseParentHandlers() == false)
+	  break;
+	
+	curLogger = curLogger.getParent();
+      }
+      while (parent != null);
+    }
+  }
+
+
+  public void log(Level level, String message)
+  {
+    if (isLoggable(level))
+      log(level, message, (Object[]) null);
+  }
+
+
+  public synchronized void log(Level level,
+			       String message,
+			       Object param)
+  {
+    if (isLoggable(level))
+      {
+        StackTraceElement caller = getCallerStackFrame();
+        logp(level,
+             caller != null ? caller.getClassName() : "<unknown>",
+             caller != null ? caller.getMethodName() : "<unknown>",
+             message,
+             param);
+      }
+  }
+
+
+  public synchronized void log(Level level,
+			       String message,
+			       Object[] params)
+  {
+    if (isLoggable(level))
+      {
+        StackTraceElement caller = getCallerStackFrame();
+        logp(level,
+             caller != null ? caller.getClassName() : "<unknown>",
+             caller != null ? caller.getMethodName() : "<unknown>",
+             message,
+             params);
+      }
+  }
+
+
+  public synchronized void log(Level level,
+			       String message,
+			       Throwable thrown)
+  {
+    if (isLoggable(level))
+      {
+        StackTraceElement caller = getCallerStackFrame();    
+        logp(level,
+             caller != null ? caller.getClassName() : "<unknown>",
+             caller != null ? caller.getMethodName() : "<unknown>",
+             message,
+             thrown);
+      }
+  }
+
+
+  public synchronized void logp(Level level,
+				String sourceClass,
+				String sourceMethod,
+				String message)
+  {
+    logp(level, sourceClass, sourceMethod, message,
+	 (Object[]) null);
+  }
+
+
+  public synchronized void logp(Level level,
+				String sourceClass,
+				String sourceMethod,
+				String message,
+				Object param)
+  {
+    logp(level, sourceClass, sourceMethod, message,
+	 new Object[] { param });
+  }
+
+
+  private synchronized ResourceBundle findResourceBundle()
+  {
+    if (resourceBundle != null)
+      return resourceBundle;
+
+    if (parent != null)
+      return parent.findResourceBundle();
+
+    return null;
+  }
+
+
+  private synchronized void logImpl(Level level,
+				    String sourceClass,
+				    String sourceMethod,
+				    String message,
+				    Object[] params)
+  {
+    LogRecord rec = new LogRecord(level, message);
+
+    rec.setResourceBundle(findResourceBundle());
+    rec.setSourceClassName(sourceClass);
+    rec.setSourceMethodName(sourceMethod);
+    rec.setParameters(params);
+
+    log(rec);
+  }
+
+
+  public synchronized void logp(Level level,
+				String sourceClass,
+				String sourceMethod,
+				String message,
+				Object[] params)
+  {
+    logImpl(level, sourceClass, sourceMethod, message, params);
+  }
+
+
+  public synchronized void logp(Level level,
+				String sourceClass,
+				String sourceMethod,
+				String message,
+				Throwable thrown)
+  {
+    LogRecord rec = new LogRecord(level, message);
+
+    rec.setResourceBundle(resourceBundle);
+    rec.setSourceClassName(sourceClass);
+    rec.setSourceMethodName(sourceMethod);
+    rec.setThrown(thrown);
+
+    log(rec);
+  }
+
+
+  public synchronized void logrb(Level level,
+				 String sourceClass,
+				 String sourceMethod,
+				 String bundleName,
+				 String message)
+  {
+    logrb(level, sourceClass, sourceMethod, bundleName,
+	  message, (Object[]) null);
+  }
+
+
+  public synchronized void logrb(Level level,
+				 String sourceClass,
+				 String sourceMethod,
+				 String bundleName,
+				 String message,
+				 Object param)
+  {
+    logrb(level, sourceClass, sourceMethod, bundleName,
+	  message, new Object[] { param });
+  }
+
+
+  public synchronized void logrb(Level level,
+				 String sourceClass,
+				 String sourceMethod,
+				 String bundleName,
+				 String message,
+				 Object[] params)
+  {
+    LogRecord rec = new LogRecord(level, message);
+
+    rec.setResourceBundleName(bundleName);
+    rec.setSourceClassName(sourceClass);
+    rec.setSourceMethodName(sourceMethod);
+    rec.setParameters(params);
+
+    log(rec);
+  }
+
+
+  public synchronized void logrb(Level level,
+				 String sourceClass,
+				 String sourceMethod,
+				 String bundleName,
+				 String message,
+				 Throwable thrown)
+  {
+    LogRecord rec = new LogRecord(level, message);
+
+    rec.setResourceBundleName(bundleName);
+    rec.setSourceClassName(sourceClass);
+    rec.setSourceMethodName(sourceMethod);
+    rec.setThrown(thrown);
+
+    log(rec);
+  }
+
+
+  public synchronized void entering(String sourceClass,
+				    String sourceMethod)
+  {
+    if (isLoggable(Level.FINER))
+      logp(Level.FINER, sourceClass, sourceMethod, "ENTRY");
+  }
+
+
+  public synchronized void entering(String sourceClass,
+				    String sourceMethod,
+				    Object param)
+  {
+    if (isLoggable(Level.FINER))
+      logp(Level.FINER, sourceClass, sourceMethod, "ENTRY {0}", param);
+  }
+
+
+  public synchronized void entering(String sourceClass,
+				    String sourceMethod,
+				    Object[] params)
+  {
+    if (isLoggable(Level.FINER))
+    {
+      StringBuffer buf = new StringBuffer(80);
+      buf.append("ENTRY");
+      for (int i = 0; i < params.length; i++)
+      {
+	buf.append(" {");
+	buf.append(i);
+	buf.append('}');
+      }
+      
+      logp(Level.FINER, sourceClass, sourceMethod, buf.toString(), params);
+    }
+  }
+
+
+  public synchronized void exiting(String sourceClass,
+				   String sourceMethod)
+  {
+    if (isLoggable(Level.FINER))
+      logp(Level.FINER, sourceClass, sourceMethod, "RETURN");
+  }
+
+   
+  public synchronized void exiting(String sourceClass,
+				   String sourceMethod,
+				   Object result)
+  {
+    if (isLoggable(Level.FINER))
+      logp(Level.FINER, sourceClass, sourceMethod, "RETURN {0}", result);
+  }
+
+ 
+  public synchronized void throwing(String sourceClass,
+				    String sourceMethod,
+				    Throwable thrown)
+  {
+    if (isLoggable(Level.FINER))
+      logp(Level.FINER, sourceClass, sourceMethod, "THROW", thrown);
+  }
+
+
+  /**
+   * Logs a message with severity level SEVERE, indicating a serious
+   * failure that prevents normal program execution.  Messages at this
+   * level should be understandable to an inexperienced, non-technical
+   * end user.  Ideally, they explain in simple words what actions the
+   * user can take in order to resolve the problem.
+   *
+   * @see Level#SEVERE
+   *
+   * @param message the message text, also used as look-up key if the
+   *                logger is localizing messages with a resource
+   *                bundle.  While it is possible to pass
+   *                <code>null</code>, this is not recommended, since
+   *                a logging message without text is unlikely to be
+   *                helpful.
+   */
+  public synchronized void severe(String message)
+  {
+    if (isLoggable(Level.SEVERE))
+      log(Level.SEVERE, message);
+  }
+
+
+  /**
+   * Logs a message with severity level WARNING, indicating a
+   * potential problem that does not prevent normal program execution.
+   * Messages at this level should be understandable to an
+   * inexperienced, non-technical end user.  Ideally, they explain in
+   * simple words what actions the user can take in order to resolve
+   * the problem.
+   *
+   * @see Level#WARNING
+   *
+   * @param message the message text, also used as look-up key if the
+   *                logger is localizing messages with a resource
+   *                bundle.  While it is possible to pass
+   *                <code>null</code>, this is not recommended, since
+   *                a logging message without text is unlikely to be
+   *                helpful.
+   */
+  public synchronized void warning(String message)
+  {
+    if (isLoggable(Level.WARNING))
+      log(Level.WARNING, message);
+  }
+
+
+  /**
+   * Logs a message with severity level INFO.  {@link Level#INFO} is
+   * intended for purely informational messages that do not indicate
+   * error or warning situations. In the default logging
+   * configuration, INFO messages will be written to the system
+   * console.  For this reason, the INFO level should be used only for
+   * messages that are important to end users and system
+   * administrators.  Messages at this level should be understandable
+   * to an inexperienced, non-technical user.
+   *
+   * @param message the message text, also used as look-up key if the
+   *                logger is localizing messages with a resource
+   *                bundle.  While it is possible to pass
+   *                <code>null</code>, this is not recommended, since
+   *                a logging message without text is unlikely to be
+   *                helpful.
+   */
+  public synchronized void info(String message)
+  {
+    if (isLoggable(Level.INFO))
+      log(Level.INFO, message);
+  }
+
+
+  /**
+   * Logs a message with severity level CONFIG.  {@link Level#CONFIG} is
+   * intended for static configuration messages, for example about the
+   * windowing environment, the operating system version, etc.
+   *
+   * @param message the message text, also used as look-up key if the
+   *     logger is localizing messages with a resource bundle.  While
+   *     it is possible to pass <code>null</code>, this is not
+   *     recommended, since a logging message without text is unlikely
+   *     to be helpful.
+   */
+  public synchronized void config(String message)
+  {
+    if (isLoggable(Level.CONFIG))
+      log(Level.CONFIG, message);
+  }
+
+
+  /**
+   * Logs a message with severity level FINE.  {@link Level#FINE} is
+   * intended for messages that are relevant for developers using
+   * the component generating log messages. Examples include minor,
+   * recoverable failures, or possible inefficiencies.
+   *
+   * @param message the message text, also used as look-up key if the
+   *                logger is localizing messages with a resource
+   *                bundle.  While it is possible to pass
+   *                <code>null</code>, this is not recommended, since
+   *                a logging message without text is unlikely to be
+   *                helpful.
+   */
+  public synchronized void fine(String message)
+  {
+    if (isLoggable(Level.FINE))
+      log(Level.FINE, message);
+  }
+
+
+  /**
+   * Logs a message with severity level FINER.  {@link Level#FINER} is
+   * intended for rather detailed tracing, for example entering a
+   * method, returning from a method, or throwing an exception.
+   *
+   * @param message the message text, also used as look-up key if the
+   *                logger is localizing messages with a resource
+   *                bundle.  While it is possible to pass
+   *                <code>null</code>, this is not recommended, since
+   *                a logging message without text is unlikely to be
+   *                helpful.
+   */
+  public synchronized void finer(String message)
+  {
+    if (isLoggable(Level.FINER))
+      log(Level.FINER, message);
+  }
+
+
+  /**
+   * Logs a message with severity level FINEST.  {@link Level#FINEST}
+   * is intended for highly detailed tracing, for example reaching a
+   * certain point inside the body of a method.
+   *
+   * @param message the message text, also used as look-up key if the
+   *                logger is localizing messages with a resource
+   *                bundle.  While it is possible to pass
+   *                <code>null</code>, this is not recommended, since
+   *                a logging message without text is unlikely to be
+   *                helpful.
+   */
+  public synchronized void finest(String message)
+  {
+    if (isLoggable(Level.FINEST))
+      log(Level.FINEST, message);
+  }
+
+
+  /**
+   * Adds a handler to the set of handlers that get notified
+   * when a log record is to be published.
+   *
+   * @param handler the handler to be added.
+   *
+   * @throws NullPointerException if <code>handler</code>
+   *     is <code>null</code>.
+   *
+   * @throws SecurityException if this logger is not anonymous, a
+   *     security manager exists, and the caller is not granted
+   *     the permission to control the logging infrastructure by
+   *     having LoggingPermission("control").  Untrusted code can
+   *     obtain an anonymous logger through the static factory method
+   *     {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
+   */
+  public synchronized void addHandler(Handler handler)
+    throws SecurityException
+  {
+    /* Throw a new NullPointerException if handler is null. */
+    handler.getClass();
+
+    /* An application is allowed to control an anonymous logger
+     * without having the permission to control the logging
+     * infrastructure.
+     */
+    if (!anonymous)
+      LogManager.getLogManager().checkAccess();
+
+    if (!handlerList.contains(handler))
+    {
+      handlerList.add(handler);
+      handlers = getHandlers();
+    }
+  }
+
+
+  /**
+   * Removes a handler from the set of handlers that get notified
+   * when a log record is to be published.
+   *
+   * @param handler the handler to be removed.
+   *
+   * @throws SecurityException if this logger is not anonymous, a
+   *     security manager exists, and the caller is not granted the
+   *     permission to control the logging infrastructure by having
+   *     LoggingPermission("control").  Untrusted code can obtain an
+   *     anonymous logger through the static factory method {@link
+   *     #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
+   *
+   * @throws NullPointerException if <code>handler</code>
+   *     is <code>null</code>.
+   */
+  public synchronized void removeHandler(Handler handler)
+    throws SecurityException
+  {
+    /* An application is allowed to control an anonymous logger
+     * without having the permission to control the logging
+     * infrastructure.
+     */
+    if (!anonymous)
+      LogManager.getLogManager().checkAccess();
+
+    /* Throw a new NullPointerException if handler is null. */
+    handler.getClass();
+
+    handlerList.remove(handler);
+    handlers = getHandlers();
+  }
+
+
+  /**
+   * Returns the handlers currently registered for this Logger.
+   * When a log record has been deemed as being loggable,
+   * it will be passed to all registered handlers for
+   * publication.  In addition, if the logger uses parent handlers
+   * (see {@link #getUseParentHandlers() getUseParentHandlers}
+   * and {@link #setUseParentHandlers(boolean) setUseParentHandlers},
+   * the log record will be passed to the parent's handlers.
+   */
+  public synchronized Handler[] getHandlers()
+  {
+    /* We cannot return our internal handlers array
+     * because we do not have any guarantee that the
+     * caller would not change the array entries.
+     */
+    return (Handler[]) handlerList.toArray(new Handler[handlerList.size()]);
+  }
+
+
+  /**
+   * Returns whether or not this Logger forwards log records to
+   * handlers registered for its parent loggers.
+   *
+   * @return <code>false</code> if this Logger sends log records
+   *         merely to Handlers registered with itself;
+   *         <code>true</code> if this Logger sends log records
+   *         not only to Handlers registered with itself, but also
+   *         to those Handlers registered with parent loggers.
+   */
+  public synchronized boolean getUseParentHandlers()
+  {
+    return useParentHandlers;
+  }
+
+
+  /**
+   * Sets whether or not this Logger forwards log records to
+   * handlers registered for its parent loggers.
+   *
+   * @param useParentHandlers <code>false</code> to let this
+   *         Logger send log records merely to Handlers registered
+   *         with itself; <code>true</code> to let this Logger
+   *         send log records not only to Handlers registered
+   *         with itself, but also to those Handlers registered with
+   *         parent loggers.
+   *
+   * @throws SecurityException if this logger is not anonymous, a
+   *     security manager exists, and the caller is not granted
+   *     the permission to control the logging infrastructure by
+   *     having LoggingPermission("control").  Untrusted code can
+   *     obtain an anonymous logger through the static factory method
+   *     {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
+   *
+   */
+  public synchronized void setUseParentHandlers(boolean useParentHandlers)
+  {
+    /* An application is allowed to control an anonymous logger
+     * without having the permission to control the logging
+     * infrastructure.
+     */
+    if (!anonymous)
+      LogManager.getLogManager().checkAccess();
+
+    this.useParentHandlers = useParentHandlers;
+  }
+
+
+  /**
+   * Returns the parent of this logger.  By default, the parent is
+   * assigned by the LogManager by inspecting the logger's name.
+   *
+   * @return the parent of this logger (as detemined by the LogManager
+   *     by inspecting logger names), the root logger if no other
+   *     logger has a name which is a prefix of this logger's name, or
+   *     <code>null</code> for the root logger.
+   */
+  public synchronized Logger getParent()
+  {
+    return parent;
+  }
+
+
+  /**
+   * Sets the parent of this logger.  Usually, applications do not
+   * call this method directly.  Instead, the LogManager will ensure
+   * that the tree of loggers reflects the hierarchical logger
+   * namespace.  Basically, this method should not be public at all,
+   * but the GNU implementation follows the API specification.
+   *
+   * @throws NullPointerException if <code>parent</code> is
+   *     <code>null</code>.
+   *
+   * @throws SecurityException if this logger is not anonymous, a
+   *     security manager exists, and the caller is not granted
+   *     the permission to control the logging infrastructure by
+   *     having LoggingPermission("control").  Untrusted code can
+   *     obtain an anonymous logger through the static factory method
+   *     {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
+   */
+  public synchronized void setParent(Logger parent)
+  {
+    /* Throw a new NullPointerException if parent is null. */
+    parent.getClass();
+
+    if (this == root)
+        throw new IllegalArgumentException(
+          "the root logger can only have a null parent");
+
+    /* An application is allowed to control an anonymous logger
+     * without having the permission to control the logging
+     * infrastructure.
+     */
+    if (!anonymous)
+      LogManager.getLogManager().checkAccess();
+
+    this.parent = parent;
+  }
+  
+  /**
+   * Gets the StackTraceElement of the first class that is not this class.
+   * That should be the initial caller of a logging method.
+   * @return caller of the initial logging method or null if unknown.
+   */
+  private StackTraceElement getCallerStackFrame()
+  {
+    Throwable t = new Throwable();
+    StackTraceElement[] stackTrace = t.getStackTrace();
+    int index = 0;
+
+    // skip to stackentries until this class
+    while(index < stackTrace.length
+	  && !stackTrace[index].getClassName().equals(getClass().getName()))
+      index++;
+
+    // skip the stackentries of this class
+    while(index < stackTrace.length
+	  && stackTrace[index].getClassName().equals(getClass().getName()))
+      index++;
+
+    return index < stackTrace.length ? stackTrace[index] : null;
+  }
+  
+  /**
+   * Reset and close handlers attached to this logger. This function is package
+   * private because it must only be available to the LogManager.
+   */
+  void resetLogger()
+  {
+    for (int i = 0; i < handlers.length; i++)
+      {
+        handlers[i].close();
+        handlerList.remove(handlers[i]);
+      }
+    handlers = getHandlers();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LoggingMXBean.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LoggingMXBean.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LoggingMXBean.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LoggingMXBean.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* LoggingMxBean.java -- Management interface for logging
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+import java.util.List;
+
+/**
+ * This interface represents the management interface for logging.
+ * There is a single logging bean per VM instance, which can be
+ * retrieved via {@link LogManager#getLoggingMXBean()}.
+ * 
+ * @since 1.5
+ */
+public interface LoggingMXBean
+{
+  /**
+   * Return the name of the logging level given the name of
+   * a logger.  Returns null if no such logger exists.
+   * @param logger the logger's name
+   * @return the logging level's name, or null
+   */
+  String getLoggerLevel(String logger);
+
+  /**
+   * Return a list of all logger names.
+   */
+  List/*<String>*/ getLoggerNames();
+
+  /**
+   * Return the name of the parent of the indicated logger.
+   * If no such logger exists, returns null.  If the logger
+   * is the root logger, returns the empty string.
+   * @param logger the logger's name
+   * @return the name of the logger's parent, or null
+   */
+  String getParentLoggerName(String logger);
+
+  /**
+   * Sets the logging level for a particular logger.
+   * 
+   * @param logger the name of the logger
+   * @param level the name of the new logging level, or null
+   * @throws IllegalArgumentException if the level is not
+   * recognized, or if the logger does not exist
+   * @throws SecurityException if access is denied;
+   * see {@link Logger#setLevel(Level)}
+   */
+  void setLoggerLevel(String logger, String level);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LoggingPermission.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LoggingPermission.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LoggingPermission.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/LoggingPermission.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* LoggingPermission.java -- a class for logging permissions.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+public final class LoggingPermission
+  extends java.security.BasicPermission
+{
+  private static final long serialVersionUID = 63564341580231582L;
+
+  /**
+   * Creates a new LoggingPermission.
+   *
+   * @param name the name of the permission, which must be "control".
+   *
+   * @param actions the list of actions for the permission, which
+   *                must be either <code>null</code> or an empty
+   *                string.
+   *
+   * @exception IllegalArgumentException if <code>name</code>
+   *            is not "control", or <code>actions</code> is
+   *            neither <code>null</code> nor empty.
+   */
+  public LoggingPermission(String name, String actions)
+  {
+    super("control", "");
+    
+    if (!"control".equals(name))
+    {
+      throw new IllegalArgumentException(
+        "name of LoggingPermission must be \"control\"");
+    }
+    
+    if ((actions != null) && (actions.length() != 0))
+    {
+      throw new IllegalArgumentException(
+	"actions of LoggingPermissions must be null or empty");
+    }    
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/MemoryHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/MemoryHandler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/MemoryHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/MemoryHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,345 @@
+/* MemoryHandler.java -- a class for buffering log messages in a memory buffer
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.logging;
+
+/**
+ * A <code>MemoryHandler</code> maintains a circular buffer of
+ * log records.
+ *
+ * <p><strong>Configuration:</strong> Values of the subsequent
+ * <code>LogManager</code> properties are taken into consideration
+ * when a <code>MemoryHandler</code> is initialized.
+ * If a property is not defined, or if it has an invalid
+ * value, a default is taken without an exception being thrown.
+ *
+ * <ul>
+ * <li><code>java.util.MemoryHandler.level</code> - specifies
+ *     the initial severity level threshold. Default value:
+ *     <code>Level.ALL</code>.</li>
+ * <li><code>java.util.MemoryHandler.filter</code> - specifies
+ *     the name of a Filter class. Default value: No Filter.</li>
+ * <li><code>java.util.MemoryHandler.size</code> - specifies the
+ *     maximum number of log records that are kept in the circular
+ *     buffer.  Default value: 1000.</li>
+ * <li><code>java.util.MemoryHandler.push</code> - specifies the
+ *     <code>pushLevel</code>. Default value:
+ *     <code>Level.SEVERE</code>.</li>
+ * <li><code>java.util.MemoryHandler.target</code> - specifies the
+ *     name of a subclass of {@link Handler} that will be used as the
+ *     target handler.  There is no default value for this property;
+ *     if it is not set, the no-argument MemoryHandler constructor
+ *     will throw an exception.</li>
+ * </ul>
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public class MemoryHandler
+  extends Handler
+{
+  /**
+   * The storage area used for buffering the unpushed log records in
+   * memory.
+   */
+  private final LogRecord[] buffer;
+
+
+  /**
+   * The current position in the circular buffer. For a new
+   * MemoryHandler, or immediately after {@link #push()} was called,
+   * the value of this variable is zero.  Each call to {@link
+   * #publish(LogRecord)} will store the published LogRecord into
+   * <code>buffer[position]</code> before position is incremented by
+   * one.  If position becomes greater than the size of the buffer, it
+   * is reset to zero.
+   */
+  private int position;
+
+
+  /**
+   * The number of log records which have been published, but not
+   * pushed yet to the target handler.
+   */
+  private int numPublished;
+
+
+  /**
+   * The push level threshold for this <code>Handler</code>.  When a
+   * record is published whose severity level is greater than or equal
+   * to the <code>pushLevel</code> of this <code>MemoryHandler</code>,
+   * the {@link #push()} method will be invoked for pushing the buffer
+   * contents to the target <code>Handler</code>.
+   */
+  private Level pushLevel;
+
+
+  /**
+   * The Handler to which log records are forwarded for actual
+   * publication.
+   */
+  private final Handler target;
+
+
+  /**
+   * Constructs a <code>MemoryHandler</code> for keeping a circular
+   * buffer of LogRecords; the initial configuration is determined by
+   * the <code>LogManager</code> properties described above.
+   */
+  public MemoryHandler()
+  {
+    this((Handler) LogManager.getInstanceProperty(
+	   "java.util.logging.MemoryHandler.target",
+	   Handler.class, /* default */ null),
+	 LogManager.getIntPropertyClamped(
+	   "java.util.logging.MemoryHandler.size",
+	   /* default */ 1000,
+	   /* minimum value */ 1,
+	   /* maximum value */ Integer.MAX_VALUE),
+	 LogManager.getLevelProperty(
+	   "java.util.logging.MemoryHandler.push",
+	   /* default push level */ Level.SEVERE));
+  }
+
+  
+  /**
+   * Constructs a <code>MemoryHandler</code> for keeping a circular
+   * buffer of LogRecords, given some parameters. The values of the
+   * other parameters are taken from LogManager properties, as
+   * described above.
+   *
+   * @param target the target handler that will receive those
+   *               log records that are passed on for publication.
+   *
+   * @param size the number of log records that are kept in the buffer.
+   *             The value must be a at least one.
+   *
+   * @param pushLevel the push level threshold for this
+   *     <code>MemoryHandler</code>.  When a record is published whose
+   *     severity level is greater than or equal to
+   *     <code>pushLevel</code>, the {@link #push()} method will be
+   *     invoked in order to push the bufffer contents to
+   *     <code>target</code>.
+   *
+   * @throws java.lang.IllegalArgumentException if <code>size</code>
+   *         is negative or zero. The GNU implementation also throws
+   *         an IllegalArgumentException if <code>target</code> or
+   *         <code>pushLevel</code> are <code>null</code>, but the
+   *         API specification does not prescribe what should happen
+   *         in those cases.
+   */
+  public MemoryHandler(Handler target, int size, Level pushLevel)
+  { 
+    if ((target == null) || (size <= 0) || (pushLevel == null))
+      throw new IllegalArgumentException();
+
+    buffer = new LogRecord[size];
+    this.pushLevel = pushLevel;
+    this.target = target;
+
+    setLevel(LogManager.getLevelProperty(
+      "java.util.logging.MemoryHandler.level",
+      /* default value */ Level.ALL));
+
+    setFilter((Filter) LogManager.getInstanceProperty(
+      "java.util.logging.MemoryHandler.filter",
+      /* must be instance of */ Filter.class,
+      /* default value */ null));
+  }
+
+
+  /**
+   * Stores a <code>LogRecord</code> in a fixed-size circular buffer,
+   * provided the record passes all tests for being loggable.  If the
+   * buffer is full, the oldest record will be discarded.
+   *
+   * <p>If the record has a severity level which is greater than or
+   * equal to the <code>pushLevel</code> of this
+   * <code>MemoryHandler</code>, the {@link #push()} method will be
+   * invoked for pushing the buffer contents to the target
+   * <code>Handler</code>.
+   *
+   * <p>Most applications do not need to call this method directly.
+   * Instead, they will use use a {@link Logger}, which will create
+   * LogRecords and distribute them to registered handlers.
+   *
+   * @param record the log event to be published.
+   */
+  public void publish(LogRecord record)
+  {
+    if (!isLoggable(record))
+      return;
+
+    buffer[position] = record;
+    position = (position + 1) % buffer.length;
+    numPublished = numPublished + 1;
+
+    if (record.getLevel().intValue() >= pushLevel.intValue())
+      push();
+  }
+
+
+  /**
+   * Pushes the contents of the memory buffer to the target
+   * <code>Handler</code> and clears the buffer. Note that
+   * the target handler will discard those records that do
+   * not satisfy its own severity level threshold, or that are
+   * not considered loggable by an installed {@link Filter}.
+   *
+   * <p>In case of an I/O failure, the {@link ErrorManager} of the
+   * target <code>Handler</code> will be notified, but the caller of
+   * this method will not receive an exception.
+   */
+  public void push()
+  {
+    int i;
+
+    if (numPublished < buffer.length)
+    {
+      for (i = 0; i < position; i++)
+        target.publish(buffer[i]);
+    }
+    else
+    {
+      for (i = position; i < buffer.length; i++)
+	target.publish(buffer[i]);
+      for (i = 0; i < position; i++)
+	target.publish(buffer[i]);
+    }
+
+    numPublished = 0;
+    position = 0;
+  }
+
+
+  /**
+   * Forces any data that may have been buffered by the target
+   * <code>Handler</code> to the underlying output device, but
+   * does <em>not</em> push the contents of the circular memory
+   * buffer to the target handler.
+   *
+   * <p>In case of an I/O failure, the {@link ErrorManager} of the
+   * target <code>Handler</code> will be notified, but the caller of
+   * this method will not receive an exception.
+   *
+   * @see #push()
+   */
+  public void flush()
+  {
+    target.flush();
+  }
+
+
+  /**
+   * Closes this <code>MemoryHandler</code> and its associated target
+   * handler, discarding the contents of the memory buffer.  However,
+   * any data that may have been buffered by the target
+   * <code>Handler</code> is forced to the underlying output device.
+   *
+   * <p>As soon as <code>close</code> has been called,
+   * a <code>Handler</code> should not be used anymore. Attempts
+   * to publish log records, to flush buffers, or to modify the
+   * <code>Handler</code> in any other way may throw runtime
+   * exceptions after calling <code>close</code>.</p>
+   *
+   * <p>In case of an I/O failure, the <code>ErrorManager</code> of
+   * the associated target <code>Handler</code> will be informed, but
+   * the caller of this method will not receive an exception.</p>
+   *
+   * @throws SecurityException if a security manager exists and
+   *         the caller is not granted the permission to control
+   *         the logging infrastructure.
+   *
+   * @see #push()
+   */
+  public void close()
+    throws SecurityException
+  {
+    push();
+
+    /* This will check for LoggingPermission("control"). If the
+     * current security context does not grant this permission,
+     * push() has been executed, but this does not impose a
+     * security risk.
+     */
+    target.close();
+  }
+
+    
+
+  /**
+   * Returns the push level threshold for this <code>Handler</code>.
+   * When a record is published whose severity level is greater
+   * than or equal to the <code>pushLevel</code> of this
+   * <code>MemoryHandler</code>, the {@link #push()} method will be
+   * invoked for pushing the buffer contents to the target
+   * <code>Handler</code>.
+   *
+   * @return the push level threshold for automatic pushing.
+   */
+  public Level getPushLevel()
+  {
+    return pushLevel;
+  }
+
+
+  /**
+   * Sets the push level threshold for this <code>Handler</code>.
+   * When a record is published whose severity level is greater
+   * than or equal to the <code>pushLevel</code> of this
+   * <code>MemoryHandler</code>, the {@link #push()} method will be
+   * invoked for pushing the buffer contents to the target
+   * <code>Handler</code>.
+   *
+   * @param pushLevel the push level threshold for automatic pushing.
+   *
+   * @exception SecurityException if a security manager exists and
+   *            the caller is not granted the permission to control
+   *            the logging infrastructure.
+   *
+   * @exception NullPointerException if <code>pushLevel</code> is
+   *            <code>null</code>.
+   */
+  public void setPushLevel(Level pushLevel)
+  {
+    LogManager.getLogManager().checkAccess();
+
+    /* Throws a NullPointerException if pushLevel is null. */
+    pushLevel.getClass();
+
+    this.pushLevel = pushLevel;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/SimpleFormatter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/SimpleFormatter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/SimpleFormatter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/SimpleFormatter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,129 @@
+/* SimpleFormatter.java --
+   A class for formatting log records into short human-readable messages
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.DateFormat;
+import java.util.Date;
+
+/**
+ * A <code>SimpleFormatter</code> formats log records into
+ * short human-readable messages, typically one or two lines.
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public class SimpleFormatter
+  extends Formatter
+{
+  /**
+   * Constructs a SimpleFormatter.
+   */
+  public SimpleFormatter()
+  {
+  }
+
+
+  /**
+   * An instance of a DateFormatter that is used for formatting
+   * the time of a log record into a human-readable string,
+   * according to the rules of the current locale.  The value
+   * is set after the first invocation of format, since it is
+   * common that a JVM will instantiate a SimpleFormatter without
+   * ever using it.
+   */
+  private DateFormat dateFormat;
+
+  /**
+   * The character sequence that is used to separate lines in the
+   * generated stream. Somewhat surprisingly, the Sun J2SE 1.4
+   * reference implementation always uses UNIX line endings, even on
+   * platforms that have different line ending conventions (i.e.,
+   * DOS). The GNU implementation does not replicate this bug.
+   *
+   * @see Sun bug parade, bug #4462871,
+   * "java.util.logging.SimpleFormatter uses hard-coded line separator".
+   */
+  static final String lineSep = System.getProperty("line.separator");
+
+
+  /**
+   * Formats a log record into a String.
+   *
+   * @param record the log record to be formatted.
+   *
+   * @return a short human-readable message, typically one or two
+   *   lines.  Lines are separated using the default platform line
+   *   separator.
+   *
+   * @throws NullPointerException if <code>record</code>
+   *         is <code>null</code>.
+   */
+  public String format(LogRecord record)
+  {
+    StringBuffer buf = new StringBuffer(180);
+
+    if (dateFormat == null)
+      dateFormat = DateFormat.getDateTimeInstance();
+
+    buf.append(dateFormat.format(new Date(record.getMillis())));
+    buf.append(' ');
+    buf.append(record.getSourceClassName());
+    buf.append(' ');
+    buf.append(record.getSourceMethodName());
+    buf.append(lineSep);
+
+    buf.append(record.getLevel());
+    buf.append(": ");
+    buf.append(formatMessage(record));
+
+    buf.append(lineSep);
+
+    Throwable throwable = record.getThrown();
+    if (throwable != null)
+      {
+        StringWriter sink = new StringWriter();
+        throwable.printStackTrace(new PrintWriter(sink, true));
+        buf.append(sink.toString());
+      }
+
+    return buf.toString();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/SocketHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/SocketHandler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/SocketHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/SocketHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,221 @@
+/* SocketHandler.java -- a class for publishing log messages to network sockets
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+
+/**
+ * A <code>SocketHandler</code> publishes log records to
+ * a TCP/IP socket.
+ *
+ * <p><strong>Configuration:</strong> Values of the subsequent
+ * <code>LogManager</code> properties are taken into consideration
+ * when a <code>SocketHandler</code> is initialized.
+ * If a property is not defined, or if it has an invalid
+ * value, a default is taken without an exception being thrown.
+ *
+ * <ul>
+ *
+ * <li><code>java.util.SocketHandler.level</code> - specifies
+ *     the initial severity level threshold. Default value:
+ *     <code>Level.ALL</code>.</li>
+ *
+ * <li><code>java.util.SocketHandler.filter</code> - specifies
+ *     the name of a Filter class. Default value: No Filter.</li>
+ *
+ * <li><code>java.util.SocketHandler.formatter</code> - specifies
+ *     the name of a Formatter class. Default value:
+ *     <code>java.util.logging.XMLFormatter</code>.</li>
+ *
+ * <li><code>java.util.SocketHandler.encoding</code> - specifies
+ *     the name of the character encoding. Default value:
+ *     the default platform encoding.</li>
+ *
+ * <li><code>java.util.SocketHandler.host</code> - specifies
+ *     the name of the host to which records are published.
+ *     There is no default value for this property; if it is
+ *     not set, the SocketHandler constructor will throw
+ *     an exception.</li>
+ *
+ * <li><code>java.util.SocketHandler.port</code> - specifies
+ *     the TCP/IP port to which records are published.
+ *     There is no default value for this property; if it is
+ *     not set, the SocketHandler constructor will throw
+ *     an exception.</li>
+ *
+ * </ul>
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public class SocketHandler
+  extends StreamHandler
+{
+  /**
+   * Constructs a <code>SocketHandler</code> that publishes log
+   * records to a TCP/IP socket.  Tthe initial configuration is
+   * determined by the <code>LogManager</code> properties described
+   * above.
+   *
+   * @throws java.io.IOException if the connection to the specified
+   *         network host and port cannot be established.
+   *
+   * @throws java.lang.IllegalArgumentException if either the
+   *         <code>java.util.logging.SocketHandler.host</code>
+   *         or <code>java.util.logging.SocketHandler.port</code>
+   *         LogManager properties is not defined, or specifies
+   *         an invalid value.
+   */
+  public SocketHandler()
+    throws java.io.IOException
+  {
+    this(LogManager.getLogManager().getProperty("java.util.logging.SocketHandler.host"),
+	 getPortNumber());
+  }
+
+    
+  /**
+   * Constructs a <code>SocketHandler</code> that publishes log
+   * records to a TCP/IP socket.  With the exception of the internet
+   * host and port, the initial configuration is determined by the
+   * <code>LogManager</code> properties described above.
+   *
+   * @param host the Internet host to which log records will be
+   *        forwarded.
+   *
+   * @param port the port at the host which will accept a request
+   *        for a TCP/IP connection.
+   *
+   * @throws java.io.IOException if the connection to the specified
+   *         network host and port cannot be established.
+   *
+   * @throws java.lang.IllegalArgumentException if either
+   *         <code>host</code> or <code>port</code> specify
+   *         an invalid value.
+   */
+  public SocketHandler(String host, int port)
+    throws java.io.IOException
+  {
+    super(createSocket(host, port),
+	  "java.util.logging.SocketHandler",
+	  /* default level */ Level.ALL,
+	  /* formatter */ null,
+	  /* default formatter */ XMLFormatter.class);
+  }
+
+
+  /**
+   * Retrieves the port number from the java.util.logging.SocketHandler.port
+   * LogManager property.
+   *
+   * @throws IllegalArgumentException if the property is not defined or
+   *         does not specify an integer value.
+   */
+  private static int getPortNumber()
+  {
+    try {
+      return Integer.parseInt(LogManager.getLogManager().getProperty("java.util.logging.SocketHandler.port"));
+    } catch (Exception ex) {
+      throw new IllegalArgumentException();
+    }
+  }
+
+
+  /**
+   * Creates an OutputStream for publishing log records to an Internet
+   * host and port.  This private method is a helper for use by the
+   * constructor of SocketHandler.
+   *
+   * @param host the Internet host to which log records will be
+   *        forwarded.
+   *
+   * @param port the port at the host which will accept a request
+   *        for a TCP/IP connection.
+   *
+   * @throws java.io.IOException if the connection to the specified
+   *         network host and port cannot be established.
+   *
+   * @throws java.lang.IllegalArgumentException if either
+   *         <code>host</code> or <code>port</code> specify
+   *         an invalid value.
+   */
+  private static java.io.OutputStream createSocket(String host, int port)
+    throws java.io.IOException, java.lang.IllegalArgumentException
+  {
+    java.net.Socket  socket;
+
+    if ((host == null) || (port < 1))
+      throw new IllegalArgumentException();
+
+    socket = new java.net.Socket(host, port);
+
+    socket.shutdownInput();
+
+    /* The architecture of the logging framework provides replaceable
+     * formatters.  Because these formatters perform their task by
+     * returning one single String for each LogRecord to be formatted,
+     * there is no need to buffer.
+     */
+    socket.setTcpNoDelay(true);
+
+    return socket.getOutputStream();
+  }
+
+
+  /**
+   * Publishes a <code>LogRecord</code> to the network socket,
+   * provided the record passes all tests for being loggable.
+   * In addition, all data that may have been buffered will
+   * be forced to the network stream.
+   *
+   * <p>Most applications do not need to call this method directly.
+   * Instead, they will use a {@link Logger} instance, which will
+   * create LogRecords and distribute them to registered handlers.
+   *
+   * <p>In case of an I/O failure, the <code>ErrorManager</code>
+   * of this <code>SocketHandler</code> will be informed, but the caller
+   * of this method will not receive an exception.
+   *
+   * @param record the log event to be published.
+   */
+  public void publish(LogRecord record)
+  {
+    super.publish(record);
+    flush();
+  }
+}
+    

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/StreamHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/StreamHandler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/StreamHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/StreamHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,521 @@
+/* StreamHandler.java --
+   A class for publishing log messages to instances of java.io.OutputStream
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+
+/**
+ * A <code>StreamHandler</code> publishes <code>LogRecords</code> to
+ * a instances of <code>java.io.OutputStream</code>.
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public class StreamHandler
+  extends Handler
+{
+  private OutputStream  out;
+  private Writer        writer;
+
+
+ /**
+  * Indicates the current state of this StreamHandler.  The value
+  * should be one of STATE_FRESH, STATE_PUBLISHED, or STATE_CLOSED.
+  */
+  private int streamState = STATE_FRESH;
+
+
+  /**
+   * streamState having this value indicates that the StreamHandler
+   * has been created, but the publish(LogRecord) method has not been
+   * called yet.  If the StreamHandler has been constructed without an
+   * OutputStream, writer will be null, otherwise it is set to a
+   * freshly created OutputStreamWriter.
+   */
+  private static final int STATE_FRESH = 0;
+
+
+  /**
+   * streamState having this value indicates that the publish(LocRecord)
+   * method has been called at least once.
+   */
+  private static final int STATE_PUBLISHED = 1;
+
+
+  /**
+   * streamState having this value indicates that the close() method
+   * has been called.
+   */
+  private static final int STATE_CLOSED = 2;
+
+
+  /**
+   * Creates a <code>StreamHandler</code> without an output stream.
+   * Subclasses can later use {@link
+   * #setOutputStream(java.io.OutputStream)} to associate an output
+   * stream with this StreamHandler.
+   */
+  public StreamHandler()
+  {
+    this(null, null);
+  }
+
+
+  /**
+   * Creates a <code>StreamHandler</code> that formats log messages
+   * with the specified Formatter and publishes them to the specified
+   * output stream.
+   *
+   * @param out the output stream to which the formatted log messages
+   *     are published.
+   *
+   * @param formatter the <code>Formatter</code> that will be used
+   *     to format log messages.
+   */
+  public StreamHandler(OutputStream out, Formatter formatter)
+  {
+    this(out, "java.util.logging.StreamHandler", Level.INFO,
+	 formatter, SimpleFormatter.class);
+  }
+
+
+  StreamHandler(
+    OutputStream out,
+    String propertyPrefix,
+    Level defaultLevel,
+    Formatter formatter, Class defaultFormatterClass)
+  {
+    this.level = LogManager.getLevelProperty(propertyPrefix + ".level",
+					     defaultLevel);
+
+    this.filter = (Filter) LogManager.getInstanceProperty(
+      propertyPrefix + ".filter",
+      /* must be instance of */       Filter.class,
+      /* default: new instance of */  null);
+
+    if (formatter != null)
+      this.formatter = formatter;
+    else
+      this.formatter = (Formatter) LogManager.getInstanceProperty(
+	propertyPrefix + ".formatter",
+        /* must be instance of */       Formatter.class,
+        /* default: new instance of */  defaultFormatterClass);
+
+    try
+    {
+      String enc = LogManager.getLogManager().getProperty(propertyPrefix
+							  + ".encoding");
+
+      /* make sure enc actually is a valid encoding */
+      if ((enc != null) && (enc.length() > 0))
+        new String(new byte[0], enc);
+
+      this.encoding = enc;
+    }
+    catch (Exception _)
+    {
+    }
+
+    if (out != null)
+    {
+      try
+      {
+        changeWriter(out, getEncoding());
+      }
+      catch (UnsupportedEncodingException uex)
+      {
+	/* This should never happen, since the validity of the encoding
+	 * name has been checked above.
+	 */
+	throw new RuntimeException(uex.getMessage());
+      }
+    }
+  }
+
+
+  private void checkOpen()
+  {
+    if (streamState == STATE_CLOSED)
+      throw new IllegalStateException(this.toString() + " has been closed");
+  }
+
+  private void checkFresh()
+  {
+    checkOpen();
+    if (streamState != STATE_FRESH)
+      throw new IllegalStateException("some log records have been published to " + this);
+  }
+
+
+  private void changeWriter(OutputStream out, String encoding)
+    throws UnsupportedEncodingException
+  {
+    OutputStreamWriter writer;
+
+    /* The logging API says that a null encoding means the default
+     * platform encoding. However, java.io.OutputStreamWriter needs
+     * another constructor for the default platform encoding,
+     * passing null would throw an exception.
+     */
+    if (encoding == null)
+      writer = new OutputStreamWriter(out);
+    else
+      writer = new OutputStreamWriter(out, encoding);
+
+    /* Closing the stream has side effects -- do this only after
+     * creating a new writer has been successful.
+     */
+    if ((streamState != STATE_FRESH) || (this.writer != null))
+      close();
+
+    this.writer = writer;
+    this.out = out;
+    this.encoding = encoding;
+    streamState = STATE_FRESH;
+  }
+
+
+  /**
+   * Sets the character encoding which this handler uses for publishing
+   * log records.  The encoding of a <code>StreamHandler</code> must be
+   * set before any log records have been published.
+   *
+   * @param encoding the name of a character encoding, or <code>null</code>
+   *            for the default encoding.
+   *
+   * @throws SecurityException if a security manager exists and
+   *     the caller is not granted the permission to control the
+   *     the logging infrastructure.
+   *
+   * @exception IllegalStateException if any log records have been
+   *     published to this <code>StreamHandler</code> before.  Please
+   *     be aware that this is a pecularity of the GNU implementation.
+   *     While the API specification indicates that it is an error
+   *     if the encoding is set after records have been published,
+   *     it does not mandate any specific behavior for that case.
+   */
+  public void setEncoding(String encoding)
+    throws SecurityException, UnsupportedEncodingException
+  {
+    /* The inherited implementation first checks whether the invoking
+     * code indeed has the permission to control the logging infra-
+     * structure, and throws a SecurityException if this was not the
+     * case.
+     *
+     * Next, it verifies that the encoding is supported and throws
+     * an UnsupportedEncodingExcpetion otherwise. Finally, it remembers
+     * the name of the encoding.
+     */
+    super.setEncoding(encoding);
+
+    checkFresh();
+
+    /* If out is null, setEncoding is being called before an output
+     * stream has been set. In that case, we need to check that the
+     * encoding is valid, and remember it if this is the case.  Since
+     * this is exactly what the inherited implementation of
+     * Handler.setEncoding does, we can delegate.
+     */
+    if (out != null)
+    {
+      /* The logging API says that a null encoding means the default
+       * platform encoding. However, java.io.OutputStreamWriter needs
+       * another constructor for the default platform encoding, passing
+       * null would throw an exception.
+       */
+      if (encoding == null)
+	writer = new OutputStreamWriter(out);
+      else
+	writer = new OutputStreamWriter(out, encoding);
+    }
+  }
+
+
+  /**
+   * Changes the output stream to which this handler publishes
+   * logging records.
+   *
+   * @throws SecurityException if a security manager exists and
+   *         the caller is not granted the permission to control
+   *         the logging infrastructure.
+   *
+   * @throws NullPointerException if <code>out</code>
+   *         is <code>null</code>.
+   */
+  protected void setOutputStream(OutputStream out)
+    throws SecurityException
+  {
+    LogManager.getLogManager().checkAccess();
+
+    /* Throw a NullPointerException if out is null. */
+    out.getClass();
+
+    try
+    {
+      changeWriter(out, getEncoding());
+    }
+    catch (UnsupportedEncodingException ex)
+    {
+      /* This seems quite unlikely to happen, unless the underlying
+       * implementation of java.io.OutputStreamWriter changes its
+       * mind (at runtime) about the set of supported character
+       * encodings.
+       */
+      throw new RuntimeException(ex.getMessage());
+    }
+  }
+
+
+  /**
+   * Publishes a <code>LogRecord</code> to the associated output
+   * stream, provided the record passes all tests for being loggable.
+   * The <code>StreamHandler</code> will localize the message of the
+   * log record and substitute any message parameters.
+   *
+   * <p>Most applications do not need to call this method directly.
+   * Instead, they will use use a {@link Logger}, which will create
+   * LogRecords and distribute them to registered handlers.
+   *
+   * <p>In case of an I/O failure, the <code>ErrorManager</code>
+   * of this <code>Handler</code> will be informed, but the caller
+   * of this method will not receive an exception.
+   *
+   * <p>If a log record is being published to a
+   * <code>StreamHandler</code> that has been closed earlier, the Sun
+   * J2SE 1.4 reference can be observed to silently ignore the
+   * call. The GNU implementation, however, intentionally behaves
+   * differently by informing the <code>ErrorManager</code> associated
+   * with this <code>StreamHandler</code>.  Since the condition
+   * indicates a programming error, the programmer should be
+   * informed. It also seems extremely unlikely that any application
+   * would depend on the exact behavior in this rather obscure,
+   * erroneous case -- especially since the API specification does not
+   * prescribe what is supposed to happen.
+   * 
+   * @param record the log event to be published.
+   */
+  public void publish(LogRecord record)
+  {
+    String formattedMessage;
+
+    if (!isLoggable(record))
+      return;
+
+    if (streamState == STATE_FRESH)
+    {
+      try
+      {
+        writer.write(formatter.getHead(this));
+      }
+      catch (java.io.IOException ex)
+      {
+	reportError(null, ex, ErrorManager.WRITE_FAILURE);
+	return;
+      }
+      catch (Exception ex)
+      {
+	reportError(null, ex, ErrorManager.GENERIC_FAILURE);
+	return;
+      }
+
+      streamState = STATE_PUBLISHED;
+    }
+
+    try
+    {
+      formattedMessage = formatter.format(record);
+    }
+    catch (Exception ex)
+    {
+      reportError(null, ex, ErrorManager.FORMAT_FAILURE);
+      return;
+    }
+
+    try
+    {
+      writer.write(formattedMessage);
+    }
+    catch (Exception ex)
+    {
+      reportError(null, ex, ErrorManager.WRITE_FAILURE);
+    }
+  }
+
+
+  /**
+   * Checks whether or not a <code>LogRecord</code> would be logged
+   * if it was passed to this <code>StreamHandler</code> for publication.
+   *
+   * <p>The <code>StreamHandler</code> implementation first checks
+   * whether a writer is present and the handler's level is greater
+   * than or equal to the severity level threshold.  In a second step,
+   * if a {@link Filter} has been installed, its {@link
+   * Filter#isLoggable(LogRecord) isLoggable} method is
+   * invoked. Subclasses of <code>StreamHandler</code> can override
+   * this method to impose their own constraints.
+   *
+   * @param record the <code>LogRecord</code> to be checked.
+   *
+   * @return <code>true</code> if <code>record</code> would
+   *         be published by {@link #publish(LogRecord) publish},
+   *         <code>false</code> if it would be discarded.
+   *
+   * @see #setLevel(Level)
+   * @see #setFilter(Filter)
+   * @see Filter#isLoggable(LogRecord)
+   *
+   * @throws NullPointerException if <code>record</code> is
+   *         <code>null</code>.  */
+  public boolean isLoggable(LogRecord record)
+  {
+    return (writer != null) && super.isLoggable(record);
+  }
+
+
+  /**
+   * Forces any data that may have been buffered to the underlying
+   * output device.
+   *
+   * <p>In case of an I/O failure, the <code>ErrorManager</code>
+   * of this <code>Handler</code> will be informed, but the caller
+   * of this method will not receive an exception.
+   *
+   * <p>If a <code>StreamHandler</code> that has been closed earlier
+   * is closed a second time, the Sun J2SE 1.4 reference can be
+   * observed to silently ignore the call. The GNU implementation,
+   * however, intentionally behaves differently by informing the
+   * <code>ErrorManager</code> associated with this
+   * <code>StreamHandler</code>.  Since the condition indicates a
+   * programming error, the programmer should be informed. It also
+   * seems extremely unlikely that any application would depend on the
+   * exact behavior in this rather obscure, erroneous case --
+   * especially since the API specification does not prescribe what is
+   * supposed to happen.
+   */
+  public void flush()
+  {
+    try
+    {
+      checkOpen();
+      if (writer != null)
+        writer.flush();
+    }
+    catch (Exception ex)
+    {
+      reportError(null, ex, ErrorManager.FLUSH_FAILURE);
+    }
+  }
+
+
+  /**
+   * Closes this <code>StreamHandler</code> after having forced any
+   * data that may have been buffered to the underlying output
+   * device. 
+   *
+   * <p>As soon as <code>close</code> has been called,
+   * a <code>Handler</code> should not be used anymore. Attempts
+   * to publish log records, to flush buffers, or to modify the
+   * <code>Handler</code> in any other way may throw runtime
+   * exceptions after calling <code>close</code>.</p>
+   *
+   * <p>In case of an I/O failure, the <code>ErrorManager</code>
+   * of this <code>Handler</code> will be informed, but the caller
+   * of this method will not receive an exception.</p>
+   *
+   * <p>If a <code>StreamHandler</code> that has been closed earlier
+   * is closed a second time, the Sun J2SE 1.4 reference can be
+   * observed to silently ignore the call. The GNU implementation,
+   * however, intentionally behaves differently by informing the
+   * <code>ErrorManager</code> associated with this
+   * <code>StreamHandler</code>.  Since the condition indicates a
+   * programming error, the programmer should be informed. It also
+   * seems extremely unlikely that any application would depend on the
+   * exact behavior in this rather obscure, erroneous case --
+   * especially since the API specification does not prescribe what is
+   * supposed to happen.
+   *
+   * @throws SecurityException if a security manager exists and
+   *         the caller is not granted the permission to control
+   *         the logging infrastructure.
+   */
+  public void close()
+    throws SecurityException
+  {
+    LogManager.getLogManager().checkAccess();
+
+    try
+    {
+      /* Although  flush also calls checkOpen, it catches
+       * any exceptions and reports them to the ErrorManager
+       * as flush failures.  However, we want to report
+       * a closed stream as a close failure, not as a
+       * flush failure here.  Therefore, we call checkOpen()
+       * before flush().
+       */
+      checkOpen();
+      flush();
+
+      if (writer != null)
+      {
+	if (formatter != null)
+	{
+	  /* Even if the StreamHandler has never published a record,
+	   * it emits head and tail upon closing. An earlier version
+	   * of the GNU Classpath implementation did not emitted
+	   * anything. However, this had caused XML log files to be
+	   * entirely empty instead of containing no log records.
+	   */
+	  if (streamState == STATE_FRESH)
+            writer.write(formatter.getHead(this));
+	  if (streamState != STATE_CLOSED)
+	    writer.write(formatter.getTail(this));
+	}
+	streamState = STATE_CLOSED;
+        writer.close();
+      }
+    }
+    catch (Exception ex)
+    {
+      reportError(null, ex, ErrorManager.CLOSE_FAILURE);
+    }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/XMLFormatter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/XMLFormatter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/XMLFormatter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/XMLFormatter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,387 @@
+/* XMLFormatter.java --
+   A class for formatting log messages into a standard XML format
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.logging;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.ResourceBundle;
+
+/**
+ * An <code>XMLFormatter</code> formats LogRecords into
+ * a standard XML format.
+ *
+ * @author Sascha Brawer (brawer at acm.org)
+ */
+public class XMLFormatter
+  extends Formatter
+{
+  /**
+   * Constructs a new XMLFormatter.
+   */
+  public XMLFormatter()
+  {
+  }
+
+
+  /**
+   * The character sequence that is used to separate lines in the
+   * generated XML stream. Somewhat surprisingly, the Sun J2SE 1.4
+   * reference implementation always uses UNIX line endings, even on
+   * platforms that have different line ending conventions (i.e.,
+   * DOS). The GNU Classpath implementation does not replicates this
+   * bug.
+   *
+   * See also the Sun bug parade, bug #4462871,
+   * "java.util.logging.SimpleFormatter uses hard-coded line separator".
+   */
+  private static final String lineSep = SimpleFormatter.lineSep;
+
+    
+  /**
+   * A DateFormat for emitting time in the ISO 8601 format.
+   * Since the API specification of SimpleDateFormat does not talk
+   * about its thread-safety, we cannot share a singleton instance.
+   */
+  private final SimpleDateFormat iso8601
+    = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+
+
+  /**
+   * Appends a line consisting of indentation, opening element tag,
+   * element content, closing element tag and line separator to
+   * a StringBuffer, provided that the element content is
+   * actually existing.
+   *
+   * @param buf the StringBuffer to which the line will be appended.
+   *
+   * @param indent the indentation level.
+   *
+   * @param tag the element tag name, for instance <code>method</code>.
+   *
+   * @param content the element content, or <code>null</code> to
+   *        have no output whatsoever appended to <code>buf</code>.
+   */
+  private static void appendTag(StringBuffer buf, int indent,
+                                String tag, String content)
+  {
+    int i;
+
+    if (content == null)
+      return;
+
+    for (i = 0; i < indent * 2; i++)
+      buf.append(' ');
+
+    buf.append("<");
+    buf.append(tag);
+    buf.append('>');
+
+    /* Append the content, but escape for XML by replacing
+     * '&', '<', '>' and all non-ASCII characters with
+     * appropriate escape sequences.
+     * The Sun J2SE 1.4 reference implementation does not
+     * escape non-ASCII characters. This is a bug in their
+     * implementation which has been reported in the Java
+     * bug parade as bug number (FIXME: Insert number here).
+     */
+    for (i = 0; i < content.length(); i++)
+    {
+      char c = content.charAt(i);
+      switch (c)
+      {
+      case '&':
+	buf.append("&");
+	break;
+
+      case '<':
+	buf.append("<");
+	break;
+
+      case '>':
+	buf.append(">");
+	break;
+
+      default:
+	if (((c >= 0x20) && (c <= 0x7e))
+	    || (c == /* line feed */ 10)
+	    || (c == /* carriage return */ 13))
+	  buf.append(c);
+	else
+	{
+	  buf.append("&#");
+	  buf.append((int) c);
+	  buf.append(';');
+	}
+	break;
+      } /* switch (c) */
+    } /* for i */
+
+    buf.append("</");
+    buf.append(tag);
+    buf.append(">");
+    buf.append(lineSep);
+  }
+
+
+  /**
+   * Appends a line consisting of indentation, opening element tag,
+   * numeric element content, closing element tag and line separator
+   * to a StringBuffer.
+   *
+   * @param buf the StringBuffer to which the line will be appended.
+   *
+   * @param indent the indentation level.
+   *
+   * @param tag the element tag name, for instance <code>method</code>.
+   *
+   * @param content the element content.
+   */
+  private static void appendTag(StringBuffer buf, int indent,
+                                String tag, long content)
+  {
+    appendTag(buf, indent, tag, Long.toString(content));
+  }
+
+
+  public String format(LogRecord record)
+  {
+    StringBuffer    buf = new StringBuffer(400);
+    Level           level = record.getLevel();
+    long            millis = record.getMillis();
+    Object[]        params = record.getParameters();
+    ResourceBundle  bundle = record.getResourceBundle();
+    String          message;
+    
+    buf.append("<record>");
+    buf.append(lineSep);
+    
+    
+    appendTag(buf, 1, "date", iso8601.format(new Date(millis)));
+    appendTag(buf, 1, "millis", millis);
+    appendTag(buf, 1, "sequence", record.getSequenceNumber());
+    appendTag(buf, 1, "logger", record.getLoggerName());
+
+    if (level.isStandardLevel())
+      appendTag(buf, 1, "level", level.toString());
+    else
+      appendTag(buf, 1, "level", level.intValue());
+
+    appendTag(buf, 1, "class", record.getSourceClassName());
+    appendTag(buf, 1, "method", record.getSourceMethodName());
+    appendTag(buf, 1, "thread", record.getThreadID());
+
+    /* The Sun J2SE 1.4 reference implementation does not emit the
+     * message in localized form. This is in violation of the API
+     * specification. The GNU Classpath implementation intentionally
+     * replicates the buggy behavior of the Sun implementation, as
+     * different log files might be a big nuisance to users.
+     */
+    try
+    {
+      record.setResourceBundle(null);
+      message = formatMessage(record);
+    }
+    finally
+    {
+      record.setResourceBundle(bundle);
+    }
+    appendTag(buf, 1, "message", message);
+
+    /* The Sun J2SE 1.4 reference implementation does not
+     * emit key, catalog and param tags. This is in violation
+     * of the API specification.  The Classpath implementation
+     * intentionally replicates the buggy behavior of the
+     * Sun implementation, as different log files might be
+     * a big nuisance to users.
+     *
+     * FIXME: File a bug report with Sun. Insert bug number here.
+     *
+     *
+     * key = record.getMessage();
+     * if (key == null)
+     *   key = "";
+     *
+     * if ((bundle != null) && !key.equals(message))
+     * {
+     *   appendTag(buf, 1, "key", key);
+     *   appendTag(buf, 1, "catalog", record.getResourceBundleName());
+     * }
+     *
+     * if (params != null)
+     * {
+     *   for (int i = 0; i < params.length; i++)
+     *     appendTag(buf, 1, "param", params[i].toString());
+     * }
+     */
+
+    /* FIXME: We have no way to obtain the stacktrace before free JVMs
+     * support the corresponding method in java.lang.Throwable.  Well,
+     * it would be possible to parse the output of printStackTrace,
+     * but this would be pretty kludgy. Instead, we postpose the
+     * implementation until Throwable has made progress.
+     */
+    Throwable thrown = record.getThrown();
+    if (thrown != null)
+    {
+      buf.append("  <exception>");
+      buf.append(lineSep);
+
+      /* The API specification is not clear about what exactly
+       * goes into the XML record for a thrown exception: It
+       * could be the result of getMessage(), getLocalizedMessage(),
+       * or toString(). Therefore, it was necessary to write a
+       * Mauve testlet and run it with the Sun J2SE 1.4 reference
+       * implementation. It turned out that the we need to call
+       * toString().
+       *
+       * FIXME: File a bug report with Sun, asking for clearer
+       * specs.
+       */
+      appendTag(buf, 2, "message", thrown.toString());
+
+      /* FIXME: The Logging DTD specifies:
+       *
+       * <!ELEMENT exception (message?, frame+)>
+       *
+       * However, java.lang.Throwable.getStackTrace() is
+       * allowed to return an empty array. So, what frame should
+       * be emitted for an empty stack trace? We probably
+       * should file a bug report with Sun, asking for the DTD
+       * to be changed.
+       */
+
+      buf.append("  </exception>");
+      buf.append(lineSep);
+    }
+
+
+    buf.append("</record>");
+    buf.append(lineSep);
+
+    return buf.toString();
+  }
+
+
+  /**
+   * Returns a string that handlers are supposed to emit before
+   * the first log record.  The base implementation returns an
+   * empty string, but subclasses such as {@link XMLFormatter}
+   * override this method in order to provide a suitable header.
+   *
+   * @return a string for the header.
+   *
+   * @param h the handler which will prepend the returned
+   *     string in front of the first log record.  This method
+   *     will inspect certain properties of the handler, for
+   *     example its encoding, in order to construct the header.
+   */
+  public String getHead(Handler h)
+  {
+    StringBuffer  buf;
+    String        encoding;
+
+    buf = new StringBuffer(80);
+    buf.append("<?xml version=\"1.0\" encoding=\"");
+
+    encoding = h.getEncoding();
+
+    /* file.encoding is a system property with the Sun JVM, indicating
+     * the platform-default file encoding. Unfortunately, the API
+     * specification for java.lang.System.getProperties() does not
+     * list this property.
+     */
+    if (encoding == null)
+      encoding = System.getProperty("file.encoding");
+
+    /* Since file.encoding is not listed with the API specification of
+     * java.lang.System.getProperties(), there might be some VMs that
+     * do not define this system property.  Therefore, we use UTF-8 as
+     * a reasonable default. Please note that if the platform encoding
+     * uses the same codepoints as US-ASCII for the US-ASCII character
+     * set (e.g, 65 for A), it does not matter whether we emit the
+     * wrong encoding into the XML header -- the GNU Classpath will
+     * emit XML escape sequences like Ӓ for any non-ASCII
+     * character.  Virtually all character encodings use the same code
+     * points as US-ASCII for ASCII characters.  Probably, EBCDIC is
+     * the only exception.
+     */
+    if (encoding == null)
+      encoding = "UTF-8";
+    
+    /* On Windows XP localized for Swiss German (this is one of
+     * my [Sascha Brawer's] test machines), the default encoding
+     * has the canonical name "windows-1252". The "historical" name
+     * of this encoding is "Cp1252" (see the Javadoc for the class
+     * java.nio.charset.Charset for the distinction). Now, that class
+     * does have a method for mapping historical to canonical encoding
+     * names. However, if we used it here, we would be come dependent
+     * on java.nio.*, which was only introduced with J2SE 1.4.
+     * Thus, we do this little hack here. As soon as Classpath supports
+     * java.nio.charset.CharSet, this hack should be replaced by
+     * code that correctly canonicalizes the encoding name.
+     */
+    if ((encoding.length() > 2) && encoding.startsWith("Cp"))
+      encoding = "windows-" + encoding.substring(2);
+
+    buf.append(encoding);
+
+    buf.append("\" standalone=\"no\"?>");
+    buf.append(lineSep);
+
+    /* SYSTEM is not a fully qualified URL so that validating
+     * XML parsers do not need to connect to the Internet in
+     * order to read in a log file.  See also the Sun Bug Parade,
+     * bug #4372790, "Logging APIs: need to use relative URL for XML
+     * doctype".
+     */
+    buf.append("<!DOCTYPE log SYSTEM \"logger.dtd\">");
+    buf.append(lineSep);
+    buf.append("<log>");
+    buf.append(lineSep);
+
+    return buf.toString();
+  }
+
+
+  public String getTail(Handler h)
+  {
+    return "</log>" + lineSep;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/logging/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.util.logging package.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.util.logging</title></head>
+
+<body>
+<p>Utility classes for logging events.</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.util package.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.util</title></head>
+
+<body>
+<p>Utility classes such as collections (maps, sets, lists, dictionaries and
+stacks), calendars, dates, locales, properties, timers, resource bundles and
+event objects.</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/AbstractPreferences.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/AbstractPreferences.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/AbstractPreferences.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/AbstractPreferences.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1384 @@
+/* AbstractPreferences -- Partial implementation of a Preference node
+   Copyright (C) 2001, 2003, 2004, 2006  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.prefs;
+
+import gnu.java.util.prefs.EventDispatcher;
+import gnu.java.util.prefs.NodeWriter;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.TreeSet;
+
+/**
+ * Partial implementation of a Preference node.
+ *
+ * @since 1.4
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+public abstract class AbstractPreferences extends Preferences {
+
+    // protected fields
+
+    /**
+     * Object used to lock this preference node. Any thread only locks nodes
+     * downwards when it has the lock on the current node. No method should
+     * synchronize on the lock of any of its parent nodes while holding the
+     * lock on the current node.
+     */
+    protected final Object lock = new Object();
+
+    /**
+     * Set to true in the contructor if the node did not exist in the backing
+     * store when this preference node object was created. Should be set in
+     * the constructor of a subclass. Defaults to false. Used to fire node
+     * changed events.
+     */
+    protected boolean newNode = false;
+
+    // private fields
+
+    /**
+     * The parent preferences node or null when this is the root node.
+     */
+    private final AbstractPreferences parent;
+
+    /**
+     * The name of this node.
+     * Only when this is a root node (parent == null) the name is empty.
+     * It has a maximum of 80 characters and cannot contain any '/' characters.
+     */
+    private final String name;
+
+    /** True when this node has been remove, false otherwise. */
+    private boolean removed = false;
+
+    /**
+     * Holds all the child names and nodes of this node that have been
+     * accessed by earlier <code>getChild()</code> or <code>childSpi()</code>
+     * invocations and that have not been removed.
+     */
+    private HashMap childCache = new HashMap();
+
+    /**
+     * A list of all the registered NodeChangeListener objects.
+     */
+    private ArrayList nodeListeners;
+
+    /**
+     * A list of all the registered PreferenceChangeListener objects.
+     */
+    private ArrayList preferenceListeners;
+
+    // constructor
+
+    /**
+     * Creates a new AbstractPreferences node with the given parent and name.
+     * 
+     * @param parent the parent of this node or null when this is the root node
+     * @param name the name of this node, can not be null, only 80 characters
+     *             maximum, must be empty when parent is null and cannot
+     *             contain any '/' characters
+     * @exception IllegalArgumentException when name is null, greater then 80
+     *            characters, not the empty string but parent is null or
+     *            contains a '/' character
+     */
+    protected AbstractPreferences(AbstractPreferences parent, String name) {
+        if (  (name == null)                            // name should be given
+           || (name.length() > MAX_NAME_LENGTH)         // 80 characters max
+           || (parent == null && name.length() != 0)    // root has no name
+           || (parent != null && name.length() == 0)    // all other nodes do
+           || (name.indexOf('/') != -1))                // must not contain '/'
+            throw new IllegalArgumentException("Illegal name argument '"
+                                               + name
+                                               + "' (parent is "
+                                               + (parent == null ? "" : "not ")
+                                               + "null)");
+        this.parent = parent;
+        this.name = name;
+    }
+
+    // identification methods
+
+    /**
+     * Returns the absolute path name of this preference node.
+     * The absolute path name of a node is the path name of its parent node
+     * plus a '/' plus its own name. If the node is the root node and has no
+     * parent then its path name is "" and its absolute path name is "/".
+     */
+    public String absolutePath() {
+        if (parent == null)
+            return "/";
+        else
+            return parent.path() + '/' + name;
+    }
+
+    /**
+     * Private helper method for absolutePath. Returns the empty string for a
+     * root node and otherwise the parentPath of its parent plus a '/'.
+     */
+    private String path() {
+        if (parent == null)
+            return "";
+        else
+            return parent.path() + '/' + name;
+    }
+
+    /**
+     * Returns true if this node comes from the user preferences tree, false
+     * if it comes from the system preferences tree.
+     */
+    public boolean isUserNode() {
+        AbstractPreferences root = this;
+	while (root.parent != null)
+	    root = root.parent;
+	return root == Preferences.userRoot();
+    }
+
+    /**
+     * Returns the name of this preferences node. The name of the node cannot
+     * be null, can be mostly 80 characters and cannot contain any '/'
+     * characters. The root node has as name "".
+     */
+    public String name() {
+        return name;
+    }
+
+    /**
+     * Returns the String given by
+     * <code>
+     * (isUserNode() ? "User":"System") + " Preference Node: " + absolutePath()
+     * </code>
+     */
+    public String toString() {
+        return (isUserNode() ? "User":"System")
+               + " Preference Node: "
+               + absolutePath();
+    }
+
+    /**
+     * Returns all known unremoved children of this node.
+     *
+     * @return All known unremoved children of this node
+     */
+    protected final AbstractPreferences[] cachedChildren()
+    {
+      return (AbstractPreferences[]) childCache.values().toArray();
+    }
+
+    /**
+     * Returns all the direct sub nodes of this preferences node.
+     * Needs access to the backing store to give a meaningfull answer.
+     * <p>
+     * This implementation locks this node, checks if the node has not yet
+     * been removed and throws an <code>IllegalStateException</code> when it
+     * has been. Then it creates a new <code>TreeSet</code> and adds any
+     * already cached child nodes names. To get any uncached names it calls
+     * <code>childrenNamesSpi()</code> and adds the result to the set. Finally
+     * it calls <code>toArray()</code> on the created set. When the call to
+     * <code>childrenNamesSpi</code> thows an <code>BackingStoreException</code>
+     * this method will not catch that exception but propagate the exception
+     * to the caller.
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     * @exception IllegalStateException when this node has been removed
+     */
+    public String[] childrenNames() throws BackingStoreException {
+        synchronized(lock) {
+            if (isRemoved())
+                throw new IllegalStateException("Node removed");
+
+            TreeSet childrenNames = new TreeSet();
+
+            // First get all cached node names
+            childrenNames.addAll(childCache.keySet());
+            
+            // Then add any others
+            String names[] = childrenNamesSpi();
+            for (int i = 0; i < names.length; i++) {
+                childrenNames.add(names[i]);
+            }
+
+            // And return the array of names
+            String[] children = new String[childrenNames.size()];
+            childrenNames.toArray(children);
+            return children;
+
+        }
+    }
+
+    /**
+     * Returns a sub node of this preferences node if the given path is
+     * relative (does not start with a '/') or a sub node of the root
+     * if the path is absolute (does start with a '/').
+     * <p>
+     * This method first locks this node and checks if the node has not been
+     * removed, if it has been removed it throws an exception. Then if the
+     * path is relative (does not start with a '/') it checks if the path is
+     * legal (does not end with a '/' and has no consecutive '/' characters).
+     * Then it recursively gets a name from the path, gets the child node
+     * from the child-cache of this node or calls the <code>childSpi()</code>
+     * method to create a new child sub node. This is done recursively on the
+     * newly created sub node with the rest of the path till the path is empty.
+     * If the path is absolute (starts with a '/') the lock on this node is
+     * droped and this method is called on the root of the preferences tree
+     * with as argument the complete path minus the first '/'.
+     *
+     * @exception IllegalStateException if this node has been removed
+     * @exception IllegalArgumentException if the path contains two or more
+     * consecutive '/' characters, ends with a '/' charactor and is not the
+     * string "/" (indicating the root node) or any name on the path is more
+     * than 80 characters long
+     */
+    public Preferences node(String path) {
+        synchronized(lock) {
+            if (isRemoved())
+                throw new IllegalStateException("Node removed");
+
+            // Is it a relative path?
+            if (!path.startsWith("/")) {
+
+                // Check if it is a valid path
+                if (path.indexOf("//") != -1 || path.endsWith("/"))
+                    throw new IllegalArgumentException(path);
+
+                return getNode(path);
+            }
+        }
+
+        // path started with a '/' so it is absolute
+        // we drop the lock and start from the root (omitting the first '/')
+        Preferences root = isUserNode() ? userRoot() : systemRoot();
+        return root.node(path.substring(1));
+
+    }
+
+    /**
+     * Private helper method for <code>node()</code>. Called with this node
+     * locked. Returns this node when path is the empty string, if it is not
+     * empty the next node name is taken from the path (all chars till the
+     * next '/' or end of path string) and the node is either taken from the
+     * child-cache of this node or the <code>childSpi()</code> method is called
+     * on this node with the name as argument. Then this method is called
+     * recursively on the just constructed child node with the rest of the
+     * path.
+     *
+     * @param path should not end with a '/' character and should not contain
+     *        consecutive '/' characters
+     * @exception IllegalArgumentException if path begins with a name that is
+     *            larger then 80 characters.
+     */
+    private Preferences getNode(String path) {
+        // if mark is dom then goto end
+
+        // Empty String "" indicates this node
+        if (path.length() == 0)
+            return this;
+
+        // Calculate child name and rest of path
+        String childName;
+        String childPath;
+        int nextSlash = path.indexOf('/');
+        if (nextSlash == -1) {
+            childName = path;
+            childPath = "";
+        } else {
+            childName = path.substring(0, nextSlash);
+            childPath = path.substring(nextSlash+1);
+        }
+
+        // Get the child node
+        AbstractPreferences child;
+        child = (AbstractPreferences)childCache.get(childName);
+        if (child == null) {
+
+            if (childName.length() > MAX_NAME_LENGTH)
+               throw new IllegalArgumentException(childName); 
+
+            // Not in childCache yet so create a new sub node
+            child = childSpi(childName);
+            childCache.put(childName, child);
+            if (child.newNode && nodeListeners != null)
+              fire(new NodeChangeEvent(this, child), true);
+        }
+
+        // Lock the child and go down
+        synchronized(child.lock) {
+            return child.getNode(childPath);
+        }
+    }
+
+    /**
+     * Returns true if the node that the path points to exists in memory or
+     * in the backing store. Otherwise it returns false or an exception is
+     * thrown. When this node is removed the only valid parameter is the
+     * empty string (indicating this node), the return value in that case
+     * will be false.
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     * @exception IllegalStateException if this node has been removed
+     *            and the path is not the empty string (indicating this node)
+     * @exception IllegalArgumentException if the path contains two or more
+     * consecutive '/' characters, ends with a '/' charactor and is not the
+     * string "/" (indicating the root node) or any name on the path is more
+     * then 80 characters long
+     */
+    public boolean nodeExists(String path) throws BackingStoreException {
+        synchronized(lock) {
+            if (isRemoved() && path.length() != 0)
+                throw new IllegalStateException("Node removed");
+
+            // Is it a relative path?
+            if (!path.startsWith("/")) {
+
+                // Check if it is a valid path
+                if (path.indexOf("//") != -1 || path.endsWith("/"))
+                    throw new IllegalArgumentException(path);
+
+                return existsNode(path);
+            }
+        }
+
+        // path started with a '/' so it is absolute
+        // we drop the lock and start from the root (omitting the first '/')
+        Preferences root = isUserNode() ? userRoot() : systemRoot();
+        return root.nodeExists(path.substring(1));
+
+    }
+
+    private boolean existsNode(String path) throws BackingStoreException {
+
+        // Empty String "" indicates this node
+        if (path.length() == 0)
+            return(!isRemoved());
+
+        // Calculate child name and rest of path
+        String childName;
+        String childPath;
+        int nextSlash = path.indexOf('/');
+        if (nextSlash == -1) {
+            childName = path;
+            childPath = "";
+        } else {
+            childName = path.substring(0, nextSlash);
+            childPath = path.substring(nextSlash+1);
+        }
+
+        // Get the child node
+        AbstractPreferences child;
+        child = (AbstractPreferences)childCache.get(childName);
+        if (child == null) {
+
+            if (childName.length() > MAX_NAME_LENGTH)
+               throw new IllegalArgumentException(childName);
+
+            // Not in childCache yet so create a new sub node
+            child = getChild(childName);
+
+            if (child == null)
+                return false;
+
+            childCache.put(childName, child);
+        }
+
+        // Lock the child and go down
+        synchronized(child.lock) {
+            return child.existsNode(childPath);
+        }
+    }
+
+    /**
+     * Returns the child sub node if it exists in the backing store or null
+     * if it does not exist. Called (indirectly) by <code>nodeExists()</code>
+     * when a child node name can not be found in the cache.
+     * <p>
+     * Gets the lock on this node, calls <code>childrenNamesSpi()</code> to
+     * get an array of all (possibly uncached) children and compares the
+     * given name with the names in the array. If the name is found in the
+     * array <code>childSpi()</code> is called to get an instance, otherwise
+     * null is returned.
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     */
+    protected AbstractPreferences getChild(String name)
+                                    throws BackingStoreException
+    {
+        synchronized(lock) {
+            // Get all the names (not yet in the cache)
+            String[] names = childrenNamesSpi();
+            for (int i=0; i < names.length; i++)
+                if (name.equals(names[i]))
+                    return childSpi(name);
+           
+            // No child with that name found
+            return null;
+        }
+    }
+
+    /**
+     * Returns true if this node has been removed with the
+     * <code>removeNode()</code> method, false otherwise.
+     * <p>
+     * Gets the lock on this node and then returns a boolean field set by
+     * <code>removeNode</code> methods.
+     */
+    protected boolean isRemoved() {
+        synchronized(lock) {
+            return removed;
+        }
+    }
+
+    /**
+     * Returns the parent preferences node of this node or null if this is
+     * the root of the preferences tree.
+     * <p>
+     * Gets the lock on this node, checks that the node has not been removed
+     * and returns the parent given to the constructor.
+     *
+     * @exception IllegalStateException if this node has been removed
+     */
+    public Preferences parent() {
+        synchronized(lock) {
+            if (isRemoved())
+                throw new IllegalStateException("Node removed");
+
+            return parent;
+        }
+    }
+
+    // export methods
+
+    // Inherit javadoc.
+    public void exportNode(OutputStream os)
+                                    throws BackingStoreException,
+                                           IOException
+    {
+        NodeWriter nodeWriter = new NodeWriter(this, os);
+        nodeWriter.writePrefs();
+    }
+
+    // Inherit javadoc.
+    public void exportSubtree(OutputStream os)
+                                    throws BackingStoreException,
+                                           IOException
+    {
+        NodeWriter nodeWriter = new NodeWriter(this, os);
+        nodeWriter.writePrefsTree();
+    }
+
+    // preference entry manipulation methods
+
+    /**
+     * Returns an (possibly empty) array with all the keys of the preference
+     * entries of this node.
+     * <p>
+     * This method locks this node and checks if the node has not been
+     * removed, if it has been removed it throws an exception, then it returns
+     * the result of calling <code>keysSpi()</code>.
+     * 
+     * @exception BackingStoreException when the backing store cannot be     
+     *            reached
+     * @exception IllegalStateException if this node has been removed
+     */
+    public String[] keys() throws BackingStoreException {
+        synchronized(lock) {
+            if (isRemoved())
+                throw new IllegalStateException("Node removed");
+
+            return keysSpi();
+        }
+    }
+
+
+    /**
+     * Returns the value associated with the key in this preferences node. If
+     * the default value of the key cannot be found in the preferences node
+     * entries or something goes wrong with the backing store the supplied
+     * default value is returned.
+     * <p>
+     * Checks that key is not null and not larger then 80 characters,
+     * locks this node, and checks that the node has not been removed.
+     * Then it calls <code>keySpi()</code> and returns
+     * the result of that method or the given default value if it returned
+     * null or throwed an exception.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public String get(String key, String defaultVal) {
+        if (key.length() > MAX_KEY_LENGTH)
+            throw new IllegalArgumentException(key);
+
+        synchronized(lock) {
+            if (isRemoved())
+                throw new IllegalStateException("Node removed");
+
+            String value;
+            try {
+                value = getSpi(key);
+            } catch (ThreadDeath death) {
+                throw death;
+            } catch (Throwable t) {
+                value = null;
+            }
+
+            if (value != null) {
+                return value;
+            } else {
+                return defaultVal;
+            }
+        }
+    }
+
+    /**
+     * Convenience method for getting the given entry as a boolean.
+     * When the string representation of the requested entry is either
+     * "true" or "false" (ignoring case) then that value is returned,
+     * otherwise the given default boolean value is returned.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public boolean getBoolean(String key, boolean defaultVal) {
+        String value = get(key, null);
+
+        if ("true".equalsIgnoreCase(value))
+            return true;
+
+        if ("false".equalsIgnoreCase(value))
+            return false;
+        
+        return defaultVal;
+    }
+
+    /**
+     * Convenience method for getting the given entry as a byte array.
+     * When the string representation of the requested entry is a valid
+     * Base64 encoded string (without any other characters, such as newlines)
+     * then the decoded Base64 string is returned as byte array,
+     * otherwise the given default byte array value is returned.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public byte[] getByteArray(String key, byte[] defaultVal) {
+        String value = get(key, null);
+
+        byte[] b = null;
+        if (value != null) {
+            b = decode64(value);
+        }
+
+        if (b != null)
+            return b;
+        else
+            return defaultVal;
+    }
+    
+    /**
+     * Helper method for decoding a Base64 string as an byte array.
+     * Returns null on encoding error. This method does not allow any other
+     * characters present in the string then the 65 special base64 chars.
+     */
+    private static byte[] decode64(String s) {
+        ByteArrayOutputStream bs = new ByteArrayOutputStream((s.length()/4)*3);
+        char[] c = new char[s.length()];
+        s.getChars(0, s.length(), c, 0);
+
+        // Convert from base64 chars
+        int endchar = -1;
+        for(int j = 0; j < c.length && endchar == -1; j++) {
+            if (c[j] >= 'A' && c[j] <= 'Z') {
+                c[j] -= 'A';
+            } else if (c[j] >= 'a' && c[j] <= 'z') {
+                c[j] = (char) (c[j] + 26 - 'a');
+            } else if (c[j] >= '0' && c[j] <= '9') {
+                c[j] = (char) (c[j] + 52 - '0');
+            } else if (c[j] == '+') {
+                c[j] = 62;
+            } else if (c[j] == '/') {
+                c[j] = 63;
+            } else if (c[j] == '=') {
+                endchar = j;
+            } else {
+                return null; // encoding exception
+            }
+        }
+
+        int remaining = endchar == -1 ? c.length : endchar;
+        int i = 0;
+        while (remaining > 0) {
+            // Four input chars (6 bits) are decoded as three bytes as
+            // 000000 001111 111122 222222
+
+            byte b0 = (byte) (c[i] << 2);
+            if (remaining >= 2) {
+                b0 += (c[i+1] & 0x30) >> 4;
+            }
+            bs.write(b0);
+
+            if (remaining >= 3) {
+                byte b1 = (byte) ((c[i+1] & 0x0F) << 4);
+                b1 += (byte) ((c[i+2] & 0x3C) >> 2);
+                bs.write(b1);
+            }
+
+            if (remaining >= 4) {
+                byte b2 = (byte) ((c[i+2] & 0x03) << 6);
+                b2 += c[i+3];
+                bs.write(b2);
+            }
+
+            i += 4;
+            remaining -= 4;
+        }
+
+        return bs.toByteArray();
+    }
+
+    /**
+     * Convenience method for getting the given entry as a double.
+     * When the string representation of the requested entry can be decoded
+     * with <code>Double.parseDouble()</code> then that double is returned,
+     * otherwise the given default double value is returned.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public double getDouble(String key, double defaultVal) {
+        String value = get(key, null);
+
+        if (value != null) {
+            try {
+                return Double.parseDouble(value);
+            } catch (NumberFormatException nfe) { /* ignore */ }
+        }
+
+        return defaultVal;
+    }
+
+    /**
+     * Convenience method for getting the given entry as a float.
+     * When the string representation of the requested entry can be decoded
+     * with <code>Float.parseFloat()</code> then that float is returned,
+     * otherwise the given default float value is returned.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public float getFloat(String key, float defaultVal) {
+        String value = get(key, null);
+
+        if (value != null) {
+            try {
+                return Float.parseFloat(value);
+            } catch (NumberFormatException nfe) { /* ignore */ }
+        }
+
+        return defaultVal;
+    }
+
+    /**
+     * Convenience method for getting the given entry as an integer.
+     * When the string representation of the requested entry can be decoded
+     * with <code>Integer.parseInt()</code> then that integer is returned,
+     * otherwise the given default integer value is returned.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public int getInt(String key, int defaultVal) {
+        String value = get(key, null);
+
+        if (value != null) {
+            try {
+                return Integer.parseInt(value);
+            } catch (NumberFormatException nfe) { /* ignore */ }
+        }
+
+        return defaultVal;
+    }
+
+    /**
+     * Convenience method for getting the given entry as a long.
+     * When the string representation of the requested entry can be decoded
+     * with <code>Long.parseLong()</code> then that long is returned,
+     * otherwise the given default long value is returned.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public long getLong(String key, long defaultVal) {
+        String value = get(key, null);
+
+        if (value != null) {
+            try {
+                return Long.parseLong(value);
+            } catch (NumberFormatException nfe) { /* ignore */ }
+        }
+
+        return defaultVal;
+    }
+
+    /**
+     * Sets the value of the given preferences entry for this node.
+     * Key and value cannot be null, the key cannot exceed 80 characters
+     * and the value cannot exceed 8192 characters.
+     * <p>
+     * The result will be immediately visible in this VM, but may not be
+     * immediately written to the backing store.
+     * <p>
+     * Checks that key and value are valid, locks this node, and checks that
+     * the node has not been removed. Then it calls <code>putSpi()</code>.
+     *
+     * @exception NullPointerException if either key or value are null
+     * @exception IllegalArgumentException if either key or value are to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public void put(String key, String value) {
+        if (key.length() > MAX_KEY_LENGTH
+            || value.length() > MAX_VALUE_LENGTH)
+            throw new IllegalArgumentException("key ("
+                                               + key.length() + ")"
+                                               + " or value ("
+                                               + value.length() + ")"
+                                               + " to large");
+        synchronized(lock) {
+            if (isRemoved())
+                throw new IllegalStateException("Node removed");
+
+            putSpi(key, value);
+
+            if (preferenceListeners != null)
+              fire(new PreferenceChangeEvent(this, key, value));
+        }
+            
+    }
+
+    /**
+     * Convenience method for setting the given entry as a boolean.
+     * The boolean is converted with <code>Boolean.toString(value)</code>
+     * and then stored in the preference entry as that string.
+     *
+     * @exception NullPointerException if key is null
+     * @exception IllegalArgumentException if the key length is to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public void putBoolean(String key, boolean value) {
+        put(key, Boolean.toString(value));
+    }
+
+    /**
+     * Convenience method for setting the given entry as an array of bytes.
+     * The byte array is converted to a Base64 encoded string
+     * and then stored in the preference entry as that string.
+     * <p>
+     * Note that a byte array encoded as a Base64 string will be about 1.3
+     * times larger then the original length of the byte array, which means
+     * that the byte array may not be larger about 6 KB.
+     *
+     * @exception NullPointerException if either key or value are null
+     * @exception IllegalArgumentException if either key or value are to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public void putByteArray(String key, byte[] value) {
+        put(key, encode64(value));
+    }
+
+    /**
+     * Helper method for encoding an array of bytes as a Base64 String.
+     */
+    private static String encode64(byte[] b) {
+        StringBuffer sb = new StringBuffer((b.length/3)*4);
+
+        int i = 0;
+        int remaining = b.length;
+        char c[] = new char[4];
+        while (remaining > 0) {
+            // Three input bytes are encoded as four chars (6 bits) as
+            // 00000011 11112222 22333333
+
+            c[0] = (char) ((b[i] & 0xFC) >> 2);
+            c[1] = (char) ((b[i] & 0x03) << 4);
+            if (remaining >= 2) {
+                c[1] += (char) ((b[i+1] & 0xF0) >> 4);
+                c[2] = (char) ((b[i+1] & 0x0F) << 2);
+                if (remaining >= 3) {
+                    c[2] += (char) ((b[i+2] & 0xC0) >> 6);
+                    c[3] = (char) (b[i+2] & 0x3F);
+                } else {
+                    c[3] = 64;
+                }
+            } else {
+                c[2] = 64;
+                c[3] = 64;
+            }
+
+            // Convert to base64 chars
+            for(int j = 0; j < 4; j++) {
+                if (c[j] < 26) {
+                    c[j] += 'A';
+                } else if (c[j] < 52) {
+                    c[j] = (char) (c[j] - 26 + 'a');
+                } else if (c[j] < 62) {
+                    c[j] = (char) (c[j] - 52 + '0');
+                } else if (c[j] == 62) {
+                    c[j] = '+';
+                } else if (c[j] == 63) {
+                    c[j] = '/';
+                } else {
+                    c[j] = '=';
+                }
+            }
+
+            sb.append(c);
+            i += 3;
+            remaining -= 3;
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * Convenience method for setting the given entry as a double.
+     * The double is converted with <code>Double.toString(double)</code>
+     * and then stored in the preference entry as that string.
+     *
+     * @exception NullPointerException if the key is null
+     * @exception IllegalArgumentException if the key length is to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public void putDouble(String key, double value) {
+        put(key, Double.toString(value));
+    }
+
+    /**
+     * Convenience method for setting the given entry as a float.
+     * The float is converted with <code>Float.toString(float)</code>
+     * and then stored in the preference entry as that string.
+     *
+     * @exception NullPointerException if the key is null
+     * @exception IllegalArgumentException if the key length is to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public void putFloat(String key, float value) {
+        put(key, Float.toString(value));
+    }
+
+    /**
+     * Convenience method for setting the given entry as an integer.
+     * The integer is converted with <code>Integer.toString(int)</code>
+     * and then stored in the preference entry as that string.
+     *
+     * @exception NullPointerException if the key is null
+     * @exception IllegalArgumentException if the key length is to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public void putInt(String key, int value) {
+        put(key, Integer.toString(value));
+    }
+
+    /**
+     * Convenience method for setting the given entry as a long.
+     * The long is converted with <code>Long.toString(long)</code>
+     * and then stored in the preference entry as that string.
+     *
+     * @exception NullPointerException if the key is null
+     * @exception IllegalArgumentException if the key length is to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public void putLong(String key, long value) {
+        put(key, Long.toString(value));
+    }
+
+    /**
+     * Removes the preferences entry from this preferences node.
+     * <p>     
+     * The result will be immediately visible in this VM, but may not be
+     * immediately written to the backing store.
+     * <p>
+     * This implementation checks that the key is not larger then 80
+     * characters, gets the lock of this node, checks that the node has
+     * not been removed and calls <code>removeSpi</code> with the given key.
+     *
+     * @exception NullPointerException if the key is null
+     * @exception IllegalArgumentException if the key length is to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public void remove(String key) {
+        if (key.length() > MAX_KEY_LENGTH)
+            throw new IllegalArgumentException(key);
+
+        synchronized(lock) {
+            if (isRemoved())
+                throw new IllegalStateException("Node removed");
+
+            removeSpi(key);
+
+            if (preferenceListeners != null)
+              fire(new PreferenceChangeEvent(this, key, null));
+        }
+    }
+
+    /**
+     * Removes all entries from this preferences node. May need access to the
+     * backing store to get and clear all entries.
+     * <p>
+     * The result will be immediately visible in this VM, but may not be
+     * immediatly written to the backing store.
+     * <p>
+     * This implementation locks this node, checks that the node has not been
+     * removed and calls <code>keys()</code> to get a complete array of keys
+     * for this node. For every key found <code>removeSpi()</code> is called.
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     * @exception IllegalStateException if this node has been removed
+     */
+    public void clear() throws BackingStoreException {
+        synchronized(lock) {
+            if (isRemoved())
+                throw new IllegalStateException("Node Removed");
+
+            String[] keys = keys();
+            for (int i = 0; i < keys.length; i++) {
+                removeSpi(keys[i]);
+            }
+        }
+    }
+
+    /**
+     * Writes all preference changes on this and any subnode that have not
+     * yet been written to the backing store. This has no effect on the
+     * preference entries in this VM, but it makes sure that all changes
+     * are visible to other programs (other VMs might need to call the
+     * <code>sync()</code> method to actually see the changes to the backing
+     * store.
+     * <p>
+     * Locks this node, calls the <code>flushSpi()</code> method, gets all
+     * the (cached - already existing in this VM) subnodes and then calls
+     * <code>flushSpi()</code> on every subnode with this node unlocked and
+     * only that particular subnode locked.
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     */
+    public void flush() throws BackingStoreException {
+        flushNode(false);
+    }
+
+    /**
+     * Writes and reads all preference changes to and from this and any
+     * subnodes. This makes sure that all local changes are written to the
+     * backing store and that all changes to the backing store are visible
+     * in this preference node (and all subnodes).
+     * <p>
+     * Checks that this node is not removed, locks this node, calls the
+     * <code>syncSpi()</code> method, gets all the subnodes and then calls
+     * <code>syncSpi()</code> on every subnode with this node unlocked and
+     * only that particular subnode locked.
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     * @exception IllegalStateException if this node has been removed
+     */
+    public void sync() throws BackingStoreException {
+        flushNode(true);
+    }
+    
+
+    /**
+     * Private helper method that locks this node and calls either
+     * <code>flushSpi()</code> if <code>sync</code> is false, or
+     * <code>flushSpi()</code> if <code>sync</code> is true. Then it gets all
+     * the currently cached subnodes. For every subnode it calls this method
+     * recursively with this node no longer locked.
+     * <p>
+     * Called by either <code>flush()</code> or <code>sync()</code>
+     */
+    private void flushNode(boolean sync) throws BackingStoreException {
+        String[] keys = null;
+        synchronized(lock) {
+            if (sync) {
+                syncSpi();
+            } else {
+                flushSpi();
+            }
+            keys = (String[]) childCache.keySet().toArray(new String[]{});
+        }
+
+        if (keys != null) {
+            for (int i = 0; i < keys.length; i++) {
+                // Have to lock this node again to access the childCache
+                AbstractPreferences subNode;
+                synchronized(lock) {
+                    subNode = (AbstractPreferences) childCache.get(keys[i]);
+                }
+
+                // The child could already have been removed from the cache
+                if (subNode != null) {
+                    subNode.flushNode(sync);
+                }
+            }
+        }
+    }
+
+    /**
+     * Removes this and all subnodes from the backing store and clears all
+     * entries. After removal this instance will not be useable (except for
+     * a few methods that don't throw a <code>InvalidStateException</code>),
+     * even when a new node with the same path name is created this instance
+     * will not be usable again.
+     * <p>
+     * Checks that this is not a root node. If not it locks the parent node,
+     * then locks this node and checks that the node has not yet been removed.
+     * Then it makes sure that all subnodes of this node are in the child cache,
+     * by calling <code>childSpi()</code> on any children not yet in the cache.
+     * Then for all children it locks the subnode and removes it. After all
+     * subnodes have been purged the child cache is cleared, this nodes removed
+     * flag is set and any listeners are called. Finally this node is removed
+     * from the child cache of the parent node.
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     * @exception IllegalStateException if this node has already been removed
+     * @exception UnsupportedOperationException if this is a root node
+     */
+    public void removeNode() throws BackingStoreException {
+        // Check if it is a root node
+        if (parent == null)
+            throw new UnsupportedOperationException("Cannot remove root node");
+
+        synchronized (parent.lock) {
+            synchronized(this.lock) {
+                if (isRemoved())
+                    throw new IllegalStateException("Node Removed");
+
+                purge();
+            }
+            parent.childCache.remove(name);
+        }
+    }
+
+    /**
+     * Private helper method used to completely remove this node.
+     * Called by <code>removeNode</code> with the parent node and this node
+     * locked.
+     * <p>
+     * Makes sure that all subnodes of this node are in the child cache,
+     * by calling <code>childSpi()</code> on any children not yet in the
+     * cache. Then for all children it locks the subnode and calls this method
+     * on that node. After all subnodes have been purged the child cache is
+     * cleared, this nodes removed flag is set and any listeners are called.
+     */
+    private void purge() throws BackingStoreException
+    {
+        // Make sure all children have an AbstractPreferences node in cache
+        String children[] = childrenNamesSpi();
+        for (int i = 0; i < children.length; i++) {
+            if (childCache.get(children[i]) == null)
+                childCache.put(children[i], childSpi(children[i]));
+        }
+
+        // purge all children
+        Iterator i = childCache.values().iterator();
+        while (i.hasNext()) {
+            AbstractPreferences node = (AbstractPreferences) i.next();
+            synchronized(node.lock) {
+                node.purge();
+            }
+        }
+
+        // Cache is empty now
+        childCache.clear();
+
+        // remove this node
+        removeNodeSpi();
+        removed = true;
+
+        if (nodeListeners != null)
+          fire(new NodeChangeEvent(parent, this), false);
+    }
+
+    // listener methods
+
+    /**
+     * Add a listener which is notified when a sub-node of this node
+     * is added or removed.
+     * @param listener the listener to add
+     */
+    public void addNodeChangeListener(NodeChangeListener listener)
+    {
+      synchronized (lock)
+        {
+          if (isRemoved())
+            throw new IllegalStateException("node has been removed");
+          if (listener == null)
+            throw new NullPointerException("listener is null");
+          if (nodeListeners == null)
+            nodeListeners = new ArrayList();
+          nodeListeners.add(listener);
+        }
+    }
+
+    /**
+     * Add a listener which is notified when a value in this node
+     * is added, changed, or removed.
+     * @param listener the listener to add
+     */
+    public void addPreferenceChangeListener(PreferenceChangeListener listener)
+    {
+      synchronized (lock)
+        {
+          if (isRemoved())
+            throw new IllegalStateException("node has been removed");
+          if (listener == null)
+            throw new NullPointerException("listener is null");
+          if (preferenceListeners == null)
+            preferenceListeners = new ArrayList();
+          preferenceListeners.add(listener);
+        }
+    }
+
+    /**
+     * Remove the indicated node change listener from the list of
+     * listeners to notify.
+     * @param listener the listener to remove
+     */
+    public void removeNodeChangeListener(NodeChangeListener listener)
+    {
+      synchronized (lock)
+        {
+          if (isRemoved())
+            throw new IllegalStateException("node has been removed");
+          if (listener == null)
+            throw new NullPointerException("listener is null");
+          if (nodeListeners != null)
+            nodeListeners.remove(listener);
+        }
+    }
+
+    /**
+     * Remove the indicated preference change listener from the list of
+     * listeners to notify.
+     * @param listener the listener to remove
+     */
+    public void removePreferenceChangeListener (PreferenceChangeListener listener)
+    {
+      synchronized (lock)
+        {
+          if (isRemoved())
+            throw new IllegalStateException("node has been removed");
+          if (listener == null)
+            throw new NullPointerException("listener is null");
+          if (preferenceListeners != null)
+            preferenceListeners.remove(listener);
+        }
+    }
+
+    /**
+     * Send a preference change event to all listeners.  Note that
+     * the caller is responsible for holding the node's lock, and
+     * for checking that the list of listeners is not null.
+     * @param event the event to send
+     */
+    private void fire(final PreferenceChangeEvent event)
+    {
+      Iterator it = preferenceListeners.iterator();
+      while (it.hasNext())
+        {
+          final PreferenceChangeListener l = (PreferenceChangeListener) it.next();
+          EventDispatcher.dispatch(new Runnable()
+                                   {
+                                     public void run()
+                                     {
+                                       l.preferenceChange(event);
+                                     }
+                                   });
+        }
+    }
+
+    /**
+     * Send a node change event to all listeners.  Note that
+     * the caller is responsible for holding the node's lock, and
+     * for checking that the list of listeners is not null.
+     * @param event the event to send
+     */
+    private void fire(final NodeChangeEvent event, final boolean added)
+    {
+      Iterator it = nodeListeners.iterator();
+      while (it.hasNext())
+        {
+          final NodeChangeListener l = (NodeChangeListener) it.next();
+          EventDispatcher.dispatch(new Runnable()
+                                   {
+                                     public void run()
+                                     {
+                                       if (added)
+                                         l.childAdded(event);
+                                       else
+                                         l.childRemoved(event);
+                                     }
+                                   });
+        }
+    }
+
+    // abstract spi methods
+
+    /**
+     * Returns the names of the sub nodes of this preference node.
+     * This method only has to return any not yet cached child names,
+     * but may return all names if that is easier. It must not return
+     * null when there are no children, it has to return an empty array
+     * in that case. Since this method must consult the backing store to
+     * get all the sub node names it may throw a BackingStoreException.
+     * <p>
+     * Called by <code>childrenNames()</code> with this node locked.
+     */
+    protected abstract String[] childrenNamesSpi() throws BackingStoreException;
+
+    /**
+     * Returns a child note with the given name.
+     * This method is called by the <code>node()</code> method (indirectly
+     * through the <code>getNode()</code> helper method) with this node locked
+     * if a sub node with this name does not already exist in the child cache.
+     * If the child node did not aleady exist in the backing store the boolean
+     * field <code>newNode</code> of the returned node should be set.
+     * <p>
+     * Note that this method should even return a non-null child node if the
+     * backing store is not available since it may not throw a
+     * <code>BackingStoreException</code>.
+     */
+    protected abstract AbstractPreferences childSpi(String name);
+
+    /**
+     * Returns an (possibly empty) array with all the keys of the preference
+     * entries of this node.
+     * <p>
+     * Called by <code>keys()</code> with this node locked if this node has
+     * not been removed. May throw an exception when the backing store cannot
+     * be accessed.
+     *
+     * @exception BackingStoreException when the backing store cannot be     
+     *            reached
+     */
+    protected abstract String[] keysSpi() throws BackingStoreException;
+     
+    /**
+     * Returns the value associated with the key in this preferences node or
+     * null when the key does not exist in this preferences node.
+     * <p>
+     * Called by <code>key()</code> with this node locked after checking that
+     * key is valid, not null and that the node has not been removed.
+     * <code>key()</code> will catch any exceptions that this method throws.
+     */
+    protected abstract String getSpi(String key);
+
+    /**
+     * Sets the value of the given preferences entry for this node.
+     * The implementation is not required to propagate the change to the
+     * backing store immediately. It may not throw an exception when it tries
+     * to write to the backing store and that operation fails, the failure
+     * should be registered so a later invocation of <code>flush()</code>
+     * or <code>sync()</code> can signal the failure.
+     * <p>
+     * Called by <code>put()</code> with this node locked after checking that
+     * key and value are valid and non-null.
+     */
+    protected abstract void putSpi(String key, String value);
+
+    /**
+     * Removes the given key entry from this preferences node.
+     * The implementation is not required to propagate the change to the
+     * backing store immediately.  It may not throw an exception when it tries
+     * to write to the backing store and that operation fails, the failure
+     * should be registered so a later invocation of <code>flush()</code>
+     * or <code>sync()</code> can signal the failure.
+     * <p>
+     * Called by <code>remove()</code> with this node locked after checking
+     * that the key is valid and non-null.
+     */
+    protected abstract void removeSpi(String key);
+
+    /**
+     * Writes all entries of this preferences node that have not yet been
+     * written to the backing store and possibly creates this node in the
+     * backing store, if it does not yet exist. Should only write changes to
+     * this node and not write changes to any subnodes.
+     * Note that the node can be already removed in this VM. To check if
+     * that is the case the implementation can call <code>isRemoved()</code>.
+     * <p>
+     * Called (indirectly) by <code>flush()</code> with this node locked.
+     */
+    protected abstract void flushSpi() throws BackingStoreException;
+
+    /**
+     * Writes all entries of this preferences node that have not yet been
+     * written to the backing store and reads any entries that have changed
+     * in the backing store but that are not yet visible in this VM.
+     * Should only sync this node and not change any of the subnodes.
+     * Note that the node can be already removed in this VM. To check if
+     * that is the case the implementation can call <code>isRemoved()</code>.
+     * <p>
+     * Called (indirectly) by <code>sync()</code> with this node locked.
+     */
+    protected abstract void syncSpi() throws BackingStoreException;
+
+    /**
+     * Clears this node from this VM and removes it from the backing store.
+     * After this method has been called the node is marked as removed.
+     * <p>
+     * Called (indirectly) by <code>removeNode()</code> with this node locked
+     * after all the sub nodes of this node have already been removed.
+     */
+    protected abstract void removeNodeSpi() throws BackingStoreException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/BackingStoreException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/BackingStoreException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/BackingStoreException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/BackingStoreException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,104 @@
+/* BackingStoreException.java - chained exception thrown when backing store
+   fails
+   Copyright (C) 2001, 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.prefs;
+
+import java.io.NotSerializableException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * Chained exception thrown when backing store fails. This exception is
+ * only thrown from methods that actually have to access the backing store,
+ * such as <code>clear(), keys(), childrenNames(), nodeExists(), removeNode(),
+ * flush(), sync(), exportNode(), exportSubTree()</code>; normal operations
+ * do not throw BackingStoreExceptions.
+ *
+ * <p>Note that although this class inherits the Serializable interface, an
+ * attempt to serialize will fail with a <code>NotSerializableException</code>.
+ *
+ * @author Mark Wielaard (mark at klomp.org)
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public class BackingStoreException extends Exception
+{
+  static final long serialVersionUID = 859796500401108469L;
+
+  /**
+   * Creates a new exception with a descriptive message.
+   *
+   * @param message the message
+   */
+  public BackingStoreException(String message)
+  {
+    super(message);
+  }
+
+  /**
+   * Create a new exception with the given cause.
+   *
+   * @param cause the cause
+   */
+  public BackingStoreException(Throwable cause)
+  {
+    super(cause);
+  }
+
+  /**
+   * This class should not be serialized.
+   *
+   * @param o the output stream
+   */
+  private void writeObject(ObjectOutputStream o) throws NotSerializableException
+  {
+    throw new NotSerializableException
+      ("java.util.prefs.BackingStoreException");
+  }
+
+  /**
+   * This class should not be serialized.
+   *
+   * @param i the input stream
+   */
+  private void readObject(ObjectInputStream i) throws NotSerializableException
+  {
+    throw new NotSerializableException
+      ("java.util.prefs.BackingStoreException");
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/InvalidPreferencesFormatException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/InvalidPreferencesFormatException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/InvalidPreferencesFormatException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/InvalidPreferencesFormatException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,116 @@
+/* InvalidPreferencesFormatException - indicates reading prefs from stream
+   failed
+   Copyright (C) 2001, 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.prefs;
+
+import java.io.NotSerializableException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * Indicates reading prefs from stream failed. Thrown by the
+ * <code>importPreferences()</code> method when the supplied input stream
+ * could not be read because it was not in the correct XML format.
+ *
+ * <p>Note that although this class inherits the Serializable interface, an
+ * attempt to serialize will fail with a <code>NotSerializableException</code>.
+ * </p>
+ *
+ * @author Mark Wielaard (mark at klomp.org)
+ * @see Preferences
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public class InvalidPreferencesFormatException extends Exception
+{
+  static final long serialVersionUID = -791715184232119669L;
+
+  /**
+   * Creates a new exception with a descriptive message. The cause remains
+   * uninitialized.
+   *
+   * @param message the message
+   */
+  public InvalidPreferencesFormatException(String message)
+  {
+    super(message);
+  }
+
+  /**
+   * Creates a new exception with the given cause.
+   *
+   * @param cause the cause
+   */
+  public InvalidPreferencesFormatException(Throwable cause)
+  {
+    super(cause);
+  }
+
+  /**
+   * Creates a new exception with a descriptive message and a cause.
+   *
+   * @param message the message
+   * @param cause the cause
+   */
+  public InvalidPreferencesFormatException(String message, Throwable cause)
+  {
+    super(message, cause);
+  }
+
+  /**
+   * This class should not be serialized.
+   *
+   * @param o the output stream
+   */
+  private void writeObject(ObjectOutputStream o) throws NotSerializableException
+  {
+    throw new NotSerializableException
+      ("java.util.prefs.InvalidPreferencesFormatException");
+  }
+
+  /**
+   * This class should not be serialized.
+   *
+   * @param i the input stream
+   */
+  private void readObject(ObjectInputStream i) throws NotSerializableException
+  {
+    throw new NotSerializableException
+      ("java.util.prefs.InvalidPreferencesFormatException");
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/NodeChangeEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/NodeChangeEvent.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/NodeChangeEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/NodeChangeEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,111 @@
+/* NodeChangeEvent - ObjectEvent fired when a Preference node is added/removed
+   Copyright (C) 2001, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.prefs;
+
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.EventObject;
+
+/**
+ * ObjectEvent fired when a Preference node is added/removed.
+ * This event is only generated when a new subnode is added or a subnode is
+ * removed from a preference node. Changes in the entries of a preference node
+ * are indicated with a <code>PreferenceChangeEvent</code>.
+ * <p>
+ * Note that although this class is marked as serializable, attempts to
+ * serialize it will fail with NotSerializableException.
+ *
+ * @since 1.4
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+public class NodeChangeEvent extends EventObject {
+
+  // We have this to placate the compiler.
+  private static final long serialVersionUID =8068949086596572957L; 
+  
+    /**
+     * The sub node that was added or removed.
+     * Defined transient just like <code>EventObject.source</code> since
+     * this object should be serializable, but Preferences is in general not
+     * serializable.
+     */
+    private final transient Preferences child;
+
+    /**
+     * Creates a new NodeChangeEvent.
+     *
+     * @param parentNode The source preference node from which a subnode was
+     * added or removed
+     * @param childNode The preference node that was added or removed
+     */
+    public NodeChangeEvent(Preferences parentNode, Preferences childNode) {
+        super(parentNode);
+        child = childNode;
+    }
+
+    /**
+     * Returns the source parent preference node from which a subnode was
+     * added or removed.
+     */
+    public Preferences getParent() {
+        return (Preferences) source;
+    }
+
+    /**
+     * Returns the child preference subnode that was added or removed.
+     * To see wether it is still a valid preference node one has to call
+     * <code>event.getChild().nodeExists("")</code>.
+     */
+    public Preferences getChild() {
+        return child;
+    }
+
+    private void readObject(ObjectInputStream ois)
+      throws IOException
+    {
+      throw new NotSerializableException("LineEvent is not serializable");
+    }
+  
+    private void writeObject(ObjectOutputStream oos)
+      throws IOException
+    {
+      throw new NotSerializableException("LineEvent is not serializable");
+    }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/NodeChangeListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/NodeChangeListener.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/NodeChangeListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/NodeChangeListener.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,64 @@
+/* NodeChangeListener - EventListener for Preferences node addition/removal
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.prefs;
+
+import java.util.EventListener;
+
+/**
+ * EventListener for Preferences node addition/removal.
+ * <p>
+ * Note that these events are only generated for the addition and removal
+ * of sub nodes from the preference node. Entry changes in the preference
+ * node can be monitored with a <code>PreferenceChangeListener</code>.
+ *
+ * @since 1.4
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+public interface NodeChangeListener extends EventListener {
+
+    /**
+     * Fired when a sub node is added to the preference node.
+     */
+    void childAdded(NodeChangeEvent event);
+
+    /**
+     * Fired when a sub node is removed from the preference node.
+     */
+    void childRemoved(NodeChangeEvent event);
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/PreferenceChangeEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/PreferenceChangeEvent.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/PreferenceChangeEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/PreferenceChangeEvent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,125 @@
+/* PreferenceChangeEvent - ObjectEvent fired when a Preferences entry changes
+   Copyright (C) 2001, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.prefs;
+
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.EventObject;
+
+/**
+ * ObjectEvent fired when a Preferences entry changes.
+ * This event is generated when a entry is added, changed or removed.
+ * When an entry is removed then <code>getNewValue</code> will return null.
+ * <p>
+ * Preference change events are only generated for entries in one particular
+ * preference node. Notification of subnode addition/removal is given by a
+ * <code>NodeChangeEvent</code>.
+ * <p>
+ * Note that although this class is marked as serializable, attempts to
+ * serialize it will fail with NotSerializableException.
+ *
+ * @since 1.4
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+public class PreferenceChangeEvent extends EventObject {
+
+  // We have this to placate the compiler.
+  private static final long serialVersionUID = 793724513368024975L;
+  
+    /**
+     * The key of the changed entry.
+     */
+    private final String key;
+
+    /**
+     * The new value of the changed entry, or null when the entry was removed.
+     */
+    private final String newValue;
+
+    /**
+     * Creates a new PreferenceChangeEvent.
+     *
+     * @param node The source preference node for which an entry was added,
+     * changed or removed
+     * @param key The key of the entry that was added, changed or removed
+     * @param value The new value of the entry that was added or changed, or
+     * null when the entry was removed
+     */
+    public PreferenceChangeEvent(Preferences node, String key, String value) {
+        super(node);
+        this.key = key;
+        this.newValue = value;
+    }
+
+    /**
+     * Returns the source Preference node from which an entry was added,
+     * changed or removed.
+     */
+    public Preferences getNode() {
+        return (Preferences) source;
+    }
+
+    /**
+     * Returns the key of the entry that was added, changed or removed.
+     */
+    public String getKey() {
+        return key;
+    }
+
+    /**
+     * Returns the new value of the entry that was added or changed, or
+     * returns null when the entry was removed.
+     */
+    public String getNewValue() {
+        return newValue;
+    }
+
+    private void readObject(ObjectInputStream ois)
+      throws IOException
+    {
+      throw new NotSerializableException("LineEvent is not serializable");
+    }
+  
+    private void writeObject(ObjectOutputStream oos)
+      throws IOException
+    {
+      throw new NotSerializableException("LineEvent is not serializable");
+    }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/PreferenceChangeListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/PreferenceChangeListener.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/PreferenceChangeListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/PreferenceChangeListener.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,60 @@
+/* PreferenceChangeListener - EventListener for Preferences entry changes
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.prefs;
+
+import java.util.EventListener;
+
+/**
+ * EventListener for Preferences entry addition, change or removal.
+ * <p>
+ * Preference change events are only generated for entries in one particular
+ * preference node. Notification of subnode addition/removal can be monitored
+ * with a <code>NodeChangeListener</code>.
+ *
+ * @since 1.4
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+public interface PreferenceChangeListener extends EventListener {
+
+    /**
+     * Fired when a entry has been added, changed or removed from the
+     * preference node.
+     */
+    void preferenceChange(PreferenceChangeEvent event);
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/Preferences.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/Preferences.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/Preferences.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/Preferences.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,697 @@
+/* Preferences -- Preference node containing key value entries and subnodes
+   Copyright (C) 2001, 2004, 2005, 2006  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.prefs;
+
+import gnu.classpath.ServiceFactory;
+import gnu.java.util.prefs.NodeReader;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.PrivilegedAction;
+import java.util.Iterator;
+
+/**
+ * Preference node containing key value entries and subnodes.
+ * <p>
+ * There are two preference node trees, a system tree which can be accessed
+ * by calling <code>systemRoot()</code> containing system preferences usefull
+ * for all users, and a user tree that can be accessed by calling
+ * <code>userRoot()</code> containing preferences that can differ between
+ * different users. How different users are identified is implementation
+ * depended. It can be determined by Thread, Access Control Context or Subject.
+ * <p>
+ * This implementation uses the "java.util.prefs.PreferencesFactory" system
+ * property to find a class that implement <code>PreferencesFactory</code>
+ * and initialized that class (if it has a public no arguments contructor)
+ * to get at the actual system or user root. If the system property is not set,
+ * or the class cannot be initialized it uses the default implementation
+ * <code>gnu.java.util.prefs.FileBasedFactory</code>.
+ * <p>
+ * Besides the two static method above to get the roots of the system and user
+ * preference node trees there are also two convenience methods to access the
+ * default preference node for a particular package an object is in. These are
+ * <code>userNodeForPackage()</code> and <code>systemNodeForPackage()</code>.
+ * Both methods take an Object as an argument so accessing preferences values
+ * can be as easy as calling <code>Preferences.userNodeForPackage(this)</code>.
+ * <p>
+ * Note that if a security manager is installed all static methods check for
+ * <code>RuntimePermission("preferences")</code>. But if this permission is
+ * given to the code then it can access and change all (user) preference nodes
+ * and entries. So you should be carefull not to store to sensitive information
+ * or make security decissions based on preference values since there is no
+ * more fine grained control over what preference values can be changed once
+ * code has been given the correct runtime permission.
+ * <p>
+ * XXX
+ *
+ * @since 1.4
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+public abstract class Preferences {
+
+    // Static Fields
+
+    /**
+     * Default PreferencesFactory class used when the system property
+     * "java.util.prefs.PreferencesFactory" is not set.
+     */
+    private static final String defaultFactoryClass
+        = "gnu.java.util.prefs.FileBasedFactory";
+
+    /** Permission needed to access system or user root. */
+    private static final Permission prefsPermission
+        = new RuntimePermission("preferences");
+
+    /**
+     * The preferences factory object that supplies the system and user root.
+     * Set and returned by the getFactory() method.
+     */
+    private static PreferencesFactory factory;
+
+    /** Maximum node name length. 80 characters. */
+    public static final int MAX_NAME_LENGTH = 80;
+
+    /** Maximum entry key length. 80 characters. */
+    public static final int MAX_KEY_LENGTH = 80;
+
+    /** Maximum entry value length. 8192 characters. */
+    public static final int MAX_VALUE_LENGTH = 8192;
+
+    // Constructors
+
+    /**
+     * Creates a new Preferences node. Can only be used by subclasses.
+     * Empty implementation.
+     */
+    protected Preferences() {}
+
+    // Static methods
+
+    /**
+     * Returns the system preferences root node containing usefull preferences
+     * for all users. It is save to cache this value since it should always
+     * return the same preference node.
+     *
+     * @return the root system preference node
+     * @exception SecurityException when a security manager is installed and
+     * the caller does not have <code>RuntimePermission("preferences")</code>.
+     */
+    public static Preferences systemRoot() throws SecurityException {
+        // Get the preferences factory and check for permission
+        PreferencesFactory factory = getFactory();
+
+        return factory.systemRoot();
+    }
+
+    /**
+     * Returns the user preferences root node containing preferences for the
+     * the current user. How different users are identified is implementation
+     * depended. It can be determined by Thread, Access Control Context or
+     * Subject.
+     *
+     * @return the root user preference node
+     * @exception SecurityException when a security manager is installed and
+     * the caller does not have <code>RuntimePermission("preferences")</code>.
+     */
+    public static Preferences userRoot() throws SecurityException {
+        // Get the preferences factory and check for permission
+        PreferencesFactory factory = getFactory();
+        return factory.userRoot();
+    }
+
+    /**
+     * Private helper method for <code>systemRoot()</code> and
+     * <code>userRoot()</code>. Checks security permission and instantiates the
+     * correct factory if it has not yet been set.
+     * <p>
+     * When the preferences factory has not yet been set this method first
+     * tries to get the system propery "java.util.prefs.PreferencesFactory"
+     * and tries to initializes that class. If the system property is not set
+     * or initialization fails it returns an instance of the default factory
+     * <code>gnu.java.util.prefs.FileBasedPreferencesFactory</code>.
+     *
+     * @return the preferences factory to use
+     * @exception SecurityException when a security manager is installed and
+     * the caller does not have <code>RuntimePermission("preferences")</code>.
+     */
+    private static PreferencesFactory getFactory() throws SecurityException {
+
+        // First check for permission
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkPermission(prefsPermission);
+        }
+
+        // Get the factory
+        if (factory == null) {
+            // Caller might not have enough permissions
+            factory = (PreferencesFactory) AccessController.doPrivileged(
+                        new PrivilegedAction() {
+                            public Object run() {
+                                PreferencesFactory pf = null;
+                                String className = System.getProperty
+                                    ("java.util.prefs.PreferencesFactory");
+                                if (className != null) {
+                                    try {
+                                        Class fc = Class.forName(className);
+                                        Object o = fc.newInstance();
+                                        pf = (PreferencesFactory) o;
+                                    } catch (ClassNotFoundException cnfe)
+                                        {/*ignore*/}
+                                    catch (InstantiationException ie)
+                                        {/*ignore*/}
+                                    catch (IllegalAccessException iae)
+                                        {/*ignore*/}
+                                    catch (ClassCastException cce)
+                                        {/*ignore*/}
+                                }
+                                return pf;
+                            }
+                        });
+
+            // Still no factory? Try to see if we have one defined
+            // as a System Preference
+            if (factory == null)
+              {
+                Iterator iter = ServiceFactory.lookupProviders
+                    (PreferencesFactory.class, null);
+            
+                if (iter != null && iter.hasNext())
+                  factory = (PreferencesFactory) iter.next();
+              }
+            
+            // Still no factory? Use our default.
+            if (factory == null)
+	      {
+                try
+		  {
+                    Class cls = Class.forName (defaultFactoryClass);
+                    factory = (PreferencesFactory) cls.newInstance();
+                  }
+		catch (Exception e)
+		  {
+                    throw new RuntimeException ("Couldn't load default factory"
+                        + " '"+ defaultFactoryClass +"'", e);
+                  }
+              }
+
+        }
+	
+        return factory;
+    }
+
+    /**
+     * Returns the system preferences node for the package of a class.
+     * The package node name of the class is determined by dropping the
+     * final component of the fully qualified class name and
+     * changing all '.' to '/' in the package name. If the class of the
+     * object has no package then the package node name is "<unnamed>".
+     * The returned node is <code>systemRoot().node(packageNodeName)</code>.
+     *
+     * @param c Object whose default system preference node is requested
+     * @returns system preferences node that should be used by class c
+     * @exception SecurityException when a security manager is installed and
+     * the caller does not have <code>RuntimePermission("preferences")</code>.
+     */
+    public static Preferences systemNodeForPackage(Class c)
+            throws SecurityException
+    {
+        return nodeForPackage(c, systemRoot());
+    }
+
+    /**
+     * Returns the user preferences node for the package of a class.
+     * The package node name of the class is determined by dropping the
+     * final component of the fully qualified class name and
+     * changing all '.' to '/' in the package name. If the class of the
+     * object has no package then the package node name is "<unnamed>".
+     * The returned node is <code>userRoot().node(packageNodeName)</code>.
+     *
+     * @param c Object whose default userpreference node is requested
+     * @returns userpreferences node that should be used by class c
+     * @exception SecurityException when a security manager is installed and
+     * the caller does not have <code>RuntimePermission("preferences")</code>.
+     */
+    public static Preferences userNodeForPackage(Class c)
+            throws SecurityException
+    {
+        return nodeForPackage(c, userRoot());
+    }
+
+    /**
+     * Private helper method for <code>systemNodeForPackage()</code> and
+     * <code>userNodeForPackage()</code>. Given the correct system or user
+     * root it returns the correct Preference node for the package node name
+     * of the given object.
+     */
+    private static Preferences nodeForPackage(Class c, Preferences root) {
+        // Get the package path
+        String className = c.getName();
+        String packagePath;
+        int index = className.lastIndexOf('.');
+        if(index == -1) {
+            packagePath = "<unnamed>";
+        } else {
+            packagePath = className.substring(0,index).replace('.','/');
+        }
+
+        return root.node(packagePath);
+    }
+
+    /**
+     * Import preferences from the given input stream.  This expects
+     * preferences to be represented in XML as emitted by
+     * {@link #exportNode(OutputStream)} and
+     * {@link #exportSubtree(OutputStream)}.
+     * @throws IOException if there is an error while reading
+     * @throws InvalidPreferencesFormatException if the XML is not properly
+     * formatted
+     */
+    public static void importPreferences(InputStream is) 
+                                    throws InvalidPreferencesFormatException,
+                                           IOException
+    {
+        PreferencesFactory factory = getFactory();
+        NodeReader reader = new NodeReader(is, factory);
+        reader.importPreferences();
+    }
+
+    // abstract methods (identification)
+
+    /**
+     * Returns the absolute path name of this preference node.
+     * The absolute path name of a node is the path name of its parent node 
+     * plus a '/' plus its own name. If the node is the root node and has no
+     * parent then its name is "" and its absolute path name is "/".
+     */
+    public abstract String absolutePath();
+
+    /**
+     * Returns true if this node comes from the user preferences tree, false
+     * if it comes from the system preferences tree.
+     */
+    public abstract boolean isUserNode();
+
+    /**
+     * Returns the name of this preferences node. The name of the node cannot
+     * be null, can be mostly 80 characters and cannot contain any '/'
+     * characters. The root node has as name "".
+     */
+    public abstract String name();
+
+    /**
+     * Returns the String given by
+     * <code>
+     * (isUserNode() ? "User":"System") + " Preference Node: " + absolutePath()
+     * </code>
+     */
+    public abstract String toString();
+
+    // abstract methods (navigation)
+
+    /**
+     * Returns all the direct sub nodes of this preferences node.
+     * Needs access to the backing store to give a meaningfull answer.
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     * @exception IllegalStateException when this node has been removed
+     */
+    public abstract String[] childrenNames() throws BackingStoreException;
+
+    /**
+     * Returns a sub node of this preferences node if the given path is
+     * relative (does not start with a '/') or a sub node of the root
+     * if the path is absolute (does start with a '/').
+     *
+     * @exception IllegalStateException if this node has been removed
+     * @exception IllegalArgumentException if the path contains two or more
+     * consecutive '/' characters, ends with a '/' charactor and is not the
+     * string "/" (indicating the root node) or any name on the path is more
+     * then 80 characters long
+     */
+    public abstract Preferences node(String path);
+
+    /**
+     * Returns true if the node that the path points to exists in memory or
+     * in the backing store. Otherwise it returns false or an exception is
+     * thrown. When this node is removed the only valid parameter is the
+     * empty string (indicating this node), the return value in that case
+     * will be false.
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     * @exception IllegalStateException if this node has been removed
+     *            and the path is not the empty string (indicating this node)
+     * @exception IllegalArgumentException if the path contains two or more
+     * consecutive '/' characters, ends with a '/' charactor and is not the
+     * string "/" (indicating the root node) or any name on the path is more
+     * then 80 characters long
+     */
+    public abstract boolean nodeExists(String path)
+                                throws BackingStoreException;
+
+    /**
+     * Returns the parent preferences node of this node or null if this is
+     * the root of the preferences tree.
+     *
+     * @exception IllegalStateException if this node has been removed
+     */
+    public abstract Preferences parent();
+
+    // abstract methods (export)
+
+    /**
+     * Export this node, but not its descendants, as XML to the 
+     * indicated output stream.  The XML will be encoded using UTF-8 
+     * and will use a specified document type:<br>
+     * <code><!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd"></code><br>
+     * @param os the output stream to which the XML is sent
+     * @throws BackingStoreException if preference data cannot be read
+     * @throws IOException if an error occurs while writing the XML
+     * @throws IllegalStateException if this node or an ancestor has been removed
+     */
+    public abstract void exportNode(OutputStream os)
+                                throws BackingStoreException,
+                                       IOException;
+
+    /**
+     * Export this node and all its descendants as XML to the 
+     * indicated output stream.  The XML will be encoded using UTF-8 
+     * and will use a specified document type:<br>
+     * <code><!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd"></code><br>
+     * @param os the output stream to which the XML is sent
+     * @throws BackingStoreException if preference data cannot be read
+     * @throws IOException if an error occurs while writing the XML
+     * @throws IllegalStateException if this node or an ancestor has been removed
+     */
+    public abstract void exportSubtree(OutputStream os)
+                                throws BackingStoreException,
+                                       IOException;
+
+    // abstract methods (preference entry manipulation)
+
+    /**
+     * Returns an (possibly empty) array with all the keys of the preference
+     * entries of this node.
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     * @exception IllegalStateException if this node has been removed
+     */
+    public abstract String[] keys() throws BackingStoreException;
+
+    /**
+     * Returns the value associated with the key in this preferences node. If
+     * the default value of the key cannot be found in the preferences node
+     * entries or something goes wrong with the backing store the supplied
+     * default value is returned.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public abstract String get(String key, String defaultVal);
+
+    /**
+     * Convenience method for getting the given entry as a boolean.
+     * When the string representation of the requested entry is either
+     * "true" or "false" (ignoring case) then that value is returned,
+     * otherwise the given default boolean value is returned.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public abstract boolean getBoolean(String key, boolean defaultVal);
+
+    /**
+     * Convenience method for getting the given entry as a byte array.
+     * When the string representation of the requested entry is a valid
+     * Base64 encoded string (without any other characters, such as newlines)
+     * then the decoded Base64 string is returned as byte array,
+     * otherwise the given default byte array value is returned.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public abstract byte[] getByteArray(String key, byte[] defaultVal);
+
+    /**
+     * Convenience method for getting the given entry as a double.
+     * When the string representation of the requested entry can be decoded
+     * with <code>Double.parseDouble()</code> then that double is returned,
+     * otherwise the given default double value is returned.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public abstract double getDouble(String key, double defaultVal);
+
+    /**
+     * Convenience method for getting the given entry as a float.
+     * When the string representation of the requested entry can be decoded
+     * with <code>Float.parseFloat()</code> then that float is returned,
+     * otherwise the given default float value is returned.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public abstract float getFloat(String key, float defaultVal);
+
+    /**
+     * Convenience method for getting the given entry as an integer.
+     * When the string representation of the requested entry can be decoded
+     * with <code>Integer.parseInt()</code> then that integer is returned,
+     * otherwise the given default integer value is returned.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public abstract int getInt(String key, int defaultVal);
+
+    /**
+     * Convenience method for getting the given entry as a long.
+     * When the string representation of the requested entry can be decoded
+     * with <code>Long.parseLong()</code> then that long is returned,
+     * otherwise the given default long value is returned.
+     *
+     * @exception IllegalArgumentException if key is larger then 80 characters
+     * @exception IllegalStateException if this node has been removed
+     * @exception NullPointerException if key is null
+     */
+    public abstract long getLong(String key, long defaultVal);
+
+    /**
+     * Sets the value of the given preferences entry for this node.
+     * Key and value cannot be null, the key cannot exceed 80 characters
+     * and the value cannot exceed 8192 characters.
+     * <p>
+     * The result will be immediatly visible in this VM, but may not be
+     * immediatly written to the backing store.
+     *
+     * @exception NullPointerException if either key or value are null
+     * @exception IllegalArgumentException if either key or value are to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public abstract void put(String key, String value);
+
+    /**
+     * Convenience method for setting the given entry as a boolean.
+     * The boolean is converted with <code>Boolean.toString(value)</code>
+     * and then stored in the preference entry as that string.
+     *
+     * @exception NullPointerException if key is null
+     * @exception IllegalArgumentException if the key length is to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public abstract void putBoolean(String key, boolean value);
+
+    /**
+     * Convenience method for setting the given entry as an array of bytes.
+     * The byte array is converted to a Base64 encoded string
+     * and then stored in the preference entry as that string.
+     * <p>
+     * Note that a byte array encoded as a Base64 string will be about 1.3
+     * times larger then the original length of the byte array, which means
+     * that the byte array may not be larger about 6 KB.
+     *
+     * @exception NullPointerException if either key or value are null
+     * @exception IllegalArgumentException if either key or value are to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public abstract void putByteArray(String key, byte[] value);
+
+    /**
+     * Convenience method for setting the given entry as a double.
+     * The double is converted with <code>Double.toString(double)</code>
+     * and then stored in the preference entry as that string.
+     *
+     * @exception NullPointerException if the key is null
+     * @exception IllegalArgumentException if the key length is to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public abstract void putDouble(String key, double value);
+
+    /**
+     * Convenience method for setting the given entry as a float.
+     * The float is converted with <code>Float.toString(float)</code>
+     * and then stored in the preference entry as that string.
+     *
+     * @exception NullPointerException if the key is null
+     * @exception IllegalArgumentException if the key length is to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public abstract void putFloat(String key, float value);
+
+    /**
+     * Convenience method for setting the given entry as an integer.
+     * The integer is converted with <code>Integer.toString(int)</code>
+     * and then stored in the preference entry as that string.
+     *
+     * @exception NullPointerException if the key is null
+     * @exception IllegalArgumentException if the key length is to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public abstract void putInt(String key, int value);
+
+    /**
+     * Convenience method for setting the given entry as a long.
+     * The long is converted with <code>Long.toString(long)</code>
+     * and then stored in the preference entry as that string.
+     *
+     * @exception NullPointerException if the key is null
+     * @exception IllegalArgumentException if the key length is to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public abstract void putLong(String key, long value);
+
+    /**
+     * Removes the preferences entry from this preferences node.
+     * <p>
+     * The result will be immediatly visible in this VM, but may not be
+     * immediatly written to the backing store.
+     *
+     * @exception NullPointerException if the key is null
+     * @exception IllegalArgumentException if the key length is to large
+     * @exception IllegalStateException when this node has been removed
+     */
+    public abstract void remove(String key);
+
+    // abstract methods (preference node manipulation)
+
+    /**
+     * Removes all entries from this preferences node. May need access to the
+     * backing store to get and clear all entries.
+     * <p>
+     * The result will be immediatly visible in this VM, but may not be
+     * immediatly written to the backing store.
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     * @exception IllegalStateException if this node has been removed
+     */
+    public abstract void clear() throws BackingStoreException;
+
+    /**
+     * Writes all preference changes on this and any subnode that have not
+     * yet been written to the backing store. This has no effect on the
+     * preference entries in this VM, but it makes sure that all changes
+     * are visible to other programs (other VMs might need to call the
+     * <code>sync()</code> method to actually see the changes to the backing
+     * store.
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     * @exception IllegalStateException if this node has been removed
+     */
+    public abstract void flush() throws BackingStoreException;
+
+    /**
+     * Writes and reads all preference changes to and from this and any
+     * subnodes. This makes sure that all local changes are written to the
+     * backing store and that all changes to the backing store are visible
+     * in this preference node (and all subnodes).
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     * @exception IllegalStateException if this node has been removed
+     */
+    public abstract void sync() throws BackingStoreException;
+
+    /**
+     * Removes this and all subnodes from the backing store and clears all
+     * entries. After removal this instance will not be useable (except for
+     * a few methods that don't throw a <code>InvalidStateException</code>),
+     * even when a new node with the same path name is created this instance
+     * will not be usable again. The root (system or user) may never be removed.
+     * <p>
+     * Note that according to the specification an implementation may delay
+     * removal of the node from the backing store till the <code>flush()</code>
+     * method is called. But the <code>flush()</code> method may throw a 
+     * <code>IllegalStateException</code> when the node has been removed.
+     * So most implementations will actually remove the node and any subnodes
+     * from the backing store immediatly.
+     *
+     * @exception BackingStoreException when the backing store cannot be
+     *            reached
+     * @exception IllegalStateException if this node has already been removed
+     * @exception UnsupportedOperationException if this is a root node
+     */
+    public abstract void removeNode() throws BackingStoreException;
+
+    // abstract methods (listeners)
+
+    public abstract void addNodeChangeListener(NodeChangeListener listener);
+
+    public abstract void addPreferenceChangeListener
+                            (PreferenceChangeListener listener);
+
+    public abstract void removeNodeChangeListener(NodeChangeListener listener);
+
+    public abstract void removePreferenceChangeListener
+                            (PreferenceChangeListener listener);
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/PreferencesFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/PreferencesFactory.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/PreferencesFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/PreferencesFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* PreferencesFactory - Preferences system and user root factory interface
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.prefs;
+
+/**
+ * Preferences system and user root factory interface. Defines how to get
+ * to the system and user root preferences objects. Should be implemented by
+ * new preferences backends.
+ *
+ * @since 1.4
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+public interface PreferencesFactory {
+
+    /**
+     * Returns the system root preferences node. Should always return the
+     * same object.
+     */
+    Preferences systemRoot();
+
+    /**
+     * Returns the user root preferences node. May return different objects
+     * depending on the user that called this method. The user may for example
+     * be determined by the current Thread or the Subject associated with the
+     * current AccessControllContext.
+     */
+    Preferences userRoot();
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/prefs/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.util.prefs package.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.util.prefs</title></head>
+
+<body>
+<p>Utility classes for storing and retrieving user and system preferences.</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/MatchResult.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/MatchResult.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/MatchResult.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/MatchResult.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,81 @@
+/* MatchResult.java -- Result of a regular expression match.
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.regex;
+
+/**
+ * This interface represents the result of a regular expression match.
+ * It can be used to query the contents of the match, but not to modify
+ * them.
+ * @since 1.5
+ */
+public interface MatchResult
+{
+  /** Returns the index just after the last matched character.  */
+  int end();
+  
+  /**
+   * Returns the index just after the last matched character of the
+   * given sub-match group.
+   * @param group the sub-match group
+   */ 
+  int end(int group);
+
+  /** Returns the substring of the input which was matched.  */
+  String group();
+  
+  /** 
+   * Returns the substring of the input which was matched by the
+   * given sub-match group.
+   * @param group the sub-match group
+   */
+  String group(int group);
+
+  /** Returns the number of sub-match groups in the matching pattern.  */  
+  int groupCount();
+
+  /** Returns the index of the first character of the match.  */
+  int start();
+
+  /**
+   * Returns the index of the first character of the given sub-match
+   * group.
+   * @param group the sub-match group
+   */
+  int start(int group);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/Matcher.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/Matcher.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/Matcher.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/Matcher.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,316 @@
+/* Matcher.java -- Instance of a regular expression applied to a char sequence.
+   Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.regex;
+
+import gnu.java.util.regex.CharIndexed;
+import gnu.java.util.regex.RE;
+import gnu.java.util.regex.REMatch;
+
+/**
+ * Instance of a regular expression applied to a char sequence.
+ *
+ * @since 1.4
+ */
+public final class Matcher implements MatchResult
+{
+  private Pattern pattern;
+  private CharSequence input;
+  // We use CharIndexed as an input object to the getMatch method in order
+  // that /\G/ (the end of the previous match) may work.  The information
+  // of the previous match is stored in the CharIndexed object.
+  private CharIndexed inputCharIndexed;
+  private int position;
+  private int appendPosition;
+  private REMatch match;
+
+  Matcher(Pattern pattern, CharSequence input)
+  {
+    this.pattern = pattern;
+    this.input = input;
+    this.inputCharIndexed = RE.makeCharIndexed(input, 0);
+  }
+  
+  /**
+   * @param sb The target string buffer
+   * @param replacement The replacement string
+   *
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   * @exception IndexOutOfBoundsException If the replacement string refers
+   * to a capturing group that does not exist in the pattern
+   */
+  public Matcher appendReplacement (StringBuffer sb, String replacement)
+    throws IllegalStateException
+  {
+    assertMatchOp();
+    sb.append(input.subSequence(appendPosition,
+				match.getStartIndex()).toString());
+    sb.append(RE.getReplacement(replacement, match,
+	RE.REG_REPLACE_USE_BACKSLASHESCAPE));
+    appendPosition = match.getEndIndex();
+    return this;
+  }
+
+  /**
+   * @param sb The target string buffer
+   */
+  public StringBuffer appendTail (StringBuffer sb)
+  {
+    sb.append(input.subSequence(appendPosition, input.length()).toString());
+    return sb;
+  }
+ 
+  /**
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   */
+  public int end ()
+    throws IllegalStateException
+  {
+    assertMatchOp();
+    return match.getEndIndex();
+  }
+  
+  /**
+   * @param group The index of a capturing group in this matcher's pattern
+   *
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   * @exception IndexOutOfBoundsException If the replacement string refers
+   * to a capturing group that does not exist in the pattern
+   */
+  public int end (int group)
+    throws IllegalStateException
+  {
+    assertMatchOp();
+    return match.getEndIndex(group);
+  }
+ 
+  public boolean find ()
+  {
+    boolean first = (match == null);
+    match = pattern.getRE().getMatch(inputCharIndexed, position);
+    if (match != null)
+      {
+	int endIndex = match.getEndIndex();
+	// Are we stuck at the same position?
+	if (!first && endIndex == position)
+	  {
+	    match = null;
+	    // Not at the end of the input yet?
+	    if (position < input.length() - 1)
+	      {
+		position++;
+		return find(position);
+	      }
+	    else
+	      return false;
+	  }
+	position = endIndex;
+	return true;
+      }
+    return false;
+  } 
+
+  /**
+   * @param start The index to start the new pattern matching
+   *
+   * @exception IndexOutOfBoundsException If the replacement string refers
+   * to a capturing group that does not exist in the pattern
+   */
+  public boolean find (int start)
+  {
+    match = pattern.getRE().getMatch(inputCharIndexed, start);
+    if (match != null)
+      {
+	position = match.getEndIndex();
+	return true;
+      }
+    return false;
+  }
+ 
+  /**
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   */
+  public String group ()
+  {
+    assertMatchOp();
+    return match.toString();
+  }
+  
+  /**
+   * @param group The index of a capturing group in this matcher's pattern
+   *
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   * @exception IndexOutOfBoundsException If the replacement string refers
+   * to a capturing group that does not exist in the pattern
+   */
+  public String group (int group)
+    throws IllegalStateException
+  {
+    assertMatchOp();
+    return match.toString(group);
+  }
+
+  /**
+   * @param replacement The replacement string
+   */
+  public String replaceFirst (String replacement)
+  {
+    reset();
+    // Semantics might not quite match
+    return pattern.getRE().substitute(input, replacement, position,
+	RE.REG_REPLACE_USE_BACKSLASHESCAPE);
+  }
+
+  /**
+   * @param replacement The replacement string
+   */
+  public String replaceAll (String replacement)
+  {
+    reset();
+    return pattern.getRE().substituteAll(input, replacement, position,
+	RE.REG_REPLACE_USE_BACKSLASHESCAPE);
+  }
+  
+  public int groupCount ()
+  {
+    return pattern.getRE().getNumSubs();
+  }
+ 
+  public boolean lookingAt ()
+  {
+    match = pattern.getRE().getMatch(inputCharIndexed, 0);
+    if (match != null)
+      {
+	if (match.getStartIndex() == 0)
+	  {
+	    position = match.getEndIndex();
+	    return true;
+	  }
+	match = null;
+      }
+    return false;
+  }
+  
+  /**
+   * Attempts to match the entire input sequence against the pattern. 
+   *
+   * If the match succeeds then more information can be obtained via the
+   * start, end, and group methods.
+   *
+   * @see #start()
+   * @see #end()
+   * @see #group()
+   */
+  public boolean matches ()
+  {
+    match = pattern.getRE().getMatch(inputCharIndexed, 0, RE.REG_TRY_ENTIRE_MATCH);
+    if (match != null)
+      {
+	if (match.getStartIndex() == 0)
+	  {
+	    position = match.getEndIndex();
+	    if (position == input.length())
+	        return true;
+	  }
+	match = null;
+      }
+    return false;
+  }
+  
+  /**
+   * Returns the Pattern that is interpreted by this Matcher
+   */
+  public Pattern pattern ()
+  {
+    return pattern;
+  }
+  
+  public Matcher reset ()
+  {
+    position = 0;
+    match = null;
+    return this;
+  }
+  
+  /**
+   * @param input The new input character sequence
+   */
+  public Matcher reset (CharSequence input)
+  {
+    this.input = input;
+    return reset();
+  }
+  
+  /**
+   * @returns the index of a capturing group in this matcher's pattern
+   *
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   */
+  public int start ()
+    throws IllegalStateException
+  {
+    assertMatchOp();
+    return match.getStartIndex();
+  }
+
+  /**
+   * @param group The index of a capturing group in this matcher's pattern
+   *
+   * @exception IllegalStateException If no match has yet been attempted,
+   * or if the previous match operation failed
+   * @exception IndexOutOfBoundsException If the replacement string refers
+   * to a capturing group that does not exist in the pattern
+   */
+  public int start (int group)
+    throws IllegalStateException
+  {
+    assertMatchOp();
+    return match.getStartIndex(group);
+  }
+
+  private void assertMatchOp()
+  {
+    if (match == null) throw new IllegalStateException();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/Pattern.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/Pattern.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/Pattern.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/Pattern.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,263 @@
+/* Pattern.java -- Compiled regular expression ready to be applied.
+   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.regex;
+
+import gnu.java.util.regex.RE;
+import gnu.java.util.regex.REException;
+import gnu.java.util.regex.RESyntax;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+
+/**
+ * Compiled regular expression ready to be applied. 
+ *
+ * @since 1.4
+ */
+public final class Pattern implements Serializable
+{
+  private static final long serialVersionUID = 5073258162644648461L;
+  
+  public static final int CANON_EQ = 128;
+  public static final int CASE_INSENSITIVE = 2;
+  public static final int COMMENTS = 4;
+  public static final int DOTALL = 32;
+  public static final int MULTILINE = 8;
+  public static final int UNICODE_CASE = 64;
+  public static final int UNIX_LINES = 1;
+  
+  private final String regex;
+  private final int flags;
+
+  private final RE re;
+
+  private Pattern (String regex, int flags)
+    throws PatternSyntaxException
+  {
+    this.regex = regex;
+    this.flags = flags;
+
+    RESyntax syntax = RESyntax.RE_SYNTAX_JAVA_1_4;
+    int gnuFlags = 0;
+    gnuFlags |= RE.REG_ICASE_USASCII;
+    if ((flags & CASE_INSENSITIVE) != 0)
+      gnuFlags |= RE.REG_ICASE;
+    if ((flags & MULTILINE) != 0)
+      {
+        gnuFlags |= RE.REG_MULTILINE;
+        syntax = new RESyntax(syntax);
+        syntax.setLineSeparator(null);
+      }
+    if ((flags & DOTALL) != 0)
+      gnuFlags |= RE.REG_DOT_NEWLINE;
+    if ((flags & UNICODE_CASE) != 0)
+      gnuFlags &= ~RE.REG_ICASE_USASCII;
+    // not yet supported:
+    // if ((flags & CANON_EQ) != 0) gnuFlags =
+
+    if ((flags & UNIX_LINES) != 0)
+      {
+	// Use a syntax set with \n for linefeeds?
+	syntax = new RESyntax(syntax);
+	syntax.setLineSeparator("\n");
+      }
+
+    if ((flags & COMMENTS) != 0)
+      {
+	gnuFlags |= RE.REG_X_COMMENTS;
+      }
+
+    try
+      {
+	this.re = new RE(regex, gnuFlags, syntax);
+      }
+    catch (REException e)
+      {
+	PatternSyntaxException pse;
+	pse = new PatternSyntaxException(e.getMessage(),
+					 regex, e.getPosition());
+	pse.initCause(e);
+	throw pse;
+      }
+  }
+ 
+  // package private accessor method
+  RE getRE()
+  {
+    return re;
+  }
+
+  /**
+   * @param regex The regular expression
+   *
+   * @exception PatternSyntaxException If the expression's syntax is invalid
+   */
+  public static Pattern compile (String regex)
+    throws PatternSyntaxException
+  {
+    return compile(regex, 0);
+  }
+  
+  /**
+   * @param regex The regular expression
+   * @param flags The match flags, a bit mask
+   *
+   * @exception PatternSyntaxException If the expression's syntax is invalid
+   * @exception IllegalArgumentException If bit values other than those
+   * corresponding to the defined match flags are set in flags
+   */
+  public static Pattern compile (String regex, int flags)
+    throws PatternSyntaxException
+  {
+    // FIXME: check which flags are really accepted
+    if ((flags & ~0xEF) != 0)
+      throw new IllegalArgumentException ();
+    
+    return new Pattern (regex, flags); 
+  }
+  
+  public int flags ()
+  {
+    return this.flags;
+  }
+  
+  /**
+   * @param regex The regular expression
+   * @param input The character sequence to be matched
+   *
+   * @exception PatternSyntaxException If the expression's syntax is invalid
+   */
+  public static boolean matches (String regex, CharSequence input) 
+  {
+    return compile(regex).matcher(input).matches();
+  }
+  
+  /**
+   * @param input The character sequence to be matched
+   */
+  public Matcher matcher (CharSequence input)
+  {
+    return new Matcher(this, input);
+  }
+  
+  /**
+   * @param input The character sequence to be matched
+   */
+  public String[] split (CharSequence input)
+  {
+    return split(input, 0);
+  }
+  
+  /**
+   * @param input The character sequence to be matched
+   * @param limit The result threshold
+   */
+  public String[] split (CharSequence input, int limit)
+  {
+    Matcher matcher = new Matcher(this, input);
+    ArrayList list = new ArrayList();
+    int empties = 0;
+    int count = 0;
+    int start = 0;
+    int end;
+    boolean matched = matcher.find();
+
+    while (matched && (limit <= 0 || count < limit - 1))
+      {
+	++count;
+	end = matcher.start();
+	if (start == end)
+	  empties++;
+	else
+	  {
+	    while (empties > 0)
+	      {
+		list.add("");
+		empties--;
+	      }
+
+	    String text = input.subSequence(start, end).toString();
+	    list.add(text);
+	  }
+	start = matcher.end();
+	matched = matcher.find();
+      }
+
+    // We matched nothing.
+    if (!matched && count == 0)
+      return new String[] { input.toString() };
+    
+    // Is the last token empty?
+    boolean emptyLast = (start == input.length());
+
+    // Can/Must we add empties or an extra last token at the end?
+    if (list.size() < limit || limit < 0 || (limit == 0 && !emptyLast))
+      {
+	if (limit > list.size())
+	  {
+	    int max = limit - list.size();
+	    empties = (empties > max) ? max : empties;
+	  }
+	while (empties > 0)
+	  {
+	    list.add("");
+	    empties--;
+	  }
+      }
+
+    // last token at end
+    if (limit != 0 || (limit == 0 && !emptyLast))
+      {
+	String t = input.subSequence(start, input.length()).toString();
+	if ("".equals(t) && limit == 0)
+	  ; // Don't add.
+	else
+	  list.add(t);
+      }
+
+    String[] output = new String [list.size()];
+    list.toArray(output);
+    return output;
+  }
+  
+  public String pattern ()
+  {
+    return regex;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/PatternSyntaxException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/PatternSyntaxException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/PatternSyntaxException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/PatternSyntaxException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,133 @@
+/* PatternSyntaxException - Indicates illegal pattern for regular expression.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.regex;
+
+/**
+ * Indicates illegal pattern for regular expression.
+ * Includes state to inspect the pattern and what and where the expression
+ * was not valid regular expression.
+ * @since 1.4
+ */
+public class PatternSyntaxException extends IllegalArgumentException
+{
+  private static final long serialVersionUID = -3864639126226059218L;
+
+  /**
+   * Human readable escription of the syntax error.
+   */
+  private final String desc;
+
+  /**
+   * The original pattern that contained the syntax error.
+   */
+  private final String pattern;
+  
+  /**
+   * Index of the first character in the String that was probably invalid,
+   * or -1 when unknown.
+   */
+  private final int index;
+
+  /**
+   * Creates a new PatternSyntaxException.
+   *
+   * @param description Human readable escription of the syntax error.
+   * @param pattern The original pattern that contained the syntax error.
+   * @param index Index of the first character in the String that was
+   *        probably invalid, or -1 when unknown.
+   */
+  public PatternSyntaxException(String description,
+		                String pattern,
+				int index)
+  {
+    super(description);
+    this.desc = description;
+    this.pattern = pattern;
+    this.index = index;
+  }
+
+  /**
+   * Returns a human readable escription of the syntax error.
+   */
+  public String getDescription()
+  {
+    return desc;
+  }
+
+  /**
+   * Returns the original pattern that contained the syntax error.
+   */
+  public String getPattern()
+  {
+    return pattern;
+  }
+
+  /**
+   * Returns the index of the first character in the String that was probably
+   * invalid, or -1 when unknown.
+   */
+  public int getIndex()
+  {
+    return index;
+  }
+
+  /**
+   * Returns a string containing a line with the description, a line with
+   * the original pattern and a line indicating with a ^ which character is
+   * probably the first invalid character in the pattern if the index is not
+   * negative.
+   */
+  public String getMessage()
+  {
+    String lineSep = System.getProperty("line.separator");
+    StringBuffer sb = new StringBuffer(desc);
+    sb.append(lineSep);
+    sb.append('\t');
+    sb.append(pattern);
+    if (index != -1)
+      {
+	sb.append(lineSep);
+	sb.append('\t');
+	for (int i=0; i<index; i++)
+	  sb.append(' ');
+	sb.append('^');
+      }
+    return sb.toString();
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/regex/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.util.regex package.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.util.regex</title></head>
+
+<body>
+<p>Regular expression patterns and matchers.</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Adler32.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Adler32.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Adler32.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Adler32.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,205 @@
+/* Adler32.java - Computes Adler32 data checksum of a data stream
+   Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+/*
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * The actual Adler32 algorithm is taken from RFC 1950.
+ * Status:  Believed complete and correct.
+ */
+
+/**
+ * Computes Adler32 checksum for a stream of data. An Adler32 
+ * checksum is not as reliable as a CRC32 checksum, but a lot faster to 
+ * compute.
+ *<p>
+ * The specification for Adler32 may be found in RFC 1950.
+ * (ZLIB Compressed Data Format Specification version 3.3)
+ *<p>
+ *<p>
+ * From that document:
+ *<p>
+ *      "ADLER32 (Adler-32 checksum)
+ *       This contains a checksum value of the uncompressed data
+ *       (excluding any dictionary data) computed according to Adler-32
+ *       algorithm. This algorithm is a 32-bit extension and improvement
+ *       of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073
+ *       standard. 
+ *<p>
+ *       Adler-32 is composed of two sums accumulated per byte: s1 is
+ *       the sum of all bytes, s2 is the sum of all s1 values. Both sums
+ *       are done modulo 65521. s1 is initialized to 1, s2 to zero.  The
+ *       Adler-32 checksum is stored as s2*65536 + s1 in most-
+ *       significant-byte first (network) order."
+ *<p>
+ * "8.2. The Adler-32 algorithm
+ *<p>
+ *    The Adler-32 algorithm is much faster than the CRC32 algorithm yet
+ *    still provides an extremely low probability of undetected errors.
+ *<p>
+ *    The modulo on unsigned long accumulators can be delayed for 5552
+ *    bytes, so the modulo operation time is negligible.  If the bytes
+ *    are a, b, c, the second sum is 3a + 2b + c + 3, and so is position
+ *    and order sensitive, unlike the first sum, which is just a
+ *    checksum.  That 65521 is prime is important to avoid a possible
+ *    large class of two-byte errors that leave the check unchanged.
+ *    (The Fletcher checksum uses 255, which is not prime and which also
+ *    makes the Fletcher check insensitive to single byte changes 0 <->
+ *    255.)
+ *<p>
+ *    The sum s1 is initialized to 1 instead of zero to make the length
+ *    of the sequence part of s2, so that the length does not have to be
+ *   checked separately. (Any sequence of zeroes has a Fletcher
+ *    checksum of zero.)"
+ *
+ * @author John Leuner, Per Bothner
+ * @since JDK 1.1
+ *
+ * @see InflaterInputStream
+ * @see DeflaterOutputStream
+ */
+public class Adler32 implements Checksum
+{
+
+  /** largest prime smaller than 65536 */
+  private static final int BASE = 65521;
+
+  private int checksum; //we do all in int.
+
+  //Note that java doesn't have unsigned integers,
+  //so we have to be careful with what arithmetic 
+  //we do. We return the checksum as a long to 
+  //avoid sign confusion.
+
+  /**
+   * Creates a new instance of the <code>Adler32</code> class. 
+   * The checksum starts off with a value of 1. 
+   */
+  public Adler32 ()
+  {
+    reset();
+  }
+
+  /**
+   * Resets the Adler32 checksum to the initial value.
+   */
+  public void reset () 
+  {
+    checksum = 1; //Initialize to 1    
+  }
+
+  /**
+   * Updates the checksum with the byte b. 
+   *
+   * @param bval the data value to add. The high byte of the int is ignored.
+   */
+  public void update (int bval)
+  {
+    //We could make a length 1 byte array and call update again, but I
+    //would rather not have that overhead
+    int s1 = checksum & 0xffff;
+    int s2 = checksum >>> 16;
+    
+    s1 = (s1 + (bval & 0xFF)) % BASE;
+    s2 = (s1 + s2) % BASE;
+    
+    checksum = (s2 << 16) + s1;
+  }
+
+  /**
+   * Updates the checksum with the bytes taken from the array. 
+   * 
+   * @param buffer an array of bytes
+   */
+  public void update (byte[] buffer)
+  {
+    update(buffer, 0, buffer.length);
+  }
+
+  /**
+   * Updates the checksum with the bytes taken from the array. 
+   * 
+   * @param buf an array of bytes
+   * @param off the start of the data used for this update
+   * @param len the number of bytes to use for this update
+   */
+  public void update (byte[] buf, int off, int len)
+  {
+    //(By Per Bothner)
+    int s1 = checksum & 0xffff;
+    int s2 = checksum >>> 16;
+
+    while (len > 0)
+      {
+	// We can defer the modulo operation:
+	// s1 maximally grows from 65521 to 65521 + 255 * 3800
+	// s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31
+	int n = 3800;
+	if (n > len)
+	  n = len;
+	len -= n;
+	while (--n >= 0)
+	  {
+	    s1 = s1 + (buf[off++] & 0xFF);
+	    s2 = s2 + s1;
+	  }
+	s1 %= BASE;
+	s2 %= BASE;
+      }
+
+    /*Old implementation, borrowed from somewhere:
+    int n;
+    
+    while (len-- > 0) {
+
+      s1 = (s1 + (bs[offset++] & 0xff)) % BASE; 
+      s2 = (s2 + s1) % BASE;
+    }*/
+    
+    checksum = (s2 << 16) | s1;
+  }
+
+  /**
+   * Returns the Adler32 data checksum computed so far.
+   */
+  public long getValue()
+  {
+    return (long) checksum & 0xffffffffL;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/CRC32.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/CRC32.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/CRC32.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/CRC32.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,132 @@
+/* CRC32.java - Computes CRC32 data checksum of a data stream
+   Copyright (C) 1999. 2000, 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+/*
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * The actual CRC32 algorithm is taken from RFC 1952.
+ * Status:  Believed complete and correct.
+ */
+
+/**
+ * Computes CRC32 data checksum of a data stream.
+ * The actual CRC32 algorithm is described in RFC 1952
+ * (GZIP file format specification version 4.3).
+ * Can be used to get the CRC32 over a stream if used with checked input/output
+ * streams.
+ *
+ * @see InflaterInputStream
+ * @see DeflaterOutputStream
+ *
+ * @author Per Bothner
+ * @date April 1, 1999.
+ */
+public class CRC32 implements Checksum
+{
+  /** The crc data checksum so far. */
+  private int crc = 0;
+
+  /** The fast CRC table. Computed once when the CRC32 class is loaded. */
+  private static int[] crc_table = make_crc_table();
+
+  /** Make the table for a fast CRC. */
+  private static int[] make_crc_table ()
+  {
+    int[] crc_table = new int[256];
+    for (int n = 0; n < 256; n++)
+      {
+	int c = n;
+	for (int k = 8;  --k >= 0; )
+	  {
+	    if ((c & 1) != 0)
+	      c = 0xedb88320 ^ (c >>> 1);
+	    else
+	      c = c >>> 1;
+	  }
+	crc_table[n] = c;
+      }
+    return crc_table;
+  }
+
+  /**
+   * Returns the CRC32 data checksum computed so far.
+   */
+  public long getValue ()
+  {
+    return (long) crc & 0xffffffffL;
+  }
+
+  /**
+   * Resets the CRC32 data checksum as if no update was ever called.
+   */
+  public void reset () { crc = 0; }
+
+  /**
+   * Updates the checksum with the int bval. 
+   *
+   * @param bval (the byte is taken as the lower 8 bits of bval)
+   */
+
+  public void update (int bval)
+  {
+    int c = ~crc;
+    c = crc_table[(c ^ bval) & 0xff] ^ (c >>> 8);
+    crc = ~c;
+  }
+
+  /**
+   * Adds the byte array to the data checksum.
+   *
+   * @param buf the buffer which contains the data
+   * @param off the offset in the buffer where the data starts
+   * @param len the length of the data
+   */
+  public void update (byte[] buf, int off, int len)
+  {
+    int c = ~crc;
+    while (--len >= 0)
+      c = crc_table[(c ^ buf[off++]) & 0xff] ^ (c >>> 8);
+    crc = ~c;
+  }
+
+  /**
+   * Adds the complete byte array to the data checksum.
+   */
+  public void update (byte[] buf) { update(buf, 0, buf.length); }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/CheckedInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/CheckedInputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/CheckedInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/CheckedInputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,135 @@
+/* CheckedInputStream.java - Compute checksum of data being read
+   Copyright (C) 1999, 2000, 2004  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.zip;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/* Written using on-line Java Platform 1.2 API Specification
+ * and JCL book.
+ * Believed complete and correct.
+ */
+
+/**
+ * InputStream that computes a checksum of the data being read using a
+ * supplied Checksum object.
+ *
+ * @see Checksum
+ *
+ * @author Tom Tromey
+ * @date May 17, 1999
+ */
+public class CheckedInputStream extends FilterInputStream
+{
+  /**
+   * Creates a new CheckInputStream on top of the supplied OutputStream
+   * using the supplied Checksum.
+   */
+  public CheckedInputStream (InputStream in, Checksum sum)
+  {
+    super (in);
+    this.sum = sum;
+  }
+
+  /**
+   * Returns the Checksum object used. To get the data checksum computed so
+   * far call <code>getChecksum.getValue()</code>.
+   */
+  public Checksum getChecksum ()
+  {
+    return sum;
+  }
+
+  /**
+   * Reads one byte, updates the checksum and returns the read byte
+   * (or -1 when the end of file was reached).
+   */
+  public int read () throws IOException
+  {
+    int x = in.read();
+    if (x != -1)
+      sum.update(x);
+    return x;
+  }
+
+  /**
+   * Reads at most len bytes in the supplied buffer and updates the checksum
+   * with it. Returns the number of bytes actually read or -1 when the end
+   * of file was reached.
+   */
+  public int read (byte[] buf, int off, int len) throws IOException
+  {
+    int r = in.read(buf, off, len);
+    if (r != -1)
+      sum.update(buf, off, r);
+    return r;
+  }
+
+  /**
+   * Skips n bytes by reading them in a temporary buffer and updating the
+   * the checksum with that buffer. Returns the actual number of bytes skiped
+   * which can be less then requested when the end of file is reached.
+   */
+  public long skip (long n) throws IOException
+  {
+    if (n == 0)
+      return 0;
+
+    int min = (int) Math.min(n, 1024);
+    byte[] buf = new byte[min];
+
+    long s = 0;
+    while (n > 0)
+      {
+	int r = in.read(buf, 0, min);
+	if (r == -1)
+	  break;
+	n -= r;
+	s += r;
+	min = (int) Math.min(n, 1024);
+	sum.update(buf, 0, r);
+      }
+
+    return s;
+  }
+
+  /** The checksum object. */
+  private Checksum sum;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/CheckedOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/CheckedOutputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/CheckedOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/CheckedOutputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,100 @@
+/* CheckedOutputStream.java - Compute checksum of data being written.
+   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.zip;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/* Written using on-line Java Platform 1.2 API Specification
+ * and JCL book.
+ * Believed complete and correct.
+ */
+
+/**
+ * OutputStream that computes a checksum of data being written using a
+ * supplied Checksum object.
+ *
+ * @see Checksum
+ *
+ * @author Tom Tromey
+ * @date May 17, 1999
+ */
+public class CheckedOutputStream extends FilterOutputStream
+{
+  /**
+   * Creates a new CheckInputStream on top of the supplied OutputStream
+   * using the supplied Checksum.
+   */
+  public CheckedOutputStream (OutputStream out, Checksum cksum)
+  {
+    super (out);
+    this.sum = cksum;
+  }
+
+  /**
+   * Returns the Checksum object used. To get the data checksum computed so
+   * far call <code>getChecksum.getValue()</code>.
+   */
+  public Checksum getChecksum ()
+  {
+    return sum;
+  }
+
+  /**
+   * Writes one byte to the OutputStream and updates the Checksum.
+   */
+  public void write (int bval) throws IOException
+  {
+    out.write(bval);
+    sum.update(bval);
+  }
+
+  /**
+   * Writes the byte array to the OutputStream and updates the Checksum.
+   */
+  public void write (byte[] buf, int off, int len) throws IOException
+  {
+    out.write(buf, off, len);
+    sum.update(buf, off, len);
+  }
+
+  /** The checksum object. */
+  private Checksum sum;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Checksum.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Checksum.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Checksum.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Checksum.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,86 @@
+/* Checksum.java - Interface to compute a data checksum
+   Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+/*
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status:  Believed complete and correct.
+ */
+
+/**
+ * Interface to compute a data checksum used by checked input/output streams.
+ * A data checksum can be updated by one byte or with a byte array. After each
+ * update the value of the current checksum can be returned by calling
+ * <code>getValue</code>. The complete checksum object can also be reset
+ * so it can be used again with new data.
+ *
+ * @see CheckedInputStream
+ * @see CheckedOutputStream
+ *
+ * @author Per Bothner
+ * @author Jochen Hoenicke
+ */
+public interface Checksum
+{
+  /**
+   * Returns the data checksum computed so far.
+   */
+  long getValue();
+
+  /**
+   * Resets the data checksum as if no update was ever called.
+   */
+  void reset();
+
+  /**
+   * Adds one byte to the data checksum.
+   *
+   * @param bval the data value to add. The high byte of the int is ignored.
+   */
+  void update (int bval);
+
+  /**
+   * Adds the byte array to the data checksum.
+   *
+   * @param buf the buffer which contains the data
+   * @param off the offset in the buffer where the data starts
+   * @param len the length of the data
+   */
+  void update (byte[] buf, int off, int len);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DataFormatException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DataFormatException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DataFormatException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DataFormatException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* DataformatException.java -- thrown when compressed data is corrupt
+   Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+/**
+ * Exception thrown when compressed data is corrupt.
+ *
+ * @author Tom Tromey
+ * @author John Leuner
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class DataFormatException extends Exception
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = 2219632870893641452L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public DataFormatException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param msg the message
+   */
+  public DataFormatException(String msg)
+  {
+    super(msg);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Deflater.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Deflater.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Deflater.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Deflater.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,519 @@
+/* Deflater.java - Compress a data stream
+   Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+/**
+ * This is the Deflater class.  The deflater class compresses input
+ * with the deflate algorithm described in RFC 1951.  It has several
+ * compression levels and three different strategies described below.
+ * 
+ * This class is <i>not</i> thread safe.  This is inherent in the API, due
+ * to the split of deflate and setInput.
+ * 
+ * @author Jochen Hoenicke
+ * @author Tom Tromey
+ */
+public class Deflater
+{
+  /**
+   * The best and slowest compression level.  This tries to find very
+   * long and distant string repetitions.  
+   */
+  public static final int BEST_COMPRESSION = 9;
+  /**
+   * The worst but fastest compression level.  
+   */
+  public static final int BEST_SPEED = 1;
+  /**
+   * The default compression level.
+   */
+  public static final int DEFAULT_COMPRESSION = -1;
+  /**
+   * This level won't compress at all but output uncompressed blocks.
+   */
+  public static final int NO_COMPRESSION = 0;
+
+  /**
+   * The default strategy.
+   */
+  public static final int DEFAULT_STRATEGY = 0;
+  /**
+   * This strategy will only allow longer string repetitions.  It is
+   * useful for random data with a small character set.
+   */
+  public static final int FILTERED = 1;
+
+  /** 
+   * This strategy will not look for string repetitions at all.  It
+   * only encodes with Huffman trees (which means, that more common
+   * characters get a smaller encoding.  
+   */
+  public static final int HUFFMAN_ONLY = 2;
+
+  /**
+   * The compression method.  This is the only method supported so far.
+   * There is no need to use this constant at all.
+   */
+  public static final int DEFLATED = 8;
+
+  /*
+   * The Deflater can do the following state transitions:
+   *
+   * (1) -> INIT_STATE   ----> INIT_FINISHING_STATE ---.
+   *        /  | (2)      (5)                         |
+   *       /   v          (5)                         |
+   *   (3)| SETDICT_STATE ---> SETDICT_FINISHING_STATE |(3)
+   *       \   | (3)                 |        ,-------'
+   *        |  |                     | (3)   /
+   *        v  v          (5)        v      v
+   * (1) -> BUSY_STATE   ----> FINISHING_STATE
+   *                                | (6)
+   *                                v
+   *                           FINISHED_STATE
+   *    \_____________________________________/
+   *          | (7)
+   *          v
+   *        CLOSED_STATE
+   *
+   * (1) If we should produce a header we start in INIT_STATE, otherwise
+   *     we start in BUSY_STATE.
+   * (2) A dictionary may be set only when we are in INIT_STATE, then
+   *     we change the state as indicated.
+   * (3) Whether a dictionary is set or not, on the first call of deflate
+   *     we change to BUSY_STATE.
+   * (4) -- intentionally left blank -- :)
+   * (5) FINISHING_STATE is entered, when flush() is called to indicate that
+   *     there is no more INPUT.  There are also states indicating, that
+   *     the header wasn't written yet.
+   * (6) FINISHED_STATE is entered, when everything has been flushed to the
+   *     internal pending output buffer.
+   * (7) At any time (7)
+   * 
+   */
+
+  private static final int IS_SETDICT              = 0x01;
+  private static final int IS_FLUSHING             = 0x04;
+  private static final int IS_FINISHING            = 0x08;
+  
+  private static final int INIT_STATE              = 0x00;
+  private static final int SETDICT_STATE           = 0x01;
+  private static final int INIT_FINISHING_STATE    = 0x08;
+  private static final int SETDICT_FINISHING_STATE = 0x09;
+  private static final int BUSY_STATE              = 0x10;
+  private static final int FLUSHING_STATE          = 0x14;
+  private static final int FINISHING_STATE         = 0x1c;
+  private static final int FINISHED_STATE          = 0x1e;
+  private static final int CLOSED_STATE            = 0x7f;
+
+  /** Compression level. */
+  private int level;
+
+  /** should we include a header. */
+  private boolean noHeader;
+
+  /** The current state. */
+  private int state;
+
+  /** The total bytes of output written. */
+  private int totalOut;
+ 
+  /** The pending output. */
+  private DeflaterPending pending;
+
+  /** The deflater engine. */
+  private DeflaterEngine engine;
+
+  /**
+   * Creates a new deflater with default compression level.
+   */
+  public Deflater()
+  {
+    this(DEFAULT_COMPRESSION, false);
+  }
+
+  /**
+   * Creates a new deflater with given compression level.
+   * @param lvl the compression level, a value between NO_COMPRESSION
+   * and BEST_COMPRESSION, or DEFAULT_COMPRESSION.  
+   * @exception IllegalArgumentException if lvl is out of range.
+   */
+  public Deflater(int lvl)
+  {
+    this(lvl, false);
+  }
+
+  /**
+   * Creates a new deflater with given compression level.
+   * @param lvl the compression level, a value between NO_COMPRESSION
+   * and BEST_COMPRESSION.  
+   * @param nowrap true, iff we should suppress the deflate header at the
+   * beginning and the adler checksum at the end of the output.  This is
+   * useful for the GZIP format.
+   * @exception IllegalArgumentException if lvl is out of range.
+   */
+  public Deflater(int lvl, boolean nowrap)
+  {
+    if (lvl == DEFAULT_COMPRESSION)
+      lvl = 6;
+    else if (lvl < NO_COMPRESSION || lvl > BEST_COMPRESSION)
+      throw new IllegalArgumentException();
+
+    pending = new DeflaterPending();
+    engine = new DeflaterEngine(pending);
+    this.noHeader = nowrap;
+    setStrategy(DEFAULT_STRATEGY);
+    setLevel(lvl);
+    reset();
+  }
+
+  /** 
+   * Resets the deflater.  The deflater acts afterwards as if it was
+   * just created with the same compression level and strategy as it
+   * had before.  
+   */
+  public void reset() 
+  {
+    state = (noHeader ? BUSY_STATE : INIT_STATE);
+    totalOut = 0;
+    pending.reset();
+    engine.reset();
+  }
+  
+  /**
+   * Frees all objects allocated by the compressor.  There's no
+   * reason to call this, since you can just rely on garbage
+   * collection.  Exists only for compatibility against Sun's JDK,
+   * where the compressor allocates native memory.
+   * If you call any method (even reset) afterwards the behaviour is
+   * <i>undefined</i>.  
+   */
+  public void end()
+  {
+    engine = null;
+    pending = null;
+    state = CLOSED_STATE;
+  }
+
+  /** 
+   * Gets the current adler checksum of the data that was processed so
+   * far.
+   */
+  public int getAdler()
+  {
+    return engine.getAdler();
+  }
+
+  /** 
+   * Gets the number of input bytes processed so far.
+   */
+  public int getTotalIn()
+  {
+    return engine.getTotalIn();
+  }
+
+  /** 
+   * Gets the number of output bytes so far.
+   */
+  public int getTotalOut()
+  {
+    return totalOut;
+  }
+
+  /** 
+   * Finalizes this object.
+   */
+  protected void finalize()
+  {
+    /* Exists solely for compatibility.  We don't have any native state. */
+  }
+
+  /** 
+   * Flushes the current input block.  Further calls to deflate() will
+   * produce enough output to inflate everything in the current input
+   * block.  This is not part of Sun's JDK so I have made it package
+   * private.  It is used by DeflaterOutputStream to implement
+   * flush().
+   */
+  void flush() {
+    state |= IS_FLUSHING;
+  }
+
+  /** 
+   * Finishes the deflater with the current input block.  It is an error
+   * to give more input after this method was called.  This method must
+   * be called to force all bytes to be flushed.
+   */
+  public void finish() {
+    state |= IS_FLUSHING | IS_FINISHING;
+  }
+
+  /** 
+   * Returns true iff the stream was finished and no more output bytes
+   * are available.
+   */
+  public boolean finished()
+  {
+    return state == FINISHED_STATE && pending.isFlushed();
+  }
+
+  /**
+   * Returns true, if the input buffer is empty.
+   * You should then call setInput(). <br>
+   *
+   * <em>NOTE</em>: This method can also return true when the stream
+   * was finished.  
+   */
+  public boolean needsInput()
+  {
+    return engine.needsInput();
+  }
+
+  /**
+   * Sets the data which should be compressed next.  This should be only
+   * called when needsInput indicates that more input is needed.
+   * If you call setInput when needsInput() returns false, the
+   * previous input that is still pending will be thrown away.
+   * The given byte array should not be changed, before needsInput() returns
+   * true again.
+   * This call is equivalent to <code>setInput(input, 0, input.length)</code>.
+   * @param input the buffer containing the input data.
+   * @exception IllegalStateException if the buffer was finished() or ended().
+   */
+  public void setInput(byte[] input)
+  {
+    setInput(input, 0, input.length);
+  }
+
+  /**
+   * Sets the data which should be compressed next.  This should be
+   * only called when needsInput indicates that more input is needed.
+   * The given byte array should not be changed, before needsInput() returns
+   * true again.
+   * @param input the buffer containing the input data.
+   * @param off the start of the data.
+   * @param len the length of the data.  
+   * @exception IllegalStateException if the buffer was finished() or ended()
+   * or if previous input is still pending.
+   */
+  public void setInput(byte[] input, int off, int len)
+  {
+    if ((state & IS_FINISHING) != 0)
+      throw new IllegalStateException("finish()/end() already called");
+    engine.setInput(input, off, len);
+  }
+
+  /** 
+   * Sets the compression level.  There is no guarantee of the exact
+   * position of the change, but if you call this when needsInput is
+   * true the change of compression level will occur somewhere near
+   * before the end of the so far given input.  
+   * @param lvl the new compression level.
+   */
+  public void setLevel(int lvl)
+  {
+    if (lvl == DEFAULT_COMPRESSION)
+      lvl = 6;
+    else if (lvl < NO_COMPRESSION || lvl > BEST_COMPRESSION)
+      throw new IllegalArgumentException();
+
+
+    if (level != lvl)
+      {
+	level = lvl;
+	engine.setLevel(lvl);
+      }
+  }
+
+  /** 
+   * Sets the compression strategy. Strategy is one of
+   * DEFAULT_STRATEGY, HUFFMAN_ONLY and FILTERED.  For the exact
+   * position where the strategy is changed, the same as for
+   * setLevel() applies.
+   * @param stgy the new compression strategy.
+   */
+  public void setStrategy(int stgy)
+  {
+    if (stgy != DEFAULT_STRATEGY && stgy != FILTERED
+	&& stgy != HUFFMAN_ONLY)
+      throw new IllegalArgumentException();
+    engine.setStrategy(stgy);
+  }
+
+  /**
+   * Deflates the current input block to the given array.  It returns 
+   * the number of bytes compressed, or 0 if either 
+   * needsInput() or finished() returns true or length is zero.
+   * @param output the buffer where to write the compressed data.
+   */
+  public int deflate(byte[] output)
+  {
+    return deflate(output, 0, output.length);
+  }
+
+  /**
+   * Deflates the current input block to the given array.  It returns 
+   * the number of bytes compressed, or 0 if either 
+   * needsInput() or finished() returns true or length is zero.
+   * @param output the buffer where to write the compressed data.
+   * @param offset the offset into the output array.
+   * @param length the maximum number of bytes that may be written.
+   * @exception IllegalStateException if end() was called.
+   * @exception IndexOutOfBoundsException if offset and/or length
+   * don't match the array length.  
+   */
+  public int deflate(byte[] output, int offset, int length)
+  {
+    int origLength = length;
+
+    if (state == CLOSED_STATE)
+      throw new IllegalStateException("Deflater closed");
+
+    if (state < BUSY_STATE)
+      {
+	/* output header */
+	int header = (DEFLATED + 
+		      ((DeflaterConstants.MAX_WBITS - 8) << 4)) << 8;
+	int level_flags = (level - 1) >> 1;
+	if (level_flags < 0 || level_flags > 3) 
+	  level_flags = 3;
+	header |= level_flags << 6;
+	if ((state & IS_SETDICT) != 0)
+	  /* Dictionary was set */
+	  header |= DeflaterConstants.PRESET_DICT;
+	header += 31 - (header % 31);
+
+	pending.writeShortMSB(header);
+	if ((state & IS_SETDICT) != 0)
+	  {
+	    int chksum = engine.getAdler();
+	    engine.resetAdler();
+	    pending.writeShortMSB(chksum >> 16);
+	    pending.writeShortMSB(chksum & 0xffff);
+	  }
+
+	state = BUSY_STATE | (state & (IS_FLUSHING | IS_FINISHING));
+      }
+
+    for (;;)
+      {
+	int count = pending.flush(output, offset, length);
+	offset += count;
+	totalOut += count;
+	length -= count;
+	if (length == 0 || state == FINISHED_STATE)
+	  break;
+
+	if (!engine.deflate((state & IS_FLUSHING) != 0, 
+			    (state & IS_FINISHING) != 0))
+	  {
+	    if (state == BUSY_STATE)
+	      /* We need more input now */
+	      return origLength - length;
+	    else if (state == FLUSHING_STATE)
+	      {
+		if (level != NO_COMPRESSION)
+		  {
+		    /* We have to supply some lookahead.  8 bit lookahead
+		     * are needed by the zlib inflater, and we must fill 
+		     * the next byte, so that all bits are flushed.
+		     */
+		    int neededbits = 8 + ((-pending.getBitCount()) & 7);
+		    while (neededbits > 0)
+		      {
+			/* write a static tree block consisting solely of
+			 * an EOF:
+			 */
+			pending.writeBits(2, 10);
+			neededbits -= 10;
+		      }
+		  }
+		state = BUSY_STATE;
+	      }
+	    else if (state == FINISHING_STATE)
+	      {
+		pending.alignToByte();
+		/* We have completed the stream */
+		if (!noHeader)
+		  {
+		    int adler = engine.getAdler();
+		    pending.writeShortMSB(adler >> 16);
+		    pending.writeShortMSB(adler & 0xffff);
+		  }
+		state = FINISHED_STATE;
+	      }
+	  }
+      }
+
+    return origLength - length;
+  }
+
+  /**
+   * Sets the dictionary which should be used in the deflate process.
+   * This call is equivalent to <code>setDictionary(dict, 0,
+   * dict.length)</code>.  
+   * @param dict the dictionary.  
+   * @exception IllegalStateException if setInput () or deflate ()
+   * were already called or another dictionary was already set.  
+   */
+  public void setDictionary(byte[] dict)
+  {
+    setDictionary(dict, 0, dict.length);
+  }
+
+  /**
+   * Sets the dictionary which should be used in the deflate process.
+   * The dictionary should be a byte array containing strings that are
+   * likely to occur in the data which should be compressed.  The
+   * dictionary is not stored in the compressed output, only a
+   * checksum.  To decompress the output you need to supply the same
+   * dictionary again.
+   * @param dict the dictionary.
+   * @param offset an offset into the dictionary.
+   * @param length the length of the dictionary.
+   * @exception IllegalStateException if setInput () or deflate () were
+   * already called or another dictionary was already set.
+   */
+  public void setDictionary(byte[] dict, int offset, int length)
+  {
+    if (state != INIT_STATE)
+      throw new IllegalStateException();
+
+    state = SETDICT_STATE;
+    engine.setDictionary(dict, offset, length);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterConstants.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterConstants.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterConstants.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterConstants.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* java.util.zip.DeflaterConstants
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+interface DeflaterConstants
+{
+  boolean DEBUGGING = false;
+
+  int STORED_BLOCK = 0;
+  int STATIC_TREES = 1;
+  int DYN_TREES    = 2;
+  int PRESET_DICT  = 0x20;
+
+  int DEFAULT_MEM_LEVEL = 8;
+
+  int MAX_MATCH = 258;
+  int MIN_MATCH = 3;
+
+  int MAX_WBITS = 15;
+  int WSIZE = 1 << MAX_WBITS;
+  int WMASK = WSIZE - 1;
+
+  int HASH_BITS = DEFAULT_MEM_LEVEL + 7;
+  int HASH_SIZE = 1 << HASH_BITS;
+  int HASH_MASK = HASH_SIZE - 1;
+  int HASH_SHIFT = (HASH_BITS + MIN_MATCH - 1) / MIN_MATCH;
+
+  int MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;
+  int MAX_DIST = WSIZE - MIN_LOOKAHEAD;
+
+  int PENDING_BUF_SIZE = 1 << (DEFAULT_MEM_LEVEL + 8);
+  int MAX_BLOCK_SIZE = Math.min(65535, PENDING_BUF_SIZE-5);
+
+  int DEFLATE_STORED = 0;
+  int DEFLATE_FAST   = 1;
+  int DEFLATE_SLOW   = 2;
+
+  int GOOD_LENGTH[] = { 0,4, 4, 4, 4, 8,  8,  8,  32,  32 };
+  int MAX_LAZY[]    = { 0,4, 5, 6, 4,16, 16, 32, 128, 258 };
+  int NICE_LENGTH[] = { 0,8,16,32,16,32,128,128, 258, 258 };
+  int MAX_CHAIN[]   = { 0,4, 8,32,16,32,128,256,1024,4096 };
+  int COMPR_FUNC[]  = { 0,1, 1, 1, 1, 2,  2,  2,   2,   2 };
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterEngine.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterEngine.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterEngine.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterEngine.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,697 @@
+/* DeflaterEngine.java --
+   Copyright (C) 2001, 2004  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+class DeflaterEngine implements DeflaterConstants
+{
+  private static final int TOO_FAR = 4096;
+
+  private int ins_h;
+
+  /**
+   * Hashtable, hashing three characters to an index for window, so
+   * that window[index]..window[index+2] have this hash code.  
+   * Note that the array should really be unsigned short, so you need
+   * to and the values with 0xffff.
+   */
+  private short[] head;
+
+  /**
+   * prev[index & WMASK] points to the previous index that has the
+   * same hash code as the string starting at index.  This way 
+   * entries with the same hash code are in a linked list.
+   * Note that the array should really be unsigned short, so you need
+   * to and the values with 0xffff.
+   */
+  private short[] prev;
+
+  private int matchStart, matchLen;
+  private boolean prevAvailable;
+  private int blockStart;
+
+  /**
+   * strstart points to the current character in window.
+   */
+  private int strstart;
+
+  /**
+   * lookahead is the number of characters starting at strstart in
+   * window that are valid.
+   * So window[strstart] until window[strstart+lookahead-1] are valid
+   * characters.
+   */
+  private int lookahead;
+
+  /**
+   * This array contains the part of the uncompressed stream that 
+   * is of relevance.  The current character is indexed by strstart.
+   */
+  private byte[] window;
+
+  private int strategy, max_chain, max_lazy, niceLength, goodLength;
+
+  /** The current compression function. */
+  private int comprFunc;
+
+  /** The input data for compression. */
+  private byte[] inputBuf;
+
+  /** The total bytes of input read. */
+  private int totalIn;
+
+  /** The offset into inputBuf, where input data starts. */
+  private int inputOff;
+
+  /** The end offset of the input data. */
+  private int inputEnd;
+
+  private DeflaterPending pending;
+  private DeflaterHuffman huffman;
+
+  /** The adler checksum */
+  private Adler32 adler;
+
+  /* DEFLATE ALGORITHM:
+   *
+   * The uncompressed stream is inserted into the window array.  When
+   * the window array is full the first half is thrown away and the
+   * second half is copied to the beginning.
+   *
+   * The head array is a hash table.  Three characters build a hash value
+   * and they the value points to the corresponding index in window of 
+   * the last string with this hash.  The prev array implements a
+   * linked list of matches with the same hash: prev[index & WMASK] points
+   * to the previous index with the same hash.
+   * 
+   * 
+   */
+
+
+  DeflaterEngine(DeflaterPending pending) {
+    this.pending = pending;
+    huffman = new DeflaterHuffman(pending);
+    adler = new Adler32();
+
+    window = new byte[2*WSIZE];
+    head   = new short[HASH_SIZE];
+    prev   = new short[WSIZE];
+
+    /* We start at index 1, to avoid a implementation deficiency, that
+     * we cannot build a repeat pattern at index 0.
+     */
+    blockStart = strstart = 1;
+  }
+
+  public void reset()
+  {
+    huffman.reset();
+    adler.reset();
+    blockStart = strstart = 1;
+    lookahead = 0;
+    totalIn = 0;
+    prevAvailable = false;
+    matchLen = MIN_MATCH - 1;
+    for (int i = 0; i < HASH_SIZE; i++)
+      head[i] = 0;
+    for (int i = 0; i < WSIZE; i++)
+      prev[i] = 0;
+  }
+
+  public final void resetAdler()
+  {
+    adler.reset();
+  }
+
+  public final int getAdler()
+  {
+    int chksum = (int) adler.getValue();
+    return chksum;
+  }
+
+  public final int getTotalIn()
+  {
+    return totalIn;
+  }
+
+  public final void setStrategy(int strat)
+  {
+    strategy = strat;
+  }
+
+  public void setLevel(int lvl)
+  {
+    goodLength = DeflaterConstants.GOOD_LENGTH[lvl];
+    max_lazy    = DeflaterConstants.MAX_LAZY[lvl];
+    niceLength = DeflaterConstants.NICE_LENGTH[lvl];
+    max_chain   = DeflaterConstants.MAX_CHAIN[lvl];
+
+    if (DeflaterConstants.COMPR_FUNC[lvl] != comprFunc) 
+      {
+	if (DeflaterConstants.DEBUGGING)
+	  System.err.println("Change from "+comprFunc +" to "
+			     + DeflaterConstants.COMPR_FUNC[lvl]);
+	switch (comprFunc)
+	  {
+	  case DEFLATE_STORED:
+	    if (strstart > blockStart)
+	      {
+		huffman.flushStoredBlock(window, blockStart, 
+					 strstart - blockStart, false);
+		blockStart = strstart;
+	      }
+	    updateHash();
+	    break;
+	  case DEFLATE_FAST:
+	    if (strstart > blockStart)
+	      {
+		huffman.flushBlock(window, blockStart, strstart - blockStart,
+				   false);
+		blockStart = strstart;
+	      }
+	    break;
+	  case DEFLATE_SLOW:
+	    if (prevAvailable)
+	      huffman.tallyLit(window[strstart-1] & 0xff);
+	    if (strstart > blockStart)
+	      {
+		huffman.flushBlock(window, blockStart, strstart - blockStart,
+				   false);
+		blockStart = strstart;
+	      }
+	    prevAvailable = false;
+	    matchLen = MIN_MATCH - 1;
+	    break;
+	  }
+	comprFunc = COMPR_FUNC[lvl];
+      }
+  }
+
+  private void updateHash() {
+    if (DEBUGGING)
+      System.err.println("updateHash: "+strstart);
+    ins_h = (window[strstart] << HASH_SHIFT) ^ window[strstart + 1];
+  }    
+
+  /**
+   * Inserts the current string in the head hash and returns the previous
+   * value for this hash.
+   */
+  private int insertString() {
+    short match;
+    int hash = ((ins_h << HASH_SHIFT) ^ window[strstart + (MIN_MATCH -1)])
+      & HASH_MASK;
+
+    if (DEBUGGING)
+      {
+	if (hash != (((window[strstart] << (2*HASH_SHIFT))
+		      ^ (window[strstart + 1] << HASH_SHIFT)
+		      ^ (window[strstart + 2])) & HASH_MASK))
+	  throw new InternalError("hash inconsistent: "+hash+"/"
+				  +window[strstart]+","
+				  +window[strstart+1]+","
+				  +window[strstart+2]+","+HASH_SHIFT);
+      }
+
+    prev[strstart & WMASK] = match = head[hash];
+    head[hash] = (short) strstart;
+    ins_h = hash;
+    return match & 0xffff;
+  }
+
+  private void slideWindow()
+  {
+    System.arraycopy(window, WSIZE, window, 0, WSIZE);
+    matchStart -= WSIZE;
+    strstart -= WSIZE;
+    blockStart -= WSIZE;
+    
+    /* Slide the hash table (could be avoided with 32 bit values
+     * at the expense of memory usage).
+     */
+    for (int i = 0; i < HASH_SIZE; i++) 
+      {
+	int m = head[i] & 0xffff;
+	head[i] = m >= WSIZE ? (short) (m - WSIZE) : 0;
+      }
+
+    /* Slide the prev table.
+     */
+    for (int i = 0; i < WSIZE; i++) 
+      {
+	int m = prev[i] & 0xffff;
+	prev[i] = m >= WSIZE ? (short) (m - WSIZE) : 0;
+      }
+  }
+
+  /**
+   * Fill the window when the lookahead becomes insufficient.
+   * Updates strstart and lookahead.
+   *
+   * OUT assertions: strstart + lookahead <= 2*WSIZE
+   *    lookahead >= MIN_LOOKAHEAD or inputOff == inputEnd
+   */
+  private void fillWindow()
+  {
+    /* If the window is almost full and there is insufficient lookahead,
+     * move the upper half to the lower one to make room in the upper half.
+     */
+    if (strstart >= WSIZE + MAX_DIST)
+      slideWindow();
+
+    /* If there is not enough lookahead, but still some input left,
+     * read in the input
+     */
+    while (lookahead < DeflaterConstants.MIN_LOOKAHEAD && inputOff < inputEnd)
+      {
+	int more = 2*WSIZE - lookahead - strstart;
+	
+	if (more > inputEnd - inputOff)
+	  more = inputEnd - inputOff;
+
+	System.arraycopy(inputBuf, inputOff, 
+			 window, strstart + lookahead, more);
+	adler.update(inputBuf, inputOff, more);
+	inputOff += more;
+	totalIn  += more;
+	lookahead += more;
+      }
+
+    if (lookahead >= MIN_MATCH) 
+      updateHash();
+  }
+
+  /**
+   * Find the best (longest) string in the window matching the 
+   * string starting at strstart.
+   *
+   * Preconditions:
+   *    strstart + MAX_MATCH <= window.length.
+   *    
+   *
+   * @param curMatch
+   */
+  private boolean findLongestMatch(int curMatch) {
+    int chainLength = this.max_chain;
+    int niceLength = this.niceLength;
+    short[] prev = this.prev;
+    int scan  = this.strstart;
+    int match;
+    int best_end = this.strstart + matchLen;
+    int best_len = Math.max(matchLen, MIN_MATCH - 1);
+    
+    int limit = Math.max(strstart - MAX_DIST, 0);
+
+    int strend = scan + MAX_MATCH - 1;
+    byte scan_end1 = window[best_end - 1];
+    byte scan_end  = window[best_end];
+
+    /* Do not waste too much time if we already have a good match: */
+    if (best_len >= this.goodLength)
+      chainLength >>= 2;
+
+    /* Do not look for matches beyond the end of the input. This is necessary
+     * to make deflate deterministic.
+     */
+    if (niceLength > lookahead)
+      niceLength = lookahead;
+
+    if (DeflaterConstants.DEBUGGING 
+	&& strstart > 2*WSIZE - MIN_LOOKAHEAD)
+      throw new InternalError("need lookahead");
+    
+    do {
+      if (DeflaterConstants.DEBUGGING && curMatch >= strstart)
+	throw new InternalError("future match");
+      if (window[curMatch + best_len] != scan_end
+	  || window[curMatch + best_len - 1] != scan_end1
+	  || window[curMatch] != window[scan]
+	  || window[curMatch+1] != window[scan + 1])
+	continue;
+
+      match = curMatch + 2;      
+      scan += 2;
+
+      /* We check for insufficient lookahead only every 8th comparison;
+       * the 256th check will be made at strstart+258.
+       */
+      while (window[++scan] == window[++match]
+	     && window[++scan] == window[++match]
+	     && window[++scan] == window[++match]
+	     && window[++scan] == window[++match]
+	     && window[++scan] == window[++match]
+	     && window[++scan] == window[++match]
+	     && window[++scan] == window[++match]
+	     && window[++scan] == window[++match]
+	     && scan < strend);
+
+      if (scan > best_end) {
+//  	if (DeflaterConstants.DEBUGGING && ins_h == 0)
+//  	  System.err.println("Found match: "+curMatch+"-"+(scan-strstart));
+	matchStart = curMatch;
+	best_end = scan;
+	best_len = scan - strstart;
+	if (best_len >= niceLength)
+	  break;
+
+	scan_end1  = window[best_end-1];
+	scan_end   = window[best_end];
+      }
+      scan = strstart;
+    } while ((curMatch = (prev[curMatch & WMASK] & 0xffff)) > limit
+	     && --chainLength != 0);
+
+    matchLen = Math.min(best_len, lookahead);
+    return matchLen >= MIN_MATCH;
+  }
+
+  void setDictionary(byte[] buffer, int offset, int length) {
+    if (DeflaterConstants.DEBUGGING && strstart != 1)
+      throw new IllegalStateException("strstart not 1");
+    adler.update(buffer, offset, length);
+    if (length < MIN_MATCH)
+      return;
+    if (length > MAX_DIST) {
+      offset += length - MAX_DIST;
+      length = MAX_DIST;
+    }
+
+    System.arraycopy(buffer, offset, window, strstart, length);
+
+    updateHash();
+    length--;
+    while (--length > 0)
+      {
+	insertString();
+	strstart++;
+      }
+    strstart += 2;
+    blockStart = strstart;
+  }    
+    
+  private boolean deflateStored(boolean flush, boolean finish)
+  {
+    if (!flush && lookahead == 0)
+      return false;
+
+    strstart += lookahead;
+    lookahead = 0;
+
+    int storedLen = strstart - blockStart;
+
+    if ((storedLen >= DeflaterConstants.MAX_BLOCK_SIZE) 
+	/* Block is full */
+	|| (blockStart < WSIZE && storedLen >= MAX_DIST)
+	/* Block may move out of window */
+	|| flush)
+      {
+	boolean lastBlock = finish;
+	if (storedLen > DeflaterConstants.MAX_BLOCK_SIZE)
+	  {
+	    storedLen = DeflaterConstants.MAX_BLOCK_SIZE;
+	    lastBlock = false;
+	  }
+
+	if (DeflaterConstants.DEBUGGING)
+	  System.err.println("storedBlock["+storedLen+","+lastBlock+"]");
+
+	huffman.flushStoredBlock(window, blockStart, storedLen, lastBlock);
+	blockStart += storedLen;
+	return !lastBlock;
+      }
+    return true;
+  }
+
+  private boolean deflateFast(boolean flush, boolean finish)
+  {
+    if (lookahead < MIN_LOOKAHEAD && !flush)
+      return false;
+
+    while (lookahead >= MIN_LOOKAHEAD || flush)
+      {
+	if (lookahead == 0)
+	  {
+	    /* We are flushing everything */
+	    huffman.flushBlock(window, blockStart, strstart - blockStart,
+			       finish);
+	    blockStart = strstart;
+	    return false;
+	  }
+
+	if (strstart > 2 * WSIZE - MIN_LOOKAHEAD)
+	  {
+	    /* slide window, as findLongestMatch need this.
+	     * This should only happen when flushing and the window
+	     * is almost full.
+	     */
+	    slideWindow();
+	  }
+
+	int hashHead;
+	if (lookahead >= MIN_MATCH 
+	    && (hashHead = insertString()) != 0
+	    && strategy != Deflater.HUFFMAN_ONLY
+	    && strstart - hashHead <= MAX_DIST
+	    && findLongestMatch(hashHead))
+	  {
+	    /* longestMatch sets matchStart and matchLen */
+	    if (DeflaterConstants.DEBUGGING)
+	      {
+		for (int i = 0 ; i < matchLen; i++)
+		  {
+		    if (window[strstart+i] != window[matchStart + i])
+		      throw new InternalError();
+		  }
+	      }
+	    boolean full = huffman.tallyDist(strstart - matchStart, matchLen);
+	    
+	    lookahead -= matchLen;
+	    if (matchLen <= max_lazy && lookahead >= MIN_MATCH)
+	      {
+		while (--matchLen > 0)
+		  {
+		    strstart++;
+		    insertString();
+		  }
+		strstart++;
+	      }
+	    else
+	      {
+		strstart += matchLen;
+		if (lookahead >= MIN_MATCH - 1)
+		  updateHash();
+	      }
+	    matchLen = MIN_MATCH - 1;
+	    if (!full)
+	      continue;
+	  }
+	else
+	  {
+	    /* No match found */
+	    huffman.tallyLit(window[strstart] & 0xff);
+	    strstart++;
+	    lookahead--;
+	  }
+
+	if (huffman.isFull())
+	  {
+	    boolean lastBlock = finish && lookahead == 0;
+	    huffman.flushBlock(window, blockStart, strstart - blockStart,
+			       lastBlock);
+	    blockStart = strstart;
+	    return !lastBlock;
+	  }
+      }
+    return true;
+  }
+
+  private boolean deflateSlow(boolean flush, boolean finish)
+  {
+    if (lookahead < MIN_LOOKAHEAD && !flush)
+      return false;
+
+    while (lookahead >= MIN_LOOKAHEAD || flush)
+      {
+	if (lookahead == 0)
+	  {
+	    if (prevAvailable)
+	      huffman.tallyLit(window[strstart-1] & 0xff);
+	    prevAvailable = false;
+
+	    /* We are flushing everything */
+	    if (DeflaterConstants.DEBUGGING && !flush)
+	      throw new InternalError("Not flushing, but no lookahead");
+	    huffman.flushBlock(window, blockStart, strstart - blockStart,
+			       finish);
+	    blockStart = strstart;
+	    return false;
+	  }
+
+	if (strstart >= 2 * WSIZE - MIN_LOOKAHEAD)
+	  {
+	    /* slide window, as findLongestMatch need this.
+	     * This should only happen when flushing and the window
+	     * is almost full.
+	     */
+	    slideWindow();
+	  }
+
+	int prevMatch = matchStart;
+	int prevLen = matchLen;
+	if (lookahead >= MIN_MATCH)
+	  {
+	    int hashHead = insertString();
+	    if (strategy != Deflater.HUFFMAN_ONLY
+		&& hashHead != 0 && strstart - hashHead <= MAX_DIST
+		&& findLongestMatch(hashHead))
+	      {
+		/* longestMatch sets matchStart and matchLen */
+		
+		/* Discard match if too small and too far away */
+		if (matchLen <= 5
+		    && (strategy == Deflater.FILTERED
+			|| (matchLen == MIN_MATCH
+			    && strstart - matchStart > TOO_FAR))) {
+		  matchLen = MIN_MATCH - 1;
+		}
+	      }
+	  }
+	
+	/* previous match was better */
+	if (prevLen >= MIN_MATCH && matchLen <= prevLen)
+	  {
+	    if (DeflaterConstants.DEBUGGING)
+	      {
+		for (int i = 0 ; i < matchLen; i++)
+		  {
+		    if (window[strstart-1+i] != window[prevMatch + i])
+		      throw new InternalError();
+		  }
+	      }
+	    huffman.tallyDist(strstart - 1 - prevMatch, prevLen);
+	    prevLen -= 2;
+	    do 
+	      {
+		strstart++;
+		lookahead--;
+		if (lookahead >= MIN_MATCH)
+		  insertString();
+	      }
+	    while (--prevLen > 0);
+	    strstart ++;
+	    lookahead--;
+	    prevAvailable = false;
+	    matchLen = MIN_MATCH - 1;
+	  }
+	else
+	  {
+	    if (prevAvailable)
+	      huffman.tallyLit(window[strstart-1] & 0xff);
+	    prevAvailable = true;
+	    strstart++;
+	    lookahead--;
+	  }
+
+	if (huffman.isFull())
+	  {
+	    int len = strstart - blockStart;
+	    if (prevAvailable)
+	      len--;
+	    boolean lastBlock = (finish && lookahead == 0 && !prevAvailable);
+	    huffman.flushBlock(window, blockStart, len, lastBlock);
+	    blockStart += len;
+	    return !lastBlock;
+	  }
+      }
+    return true;
+  } 
+
+  public boolean deflate(boolean flush, boolean finish) 
+  {
+    boolean progress;
+    do
+      {
+	fillWindow();
+	boolean canFlush = flush && inputOff == inputEnd;
+	if (DeflaterConstants.DEBUGGING)
+	  System.err.println("window: ["+blockStart+","+strstart+","
+			     +lookahead+"], "+comprFunc+","+canFlush);
+	switch (comprFunc)
+	  {
+	  case DEFLATE_STORED:
+	    progress = deflateStored(canFlush, finish);
+	    break;
+	  case DEFLATE_FAST:
+	    progress = deflateFast(canFlush, finish);
+	    break;
+	  case DEFLATE_SLOW:
+	    progress = deflateSlow(canFlush, finish);
+	    break;
+	  default:
+	    throw new InternalError();
+	  }
+      }
+    while (pending.isFlushed()  /* repeat while we have no pending output */
+	   && progress);        /* and progress was made */
+
+    return progress;
+  }
+
+  public void setInput(byte[] buf, int off, int len)
+  {
+    if (inputOff < inputEnd)
+      throw new IllegalStateException
+	("Old input was not completely processed");
+
+    int end = off + len;
+
+    /* We want to throw an ArrayIndexOutOfBoundsException early.  The
+     * check is very tricky: it also handles integer wrap around.  
+     */
+    if (0 > off || off > end || end > buf.length)
+      throw new ArrayIndexOutOfBoundsException();
+
+    inputBuf = buf;
+    inputOff = off;
+    inputEnd = end;
+  }
+
+  public final boolean needsInput()
+  {
+    return inputEnd == inputOff;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterHuffman.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterHuffman.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterHuffman.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterHuffman.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,776 @@
+/* DeflaterHuffman.java --
+   Copyright (C) 2001, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+/**
+ * This is the DeflaterHuffman class.
+ *
+ * This class is <i>not</i> thread safe.  This is inherent in the API, due
+ * to the split of deflate and setInput.
+ *
+ * @author Jochen Hoenicke
+ * @date Jan 6, 2000 
+ */
+class DeflaterHuffman
+{
+  private static final int BUFSIZE = 1 << (DeflaterConstants.DEFAULT_MEM_LEVEL + 6);
+  private static final int LITERAL_NUM = 286;
+  private static final int DIST_NUM = 30;
+  private static final int BITLEN_NUM = 19;
+  private static final int REP_3_6    = 16;
+  private static final int REP_3_10   = 17;
+  private static final int REP_11_138 = 18;
+  private static final int EOF_SYMBOL = 256;
+  private static final int[] BL_ORDER =
+  { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
+
+  private static final String bit4Reverse =
+    "\000\010\004\014\002\012\006\016\001\011\005\015\003\013\007\017";
+
+  class Tree {
+    short[] freqs;
+    short[] codes;
+    byte[]  length;
+    int[]   bl_counts;
+    int     minNumCodes, numCodes;
+    int     maxLength;
+
+    Tree(int elems, int minCodes, int maxLength) {
+      this.minNumCodes = minCodes;
+      this.maxLength  = maxLength;
+      freqs  = new short[elems];
+      bl_counts = new int[maxLength];
+    }
+
+    void reset() {
+      for (int i = 0; i < freqs.length; i++)
+	freqs[i] = 0;
+      codes = null;
+      length = null;
+    }
+
+    final void writeSymbol(int code)
+    {
+      if (DeflaterConstants.DEBUGGING)
+ 	{
+ 	  freqs[code]--;
+//  	  System.err.print("writeSymbol("+freqs.length+","+code+"): ");
+ 	}
+      pending.writeBits(codes[code] & 0xffff, length[code]);
+    }
+
+    final void checkEmpty()
+    {
+      boolean empty = true;
+      for (int i = 0; i < freqs.length; i++)
+	if (freqs[i] != 0)
+	  {
+	    System.err.println("freqs["+i+"] == "+freqs[i]);
+	    empty = false;
+	  }
+      if (!empty)
+	throw new InternalError();
+      System.err.println("checkEmpty suceeded!");
+    }
+
+    void setStaticCodes(short[] stCodes, byte[] stLength)
+    {
+      codes = stCodes;
+      length = stLength;
+    }
+
+    public void buildCodes() {
+      int[] nextCode = new int[maxLength];
+      int code = 0;
+      codes = new short[freqs.length];
+
+      if (DeflaterConstants.DEBUGGING)
+	System.err.println("buildCodes: "+freqs.length);
+      for (int bits = 0; bits < maxLength; bits++) 
+	{
+	  nextCode[bits] = code;
+	  code += bl_counts[bits] << (15 - bits);
+	  if (DeflaterConstants.DEBUGGING)
+	    System.err.println("bits: "+(bits+1)+" count: "+bl_counts[bits]
+			       +" nextCode: "+Integer.toHexString(code));
+	}
+      if (DeflaterConstants.DEBUGGING && code != 65536)
+	throw new RuntimeException("Inconsistent bl_counts!");
+      
+      for (int i=0; i < numCodes; i++)
+	{
+	  int bits = length[i];
+	  if (bits > 0)
+	    {
+	      if (DeflaterConstants.DEBUGGING)
+		System.err.println("codes["+i+"] = rev("
+				   +Integer.toHexString(nextCode[bits-1])+"),"
+				   +bits);
+	      codes[i] = bitReverse(nextCode[bits-1]);
+	      nextCode[bits-1] += 1 << (16 - bits);
+	    }
+	}
+    }
+
+    private void buildLength(int childs[])
+    {
+      this.length = new byte [freqs.length];
+      int numNodes = childs.length / 2;
+      int numLeafs = (numNodes + 1) / 2;
+      int overflow = 0;
+      
+      for (int i = 0; i < maxLength; i++)
+	bl_counts[i] = 0;
+
+      /* First calculate optimal bit lengths */
+      int lengths[] = new int[numNodes];
+      lengths[numNodes-1] = 0;
+      for (int i = numNodes - 1; i >= 0; i--)
+	{
+	  if (childs[2*i+1] != -1)
+	    {
+	      int bitLength = lengths[i] + 1;
+	      if (bitLength > maxLength)
+		{
+		  bitLength = maxLength;
+		  overflow++;
+		}
+	      lengths[childs[2*i]] = lengths[childs[2*i+1]] = bitLength;
+	    }
+	  else
+	    {
+	      /* A leaf node */
+	      int bitLength = lengths[i];
+	      bl_counts[bitLength - 1]++;
+	      this.length[childs[2*i]] = (byte) lengths[i];
+	    }
+	}
+      
+      if (DeflaterConstants.DEBUGGING)
+	{
+	  System.err.println("Tree "+freqs.length+" lengths:");
+	  for (int i=0; i < numLeafs; i++)
+	    System.err.println("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]]
+			       + " len: "+length[childs[2*i]]);
+	}
+      
+      if (overflow == 0)
+	return;
+      
+      int incrBitLen = maxLength - 1;
+      do
+	{
+	  /* Find the first bit length which could increase: */
+	  while (bl_counts[--incrBitLen] == 0)
+	    ;
+	  
+	  /* Move this node one down and remove a corresponding
+	   * amount of overflow nodes.
+	   */
+	  do
+	    {
+	      bl_counts[incrBitLen]--;
+	      bl_counts[++incrBitLen]++;
+	      overflow -= 1 << (maxLength - 1 - incrBitLen);
+	    }
+	  while (overflow > 0 && incrBitLen < maxLength - 1);
+	}
+      while (overflow > 0);
+
+      /* We may have overshot above.  Move some nodes from maxLength to
+       * maxLength-1 in that case.
+       */
+      bl_counts[maxLength-1] += overflow;
+      bl_counts[maxLength-2] -= overflow;
+      
+      /* Now recompute all bit lengths, scanning in increasing
+       * frequency.  It is simpler to reconstruct all lengths instead of
+       * fixing only the wrong ones. This idea is taken from 'ar'
+       * written by Haruhiko Okumura.
+       *
+       * The nodes were inserted with decreasing frequency into the childs
+       * array.
+       */
+      int nodePtr = 2 * numLeafs;
+      for (int bits = maxLength; bits != 0; bits--) 
+	{
+	  int n = bl_counts[bits-1];
+	  while (n > 0) 
+	    {
+	      int childPtr = 2*childs[nodePtr++];
+	      if (childs[childPtr + 1] == -1)
+		{
+		  /* We found another leaf */
+		  length[childs[childPtr]] = (byte) bits;
+		  n--;
+		}
+	    }
+	}
+      if (DeflaterConstants.DEBUGGING)
+	{
+	  System.err.println("*** After overflow elimination. ***");
+	  for (int i=0; i < numLeafs; i++)
+	    System.err.println("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]]
+			       + " len: "+length[childs[2*i]]);
+	}
+    }
+    
+    void buildTree() 
+    {
+      int numSymbols = freqs.length;
+
+      /* heap is a priority queue, sorted by frequency, least frequent
+       * nodes first.  The heap is a binary tree, with the property, that
+       * the parent node is smaller than both child nodes.  This assures
+       * that the smallest node is the first parent.
+       *
+       * The binary tree is encoded in an array:  0 is root node and
+       * the nodes 2*n+1, 2*n+2 are the child nodes of node n.
+       */
+      int[] heap = new int[numSymbols];
+      int heapLen = 0;
+      int maxCode = 0;
+      for (int n = 0; n < numSymbols; n++)
+	{
+	  int freq = freqs[n];
+	  if (freq != 0)
+	    {
+	      /* Insert n into heap */
+	      int pos = heapLen++;
+	      int ppos;
+	      while (pos > 0 &&
+		     freqs[heap[ppos = (pos - 1) / 2]] > freq) {
+		heap[pos] = heap[ppos];
+		pos = ppos;
+	      }
+	      heap[pos] = n;
+	      maxCode = n;
+	    }
+	}
+      
+      /* We could encode a single literal with 0 bits but then we
+       * don't see the literals.  Therefore we force at least two
+       * literals to avoid this case.  We don't care about order in
+       * this case, both literals get a 1 bit code.  
+       */
+      while (heapLen < 2)
+	{
+	  int node = maxCode < 2 ? ++maxCode : 0;
+	  heap[heapLen++] = node;
+	}
+
+      numCodes = Math.max(maxCode + 1, minNumCodes);
+      
+      int numLeafs = heapLen;
+      int[] childs = new int[4*heapLen - 2];
+      int[] values = new int[2*heapLen - 1];
+      int numNodes = numLeafs;
+      for (int i = 0; i < heapLen; i++)
+	{
+	  int node = heap[i];
+	  childs[2*i]   = node;
+	  childs[2*i+1] = -1;
+	  values[i] = freqs[node] << 8;
+	  heap[i] = i;
+	}
+      
+      /* Construct the Huffman tree by repeatedly combining the least two
+       * frequent nodes.
+       */
+      do
+	{
+	  int first = heap[0];
+	  int last  = heap[--heapLen];
+	  
+	  /* Propagate the hole to the leafs of the heap */
+	  int ppos = 0;
+	  int path = 1;
+	  while (path < heapLen)
+	    {
+	      if (path + 1 < heapLen 
+		  && values[heap[path]] > values[heap[path+1]])
+		path++;
+	      
+	      heap[ppos] = heap[path];
+	      ppos = path;
+	      path = path * 2 + 1;
+	    }
+	  
+	  /* Now propagate the last element down along path.  Normally
+	   * it shouldn't go too deep.
+	   */
+	  int lastVal = values[last];
+	  while ((path = ppos) > 0
+		 && values[heap[ppos = (path - 1)/2]] > lastVal)
+	    heap[path] = heap[ppos];
+	  heap[path] = last;
+	  
+	  
+	  int second = heap[0];
+	  
+	  /* Create a new node father of first and second */
+	  last = numNodes++;
+	  childs[2*last] = first;
+	  childs[2*last+1] = second;
+	  int mindepth = Math.min(values[first] & 0xff, values[second] & 0xff);
+	  values[last] = lastVal = values[first] + values[second] - mindepth + 1;
+	  
+	  /* Again, propagate the hole to the leafs */
+	  ppos = 0;
+	  path = 1;
+	  while (path < heapLen)
+	    {
+	      if (path + 1 < heapLen 
+		  && values[heap[path]] > values[heap[path+1]])
+		path++;
+	      
+	      heap[ppos] = heap[path];
+	      ppos = path;
+	      path = ppos * 2 + 1;
+	    }
+	  
+	  /* Now propagate the new element down along path */
+	  while ((path = ppos) > 0
+		 && values[heap[ppos = (path - 1)/2]] > lastVal)
+	    heap[path] = heap[ppos];
+	  heap[path] = last;
+	}
+      while (heapLen > 1);
+      
+      if (heap[0] != childs.length / 2 - 1)
+	throw new RuntimeException("Weird!");
+      
+      buildLength(childs);
+    }
+
+    int getEncodedLength() 
+    {
+      int len = 0;
+      for (int i = 0; i < freqs.length; i++)
+	len += freqs[i] * length[i];
+      return len;
+    }
+
+    void calcBLFreq(Tree blTree) {
+      int max_count;               /* max repeat count */
+      int min_count;               /* min repeat count */
+      int count;                   /* repeat count of the current code */
+      int curlen = -1;             /* length of current code */
+      
+      int i = 0;
+      while (i < numCodes)
+	{
+	  count = 1;
+	  int nextlen = length[i];
+	  if (nextlen == 0) 
+	    {
+	      max_count = 138;
+	      min_count = 3;
+	    }
+	  else
+	    {
+	      max_count = 6;
+	      min_count = 3;
+	      if (curlen != nextlen)
+		{
+		  blTree.freqs[nextlen]++;
+		  count = 0;
+		}
+	    }
+	  curlen = nextlen;
+	  i++;
+
+	  while (i < numCodes && curlen == length[i])
+	    {
+	      i++;
+	      if (++count >= max_count)
+		break;
+	    }
+
+	  if (count < min_count)
+	    blTree.freqs[curlen] += count;
+	  else if (curlen != 0)
+	    blTree.freqs[REP_3_6]++;
+	  else if (count <= 10)
+	    blTree.freqs[REP_3_10]++;
+	  else
+	    blTree.freqs[REP_11_138]++;
+	}
+    }
+
+    void writeTree(Tree blTree)
+    {
+      int max_count;               /* max repeat count */
+      int min_count;               /* min repeat count */
+      int count;                   /* repeat count of the current code */
+      int curlen = -1;             /* length of current code */
+      
+      int i = 0;
+      while (i < numCodes)
+	{
+	  count = 1;
+	  int nextlen = length[i];
+	  if (nextlen == 0) 
+	    {
+	      max_count = 138;
+	      min_count = 3;
+	    }
+	  else
+	    {
+	      max_count = 6;
+	      min_count = 3;
+	      if (curlen != nextlen)
+		{
+		  blTree.writeSymbol(nextlen);
+		  count = 0;
+		}
+	    }
+	  curlen = nextlen;
+	  i++;
+
+	  while (i < numCodes && curlen == length[i])
+	    {
+	      i++;
+	      if (++count >= max_count)
+		break;
+	    }
+
+	  if (count < min_count)
+	    {
+	      while (count-- > 0)
+		blTree.writeSymbol(curlen);
+	    }
+	  else if (curlen != 0)
+	    {
+	      blTree.writeSymbol(REP_3_6);
+	      pending.writeBits(count - 3, 2);
+	    }
+	  else if (count <= 10)
+	    {
+	      blTree.writeSymbol(REP_3_10);
+	      pending.writeBits(count - 3, 3);
+	    }
+	  else
+	    {
+	      blTree.writeSymbol(REP_11_138);
+	      pending.writeBits(count - 11, 7);
+	    }
+	}
+    }
+  }
+
+
+
+  DeflaterPending pending;
+  private Tree literalTree, distTree, blTree;
+
+  private short d_buf[];
+  private byte l_buf[];
+  private int last_lit;
+  private int extra_bits;
+
+  private static short staticLCodes[];
+  private static byte  staticLLength[];
+  private static short staticDCodes[];
+  private static byte  staticDLength[];
+
+  /**
+   * Reverse the bits of a 16 bit value.
+   */
+  static short bitReverse(int value) {
+    return (short) (bit4Reverse.charAt(value & 0xf) << 12
+		    | bit4Reverse.charAt((value >> 4) & 0xf) << 8
+		    | bit4Reverse.charAt((value >> 8) & 0xf) << 4
+		    | bit4Reverse.charAt(value >> 12));
+  }
+
+  static {
+    /* See RFC 1951 3.2.6 */
+    /* Literal codes */
+    staticLCodes = new short[LITERAL_NUM];
+    staticLLength = new byte[LITERAL_NUM];
+    int i = 0;
+    while (i < 144) {
+      staticLCodes[i] = bitReverse((0x030 + i) << 8);
+      staticLLength[i++] = 8;
+    }
+    while (i < 256) {
+      staticLCodes[i] = bitReverse((0x190 - 144 + i) << 7);
+      staticLLength[i++] = 9;
+    }
+    while (i < 280) {
+      staticLCodes[i] = bitReverse((0x000 - 256 + i) << 9);
+      staticLLength[i++] = 7;
+    }
+    while (i < LITERAL_NUM) {
+      staticLCodes[i] = bitReverse((0x0c0 - 280 + i)  << 8);
+      staticLLength[i++] = 8;
+    }
+
+    /* Distant codes */
+    staticDCodes = new short[DIST_NUM];
+    staticDLength = new byte[DIST_NUM];
+    for (i = 0; i < DIST_NUM; i++) {
+      staticDCodes[i] = bitReverse(i << 11);
+      staticDLength[i] = 5;
+    }
+  }
+    
+  public DeflaterHuffman(DeflaterPending pending) 
+  {
+    this.pending = pending;
+
+    literalTree = new Tree(LITERAL_NUM, 257, 15);
+    distTree    = new Tree(DIST_NUM, 1, 15);
+    blTree      = new Tree(BITLEN_NUM, 4, 7);
+
+    d_buf = new short[BUFSIZE];
+    l_buf = new byte [BUFSIZE];
+  }
+
+  public final void reset() {
+    last_lit = 0;
+    extra_bits = 0;
+    literalTree.reset();
+    distTree.reset();
+    blTree.reset();
+  }
+
+  private int l_code(int len) {
+    if (len == 255)
+      return 285;
+
+    int code = 257;
+    while (len >= 8)
+      {
+	code += 4;
+	len >>= 1;
+      }
+    return code + len;
+  }
+
+  private int d_code(int distance) {
+    int code = 0;
+    while (distance >= 4)
+      {
+	code += 2;
+	distance >>= 1;
+      }
+    return code + distance;
+  }
+
+  public void sendAllTrees(int blTreeCodes) {
+    blTree.buildCodes();
+    literalTree.buildCodes();
+    distTree.buildCodes();
+    pending.writeBits(literalTree.numCodes - 257, 5);
+    pending.writeBits(distTree.numCodes - 1, 5);
+    pending.writeBits(blTreeCodes - 4, 4);
+    for (int rank = 0; rank < blTreeCodes; rank++)
+      pending.writeBits(blTree.length[BL_ORDER[rank]], 3);
+    literalTree.writeTree(blTree);
+    distTree.writeTree(blTree);
+    if (DeflaterConstants.DEBUGGING)
+      blTree.checkEmpty();
+  }
+
+  public void compressBlock() {
+    for (int i = 0; i < last_lit; i++) 
+      {
+	int litlen = l_buf[i] & 0xff;
+	int dist = d_buf[i];
+	if (dist-- != 0)
+	  {
+	    if (DeflaterConstants.DEBUGGING)
+	      System.err.print("["+(dist+1)+","+(litlen+3)+"]: ");
+
+	    int lc = l_code(litlen);
+	    literalTree.writeSymbol(lc);
+
+	    int bits = (lc - 261) / 4;
+	    if (bits > 0 && bits <= 5)
+	      pending.writeBits(litlen & ((1 << bits) - 1), bits);
+
+	    int dc = d_code(dist);
+	    distTree.writeSymbol(dc);
+
+	    bits = dc / 2 - 1;
+	    if (bits > 0)
+	      pending.writeBits(dist & ((1 << bits) - 1), bits);
+	  }
+	else
+	  {
+	    if (DeflaterConstants.DEBUGGING)
+	      {
+		if (litlen > 32 && litlen < 127)
+		  System.err.print("("+(char)litlen+"): ");
+		else
+		  System.err.print("{"+litlen+"}: ");
+	      }
+	    literalTree.writeSymbol(litlen);
+	  }
+      }
+    if (DeflaterConstants.DEBUGGING)
+      System.err.print("EOF: ");
+    literalTree.writeSymbol(EOF_SYMBOL);
+    if (DeflaterConstants.DEBUGGING)
+      {
+	literalTree.checkEmpty();
+	distTree.checkEmpty();
+      }
+  }
+
+  public void flushStoredBlock(byte[] stored, 
+			       int stored_offset, int stored_len,
+			       boolean lastBlock) {
+    if (DeflaterConstants.DEBUGGING)
+      System.err.println("Flushing stored block "+ stored_len);
+    pending.writeBits((DeflaterConstants.STORED_BLOCK << 1)
+		      + (lastBlock ? 1 : 0), 3);
+    pending.alignToByte();
+    pending.writeShort(stored_len);
+    pending.writeShort(~stored_len);
+    pending.writeBlock(stored, stored_offset, stored_len);
+    reset();
+  }
+
+  public void flushBlock(byte[] stored, int stored_offset, int stored_len,
+			 boolean lastBlock) {
+    literalTree.freqs[EOF_SYMBOL]++;
+
+    /* Build trees */
+    literalTree.buildTree();
+    distTree.buildTree();
+
+    /* Calculate bitlen frequency */
+    literalTree.calcBLFreq(blTree);
+    distTree.calcBLFreq(blTree);
+
+    /* Build bitlen tree */
+    blTree.buildTree();
+
+    int blTreeCodes = 4;
+    for (int i = 18; i > blTreeCodes; i--)
+      {
+	if (blTree.length[BL_ORDER[i]] > 0)
+	  blTreeCodes = i+1;
+      }
+    int opt_len = 14 + blTreeCodes * 3 + blTree.getEncodedLength()
+      + literalTree.getEncodedLength() + distTree.getEncodedLength()
+      + extra_bits;
+
+    int static_len = extra_bits;
+    for (int i = 0; i < LITERAL_NUM; i++)
+      static_len += literalTree.freqs[i] * staticLLength[i];
+    for (int i = 0; i < DIST_NUM; i++)
+      static_len += distTree.freqs[i] * staticDLength[i];
+    if (opt_len >= static_len)
+      {
+	/* Force static trees */
+	opt_len = static_len;
+      }
+
+    if (stored_offset >= 0 && stored_len+4 < opt_len >> 3)
+      {
+	/* Store Block */
+	if (DeflaterConstants.DEBUGGING)
+	  System.err.println("Storing, since " + stored_len + " < " + opt_len
+			     + " <= " + static_len);
+	flushStoredBlock(stored, stored_offset, stored_len, lastBlock);
+      }
+    else if (opt_len == static_len)
+      {
+	/* Encode with static tree */
+	pending.writeBits((DeflaterConstants.STATIC_TREES << 1)
+			  + (lastBlock ? 1 : 0), 3);
+	literalTree.setStaticCodes(staticLCodes, staticLLength);
+	distTree.setStaticCodes(staticDCodes, staticDLength);
+	compressBlock();
+	reset();
+      }
+    else
+      {
+	/* Encode with dynamic tree */
+	pending.writeBits((DeflaterConstants.DYN_TREES << 1)
+			  + (lastBlock ? 1 : 0), 3);
+	sendAllTrees(blTreeCodes);
+	compressBlock();
+	reset();
+      }
+  }
+
+  public final boolean isFull()
+  {
+    return last_lit == BUFSIZE;
+  }
+
+  public final boolean tallyLit(int lit) 
+  {
+    if (DeflaterConstants.DEBUGGING)
+      {
+	if (lit > 32 && lit < 127)
+	  System.err.println("("+(char)lit+")");
+	else
+	  System.err.println("{"+lit+"}");
+      }
+    d_buf[last_lit] = 0;
+    l_buf[last_lit++] = (byte) lit;
+    literalTree.freqs[lit]++;
+    return last_lit == BUFSIZE;
+  }
+
+  public final boolean tallyDist(int dist, int len) 
+  {
+    if (DeflaterConstants.DEBUGGING)
+      System.err.println("["+dist+","+len+"]");
+
+    d_buf[last_lit] = (short) dist;
+    l_buf[last_lit++] = (byte) (len - 3);
+
+    int lc = l_code(len-3);
+    literalTree.freqs[lc]++;
+    if (lc >= 265 && lc < 285)
+      extra_bits += (lc - 261) / 4;
+
+    int dc = d_code(dist-1);
+    distTree.freqs[dc]++;
+    if (dc >= 4)
+      extra_bits += dc / 2 - 1;
+    return last_lit == BUFSIZE;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterOutputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterOutputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,198 @@
+/* DeflaterOutputStream.java - Output filter for compressing.
+   Copyright (C) 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.zip;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/* Written using on-line Java Platform 1.2 API Specification
+ * and JCL book.
+ * Believed complete and correct.
+ */
+
+/**
+ * This is a special FilterOutputStream deflating the bytes that are
+ * written through it.  It uses the Deflater for deflating.
+ *
+ * A special thing to be noted is that flush() doesn't flush
+ * everything in Sun's JDK, but it does so in jazzlib. This is because
+ * Sun's Deflater doesn't have a way to flush() everything, without
+ * finishing the stream.
+ *
+ * @author Tom Tromey, Jochen Hoenicke
+ * @date Jan 11, 2001 
+ */
+public class DeflaterOutputStream extends FilterOutputStream
+{
+  /** 
+   * This buffer is used temporarily to retrieve the bytes from the
+   * deflater and write them to the underlying output stream.  
+   */
+  protected byte[] buf;
+
+  /** 
+   * The deflater which is used to deflate the stream.
+   */
+  protected Deflater def;
+  
+  /**
+   * Deflates everything in the def's input buffers.  This will call
+   * <code>def.deflate()</code> until all bytes from the input buffers
+   * are processed.
+   */
+  protected void deflate() throws IOException
+  {
+    while (! def.needsInput())
+      {
+	int len = def.deflate(buf, 0, buf.length);
+
+	//	System.err.println("DOS deflated " + len + " out of " + buf.length);
+	if (len <= 0)
+	  break;
+	out.write(buf, 0, len);
+      }
+
+    if (! def.needsInput())
+      throw new InternalError("Can't deflate all input?");
+  }
+
+  /** 
+   * Creates a new DeflaterOutputStream with a default Deflater and
+   * default buffer size.
+   * @param out the output stream where deflated output should be written.
+   */
+  public DeflaterOutputStream(OutputStream out)
+  {
+    this(out, new Deflater(), 4096);
+  }
+
+  /** 
+   * Creates a new DeflaterOutputStream with the given Deflater and
+   * default buffer size.
+   * @param out the output stream where deflated output should be written.
+   * @param defl the underlying deflater.
+   */
+  public DeflaterOutputStream(OutputStream out, Deflater defl)
+  {
+    this(out, defl, 4096);
+  }
+
+  /** 
+   * Creates a new DeflaterOutputStream with the given Deflater and
+   * buffer size.
+   * @param out the output stream where deflated output should be written.
+   * @param defl the underlying deflater.
+   * @param bufsize the buffer size.
+   * @exception IllegalArgumentException if bufsize isn't positive.
+   */
+  public DeflaterOutputStream(OutputStream out, Deflater defl, int bufsize)
+  {
+    super(out);
+    if (bufsize <= 0)
+      throw new IllegalArgumentException("bufsize <= 0");
+    buf = new byte[bufsize];
+    def = defl;
+  }
+
+  /**  
+   * Flushes the stream by calling flush() on the deflater and then
+   * on the underlying stream.  This ensures that all bytes are
+   * flushed.  This function doesn't work in Sun's JDK, but only in
+   * jazzlib.
+   */
+  public void flush() throws IOException
+  {
+    def.flush();
+    deflate();
+    out.flush();
+  }
+
+  /**
+   * Finishes the stream by calling finish() on the deflater.  This
+   * was the only way to ensure that all bytes are flushed in Sun's
+   * JDK.  
+   */
+  public void finish() throws IOException
+  {
+    def.finish();
+    while (! def.finished())
+      {
+	int len = def.deflate(buf, 0, buf.length);
+	if (len <= 0)
+	  break;
+	out.write(buf, 0, len);
+      }
+    if (! def.finished())
+      throw new InternalError("Can't deflate all input?");
+    out.flush();
+  }
+
+  /**
+   * Calls finish() and closes the stream. 
+   */
+  public void close() throws IOException
+  {
+    finish();
+    out.close();
+  }
+
+  /**
+   * Writes a single byte to the compressed output stream.
+   * @param bval the byte value.
+   */
+  public void write(int bval) throws IOException
+  {
+    byte[] b = new byte[1];
+    b[0] = (byte) bval;
+    write(b, 0, 1);
+  }
+
+  /**
+   * Writes a len bytes from an array to the compressed stream.
+   * @param buf the byte array.
+   * @param off the offset into the byte array where to start.
+   * @param len the number of bytes to write.
+   */
+  public void write(byte[] buf, int off, int len) throws IOException
+  {
+    def.setInput(buf, off, len);
+    deflate();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterPending.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterPending.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterPending.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/DeflaterPending.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,54 @@
+/* java.util.zip.DeflaterPending
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+/**
+ * This class stores the pending output of the Deflater.
+ *
+ * @author Jochen Hoenicke
+ * @date Jan 5, 2000 
+ */
+
+class DeflaterPending extends PendingBuffer
+{
+  public DeflaterPending()
+  {
+    super(DeflaterConstants.PENDING_BUF_SIZE);
+  }
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/GZIPInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/GZIPInputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/GZIPInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/GZIPInputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,355 @@
+/* GZIPInputStream.java - Input filter for reading gzip file
+   Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.zip;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * This filter stream is used to decompress a "GZIP" format stream. 
+ * The "GZIP" format is described in RFC 1952.
+ *
+ * @author John Leuner
+ * @author Tom Tromey
+ * @since JDK 1.1
+ */
+public class GZIPInputStream
+  extends InflaterInputStream
+{
+  /**
+   * The magic number found at the start of a GZIP stream.
+   */
+  public static final int GZIP_MAGIC = 0x8b1f;
+
+  /**
+   * The mask for bit 0 of the flag byte.
+   */
+  static final int FTEXT = 0x1;
+
+  /**
+   * The mask for bit 1 of the flag byte.
+   */
+  static final int FHCRC = 0x2;
+
+  /**
+   * The mask for bit 2 of the flag byte.
+   */
+  static final int FEXTRA = 0x4;
+
+  /**
+   * The mask for bit 3 of the flag byte.
+   */
+  static final int FNAME = 0x8;
+
+  /**
+   * The mask for bit 4 of the flag byte.
+   */
+  static final int FCOMMENT = 0x10;
+
+  /**
+   * The CRC-32 checksum value for uncompressed data.
+   */
+  protected CRC32 crc; 
+
+  /**
+   * Indicates whether or not the end of the stream has been reached.
+   */  
+  protected boolean eos;
+
+  /**
+   * Indicates whether or not the GZIP header has been read in.
+   */
+  private boolean readGZIPHeader;
+
+  /**
+   * Creates a GZIPInputStream with the default buffer size.
+   *
+   * @param in The stream to read compressed data from 
+   *           (in GZIP format).
+   *
+   * @throws IOException if an error occurs during an I/O operation.
+   */
+  public GZIPInputStream(InputStream in)
+    throws IOException
+  {
+    this(in, 4096);
+  }
+
+  /**
+   * Creates a GZIPInputStream with the specified buffer size.
+   *
+   * @param in The stream to read compressed data from 
+   *           (in GZIP format).
+   * @param size The size of the buffer to use.
+   *
+   * @throws IOException if an error occurs during an I/O operation.
+   * @throws IllegalArgumentException if <code>size</code>
+   * is less than or equal to 0.
+   */
+  public GZIPInputStream(InputStream in, int size)
+    throws IOException
+  {
+    super(in, new Inflater(true), size);
+    crc = new CRC32();
+    readHeader();
+  }
+
+  /**
+   * Closes the input stream.
+   *
+   * @throws IOException if an error occurs during an I/O operation.
+   */
+  public void close()
+    throws IOException
+  {
+    // Nothing to do here.
+    super.close();
+  }
+
+  /**
+   * Reads in GZIP-compressed data and stores it in uncompressed form
+   * into an array of bytes.  The method will block until either
+   * enough input data becomes available or the compressed stream
+   * reaches its end.
+   *
+   * @param buf the buffer into which the uncompressed data will
+   *            be stored.
+   * @param offset the offset indicating where in <code>buf</code>
+   *               the uncompressed data should be placed.
+   * @param len the number of uncompressed bytes to be read.
+   */
+  public int read(byte[] buf, int offset, int len) throws IOException
+  {
+    // We first have to slurp in the GZIP header, then we feed all the
+    // rest of the data to the superclass.
+    //
+    // As we do that we continually update the CRC32. Once the data is
+    // finished, we check the CRC32.
+    //
+    // This means we don't need our own buffer, as everything is done
+    // in the superclass.
+    if (!readGZIPHeader)
+      readHeader();
+
+    if (eos)
+      return -1;
+
+    //  System.err.println("GZIPIS.read(byte[], off, len ... " + offset + " and len " + len);
+
+    /* We don't have to read the header,
+     * so we just grab data from the superclass.
+     */
+    int numRead = super.read(buf, offset, len);
+    if (numRead > 0)
+      crc.update(buf, offset, numRead);
+
+    if (inf.finished())
+      readFooter();
+    return numRead;
+  }
+
+
+  /**
+   * Reads in the GZIP header.
+   */
+  private void readHeader() throws IOException
+  {
+    /* 1. Check the two magic bytes */
+    CRC32 headCRC = new CRC32();
+    int magic = in.read();
+    if (magic < 0)
+    {
+      eos = true;
+      return;
+    }
+    int magic2 = in.read();
+    if ((magic + (magic2 << 8)) != GZIP_MAGIC)
+      throw new IOException("Error in GZIP header, bad magic code");
+    headCRC.update(magic);
+    headCRC.update(magic2);
+    
+    /* 2. Check the compression type (must be 8) */
+    int CM = in.read();
+    if (CM != Deflater.DEFLATED)
+      throw new IOException("Error in GZIP header, data not in deflate format");
+    headCRC.update(CM);
+
+    /* 3. Check the flags */
+    int flags = in.read();
+    if (flags < 0)
+      throw new EOFException("Early EOF in GZIP header");
+    headCRC.update(flags);
+    
+    /*    This flag byte is divided into individual bits as follows:
+	  
+	  bit 0   FTEXT
+	  bit 1   FHCRC
+	  bit 2   FEXTRA
+	  bit 3   FNAME
+	  bit 4   FCOMMENT
+	  bit 5   reserved
+	  bit 6   reserved
+	  bit 7   reserved
+    */
+    
+    /* 3.1 Check the reserved bits are zero */    
+    if ((flags & 0xd0) != 0)
+      throw new IOException("Reserved flag bits in GZIP header != 0");
+    
+    /* 4.-6. Skip the modification time, extra flags, and OS type */
+    for (int i=0; i< 6; i++)
+    {
+      int readByte = in.read();
+      if (readByte < 0)
+	throw new EOFException("Early EOF in GZIP header");
+      headCRC.update(readByte);
+    }
+    
+    /* 7. Read extra field */
+    if ((flags & FEXTRA) != 0)
+    {
+      /* Skip subfield id */
+      for (int i=0; i< 2; i++)
+      {
+        int readByte = in.read();
+	if (readByte < 0)
+	  throw new EOFException("Early EOF in GZIP header");
+	headCRC.update(readByte);
+      }
+      if (in.read() < 0 || in.read() < 0)
+	throw new EOFException("Early EOF in GZIP header");
+	
+      int len1, len2, extraLen;
+      len1 = in.read();
+      len2 = in.read();
+      if ((len1 < 0) || (len2 < 0))
+	throw new EOFException("Early EOF in GZIP header");
+      headCRC.update(len1);
+      headCRC.update(len2);
+
+      extraLen = (len1 << 8) | len2;
+      for (int i = 0; i < extraLen;i++)
+      {
+	int readByte = in.read();
+	if (readByte < 0)
+	  throw new EOFException("Early EOF in GZIP header");
+	headCRC.update(readByte);
+      }
+    }
+    
+    /* 8. Read file name */
+    if ((flags & FNAME) != 0)
+    {
+      int readByte;
+      while ( (readByte = in.read()) > 0)
+	headCRC.update(readByte);
+      if (readByte < 0)
+	throw new EOFException("Early EOF in GZIP file name");
+      headCRC.update(readByte);
+    }
+
+    /* 9. Read comment */
+    if ((flags & FCOMMENT) != 0)
+    {
+      int readByte;
+      while ( (readByte = in.read()) > 0)
+        headCRC.update(readByte);
+
+      if (readByte < 0)
+        throw new EOFException("Early EOF in GZIP comment");
+      headCRC.update(readByte);
+    }
+    
+    /* 10. Read header CRC */
+    if ((flags & FHCRC) != 0)
+    {
+      int tempByte;
+      int crcval = in.read();
+      if (crcval < 0)
+        throw new EOFException("Early EOF in GZIP header");
+	
+      tempByte = in.read();
+      if (tempByte < 0)
+        throw new EOFException("Early EOF in GZIP header");
+	
+      crcval = (crcval << 8) | tempByte;
+      if (crcval != ((int) headCRC.getValue() & 0xffff))
+        throw new IOException("Header CRC value mismatch");
+    }
+    
+    readGZIPHeader = true;
+    //System.err.println("Read GZIP header");
+  }
+
+  private void readFooter() throws IOException
+  {
+    byte[] footer = new byte[8];
+    int avail = inf.getRemaining();
+    if (avail > 8)
+      avail = 8;
+    System.arraycopy(buf, len - inf.getRemaining(), footer, 0, avail);
+    int needed = 8 - avail;
+    while (needed > 0)
+    {
+      int count = in.read(footer, 8-needed, needed);
+      if (count <= 0)
+	throw new EOFException("Early EOF in GZIP footer");
+      needed -= count; //Jewel Jan 16
+    }
+
+    int crcval = (footer[0] & 0xff) | ((footer[1] & 0xff) << 8)
+      | ((footer[2] & 0xff) << 16) | (footer[3] << 24);
+    if (crcval != (int) crc.getValue())
+      throw new IOException("GZIP crc sum mismatch, theirs \""
+			    + Integer.toHexString(crcval)
+			    + "\" and ours \""
+			    + Integer.toHexString( (int) crc.getValue()));
+
+    int total = (footer[4] & 0xff) | ((footer[5] & 0xff) << 8)
+      | ((footer[6] & 0xff) << 16) | (footer[7] << 24);
+    if (total != inf.getTotalOut())
+      throw new IOException("Number of bytes mismatch");
+
+    /* FIXME" XXX Should we support multiple members.
+     * Difficult, since there may be some bytes still in buf
+     */
+    eos = true;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/GZIPOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/GZIPOutputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/GZIPOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/GZIPOutputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,151 @@
+/* GZIPOutputStream.java - Create a file in gzip format
+   Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * This filter stream is used to compress a stream into a "GZIP" stream. 
+ * The "GZIP" format is described in RFC 1952.
+ *
+ * @author John Leuner
+ * @author Tom Tromey
+ * @since JDK 1.1
+ */
+
+/* Written using on-line Java Platform 1.2 API Specification
+ * and JCL book.
+ * Believed complete and correct.
+ */
+
+public class GZIPOutputStream extends DeflaterOutputStream
+{
+  /**
+   * CRC-32 value for uncompressed data
+   */
+  protected CRC32 crc;
+
+  /**
+   * Creates a GZIPOutputStream with the default buffer size
+   *
+   * @param out The stream to read data (to be compressed) from 
+   * 
+   */
+  public GZIPOutputStream(OutputStream out) throws IOException
+  {
+    this(out, 4096);
+  }
+
+  /**
+   * Creates a GZIPOutputStream with the specified buffer size
+   *
+   * @param out The stream to read compressed data from 
+   * @param size Size of the buffer to use 
+   */
+  public GZIPOutputStream(OutputStream out, int size) throws IOException
+  {
+    super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size);
+    crc = new CRC32();
+    int mod_time = (int) (System.currentTimeMillis() / 1000L);
+    byte[] gzipHeader =
+      {
+	/* The two magic bytes */
+	(byte) GZIPInputStream.GZIP_MAGIC,
+	(byte) (GZIPInputStream.GZIP_MAGIC >> 8),
+	  
+	/* The compression type */
+	(byte) Deflater.DEFLATED,
+	
+        /* The flags (not set) */
+	0,
+	
+	/* The modification time */
+	(byte) mod_time, (byte) (mod_time >> 8), 
+	(byte) (mod_time >> 16), (byte) (mod_time >> 24), 
+
+	/* The extra flags */
+	0,
+    
+	/* The OS type (unknown) */
+	(byte) 255
+      };
+
+    out.write(gzipHeader);
+    //    System.err.println("wrote GZIP header (" + gzipHeader.length + " bytes )");
+  }
+
+  public synchronized void write(byte[] buf, int off, int len)
+    throws IOException
+  {
+    super.write(buf, off, len);
+    crc.update(buf, off, len);
+  }
+
+  /**
+   * Writes remaining compressed output data to the output stream
+   * and closes it.
+   */
+  public void close() throws IOException
+  {
+    finish();
+    out.close();
+  }
+
+  public void finish() throws IOException
+  {
+    super.finish();
+
+    int totalin = def.getTotalIn();
+    int crcval = (int) (crc.getValue() & 0xffffffff);
+
+    //    System.err.println("CRC val is " + Integer.toHexString( crcval ) 		       + " and length " + Integer.toHexString(totalin));
+    
+    byte[] gzipFooter = 
+      {
+	(byte) crcval, (byte) (crcval >> 8),
+	(byte) (crcval >> 16), (byte) (crcval >> 24),
+
+	(byte) totalin, (byte) (totalin >> 8),
+	(byte) (totalin >> 16), (byte) (totalin >> 24)
+      };
+
+    out.write(gzipFooter);
+  //    System.err.println("wrote GZIP trailer (" + gzipFooter.length + " bytes )");    
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Inflater.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Inflater.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Inflater.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/Inflater.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,714 @@
+/* Inflater.java - Decompress a data stream
+   Copyright (C) 1999, 2000, 2001, 2003, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+/* Written using on-line Java Platform 1.2 API Specification
+ * and JCL book.
+ * Believed complete and correct.
+ */
+
+/**
+ * Inflater is used to decompress data that has been compressed according 
+ * to the "deflate" standard described in rfc1950.
+ *
+ * The usage is as following.  First you have to set some input with
+ * <code>setInput()</code>, then inflate() it.  If inflate doesn't
+ * inflate any bytes there may be three reasons:
+ * <ul>
+ * <li>needsInput() returns true because the input buffer is empty.
+ * You have to provide more input with <code>setInput()</code>.  
+ * NOTE: needsInput() also returns true when, the stream is finished.
+ * </li>
+ * <li>needsDictionary() returns true, you have to provide a preset 
+ *     dictionary with <code>setDictionary()</code>.</li>
+ * <li>finished() returns true, the inflater has finished.</li>
+ * </ul>
+ * Once the first output byte is produced, a dictionary will not be
+ * needed at a later stage.
+ *
+ * @author John Leuner, Jochen Hoenicke
+ * @author Tom Tromey
+ * @date May 17, 1999
+ * @since JDK 1.1
+ */
+public class Inflater
+{
+  /* Copy lengths for literal codes 257..285 */
+  private static final int CPLENS[] = 
+  { 
+    3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
+    35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258
+  };
+  
+  /* Extra bits for literal codes 257..285 */  
+  private static final int CPLEXT[] = 
+  { 
+    0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
+    3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0
+  };
+
+  /* Copy offsets for distance codes 0..29 */
+  private static final int CPDIST[] = {
+    1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
+    257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
+    8193, 12289, 16385, 24577
+  };
+  
+  /* Extra bits for distance codes */
+  private static final int CPDEXT[] = {
+    0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
+    7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 
+    12, 12, 13, 13
+  };
+
+  /* This are the state in which the inflater can be.  */
+  private static final int DECODE_HEADER           = 0;
+  private static final int DECODE_DICT             = 1;
+  private static final int DECODE_BLOCKS           = 2;
+  private static final int DECODE_STORED_LEN1      = 3;
+  private static final int DECODE_STORED_LEN2      = 4;
+  private static final int DECODE_STORED           = 5;
+  private static final int DECODE_DYN_HEADER       = 6;
+  private static final int DECODE_HUFFMAN          = 7;
+  private static final int DECODE_HUFFMAN_LENBITS  = 8;
+  private static final int DECODE_HUFFMAN_DIST     = 9;
+  private static final int DECODE_HUFFMAN_DISTBITS = 10;
+  private static final int DECODE_CHKSUM           = 11;
+  private static final int FINISHED                = 12;
+
+  /** This variable contains the current state. */
+  private int mode;
+
+  /**
+   * The adler checksum of the dictionary or of the decompressed
+   * stream, as it is written in the header resp. footer of the
+   * compressed stream.  <br>
+   *
+   * Only valid if mode is DECODE_DICT or DECODE_CHKSUM.
+   */
+  private int readAdler;
+  /** 
+   * The number of bits needed to complete the current state.  This
+   * is valid, if mode is DECODE_DICT, DECODE_CHKSUM,
+   * DECODE_HUFFMAN_LENBITS or DECODE_HUFFMAN_DISTBITS.  
+   */
+  private int neededBits;
+  private int repLength, repDist;
+  private int uncomprLen;
+  /**
+   * True, if the last block flag was set in the last block of the
+   * inflated stream.  This means that the stream ends after the
+   * current block.  
+   */
+  private boolean isLastBlock;
+
+  /**
+   * The total number of inflated bytes.
+   */
+  private int totalOut;
+  /**
+   * The total number of bytes set with setInput().  This is not the
+   * value returned by getTotalIn(), since this also includes the 
+   * unprocessed input.
+   */
+  private int totalIn;
+  /**
+   * This variable stores the nowrap flag that was given to the constructor.
+   * True means, that the inflated stream doesn't contain a header nor the
+   * checksum in the footer.
+   */
+  private boolean nowrap;
+
+  private StreamManipulator input;
+  private OutputWindow outputWindow;
+  private InflaterDynHeader dynHeader;
+  private InflaterHuffmanTree litlenTree, distTree;
+  private Adler32 adler;
+
+  /**
+   * Creates a new inflater.
+   */
+  public Inflater ()
+  {
+    this (false);
+  }
+
+  /**
+   * Creates a new inflater.
+   * @param nowrap true if no header and checksum field appears in the
+   * stream.  This is used for GZIPed input.  For compatibility with
+   * Sun JDK you should provide one byte of input more than needed in
+   * this case.
+   */
+  public Inflater (boolean nowrap)
+  {
+    this.nowrap = nowrap;
+    this.adler = new Adler32();
+    input = new StreamManipulator();
+    outputWindow = new OutputWindow();
+    mode = nowrap ? DECODE_BLOCKS : DECODE_HEADER;
+  }
+
+  /**
+   * Finalizes this object.
+   */
+  protected void finalize ()
+  {
+    /* Exists only for compatibility */
+  }
+
+  /**
+   * Frees all objects allocated by the inflater.  There's no reason
+   * to call this, since you can just rely on garbage collection (even
+   * for the Sun implementation).  Exists only for compatibility
+   * with Sun's JDK, where the compressor allocates native memory.
+   * If you call any method (even reset) afterwards the behaviour is
+   * <i>undefined</i>.  
+   */
+  public void end ()
+  {
+    outputWindow = null;
+    input = null;
+    dynHeader = null;
+    litlenTree = null;
+    distTree = null;
+    adler = null;
+  }
+
+  /**
+   * Returns true, if the inflater has finished.  This means, that no
+   * input is needed and no output can be produced.
+   */
+  public boolean finished() 
+  {
+    return mode == FINISHED && outputWindow.getAvailable() == 0;
+  }
+
+  /**
+   * Gets the adler checksum.  This is either the checksum of all
+   * uncompressed bytes returned by inflate(), or if needsDictionary()
+   * returns true (and thus no output was yet produced) this is the
+   * adler checksum of the expected dictionary.
+   * @returns the adler checksum.
+   */
+  public int getAdler()
+  {
+    return needsDictionary() ? readAdler : (int) adler.getValue();
+  }
+  
+  /**
+   * Gets the number of unprocessed input.  Useful, if the end of the
+   * stream is reached and you want to further process the bytes after
+   * the deflate stream.  
+   * @return the number of bytes of the input which were not processed.
+   */
+  public int getRemaining()
+  {
+    return input.getAvailableBytes();
+  }
+  
+  /**
+   * Gets the total number of processed compressed input bytes.
+   * @return the total number of bytes of processed input bytes.
+   */
+  public int getTotalIn()
+  {
+    return totalIn - getRemaining();
+  }
+
+  /**
+   * Gets the total number of output bytes returned by inflate().
+   * @return the total number of output bytes.
+   */
+  public int getTotalOut()
+  {
+    return totalOut;
+  }
+
+  /**
+   * Inflates the compressed stream to the output buffer.  If this
+   * returns 0, you should check, whether needsDictionary(),
+   * needsInput() or finished() returns true, to determine why no 
+   * further output is produced.
+   * @param buf the output buffer.
+   * @return the number of bytes written to the buffer, 0 if no further
+   * output can be produced.  
+   * @exception DataFormatException if deflated stream is invalid.
+   * @exception IllegalArgumentException if buf has length 0.
+   */
+  public int inflate (byte[] buf) throws DataFormatException
+  {
+    return inflate (buf, 0, buf.length);
+  }
+
+  /**
+   * Inflates the compressed stream to the output buffer.  If this
+   * returns 0, you should check, whether needsDictionary(),
+   * needsInput() or finished() returns true, to determine why no 
+   * further output is produced.
+   * @param buf the output buffer.
+   * @param off the offset into buffer where the output should start.
+   * @param len the maximum length of the output.
+   * @return the number of bytes written to the buffer, 0 if no further
+   * output can be produced.  
+   * @exception DataFormatException if deflated stream is invalid.
+   * @exception IndexOutOfBoundsException if the off and/or len are wrong.
+   */
+  public int inflate (byte[] buf, int off, int len) throws DataFormatException
+  {
+    /* Special case: len may be zero */
+    if (len == 0)
+      return 0;
+    /* Check for correct buff, off, len triple */
+    if (0 > off || off > off + len || off + len > buf.length)
+      throw new ArrayIndexOutOfBoundsException();
+    int count = 0;
+    int more;
+    do
+      {
+	if (mode != DECODE_CHKSUM)
+	  {
+	    /* Don't give away any output, if we are waiting for the
+	     * checksum in the input stream.
+	     *
+	     * With this trick we have always:
+	     *   needsInput() and not finished() 
+	     *   implies more output can be produced.  
+	     */
+	    more = outputWindow.copyOutput(buf, off, len);
+	    adler.update(buf, off, more);
+	    off += more;
+	    count += more;
+	    totalOut += more;
+	    len -= more;
+	    if (len == 0)
+	      return count;
+	  }
+      }
+    while (decode() || (outputWindow.getAvailable() > 0
+			&& mode != DECODE_CHKSUM));
+    return count;
+  }
+
+  /**
+   * Returns true, if a preset dictionary is needed to inflate the input.
+   */
+  public boolean needsDictionary ()
+  {
+    return mode == DECODE_DICT && neededBits == 0;
+  }
+
+  /**
+   * Returns true, if the input buffer is empty.
+   * You should then call setInput(). <br>
+   *
+   * <em>NOTE</em>: This method also returns true when the stream is finished.
+   */
+  public boolean needsInput () 
+  {
+    return input.needsInput ();
+  }
+
+  /**
+   * Resets the inflater so that a new stream can be decompressed.  All
+   * pending input and output will be discarded.
+   */
+  public void reset ()
+  {
+    mode = nowrap ? DECODE_BLOCKS : DECODE_HEADER;
+    totalIn = totalOut = 0;
+    input.reset();
+    outputWindow.reset();
+    dynHeader = null;
+    litlenTree = null;
+    distTree = null;
+    isLastBlock = false;
+    adler.reset();
+  }
+
+  /**
+   * Sets the preset dictionary.  This should only be called, if
+   * needsDictionary() returns true and it should set the same
+   * dictionary, that was used for deflating.  The getAdler()
+   * function returns the checksum of the dictionary needed.
+   * @param buffer the dictionary.
+   * @exception IllegalStateException if no dictionary is needed.
+   * @exception IllegalArgumentException if the dictionary checksum is
+   * wrong.  
+   */
+  public void setDictionary (byte[] buffer)
+  {
+    setDictionary(buffer, 0, buffer.length);
+  }
+
+  /**
+   * Sets the preset dictionary.  This should only be called, if
+   * needsDictionary() returns true and it should set the same
+   * dictionary, that was used for deflating.  The getAdler()
+   * function returns the checksum of the dictionary needed.
+   * @param buffer the dictionary.
+   * @param off the offset into buffer where the dictionary starts.
+   * @param len the length of the dictionary.
+   * @exception IllegalStateException if no dictionary is needed.
+   * @exception IllegalArgumentException if the dictionary checksum is
+   * wrong.  
+   * @exception IndexOutOfBoundsException if the off and/or len are wrong.
+   */
+  public void setDictionary (byte[] buffer, int off, int len)
+  {
+    if (!needsDictionary())
+      throw new IllegalStateException();
+
+    adler.update(buffer, off, len);
+    if ((int) adler.getValue() != readAdler)
+      throw new IllegalArgumentException("Wrong adler checksum");
+    adler.reset();
+    outputWindow.copyDict(buffer, off, len);
+    mode = DECODE_BLOCKS;
+  }
+
+  /**
+   * Sets the input.  This should only be called, if needsInput()
+   * returns true.
+   * @param buf the input.
+   * @exception IllegalStateException if no input is needed.
+   */
+  public void setInput (byte[] buf) 
+  {
+    setInput (buf, 0, buf.length);
+  }
+
+  /**
+   * Sets the input.  This should only be called, if needsInput()
+   * returns true.
+   * @param buf the input.
+   * @param off the offset into buffer where the input starts.
+   * @param len the length of the input.  
+   * @exception IllegalStateException if no input is needed.
+   * @exception IndexOutOfBoundsException if the off and/or len are wrong.
+   */
+  public void setInput (byte[] buf, int off, int len) 
+  {
+    input.setInput (buf, off, len);
+    totalIn += len;
+  }
+
+  /**
+   * Decodes the deflate header.
+   * @return false if more input is needed. 
+   * @exception DataFormatException if header is invalid.
+   */
+  private boolean decodeHeader () throws DataFormatException
+  {
+    int header = input.peekBits(16);
+    if (header < 0)
+      return false;
+    input.dropBits(16);
+    
+    /* The header is written in "wrong" byte order */
+    header = ((header << 8) | (header >> 8)) & 0xffff;
+    if (header % 31 != 0)
+      throw new DataFormatException("Header checksum illegal");
+    
+    if ((header & 0x0f00) != (Deflater.DEFLATED << 8))
+      throw new DataFormatException("Compression Method unknown");
+
+    /* Maximum size of the backwards window in bits. 
+     * We currently ignore this, but we could use it to make the
+     * inflater window more space efficient. On the other hand the
+     * full window (15 bits) is needed most times, anyway.
+     int max_wbits = ((header & 0x7000) >> 12) + 8;
+     */
+    
+    if ((header & 0x0020) == 0) // Dictionary flag?
+      {
+	mode = DECODE_BLOCKS;
+      }
+    else
+      {
+	mode = DECODE_DICT;
+	neededBits = 32;      
+      }
+    return true;
+  }
+   
+  /**
+   * Decodes the dictionary checksum after the deflate header.
+   * @return false if more input is needed. 
+   */
+  private boolean decodeDict ()
+  {
+    while (neededBits > 0)
+      {
+	int dictByte = input.peekBits(8);
+	if (dictByte < 0)
+	  return false;
+	input.dropBits(8);
+	readAdler = (readAdler << 8) | dictByte;
+	neededBits -= 8;
+      }
+    return false;
+  }
+
+  /**
+   * Decodes the huffman encoded symbols in the input stream.
+   * @return false if more input is needed, true if output window is
+   * full or the current block ends.
+   * @exception DataFormatException if deflated stream is invalid.  
+   */
+  private boolean decodeHuffman () throws DataFormatException
+  {
+    int free = outputWindow.getFreeSpace();
+    while (free >= 258)
+      {
+	int symbol;
+	switch (mode)
+	  {
+	  case DECODE_HUFFMAN:
+	    /* This is the inner loop so it is optimized a bit */
+	    while (((symbol = litlenTree.getSymbol(input)) & ~0xff) == 0)
+	      {
+		outputWindow.write(symbol);
+		if (--free < 258)
+		  return true;
+	      } 
+	    if (symbol < 257)
+	      {
+		if (symbol < 0)
+		  return false;
+		else
+		  {
+		    /* symbol == 256: end of block */
+		    distTree = null;
+		    litlenTree = null;
+		    mode = DECODE_BLOCKS;
+		    return true;
+		  }
+	      }
+		
+	    try
+	      {
+		repLength = CPLENS[symbol - 257];
+		neededBits = CPLEXT[symbol - 257];
+	      }
+	    catch (ArrayIndexOutOfBoundsException ex)
+	      {
+		throw new DataFormatException("Illegal rep length code");
+	      }
+	    /* fall through */
+	  case DECODE_HUFFMAN_LENBITS:
+	    if (neededBits > 0)
+	      {
+		mode = DECODE_HUFFMAN_LENBITS;
+		int i = input.peekBits(neededBits);
+		if (i < 0)
+		  return false;
+		input.dropBits(neededBits);
+		repLength += i;
+	      }
+	    mode = DECODE_HUFFMAN_DIST;
+	    /* fall through */
+	  case DECODE_HUFFMAN_DIST:
+	    symbol = distTree.getSymbol(input);
+	    if (symbol < 0)
+	      return false;
+	    try 
+	      {
+		repDist = CPDIST[symbol];
+		neededBits = CPDEXT[symbol];
+	      }
+	    catch (ArrayIndexOutOfBoundsException ex)
+	      {
+		throw new DataFormatException("Illegal rep dist code");
+	      }
+	    /* fall through */
+	  case DECODE_HUFFMAN_DISTBITS:
+	    if (neededBits > 0)
+	      {
+		mode = DECODE_HUFFMAN_DISTBITS;
+		int i = input.peekBits(neededBits);
+		if (i < 0)
+		  return false;
+		input.dropBits(neededBits);
+		repDist += i;
+	      }
+	    outputWindow.repeat(repLength, repDist);
+	    free -= repLength;
+	    mode = DECODE_HUFFMAN;
+	    break;
+	  default:
+	    throw new IllegalStateException();
+	  }
+      }
+    return true;
+  }
+
+  /**
+   * Decodes the adler checksum after the deflate stream.
+   * @return false if more input is needed. 
+   * @exception DataFormatException if checksum doesn't match.
+   */
+  private boolean decodeChksum () throws DataFormatException
+  {
+    while (neededBits > 0)
+      {
+	int chkByte = input.peekBits(8);
+	if (chkByte < 0)
+	  return false;
+	input.dropBits(8);
+	readAdler = (readAdler << 8) | chkByte;
+	neededBits -= 8;
+      }
+    if ((int) adler.getValue() != readAdler)
+      throw new DataFormatException("Adler chksum doesn't match: "
+				    +Integer.toHexString((int)adler.getValue())
+				    +" vs. "+Integer.toHexString(readAdler));
+    mode = FINISHED;
+    return false;
+  }
+
+  /**
+   * Decodes the deflated stream.
+   * @return false if more input is needed, or if finished. 
+   * @exception DataFormatException if deflated stream is invalid.
+   */
+  private boolean decode () throws DataFormatException
+  {
+    switch (mode) 
+      {
+      case DECODE_HEADER:
+	return decodeHeader();
+      case DECODE_DICT:
+	return decodeDict();
+      case DECODE_CHKSUM:
+	return decodeChksum();
+
+      case DECODE_BLOCKS:
+	if (isLastBlock)
+	  {
+	    if (nowrap)
+	      {
+		mode = FINISHED;
+		return false;
+	      }
+	    else
+	      {
+		input.skipToByteBoundary();
+		neededBits = 32;
+		mode = DECODE_CHKSUM;
+		return true;
+	      }
+	  }
+
+	int type = input.peekBits(3);
+	if (type < 0)
+	  return false;
+	input.dropBits(3);
+
+	if ((type & 1) != 0)
+	  isLastBlock = true;
+	switch (type >> 1)
+	  {
+	  case DeflaterConstants.STORED_BLOCK:
+	    input.skipToByteBoundary();
+	    mode = DECODE_STORED_LEN1;
+	    break;
+	  case DeflaterConstants.STATIC_TREES:
+	    litlenTree = InflaterHuffmanTree.defLitLenTree;
+	    distTree = InflaterHuffmanTree.defDistTree;
+	    mode = DECODE_HUFFMAN;
+	    break;
+	  case DeflaterConstants.DYN_TREES:
+	    dynHeader = new InflaterDynHeader();
+	    mode = DECODE_DYN_HEADER;
+	    break;
+	  default:
+	    throw new DataFormatException("Unknown block type "+type);
+	  }
+	return true;
+
+      case DECODE_STORED_LEN1:
+	{
+	  if ((uncomprLen = input.peekBits(16)) < 0)
+	    return false;
+	  input.dropBits(16);
+	  mode = DECODE_STORED_LEN2;
+	}
+	/* fall through */
+      case DECODE_STORED_LEN2:
+	{
+	  int nlen = input.peekBits(16);
+	  if (nlen < 0)
+	    return false;
+	  input.dropBits(16);
+	  if (nlen != (uncomprLen ^ 0xffff))
+	    throw new DataFormatException("broken uncompressed block");
+	  mode = DECODE_STORED;
+	}
+	/* fall through */
+      case DECODE_STORED:
+	{
+	  int more = outputWindow.copyStored(input, uncomprLen);
+	  uncomprLen -= more;
+	  if (uncomprLen == 0)
+	    {
+	      mode = DECODE_BLOCKS;
+	      return true;
+	    }
+	  return !input.needsInput();
+	}
+
+      case DECODE_DYN_HEADER:
+	if (!dynHeader.decode(input))
+	  return false;
+	litlenTree = dynHeader.buildLitLenTree();
+	distTree = dynHeader.buildDistTree();
+	mode = DECODE_HUFFMAN;
+	/* fall through */
+      case DECODE_HUFFMAN:
+      case DECODE_HUFFMAN_LENBITS:
+      case DECODE_HUFFMAN_DIST:
+      case DECODE_HUFFMAN_DISTBITS:
+	return decodeHuffman();
+      case FINISHED:
+	return false;
+      default:
+	throw new IllegalStateException();
+      }	
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/InflaterDynHeader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/InflaterDynHeader.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/InflaterDynHeader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/InflaterDynHeader.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,203 @@
+/* java.util.zip.InflaterDynHeader
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+class InflaterDynHeader
+{
+  private static final int LNUM   = 0;
+  private static final int DNUM   = 1;
+  private static final int BLNUM  = 2;
+  private static final int BLLENS = 3;
+  private static final int LENS   = 4;
+  private static final int REPS   = 5;
+
+  private static final int repMin[]  = { 3, 3, 11 };
+  private static final int repBits[] = { 2, 3,  7 };
+
+  
+  private byte[] blLens;
+  private byte[] litdistLens;
+
+  private InflaterHuffmanTree blTree;
+  
+  private int mode;
+  private int lnum, dnum, blnum, num;
+  private int repSymbol;
+  private byte lastLen;
+  private int ptr;
+
+  private static final int[] BL_ORDER =
+  { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
+  
+  public InflaterDynHeader()
+  {
+  }
+  
+  public boolean decode(StreamManipulator input) throws DataFormatException
+  {
+  decode_loop:
+    for (;;)
+      {
+	switch (mode)
+	  {
+	  case LNUM:
+	    lnum = input.peekBits(5);
+	    if (lnum < 0)
+	      return false;
+	    lnum += 257;
+	    input.dropBits(5);
+//  	    System.err.println("LNUM: "+lnum);
+	    mode = DNUM;
+	    /* fall through */
+	  case DNUM:
+	    dnum = input.peekBits(5);
+	    if (dnum < 0)
+	      return false;
+	    dnum++;
+	    input.dropBits(5);
+//  	    System.err.println("DNUM: "+dnum);
+	    num = lnum+dnum;
+	    litdistLens = new byte[num];
+	    mode = BLNUM;
+	    /* fall through */
+	  case BLNUM:
+	    blnum = input.peekBits(4);
+	    if (blnum < 0)
+	      return false;
+	    blnum += 4;
+	    input.dropBits(4);
+	    blLens = new byte[19];
+	    ptr = 0;
+//  	    System.err.println("BLNUM: "+blnum);
+	    mode = BLLENS;
+	    /* fall through */
+	  case BLLENS:
+	    while (ptr < blnum)
+	      {
+		int len = input.peekBits(3);
+		if (len < 0)
+		  return false;
+		input.dropBits(3);
+//  		System.err.println("blLens["+BL_ORDER[ptr]+"]: "+len);
+		blLens[BL_ORDER[ptr]] = (byte) len;
+		ptr++;
+	      }
+	    blTree = new InflaterHuffmanTree(blLens);
+	    blLens = null;
+	    ptr = 0;
+	    mode = LENS;
+	    /* fall through */
+	  case LENS:
+	    {
+	      int symbol;
+	      while (((symbol = blTree.getSymbol(input)) & ~15) == 0)
+		{
+		  /* Normal case: symbol in [0..15] */
+
+//  		  System.err.println("litdistLens["+ptr+"]: "+symbol);
+		  litdistLens[ptr++] = lastLen = (byte) symbol;
+
+		  if (ptr == num)
+		    {
+		      /* Finished */
+		      return true;
+		    }
+		}
+	      
+	      /* need more input ? */
+	      if (symbol < 0)
+		return false;
+
+	      /* otherwise repeat code */
+	      if (symbol >= 17)
+		{
+		  /* repeat zero */
+//  		  System.err.println("repeating zero");
+		  lastLen = 0;
+		}
+	      else
+		{
+		  if (ptr == 0)
+		    throw new DataFormatException();
+		}
+	      repSymbol = symbol-16;
+	      mode = REPS;
+	    }
+	    /* fall through */
+
+	  case REPS:
+	    {
+	      int bits = repBits[repSymbol];
+	      int count = input.peekBits(bits);
+	      if (count < 0)
+		return false;
+	      input.dropBits(bits);
+	      count += repMin[repSymbol];
+//  	      System.err.println("litdistLens repeated: "+count);
+
+	      if (ptr + count > num)
+		throw new DataFormatException();
+	      while (count-- > 0)
+		litdistLens[ptr++] = lastLen;
+
+	      if (ptr == num)
+		{
+		  /* Finished */
+		  return true;
+		}
+	    }
+	    mode = LENS;
+	    continue decode_loop;
+	  }
+      }
+  }
+
+  public InflaterHuffmanTree buildLitLenTree() throws DataFormatException
+  {
+    byte[] litlenLens = new byte[lnum];
+    System.arraycopy(litdistLens, 0, litlenLens, 0, lnum);
+    return new InflaterHuffmanTree(litlenLens);
+  }
+
+  public InflaterHuffmanTree buildDistTree() throws DataFormatException
+  {
+    byte[] distLens = new byte[dnum];
+    System.arraycopy(litdistLens, lnum, distLens, 0, dnum);
+    return new InflaterHuffmanTree(distLens);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/InflaterHuffmanTree.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/InflaterHuffmanTree.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/InflaterHuffmanTree.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/InflaterHuffmanTree.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,217 @@
+/* InflaterHuffmanTree.java --
+   Copyright (C) 2001, 2004  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+class InflaterHuffmanTree
+{
+  private static final int MAX_BITLEN = 15;
+  
+  private short[] tree;
+
+  static InflaterHuffmanTree defLitLenTree, defDistTree;
+
+  static
+  {
+    try 
+      {
+	byte[] codeLengths = new byte[288];
+	int i = 0;
+	while (i < 144)
+	  codeLengths[i++] = 8;
+	while (i < 256)
+	  codeLengths[i++] = 9;
+	while (i < 280)
+	  codeLengths[i++] = 7;
+	while (i < 288)
+	  codeLengths[i++] = 8;
+	defLitLenTree = new InflaterHuffmanTree(codeLengths);
+	
+	codeLengths = new byte[32];
+	i = 0;
+	while (i < 32)
+	  codeLengths[i++] = 5;
+	defDistTree = new InflaterHuffmanTree(codeLengths);
+      } 
+    catch (DataFormatException ex)
+      {
+	throw new InternalError
+	  ("InflaterHuffmanTree: static tree length illegal");
+      }
+  }
+
+  /**
+   * Constructs a Huffman tree from the array of code lengths.
+   *
+   * @param codeLengths the array of code lengths
+   */
+  InflaterHuffmanTree(byte[] codeLengths) throws DataFormatException
+  {
+    buildTree(codeLengths);
+  }
+  
+  private void buildTree(byte[] codeLengths) throws DataFormatException
+  {
+    int[] blCount = new int[MAX_BITLEN+1];
+    int[] nextCode = new int[MAX_BITLEN+1];
+    for (int i = 0; i < codeLengths.length; i++)
+      {
+	int bits = codeLengths[i];
+	if (bits > 0)
+	  blCount[bits]++;
+      }
+
+    int code = 0;
+    int treeSize = 512;
+    for (int bits = 1; bits <= MAX_BITLEN; bits++)
+      {
+	nextCode[bits] = code;
+	code += blCount[bits] << (16 - bits);
+	if (bits >= 10)
+	  {
+	    /* We need an extra table for bit lengths >= 10. */
+	    int start = nextCode[bits] & 0x1ff80;
+	    int end   = code & 0x1ff80;
+	    treeSize += (end - start) >> (16 - bits);
+	  }
+      }
+    if (code != 65536)
+      throw new DataFormatException("Code lengths don't add up properly.");
+
+    /* Now create and fill the extra tables from longest to shortest
+     * bit len.  This way the sub trees will be aligned.
+     */
+    tree = new short[treeSize];
+    int treePtr = 512;
+    for (int bits = MAX_BITLEN; bits >= 10; bits--)
+      {
+	int end   = code & 0x1ff80;
+	code -= blCount[bits] << (16 - bits);
+	int start = code & 0x1ff80;
+	for (int i = start; i < end; i += 1 << 7)
+	  {
+	    tree[DeflaterHuffman.bitReverse(i)]
+	      = (short) ((-treePtr << 4) | bits);
+	    treePtr += 1 << (bits-9);
+	  }
+      }
+    
+    for (int i = 0; i < codeLengths.length; i++)
+      {
+	int bits = codeLengths[i];
+	if (bits == 0)
+	  continue;
+	code = nextCode[bits];
+	int revcode = DeflaterHuffman.bitReverse(code);
+	if (bits <= 9)
+	  {
+	    do
+	      {
+		tree[revcode] = (short) ((i << 4) | bits);
+		revcode += 1 << bits;
+	      }
+	    while (revcode < 512);
+	  }
+	else
+	  {
+	    int subTree = tree[revcode & 511];
+	    int treeLen = 1 << (subTree & 15);
+	    subTree = -(subTree >> 4);
+	    do
+	      { 
+		tree[subTree | (revcode >> 9)] = (short) ((i << 4) | bits);
+		revcode += 1 << bits;
+	      }
+	    while (revcode < treeLen);
+	  }
+	nextCode[bits] = code + (1 << (16 - bits));
+      }
+  }
+
+  /**
+   * Reads the next symbol from input.  The symbol is encoded using the
+   * huffman tree.
+   * @param input the input source.
+   * @return the next symbol, or -1 if not enough input is available.
+   */
+  int getSymbol(StreamManipulator input) throws DataFormatException
+  {
+    int lookahead, symbol;
+    if ((lookahead = input.peekBits(9)) >= 0)
+      {
+	if ((symbol = tree[lookahead]) >= 0)
+	  {
+	    input.dropBits(symbol & 15);
+	    return symbol >> 4;
+	  }
+	int subtree = -(symbol >> 4);
+	int bitlen = symbol & 15;
+	if ((lookahead = input.peekBits(bitlen)) >= 0)
+	  {
+	    symbol = tree[subtree | (lookahead >> 9)];
+	    input.dropBits(symbol & 15);
+	    return symbol >> 4;
+	  }
+	else
+	  {
+	    int bits = input.getAvailableBits();
+	    lookahead = input.peekBits(bits);
+	    symbol = tree[subtree | (lookahead >> 9)];
+	    if ((symbol & 15) <= bits)
+	      {
+		input.dropBits(symbol & 15);
+		return symbol >> 4;
+	      }
+	    else
+	      return -1;
+	  }
+      }
+    else
+      {
+	int bits = input.getAvailableBits();
+	lookahead = input.peekBits(bits);
+	symbol = tree[lookahead];
+	if (symbol >= 0 && (symbol & 15) <= bits)
+	  {
+	    input.dropBits(symbol & 15);
+	    return symbol >> 4;
+	  }
+	else
+	  return -1;
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/InflaterInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/InflaterInputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/InflaterInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/InflaterInputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,265 @@
+/* InflaterInputStream.java - Input stream filter for decompressing
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.zip;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * This filter stream is used to decompress data compressed in the "deflate"
+ * format. The "deflate" format is described in RFC 1951.
+ *
+ * This stream may form the basis for other decompression filters, such
+ * as the <code>GZIPInputStream</code>.
+ *
+ * @author John Leuner
+ * @author Tom Tromey
+ * @since 1.1
+ */
+public class InflaterInputStream extends FilterInputStream
+{
+  /**
+   * Decompressor for this filter 
+   */
+  protected Inflater inf;
+
+  /**
+   * Byte array used as a buffer 
+   */
+  protected byte[] buf;
+
+  /**
+   * Size of buffer   
+   */
+  protected int len;
+
+  // We just use this if we are decoding one byte at a time with the
+  // read() call.
+  private byte[] onebytebuffer = new byte[1];
+
+  /**
+   * Create an InflaterInputStream with the default decompresseor
+   * and a default buffer size.
+   *
+   * @param in the InputStream to read bytes from
+   */
+  public InflaterInputStream(InputStream in) 
+  {
+    this(in, new Inflater(), 4096);
+  }
+
+  /**
+   * Create an InflaterInputStream with the specified decompresseor
+   * and a default buffer size.
+   *
+   * @param in the InputStream to read bytes from
+   * @param inf the decompressor used to decompress data read from in
+   */
+  public InflaterInputStream(InputStream in, Inflater inf) 
+  {
+    this(in, inf, 4096);
+  }
+
+  /**
+   * Create an InflaterInputStream with the specified decompresseor
+   * and a specified buffer size.
+   *
+   * @param in the InputStream to read bytes from
+   * @param inf the decompressor used to decompress data read from in
+   * @param size size of the buffer to use
+   */
+  public InflaterInputStream(InputStream in, Inflater inf, int size) 
+  {
+    super(in);
+
+    if (in == null)
+      throw new NullPointerException("in may not be null");
+    if (inf == null)
+      throw new NullPointerException("inf may not be null");
+    if (size < 0)
+      throw new IllegalArgumentException("size may not be negative");
+    
+    this.inf = inf;
+    this.buf = new byte [size];
+  }
+
+  /**
+   * Returns 0 once the end of the stream (EOF) has been reached.
+   * Otherwise returns 1.
+   */
+  public int available() throws IOException
+  {
+    // According to the JDK 1.2 docs, this should only ever return 0
+    // or 1 and should not be relied upon by Java programs.
+    if (inf == null)
+      throw new IOException("stream closed");
+    return inf.finished() ? 0 : 1;
+  }
+
+  /**
+   * Closes the input stream
+   */
+  public synchronized void close() throws IOException
+  {
+    if (in != null)
+      in.close();
+    in = null;
+  }
+
+  /**
+   * Fills the buffer with more data to decompress.
+   */
+  protected void fill() throws IOException
+  {
+    if (in == null)
+      throw new ZipException ("InflaterInputStream is closed");
+    
+    len = in.read(buf, 0, buf.length);
+
+    if (len < 0)
+      throw new ZipException("Deflated stream ends early.");
+    
+    inf.setInput(buf, 0, len);
+  }
+
+  /**
+   * Reads one byte of decompressed data.
+   *
+   * The byte is in the lower 8 bits of the int.
+   */
+  public int read() throws IOException
+  { 
+    int nread = read(onebytebuffer, 0, 1);
+    if (nread > 0)
+      return onebytebuffer[0] & 0xff;
+    return -1;
+  }
+
+  /**
+   * Decompresses data into the byte array
+   *
+   * @param b the array to read and decompress data into
+   * @param off the offset indicating where the data should be placed
+   * @param len the number of bytes to decompress
+   */
+  public int read(byte[] b, int off, int len) throws IOException
+  {
+    if (inf == null)
+      throw new IOException("stream closed");
+    if (len == 0)
+      return 0;
+    if (inf.finished())
+      return -1;
+
+    int count = 0;
+    while (count == 0)
+      {
+	if (inf.needsInput())
+	  fill();
+	
+	try
+	  {
+	    count = inf.inflate(b, off, len);
+	    if (count == 0)
+	      {
+		if (this.len == -1)
+		  {
+		    // Couldn't get any more data to feed to the Inflater
+		    return -1;
+		  }
+		if (inf.needsDictionary())
+		  throw new ZipException("Inflater needs Dictionary");
+	      }
+	  } 
+	catch (DataFormatException dfe) 
+	  {
+	    throw new ZipException(dfe.getMessage());
+	  }
+      }
+    return count;
+  }
+
+  /**
+   * Skip specified number of bytes of uncompressed data
+   *
+   * @param n number of bytes to skip
+   */
+  public long skip(long n) throws IOException
+  {
+    if (inf == null)
+      throw new IOException("stream closed");
+    if (n < 0)
+      throw new IllegalArgumentException();
+
+    if (n == 0)
+      return 0;
+
+    int buflen = (int) Math.min(n, 2048);
+    byte[] tmpbuf = new byte[buflen];
+
+    long skipped = 0L;
+    while (n > 0L)
+      {
+	int numread = read(tmpbuf, 0, buflen);
+	if (numread <= 0)
+	  break;
+	n -= numread;
+	skipped += numread;
+	buflen = (int) Math.min(n, 2048);
+      }
+
+    return skipped;
+ }
+
+  public boolean markSupported()
+  {
+    return false;
+  }
+
+  public void mark(int readLimit)
+  {
+  }
+
+  public void reset() throws IOException
+  {
+    throw new IOException("reset not supported");
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/OutputWindow.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/OutputWindow.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/OutputWindow.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/OutputWindow.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,178 @@
+/* OutputWindow.java --
+   Copyright (C) 2001, 2004  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+/**
+ * Contains the output from the Inflation process.
+ *
+ * We need to have a window so that we can refer backwards into the output stream
+ * to repeat stuff.
+ *
+ * @author John Leuner
+ * @since 1.1
+ */
+class OutputWindow
+{
+  private static final int WINDOW_SIZE = 1 << 15;
+  private static final int WINDOW_MASK = WINDOW_SIZE - 1;
+
+  private byte[] window = new byte[WINDOW_SIZE]; //The window is 2^15 bytes
+  private int window_end  = 0;
+  private int window_filled = 0;
+
+  public void write(int abyte)
+  {
+    if (window_filled++ == WINDOW_SIZE)
+      throw new IllegalStateException("Window full");
+    window[window_end++] = (byte) abyte;
+    window_end &= WINDOW_MASK;
+  }
+
+  private void slowRepeat(int rep_start, int len, int dist)
+  {
+    while (len-- > 0)
+      {
+	window[window_end++] = window[rep_start++];
+	window_end &= WINDOW_MASK;
+	rep_start &= WINDOW_MASK;
+      }
+  }
+
+  public void repeat(int len, int dist)
+  {
+    if ((window_filled += len) > WINDOW_SIZE)
+      throw new IllegalStateException("Window full");
+
+    int rep_start = (window_end - dist) & WINDOW_MASK;
+    int border = WINDOW_SIZE - len;
+    if (rep_start <= border && window_end < border)
+      {
+	if (len <= dist)
+	  {
+	    System.arraycopy(window, rep_start, window, window_end, len);
+	    window_end += len;
+	  }
+	else
+	  {
+	    /* We have to copy manually, since the repeat pattern overlaps.
+	     */
+	    while (len-- > 0)
+	      window[window_end++] = window[rep_start++];
+	  }
+      }
+    else
+      slowRepeat(rep_start, len, dist);
+  }
+
+  public int copyStored(StreamManipulator input, int len)
+  {
+    len = Math.min(Math.min(len, WINDOW_SIZE - window_filled), 
+		   input.getAvailableBytes());
+    int copied;
+
+    int tailLen = WINDOW_SIZE - window_end;
+    if (len > tailLen)
+      {
+	copied = input.copyBytes(window, window_end, tailLen);
+	if (copied == tailLen)
+	  copied += input.copyBytes(window, 0, len - tailLen);
+      }
+    else
+      copied = input.copyBytes(window, window_end, len);
+
+    window_end = (window_end + copied) & WINDOW_MASK;
+    window_filled += copied;
+    return copied;
+  }
+
+  public void copyDict(byte[] dict, int offset, int len)
+  {
+    if (window_filled > 0)
+      throw new IllegalStateException();
+
+    if (len > WINDOW_SIZE)
+      {
+	offset += len - WINDOW_SIZE;
+	len = WINDOW_SIZE;
+      }
+    System.arraycopy(dict, offset, window, 0, len);
+    window_end = len & WINDOW_MASK;
+  }
+
+  public int getFreeSpace()
+  {
+    return WINDOW_SIZE - window_filled;
+  }
+
+  public int getAvailable()
+  {
+    return window_filled;
+  }
+
+  public int copyOutput(byte[] output, int offset, int len)
+  {
+    int copy_end = window_end;
+    if (len > window_filled)
+      len = window_filled;
+    else
+      copy_end = (window_end - window_filled + len) & WINDOW_MASK;
+
+    int copied = len;
+    int tailLen = len - copy_end;
+
+    if (tailLen > 0)
+      {
+	System.arraycopy(window, WINDOW_SIZE - tailLen,
+			 output, offset, tailLen);
+	offset += tailLen;
+	len = copy_end;
+      }
+    System.arraycopy(window, copy_end - len, output, offset, len);
+    window_filled -= copied;
+    if (window_filled < 0)
+      throw new IllegalStateException();
+    return copied;
+  }
+
+  public void reset() {
+    window_filled = window_end = 0;
+  }
+}
+
+
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/PendingBuffer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/PendingBuffer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/PendingBuffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/PendingBuffer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,200 @@
+/* java.util.zip.PendingBuffer
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+/**
+ * This class is general purpose class for writing data to a buffer.
+ *
+ * It allows you to write bits as well as bytes 
+ *
+ * Based on DeflaterPending.java
+ *
+ * @author Jochen Hoenicke
+ * @date Jan 5, 2000 
+ */
+
+class PendingBuffer
+{
+  protected byte[] buf;
+  int    start;
+  int    end;
+
+  int    bits;
+  int    bitCount;
+
+  public PendingBuffer()
+  {
+    this( 4096 );
+  }
+
+  public PendingBuffer(int bufsize)
+  {
+    buf = new byte[bufsize];
+  }
+
+  public final void reset() {
+    start = end = bitCount = 0;
+  }
+
+  public final void writeByte(int b) 
+  {
+    if (DeflaterConstants.DEBUGGING && start != 0)
+      throw new IllegalStateException();
+    buf[end++] = (byte) b;
+  }
+
+  public final void writeShort(int s) 
+  {
+    if (DeflaterConstants.DEBUGGING && start != 0)
+      throw new IllegalStateException();
+    buf[end++] = (byte) s;
+    buf[end++] = (byte) (s >> 8);
+  }
+
+  public final void writeInt(int s) 
+  {
+    if (DeflaterConstants.DEBUGGING && start != 0)
+      throw new IllegalStateException();
+    buf[end++] = (byte) s;
+    buf[end++] = (byte) (s >> 8);
+    buf[end++] = (byte) (s >> 16);
+    buf[end++] = (byte) (s >> 24);
+  }
+
+  public final void writeBlock(byte[] block, int offset, int len) 
+  {
+    if (DeflaterConstants.DEBUGGING && start != 0)
+      throw new IllegalStateException();
+    System.arraycopy(block, offset, buf, end, len);
+    end += len;
+  }
+
+  public final int getBitCount() {
+    return bitCount;
+  }
+
+  public final void alignToByte() {
+    if (DeflaterConstants.DEBUGGING && start != 0)
+      throw new IllegalStateException();
+    if (bitCount > 0)
+      {
+	buf[end++] = (byte) bits;
+	if (bitCount > 8)
+	  buf[end++] = (byte) (bits >>> 8);
+      }
+    bits = 0;
+    bitCount = 0;
+  }
+
+  public final void writeBits(int b, int count)
+  {
+     if (DeflaterConstants.DEBUGGING && start != 0)
+       throw new IllegalStateException();
+     if (DeflaterConstants.DEBUGGING)
+       System.err.println("writeBits("+Integer.toHexString(b)+","+count+")");
+    bits |= b << bitCount;
+    bitCount += count;
+    if (bitCount >= 16) {
+      buf[end++] = (byte) bits;
+      buf[end++] = (byte) (bits >>> 8);
+      bits >>>= 16;
+      bitCount -= 16;
+    }
+  }
+
+  public final void writeShortMSB(int s) {
+    if (DeflaterConstants.DEBUGGING && start != 0)
+      throw new IllegalStateException();
+    buf[end++] = (byte) (s >> 8);
+    buf[end++] = (byte) s;
+  }
+
+  public final boolean isFlushed() {
+    return end == 0;
+  }
+
+  /**
+   * Flushes the pending buffer into the given output array.  If the
+   * output array is to small, only a partial flush is done.
+   *
+   * @param output the output array;
+   * @param offset the offset into output array;
+   * @param length the maximum number of bytes to store;
+   * @exception IndexOutOfBoundsException if offset or length are
+   * invalid.
+   */
+  public final int flush(byte[] output, int offset, int length) {
+    if (bitCount >= 8)
+      {
+	buf[end++] = (byte) bits;
+	bits >>>= 8;
+	bitCount -= 8;
+      }
+    if (length > end - start)
+      {
+	length = end - start;
+	System.arraycopy(buf, start, output, offset, length);
+	start = 0;
+	end = 0;
+      }
+    else
+      {
+	System.arraycopy(buf, start, output, offset, length);
+	start += length;
+      }
+    return length;
+  }
+
+  /**
+   * Flushes the pending buffer and returns that data in a new array
+   * 
+   * @return the output stream
+   */
+
+  public final byte[] toByteArray()
+  {
+    byte[] ret = new byte[ end - start ];
+    System.arraycopy(buf, start, ret, 0, ret.length);
+    start = 0;
+    end = 0;
+    return ret;
+  }
+
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/StreamManipulator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/StreamManipulator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/StreamManipulator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/StreamManipulator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,216 @@
+/* java.util.zip.StreamManipulator
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+/**
+ * This class allows us to retrieve a specified amount of bits from
+ * the input buffer, as well as copy big byte blocks.
+ *
+ * It uses an int buffer to store up to 31 bits for direct
+ * manipulation.  This guarantees that we can get at least 16 bits,
+ * but we only need at most 15, so this is all safe.
+ *
+ * There are some optimizations in this class, for example, you must
+ * never peek more then 8 bits more than needed, and you must first 
+ * peek bits before you may drop them.  This is not a general purpose
+ * class but optimized for the behaviour of the Inflater.
+ *
+ * @author John Leuner, Jochen Hoenicke
+ */
+
+class StreamManipulator
+{
+  private byte[] window;
+  private int window_start = 0;
+  private int window_end = 0;
+
+  private int buffer = 0;
+  private int bits_in_buffer = 0;
+
+  /**
+   * Get the next n bits but don't increase input pointer.  n must be
+   * less or equal 16 and if you if this call succeeds, you must drop
+   * at least n-8 bits in the next call.
+   * 
+   * @return the value of the bits, or -1 if not enough bits available.  */
+  public final int peekBits(int n)
+  {
+    if (bits_in_buffer < n)
+      {
+	if (window_start == window_end)
+	  return -1;
+	buffer |= (window[window_start++] & 0xff
+		   | (window[window_start++] & 0xff) << 8) << bits_in_buffer;
+	bits_in_buffer += 16;
+      }
+    return buffer & ((1 << n) - 1);
+  }
+
+  /* Drops the next n bits from the input.  You should have called peekBits
+   * with a bigger or equal n before, to make sure that enough bits are in
+   * the bit buffer.
+   */
+  public final void dropBits(int n)
+  {
+    buffer >>>= n;
+    bits_in_buffer -= n;
+  }
+
+  /**
+   * Gets the next n bits and increases input pointer.  This is equivalent
+   * to peekBits followed by dropBits, except for correct error handling.
+   * @return the value of the bits, or -1 if not enough bits available. 
+   */
+  public final int getBits(int n)
+  {
+    int bits = peekBits(n);
+    if (bits >= 0)
+      dropBits(n);
+    return bits;
+  }
+  /**
+   * Gets the number of bits available in the bit buffer.  This must be
+   * only called when a previous peekBits() returned -1.
+   * @return the number of bits available.
+   */
+  public final int getAvailableBits()
+  {
+    return bits_in_buffer;
+  }
+
+  /**
+   * Gets the number of bytes available.  
+   * @return the number of bytes available.
+   */
+  public final int getAvailableBytes()
+  {
+    return window_end - window_start + (bits_in_buffer >> 3);
+  }
+
+  /**
+   * Skips to the next byte boundary.
+   */
+  public void skipToByteBoundary()
+  {
+    buffer >>= (bits_in_buffer & 7);
+    bits_in_buffer &= ~7;
+  }
+
+  public final boolean needsInput() {
+    return window_start == window_end;
+  }
+
+
+  /* Copies length bytes from input buffer to output buffer starting
+   * at output[offset].  You have to make sure, that the buffer is
+   * byte aligned.  If not enough bytes are available, copies fewer
+   * bytes.
+   * @param length the length to copy, 0 is allowed.
+   * @return the number of bytes copied, 0 if no byte is available.  
+   */
+  public int copyBytes(byte[] output, int offset, int length)
+  {
+    if (length < 0)
+      throw new IllegalArgumentException("length negative");
+    if ((bits_in_buffer & 7) != 0)  
+      /* bits_in_buffer may only be 0 or 8 */
+      throw new IllegalStateException("Bit buffer is not aligned!");
+
+    int count = 0;
+    while (bits_in_buffer > 0 && length > 0)
+      {
+	output[offset++] = (byte) buffer;
+	buffer >>>= 8;
+	bits_in_buffer -= 8;
+	length--;
+	count++;
+      }
+    if (length == 0)
+      return count;
+
+    int avail = window_end - window_start;
+    if (length > avail)
+      length = avail;
+    System.arraycopy(window, window_start, output, offset, length);
+    window_start += length;
+
+    if (((window_start - window_end) & 1) != 0)
+      {
+	/* We always want an even number of bytes in input, see peekBits */
+	buffer = (window[window_start++] & 0xff);
+	bits_in_buffer = 8;
+      }
+    return count + length;
+  }
+
+  public StreamManipulator()
+  {
+  }
+
+  public void reset()
+  {
+    window_start = window_end = buffer = bits_in_buffer = 0;
+  }
+
+  public void setInput(byte[] buf, int off, int len)
+  {
+    if (window_start < window_end)
+      throw new IllegalStateException
+	("Old input was not completely processed");
+
+    int end = off + len;
+
+    /* We want to throw an ArrayIndexOutOfBoundsException early.  The
+     * check is very tricky: it also handles integer wrap around.  
+     */
+    if (0 > off || off > end || end > buf.length)
+      throw new ArrayIndexOutOfBoundsException();
+    
+    if ((len & 1) != 0)
+      {
+	/* We always want an even number of bytes in input, see peekBits */
+	buffer |= (buf[off++] & 0xff) << bits_in_buffer;
+	bits_in_buffer += 8;
+      }
+    
+    window = buf;
+    window_start = off;
+    window_end = end;
+  }
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipConstants.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipConstants.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipConstants.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipConstants.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,94 @@
+/* java.util.zip.ZipConstants
+   Copyright (C) 2001, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+interface ZipConstants
+{
+  /* The local file header */
+  int LOCHDR = 30;
+  long LOCSIG = 'P'|('K'<<8)|(3<<16)|(4<<24);
+
+  int LOCVER =  4;
+  int LOCFLG =  6;
+  int LOCHOW =  8;
+  int LOCTIM = 10;
+  int LOCCRC = 14;
+  int LOCSIZ = 18;
+  int LOCLEN = 22;
+  int LOCNAM = 26;
+  int LOCEXT = 28;
+
+  /* The Data descriptor */
+  long EXTSIG = 'P'|('K'<<8)|(7<<16)|(8<<24);
+  int EXTHDR = 16;
+
+  int EXTCRC =  4;
+  int EXTSIZ =  8;
+  int EXTLEN = 12;
+
+  /* The central directory file header */
+  long CENSIG = 'P'|('K'<<8)|(1<<16)|(2<<24);
+  int CENHDR = 46;
+
+  int CENVEM =  4;
+  int CENVER =  6;
+  int CENFLG =  8;
+  int CENHOW = 10;
+  int CENTIM = 12;
+  int CENCRC = 16;
+  int CENSIZ = 20;
+  int CENLEN = 24;
+  int CENNAM = 28;
+  int CENEXT = 30;
+  int CENCOM = 32;
+  int CENDSK = 34;
+  int CENATT = 36;
+  int CENATX = 38;
+  int CENOFF = 42;
+
+  /* The entries in the end of central directory */
+  long ENDSIG = 'P'|('K'<<8)|(5<<16)|(6<<24);
+  int ENDHDR = 22;
+
+  int ENDSUB =  8;
+  int ENDTOT = 10;
+  int ENDSIZ = 12;
+  int ENDOFF = 16;
+  int ENDCOM = 20;
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipEntry.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipEntry.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipEntry.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipEntry.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,431 @@
+/* ZipEntry.java --
+   Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.zip;
+
+import java.util.Calendar;
+
+/**
+ * This class represents a member of a zip archive.  ZipFile and
+ * ZipInputStream will give you instances of this class as information
+ * about the members in an archive.  On the other hand ZipOutputStream
+ * needs an instance of this class to create a new member.
+ *
+ * @author Jochen Hoenicke 
+ */
+public class ZipEntry implements ZipConstants, Cloneable
+{
+  private static final int KNOWN_SIZE   = 1;
+  private static final int KNOWN_CSIZE  = 2;
+  private static final int KNOWN_CRC    = 4;
+  private static final int KNOWN_TIME   = 8;
+  private static final int KNOWN_EXTRA  = 16;
+
+  private static Calendar cal;
+
+  private String name;
+  private int size;
+  private long compressedSize = -1;
+  private int crc;
+  private int dostime;
+  private short known = 0;
+  private short method = -1;
+  private byte[] extra = null;
+  private String comment = null;
+
+  int flags;              /* used by ZipOutputStream */
+  int offset;             /* used by ZipFile and ZipOutputStream */
+
+  /**
+   * Compression method.  This method doesn't compress at all.
+   */
+  public static final int STORED = 0;
+  /**
+   * Compression method.  This method uses the Deflater.
+   */
+  public static final int DEFLATED = 8;
+
+  /**
+   * Creates a zip entry with the given name.
+   * @param name the name. May include directory components separated
+   * by '/'.
+   *
+   * @exception NullPointerException when name is null.
+   * @exception IllegalArgumentException when name is bigger then 65535 chars.
+   */
+  public ZipEntry(String name)
+  {
+    int length = name.length();
+    if (length > 65535)
+      throw new IllegalArgumentException("name length is " + length);
+    this.name = name;
+  }
+
+  /**
+   * Creates a copy of the given zip entry.
+   * @param e the entry to copy.
+   */
+  public ZipEntry(ZipEntry e)
+  {
+    this(e, e.name);
+  }
+
+  ZipEntry(ZipEntry e, String name)
+  {
+    this.name = name;
+    known = e.known;
+    size = e.size;
+    compressedSize = e.compressedSize;
+    crc = e.crc;
+    dostime = e.dostime;
+    method = e.method;
+    extra = e.extra;
+    comment = e.comment;
+  }
+
+  final void setDOSTime(int dostime)
+  {
+    this.dostime = dostime;
+    known |= KNOWN_TIME;
+  }
+
+  final int getDOSTime()
+  {
+    if ((known & KNOWN_TIME) == 0)
+      return 0;
+    else
+      return dostime;
+  }
+
+  /**
+   * Creates a copy of this zip entry.
+   */
+  /**
+   * Clones the entry.
+   */
+  public Object clone()
+  {
+    try
+      {
+	// The JCL says that the `extra' field is also copied.
+	ZipEntry clone = (ZipEntry) super.clone();
+	if (extra != null)
+	  clone.extra = (byte[]) extra.clone();
+	return clone;
+      }
+    catch (CloneNotSupportedException ex)
+      {
+	throw new InternalError();
+      }
+  }
+
+  /**
+   * Returns the entry name.  The path components in the entry are
+   * always separated by slashes ('/').  
+   */
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Sets the time of last modification of the entry.
+   * @time the time of last modification of the entry.
+   */
+  public void setTime(long time)
+  {
+    Calendar cal = getCalendar();
+    synchronized (cal)
+      {
+	cal.setTimeInMillis(time);
+	dostime = (cal.get(Calendar.YEAR) - 1980 & 0x7f) << 25
+	  | (cal.get(Calendar.MONTH) + 1) << 21
+	  | (cal.get(Calendar.DAY_OF_MONTH)) << 16
+	  | (cal.get(Calendar.HOUR_OF_DAY)) << 11
+	  | (cal.get(Calendar.MINUTE)) << 5
+	  | (cal.get(Calendar.SECOND)) >> 1;
+      }
+    this.known |= KNOWN_TIME;
+  }
+
+  /**
+   * Gets the time of last modification of the entry.
+   * @return the time of last modification of the entry, or -1 if unknown.
+   */
+  public long getTime()
+  {
+    // The extra bytes might contain the time (posix/unix extension)
+    parseExtra();
+
+    if ((known & KNOWN_TIME) == 0)
+      return -1;
+
+    int sec = 2 * (dostime & 0x1f);
+    int min = (dostime >> 5) & 0x3f;
+    int hrs = (dostime >> 11) & 0x1f;
+    int day = (dostime >> 16) & 0x1f;
+    int mon = ((dostime >> 21) & 0xf) - 1;
+    int year = ((dostime >> 25) & 0x7f) + 1980; /* since 1900 */
+   
+    try
+      {
+	cal = getCalendar();
+	synchronized (cal)
+	  {
+	    cal.set(year, mon, day, hrs, min, sec);
+	    return cal.getTimeInMillis();
+	  }
+      }
+    catch (RuntimeException ex)
+      {
+	/* Ignore illegal time stamp */
+	known &= ~KNOWN_TIME;
+	return -1;
+      }
+  }
+
+  private static synchronized Calendar getCalendar()
+  {
+    if (cal == null)
+      cal = Calendar.getInstance();
+
+    return cal;
+  }
+
+  /**
+   * Sets the size of the uncompressed data.
+   * @exception IllegalArgumentException if size is not in 0..0xffffffffL
+   */
+  public void setSize(long size)
+  {
+    if ((size & 0xffffffff00000000L) != 0)
+	throw new IllegalArgumentException();
+    this.size = (int) size;
+    this.known |= KNOWN_SIZE;
+  }
+
+  /**
+   * Gets the size of the uncompressed data.
+   * @return the size or -1 if unknown.
+   */
+  public long getSize()
+  {
+    return (known & KNOWN_SIZE) != 0 ? size & 0xffffffffL : -1L;
+  }
+
+  /**
+   * Sets the size of the compressed data.
+   */
+  public void setCompressedSize(long csize)
+  {
+    this.compressedSize = csize;
+  }
+
+  /**
+   * Gets the size of the compressed data.
+   * @return the size or -1 if unknown.
+   */
+  public long getCompressedSize()
+  {
+    return compressedSize;
+  }
+
+  /**
+   * Sets the crc of the uncompressed data.
+   * @exception IllegalArgumentException if crc is not in 0..0xffffffffL
+   */
+  public void setCrc(long crc)
+  {
+    if ((crc & 0xffffffff00000000L) != 0)
+	throw new IllegalArgumentException();
+    this.crc = (int) crc;
+    this.known |= KNOWN_CRC;
+  }
+
+  /**
+   * Gets the crc of the uncompressed data.
+   * @return the crc or -1 if unknown.
+   */
+  public long getCrc()
+  {
+    return (known & KNOWN_CRC) != 0 ? crc & 0xffffffffL : -1L;
+  }
+
+  /**
+   * Sets the compression method.  Only DEFLATED and STORED are
+   * supported.
+   * @exception IllegalArgumentException if method is not supported.
+   * @see ZipOutputStream#DEFLATED
+   * @see ZipOutputStream#STORED 
+   */
+  public void setMethod(int method)
+  {
+    if (method != ZipOutputStream.STORED
+	&& method != ZipOutputStream.DEFLATED)
+	throw new IllegalArgumentException();
+    this.method = (short) method;
+  }
+
+  /**
+   * Gets the compression method.  
+   * @return the compression method or -1 if unknown.
+   */
+  public int getMethod()
+  {
+    return method;
+  }
+
+  /**
+   * Sets the extra data.
+   * @exception IllegalArgumentException if extra is longer than 0xffff bytes.
+   */
+  public void setExtra(byte[] extra)
+  {
+    if (extra == null) 
+      {
+	this.extra = null;
+	return;
+      }
+    if (extra.length > 0xffff)
+      throw new IllegalArgumentException();
+    this.extra = extra;
+  }
+
+  private void parseExtra()
+  {
+    // Already parsed?
+    if ((known & KNOWN_EXTRA) != 0)
+      return;
+
+    if (extra == null)
+      {
+	known |= KNOWN_EXTRA;
+	return;
+      }
+
+    try
+      {
+	int pos = 0;
+	while (pos < extra.length) 
+	  {
+	    int sig = (extra[pos++] & 0xff)
+	      | (extra[pos++] & 0xff) << 8;
+	    int len = (extra[pos++] & 0xff)
+	      | (extra[pos++] & 0xff) << 8;
+	    if (sig == 0x5455) 
+	      {
+		/* extended time stamp */
+		int flags = extra[pos];
+		if ((flags & 1) != 0)
+		  {
+		    long time = ((extra[pos+1] & 0xff)
+			    | (extra[pos+2] & 0xff) << 8
+			    | (extra[pos+3] & 0xff) << 16
+			    | (extra[pos+4] & 0xff) << 24);
+		    setTime(time);
+		  }
+	      }
+	    pos += len;
+	  }
+      }
+    catch (ArrayIndexOutOfBoundsException ex)
+      {
+	/* be lenient */
+      }
+
+    known |= KNOWN_EXTRA;
+    return;
+  }
+
+  /**
+   * Gets the extra data.
+   * @return the extra data or null if not set.
+   */
+  public byte[] getExtra()
+  {
+    return extra;
+  }
+
+  /**
+   * Sets the entry comment.
+   * @exception IllegalArgumentException if comment is longer than 0xffff.
+   */
+  public void setComment(String comment)
+  {
+    if (comment != null && comment.length() > 0xffff)
+      throw new IllegalArgumentException();
+    this.comment = comment;
+  }
+
+  /**
+   * Gets the comment.
+   * @return the comment or null if not set.
+   */
+  public String getComment()
+  {
+    return comment;
+  }
+
+  /**
+   * Gets true, if the entry is a directory.  This is solely
+   * determined by the name, a trailing slash '/' marks a directory.  
+   */
+  public boolean isDirectory()
+  {
+    int nlen = name.length();
+    return nlen > 0 && name.charAt(nlen - 1) == '/';
+  }
+
+  /**
+   * Gets the string representation of this ZipEntry.  This is just
+   * the name as returned by getName().
+   */
+  public String toString()
+  {
+    return name;
+  }
+
+  /**
+   * Gets the hashCode of this ZipEntry.  This is just the hashCode
+   * of the name.  Note that the equals method isn't changed, though.
+   */
+  public int hashCode()
+  {
+    return name.hashCode();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* ZipException.java - exception representing a zip related error
+   Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util.zip;
+
+import java.io.IOException;
+
+/**
+ * Thrown during the creation or input of a zip file.
+ *
+ * @author Jochen Hoenicke
+ * @author Per Bothner
+ * @status updated to 1.4
+ */
+public class ZipException extends IOException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 8000196834066748623L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public ZipException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param msg the message
+   */
+  public ZipException (String msg)
+  {
+    super(msg);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipFile.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipFile.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipFile.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipFile.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,705 @@
+/* ZipFile.java --
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.zip;
+
+import gnu.java.util.EmptyEnumeration;
+
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.RandomAccessFile;
+import java.io.UnsupportedEncodingException;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+
+/**
+ * This class represents a Zip archive.  You can ask for the contained
+ * entries, or get an input stream for a file entry.  The entry is
+ * automatically decompressed.
+ *
+ * This class is thread safe:  You can open input streams for arbitrary
+ * entries in different threads.
+ *
+ * @author Jochen Hoenicke
+ * @author Artur Biesiadowski
+ */
+public class ZipFile implements ZipConstants
+{
+
+  /**
+   * Mode flag to open a zip file for reading.
+   */
+  public static final int OPEN_READ = 0x1;
+
+  /**
+   * Mode flag to delete a zip file after reading.
+   */
+  public static final int OPEN_DELETE = 0x4;
+
+  /**
+   * This field isn't defined in the JDK's ZipConstants, but should be.
+   */
+  static final int ENDNRD =  4;
+
+  // Name of this zip file.
+  private final String name;
+
+  // File from which zip entries are read.
+  private final RandomAccessFile raf;
+
+  // The entries of this zip file when initialized and not yet closed.
+  private LinkedHashMap entries;
+
+  private boolean closed = false;
+
+
+  /**
+   * Helper function to open RandomAccessFile and throw the proper
+   * ZipException in case opening the file fails.
+   *
+   * @param name the file name, or null if file is provided
+   *
+   * @param file the file, or null if name is provided
+   *
+   * @return the newly open RandomAccessFile, never null
+   */
+  private RandomAccessFile openFile(String name, 
+                                    File file) 
+    throws ZipException, IOException
+  {                                       
+    try 
+      {
+        return 
+          (name != null)
+          ? new RandomAccessFile(name, "r")
+          : new RandomAccessFile(file, "r");
+      }
+    catch (FileNotFoundException f)
+      { 
+        ZipException ze = new ZipException(f.getMessage());
+        ze.initCause(f);
+        throw ze;
+      }
+  }
+
+
+  /**
+   * Opens a Zip file with the given name for reading.
+   * @exception IOException if a i/o error occured.
+   * @exception ZipException if the file doesn't contain a valid zip
+   * archive.  
+   */
+  public ZipFile(String name) throws ZipException, IOException
+  {
+    this.raf = openFile(name,null);
+    this.name = name;
+    checkZipFile();
+  }
+
+  /**
+   * Opens a Zip file reading the given File.
+   * @exception IOException if a i/o error occured.
+   * @exception ZipException if the file doesn't contain a valid zip
+   * archive.  
+   */
+  public ZipFile(File file) throws ZipException, IOException
+  {
+    this.raf = openFile(null,file);
+    this.name = file.getPath();
+    checkZipFile();
+  }
+
+  /**
+   * Opens a Zip file reading the given File in the given mode.
+   *
+   * If the OPEN_DELETE mode is specified, the zip file will be deleted at
+   * some time moment after it is opened. It will be deleted before the zip
+   * file is closed or the Virtual Machine exits.
+   * 
+   * The contents of the zip file will be accessible until it is closed.
+   *
+   * @since JDK1.3
+   * @param mode Must be one of OPEN_READ or OPEN_READ | OPEN_DELETE
+   *
+   * @exception IOException if a i/o error occured.
+   * @exception ZipException if the file doesn't contain a valid zip
+   * archive.  
+   */
+  public ZipFile(File file, int mode) throws ZipException, IOException
+  {
+    if (mode != OPEN_READ && mode != (OPEN_READ | OPEN_DELETE))
+      throw new IllegalArgumentException("invalid mode");
+    if ((mode & OPEN_DELETE) != 0)
+      file.deleteOnExit();
+    this.raf = openFile(null,file);
+    this.name = file.getPath();
+    checkZipFile();
+  }
+
+  private void checkZipFile() throws ZipException
+  {
+    boolean valid = false;
+
+    try 
+      {
+        byte[] buf = new byte[4];
+        raf.readFully(buf);
+        int sig = buf[0] & 0xFF
+                | ((buf[1] & 0xFF) << 8)
+                | ((buf[2] & 0xFF) << 16)
+                | ((buf[3] & 0xFF) << 24);
+        valid = sig == LOCSIG;
+      }
+    catch (IOException _)
+      {
+      } 
+
+    if (!valid)
+      {
+        try
+          {
+	    raf.close();
+          }
+        catch (IOException _)
+          {
+          }
+	throw new ZipException("Not a valid zip file");
+      }
+  }
+
+  /**
+   * Checks if file is closed and throws an exception.
+   */
+  private void checkClosed()
+  {
+    if (closed)
+      throw new IllegalStateException("ZipFile has closed: " + name);
+  }
+
+  /**
+   * Read the central directory of a zip file and fill the entries
+   * array.  This is called exactly once when first needed. It is called
+   * while holding the lock on <code>raf</code>.
+   *
+   * @exception IOException if a i/o error occured.
+   * @exception ZipException if the central directory is malformed 
+   */
+  private void readEntries() throws ZipException, IOException
+  {
+    /* Search for the End Of Central Directory.  When a zip comment is 
+     * present the directory may start earlier.
+     * Note that a comment has a maximum length of 64K, so that is the
+     * maximum we search backwards.
+     */
+    PartialInputStream inp = new PartialInputStream(raf, 4096);
+    long pos = raf.length() - ENDHDR;
+    long top = Math.max(0, pos - 65536);
+    do
+      {
+	if (pos < top)
+	  throw new ZipException
+	    ("central directory not found, probably not a zip file: " + name);
+	inp.seek(pos--);
+      }
+    while (inp.readLeInt() != ENDSIG);
+    
+    if (inp.skip(ENDTOT - ENDNRD) != ENDTOT - ENDNRD)
+      throw new EOFException(name);
+    int count = inp.readLeShort();
+    if (inp.skip(ENDOFF - ENDSIZ) != ENDOFF - ENDSIZ)
+      throw new EOFException(name);
+    int centralOffset = inp.readLeInt();
+
+    entries = new LinkedHashMap(count+count/2);
+    inp.seek(centralOffset);
+    
+    for (int i = 0; i < count; i++)
+      {
+	if (inp.readLeInt() != CENSIG)
+	  throw new ZipException("Wrong Central Directory signature: " + name);
+
+        inp.skip(6);
+	int method = inp.readLeShort();
+	int dostime = inp.readLeInt();
+	int crc = inp.readLeInt();
+	int csize = inp.readLeInt();
+	int size = inp.readLeInt();
+	int nameLen = inp.readLeShort();
+	int extraLen = inp.readLeShort();
+	int commentLen = inp.readLeShort();
+        inp.skip(8);
+	int offset = inp.readLeInt();
+	String name = inp.readString(nameLen);
+
+	ZipEntry entry = new ZipEntry(name);
+	entry.setMethod(method);
+	entry.setCrc(crc & 0xffffffffL);
+	entry.setSize(size & 0xffffffffL);
+	entry.setCompressedSize(csize & 0xffffffffL);
+	entry.setDOSTime(dostime);
+	if (extraLen > 0)
+	  {
+	    byte[] extra = new byte[extraLen];
+	    inp.readFully(extra);
+	    entry.setExtra(extra);
+	  }
+	if (commentLen > 0)
+	  {
+            entry.setComment(inp.readString(commentLen));
+	  }
+	entry.offset = offset;
+	entries.put(name, entry);
+      }
+  }
+
+  /**
+   * Closes the ZipFile.  This also closes all input streams given by
+   * this class.  After this is called, no further method should be
+   * called.
+   * 
+   * @exception IOException if a i/o error occured.
+   */
+  public void close() throws IOException
+  {
+    RandomAccessFile raf = this.raf;
+    if (raf == null)
+      return;
+
+    synchronized (raf)
+      {
+	closed = true;
+	entries = null;
+	raf.close();
+      }
+  }
+
+  /**
+   * Calls the <code>close()</code> method when this ZipFile has not yet
+   * been explicitly closed.
+   */
+  protected void finalize() throws IOException
+  {
+    if (!closed && raf != null) close();
+  }
+
+  /**
+   * Returns an enumeration of all Zip entries in this Zip file.
+   *
+   * @exception IllegalStateException when the ZipFile has already been closed
+   */
+  public Enumeration entries()
+  {
+    checkClosed();
+    
+    try
+      {
+	return new ZipEntryEnumeration(getEntries().values().iterator());
+      }
+    catch (IOException ioe)
+      {
+	return EmptyEnumeration.getInstance();
+      }
+  }
+
+  /**
+   * Checks that the ZipFile is still open and reads entries when necessary.
+   *
+   * @exception IllegalStateException when the ZipFile has already been closed.
+   * @exception IOException when the entries could not be read.
+   */
+  private LinkedHashMap getEntries() throws IOException
+  {
+    synchronized(raf)
+      {
+	checkClosed();
+
+	if (entries == null)
+	  readEntries();
+
+	return entries;
+      }
+  }
+
+  /**
+   * Searches for a zip entry in this archive with the given name.
+   *
+   * @param name the name. May contain directory components separated by
+   * slashes ('/').
+   * @return the zip entry, or null if no entry with that name exists.
+   *
+   * @exception IllegalStateException when the ZipFile has already been closed
+   */
+  public ZipEntry getEntry(String name)
+  {
+    checkClosed();
+
+    try
+      {
+	LinkedHashMap entries = getEntries();
+	ZipEntry entry = (ZipEntry) entries.get(name);
+        // If we didn't find it, maybe it's a directory.
+        if (entry == null && !name.endsWith("/"))
+            entry = (ZipEntry) entries.get(name + '/');
+	return entry != null ? new ZipEntry(entry, name) : null;
+      }
+    catch (IOException ioe)
+      {
+	return null;
+      }
+  }
+
+  /**
+   * Creates an input stream reading the given zip entry as
+   * uncompressed data.  Normally zip entry should be an entry
+   * returned by getEntry() or entries().
+   *
+   * This implementation returns null if the requested entry does not
+   * exist.  This decision is not obviously correct, however, it does
+   * appear to mirror Sun's implementation, and it is consistant with
+   * their javadoc.  On the other hand, the old JCL book, 2nd Edition,
+   * claims that this should return a "non-null ZIP entry".  We have
+   * chosen for now ignore the old book, as modern versions of Ant (an
+   * important application) depend on this behaviour.  See discussion
+   * in this thread:
+   * http://gcc.gnu.org/ml/java-patches/2004-q2/msg00602.html
+   *
+   * @param entry the entry to create an InputStream for.
+   * @return the input stream, or null if the requested entry does not exist.
+   *
+   * @exception IllegalStateException when the ZipFile has already been closed
+   * @exception IOException if a i/o error occured.
+   * @exception ZipException if the Zip archive is malformed.  
+   */
+  public InputStream getInputStream(ZipEntry entry) throws IOException
+  {
+    checkClosed();
+
+    LinkedHashMap entries = getEntries();
+    String name = entry.getName();
+    ZipEntry zipEntry = (ZipEntry) entries.get(name);
+    if (zipEntry == null)
+      return null;
+
+    PartialInputStream inp = new PartialInputStream(raf, 1024);
+    inp.seek(zipEntry.offset);
+
+    if (inp.readLeInt() != LOCSIG)
+      throw new ZipException("Wrong Local header signature: " + name);
+
+    inp.skip(4);
+
+    if (zipEntry.getMethod() != inp.readLeShort())
+      throw new ZipException("Compression method mismatch: " + name);
+
+    inp.skip(16);
+
+    int nameLen = inp.readLeShort();
+    int extraLen = inp.readLeShort();
+    inp.skip(nameLen + extraLen);
+
+    inp.setLength(zipEntry.getCompressedSize());
+
+    int method = zipEntry.getMethod();
+    switch (method)
+      {
+      case ZipOutputStream.STORED:
+	return inp;
+      case ZipOutputStream.DEFLATED:
+        inp.addDummyByte();
+        final Inflater inf = new Inflater(true);
+        final int sz = (int) entry.getSize();
+        return new InflaterInputStream(inp, inf)
+        {
+          public int available() throws IOException
+          {
+            if (sz == -1)
+              return super.available();
+            if (super.available() != 0)
+              return sz - inf.getTotalOut();
+            return 0;
+          }
+        };
+      default:
+	throw new ZipException("Unknown compression method " + method);
+      }
+  }
+  
+  /**
+   * Returns the (path) name of this zip file.
+   */
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Returns the number of entries in this zip file.
+   *
+   * @exception IllegalStateException when the ZipFile has already been closed
+   */
+  public int size()
+  {
+    checkClosed();
+    
+    try
+      {
+	return getEntries().size();
+      }
+    catch (IOException ioe)
+      {
+	return 0;
+      }
+  }
+  
+  private static class ZipEntryEnumeration implements Enumeration
+  {
+    private final Iterator elements;
+
+    public ZipEntryEnumeration(Iterator elements)
+    {
+      this.elements = elements;
+    }
+
+    public boolean hasMoreElements()
+    {
+      return elements.hasNext();
+    }
+
+    public Object nextElement()
+    {
+      /* We return a clone, just to be safe that the user doesn't
+       * change the entry.  
+       */
+      return ((ZipEntry)elements.next()).clone();
+    }
+  }
+
+  private static final class PartialInputStream extends InputStream
+  {
+    private final RandomAccessFile raf;
+    private final byte[] buffer;
+    private long bufferOffset;
+    private int pos;
+    private long end;
+    // We may need to supply an extra dummy byte to our reader.
+    // See Inflater.  We use a count here to simplify the logic
+    // elsewhere in this class.  Note that we ignore the dummy
+    // byte in methods where we know it is not needed.
+    private int dummyByteCount;
+
+    public PartialInputStream(RandomAccessFile raf, int bufferSize)
+      throws IOException
+    {
+      this.raf = raf;
+      buffer = new byte[bufferSize];
+      bufferOffset = -buffer.length;
+      pos = buffer.length;
+      end = raf.length();
+    }
+
+    void setLength(long length)
+    {
+      end = bufferOffset + pos + length;
+    }
+
+    private void fillBuffer() throws IOException
+    {
+      synchronized (raf)
+        {
+          long len = end - bufferOffset;
+          if (len == 0 && dummyByteCount > 0)
+            {
+              buffer[0] = 0;
+              dummyByteCount = 0;
+            }
+          else
+            {
+              raf.seek(bufferOffset);
+              raf.readFully(buffer, 0, (int) Math.min(buffer.length, len));
+            }
+        }
+    }
+    
+    public int available()
+    {
+      long amount = end - (bufferOffset + pos);
+      if (amount > Integer.MAX_VALUE)
+	return Integer.MAX_VALUE;
+      return (int) amount;
+    }
+    
+    public int read() throws IOException
+    {
+      if (bufferOffset + pos >= end + dummyByteCount)
+	return -1;
+      if (pos == buffer.length)
+        {
+          bufferOffset += buffer.length;
+          pos = 0;
+          fillBuffer();
+        }
+      
+      return buffer[pos++] & 0xFF;
+    }
+
+    public int read(byte[] b, int off, int len) throws IOException
+    {
+      if (len > end + dummyByteCount - (bufferOffset + pos))
+	{
+	  len = (int) (end + dummyByteCount - (bufferOffset + pos));
+	  if (len == 0)
+	    return -1;
+	}
+
+      int totalBytesRead = Math.min(buffer.length - pos, len);
+      System.arraycopy(buffer, pos, b, off, totalBytesRead);
+      pos += totalBytesRead;
+      off += totalBytesRead;
+      len -= totalBytesRead;
+
+      while (len > 0)
+        {
+          bufferOffset += buffer.length;
+          pos = 0;
+          fillBuffer();
+          int remain = Math.min(buffer.length, len);
+          System.arraycopy(buffer, pos, b, off, remain);
+          pos += remain;
+          off += remain;
+          len -= remain;
+          totalBytesRead += remain;
+        }
+      
+      return totalBytesRead;
+    }
+
+    public long skip(long amount) throws IOException
+    {
+      if (amount < 0)
+	return 0;
+      if (amount > end - (bufferOffset + pos))
+	amount = end - (bufferOffset + pos);
+      seek(bufferOffset + pos + amount);
+      return amount;
+    }
+
+    void seek(long newpos) throws IOException
+    {
+      long offset = newpos - bufferOffset;
+      if (offset >= 0 && offset <= buffer.length)
+        {
+          pos = (int) offset;
+        }
+      else
+        {
+          bufferOffset = newpos;
+          pos = 0;
+          fillBuffer();
+        }
+    }
+
+    void readFully(byte[] buf) throws IOException
+    {
+      if (read(buf, 0, buf.length) != buf.length)
+        throw new EOFException();
+    }
+
+    void readFully(byte[] buf, int off, int len) throws IOException
+    {
+      if (read(buf, off, len) != len)
+        throw new EOFException();
+    }
+
+    int readLeShort() throws IOException
+    {
+      int b0 = read();
+      int b1 = read();
+      if (b1 == -1)
+        throw new EOFException();
+      return (b0 & 0xff) | (b1 & 0xff) << 8;
+    }
+
+    int readLeInt() throws IOException
+    {
+      int b0 = read();
+      int b1 = read();
+      int b2 = read();
+      int b3 = read();
+      if (b3 == -1)
+        throw new EOFException();
+      return ((b0 & 0xff) | (b1 & 0xff) << 8)
+            | ((b2 & 0xff) | (b3 & 0xff) << 8) << 16;
+    }
+
+    String readString(int length) throws IOException
+    {
+      if (length > end - (bufferOffset + pos))
+        throw new EOFException();
+
+      try
+        {
+          if (buffer.length - pos >= length)
+            {
+              String s = new String(buffer, pos, length, "UTF-8");
+              pos += length;
+              return s;
+            }
+          else
+            {
+              byte[] b = new byte[length];
+              readFully(b);
+              return new String(b, 0, length, "UTF-8");
+            }
+        }
+      catch (UnsupportedEncodingException uee)
+        {
+          throw new AssertionError(uee);
+        }
+    }
+
+    public void addDummyByte()
+    {
+      dummyByteCount = 1;
+    }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipInputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipInputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipInputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipInputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,380 @@
+/* ZipInputStream.java --
+   Copyright (C) 2001, 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.zip;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * This is a FilterInputStream that reads the files in an zip archive
+ * one after another.  It has a special method to get the zip entry of
+ * the next file.  The zip entry contains information about the file name
+ * size, compressed size, CRC, etc.
+ *
+ * It includes support for STORED and DEFLATED entries.
+ *
+ * @author Jochen Hoenicke
+ */
+public class ZipInputStream extends InflaterInputStream implements ZipConstants
+{
+  private CRC32 crc = new CRC32();
+  private ZipEntry entry = null;
+
+  private int csize;
+  private int size;
+  private int method;
+  private int flags;
+  private int avail;
+  private boolean entryAtEOF;
+
+  /**
+   * Creates a new Zip input stream, reading a zip archive.
+   */
+  public ZipInputStream(InputStream in)
+  {
+    super(in, new Inflater(true));
+  }
+
+  private void fillBuf() throws IOException
+  {
+    avail = len = in.read(buf, 0, buf.length);
+  }
+
+  private int readBuf(byte[] out, int offset, int length) throws IOException
+  {
+    if (avail <= 0)
+      {
+	fillBuf();
+	if (avail <= 0)
+	  return -1;
+      }
+    if (length > avail)
+      length = avail;
+    System.arraycopy(buf, len - avail, out, offset, length);
+    avail -= length;
+    return length;
+  }
+  
+  private void readFully(byte[] out) throws IOException
+  {
+    int off = 0;
+    int len = out.length;
+    while (len > 0)
+      {
+	int count = readBuf(out, off, len);
+	if (count == -1)
+	  throw new EOFException();
+	off += count;
+	len -= count;
+      }
+  }
+  
+  private int readLeByte() throws IOException
+  {
+    if (avail <= 0)
+      {
+	fillBuf();
+	if (avail <= 0)
+	  throw new ZipException("EOF in header");
+      }
+    return buf[len - avail--] & 0xff;
+  }
+
+  /**
+   * Read an unsigned short in little endian byte order.
+   */
+  private int readLeShort() throws IOException 
+  {
+    return readLeByte() | (readLeByte() << 8);
+  }
+
+  /**
+   * Read an int in little endian byte order.
+   */
+  private int readLeInt() throws IOException 
+  {
+    return readLeShort() | (readLeShort() << 16);
+  }
+
+  /**
+   * Open the next entry from the zip archive, and return its description.
+   * If the previous entry wasn't closed, this method will close it.
+   */
+  public ZipEntry getNextEntry() throws IOException
+  {
+    if (crc == null)
+      throw new IOException("Stream closed.");
+    if (entry != null)
+      closeEntry();
+
+    int header = readLeInt();
+    if (header == CENSIG)
+      {
+	/* Central Header reached. */
+	close();
+	return null;
+      }
+    if (header != LOCSIG)
+      throw new ZipException("Wrong Local header signature: "
+			     + Integer.toHexString(header));
+    /* skip version */
+    readLeShort();
+    flags = readLeShort();
+    method = readLeShort();
+    int dostime = readLeInt();
+    int crc = readLeInt();
+    csize = readLeInt();
+    size = readLeInt();
+    int nameLen = readLeShort();
+    int extraLen = readLeShort();
+
+    if (method == ZipOutputStream.STORED && csize != size)
+      throw new ZipException("Stored, but compressed != uncompressed");
+
+
+    byte[] buffer = new byte[nameLen];
+    readFully(buffer);
+    String name;
+    try
+      {
+	name = new String(buffer, "UTF-8");
+      }
+    catch (UnsupportedEncodingException uee)
+      {
+	throw new AssertionError(uee);
+      }
+    
+    entry = createZipEntry(name);
+    entryAtEOF = false;
+    entry.setMethod(method);
+    if ((flags & 8) == 0)
+      {
+	entry.setCrc(crc & 0xffffffffL);
+	entry.setSize(size & 0xffffffffL);
+	entry.setCompressedSize(csize & 0xffffffffL);
+      }
+    entry.setDOSTime(dostime);
+    if (extraLen > 0)
+      {
+	byte[] extra = new byte[extraLen];
+	readFully(extra);
+	entry.setExtra(extra);
+      }
+
+    if (method == ZipOutputStream.DEFLATED && avail > 0)
+      {
+	System.arraycopy(buf, len - avail, buf, 0, avail);
+	len = avail;
+	avail = 0;
+	inf.setInput(buf, 0, len);
+      }
+    return entry;
+  }
+
+  private void readDataDescr() throws IOException
+  {
+    if (readLeInt() != EXTSIG)
+      throw new ZipException("Data descriptor signature not found");
+    entry.setCrc(readLeInt() & 0xffffffffL);
+    csize = readLeInt();
+    size = readLeInt();
+    entry.setSize(size & 0xffffffffL);
+    entry.setCompressedSize(csize & 0xffffffffL);
+  }
+
+  /**
+   * Closes the current zip entry and moves to the next one.
+   */
+  public void closeEntry() throws IOException
+  {
+    if (crc == null)
+      throw new IOException("Stream closed.");
+    if (entry == null)
+      return;
+
+    if (method == ZipOutputStream.DEFLATED)
+      {
+	if ((flags & 8) != 0)
+	  {
+	    /* We don't know how much we must skip, read until end. */
+	    byte[] tmp = new byte[2048];
+	    while (read(tmp) > 0)
+	      ;
+	    /* read will close this entry */
+	    return;
+	  }
+	csize -= inf.getTotalIn();
+	avail = inf.getRemaining();
+      }
+
+    if (avail > csize && csize >= 0)
+      avail -= csize;
+    else
+      {
+	csize -= avail;
+	avail = 0;
+	while (csize != 0)
+	  {
+	    long skipped = in.skip(csize & 0xffffffffL);
+	    if (skipped <= 0)
+	      throw new ZipException("zip archive ends early.");
+	    csize -= skipped;
+	  }
+      }
+
+    size = 0;
+    crc.reset();
+    if (method == ZipOutputStream.DEFLATED)
+      inf.reset();
+    entry = null;
+    entryAtEOF = true;
+  }
+
+  public int available() throws IOException
+  {
+    return entryAtEOF ? 0 : 1;
+  }
+
+  /**
+   * Reads a byte from the current zip entry.
+   * @return the byte or -1 on EOF.
+   * @exception IOException if a i/o error occured.
+   * @exception ZipException if the deflated stream is corrupted.
+   */
+  public int read() throws IOException
+  {
+    byte[] b = new byte[1];
+    if (read(b, 0, 1) <= 0)
+      return -1;
+    return b[0] & 0xff;
+  }
+
+  /**
+   * Reads a block of bytes from the current zip entry.
+   * @return the number of bytes read (may be smaller, even before
+   * EOF), or -1 on EOF.
+   * @exception IOException if a i/o error occured.
+   * @exception ZipException if the deflated stream is corrupted.
+   */
+  public int read(byte[] b, int off, int len) throws IOException
+  {
+    if (len == 0)
+      return 0;
+    if (crc == null)
+      throw new IOException("Stream closed.");
+    if (entry == null)
+      return -1;
+    boolean finished = false;
+    switch (method)
+      {
+      case ZipOutputStream.DEFLATED:
+	len = super.read(b, off, len);
+	if (len < 0)
+	  {
+	    if (!inf.finished())
+	      throw new ZipException("Inflater not finished!?");
+	    avail = inf.getRemaining();
+	    if ((flags & 8) != 0)
+	      readDataDescr();
+
+	    if (inf.getTotalIn() != csize
+		|| inf.getTotalOut() != size)
+	      throw new ZipException("size mismatch: "+csize+";"+size+" <-> "+inf.getTotalIn()+";"+inf.getTotalOut());
+	    inf.reset();
+	    finished = true;
+	  }
+	break;
+	
+      case ZipOutputStream.STORED:
+
+	if (len > csize && csize >= 0)
+	  len = csize;
+	
+	len = readBuf(b, off, len);
+	if (len > 0)
+	  {
+	    csize -= len;
+	    size -= len;
+	  }
+
+	if (csize == 0)
+	  finished = true;
+	else if (len < 0)
+	  throw new ZipException("EOF in stored block");
+	break;
+      }
+
+    if (len > 0)
+      crc.update(b, off, len);
+
+    if (finished)
+      {
+	if ((crc.getValue() & 0xffffffffL) != entry.getCrc())
+	  throw new ZipException("CRC mismatch");
+	crc.reset();
+	entry = null;
+	entryAtEOF = true;
+      }
+    return len;
+  }
+
+  /**
+   * Closes the zip file.
+   * @exception IOException if a i/o error occured.
+   */
+  public void close() throws IOException
+  {
+    super.close();
+    crc = null;
+    entry = null;
+    entryAtEOF = true;
+  }
+
+  /**
+   * Creates a new zip entry for the given name.  This is equivalent
+   * to new ZipEntry(name).
+   * @param name the name of the zip entry.
+   */
+  protected ZipEntry createZipEntry(String name) 
+  {
+    return new ZipEntry(name);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipOutputStream.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipOutputStream.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipOutputStream.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/ZipOutputStream.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,440 @@
+/* ZipOutputStream.java --
+   Copyright (C) 2001, 2004, 2005, 2006  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util.zip;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * This is a FilterOutputStream that writes the files into a zip
+ * archive one after another.  It has a special method to start a new
+ * zip entry.  The zip entries contains information about the file name
+ * size, compressed size, CRC, etc.
+ *
+ * It includes support for STORED and DEFLATED entries.
+ *
+ * This class is not thread safe.
+ *
+ * @author Jochen Hoenicke 
+ */
+public class ZipOutputStream extends DeflaterOutputStream implements ZipConstants
+{
+  private Vector entries = new Vector();
+  private CRC32 crc = new CRC32();
+  private ZipEntry curEntry = null;
+
+  private int curMethod;
+  private int size;
+  private int offset = 0;
+
+  private byte[] zipComment = new byte[0];
+  private int defaultMethod = DEFLATED;
+
+  /**
+   * Our Zip version is hard coded to 1.0 resp. 2.0
+   */
+  private static final int ZIP_STORED_VERSION = 10;
+  private static final int ZIP_DEFLATED_VERSION = 20;
+
+  /**
+   * Compression method.  This method doesn't compress at all.
+   */
+  public static final int STORED = 0;
+  
+  /**
+   * Compression method.  This method uses the Deflater.
+   */
+  public static final int DEFLATED = 8;
+
+  /**
+   * Creates a new Zip output stream, writing a zip archive.
+   * @param out the output stream to which the zip archive is written.
+   */
+  public ZipOutputStream(OutputStream out)
+  {
+    super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true));
+  }
+
+  /**
+   * Set the zip file comment.
+   * @param comment the comment.
+   * @exception IllegalArgumentException if encoding of comment is
+   * longer than 0xffff bytes.
+   */
+  public void setComment(String comment)
+  {
+    byte[] commentBytes;
+    try
+      {
+	commentBytes = comment.getBytes("UTF-8");
+      }
+    catch (UnsupportedEncodingException uee)
+      {
+	throw new AssertionError(uee);
+      }
+    if (commentBytes.length > 0xffff)
+      throw new IllegalArgumentException("Comment too long.");
+    zipComment = commentBytes;
+  }
+  
+  /**
+   * Sets default compression method.  If the Zip entry specifies
+   * another method its method takes precedence.
+   * @param method the method.
+   * @exception IllegalArgumentException if method is not supported.
+   * @see #STORED
+   * @see #DEFLATED
+   */
+  public void setMethod(int method)
+  {
+    if (method != STORED && method != DEFLATED)
+      throw new IllegalArgumentException("Method not supported.");
+    defaultMethod = method;
+  }
+
+  /**
+   * Sets default compression level.  The new level will be activated
+   * immediately.  
+   * @exception IllegalArgumentException if level is not supported.
+   * @see Deflater
+   */
+  public void setLevel(int level)
+  {
+    def.setLevel(level);
+  }
+  
+  /**
+   * Write an unsigned short in little endian byte order.
+   */
+  private void writeLeShort(int value) throws IOException 
+  {
+    out.write(value & 0xff);
+    out.write((value >> 8) & 0xff);
+  }
+
+  /**
+   * Write an int in little endian byte order.
+   */
+  private void writeLeInt(int value) throws IOException 
+  {
+    writeLeShort(value);
+    writeLeShort(value >> 16);
+  }
+
+  /**
+   * Write a long value as an int.  Some of the zip constants
+   * are declared as longs even though they fit perfectly well
+   * into integers.
+   */
+  private void writeLeInt(long value) throws IOException
+  {
+    writeLeInt((int) value);
+  }
+
+  /**
+   * Starts a new Zip entry. It automatically closes the previous
+   * entry if present.  If the compression method is stored, the entry
+   * must have a valid size and crc, otherwise all elements (except
+   * name) are optional, but must be correct if present.  If the time
+   * is not set in the entry, the current time is used.
+   * @param entry the entry.
+   * @exception IOException if an I/O error occured.
+   * @exception ZipException if stream was finished.
+   */
+  public void putNextEntry(ZipEntry entry) throws IOException
+  {
+    if (entries == null)
+      throw new ZipException("ZipOutputStream was finished");
+
+    int method = entry.getMethod();
+    int flags = 0;
+    if (method == -1)
+      method = defaultMethod;
+
+    if (method == STORED)
+      {
+	if (entry.getCompressedSize() >= 0)
+	  {
+	    if (entry.getSize() < 0)
+	      entry.setSize(entry.getCompressedSize());
+	    else if (entry.getSize() != entry.getCompressedSize())
+	      throw new ZipException
+		("Method STORED, but compressed size != size");
+	  }
+	else
+	  entry.setCompressedSize(entry.getSize());
+
+	if (entry.getSize() < 0)
+	  throw new ZipException("Method STORED, but size not set");
+	if (entry.getCrc() < 0)
+	  throw new ZipException("Method STORED, but crc not set");
+      }
+    else if (method == DEFLATED)
+      {
+	if (entry.getCompressedSize() < 0
+	    || entry.getSize() < 0 || entry.getCrc() < 0)
+	  flags |= 8;
+      }
+
+    if (curEntry != null)
+      closeEntry();
+
+    if (entry.getTime() < 0)
+      entry.setTime(System.currentTimeMillis());
+
+    entry.flags = flags;
+    entry.offset = offset;
+    entry.setMethod(method);
+    curMethod = method;
+    /* Write the local file header */
+    writeLeInt(LOCSIG);
+    writeLeShort(method == STORED
+		 ? ZIP_STORED_VERSION : ZIP_DEFLATED_VERSION);
+    writeLeShort(flags);
+    writeLeShort(method);
+    writeLeInt(entry.getDOSTime());
+    if ((flags & 8) == 0)
+      {
+	writeLeInt((int)entry.getCrc());
+	writeLeInt((int)entry.getCompressedSize());
+	writeLeInt((int)entry.getSize());
+      }
+    else
+      {
+	writeLeInt(0);
+	writeLeInt(0);
+	writeLeInt(0);
+      }
+    byte[] name;
+    try
+      {
+	name = entry.getName().getBytes("UTF-8");
+      }
+    catch (UnsupportedEncodingException uee)
+      {
+	throw new AssertionError(uee);
+      }
+    if (name.length > 0xffff)
+      throw new ZipException("Name too long.");
+    byte[] extra = entry.getExtra();
+    if (extra == null)
+      extra = new byte[0];
+    writeLeShort(name.length);
+    writeLeShort(extra.length);
+    out.write(name);
+    out.write(extra);
+
+    offset += LOCHDR + name.length + extra.length;
+
+    /* Activate the entry. */
+
+    curEntry = entry;
+    crc.reset();
+    if (method == DEFLATED)
+      def.reset();
+    size = 0;
+  }
+
+  /**
+   * Closes the current entry.
+   * @exception IOException if an I/O error occured.
+   * @exception ZipException if no entry is active.
+   */
+  public void closeEntry() throws IOException
+  {
+    if (curEntry == null)
+      throw new ZipException("No open entry");
+
+    /* First finish the deflater, if appropriate */
+    if (curMethod == DEFLATED)
+      super.finish();
+
+    int csize = curMethod == DEFLATED ? def.getTotalOut() : size;
+
+    if (curEntry.getSize() < 0)
+      curEntry.setSize(size);
+    else if (curEntry.getSize() != size)
+      throw new ZipException("size was "+size
+			     +", but I expected "+curEntry.getSize());
+
+    if (curEntry.getCompressedSize() < 0)
+      curEntry.setCompressedSize(csize);
+    else if (curEntry.getCompressedSize() != csize)
+      throw new ZipException("compressed size was "+csize
+			     +", but I expected "+curEntry.getSize());
+
+    if (curEntry.getCrc() < 0)
+      curEntry.setCrc(crc.getValue());
+    else if (curEntry.getCrc() != crc.getValue())
+      throw new ZipException("crc was " + Long.toHexString(crc.getValue())
+			     + ", but I expected " 
+			     + Long.toHexString(curEntry.getCrc()));
+
+    offset += csize;
+
+    /* Now write the data descriptor entry if needed. */
+    if (curMethod == DEFLATED && (curEntry.flags & 8) != 0)
+      {
+	writeLeInt(EXTSIG);
+	writeLeInt((int)curEntry.getCrc());
+	writeLeInt((int)curEntry.getCompressedSize());
+	writeLeInt((int)curEntry.getSize());
+	offset += EXTHDR;
+      }
+
+    entries.addElement(curEntry);
+    curEntry = null;
+  }
+
+  /**
+   * Writes the given buffer to the current entry.
+   * @exception IOException if an I/O error occured.
+   * @exception ZipException if no entry is active.
+   */
+  public void write(byte[] b, int off, int len) throws IOException
+  {
+    if (curEntry == null)
+      throw new ZipException("No open entry.");
+
+    switch (curMethod)
+      {
+      case DEFLATED:
+	super.write(b, off, len);
+	break;
+	
+      case STORED:
+	out.write(b, off, len);
+	break;
+      }
+
+    crc.update(b, off, len);
+    size += len;
+  }
+
+  /**
+   * Finishes the stream.  This will write the central directory at the
+   * end of the zip file and flush the stream.
+   * @exception IOException if an I/O error occured.
+   */
+  public void finish() throws IOException
+  {
+    if (entries == null)
+      return;
+    if (curEntry != null)
+      closeEntry();
+
+    int numEntries = 0;
+    int sizeEntries = 0;
+    
+    Enumeration e = entries.elements();
+    while (e.hasMoreElements())
+      {
+	ZipEntry entry = (ZipEntry) e.nextElement();
+	
+	int method = entry.getMethod();
+	writeLeInt(CENSIG);
+	writeLeShort(method == STORED
+		     ? ZIP_STORED_VERSION : ZIP_DEFLATED_VERSION);
+	writeLeShort(method == STORED
+		     ? ZIP_STORED_VERSION : ZIP_DEFLATED_VERSION);
+	writeLeShort(entry.flags);
+	writeLeShort(method);
+	writeLeInt(entry.getDOSTime());
+	writeLeInt((int)entry.getCrc());
+	writeLeInt((int)entry.getCompressedSize());
+	writeLeInt((int)entry.getSize());
+
+	byte[] name;
+	try
+	  {
+	    name = entry.getName().getBytes("UTF-8");
+	  }
+	catch (UnsupportedEncodingException uee)
+	  {
+	    throw new AssertionError(uee);
+	  }
+	if (name.length > 0xffff)
+	  throw new ZipException("Name too long.");
+	byte[] extra = entry.getExtra();
+	if (extra == null)
+	  extra = new byte[0];
+	String str = entry.getComment();
+	byte[] comment;
+	try
+	  {
+	    comment = str != null ? str.getBytes("UTF-8") : new byte[0];
+	  }
+	catch (UnsupportedEncodingException uee)
+	  {
+	    throw new AssertionError(uee);
+	  }
+	if (comment.length > 0xffff)
+	  throw new ZipException("Comment too long.");
+
+	writeLeShort(name.length);
+	writeLeShort(extra.length);
+	writeLeShort(comment.length);
+	writeLeShort(0); /* disk number */
+	writeLeShort(0); /* internal file attr */
+	writeLeInt(0);   /* external file attr */
+	writeLeInt(entry.offset);
+
+	out.write(name);
+	out.write(extra);
+	out.write(comment);
+	numEntries++;
+	sizeEntries += CENHDR + name.length + extra.length + comment.length;
+      }
+
+    writeLeInt(ENDSIG);
+    writeLeShort(0); /* disk number */
+    writeLeShort(0); /* disk with start of central dir */
+    writeLeShort(numEntries);
+    writeLeShort(numEntries);
+    writeLeInt(sizeEntries);
+    writeLeInt(offset);
+    writeLeShort(zipComment.length);
+    out.write(zipComment);
+    out.flush();
+    entries = null;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/zip/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.util.zip package.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.util.zip</title></head>
+
+<body>
+<p>Utility classes to manipulate zip and gzip archives as files or streams,
+includes checksum and compression support.</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/Accessible.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/Accessible.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/Accessible.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/Accessible.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,61 @@
+/* Accessible.java -- primary Java accessibility interface
+   Copyright (C) 2000, 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+/**
+ * Implementing the Accessibility API must start with implementation
+ * of this interface at a bare minimum.  This is the major interface
+ * for the Accessibility API which must be implemented by all user
+ * interface components.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface Accessible
+{
+  /**
+   * If a component supports the Accessibility API then this method should
+   * not return <code>null</code>. Only classes which must extend an accessible
+   * class, but must not itself be accessible, may return null.
+   *
+   * @return the context associated with this accessible object
+   */
+  AccessibleContext getAccessibleContext();
+} // interface Accessible

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleAction.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleAction.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleAction.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleAction.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,104 @@
+/* AccessibleAction.java -- aids in accessibly performing actions
+   Copyright (C) 2000, 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+/**
+ * If an object implements this interface then it must be able to perform one
+ * or more actions. Accessibility software can use the implementations of this
+ * interface to discover and perform actions on an object.
+ *
+ * <p>The <code>AccessibleContext.getAccessibleAction()</code> method should
+ * return <code>null</code> if an object does not implement this interface.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleContext#getAccessibleAction()
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface AccessibleAction
+{
+
+  /**
+   * The name of an action which decrements a value.
+   *
+   * @since 1.5
+   */
+  static final String DECREMENT = "decrement";
+
+  /**
+   * The name of an action which increments a value.
+   *
+   * @since 1.5
+   */
+  static final String INCREMENT = "increment";
+
+  /**
+   * The name of an action which toggles the expansion of a tree node.
+   *
+   * @since 1.5
+   */
+  static final String TOGGLE_EXPAND = "toggle expand";
+
+  /**
+   * Get the number possible actions for this object, with the zeroth
+   * representing the default action.
+   *
+   * @return the 0-based number of actions
+   */
+  int getAccessibleActionCount();
+
+  /**
+   * Get a description for the specified action. Returns null if out of
+   * bounds.
+   *
+   * @param i the action to describe, 0-based
+   * @return description of the action
+   */
+  String getAccessibleActionDescription(int i);
+
+  /**
+   * Perform the specified action. Does nothing if out of bounds.
+   *
+   * @param i the action to perform, 0-based
+   * @return true if the action was performed
+   */
+  boolean doAccessibleAction(int i);
+} // interface AccessibleAction

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleAttributeSequence.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleAttributeSequence.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleAttributeSequence.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleAttributeSequence.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* AccessibleAttributeSequence.java
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+import javax.swing.text.AttributeSet;
+
+/**
+ * This is a convenience class that represents an accessible
+ * attribute sequence.
+ * @since 1.5
+ */
+public class AccessibleAttributeSequence
+{
+  /**
+   * The attributes of the text.
+   */
+  public AttributeSet attributes;
+
+  /**
+   * The starting index.
+   */
+  public int startIndex;
+
+  /**
+   * The ending index.
+   */
+  public int endIndex;
+
+  /**
+   * Create a new instance. 
+   */
+  public AccessibleAttributeSequence()
+  {
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleBundle.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleBundle.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleBundle.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleBundle.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,120 @@
+/* AccessibleBundle.java -- base class for accessibility "enumerations"
+   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.accessibility;
+
+import java.util.Locale;
+
+/**
+ * This serves as a base class for accessibility "enumerations".  These
+ * objects are strongly typed; to make up for the lack of true enums in Java.
+ * Display should be locale dependent.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see AccessibleRole
+ * @see AccessibleState
+ * @since 1.2
+ * @status updated to 1.4, but missing Locale support
+ */
+public abstract class AccessibleBundle
+{
+  /**
+   * The locale independent name of the object. This is for the computer, not
+   * necessarily for humans; changing it in subclasses is frowned upon.
+   *
+   * @see #toDisplayString(String, Locale)
+   */
+  protected String key;
+
+  /**
+   * Default constructor.
+   */
+  public AccessibleBundle()
+  {
+  }
+
+  /**
+   * Obtains the key as a localized string, falling back to the
+   * locale-independent version if necessary.
+   *
+   * @param resourceBundle the resource to use for lookup
+   * @param locale the locale to translate to
+   * @return the translated name
+   * @throws NullPointerException if resourceBundle or locale is null
+   * @XXX For now, no transformation is done.
+   */
+  protected String toDisplayString(String resourceBundle, Locale locale)
+  {
+    return key;
+  }
+
+  /**
+   * Obtains the key as a localized string, falling back to the
+   * locale-independent version if necessary.
+   *
+   * @param locale the locale to translate to
+   * @return the translated name
+   * @throws NullPointerException if locale is null
+   * @XXX For now, no transformation is done.
+   */
+  public String toDisplayString(Locale locale)
+  {
+    return key;
+  }
+
+  /**
+   * Obtains the key as a localized string, using the default locale.
+   *
+   * @return the translated name
+   * @XXX For now, no transformation is done.
+   */
+  public String toDisplayString()
+  {
+    return toDisplayString(Locale.getDefault());
+  }
+
+  /**
+   * Obtains the key as a localized string, using the default locale.
+   *
+   * @return the translated name
+   * @XXX For now, no transformation is done.
+   */
+  public String toString()
+  {
+    return toDisplayString(Locale.getDefault());
+  }
+} // class AccessibleBundle

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleComponent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleComponent.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleComponent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleComponent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,321 @@
+/* AccessibleComponent.java -- aids in accessibly rendering Java components
+   Copyright (C) 2000, 2001, 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.accessibility;
+
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.FocusListener;
+
+/**
+ * Objects which are to be rendered to a screen as part of a graphical
+ * user interface should implement this interface.  Accessibility
+ * software can use the implementations of this interface to determine
+ * and set the screen representation for an object.
+ *
+ * <p>The <code>AccessibleContext.getAccessibleComponent()</code> method
+ * should return <code>null</code> if an object does not implement this
+ * interface.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleContext#getAccessibleComponent()
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface AccessibleComponent
+{
+  /**
+   * Get the background color of this component.
+   *
+   * @return the background color of this component, or null if not supported
+   * @see #setBackground(Color)
+   */
+  Color getBackground();
+
+  /**
+   * Set the background color of this component to the specified color.
+   *
+   * @param color the color to set the background to
+   * @see #getBackground()
+   */
+  void setBackground(Color color);
+
+  /**
+   * Get the foreground color of this component.
+   *
+   * @return the foreground color of this component, or null if not supported
+   * @see #setForeground(Color)
+   */
+  Color getForeground();
+
+  /**
+   * Set the foreground color of this component.
+   *
+   * @param color the color to set the foreground to
+   * @see #getForeground()
+   */
+  void setForeground(Color color);
+
+  /**
+   * Get the cursor of this component.
+   *
+   * @return the Cursor of this component, or null if not supported
+   * @see #setCursor(Cursor)
+   */
+  Cursor getCursor();
+
+  /**
+   * Set the cursor of the component.
+   *
+   * @param cursor the graphical representation of the cursor to use
+   * @see #getCursor()
+   */
+  void setCursor(Cursor cursor);
+
+  /**
+   * Get the font of this component
+   *
+   * @return the font of the component, or null if not supported
+   * @see #setFont(Font)
+   */
+  Font getFont();
+
+  /**
+   * Set the font of this component.
+   *
+   * @param font the font to use
+   * @see #getFont()
+   */
+  void setFont(Font font);
+
+  /**
+   * Get the <code>FontMetrics</code> of the specified font in this component.
+   *
+   * @param font the specified font
+   * @return the metrics for the specified font, or null if not supported
+   * @throws NullPointerException if font is null
+   * @see #getFont()
+   */
+  FontMetrics getFontMetrics(Font font);
+
+  /**
+   * Indicates whether or not this component is enabled. An object which is
+   * enabled also has AccessibleState.ENABLED in its StateSet.
+   *
+   * @return true if the component is enabled
+   * @see #setEnabled(boolean)
+   * @see AccessibleContext#getAccessibleStateSet()
+   * @see AccessibleState#ENABLED
+   */
+  boolean isEnabled();
+
+  /**
+   * Set this component to an enabled or disabled state.
+   *
+   * @param b true to enable the component, else disable it
+   * @see #isEnabled()
+   */
+  void setEnabled(boolean b);
+
+  /**
+   * Indicates whether or not this component is visible or intends to be
+   * visible although one of its ancestors may not be. An object which is
+   * visible also has AccessibleState.VISIBLE in its StateSet. Check
+   * <code>isShowing()</code> to see if the object is on screen.
+   *
+   * @return true if the component is visible
+   * @see #setVisible(boolean)
+   * @see AccessibleContext#getAccessibleStateSet()
+   * @see AccessibleState#VISIBLE
+   */
+  boolean isVisible();
+
+  /**
+   * Set the visible state of this component.
+   *
+   * @param b true to make the component visible, else hide it
+   * @see #isVisible()
+   */
+  void setVisible(boolean b);
+
+  /**
+   * Indicates whether or not this component is visible by checking
+   * the visibility of this component and its ancestors. The component may
+   * be hidden on screen by another component like pop-up help. An object
+   * which is showing on screen also has AccessibleState.SHOWING in its
+   * StateSet.
+   *
+   * @return true if component and ancestors are visible
+   * @see #isVisible()
+   * @see #setVisible(boolean)
+   * @see AccessibleContext#getAccessibleStateSet()
+   * @see AccessibleState#SHOWING
+   */
+  boolean isShowing();
+
+  /**
+   * Tests whether or not the specified point is contained within
+   * this component.  The coordinates are specified relative to this
+   * component's coordinate system.
+   *
+   * @param point the Point to locate
+   * @return true if the point is within this component
+   * @throws NullPointerException if point is null
+   * @see #getBounds()
+   */
+  boolean contains(Point point);
+
+  /**
+   * Get the location of this component in the screen's coordinate space.
+   * The point specified is the top-left corner of this component.
+   *
+   * @return the location on screen, or null if off-screen
+   * @see #getBounds()
+   * @see #getLocation()
+   */
+  Point getLocationOnScreen();
+
+  /**
+   * Get the location of this component in the parent's coordinate system.
+   * The point specified is the top-left corner of this component.
+   *
+   * @return the location in the parent on screen, or null if off-screen
+   * @see #getBounds()
+   * @see #getLocationOnScreen()
+   * @see #setLocation(Point)
+   */
+  Point getLocation();
+
+  /**
+   * Set the location of this component relative to its parent.  The point
+   * specified represents the top-left corner of this component.
+   *
+   * @param point the top-left corner of this component relative to the parent
+   * @throws NullPointerException if point is null
+   * @see #getLocation()
+   */
+  void setLocation(Point point);
+
+  /**
+   * Get the bounds of this component relative to its parent - it's width,
+   * height, and relative location to its parent.
+   *
+   * @return the bounds of this component, or null if not on screen
+   * @see #contains(Point)
+   */
+  Rectangle getBounds();
+
+  /**
+   * Set the bounds of this component to the specified height and width, and
+   * relative location to its parent.
+   *
+   * @param rectangle the new height, width, and relative location
+   * @throws NullPointerException if rectangle is null
+   */
+  void setBounds(Rectangle rectangle);
+
+  /**
+   * Get the size of this component - it's width and height.
+   *
+   * @return the dimensions of this component, or null if not on screen
+   * @see #setSize(Dimension)
+   */
+  Dimension getSize();
+
+  /**
+   * Set the size of this component to the given dimensions.
+   *
+   * @param dimension the new size of the component
+   * @throws NullPointerException if dimension is null
+   * @see #getSize()
+   */
+  void setSize(Dimension dimension);
+
+  /**
+   * If an object exists at the specified point which is a child of this
+   * parent component, and it is accessible, then it is returned.
+   *
+   * @param point the location within this component's coordinate system
+   * @return the accessible child object at that point, or null
+   */
+  Accessible getAccessibleAt(Point point);
+
+  /**
+   * Indicates whether or not this component can accept focus. An object
+   * which can accept focus also has AccessibleState.FOCUSABLE in its
+   * StateSet.
+   *
+   * @return true if the component can accept focus
+   * @see AccessibleContext#getAccessibleStateSet()
+   * @see AccessibleState#FOCUSABLE
+   * @see AccessibleState#FOCUSED
+   */
+  boolean isFocusTraversable();
+
+  /**
+   * If this method is called this component will attempt to gain focus,
+   * but if it cannot accept focus nothing happens. On success, the StateSet
+   * will contain AccessibleState.FOCUSED
+   *
+   * @see #isFocusTraversable()
+   * @see AccessibleState#FOCUSED
+   */
+  void requestFocus();
+
+  /**
+   * Adds the specified listener to this component.
+   *
+   * @param listener the listener to add to this component
+   * @see #removeFocusListener(FocusListener)
+   */
+  void addFocusListener(FocusListener listener);
+
+  /**
+   * Removes the specified listener from this component.
+   *
+   * @param listener the listener to remove
+   * @see #addFocusListener(FocusListener)
+   */
+  void removeFocusListener(FocusListener listener);
+} // interface AccessibleComponent

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleContext.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleContext.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,619 @@
+/* AccessibleContext.java -- the context of an accessible object
+   Copyright (C) 2002 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.accessibility;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.Locale;
+
+/**
+ * The minimum information that all accessible objects return. This includes
+ * name, description, role, and state of the object, parents and children,
+ * and any other useful information. If a component supports further details,
+ * it should implement one of the following:<ul>
+ * <li>{@link AccessibleAction} - the object can perform actions</li>
+ * <li>{@link AccessibleComponent} - the object has a graphical
+ *     representation</li>
+ * <li>{@link AccessibleSelection} - the object allows its children to be
+ *     selected</li>
+ * <li>{@link AccessibleText} - the object represents editable text</li>
+ * <li>{@link AccessibleValue} - the object represents a numerical value</li>
+ * </ul>
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public abstract class AccessibleContext
+{
+  /**
+   * Constant used when the accessible name has changed. Both the old and new
+   * values are listed in the event.
+   *
+   * @see #getAccessibleName()
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public static final String ACCESSIBLE_NAME_PROPERTY
+    = "AccessibleName";
+
+  /**
+   * Constant used when the accessible description has changed. Both the old
+   * and new values are listed in the event.
+   *
+   * @see #getAccessibleDescription()
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public static final String ACCESSIBLE_DESCRIPTION_PROPERTY
+    = "AccessibleDescription";
+
+  /**
+   * Constant used when the accessibleStateSet has changed. Both the old and
+   * new values are listed in the event, although either may be null if a
+   * state was disabled at that time.
+   *
+   * @see #getAccessibleStateSet()
+   * @see AccessibleState
+   * @see AccessibleStateSet
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public static final String ACCESSIBLE_STATE_PROPERTY
+    = "AccessibleState";
+
+  /**
+   * Constant used when the accessibleValue has changed. Both the old and new
+   * values are listed in the event.
+   *
+   * @see #getAccessibleValue()
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public static final String ACCESSIBLE_VALUE_PROPERTY
+    = "AccessibleValue";
+
+  /**
+   * Constant used when the accessibleSelection has changed. Both the old and
+   * new values of the event are reserved for future use.
+   *
+   * @see #getAccessibleSelection()
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public static final String ACCESSIBLE_SELECTION_PROPERTY
+    = "AccessibleSelection";
+
+  /**
+   * Constant used when the accessibleText has changed. Both the old and new
+   * values of the event are reserved for future use.
+   *
+   * @see #getAccessibleText()
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public static final String ACCESSIBLE_TEXT_PROPERTY
+    = "AccessibleText";
+
+  /**
+   * Constant used when the accessibleText caret has changed. Both the old and
+   * new values are listed in the event.
+   *
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public static final String ACCESSIBLE_CARET_PROPERTY
+    = "AccessibleCaret";
+
+  /**
+   * Constant used when the visible data has changed. Both the old and new
+   * values of the event are reserved for future use.
+   *
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public static final String ACCESSIBLE_VISIBLE_DATA_PROPERTY
+    = "AccessibleVisibleData";
+
+  /**
+   * Constant used when children are added or removed. On addition, the new
+   * value of the event holds the new child; on removal, the old value holds
+   * the removed child.
+   *
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public static final String ACCESSIBLE_CHILD_PROPERTY
+    = "AccessibleChild";
+
+  /**
+   * Constant used when active descendent of a component has changed. Both
+   * the old and new values are listed in the event.
+   *
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public static final String ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY
+    = "AccessibleActiveDescendant";
+
+  /**
+   * Constant used when the accessible table caption has changed. Both the
+   * old and new values are listed in the event.
+   *
+   * @see Accessible
+   * @see AccessibleTable
+   */
+  public static final String ACCESSIBLE_TABLE_CAPTION_CHANGED
+    = "accessibleTableCaptionChanged";
+
+  /**
+   * Constant used when the accessible table summary has changed. Both the
+   * old and new values are listed in the event.
+   *
+   * @see Accessible
+   * @see AccessibleTable
+   */
+  public static final String ACCESSIBLE_TABLE_SUMMARY_CHANGED
+    = "accessibleTableSummaryChanged";
+
+  /**
+   * Constant used when the accessible table model has changed. Only the new
+   * value of the event has meaning.
+   *
+   * @see AccessibleTable
+   * @see AccessibleTableModelChange
+   */
+  public static final String ACCESSIBLE_TABLE_MODEL_CHANGED
+    = "accessibleTableModelChanged";
+
+  /**
+   * Constant used when the accessible table row header has changed. Only the
+   * new value of the event has meaning.
+   *
+   * @see AccessibleTable
+   * @see AccessibleTableModelChange
+   */
+  public static final String ACCESSIBLE_TABLE_ROW_HEADER_CHANGED
+    = "accessibleTableRowHeaderChanged";
+
+  /**
+   * Constant used when the accessible table row description has changed. Only
+   * the new value of the event has meaning.
+   *
+   * @see AccessibleTable
+   */
+  public static final String ACCESSIBLE_TABLE_ROW_DESCRIPTION_CHANGED
+    = "accessibleTableRowDescriptionChanged";
+
+  /**
+   * Constant used when the accessible table column header has changed. Only
+   * the new value of the event has meaning.
+   *
+   * @see AccessibleTable
+   * @see AccessibleTableModelChange
+   */
+  public static final String ACCESSIBLE_TABLE_COLUMN_HEADER_CHANGED
+    = "accessibleTableColumnHeaderChanged";
+
+  /**
+   * Constant used when the accessible table column description has changed.
+   * Only the new value of the event has meaning.
+   *
+   * @see AccessibleTable
+   */
+  public static final String ACCESSIBLE_TABLE_COLUMN_DESCRIPTION_CHANGED
+    = "accessibleTableColumnDescriptionChanged";
+
+  /**
+   * Constant used when supported set of actions has changed. Both the old
+   * and new values are listed in the event.
+   *
+   * @see AccessibleAction
+   */
+  public static final String ACCESSIBLE_ACTION_PROPERTY
+    = "accessibleActionProperty";
+
+  /**
+   * Constant used when a hypertext element received focus. Both the old
+   * and new values are listed in the event, with -1 indicating that no link
+   * had focus.
+   *
+   * @see AccessibleHyperlink
+   */
+  public static final String ACCESSIBLE_HYPERTEXT_OFFSET
+    = "AccessibleHypertextOffset";
+
+  /**
+   * Constant used when a component's bounds have changed.  The old and
+   * new bounds are given in the event.
+   * @since 1.5
+   */
+  public static final String ACCESSIBLE_COMPONENT_BOUNDS_CHANGED
+    = "accessibleComponentBoundsChanged";
+
+  /**
+   * Constant used when the state of child objects changes.  The old
+   * value in the event is always null, and the new value is the component
+   * whose children have changed.
+   * @since 1.5
+   */
+  public static final String ACCESSIBLE_INVALIDATE_CHILDREN
+    = "accessibleInvalidateChildren";
+
+  /**
+   * Constant used when the attributes of some text have changed.
+   * On insertion, the old value is null and the new value is an
+   * {@link AccessibleAttributeSequence} describing the insertion.
+   * On deletion, the old value is an {@link AccessibleAttributeSequence}
+   * and the new value is null.  For replacement, both the old
+   * and new values are {@link AccessibleAttributeSequence} objects.
+   * @since 1.5
+   */
+  public static final String ACCESSIBLE_TEXT_ATTRIBUTES_CHANGED
+    = "accessibleTextAttributesChanged";
+
+  /**
+   * The accessible parent of this object.
+   *
+   * @see #getAccessibleParent()
+   * @see #setAccessibleParent(Accessible)
+   */
+  protected Accessible accessibleParent;
+
+  /**
+   * A localized string naming this object.
+   *
+   * @see #getAccessibleName()
+   * @see #setAccessibleName(String)
+   */
+  protected String accessibleName;
+
+  /**
+   * A localized string describing this object.
+   *
+   * @see #getAccessibleDescription()
+   * @see #setAccessibleDescription(String)
+   */
+  protected String accessibleDescription;
+
+  /**
+   * The listener tool.
+   *
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   * @see #removePropertyChangeListener(PropertyChangeListener)
+   * @see #firePropertyChange(String, Object, Object)
+   */
+  private final PropertyChangeSupport listeners
+    = new PropertyChangeSupport(this);
+
+  /**
+   * Default constructor.
+   */
+  public AccessibleContext()
+  {
+  }
+
+  /**
+   * Get the localized name of the object. For example, a label may just
+   * return the text of the label, while an entry field for city may return
+   * "city" in en_US.
+   *
+   * @return the accessible object's name, or null if it is unnamed
+   * @see #setAccessibleName(String)
+   */
+  public String getAccessibleName()
+  {
+    return accessibleName;
+  }
+
+  /**
+   * Set the localized name of the object. This will fire a
+   * PropertyChangeEvent with ACCESSIBLE_NAME_PROPERTY.
+   *
+   * @param s the new name
+   * @see #getAccessibleName()
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public void setAccessibleName(String s)
+  {
+    listeners.firePropertyChange(ACCESSIBLE_NAME_PROPERTY, accessibleName, s);
+    accessibleName = s;
+  }
+
+  /**
+   * Get the localized description of the object. For example, a 'Cancel'
+   * button may be described as "Ignore changes and close dialog box" in
+   * en_US.
+   *
+   * @return the accessible object's description, or null if there is none
+   * @see #setAccessibleDescription(String)
+   */
+  public String getAccessibleDescription()
+  {
+    return accessibleDescription;
+  }
+
+  /**
+   * Set the localized name of the object. This will fire a
+   * PropertyChangeEvent with ACCESSIBLE_DESCRIPTION_PROPERTY.
+   *
+   * @param s the new description
+   * @see #getAccessibleDescription()
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public void setAccessibleDescription(String s)
+  {
+    listeners.firePropertyChange(ACCESSIBLE_DESCRIPTION_PROPERTY,
+                                 accessibleDescription, s);
+    accessibleDescription = s;
+  }
+
+  /**
+   * Gets the role of this object. For example, a button serves the role of
+   * AccessibleRole.PUSH_BUTTON. This allows assistive technologies to funnel
+   * similar objects into the same assistance classes. Note that the class
+   * is extensible, to define new roles if necessary.
+   *
+   * @return the role of the object
+   * @see AccessibleRole
+   */
+  public abstract AccessibleRole getAccessibleRole();
+
+  /**
+   * Gets the state set of this object. A change in the state of the object
+   * will fire a PropertyChangeEvent for ACCESSIBLE_STATE_PROPERTY.
+   *
+   * @return the current state of the object
+   * @see AccessibleState
+   * @see AccessibleStateSet
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public abstract AccessibleStateSet getAccessibleStateSet();
+
+  /**
+   * Return the accessible parent of this object.
+   *
+   * @return the accessible parent, or null if there is none
+   */
+  public Accessible getAccessibleParent()
+  {
+    return accessibleParent;
+  }
+
+  /**
+   * Sets the accessible parent of this object. This should only be used when
+   * the current parent object should not be the accessible parent; only the
+   * parent of the accessible child should call this method.
+   *
+   * @param a the new parent
+   */
+  public void setAccessibleParent(Accessible a)
+  {
+    accessibleParent = a;
+  }
+
+  /**
+   * Gets the index of this object within its accessible parent.
+   *
+   * @return the 0-based index, or -1 if there is no accessible parent
+   * @see #getAccessibleParent()
+   * @see #getAccessibleChildrenCount()
+   * @see #getAccessibleChild(int)
+   */
+  public abstract int getAccessibleIndexInParent();
+
+  /**
+   * Returns the number of accessible children of this object.
+   *
+   * @return the number of accessible children
+   * @see #getAccessibleChild(int)
+   */
+  public abstract int getAccessibleChildrenCount();
+
+  /**
+   * Returns the specified accessible chile.
+   *
+   * @param i the 0-based index to get
+   * @return the child, or null if out of bounds
+   * @see #getAccessibleChildrenCount()
+   */
+  public abstract Accessible getAccessibleChild(int i);
+
+  /**
+   * Gets the component locale, deferring to the parent if one is not declared.
+   *
+   * @return the locale
+   * @throws java.awt.IllegalComponentStateException if there is no locale
+   *         or parent
+   */
+  public abstract Locale getLocale();
+
+  /**
+   * Add a PropertyChangeListener to the listener list. This listener will
+   * be notified of all property changes to the accessible object.
+   *
+   * @param l the listener to add
+   * @see #ACCESSIBLE_NAME_PROPERTY
+   * @see #ACCESSIBLE_DESCRIPTION_PROPERTY
+   * @see #ACCESSIBLE_STATE_PROPERTY
+   * @see #ACCESSIBLE_VALUE_PROPERTY
+   * @see #ACCESSIBLE_SELECTION_PROPERTY
+   * @see #ACCESSIBLE_TEXT_PROPERTY
+   * @see #ACCESSIBLE_VISIBLE_DATA_PROPERTY
+   * @see #removePropertyChangeListener(PropertyChangeListener)
+   */
+  public void addPropertyChangeListener(PropertyChangeListener l)
+  {
+    listeners.addPropertyChangeListener(l);
+  }
+
+  /**
+   * Remove a PropertyChangeListener from the listener list.
+   *
+   * @param l the listener to remove
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   */
+  public void removePropertyChangeListener(PropertyChangeListener l)
+  {
+    listeners.removePropertyChangeListener(l);
+  }
+
+  /**
+   * Get any supported accessible actions. The default implementation returns
+   * null.
+   *
+   * @return the supported action, or null
+   * @see AccessibleAction
+   */
+  public AccessibleAction getAccessibleAction()
+  {
+    return null;
+  }
+
+  /**
+   * Get any supported accessible component. The default implementation returns
+   * null.
+   *
+   * @return the supported component, or null
+   * @see AccessibleComponent
+   */
+  public AccessibleComponent getAccessibleComponent()
+  {
+    return null;
+  }
+
+  /**
+   * Get any supported accessible selection. The default implementation returns
+   * null.
+   *
+   * @return the supported selection, or null
+   * @see AccessibleSelection
+   */
+  public AccessibleSelection getAccessibleSelection()
+  {
+    return null;
+  }
+
+  /**
+   * Get any supported accessible text. The default implementation returns
+   * null.
+   *
+   * @return the supported text, or null
+   * @see AccessibleText
+   */
+  public AccessibleText getAccessibleText()
+  {
+    return null;
+  }
+
+  /**
+   * Get any supported accessible editable text. The default implementation
+   * returns null.
+   *
+   * @return the supported editable text, or null
+   * @see AccessibleEditableText
+   */
+  public AccessibleEditableText getAccessibleEditableText()
+  {
+    return null;
+  }
+
+  /**
+   * Get any supported accessible value. The default implementation returns
+   * null.
+   *
+   * @return the supported value, or null
+   * @see AccessibleValue
+   */
+  public AccessibleValue getAccessibleValue()
+  {
+    return null;
+  }
+
+  /**
+   * Get all supported accessible icons. The default implementation returns
+   * null.
+   *
+   * @return the supported icons, or null
+   * @see AccessibleIcon
+   */
+  public AccessibleIcon[] getAccessibleIcon()
+  {
+    return null;
+  }
+
+  /**
+   * Get any supported accessible relation set. The default implementation
+   * returns an empty AccessibleRelationSet.
+   *
+   * @return the supported relation set, or <code>null</code>
+   *
+   * @see AccessibleRelationSet
+   */
+  public AccessibleRelationSet getAccessibleRelationSet()
+  {
+    return new AccessibleRelationSet();
+  }
+
+  /**
+   * Get any supported accessible table. The default implementation returns
+   * null.
+   *
+   * @return the supported table, or null
+   * @see AccessibleTable
+   */
+  public AccessibleTable getAccessibleTable()
+  {
+    return null;
+  }
+
+  /**
+   * Fire an event to report property changes. This is intended for use by
+   * the accessible objects, not general application programs. If oldValue and
+   * newValue differ, and the listenter list is not empty, a PropertyChange
+   * event is fired to each listener.
+   *
+   * @param name the property name
+   * @param oldValue the prior value
+   * @param newValue the updated value
+   * @see PropertyChangeSupport
+   * @see #addPropertyChangeListener(PropertyChangeListener)
+   * @see #removePropertyChangeListener(PropertyChangeListener)
+   * @see #ACCESSIBLE_NAME_PROPERTY
+   * @see #ACCESSIBLE_DESCRIPTION_PROPERTY
+   * @see #ACCESSIBLE_STATE_PROPERTY
+   * @see #ACCESSIBLE_VALUE_PROPERTY
+   * @see #ACCESSIBLE_SELECTION_PROPERTY
+   * @see #ACCESSIBLE_TEXT_PROPERTY
+   * @see #ACCESSIBLE_VISIBLE_DATA_PROPERTY
+   */
+  public void firePropertyChange(String name, Object oldValue, Object newValue)
+  {
+    listeners.firePropertyChange(name, oldValue, newValue);
+  }
+} // class AccessibleContext

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleEditableText.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleEditableText.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleEditableText.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleEditableText.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,142 @@
+/* AccessibleEditableText.java -- aids in accessibly for editable text
+   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.accessibility;
+
+import javax.swing.text.AttributeSet;
+
+/**
+ * Objects which present editable textual information on the display should
+ * implement this interface.  Accessibility software can use the
+ * implementations of this interface to change the content, attributes,
+ * and spacial location of the text.
+ *
+ * <p>The <code>AccessibleContext.getAccessibleEditableText()</code> method
+ * should return <code>null</code> if an object does not implement this
+ * interface.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleContext#getAccessibleText()
+ * @see AccessibleContext#getAccessibleEditableText()
+ * @since 1.2
+ * @status updated to 1.4, except for javax.swing support
+ */
+public interface AccessibleEditableText extends AccessibleText
+{
+  /**
+   * Set the text contents to the given string.
+   *
+   * @param s the new text
+   */
+  // XXX What happens if s is null?
+  void setTextContents(String s);
+
+  /**
+   * Inserts the given string at the specified location.
+   *
+   * @param index the index for insertion
+   * @param s the new text
+   */
+  // XXX What happens if index is out of bounds, or s is null?
+  void insertTextAtIndex(int index, String s);
+
+  /**
+   * Return the text between two points.
+   *
+   * @param start the start position, inclusive
+   * @param end the end position, exclusive
+   */
+  // XXX What happens if indices are out of bounds?
+  String getTextRange(int start, int end);
+
+  /**
+   * Delete the text between two points.
+   *
+   * @param start the start position, inclusive
+   * @param end the end position, exclusive
+   */
+  // XXX What happens if indices are out of bounds?
+  void delete(int start, int end);
+
+  /**
+   * Cut the text between two points to the system clipboard.
+   *
+   * @param start the start position, inclusive
+   * @param end the end position, exclusive
+   */
+  // XXX What happens if indices are out of bounds?
+  void cut(int start, int end);
+
+  /**
+   * Paste the text from the system clipboard at the given index.
+   *
+   * @param start the start position
+   */
+  // XXX What happens if start is out of bounds?
+  void paste(int start);
+
+  /**
+   * Replace the text between two points with the given string.
+   *
+   * @param start the start position, inclusive
+   * @param end the end position, exclusive
+   * @param s the string to paste
+   */
+  // XXX What happens if indices are out of bounds, or s is null?
+  void replaceText(int start, int end, String s);
+
+  /**
+   * Select the text between two points.
+   *
+   * @param start the start position, inclusive
+   * @param end the end position, exclusive
+   */
+  // XXX What happens if indices are out of bounds?
+  void selectText(int start, int stop);
+
+  /**
+   * Set the attributes of text between two points.
+   *
+   * @param start the start position, inclusive
+   * @param end the end position, exclusive
+   * @param s the new attribute set for the range
+   */
+  // XXX What happens if indices are out of bounds, or s is null?
+  void setAttributes(int start, int end, AttributeSet s);
+} // interface AccessibleEditableText

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleExtendedComponent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleExtendedComponent.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleExtendedComponent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleExtendedComponent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* AccessibleExtendedComponent.java -- aids in extended component access
+   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.accessibility;
+
+/**
+ * Objects which present graphical components with extensions such as key
+ * bindings or tool-tips should implement this interface.  Accessibility
+ * software can use the implementations of this interface to display the
+ * extended information of the component.
+ *
+ * <p>The <code>AccessibleContext.getAccessibleComponent()</code> method
+ * should return an instance of this interface only when it is supported.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleContext#getAccessibleComponent()
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface AccessibleExtendedComponent extends AccessibleComponent
+{
+  /**
+   * Returns the tool-tip text for this component.
+   *
+   * @return the tool-tip, or null if not supported
+   */
+  String getToolTipText();
+
+  /**
+   * Returns the title border text for this component.
+   *
+   * @return the titled border text, or null if not supported
+   */
+  String getTitledBorderText();
+
+  /**
+   * Returns the accessible key bindings for this component.
+   *
+   * @return the key bindings, or null if not supported
+   */
+  AccessibleKeyBinding getAccessibleKeyBinding();
+} // interface AccessibleExtendedComponent

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleExtendedTable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleExtendedTable.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleExtendedTable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleExtendedTable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,81 @@
+/* AccessibleExtendedTable.java -- aids in extended table access
+   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.accessibility;
+
+/**
+ * Objects which present 2-D tables with the extension of a flat address
+ * space should implement this interface.  Accessibility software can use the
+ * implementations of this interface to better manipulate the table.
+ *
+ * <p>The <code>AccessibleContext.getAccessibleTable()</code> method
+ * should return an instance of this interface only when it is supported.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleContext#getAccessibleTable()
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface AccessibleExtendedTable extends AccessibleTable
+{
+  /**
+   * Returns the row number of an index in the table.
+   *
+   * @param index the cell index, in row-major form from (0,0)
+   * @return the row number, or -1 if out of bounds
+   */
+  int getAccessibleRow(int index);
+
+  /**
+   * Returns the column number of an index in the table.
+   *
+   * @param index the cell index, in row-major form from (0,0)
+   * @return the column number, or -1 if out of bounds
+   */
+  int getAccessibleColumn(int index);
+
+  /**
+   * Returns the cell number for a row-major address from (0,0).
+   *
+   * @param r the row
+   * @param c the column
+   * @return the cell index
+   */
+   int getAccessibleIndex(int r, int c);
+} // interface AccessibleExtendedTable

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleExtendedText.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleExtendedText.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleExtendedText.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleExtendedText.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,108 @@
+/* AccessibleExtendedText.java
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+import java.awt.Rectangle;
+
+/**
+ * This interface provides extended text functionality, similar
+ * to AccessibleText.
+ * @see AccessibleText
+ * @since 1.5
+ */
+public interface AccessibleExtendedText
+{
+  /**
+   * This constant indicates that the retrieved text should be a
+   * complete line.
+   */
+  int LINE = 4;
+
+  /**
+   * This constant indicates that the retrieved text should consist
+   * of a run with identical attributes. 
+   */
+  int ATTRIBUTE_RUN = 5;
+
+  /**
+   * Determines the bounding box of some text held by this object.
+   * @param start the starting index
+   * @param end the ending index
+   * @return the bounding box
+   * @see AccessibleText#getCharacterBounds(int)
+   */
+  Rectangle getTextBounds(int start, int end);
+
+  /**
+   * Return a range of text from the underlying object.
+   * @param start the starting index
+   * @param end the ending index
+   */
+  String getTextRange(int start, int end);
+
+  /**
+   * Return a text sequence from the underlying object.  The part
+   * parameter describes the type of sequence to return; it is one
+   * of the constants from {@link AccessibleText} or from this
+   * class.
+   * @param part the type of the sequence to return 
+   * @param index start of the sequence
+   */
+  AccessibleTextSequence getTextSequenceAfter(int part, int index);
+
+  /**
+   * Return a text sequence from the underlying object.  The part
+   * parameter describes the type of sequence to return; it is one
+   * of the constants from {@link AccessibleText} or from this
+   * class.
+   * @param part the type of the sequence to return 
+   * @param index start of the sequence
+   */
+  AccessibleTextSequence getTextSequenceAt(int part, int index);
+
+  /**
+   * Return a text sequence from the underlying object.  The part
+   * parameter describes the type of sequence to return; it is one
+   * of the constants from {@link AccessibleText} or from this
+   * class.
+   * @param part the type of the sequence to return 
+   * @param index end of the sequence
+   */
+  AccessibleTextSequence getTextSequenceBefore(int part, int index);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleHyperlink.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleHyperlink.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleHyperlink.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleHyperlink.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,139 @@
+/* AccessibleHyperlink.java -- aids in accessibly navigating hypertext
+   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+/**
+ * This object encapsulates actions associated with navigating hypertext.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleText
+ * @see AccessibleContext#getAccessibleText()
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public abstract class AccessibleHyperlink implements AccessibleAction
+{
+  /**
+   * The default constructor.
+   */
+  public AccessibleHyperlink()
+  {
+  }
+
+  /**
+   * Returns whether the document the link references is still valid, as the
+   * association may have changed with a text edit.
+   *
+   * @return true if the link is valid with respect to the AccessibleHypertext
+   */
+  public abstract boolean isValid();
+
+  /**
+   * Get the number possible actions for this object, starting from 0. In
+   * general, a hypertext link has only one action, except for an image map,
+   * so there isn't really a default action.
+   *
+   * @return the 0-based number of actions
+   */
+  public abstract int getAccessibleActionCount();
+
+  /**
+   * Perform the specified action. Does nothing if out of bounds.
+   *
+   * @param i the action to perform, 0-based
+   * @return true if the action was performed
+   * @see #getAccessibleActionCount()
+   */
+  public abstract boolean doAccessibleAction(int i);
+
+  /**
+   * Get the anchor text of the link, or null if the index is out of bounds.
+   * For example, <a href="http://www.gnu.org/">GNU Home Page</a>
+   * would return "GNU Home Page", while <a HREF="#top">
+   * <img src="top-hat.png" alt="top hat"></a> would return
+   * "top hat".
+   *
+   * @param i the link to retrieve, 0-based
+   * @return the link anchor text
+   * @see #getAccessibleActionCount()
+   */
+  public abstract String getAccessibleActionDescription(int i);
+
+  /**
+   * Get the link location, or null if the index is out of bounds. For
+   * example, <a href="http://www.gnu.org/">GNU Home Page</a>
+   * would return a java.net.URL("http://www.gnu.org/").
+   *
+   * @param i the link to retrieve, 0-based
+   * @return the link location
+   * @see #getAccessibleActionCount()
+   */
+  public abstract Object getAccessibleActionObject(int i);
+
+  /**
+   * Get the anchor appropriate for the link, or null if the index is out of
+   * bounds. For example, <a href="http://www.gnu.org/">GNU Home Page
+   * </a> would return "GNU Home Page", while <a HREF="#top">
+   * <img src="top-hat.png" alt="top hat"></a> would return
+   * an ImageIcon("top-hat.png", "top hat").
+   *
+   * @param i the link to retrieve, 0-based
+   * @return the link anchor object
+   * @see #getAccessibleActionCount()
+   */
+  public abstract Object getAccessibleActionAnchor(int i);
+
+  /**
+   * Gets the character index where this link starts in the parent hypertext
+   * document.
+   *
+   * @return the starting index
+   */
+  public abstract int getStartIndex();
+
+  /**
+   * Gets the character index where this link ends in the parent hypertext
+   * document.
+   *
+   * @return the ending index
+   */
+  public abstract int getEndIndex();
+} // class AccessibleAction

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleHypertext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleHypertext.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleHypertext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleHypertext.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,84 @@
+/* AccessibleHypertext.java -- aids in accessibly rendering hypertext
+   Copyright (C) 2000, 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+/**
+ * Objects which present hyperlinks in a document should implement this
+ * interface.  Accessibility software can use the implementations of this
+ * interface to aid the user in navigating the links.
+ *
+ * <p>The <code>AccessibleContext.getAccessibleText()</code> method
+ * should return an instance of this interface only when it is supported.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleText
+ * @see AccessibleContext#getAccessibleText()
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface AccessibleHypertext extends AccessibleText
+{
+  /**
+   * Returns the number of links in the document, if any exist.
+   *
+   * @return the number of links, or -1
+   */
+  int getLinkCount();
+
+  /**
+   * Returns link object denoted by the number <code>i</code> in this
+   * document, or null if i is out of bounds.
+   *
+   * @param i the ith hyperlink of the document
+   * @return link object denoted by <code>i</code>
+   */
+  AccessibleHyperlink getLink(int i);
+
+  /**
+   * Returns the link index for this character index if it resides within
+   * one of the hyperlinks of the document. If no association exists at that
+   * character, or c is out of bounds, returns -1.
+   *
+   * @param c the character index
+   * @return the link index, or -1
+   */
+  int getLinkIndex(int c);
+} // interface AccessibleHypertext

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleIcon.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleIcon.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleIcon.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleIcon.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* AccessibleIcon.java -- aids in accessibly rendering icons
+   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+/**
+ * Objects which have an associated icon, such as buttons, should implement
+ * this interface.  Accessibility software can use the implementations of this
+ * interface to aid the user in navigating the links.
+ *
+ * <p>The <code>AccessibleContext.getAccessibleIcon()</code> method should
+ * return <code>null</code> if an object does not implement this interface.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleContext#getAccessibleIcon()
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface AccessibleIcon
+{
+  /**
+   * Returns a textual description of the icon and its purpose.
+   *
+   * @return the description, or null if there is none
+   */
+  String getAccessibleIconDescription();
+
+  /**
+   * Modify the textual description of the icon and its purpose.
+   *
+   * @param s the new descrption string
+   */
+  void setAccessibleIconDescription(String s);
+
+  /**
+   * Get the icon width.
+   *
+   * @return the width
+   */
+  int getAccessibleIconWidth();
+
+  /**
+   * Get the icon height.
+   *
+   * @return the height
+   */
+  int getAccessibleIconHeight();
+} // interface AccessibleIcon

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleKeyBinding.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleKeyBinding.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleKeyBinding.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleKeyBinding.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* AccessibleKeyBinding.java -- aids in using keyboard navigation
+   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+/**
+ * Objects which have keyboard bindings for mneumonics or shortcuts should
+ * implement this interface.  Accessibility software can use the
+ * implementations of this interface to aid the user in using the key
+ * bindings.
+ *
+ * <p>The <code>AccessibleContext.getAccessibleKeyBinding()</code> method
+ * should return <code>null</code> if an object does not implement this
+ * interface.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleContext#getAccessibleKeyBinding()
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface AccessibleKeyBinding
+{
+  /**
+   * Returns the count of key bindings for this object.
+   *
+   * @return the 0-based count, or -1 if there are none
+   */
+  int getAccessibleKeyBindingCount();
+
+  /**
+   * Return the numbered key binding, which can then be cast in an
+   * implementation dependent way to the appropriate object type. For example,
+   * swing uses <code>javax.swing.KeyStroke</code>. This returns null if i
+   * is out of bounds.
+   *
+   * @param i the 0-based index of key bindings
+   * @return the key binding
+   * @see #getAccessibleKeyBindingCount()
+   */
+  Object getAccessibleKeyBinding(int i);
+} // interface AccessibleKeyBinding

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleRelation.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleRelation.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleRelation.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleRelation.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,318 @@
+/* AccessibleRelation.java -- the relation between accessible objects
+   Copyright (C) 2002, 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.accessibility;
+
+import java.util.Locale;
+
+/**
+ * The relation between one accessible object and one or more other objects.
+ * For example, a button may control an action. An AccessibleRelationSet
+ * summarizes all relations of the object. This strongly typed "enumeration"
+ * supports localized strings. If the constants of this class are not
+ * adequate, new ones may be added in a similar matter.
+ * 
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class AccessibleRelation extends AccessibleBundle
+{
+  /**
+   * Indicates the object labels other objects.
+   *
+   * @see #getTarget()
+   * @see #CONTROLLER_FOR
+   * @see #CONTROLLED_BY
+   * @see #LABELED_BY
+   * @see #MEMBER_OF
+   */
+  public static final String LABEL_FOR;
+
+  /**
+   * Indicates the object is labeled by other objects.
+   *
+   * @see #getTarget()
+   * @see #CONTROLLER_FOR
+   * @see #CONTROLLED_BY
+   * @see #LABEL_FOR
+   * @see #MEMBER_OF
+   */
+  public static final String LABELED_BY;
+
+  /**
+   * Indicates an object is a member of a group of target objects.
+   *
+   * @see #getTarget()
+   * @see #CONTROLLER_FOR
+   * @see #CONTROLLED_BY
+   * @see #LABEL_FOR
+   * @see #LABELED_BY
+   */
+  public static final String MEMBER_OF;
+
+  /**
+   * Indicates an object is a controller for other objects.
+   *
+   * @see #getTarget()
+   * @see #CONTROLLED_BY
+   * @see #LABEL_FOR
+   * @see #LABELED_BY
+   * @see #MEMBER_OF
+   */
+  public static final String CONTROLLER_FOR;
+
+  /**
+   * Indicates an object is controlled by other objects.
+   *
+   * @see #getTarget()
+   * @see #CONTROLLER_FOR
+   * @see #LABEL_FOR
+   * @see #LABELED_BY
+   * @see #MEMBER_OF
+   */
+  public static final String CONTROLLED_BY;
+
+  /** Indicates that the label target group has changed. */
+  public static final String LABEL_FOR_PROPERTY = "labelForProperty";
+
+  /** Indicates that the labelling objects have changed. */
+  public static final String LABELED_BY_PROPERTY = "labeledByProperty";
+
+  /** Indicates that group membership has changed. */
+  public static final String MEMBER_OF_PROPERTY = "memberOfProperty";
+
+  /** Indicates that the controller target group has changed. */
+  public static final String CONTROLLER_FOR_PROPERTY = "controllerForProperty";
+
+  /** Indicates that the controlling objects have changed. */
+  public static final String CONTROLLED_BY_PROPERTY = "controlledByProperty";
+
+  /**
+   * Indicates that an object is a child of another object.
+   * @since 1.5
+   */
+  public static final String CHILD_NODE_OF = "childNodeOf";
+
+  /**
+   * Indicates that the ancestry relationship has changed.
+   * @since 1.5
+   */
+  public static final String CHILD_NODE_OF_PROPERTY = "childNodeOfProperty";
+
+  /**
+   * Indicates that an object is embedded by another object.
+   * @since 1.5
+   */
+  public static final String EMBEDDED_BY = "embeddedBy";
+
+  /**
+   * Indicates that the {@link #EMBEDDED_BY} property changed.
+   * @since 1.5
+   */
+  public static final String EMBEDDED_BY_PROPERTY = "embeddedByProperty";
+
+  /**
+   * Indicates that an object embeds another object.
+   * @since 1.5
+   */
+  public static final String EMBEDS = "embeds";
+
+  /**
+   * Indicates that the {@link #EMBEDS} property changed.
+   * @since 1.5
+   */
+  public static final String EMBEDS_PROPERTY = "embedsProperty";
+
+  /**
+   * Indicates that one object directly follows another object,
+   * as in a paragraph flow.
+   * @since 1.5
+   */
+  public static final String FLOWS_FROM = "flowsFrom";
+
+  /**
+   * Indicates that the {@link #FLOWS_FROM} property changed.
+   * @since 1.5
+   */
+  public static final String FLOWS_FROM_PROPERTY = "flowsFromProperty";
+
+  /**
+   * Indicates that one object comes directly before another object,
+   * as in a paragraph flow.
+   * @since 1.5
+   */
+  public static final String FLOWS_TO = "flowsTo";
+
+  /**
+   * Indicates that the {@link #FLOWS_TO} property changed.
+   * @since 1.5
+   */
+  public static final String FLOWS_TO_PROPERTY = "flowsToProperty";
+
+  /**
+   * Indicates that one object is a parent window of another object.
+   * @since 1.5
+   */
+  public static final String PARENT_WINDOW_OF = "parentWindowOf";
+
+  /**
+   * Indicates that the {@link #PARENT_WINDOW_OF} property changed.
+   * @since 1.5
+   */
+  public static final String PARENT_WINDOW_OF_PROPERTY = "parentWindowOfProperty";
+
+  /**
+   * Indicates that one object is a subwindow of another object.
+   * @since 1.5
+   */
+  public static final String SUBWINDOW_OF = "subwindowOf";
+
+  /**
+   * Indicates that the {@link #SUBWINDOW_OF} property changed.
+   * @since 1.5
+   */
+  public static final String SUBWINDOW_OF_PROPERTY = "subwindowOfProperty";
+
+  /** An empty set of targets. */
+  private static final Object[] EMPTY_TARGETS = { };
+  
+  static
+    {
+      // not constants in JDK
+      LABEL_FOR = "labelFor";
+      LABELED_BY = "labeledBy";
+      MEMBER_OF = "memberOf";
+      CONTROLLER_FOR = "controllerFor";
+      CONTROLLED_BY = "controlledBy";
+    }
+
+  /**
+   * The related objects.
+   *
+   * @see #getTarget()
+   * @see #setTarget(Object)
+   * @see #setTarget(Object[])
+   */
+  Object[] targets;
+
+  /**
+   * Create a new relation with a locale independent key, and no related
+   * objects.
+   *
+   * @param key the name of the role
+   * @see #toDisplayString(String, Locale)
+   */
+  public AccessibleRelation(String key)
+  {
+    this.key = key;
+    targets = EMPTY_TARGETS;
+  }
+
+  /**
+   * Create a new relation with a locale independent key, and a single related
+   * object.
+   *
+   * @param key the name of the role
+   * @param target the related object
+   * @see #toDisplayString(String, Locale)
+   */
+  public AccessibleRelation(String key, Object target)
+  {
+    this.key = key;
+    targets = new Object[] { target };
+  }
+
+  /**
+   * Create a new relation with a locale independent key, and the given
+   * related objects.
+   *
+   * @param key the name of the role
+   * @param targets the related objects
+   * @see #toDisplayString(String, Locale)
+   */
+  public AccessibleRelation(String key, Object[] targets)
+  {
+    this.key = key;
+    this.targets = targets == null ? EMPTY_TARGETS : targets;
+  }
+
+  /**
+   * Return the key for this relation.
+   *
+   * @return the key
+   * @see #CONTROLLER_FOR
+   * @see #CONTROLLED_BY
+   * @see #LABEL_FOR
+   * @see #LABELED_BY
+   * @see #MEMBER_OF
+   */
+  public String getKey()
+  {
+    return key;
+  }
+
+  /**
+   * Return the targets of this relation.
+   *
+   * @return the targets, may be empty, but never null
+   */
+  public Object[] getTarget()
+  {
+    return targets;
+  }
+
+  /**
+   * Set the target to a single object.
+   *
+   * @param target the new target
+   */
+  public void setTarget(Object target)
+  {
+    targets = new Object[] { target };
+  }
+
+  /**
+   * Set the target to an array of objects.
+   *
+   * @param targets the new targets
+   */
+  public void setTarget(Object[] targets)
+  {
+    this.targets = targets == null ? EMPTY_TARGETS : targets;
+  }
+} // class AccessibleRelation

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleRelationSet.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleRelationSet.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleRelationSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleRelationSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,223 @@
+/* AccessibleRelationSet.java -- the combined relations of an accessible object
+   Copyright (C) 2002, 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.accessibility;
+
+import java.util.Locale;
+import java.util.Vector;
+
+/**
+ * Describes all relations of an accessible object. For example, an object
+ * by labeled by one object and control another.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see AccessibleRelation
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class AccessibleRelationSet
+{
+  /**
+   * The list of relations, should be instances of AccessibleRelation. Don't
+   * set this to null.
+   *
+   * @see #add(AccessibleRelation)
+   * @see #addAll(AccessibleRelation[])
+   * @see #remove(AccessibleRelation)
+   * @see #contains(String)
+   * @see #get(String)
+   * @see #size()
+   * @see #toArray()
+   * @see #clear()
+   */
+  protected Vector relations = new Vector();
+
+  /**
+   * Create an empty relation set.
+   */
+  public AccessibleRelationSet()
+  {
+  }
+
+  /**
+   * Create a relation set initialized with the given relations, duplicates are
+   * ignored.
+   *
+   * @param relations the relations to insert
+   * @throws NullPointerException if relations is null
+   */
+  public AccessibleRelationSet(AccessibleRelation[] relations)
+  {
+    addAll(relations);
+  }
+
+  /**
+   * Add a new relation to the current set. If the relation is already in
+   * the set, the targets are merged with the existing relation, possibly
+   * resulting in an object being in the target list more than once. Do not
+   * add a relation with a null key, as it will cause problems later.
+   *
+   * @param relation the relation to add
+   * @return true if the set was modified, which is always the case
+   * @throws NullPointerException if relation is null
+   */
+  public boolean add(AccessibleRelation relation)
+  {
+    AccessibleRelation old = get(relation.key);
+    if (old == null)
+      return relations.add(relation);
+    if (old.targets.length == 0)
+      old.targets = relation.targets;
+    else if (relation.targets.length != 0)
+      {
+        Object[] t = new Object[old.targets.length + relation.targets.length];
+        System.arraycopy(old.targets, 0, t, 0, old.targets.length);
+        System.arraycopy(relation.targets, 0, t, old.targets.length,
+                         relation.targets.length);
+        old.targets = t;
+      }
+    return true;
+  }
+
+  /**
+   * Add all of the relations to the current set. Duplicates are ignored.
+   *
+   * @param array the array of relations to add
+   * @throws NullPointerException if array is null or has null entries
+   */
+  public void addAll(AccessibleRelation[] array)
+  {
+    int i = array.length;
+    while (--i >= 0)
+      add(array[i]);
+  }
+
+  /**
+   * Remove a relation from the set. If a relation was removed, return true.
+   * Note that this uses AccessibleRelation.equals, which defaults to ==, so a
+   * relation with the same key may still exist in the set afterwords.
+   *
+   * @param relation the state to remove
+   * @return true if the set changed
+   */
+  public boolean remove(AccessibleRelation relation)
+  {
+    return relations.remove(relation);
+  }
+
+  /**
+   * Clear all relations in the set.
+   */
+  public void clear()
+  {
+    relations.clear();
+  }
+
+  /**
+   * Return the number of relations in the set.
+   *
+   * @return the set size
+   */
+  public int size()
+  {
+    return relations.size();
+  }
+
+  /**
+   * Check if the relation key is in the set.
+   *
+   * @param key the relation to locate
+   * @return true if it is in the set
+   */
+  public boolean contains(String key)
+  {
+    int i = relations.size();
+    while (--i >= 0)
+      if (((AccessibleRelation) relations.get(i)).key.equals(key))
+        return true;
+    return false;
+  }
+
+  /**
+   * Get the relation that matches the key.
+   *
+   * @param key the relation to locate
+   * @return the relation in the set, or null
+   */
+  public AccessibleRelation get(String key)
+  {
+    int i = relations.size();
+    while (--i >= 0)
+      {
+        AccessibleRelation r = (AccessibleRelation) relations.get(i);
+        if (r.key.equals(key))
+          return r;
+      }
+    return null;
+  }
+
+  /**
+   * Return the relation set as an array.
+   *
+   * @return an array of the current relations
+   */
+  public AccessibleRelation[] toArray()
+  {
+    AccessibleRelation[] result = new AccessibleRelation[relations.size()];
+    relations.toArray(result);
+    return result;
+  }
+
+  /**
+   * Return a localized, comma-separated string representing all relations
+   * in the set. This is in arbitrary order.
+   *
+   * @return the string representation
+   * @see AccessibleBundle#toDisplayString(String, Locale)
+   */
+  public String toString()
+  {
+    int i = relations.size();
+    if (i == 0)
+      return "";
+    // Pre-allocate an average of 10 chars per state.
+    StringBuffer b = new StringBuffer(i * 10);
+    while (--i >= 0)
+      b.append(relations.get(i)).append(',');
+    return b.substring(0, b.length() - 1);
+  }
+} // class AccessibleRelationSet

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleResourceBundle.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleResourceBundle.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleResourceBundle.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleResourceBundle.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* AccessibleResourceBundle.java -- deprecated class
+   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+import java.util.ListResourceBundle;
+import java.util.Locale;
+
+/**
+ * This class is deprecated. It once was used for localizing accessibility
+ * strings, and was never meant for external use anyway.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see AccessibleBundle#toDisplayString(String, Locale)
+ * @since 1.2
+ * @deprecated this class is no longer used
+ * @status updated to 1.4
+ */
+public class AccessibleResourceBundle extends ListResourceBundle
+{
+  /**
+   * Default constructor.
+   *
+   * @deprecated do not use this class
+   */
+  public AccessibleResourceBundle()
+  {
+  }
+
+  /**
+   * Returns the mapping between keys and display strings.
+   *
+   * @return null
+   * @deprecated do not use this class
+   */
+  public Object[][] getContents()
+  {
+    return null;
+  }
+} // class AccessibleResourceBundle

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleRole.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleRole.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleRole.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleRole.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,530 @@
+/* AccessibleRole.java -- the primary role of an accessible object
+   Copyright (C) 2002, 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.accessibility;
+
+import java.util.Locale;
+
+/**
+ * The role of an accessible object. For example, this could be "button" or
+ * "table". This strongly typed "enumeration" supports localized strings. If
+ * the constants of this class are not adequate, new ones may be added in a
+ * similar matter, while avoiding a public constructor.
+ * 
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class AccessibleRole extends AccessibleBundle
+{
+  /** The object alerts the user about something. */
+  public static final AccessibleRole ALERT
+    = new AccessibleRole("alert");
+
+  /** The header for a column of data. */
+  public static final AccessibleRole COLUMN_HEADER
+    = new AccessibleRole("column header");
+
+  /**
+   * The object can be drawn into, and traps events.
+   *
+   * @see #FRAME
+   * @see #GLASS_PANE
+   * @see #LAYERED_PANE
+   */
+  public static final AccessibleRole CANVAS
+    = new AccessibleRole("canvas");
+
+  /**
+   * A list of choices, which may optionally allow the user to create a new
+   * choice.
+   */
+  public static final AccessibleRole COMBO_BOX
+    = new AccessibleRole("combo box");
+
+  /**
+   * An iconified frame in a desktop.
+   *
+   * @see #DESKTOP_PANE
+   * @see #INTERNAL_FRAME
+   */
+  public static final AccessibleRole DESKTOP_ICON
+    = new AccessibleRole("desktop icon");
+
+  /**
+   * A frame-like object clipped by a desktop pane.
+   *
+   * @see #DESKTOP_ICON
+   * @see #DESKTOP_PANE
+   * @see #FRAME
+   */
+  public static final AccessibleRole INTERNAL_FRAME
+    = new AccessibleRole("internal frame");
+
+  /**
+   * A pane which supports internal frames and their icons.
+   *
+   * @see #DESKTOP_ICON
+   * @see #INTERNAL_FRAME
+   */
+  public static final AccessibleRole DESKTOP_PANE
+    = new AccessibleRole("desktop pane");
+
+  /**
+   * A specialized pane for use in a dialog.
+   *
+   * @see #DIALOG
+   */
+  public static final AccessibleRole OPTION_PANE
+    = new AccessibleRole("option pane");
+
+  /**
+   * A top level window with no title or border.
+   *
+   * @see #FRAME
+   * @see #DIALOG
+   */
+  public static final AccessibleRole WINDOW
+    = new AccessibleRole("window");
+
+  /**
+   * A top level window with title, menu bar, border, and so forth. It is
+   * often the primary window of an application.
+   *
+   * @see #DIALOG
+   * @see #CANVAS
+   * @see #WINDOW
+   */
+  public static final AccessibleRole FRAME
+    = new AccessibleRole("frame");
+
+  /**
+   * A top level window title bar and border. It is limited compared to a
+   * frame, and is often a secondary window.
+   *
+   * @see #FRAME
+   * @see #WINDOW
+   */
+  public static final AccessibleRole DIALOG
+    = new AccessibleRole("dialog");
+
+  /** A specialized dialog for choosing a color. */
+  public static final AccessibleRole COLOR_CHOOSER
+    = new AccessibleRole("color chooser");
+
+  /**
+   * A pane for navigating through directories.
+   *
+   * @see #FILE_CHOOSER
+   */
+  public static final AccessibleRole DIRECTORY_PANE
+    = new AccessibleRole("directory pane");
+
+  /**
+   * A specialized dialog that allows a user to select a file.
+   *
+   * @see #DIRECTORY_PANE
+   */
+  public static final AccessibleRole FILE_CHOOSER
+    = new AccessibleRole("file chooser");
+
+  /** An object to fill space between other components. */
+  public static final AccessibleRole FILLER
+    = new AccessibleRole("filler");
+
+  /** A hypertext anchor. */
+  public static final AccessibleRole HYPERLINK
+    = new AccessibleRole("hyperlink");
+
+  /** A small picture to decorate components. */
+  public static final AccessibleRole ICON
+    = new AccessibleRole("icon");
+
+  /** An object to label something in a graphic interface. */
+  public static final AccessibleRole LABEL
+    = new AccessibleRole("label");
+
+  /**
+   * A specialized pane with a glass pane and layered pane as children.
+   *
+   * @see #GLASS_PANE
+   * @see #LAYERED_PANE
+   */
+  public static final AccessibleRole ROOT_PANE
+    = new AccessibleRole("root pane");
+
+  /**
+   * A pane guaranteed to be painted on top of panes beneath it.
+   *
+   * @see #ROOT_PANE
+   * @see #LAYERED_PANE
+   */
+  public static final AccessibleRole GLASS_PANE
+    = new AccessibleRole("glass pane");
+
+  /**
+   * A specialized pane that allows drawing children in layers. This is often
+   * used in menus and other visual components.
+   *
+   * @see #ROOT_PANE
+   * @see #GLASS_PANE
+   */
+  public static final AccessibleRole LAYERED_PANE
+    = new AccessibleRole("layered pane");
+
+  /**
+   * An object which presents a list of items for selection. Often contained
+   * in a scroll pane.
+   *
+   * @see #SCROLL_PANE
+   * @see #LIST_ITEM
+   */
+  public static final AccessibleRole LIST
+    = new AccessibleRole("list");
+
+  /**
+   * An object which represents an item in a list. Often contained in a scroll
+   * pane.
+   *
+   * @see #SCROLL_PANE
+   * @see #LIST
+   */
+  public static final AccessibleRole LIST_ITEM
+    = new AccessibleRole("list item");
+
+  /**
+   * An object usually at the top of a frame to list available menus.
+   *
+   * @see #MENU
+   * @see #POPUP_MENU
+   * @see #LAYERED_PANE
+   */
+  public static final AccessibleRole MENU_BAR
+    = new AccessibleRole("menu bar");
+
+  /**
+   * A temporary window with a menu of options, which hides on selection.
+   *
+   * @see #MENU
+   * @see #MENU_ITEM
+   */
+  public static final AccessibleRole POPUP_MENU
+    = new AccessibleRole("popup menu");
+
+  /**
+   * An object usually in a menu bar which contains a list of actions to
+   * perform. Such actions are usually associated with menu items or submenus.
+   *
+   * @see #MENU_BAR
+   * @see #MENU_ITEM
+   * @see #SEPARATOR
+   * @see #RADIO_BUTTON
+   * @see #CHECK_BOX
+   * @see #POPUP_MENU
+   */
+  public static final AccessibleRole MENU
+    = new AccessibleRole("menu");
+
+  /**
+   * An object usually in a menu with an action available for the user.
+   *
+   * @see #MENU_BAR
+   * @see #SEPARATOR
+   * @see #POPUP_MENU
+   */
+  public static final AccessibleRole MENU_ITEM
+    = new AccessibleRole("menu item");
+
+  /**
+   * An object usually in a menu which separates logical sections of items.
+   *
+   * @see #MENU
+   * @see #MENU_ITEM
+   */
+  public static final AccessibleRole SEPARATOR
+    = new AccessibleRole("separator");
+
+  /**
+   * An object which presents a series of panels, usually via tabs along the
+   * top. Children are all page tabs.
+   *
+   * @see #PAGE_TAB
+   */
+  public static final AccessibleRole PAGE_TAB_LIST
+    = new AccessibleRole("page tab list");
+
+  /**
+   * An object in a page tab list, which contains the panel to display when
+   * selected from the list.
+   *
+   * @see #PAGE_TAB_LIST
+   */
+  public static final AccessibleRole PAGE_TAB
+    = new AccessibleRole("page tab");
+
+  /** A generic container to group objects. */
+  public static final AccessibleRole PANEL
+    = new AccessibleRole("panel");
+
+  /** An object used to track amount of a task that has completed. */
+  public static final AccessibleRole PROGRESS_BAR
+    = new AccessibleRole("progress bar");
+
+  /** An object for passwords which should not be shown to the user. */
+  public static final AccessibleRole PASSWORD_TEXT
+    = new AccessibleRole("password text");
+
+  /**
+   * An object that can be manipulated to do something.
+   *
+   * @see #CHECK_BOX
+   * @see #TOGGLE_BUTTON
+   * @see #RADIO_BUTTON
+   */
+  public static final AccessibleRole PUSH_BUTTON
+    = new AccessibleRole("push button");
+
+  /**
+   * A specialized button which can be on or off, with no separate indicator.
+   *
+   * @see #PUSH_BUTTON
+   * @see #CHECK_BOX
+   * @see #RADIO_BUTTON
+   */
+  public static final AccessibleRole TOGGLE_BUTTON
+    = new AccessibleRole("toggle button");
+
+  /**
+   * A choice which can be on or off, and has a separate indicator.
+   *
+   * @see #PUSH_BUTTON
+   * @see #TOGGLE_BUTTON
+   * @see #RADIO_BUTTON
+   */
+  public static final AccessibleRole CHECK_BOX
+    = new AccessibleRole("check box");
+
+  /**
+   * A specialized choice which toggles radio buttons in the group when it
+   * is selected.
+   *
+   * @see #PUSH_BUTTON
+   * @see #TOGGLE_BUTTON
+   * @see #CHECK_BOX
+   */
+  public static final AccessibleRole RADIO_BUTTON
+    = new AccessibleRole("radio button");
+
+  /** The header for a row of data. */
+  public static final AccessibleRole ROW_HEADER
+    = new AccessibleRole("row header");
+
+  /**
+   * An object which allows an incremental view of a larger pane.
+   *
+   * @see #SCROLL_BAR
+   * @see #VIEWPORT
+   */
+  public static final AccessibleRole SCROLL_PANE
+    = new AccessibleRole("scroll pane");
+
+  /**
+   * An object which allows selection of the view in a scroll pane.
+   *
+   * @see #SCROLL_PANE
+   */
+  public static final AccessibleRole SCROLL_BAR
+    = new AccessibleRole("scroll bar");
+
+  /**
+   * An object which represents the visual section in a scroll pane.
+   *
+   * @see #SCROLL_PANE
+   */
+  public static final AccessibleRole VIEWPORT
+    = new AccessibleRole("viewport");
+
+  /** An object which allows selection in a bounded range. */
+  public static final AccessibleRole SLIDER
+    = new AccessibleRole("slider");
+
+  /**
+   * A specialized pane which presents two other panels, and can often adjust
+   * the divider between them.
+   */
+  public static final AccessibleRole SPLIT_PANE
+    = new AccessibleRole("split pane");
+
+  /** An object for presenting data in rows and columns. */
+  public static final AccessibleRole TABLE
+    = new AccessibleRole("table");
+
+  /**
+   * An object which represents text, usually editable by the user.
+   *
+   * @see #LABEL
+   */
+  public static final AccessibleRole TEXT
+    = new AccessibleRole("text");
+
+  /**
+   * An object which represents a hierachical view of data. Subnodes can
+   * often be expanded or collapsed.
+   */
+  public static final AccessibleRole TREE
+    = new AccessibleRole("tree");
+
+  /** A bar or pallete with buttons for common actions in an application. */
+  public static final AccessibleRole TOOL_BAR
+    = new AccessibleRole("tool bar");
+
+  /**
+   * An object which provides information about another object. This is often
+   * displayed as a "help bubble" when a mouse hovers over the other object.
+   */
+  public static final AccessibleRole TOOL_TIP
+    = new AccessibleRole("tool tip");
+
+  /**
+   * An AWT component with nothing else known about it.
+   *
+   * @see #SWING_COMPONENT
+   * @see #UNKNOWN
+   */
+  public static final AccessibleRole AWT_COMPONENT
+    = new AccessibleRole("AWT component");
+
+  /**
+   * A swing component with nothing else known about it.
+   *
+   * @see #AWT_COMPONENT
+   * @see #UNKNOWN
+   */
+  public static final AccessibleRole SWING_COMPONENT
+    = new AccessibleRole("SWING component");
+
+  /**
+   * An accessible object whose role is unknown.
+   *
+   * @see #AWT_COMPONENT
+   * @see #SWING_COMPONENT
+   */
+  public static final AccessibleRole UNKNOWN
+    = new AccessibleRole("unknown");
+
+  /** A component with multiple labels of status information. */
+  public static final AccessibleRole STATUS_BAR
+    = new AccessibleRole("statusbar");
+
+  /** A component which allows editing of Date and Time objects. */
+  public static final AccessibleRole DATE_EDITOR
+    = new AccessibleRole("dateeditor");
+
+  /** A component with spinner arrows for simple numbers. */
+  public static final AccessibleRole SPIN_BOX
+    = new AccessibleRole("spinbox");
+
+  /** A component for choosing fonts and their attributes. */
+  public static final AccessibleRole FONT_CHOOSER
+    = new AccessibleRole("fontchooser");
+
+  /** A component with a border to group other components. */
+  public static final AccessibleRole GROUP_BOX
+    = new AccessibleRole("groupbox");
+
+  /**
+   * A formula for creating a value.
+   *
+   * @since 1.5
+   */
+  public static final AccessibleRole EDITBAR
+    = new AccessibleRole("editbar");
+
+  /**
+   * A text-based footer.
+   *
+   * @since 1.5
+   */
+  public static final AccessibleRole FOOTER
+    = new AccessibleRole("footer");
+
+  /**
+   * A text-based header.
+   *
+   * @since 1.5
+   */
+  public static final AccessibleRole HEADER
+    = new AccessibleRole("header");
+
+
+  /**
+   * A text-based paragraph.
+   *
+   * @since 1.5
+   */
+  public static final AccessibleRole PARAGRAPH
+    = new AccessibleRole("paragraph");
+
+  /**
+   * Represents the current level of progress on a particular task.
+   *
+   * @since 1.5
+   */
+  public static final AccessibleRole PROGRESS_MONITOR
+    = new AccessibleRole("progress monitor");
+
+  /**
+   * A ruler is a method of measuring the distance between two
+   * points.
+   *
+   * @since 1.5
+   */
+  public static final AccessibleRole RULER
+    = new AccessibleRole("ruler");
+
+  /**
+   * Create a new constant with a locale independent key. Follow the example,
+   * keep the constructor private and make public constants instead.
+   *
+   * @param key the name of the role
+   * @see #toDisplayString(String, Locale)
+   */
+  protected AccessibleRole(String key)
+  {
+    this.key = key;
+  }
+} // class AccessibleRole

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleSelection.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleSelection.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleSelection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleSelection.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,113 @@
+/* AccessibleSelection.java -- aids in accessibly selecting components
+   Copyright (C) 2000, 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+/**
+ * If an object implements this interface then it must be able to control
+ * the selection of its children. Accessibility software can use the
+ * implementations of this interface to change the selection set of children.
+ *
+ * <p>The <code>AccessibleContext.getAccessibleSelection()</code> method should
+ * return <code>null</code> if an object does not implement this interface.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleContext#getAccessibleSelection()
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface AccessibleSelection
+{
+  /**
+   * Returns the number of currently selected Accessible children, which may
+   * be 0 if nothing is selected.
+   *
+   * @return the number of selected children
+   */
+  int getAccessibleSelectionCount();
+
+  /**
+   * Returns the i-th selected child (not necessarily the overall i-th child)
+   * of this Accessible object. If i is out of bounds, null is returned.
+   *
+   * @param i zero-based index of selected child objects
+   * @return the Accessible child, or null
+   * @see #getAccessibleSelectionCount()
+   */
+  Accessible getAccessibleSelection(int i);
+
+  /**
+   * Determine if i-th overall child of this accessible object is selected.
+   * If i is out of bounds, false is returned.
+   *
+   * @param i zero-based index of child objects
+   * @return true if specified child exists and is selected
+   */
+  boolean isAccessibleChildSelected(int i);
+
+  /**
+   * Select the specified child if it is not already selected, placing it in
+   * the object's current selection. If the object does not support multiple
+   * selections then the new selection replaces the old. If the specified
+   * child is already selected, or is out of bounds, this method does nothing.
+   *
+   * @param i zero-based index of child objects
+   */
+  void addAccessibleSelection(int i);
+
+  /**
+   * Unselect the specified child of this Accessible object. If the specified
+   * child is not selected, or is out of bounds, this method does nothing.
+   *
+   * @param i the zero-based index of the child objects
+   */
+  void removeAccessibleSelection(int i);
+
+  /**
+   * Unselect all children of this Accessible object.
+   */
+  void clearAccessibleSelection();
+
+  /**
+   * Select all children of this Accessible object if the object supports
+   * multiple selections or has a single child. Otherwise this does nothing.
+   */
+  void selectAllAccessibleSelection();
+} // interface AccessibleSelection

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleState.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleState.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleState.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleState.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,349 @@
+/* AccessibleState.java -- a state of an accessible object
+   Copyright (C) 2002, 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.accessibility;
+
+import java.awt.Dimension;
+import java.util.Locale;
+
+/**
+ * A state portion of an accessible object. A combination of states represent
+ * the entire object state, in an AccessibleStateSet. For example, this could
+ * be "active" or "selected". This strongly typed "enumeration" supports
+ * localized strings. If the constants of this class are not adequate, new
+ * ones may be added in a similar matter, while avoiding a public constructor.
+ * 
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class AccessibleState extends AccessibleBundle
+{
+  /**
+   * Indicates an active window, as well as an active child in a list or other
+   * collection.
+   *
+   * @see AccessibleRole#WINDOW
+   * @see AccessibleRole#FRAME
+   * @see AccessibleRole#DIALOG
+   */
+  public static final AccessibleState ACTIVE
+    = new AccessibleState("active");
+
+  /**
+   * Indicates a pushed button, usually when the mouse has been pressed but
+   * not released.
+   *
+   * @see AccessibleRole#PUSH_BUTTON
+   */
+  public static final AccessibleState PRESSED
+    = new AccessibleState("pressed");
+
+  /**
+   * Indicates an armed object, usually a button which has been pushed and
+   * the mouse has not left the button area.
+   *
+   * @see AccessibleRole#PUSH_BUTTON
+   */
+  public static final AccessibleState ARMED
+    = new AccessibleState("armed");
+
+  /**
+   * Indicates an object is busy, such as a slider, scroll bar, or progress
+   * bar in transition.
+   *
+   * @see AccessibleRole#PROGRESS_BAR
+   * @see AccessibleRole#SCROLL_BAR
+   * @see AccessibleRole#SLIDER
+   */
+  public static final AccessibleState BUSY
+    = new AccessibleState("busy");
+
+  /**
+   * Indicates an object is checked.
+   *
+   * @see AccessibleRole#TOGGLE_BUTTON
+   * @see AccessibleRole#RADIO_BUTTON
+   * @see AccessibleRole#CHECK_BOX
+   */
+  public static final AccessibleState CHECKED
+    = new AccessibleState("checked");
+
+  /**
+   * Indicates the user can edit the component contents. This is usually for
+   * text, as other objects like scroll bars are automatically editable.
+   *
+   * @see #ENABLED
+   */
+  public static final AccessibleState EDITABLE
+    = new AccessibleState("editable");
+
+  /**
+   * Indicates the object allows progressive disclosure of its children,
+   * usually in a collapsible tree or other hierachical object.
+   *
+   * @see #EXPANDED
+   * @see #COLLAPSED
+   * @see AccessibleRole#TREE
+   */
+  public static final AccessibleState EXPANDABLE
+    = new AccessibleState("expandable");
+
+  /**
+   * Indicates that the object is collapsed, usually in a tree.
+   *
+   * @see #EXPANDABLE
+   * @see #EXPANDED
+   * @see AccessibleRole#TREE
+   */
+  public static final AccessibleState COLLAPSED
+    = new AccessibleState("collapsed");
+
+  /**
+   * Indicates that the object is expanded, usually in a tree.
+   *
+   * @see #EXPANDABLE
+   * @see #COLLAPSED
+   * @see AccessibleRole#TREE
+   */
+  public static final AccessibleState EXPANDED
+    = new AccessibleState("expanded");
+
+  /**
+   * Indicates that an object is enabled. In the absence of this state,
+   * graphics are often grayed out, and cannot be manipulated.
+   */
+  public static final AccessibleState ENABLED
+    = new AccessibleState("enabled");
+
+  /**
+   * Indicates that an object can accept focus, which means it will process
+   * keyboard events when focused.
+   *
+   * @see #FOCUSED
+   */
+  public static final AccessibleState FOCUSABLE
+    = new AccessibleState("focusable");
+
+  /**
+   * Indicates that an object has keyboard focus.
+   *
+   * @see #FOCUSABLE
+   */
+  public static final AccessibleState FOCUSED
+    = new AccessibleState("focused");
+
+  /**
+   * Indicates that an object is minimized to an icon.
+   *
+   * @see AccessibleRole#FRAME
+   * @see AccessibleRole#INTERNAL_FRAME
+   */
+  public static final AccessibleState ICONIFIED
+    = new AccessibleState("iconified");
+
+  /**
+   * Indicates that the state of this particular object is
+   * indeterminate.  This commonly occurs when an object is incapable
+   * of representing the state by a single value.
+   *
+   * @since 1.5
+   */
+  public static final AccessibleState INDETERMINATE
+    = new AccessibleState("indeterminate");
+
+  /**
+   * Indicates that this particular object manages a number of
+   * subcomponents.  This is a common property of structures such as
+   * trees and tables, which have a number of sub-elements such as
+   * rows and columns.  The subcomponents should be left to the
+   * object, and not managed by the application.
+   *
+   * @since 1.5
+   */
+  public static final AccessibleState MANAGES_DESCENDANTS
+    = new AccessibleState("manages descendants");
+
+  /**
+   * Indicates that something must be done in the current object before
+   * interaction is allowed on other windows, usually for dialogs.
+   *
+   * @see AccessibleRole#DIALOG
+   */
+  public static final AccessibleState MODAL
+    = new AccessibleState("modal");
+
+  /**
+   * Indicates that all pixels in the object are painted. If this state is not
+   * present, then the object has some degree of transparency, letting lower
+   * panes show through.
+   *
+   * @see Accessible#getAccessibleContext()
+   * @see AccessibleContext#getAccessibleComponent()
+   * @see AccessibleComponent#getBounds()
+   */
+  public static final AccessibleState OPAQUE
+    = new AccessibleState("opaque");
+
+  /**
+   * Indicates the size of this object is not fixed.
+   *
+   * @see Accessible#getAccessibleContext()
+   * @see AccessibleContext#getAccessibleComponent()
+   * @see AccessibleComponent#getSize()
+   * @see AccessibleComponent#setSize(Dimension)
+   */
+  public static final AccessibleState RESIZABLE
+    = new AccessibleState("resizable");
+
+  /**
+   * Indicates that multiple children can be selected at once.
+   *
+   * @see Accessible#getAccessibleContext()
+   * @see AccessibleContext#getAccessibleSelection()
+   * @see AccessibleSelection
+   */
+  public static final AccessibleState MULTISELECTABLE
+    = new AccessibleState("multiselectable");
+
+  /**
+   * Indicates that this child is one which can be selected from its parent.
+   *
+   * @see #SELECTED
+   * @see Accessible#getAccessibleContext()
+   * @see AccessibleContext#getAccessibleSelection()
+   * @see AccessibleSelection
+   */
+  public static final AccessibleState SELECTABLE
+    = new AccessibleState("selectable");
+
+  /**
+   * Indicates that this child has been selected from its parent.
+   *
+   * @see #SELECTABLE
+   * @see Accessible#getAccessibleContext()
+   * @see AccessibleContext#getAccessibleSelection()
+   * @see AccessibleSelection
+   */
+  public static final AccessibleState SELECTED
+    = new AccessibleState("selected");
+
+  /**
+   * Indicates that this object and all its parents are visible, so that it
+   * is on the screen. However, something opaque may be on top of it.
+   *
+   * @see #VISIBLE
+   */
+  public static final AccessibleState SHOWING
+    = new AccessibleState("showing");
+
+  /**
+   * Indicates that this particular object is truncated when displayed
+   * visually.
+   *
+   * @since 1.5
+   */
+  public static final AccessibleState TRUNCATED
+    = new AccessibleState("truncated");
+
+  /**
+   * Indicates that this object intends to be visible. However, if its
+   * parent is invisible, this object is as well.
+   *
+   * @see #SHOWING
+   */
+  public static final AccessibleState VISIBLE
+    = new AccessibleState("visible");
+
+  /**
+   * Indicates that an object has vertical orientation.
+   *
+   * @see #HORIZONTAL
+   * @see AccessibleRole#SCROLL_BAR
+   * @see AccessibleRole#SLIDER
+   * @see AccessibleRole#PROGRESS_BAR
+   */
+  public static final AccessibleState VERTICAL
+    = new AccessibleState("vertical");
+
+  /**
+   * Indicates that an object has horizontal orientation.
+   *
+   * @see #VERTICAL
+   * @see AccessibleRole#SCROLL_BAR
+   * @see AccessibleRole#SLIDER
+   * @see AccessibleRole#PROGRESS_BAR
+   */
+  public static final AccessibleState HORIZONTAL
+    = new AccessibleState("horizontal");
+
+  /**
+   * Indicates that this text object can only hold a single line.
+   *
+   * @see #MULTI_LINE
+   */
+  public static final AccessibleState SINGLE_LINE
+    = new AccessibleState("single line");
+
+  /**
+   * Indicates that this text object can hold multiple lines.
+   *
+   * @see #SINGLE_LINE
+   */
+  public static final AccessibleState MULTI_LINE
+    = new AccessibleState("multiple line");
+
+  /**
+   * Indicates that this object is transient. This means the object is
+   * generated for method queries, but will never generate events, because
+   * its container (such as a tree, list, or table) does all the work.
+   */
+  public static final AccessibleState TRANSIENT
+    = new AccessibleState("transient");
+
+  /**
+   * Create a new constant with a locale independent key. Follow the example,
+   * keep the constructor private and make public constants instead.
+   *
+   * @param key the name of the state
+   * @see #toDisplayString(String, Locale)
+   */
+  protected AccessibleState(String key)
+  {
+    this.key = key;
+  }
+} // class AccessibleState

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleStateSet.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleStateSet.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleStateSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleStateSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,173 @@
+/* AccessibleStateSet.java -- the combined state of an accessible object
+   Copyright (C) 2002, 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.accessibility;
+
+import java.util.Locale;
+import java.util.Vector;
+
+/**
+ * Describes all elements of an accessible object's state. For example, an
+ * object may be enabled and have focus.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see AccessibleState
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class AccessibleStateSet
+{
+  /**
+   * The list of states, should be instances of AccessibleState. Don't set
+   * this to null.
+   *
+   * @see #add(AccessibleState)
+   * @see #addAll(AccessibleState[])
+   * @see #remove(AccessibleState)
+   * @see #contains(AccessibleState)
+   * @see #toArray()
+   * @see #clear()
+   */
+  protected Vector states = new Vector();
+
+  /**
+   * Create an empty state set.
+   */
+  public AccessibleStateSet()
+  {
+  }
+
+  /**
+   * Create a state set initialized with the given states, duplicates are
+   * ignored.
+   *
+   * @param states the states to insert
+   * @throws NullPointerException if states is null
+   */
+  public AccessibleStateSet(AccessibleState[] states)
+  {
+    addAll(states);
+  }
+
+  /**
+   * Add a new state to the current set. Return true if the state was added,
+   * as duplicates are ignored. Entering a null state will cause problems
+   * later, so don't do it.
+   *
+   * @param state the state to add
+   * @return true if the state was added
+   */
+  public boolean add(AccessibleState state)
+  {
+    return states.contains(state) ? false : states.add(state);
+  }
+
+  /**
+   * Add all of the states to the current set. Duplicates are ignored.
+   * Entering a null state will cause problems later, so don't do it.
+   *
+   * @param array the array of states to add
+   * @throws NullPointerException if array is null
+   */
+  public void addAll(AccessibleState[] array)
+  {
+    int i = array.length;
+    while (--i >= 0)
+      add(array[i]);
+  }
+
+  /**
+   * Remove a state from the set. If a state was removed, return true.
+   *
+   * @param state the state to remove
+   * @return true if the set changed
+   */
+  public boolean remove(AccessibleState state)
+  {
+    return states.remove(state);
+  }
+
+  /**
+   * Clear all states in the set.
+   */
+  public void clear()
+  {
+    states.clear();
+  }
+
+  /**
+   * Check if the current state is in the set.
+   *
+   * @param state the state to locate
+   * @return true if it is in the set
+   */
+  public boolean contains(AccessibleState state)
+  {
+    return states.contains(state);
+  }
+
+  /**
+   * Return the state set as an array.
+   *
+   * @return an array of the current states
+   */
+  public AccessibleState[] toArray()
+  {
+    AccessibleState[] result = new AccessibleState[states.size()];
+    states.toArray(result);
+    return result;
+  }
+
+  /**
+   * Return a localized, comma-separated string representing all states
+   * in the set. This is in arbitrary order.
+   *
+   * @return the string representation
+   * @see AccessibleBundle#toDisplayString(String, Locale)
+   */
+  public String toString()
+  {
+    int i = states.size();
+    if (i == 0)
+      return "";
+    // Pre-allocate an average of 10 chars per state.
+    StringBuffer b = new StringBuffer(i * 10);
+    while (--i >= 0)
+      b.append(states.get(i)).append(',');
+    return b.substring(0, b.length() - 1);
+  }
+} // class AccessibleStateSet

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleStreamable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleStreamable.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleStreamable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleStreamable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,62 @@
+/* AccessibleStreamable.java
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+import java.awt.datatransfer.DataFlavor;
+import java.io.InputStream;
+
+/**
+ * This interface represents a streamable accessible object.
+ * @since 1.5
+ */
+public interface AccessibleStreamable
+{
+  /**
+   * Return an array of the data flavors supported by this object.
+   */
+  DataFlavor[] getMimeTypes();
+
+  /**
+   * Return an input stream that yields the contents of this object,
+   * using the given data flavor.  If the given data flavor cannot
+   * be used, returns null.
+   * @param flavor the data flavor
+   */
+  InputStream getStream(DataFlavor flavor);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleTable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleTable.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleTable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleTable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,236 @@
+/* AccessibleTable.java -- aids in accessibly manipulating tables
+   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+/**
+ * Objects which present information in a 2-dimensional table should implement
+ * this interface. Accessibility software can use the implementations of
+ * this interface to navigate and change the attributes of the table.
+ *
+ * <p>The <code>AccessibleContext.getAccessibleTable()</code> method
+ * should return <code>null</code> if an object does not implement this
+ * interface.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleContext#getAccessibleTable()
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface AccessibleTable
+{
+  /**
+   * Return the caption for the table, or null if unknown.
+   *
+   * @return the table caption
+   */
+  Accessible getAccessibleCaption();
+
+  /**
+   * Set the table caption.
+   *
+   * @param caption the new caption
+   */
+  void setAccessibleCaption(Accessible caption);
+
+  /**
+   * Return the summary description of the table, or null if unknown.
+   *
+   * @return the summary description
+   */
+  Accessible getAccessibleSummary();
+
+  /**
+   * Set the table summary description.
+   *
+   * @param summary the new summary
+   */
+  void setAccessibleSummary(Accessible summary);
+
+  /**
+   * Return the number of rows in the table.
+   *
+   * @return the row count
+   */
+  int getAccessibleRowCount();
+
+  /**
+   * Return the number of columns in the table.
+   *
+   * @return the column count
+   */
+  int getAccessibleColumnCount();
+
+  /**
+   * Return the cell at the specified row and column, or null if out of bounds.
+   *
+   * @param r the 0-based row index
+   * @param c the 0-based column index
+   * @return the cell at (r,c)
+   */
+  Accessible getAccessibleAt(int r, int c);
+
+  /**
+   * Returns the number of merged rows occupied at the specified row and
+   * column, or 0 if out of bounds.
+   *
+   * @param r the 0-based row index
+   * @param c the 0-based column index
+   * @return the row extent at (r,c)
+   */
+  int getAccessibleRowExtentAt(int r, int c);
+
+  /**
+   * Returns the number of merged columns occupied at the specified row and
+   * column, or 0 if out of bounds.
+   *
+   * @param r the 0-based row index
+   * @param c the 0-based column index
+   * @return the column extent at (r,c)
+   */
+  int getAccessibleColumnExtentAt(int r, int c);
+
+  /**
+   * Return the row headers as a table.
+   *
+   * @return the row headers, or null if there are none
+   */
+  AccessibleTable getAccessibleRowHeader();
+
+  /**
+   * Set the row headers.
+   *
+   * @param header the new row header
+   */
+  // XXX What happens if header is incompatible size?
+  void setAccessibleRowHeader(AccessibleTable header);
+
+  /**
+   * Return the column headers as a table.
+   *
+   * @return the column headers, or null if there are none
+   */
+  AccessibleTable getAccessibleColumnHeader();
+
+  /**
+   * Set the column headers.
+   *
+   * @param header the new column header
+   */
+  // XXX What happens if header is incompatible size?
+  void setAccessibleColumnHeader(AccessibleTable header);
+
+  /**
+   * Return the description of a row, or null if there is none or the index
+   * is out of bounds.
+   *
+   * @param r the 0-based row index
+   * @return the description
+   */
+  Accessible getAccessibleRowDescription(int r);
+
+  /**
+   * Set the description of a row. Does nothing if the index is invalid.
+   *
+   * @param r the 0-based row index
+   * @param description the new description
+   */
+  void setAccessibleRowDescription(int r, Accessible description);
+
+  /**
+   * Return the description of a column, or null if there is none or the index
+   * is out of bounds.
+   *
+   * @param c the 0-based column index
+   * @return the description
+   */
+  Accessible getAccessibleColumnDescription(int c);
+
+  /**
+   * Set the description of a column. Does nothing if the index is invalid.
+   *
+   * @param c the 0-based column index
+   * @param description the new description
+   */
+  void setAccessibleColumnDescription(int c, Accessible description);
+
+  /**
+   * Return whether the cell at the specified location is selected. Returns
+   * false if the index is out of bounds.
+   *
+   * @param r the 0-based row index
+   * @param c the 0-based column index
+   * @return true if that cell is selected
+   */
+  boolean isAccessibleSelected(int r, int c);
+
+  /**
+   * Return whether the specified row is selected. Returns false if the
+   * index is out of bounds.
+   *
+   * @param r the 0-based row index
+   * @return true if that row is selected
+   */
+  boolean isAccessibleRowSelected(int r);
+
+  /**
+   * Return whether the specified column is selected. Returns false if the
+   * index is out of bounds.
+   *
+   * @param c the 0-based column index
+   * @return true if that column is selected
+   */
+  boolean isAccessibleColumnSelected(int c);
+
+  /**
+   * Return the selected rows. May be null or empty if there is no selection.
+   *
+   * @return the indices of selected rows
+   */
+  int[] getSelectedAccessibleRows();
+
+  /**
+   * Return the selected columns. May be null or empty if there is no
+   * selection.
+   *
+   * @return the indices of selected columns
+   */
+  int[] getSelectedAccessibleColumns();
+} // interface AccessibleTable

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleTableModelChange.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleTableModelChange.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleTableModelChange.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleTableModelChange.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,102 @@
+/* AccessibleTableModelChange.java -- describes change to an accessible table
+   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+/**
+ * Describes a change to an accessible table. Accessibility software can use
+ * the implementations of this interface to update their state after a
+ * change to a table.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleContext#getAccessibleTable()
+ * @see AccessibleTable
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface AccessibleTableModelChange
+{
+  /** Identifies insertion of rows or columns. */
+  int INSERT = 1;
+
+  /** Identifies change to existing data. */
+  int UPDATE = 0;
+
+  /** Identifies deletion of rows or columns. */
+  int DELETE = -1;
+
+  /**
+   * Returns the change type.
+   *
+   * @return the type
+   * @see #INSERT
+   * @see #UPDATE
+   * @see #DELETE
+   */
+  int getType();
+
+  /**
+   * Returns the first row that changed.
+   *
+   * @return the 0-based index of the first row to change
+   */
+  int getFirstRow();
+
+  /**
+   * Returns the last row that changed.
+   *
+   * @return the 0-based index of the last row to change
+   */
+  int getLastRow();
+
+  /**
+   * Returns the first column that changed.
+   *
+   * @return the 0-based index of the first column to change
+   */
+  int getFirstColumn();
+
+  /**
+   * Returns the last column that changed.
+   *
+   * @return the 0-based index of the last column to change
+   */
+  int getLastColumn();
+} // interface AccessibleTableModelChange

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleText.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleText.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleText.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleText.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,185 @@
+/* AccessibleText.java -- aids in accessibly manipulating text
+   Copyright (C) 2000, 2002, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+import java.awt.Point;
+import java.awt.Rectangle;
+
+import javax.swing.text.AttributeSet;
+
+/**
+ * Objects which present textual information on the display should implement
+ * this interface.  Accessibility software can use the implementations of
+ * this interface to change the attributes and spacial location of the text.
+ *
+ * <p>The <code>AccessibleContext.getAccessibleText()</code> method
+ * should return <code>null</code> if an object does not implement this
+ * interface.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleContext#getAccessibleText()
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface AccessibleText
+{
+  /**
+   * Constant designating that the next selection should be a character.
+   *
+   * @see #getAtIndex(int, int)
+   * @see #getAfterIndex(int, int)
+   * @see #getBeforeIndex(int, int)
+   */
+  int CHARACTER = 1;
+
+  /**
+   * Constant designating that the next selection should be a word.
+   *
+   * @see #getAtIndex(int, int)
+   * @see #getAfterIndex(int, int)
+   * @see #getBeforeIndex(int, int)
+   */
+  int WORD = 2;
+
+  /**
+   * Constant designating that the next selection should be a sentence.
+   *
+   * @see #getAtIndex(int, int)
+   * @see #getAfterIndex(int, int)
+   * @see #getBeforeIndex(int, int)
+   */
+  int SENTENCE = 3;
+
+  /**
+   * Given a point in the coordinate system of this object, return the
+   * 0-based index of the character at that point, or -1 if there is none.
+   *
+   * @param point the point to look at
+   * @return the character index, or -1
+   */
+  int getIndexAtPoint(Point point);
+
+  /**
+   * Determines the bounding box of the indexed character. Returns an empty
+   * rectangle if the index is out of bounds.
+   *
+   * @param index the 0-based character index
+   * @return the bounding box, may be empty
+   */
+  Rectangle getCharacterBounds(int index);
+
+  /**
+   * Return the number of characters.
+   *
+   * @return the character count
+   */
+  int getCharCount();
+
+  /**
+   * Return the offset of the character. The offset matches the index of the
+   * character to the right, since the carat lies between characters.
+   *
+   * @return the 0-based caret position
+   */
+  int getCaretPosition();
+
+  /**
+   * Returns the section of text at the index, or null if the index or part
+   * is invalid.
+   *
+   * @param part {@link #CHARACTER}, {@link #WORD}, or {@link #SENTENCE}
+   * @param index the 0-based character index
+   * @return the selection of text at that index, or null
+   */
+  String getAtIndex(int part, int index);
+
+  /**
+   * Returns the section of text after the index, or null if the index or part
+   * is invalid.
+   *
+   * @param part {@link #CHARACTER}, {@link #WORD}, or {@link #SENTENCE}
+   * @param index the 0-based character index
+   * @return the selection of text after that index, or null
+   */
+  String getAfterIndex(int part, int index);
+
+  /**
+   * Returns the section of text before the index, or null if the index or part
+   * is invalid.
+   *
+   * @param part {@link #CHARACTER}, {@link #WORD}, or {@link #SENTENCE}
+   * @param index the 0-based character index
+   * @return the selection of text before that index, or null
+   */
+  String getBeforeIndex(int part, int index);
+
+  /**
+   * Returns the attributes of a character at an index, or null if the index
+   * is out of bounds.
+   *
+   * @param index the 0-based character index
+   * @return the character's attributes
+   */
+  AttributeSet getCharacterAttribute(int index);
+
+  /**
+   * Returns the start index of the selection. If there is no selection, this
+   * is the same as the caret location.
+   *
+   * @return the 0-based character index of the selection start
+   */
+  int getSelectionStart();
+
+  /**
+   * Returns the end index of the selection. If there is no selection, this
+   * is the same as the caret location.
+   *
+   * @return the 0-based character index of the selection end
+   */
+  int getSelectionEnd();
+
+  /**
+   * Returns the selected text. This may be null or "" if no text is selected.
+   *
+   * @return the selected text
+   */
+  String getSelectedText();
+} // interface AccessibleText

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleTextSequence.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleTextSequence.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleTextSequence.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleTextSequence.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,68 @@
+/* AccessibleTextSequence.java
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+/**
+ * This is a convenience class that encapsulates a String and a range.
+ * @since 1.5
+ */
+public class AccessibleTextSequence
+{
+  /**
+   * The text of the sequence.
+   */
+  public String text;
+
+  /**
+   * The starting index.
+   */
+  public int startIndex;
+
+  /**
+   * The ending index.
+   */
+  public int endIndex;
+
+  /**
+   * Create a new instance.
+   */
+  public AccessibleTextSequence()
+  {
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleValue.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleValue.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleValue.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/AccessibleValue.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,94 @@
+/* AccessibleValue.java -- aids in accessibly controlling values
+   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.accessibility;
+
+/**
+ * If an object implements this interface then it must be able to control
+ * a numerical value. For example, a scroll bar has a position represented
+ * by a number. Accessibility software can use the implementations of this
+ * interface to change the associated value.
+ *
+ * <p>The <code>AccessibleContext.getAccessibleValue()</code> method should
+ * return <code>null</code> if an object does not implement this interface.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Accessible
+ * @see AccessibleContext
+ * @see AccessibleContext#getAccessibleValue()
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface AccessibleValue
+{
+  /**
+   * Gets the current value of this object, or null if it has not been set.
+   *
+   * @return the current value, or null
+   * @see #setCurrentAccessibleValue(Number)
+   */
+  Number getCurrentAccessibleValue();
+
+  /**
+   * Sets the current value of this object. Returns true if the number
+   * successfully changed.
+   *
+   * @param number the new value
+   * @return true on success
+   */
+  // XXX What happens if number is null?
+  boolean setCurrentAccessibleValue(Number number);
+
+  /**
+   * Gets the minimum value in the range of this object, or null if there is
+   * no minimum.
+   *
+   * @return the minimum
+   * @see #getMaximumAccessibleValue()
+   */
+  Number getMinimumAccessibleValue();
+
+  /**
+   * Gets the maximum value in the range of this object, or null if there is
+   * no maximum.
+   *
+   * @return the maximum
+   * @see #getMinimumAccessibleValue()
+   */
+  Number getMaximumAccessibleValue();
+} // interface AccessibleValue

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/accessibility/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.accessibility package.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.accessibility</title></head>
+
+<body>
+<p>Provides a contract between objects and accessibility software.</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/BadPaddingException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/BadPaddingException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/BadPaddingException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/crypto/BadPaddingException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* BadPaddingException -- Signals bad padding bytes on decryption.
+   Copyright (C) 2004  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.crypto;
+
+import java.security.GeneralSecurityException;
+
+/**
+ * This exception is thrown during decryption when the decrypted input
+ * does not have the proper padding bytes that are expected by the padding
+ * mechanism.
+ *
+ * @author Casey Marshall (csm at gnu.org)
+ */
+public class BadPaddingException extends GeneralSecurityException
+{
+
+  // Constant.
+  // ------------------------------------------------------------------------
+
+  /** Serialization constant. */
+  private static final long serialVersionUID = -5315033893984728443L;
+
+  // Constructors.
+  // ------------------------------------------------------------------------
+
+  /**
+   * Creates a new bad padding exception with no detail message.
+   */
+  public BadPaddingException()
+  {
+    super();
+  }
+
+  /**
+   * Creates a new bad padding exception with a detail message.
+   *
+   * @param message The detail message.
+   */
+  public BadPaddingException(String message)
+  {
+    super(message);
+  }
+}





More information about the llvm-commits mailing list