[llvm-commits] [llvm-gcc-4.2] r43913 [39/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/lang/StringIndexOutOfBoundsException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/lang/StringIndexOutOfBoundsException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/StringIndexOutOfBoundsException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/StringIndexOutOfBoundsException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* StringIndexOutOfBoundsException.java -- thrown to indicate attempt to
+   exceed string bounds
+   Copyright (C) 1998, 1999, 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.lang;
+
+/**
+ * This exception can be thrown to indicate an attempt to access an index
+ * which is out of bounds of a String. Any negative integer, and a positive
+ * integer greater than or equal to the size of the string, is an index
+ * which would be out of bounds.
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class StringIndexOutOfBoundsException extends IndexOutOfBoundsException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -6762910422159637258L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public StringIndexOutOfBoundsException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public StringIndexOutOfBoundsException(String s)
+  {
+    super(s);
+  }
+
+  /**
+   * Create an exception noting the illegal index.
+   *
+   * @param index the invalid index
+   */
+  public StringIndexOutOfBoundsException(int index)
+  {
+    super("String index out of range: " + index);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/System.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/System.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,607 @@
+/* System.java -- useful methods to interface with the system
+   Copyright (C) 1998, 1999, 2000, 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.lang;
+
+import gnu.classpath.SystemProperties;
+import gnu.classpath.VMStackWalker;
+
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.Properties;
+import java.util.PropertyPermission;
+
+/**
+ * System represents system-wide resources; things that represent the
+ * general environment.  As such, all methods are static.
+ *
+ * @author John Keiser
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status still missing 1.4 functionality
+ */
+public final class System
+{
+  // WARNING: System is a CORE class in the bootstrap cycle. See the comments
+  // in vm/reference/java/lang/Runtime for implications of this fact.
+
+  /**
+   * The standard InputStream. This is assigned at startup and starts its
+   * life perfectly valid. Although it is marked final, you can change it
+   * using {@link #setIn(InputStream)} through some hefty VM magic.
+   *
+   * <p>This corresponds to the C stdin and C++ cin variables, which
+   * typically input from the keyboard, but may be used to pipe input from
+   * other processes or files.  That should all be transparent to you,
+   * however.
+   */
+  public static final InputStream in = VMSystem.makeStandardInputStream();
+
+  /**
+   * The standard output PrintStream.  This is assigned at startup and
+   * starts its life perfectly valid. Although it is marked final, you can
+   * change it using {@link #setOut(PrintStream)} through some hefty VM magic.
+   *
+   * <p>This corresponds to the C stdout and C++ cout variables, which
+   * typically output normal messages to the screen, but may be used to pipe
+   * output to other processes or files.  That should all be transparent to
+   * you, however.
+   */
+  public static final PrintStream out = VMSystem.makeStandardOutputStream();
+
+  /**
+   * The standard output PrintStream.  This is assigned at startup and
+   * starts its life perfectly valid. Although it is marked final, you can
+   * change it using {@link #setErr(PrintStream)} through some hefty VM magic.
+   *
+   * <p>This corresponds to the C stderr and C++ cerr variables, which
+   * typically output error messages to the screen, but may be used to pipe
+   * output to other processes or files.  That should all be transparent to
+   * you, however.
+   */
+  public static final PrintStream err = VMSystem.makeStandardErrorStream();
+
+  /**
+   * This class is uninstantiable.
+   */
+  private System()
+  {
+  }
+
+  /**
+   * Set {@link #in} to a new InputStream. This uses some VM magic to change
+   * a "final" variable, so naturally there is a security check,
+   * <code>RuntimePermission("setIO")</code>.
+   *
+   * @param in the new InputStream
+   * @throws SecurityException if permission is denied
+   * @since 1.1
+   */
+  public static void setIn(InputStream in)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe.
+    if (sm != null)
+      sm.checkPermission(new RuntimePermission("setIO"));
+    VMSystem.setIn(in);
+  }
+
+  /**
+   * Set {@link #out} to a new PrintStream. This uses some VM magic to change
+   * a "final" variable, so naturally there is a security check,
+   * <code>RuntimePermission("setIO")</code>.
+   *
+   * @param out the new PrintStream
+   * @throws SecurityException if permission is denied
+   * @since 1.1
+   */
+  public static void setOut(PrintStream out)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe.
+    if (sm != null)
+      sm.checkPermission(new RuntimePermission("setIO"));
+    
+    VMSystem.setOut(out);
+  }
+
+  /**
+   * Set {@link #err} to a new PrintStream. This uses some VM magic to change
+   * a "final" variable, so naturally there is a security check,
+   * <code>RuntimePermission("setIO")</code>.
+   *
+   * @param err the new PrintStream
+   * @throws SecurityException if permission is denied
+   * @since 1.1
+   */
+  public static void setErr(PrintStream err)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe.
+    if (sm != null)
+      sm.checkPermission(new RuntimePermission("setIO"));
+    VMSystem.setErr(err);
+  }
+
+  /**
+   * Set the current SecurityManager. If a security manager already exists,
+   * then <code>RuntimePermission("setSecurityManager")</code> is checked
+   * first. Since this permission is denied by the default security manager,
+   * setting the security manager is often an irreversible action.
+   *
+   * <STRONG>Spec Note:</STRONG> Don't ask me, I didn't write it.  It looks
+   * pretty vulnerable; whoever gets to the gate first gets to set the policy.
+   * There is probably some way to set the original security manager as a
+   * command line argument to the VM, but I don't know it.
+   *
+   * @param sm the new SecurityManager
+   * @throws SecurityException if permission is denied
+   */
+  public static synchronized void setSecurityManager(SecurityManager sm)
+  {
+    // Implementation note: the field lives in SecurityManager because of
+    // bootstrap initialization issues. This method is synchronized so that
+    // no other thread changes it to null before this thread makes the change.
+    if (SecurityManager.current != null)
+      SecurityManager.current.checkPermission
+        (new RuntimePermission("setSecurityManager"));
+
+    // java.security.Security's class initialiser loads and parses the
+    // policy files.  If it hasn't been run already it will be run
+    // during the first permission check.  That initialisation will
+    // fail if a very restrictive security manager is in force, so we
+    // preload it here.
+    if (SecurityManager.current == null)
+      {
+	try
+	  {
+	    Class.forName("java.security.Security");
+	  }
+	catch (ClassNotFoundException e)
+	  {
+	  }
+      }
+    
+    SecurityManager.current = sm;
+  }
+
+  /**
+   * Get the current SecurityManager. If the SecurityManager has not been
+   * set yet, then this method returns null.
+   *
+   * @return the current SecurityManager, or null
+   */
+  public static SecurityManager getSecurityManager()
+  {
+    return SecurityManager.current;
+  }
+
+  /**
+   * Get the current time, measured in the number of milliseconds from the
+   * beginning of Jan. 1, 1970. This is gathered from the system clock, with
+   * any attendant incorrectness (it may be timezone dependent).
+   *
+   * @return the current time
+   * @see java.util.Date
+   */
+  public static long currentTimeMillis()
+  {
+    return VMSystem.currentTimeMillis();
+  }
+
+  /** 
+   * <p>
+   * Returns the current value of a nanosecond-precise system timer.
+   * The value of the timer is an offset relative to some arbitrary fixed
+   * time, which may be in the future (making the value negative).  This
+   * method is useful for timing events where nanosecond precision is
+   * required.  This is achieved by calling this method before and after the
+   * event, and taking the difference betweent the two times:
+   * </p>
+   * <p>
+   * <code>long startTime = System.nanoTime();</code><br />
+   * <code>... <emph>event code</emph> ...</code><br />
+   * <code>long endTime = System.nanoTime();</code><br />
+   * <code>long duration = endTime - startTime;</code><br />
+   * </p>
+   * <p>
+   * Note that the value is only nanosecond-precise, and not accurate; there
+   * is no guarantee that the difference between two values is really a
+   * nanosecond.  Also, the value is prone to overflow if the offset
+   * exceeds 2^63.
+   * </p>
+   *
+   * @return the time of a system timer in nanoseconds.
+   * @since 1.5 
+   */
+  public static long nanoTime()
+  {
+    return VMSystem.nanoTime();
+  }
+
+  /**
+   * Copy one array onto another from <code>src[srcStart]</code> ...
+   * <code>src[srcStart+len-1]</code> to <code>dest[destStart]</code> ...
+   * <code>dest[destStart+len-1]</code>. First, the arguments are validated:
+   * neither array may be null, they must be of compatible types, and the
+   * start and length must fit within both arrays. Then the copying starts,
+   * and proceeds through increasing slots.  If src and dest are the same
+   * array, this will appear to copy the data to a temporary location first.
+   * An ArrayStoreException in the middle of copying will leave earlier
+   * elements copied, but later elements unchanged.
+   *
+   * @param src the array to copy elements from
+   * @param srcStart the starting position in src
+   * @param dest the array to copy elements to
+   * @param destStart the starting position in dest
+   * @param len the number of elements to copy
+   * @throws NullPointerException if src or dest is null
+   * @throws ArrayStoreException if src or dest is not an array, if they are
+   *         not compatible array types, or if an incompatible runtime type
+   *         is stored in dest
+   * @throws IndexOutOfBoundsException if len is negative, or if the start or
+   *         end copy position in either array is out of bounds
+   */
+  public static void arraycopy(Object src, int srcStart,
+                               Object dest, int destStart, int len)
+  {
+    VMSystem.arraycopy(src, srcStart, dest, destStart, len);
+  }
+
+  /**
+   * Get a hash code computed by the VM for the Object. This hash code will
+   * be the same as Object's hashCode() method.  It is usually some
+   * convolution of the pointer to the Object internal to the VM.  It
+   * follows standard hash code rules, in that it will remain the same for a
+   * given Object for the lifetime of that Object.
+   *
+   * @param o the Object to get the hash code for
+   * @return the VM-dependent hash code for this Object
+   * @since 1.1
+   */
+  public static int identityHashCode(Object o)
+  {
+    return VMSystem.identityHashCode(o);
+  }
+
+  /**
+   * Get all the system properties at once. A security check may be performed,
+   * <code>checkPropertiesAccess</code>. Note that a security manager may
+   * allow getting a single property, but not the entire group.
+   *
+   * <p>The required properties include:
+   * <dl>
+   * <dt>java.version</dt>         <dd>Java version number</dd>
+   * <dt>java.vendor</dt>          <dd>Java vendor specific string</dd>
+   * <dt>java.vendor.url</dt>      <dd>Java vendor URL</dd>
+   * <dt>java.home</dt>            <dd>Java installation directory</dd>
+   * <dt>java.vm.specification.version</dt> <dd>VM Spec version</dd>
+   * <dt>java.vm.specification.vendor</dt>  <dd>VM Spec vendor</dd>
+   * <dt>java.vm.specification.name</dt>    <dd>VM Spec name</dd>
+   * <dt>java.vm.version</dt>      <dd>VM implementation version</dd>
+   * <dt>java.vm.vendor</dt>       <dd>VM implementation vendor</dd>
+   * <dt>java.vm.name</dt>         <dd>VM implementation name</dd>
+   * <dt>java.specification.version</dt>    <dd>Java Runtime Environment version</dd>
+   * <dt>java.specification.vendor</dt>     <dd>Java Runtime Environment vendor</dd>
+   * <dt>java.specification.name</dt>       <dd>Java Runtime Environment name</dd>
+   * <dt>java.class.version</dt>   <dd>Java class version number</dd>
+   * <dt>java.class.path</dt>      <dd>Java classpath</dd>
+   * <dt>java.library.path</dt>    <dd>Path for finding Java libraries</dd>
+   * <dt>java.io.tmpdir</dt>       <dd>Default temp file path</dd>
+   * <dt>java.compiler</dt>        <dd>Name of JIT to use</dd>
+   * <dt>java.ext.dirs</dt>        <dd>Java extension path</dd>
+   * <dt>os.name</dt>              <dd>Operating System Name</dd>
+   * <dt>os.arch</dt>              <dd>Operating System Architecture</dd>
+   * <dt>os.version</dt>           <dd>Operating System Version</dd>
+   * <dt>file.separator</dt>       <dd>File separator ("/" on Unix)</dd>
+   * <dt>path.separator</dt>       <dd>Path separator (":" on Unix)</dd>
+   * <dt>line.separator</dt>       <dd>Line separator ("\n" on Unix)</dd>
+   * <dt>user.name</dt>            <dd>User account name</dd>
+   * <dt>user.home</dt>            <dd>User home directory</dd>
+   * <dt>user.dir</dt>             <dd>User's current working directory</dd>
+   * </dl>
+   *
+   * In addition, gnu defines several other properties, where ? stands for
+   * each character in '0' through '9':
+   * <dl>
+   * <dt>gnu.classpath.home</dt>         <dd>Path to the classpath libraries.</dd>
+   * <dt>gnu.classpath.version</dt>      <dd>Version of the classpath libraries.</dd>
+   * <dt>gnu.classpath.vm.shortname</dt> <dd>Succinct version of the VM name;
+   *     used for finding property files in file system</dd>
+   * <dt>gnu.classpath.home.url</dt>     <dd> Base URL; used for finding
+   *     property files in file system</dd>
+   * <dt>gnu.cpu.endian</dt>             <dd>big or little</dd>
+   * <dt>gnu.java.io.encoding_scheme_alias.iso-8859-?</dt>   <dd>8859_?</dd>
+   * <dt>gnu.java.io.encoding_scheme_alias.iso8859_?</dt>    <dd>8859_?</dd>
+   * <dt>gnu.java.io.encoding_scheme_alias.iso-latin-_?</dt> <dd>8859_?</dd>
+   * <dt>gnu.java.io.encoding_scheme_alias.latin?</dt>       <dd>8859_?</dd>
+   * <dt>gnu.java.io.encoding_scheme_alias.utf-8</dt>        <dd>UTF8</dd>
+   * <dt>gnu.javax.print.server</dt>     <dd>Hostname of external CUPS server.</dd>
+   * </dl>
+   *
+   * @return the system properties, will never be null
+   * @throws SecurityException if permission is denied
+   */
+  public static Properties getProperties()
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe.
+    if (sm != null)
+      sm.checkPropertiesAccess();
+    return SystemProperties.getProperties();
+  }
+
+  /**
+   * Set all the system properties at once. A security check may be performed,
+   * <code>checkPropertiesAccess</code>. Note that a security manager may
+   * allow setting a single property, but not the entire group. An argument
+   * of null resets the properties to the startup default.
+   *
+   * @param properties the new set of system properties
+   * @throws SecurityException if permission is denied
+   */
+  public static void setProperties(Properties properties)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe.
+    if (sm != null)
+      sm.checkPropertiesAccess();
+    SystemProperties.setProperties(properties);
+  }
+
+  /**
+   * Get a single system property by name. A security check may be performed,
+   * <code>checkPropertyAccess(key)</code>.
+   *
+   * @param key the name of the system property to get
+   * @return the property, or null if not found
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if key is null
+   * @throws IllegalArgumentException if key is ""
+   */
+  public static String getProperty(String key)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe.
+    if (sm != null)
+      sm.checkPropertyAccess(key);
+    if (key.length() == 0)
+      throw new IllegalArgumentException("key can't be empty");
+    return SystemProperties.getProperty(key);
+  }
+
+  /**
+   * Get a single system property by name. A security check may be performed,
+   * <code>checkPropertyAccess(key)</code>.
+   *
+   * @param key the name of the system property to get
+   * @param def the default
+   * @return the property, or def if not found
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if key is null
+   * @throws IllegalArgumentException if key is ""
+   */
+  public static String getProperty(String key, String def)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe.
+    if (sm != null)
+      sm.checkPropertyAccess(key);
+    // This handles both the null pointer exception and the illegal
+    // argument exception.
+    if (key.length() == 0)
+      throw new IllegalArgumentException("key can't be empty");
+    return SystemProperties.getProperty(key, def);
+  }
+
+  /**
+   * Set a single system property by name. A security check may be performed,
+   * <code>checkPropertyAccess(key, "write")</code>.
+   *
+   * @param key the name of the system property to set
+   * @param value the new value
+   * @return the previous value, or null
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if key is null
+   * @throws IllegalArgumentException if key is ""
+   * @since 1.2
+   */
+  public static String setProperty(String key, String value)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe.
+    if (sm != null)
+      sm.checkPermission(new PropertyPermission(key, "write"));
+    // This handles both the null pointer exception and the illegal
+    // argument exception.
+    if (key.length() == 0)
+      throw new IllegalArgumentException("key can't be empty");
+    return SystemProperties.setProperty(key, value);
+  }
+
+  /**
+   * Remove a single system property by name. A security check may be
+   * performed, <code>checkPropertyAccess(key, "write")</code>.
+   *
+   * @param key the name of the system property to remove
+   * @return the previous value, or null
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if key is null
+   * @throws IllegalArgumentException if key is ""
+   * @since 1.5
+   */
+  public static String clearProperty(String key)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe.
+    if (sm != null)
+      sm.checkPermission(new PropertyPermission(key, "write"));
+    // This handles both the null pointer exception and the illegal
+    // argument exception.
+    if (key.length() == 0)
+      throw new IllegalArgumentException("key can't be empty");
+    return SystemProperties.remove(key);
+  }
+
+  /**
+   * Gets the value of an environment variable.
+   *
+   * @param name the name of the environment variable
+   * @return the string value of the variable or null when the
+   *         environment variable is not defined.
+   * @throws NullPointerException
+   * @throws SecurityException if permission is denied
+   * @since 1.5
+   * @specnote This method was deprecated in some JDK releases, but
+   *           was restored in 1.5.
+   */
+  public static String getenv(String name)
+  {
+    if (name == null)
+      throw new NullPointerException();
+    SecurityManager sm = SecurityManager.current; // Be thread-safe.
+    if (sm != null)
+      sm.checkPermission(new RuntimePermission("getenv." + name));
+    return VMSystem.getenv(name);
+  }
+
+  /**
+   * Terminate the Virtual Machine. This just calls
+   * <code>Runtime.getRuntime().exit(status)</code>, and never returns.
+   * Obviously, a security check is in order, <code>checkExit</code>.
+   *
+   * @param status the exit status; by convention non-zero is abnormal
+   * @throws SecurityException if permission is denied
+   * @see Runtime#exit(int)
+   */
+  public static void exit(int status)
+  {
+    Runtime.getRuntime().exit(status);
+  }
+
+  /**
+   * Calls the garbage collector. This is only a hint, and it is up to the
+   * implementation what this hint suggests, but it usually causes a
+   * best-effort attempt to reclaim unused memory from discarded objects.
+   * This calls <code>Runtime.getRuntime().gc()</code>.
+   *
+   * @see Runtime#gc()
+   */
+  public static void gc()
+  {
+    Runtime.getRuntime().gc();
+  }
+
+  /**
+   * Runs object finalization on pending objects. This is only a hint, and
+   * it is up to the implementation what this hint suggests, but it usually
+   * causes a best-effort attempt to run finalizers on all objects ready
+   * to be reclaimed. This calls
+   * <code>Runtime.getRuntime().runFinalization()</code>.
+   *
+   * @see Runtime#runFinalization()
+   */
+  public static void runFinalization()
+  {
+    Runtime.getRuntime().runFinalization();
+  }
+
+  /**
+   * Tell the Runtime whether to run finalization before exiting the
+   * JVM.  This is inherently unsafe in multi-threaded applications,
+   * since it can force initialization on objects which are still in use
+   * by live threads, leading to deadlock; therefore this is disabled by
+   * default. There may be a security check, <code>checkExit(0)</code>. This
+   * calls <code>Runtime.runFinalizersOnExit()</code>.
+   *
+   * @param finalizeOnExit whether to run finalizers on exit
+   * @throws SecurityException if permission is denied
+   * @see Runtime#runFinalizersOnExit(boolean)
+   * @since 1.1
+   * @deprecated never rely on finalizers to do a clean, thread-safe,
+   *             mop-up from your code
+   */
+  public static void runFinalizersOnExit(boolean finalizeOnExit)
+  {
+    Runtime.runFinalizersOnExit(finalizeOnExit);
+  }
+
+  /**
+   * Load a code file using its explicit system-dependent filename. A security
+   * check may be performed, <code>checkLink</code>. This just calls
+   * <code>Runtime.getRuntime().load(filename)</code>.
+   *
+   * <p>
+   * The library is loaded using the class loader associated with the
+   * class associated with the invoking method.
+   *
+   * @param filename the code file to load
+   * @throws SecurityException if permission is denied
+   * @throws UnsatisfiedLinkError if the file cannot be loaded
+   * @see Runtime#load(String)
+   */
+  public static void load(String filename)
+  {
+    Runtime.getRuntime().load(filename, VMStackWalker.getCallingClassLoader());
+  }
+
+  /**
+   * Load a library using its explicit system-dependent filename. A security
+   * check may be performed, <code>checkLink</code>. This just calls
+   * <code>Runtime.getRuntime().load(filename)</code>.
+   *
+   * <p>
+   * The library is loaded using the class loader associated with the
+   * class associated with the invoking method.
+   *
+   * @param libname the library file to load
+   * @throws SecurityException if permission is denied
+   * @throws UnsatisfiedLinkError if the file cannot be loaded
+   * @see Runtime#load(String)
+   */
+  public static void loadLibrary(String libname)
+  {
+    Runtime.getRuntime().loadLibrary(libname,
+      VMStackWalker.getCallingClassLoader());
+  }
+
+  /**
+   * Convert a library name to its platform-specific variant.
+   *
+   * @param libname the library name, as used in <code>loadLibrary</code>
+   * @return the platform-specific mangling of the name
+   * @since 1.2
+   */
+  public static String mapLibraryName(String libname)
+  {
+    return VMRuntime.mapLibraryName(libname);
+  }
+
+} // class System

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Thread.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Thread.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1346 @@
+/* Thread -- an independent thread of executable code
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   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 java.lang;
+
+import gnu.classpath.VMStackWalker;
+import gnu.java.util.WeakIdentityHashMap;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadInfo;
+import java.lang.management.ThreadMXBean;
+
+import java.security.Permission;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
+ * "The Java Language Specification", ISBN 0-201-63451-1
+ * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
+ * Status:  Believed complete to version 1.4, with caveats. We do not
+ *          implement the deprecated (and dangerous) stop, suspend, and resume
+ *          methods. Security implementation is not complete.
+ */
+
+/**
+ * Thread represents a single thread of execution in the VM. When an
+ * application VM starts up, it creates a non-daemon Thread which calls the
+ * main() method of a particular class.  There may be other Threads running,
+ * such as the garbage collection thread.
+ *
+ * <p>Threads have names to identify them.  These names are not necessarily
+ * unique. Every Thread has a priority, as well, which tells the VM which
+ * Threads should get more running time. New threads inherit the priority
+ * and daemon status of the parent thread, by default.
+ *
+ * <p>There are two methods of creating a Thread: you may subclass Thread and
+ * implement the <code>run()</code> method, at which point you may start the
+ * Thread by calling its <code>start()</code> method, or you may implement
+ * <code>Runnable</code> in the class you want to use and then call new
+ * <code>Thread(your_obj).start()</code>.
+ *
+ * <p>The virtual machine runs until all non-daemon threads have died (either
+ * by returning from the run() method as invoked by start(), or by throwing
+ * an uncaught exception); or until <code>System.exit</code> is called with
+ * adequate permissions.
+ *
+ * <p>It is unclear at what point a Thread should be added to a ThreadGroup,
+ * and at what point it should be removed. Should it be inserted when it
+ * starts, or when it is created?  Should it be removed when it is suspended
+ * or interrupted?  The only thing that is clear is that the Thread should be
+ * removed when it is stopped.
+ *
+ * @author Tom Tromey
+ * @author John Keiser
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @see Runnable
+ * @see Runtime#exit(int)
+ * @see #run()
+ * @see #start()
+ * @see ThreadLocal
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public class Thread implements Runnable
+{
+  /** The minimum priority for a Thread. */
+  public static final int MIN_PRIORITY = 1;
+
+  /** The priority a Thread gets by default. */
+  public static final int NORM_PRIORITY = 5;
+
+  /** The maximum priority for a Thread. */
+  public static final int MAX_PRIORITY = 10;
+
+  /** The underlying VM thread, only set when the thread is actually running.
+   */
+  volatile VMThread vmThread;
+
+  /**
+   * The group this thread belongs to. This is set to null by
+   * ThreadGroup.removeThread when the thread dies.
+   */
+  volatile ThreadGroup group;
+
+  /** The object to run(), null if this is the target. */
+  final Runnable runnable;
+
+  /** The thread name, non-null. */
+  volatile String name;
+
+  /** Whether the thread is a daemon. */
+  volatile boolean daemon;
+
+  /** The thread priority, 1 to 10. */
+  volatile int priority;
+
+  /** Native thread stack size. 0 = use default */
+  private long stacksize;
+
+  /** Was the thread stopped before it was started? */
+  Throwable stillborn;
+
+  /** The context classloader for this Thread. */
+  private ClassLoader contextClassLoader;
+  private boolean contextClassLoaderIsSystemClassLoader;
+
+  /** This thread's ID.  */
+  private final long threadId;
+
+  /** The next thread number to use. */
+  private static int numAnonymousThreadsCreated;
+  
+  /** Used to generate the next thread ID to use.  */
+  private static long totalThreadsCreated;
+
+  /** The default exception handler.  */
+  private static UncaughtExceptionHandler defaultHandler;
+
+  /** Thread local storage. Package accessible for use by
+    * InheritableThreadLocal.
+    */
+  WeakIdentityHashMap locals;
+
+  /** The uncaught exception handler.  */
+  UncaughtExceptionHandler exceptionHandler;
+
+  /**
+   * Allocates a new <code>Thread</code> object. This constructor has
+   * the same effect as <code>Thread(null, null,</code>
+   * <i>gname</i><code>)</code>, where <b><i>gname</i></b> is
+   * a newly generated name. Automatically generated names are of the
+   * form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer.
+   * <p>
+   * Threads created this way must have overridden their
+   * <code>run()</code> method to actually do anything.  An example
+   * illustrating this method being used follows:
+   * <p><blockquote><pre>
+   *     import java.lang.*;
+   *
+   *     class plain01 implements Runnable {
+   *         String name;
+   *         plain01() {
+   *             name = null;
+   *         }
+   *         plain01(String s) {
+   *             name = s;
+   *         }
+   *         public void run() {
+   *             if (name == null)
+   *                 System.out.println("A new thread created");
+   *             else
+   *                 System.out.println("A new thread with name " + name +
+   *                                    " created");
+   *         }
+   *     }
+   *     class threadtest01 {
+   *         public static void main(String args[] ) {
+   *             int failed = 0 ;
+   *
+   *             <b>Thread t1 = new Thread();</b>
+   *             if (t1 != null)
+   *                 System.out.println("new Thread() succeed");
+   *             else {
+   *                 System.out.println("new Thread() failed");
+   *                 failed++;
+   *             }
+   *         }
+   *     }
+   * </pre></blockquote>
+   *
+   * @see     java.lang.Thread#Thread(java.lang.ThreadGroup,
+   *          java.lang.Runnable, java.lang.String)
+   */
+  public Thread()
+  {
+    this(null, (Runnable) null);
+  }
+
+  /**
+   * Allocates a new <code>Thread</code> object. This constructor has
+   * the same effect as <code>Thread(null, target,</code>
+   * <i>gname</i><code>)</code>, where <i>gname</i> is
+   * a newly generated name. Automatically generated names are of the
+   * form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer.
+   *
+   * @param target the object whose <code>run</code> method is called.
+   * @see java.lang.Thread#Thread(java.lang.ThreadGroup,
+   *                              java.lang.Runnable, java.lang.String)
+   */
+  public Thread(Runnable target)
+  {
+    this(null, target);
+  }
+
+  /**
+   * Allocates a new <code>Thread</code> object. This constructor has
+   * the same effect as <code>Thread(null, null, name)</code>.
+   *
+   * @param   name   the name of the new thread.
+   * @see     java.lang.Thread#Thread(java.lang.ThreadGroup,
+   *          java.lang.Runnable, java.lang.String)
+   */
+  public Thread(String name)
+  {
+    this(null, null, name, 0);
+  }
+
+  /**
+   * Allocates a new <code>Thread</code> object. This constructor has
+   * the same effect as <code>Thread(group, target,</code>
+   * <i>gname</i><code>)</code>, where <i>gname</i> is
+   * a newly generated name. Automatically generated names are of the
+   * form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer.
+   *
+   * @param group the group to put the Thread into
+   * @param target the Runnable object to execute
+   * @throws SecurityException if this thread cannot access <code>group</code>
+   * @throws IllegalThreadStateException if group is destroyed
+   * @see #Thread(ThreadGroup, Runnable, String)
+   */
+  public Thread(ThreadGroup group, Runnable target)
+  {
+    this(group, target, createAnonymousThreadName(), 0);
+  }
+
+  /**
+   * Allocates a new <code>Thread</code> object. This constructor has
+   * the same effect as <code>Thread(group, null, name)</code>
+   *
+   * @param group the group to put the Thread into
+   * @param name the name for the Thread
+   * @throws NullPointerException if name is null
+   * @throws SecurityException if this thread cannot access <code>group</code>
+   * @throws IllegalThreadStateException if group is destroyed
+   * @see #Thread(ThreadGroup, Runnable, String)
+   */
+  public Thread(ThreadGroup group, String name)
+  {
+    this(group, null, name, 0);
+  }
+
+  /**
+   * Allocates a new <code>Thread</code> object. This constructor has
+   * the same effect as <code>Thread(null, target, name)</code>.
+   *
+   * @param target the Runnable object to execute
+   * @param name the name for the Thread
+   * @throws NullPointerException if name is null
+   * @see #Thread(ThreadGroup, Runnable, String)
+   */
+  public Thread(Runnable target, String name)
+  {
+    this(null, target, name, 0);
+  }
+
+  /**
+   * Allocate a new Thread object, with the specified ThreadGroup and name, and
+   * using the specified Runnable object's <code>run()</code> method to
+   * execute.  If the Runnable object is null, <code>this</code> (which is
+   * a Runnable) is used instead.
+   *
+   * <p>If the ThreadGroup is null, the security manager is checked. If a
+   * manager exists and returns a non-null object for
+   * <code>getThreadGroup</code>, that group is used; otherwise the group
+   * of the creating thread is used. Note that the security manager calls
+   * <code>checkAccess</code> if the ThreadGroup is not null.
+   *
+   * <p>The new Thread will inherit its creator's priority and daemon status.
+   * These can be changed with <code>setPriority</code> and
+   * <code>setDaemon</code>.
+   *
+   * @param group the group to put the Thread into
+   * @param target the Runnable object to execute
+   * @param name the name for the Thread
+   * @throws NullPointerException if name is null
+   * @throws SecurityException if this thread cannot access <code>group</code>
+   * @throws IllegalThreadStateException if group is destroyed
+   * @see Runnable#run()
+   * @see #run()
+   * @see #setDaemon(boolean)
+   * @see #setPriority(int)
+   * @see SecurityManager#checkAccess(ThreadGroup)
+   * @see ThreadGroup#checkAccess()
+   */
+  public Thread(ThreadGroup group, Runnable target, String name)
+  {
+    this(group, target, name, 0);
+  }
+
+  /**
+   * Allocate a new Thread object, as if by
+   * <code>Thread(group, null, name)</code>, and give it the specified stack
+   * size, in bytes. The stack size is <b>highly platform independent</b>,
+   * and the virtual machine is free to round up or down, or ignore it
+   * completely.  A higher value might let you go longer before a
+   * <code>StackOverflowError</code>, while a lower value might let you go
+   * longer before an <code>OutOfMemoryError</code>.  Or, it may do absolutely
+   * nothing! So be careful, and expect to need to tune this value if your
+   * virtual machine even supports it.
+   *
+   * @param group the group to put the Thread into
+   * @param target the Runnable object to execute
+   * @param name the name for the Thread
+   * @param size the stack size, in bytes; 0 to be ignored
+   * @throws NullPointerException if name is null
+   * @throws SecurityException if this thread cannot access <code>group</code>
+   * @throws IllegalThreadStateException if group is destroyed
+   * @since 1.4
+   */
+  public Thread(ThreadGroup group, Runnable target, String name, long size)
+  {
+    // Bypass System.getSecurityManager, for bootstrap efficiency.
+    SecurityManager sm = SecurityManager.current;
+    Thread current = currentThread();
+    if (group == null)
+      {
+	if (sm != null)
+	    group = sm.getThreadGroup();
+	if (group == null)
+	    group = current.group;
+      }
+    if (sm != null)
+      sm.checkAccess(group);
+
+    this.group = group;
+    // Use toString hack to detect null.
+    this.name = name.toString();
+    this.runnable = target;
+    this.stacksize = size;
+    
+    synchronized (Thread.class)
+      {
+        this.threadId = ++totalThreadsCreated;
+      }
+
+    priority = current.priority;
+    daemon = current.daemon;
+    contextClassLoader = current.contextClassLoader;
+    contextClassLoaderIsSystemClassLoader =
+        current.contextClassLoaderIsSystemClassLoader;
+
+    group.addThread(this);
+    InheritableThreadLocal.newChildThread(this);
+  }
+
+  /**
+   * Used by the VM to create thread objects for threads started outside
+   * of Java. Note: caller is responsible for adding the thread to
+   * a group and InheritableThreadLocal.
+   * Note: This constructor should not call any methods that could result
+   * in a call to Thread.currentThread(), because that makes life harder
+   * for the VM.
+   *
+   * @param vmThread the native thread
+   * @param name the thread name or null to use the default naming scheme
+   * @param priority current priority
+   * @param daemon is the thread a background thread?
+   */
+  Thread(VMThread vmThread, String name, int priority, boolean daemon)
+  {
+    this.vmThread = vmThread;
+    this.runnable = null;
+    if (name == null)
+	name = createAnonymousThreadName();
+    this.name = name;
+    this.priority = priority;
+    this.daemon = daemon;
+    // By default the context class loader is the system class loader,
+    // we set a flag to signal this because we don't want to call
+    // ClassLoader.getSystemClassLoader() at this point, because on
+    // VMs that lazily create the system class loader that might result
+    // in running user code (when a custom system class loader is specified)
+    // and that user code could call Thread.currentThread().
+    // ClassLoader.getSystemClassLoader() can also return null, if the system
+    // is currently in the process of constructing the system class loader
+    // (and, as above, the constructiong sequence calls Thread.currenThread()).
+    contextClassLoaderIsSystemClassLoader = true;
+    synchronized (Thread.class)
+      {
+	this.threadId = ++totalThreadsCreated;
+      }
+  }
+
+  /**
+   * Generate a name for an anonymous thread.
+   */
+  private static synchronized String createAnonymousThreadName()
+  {
+    return "Thread-" + ++numAnonymousThreadsCreated;
+  }
+
+  /**
+   * Get the number of active threads in the current Thread's ThreadGroup.
+   * This implementation calls
+   * <code>currentThread().getThreadGroup().activeCount()</code>.
+   *
+   * @return the number of active threads in the current ThreadGroup
+   * @see ThreadGroup#activeCount()
+   */
+  public static int activeCount()
+  {
+    return currentThread().group.activeCount();
+  }
+
+  /**
+   * Check whether the current Thread is allowed to modify this Thread. This
+   * passes the check on to <code>SecurityManager.checkAccess(this)</code>.
+   *
+   * @throws SecurityException if the current Thread cannot modify this Thread
+   * @see SecurityManager#checkAccess(Thread)
+   */
+  public final void checkAccess()
+  {
+    // Bypass System.getSecurityManager, for bootstrap efficiency.
+    SecurityManager sm = SecurityManager.current;
+    if (sm != null)
+      sm.checkAccess(this);
+  }
+
+  /**
+   * Count the number of stack frames in this Thread.  The Thread in question
+   * must be suspended when this occurs.
+   *
+   * @return the number of stack frames in this Thread
+   * @throws IllegalThreadStateException if this Thread is not suspended
+   * @deprecated pointless, since suspend is deprecated
+   */
+  public int countStackFrames()
+  {
+    VMThread t = vmThread;
+    if (t == null || group == null)
+	throw new IllegalThreadStateException();
+
+    return t.countStackFrames();
+  }
+
+  /**
+   * Get the currently executing Thread. In the situation that the
+   * currently running thread was created by native code and doesn't
+   * have an associated Thread object yet, a new Thread object is
+   * constructed and associated with the native thread.
+   *
+   * @return the currently executing Thread
+   */
+  public static Thread currentThread()
+  {
+    return VMThread.currentThread();
+  }
+
+  /**
+   * Originally intended to destroy this thread, this method was never
+   * implemented by Sun, and is hence a no-op.
+   *
+   * @deprecated This method was originally intended to simply destroy
+   *             the thread without performing any form of cleanup operation.
+   *             However, it was never implemented.  It is now deprecated
+   *             for the same reason as <code>suspend()</code>,
+   *             <code>stop()</code> and <code>resume()</code>; namely,
+   *             it is prone to deadlocks.  If a thread is destroyed while
+   *             it still maintains a lock on a resource, then this resource
+   *             will remain locked and any attempts by other threads to
+   *             access the resource will result in a deadlock.  Thus, even
+   *             an implemented version of this method would be still be
+   *             deprecated, due to its unsafe nature.
+   * @throws NoSuchMethodError as this method was never implemented.
+   */
+  public void destroy()
+  {
+    throw new NoSuchMethodError();
+  }
+  
+  /**
+   * Print a stack trace of the current thread to stderr using the same
+   * format as Throwable's printStackTrace() method.
+   *
+   * @see Throwable#printStackTrace()
+   */
+  public static void dumpStack()
+  {
+    new Throwable().printStackTrace();
+  }
+
+  /**
+   * Copy every active thread in the current Thread's ThreadGroup into the
+   * array. Extra threads are silently ignored. This implementation calls
+   * <code>getThreadGroup().enumerate(array)</code>, which may have a
+   * security check, <code>checkAccess(group)</code>.
+   *
+   * @param array the array to place the Threads into
+   * @return the number of Threads placed into the array
+   * @throws NullPointerException if array is null
+   * @throws SecurityException if you cannot access the ThreadGroup
+   * @see ThreadGroup#enumerate(Thread[])
+   * @see #activeCount()
+   * @see SecurityManager#checkAccess(ThreadGroup)
+   */
+  public static int enumerate(Thread[] array)
+  {
+    return currentThread().group.enumerate(array);
+  }
+  
+  /**
+   * Get this Thread's name.
+   *
+   * @return this Thread's name
+   */
+  public final String getName()
+  {
+    VMThread t = vmThread;
+    return t == null ? name : t.getName();
+  }
+
+  /**
+   * Get this Thread's priority.
+   *
+   * @return the Thread's priority
+   */
+  public final synchronized int getPriority()
+  {
+    VMThread t = vmThread;
+    return t == null ? priority : t.getPriority();
+  }
+
+  /**
+   * Get the ThreadGroup this Thread belongs to. If the thread has died, this
+   * returns null.
+   *
+   * @return this Thread's ThreadGroup
+   */
+  public final ThreadGroup getThreadGroup()
+  {
+    return group;
+  }
+
+  /**
+   * Checks whether the current thread holds the monitor on a given object.
+   * This allows you to do <code>assert Thread.holdsLock(obj)</code>.
+   *
+   * @param obj the object to test lock ownership on.
+   * @return true if the current thread is currently synchronized on obj
+   * @throws NullPointerException if obj is null
+   * @since 1.4
+   */
+  public static boolean holdsLock(Object obj)
+  {
+    return VMThread.holdsLock(obj);
+  }
+
+  /**
+   * Interrupt this Thread. First, there is a security check,
+   * <code>checkAccess</code>. Then, depending on the current state of the
+   * thread, various actions take place:
+   *
+   * <p>If the thread is waiting because of {@link #wait()},
+   * {@link #sleep(long)}, or {@link #join()}, its <i>interrupt status</i>
+   * will be cleared, and an InterruptedException will be thrown. Notice that
+   * this case is only possible if an external thread called interrupt().
+   *
+   * <p>If the thread is blocked in an interruptible I/O operation, in
+   * {@link java.nio.channels.InterruptibleChannel}, the <i>interrupt
+   * status</i> will be set, and ClosedByInterruptException will be thrown.
+   *
+   * <p>If the thread is blocked on a {@link java.nio.channels.Selector}, the
+   * <i>interrupt status</i> will be set, and the selection will return, with
+   * a possible non-zero value, as though by the wakeup() method.
+   *
+   * <p>Otherwise, the interrupt status will be set.
+   *
+   * @throws SecurityException if you cannot modify this Thread
+   */
+  public synchronized void interrupt()
+  {
+    checkAccess();
+    VMThread t = vmThread;
+    if (t != null)
+	t.interrupt();
+  }
+
+  /**
+   * Determine whether the current Thread has been interrupted, and clear
+   * the <i>interrupted status</i> in the process.
+   *
+   * @return whether the current Thread has been interrupted
+   * @see #isInterrupted()
+   */
+  public static boolean interrupted()
+  {
+    return VMThread.interrupted();
+  }
+
+  /**
+   * Determine whether the given Thread has been interrupted, but leave
+   * the <i>interrupted status</i> alone in the process.
+   *
+   * @return whether the Thread has been interrupted
+   * @see #interrupted()
+   */
+  public boolean isInterrupted()
+  {
+    VMThread t = vmThread;
+    return t != null && t.isInterrupted();
+  }
+
+  /**
+   * Determine whether this Thread is alive. A thread which is alive has
+   * started and not yet died.
+   *
+   * @return whether this Thread is alive
+   */
+  public final boolean isAlive()
+  {
+    return vmThread != null && group != null;
+  }
+
+  /**
+   * Tell whether this is a daemon Thread or not.
+   *
+   * @return whether this is a daemon Thread or not
+   * @see #setDaemon(boolean)
+   */
+  public final boolean isDaemon()
+  {
+    VMThread t = vmThread;
+    return t == null ? daemon : t.isDaemon();
+  }
+
+  /**
+   * Wait forever for the Thread in question to die.
+   *
+   * @throws InterruptedException if the Thread is interrupted; it's
+   *         <i>interrupted status</i> will be cleared
+   */
+  public final void join() throws InterruptedException
+  {
+    join(0, 0);
+  }
+
+  /**
+   * Wait the specified amount of time for the Thread in question to die.
+   *
+   * @param ms the number of milliseconds to wait, or 0 for forever
+   * @throws InterruptedException if the Thread is interrupted; it's
+   *         <i>interrupted status</i> will be cleared
+   */
+  public final void join(long ms) throws InterruptedException
+  {
+    join(ms, 0);
+  }
+
+  /**
+   * Wait the specified amount of time for the Thread in question to die.
+   *
+   * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
+   * not offer that fine a grain of timing resolution. Besides, there is
+   * no guarantee that this thread can start up immediately when time expires,
+   * because some other thread may be active.  So don't expect real-time
+   * performance.
+   *
+   * @param ms the number of milliseconds to wait, or 0 for forever
+   * @param ns the number of extra nanoseconds to sleep (0-999999)
+   * @throws InterruptedException if the Thread is interrupted; it's
+   *         <i>interrupted status</i> will be cleared
+   * @throws IllegalArgumentException if ns is invalid
+   */
+  public final void join(long ms, int ns) throws InterruptedException
+  {
+    if(ms < 0 || ns < 0 || ns > 999999)
+	throw new IllegalArgumentException();
+
+    VMThread t = vmThread;
+    if(t != null)
+        t.join(ms, ns);
+  }
+
+  /**
+   * Resume this Thread.  If the thread is not suspended, this method does
+   * nothing. To mirror suspend(), there may be a security check:
+   * <code>checkAccess</code>.
+   *
+   * @throws SecurityException if you cannot resume the Thread
+   * @see #checkAccess()
+   * @see #suspend()
+   * @deprecated pointless, since suspend is deprecated
+   */
+  public final synchronized void resume()
+  {
+    checkAccess();
+    VMThread t = vmThread;
+    if (t != null)
+	t.resume();
+  }
+  
+  /**
+   * The method of Thread that will be run if there is no Runnable object
+   * associated with the Thread. Thread's implementation does nothing at all.
+   *
+   * @see #start()
+   * @see #Thread(ThreadGroup, Runnable, String)
+   */
+  public void run()
+  {
+    if (runnable != null)
+      runnable.run();
+  }
+
+  /**
+   * Set the daemon status of this Thread.  If this is a daemon Thread, then
+   * the VM may exit even if it is still running.  This may only be called
+   * before the Thread starts running. There may be a security check,
+   * <code>checkAccess</code>.
+   *
+   * @param daemon whether this should be a daemon thread or not
+   * @throws SecurityException if you cannot modify this Thread
+   * @throws IllegalThreadStateException if the Thread is active
+   * @see #isDaemon()
+   * @see #checkAccess()
+   */
+  public final synchronized void setDaemon(boolean daemon)
+  {
+    if (vmThread != null)
+      throw new IllegalThreadStateException();
+    checkAccess();
+    this.daemon = daemon;
+  }
+
+  /**
+   * Returns the context classloader of this Thread. The context
+   * classloader can be used by code that want to load classes depending
+   * on the current thread. Normally classes are loaded depending on
+   * the classloader of the current class. There may be a security check
+   * for <code>RuntimePermission("getClassLoader")</code> if the caller's
+   * class loader is not null or an ancestor of this thread's context class
+   * loader.
+   *
+   * @return the context class loader
+   * @throws SecurityException when permission is denied
+   * @see #setContextClassLoader(ClassLoader)
+   * @since 1.2
+   */
+  public synchronized ClassLoader getContextClassLoader()
+  {
+    ClassLoader loader = contextClassLoaderIsSystemClassLoader ?
+        ClassLoader.getSystemClassLoader() : contextClassLoader;
+    // Check if we may get the classloader
+    SecurityManager sm = SecurityManager.current;
+    if (loader != null && sm != null)
+      {
+        // Get the calling classloader
+	ClassLoader cl = VMStackWalker.getCallingClassLoader();
+        if (cl != null && !cl.isAncestorOf(loader))
+          sm.checkPermission(new RuntimePermission("getClassLoader"));
+      }
+    return loader;
+  }
+
+  /**
+   * Sets the context classloader for this Thread. When not explicitly set,
+   * the context classloader for a thread is the same as the context
+   * classloader of the thread that created this thread. The first thread has
+   * as context classloader the system classloader. There may be a security
+   * check for <code>RuntimePermission("setContextClassLoader")</code>.
+   *
+   * @param classloader the new context class loader
+   * @throws SecurityException when permission is denied
+   * @see #getContextClassLoader()
+   * @since 1.2
+   */
+  public synchronized void setContextClassLoader(ClassLoader classloader)
+  {
+    SecurityManager sm = SecurityManager.current;
+    if (sm != null)
+      sm.checkPermission(new RuntimePermission("setContextClassLoader"));
+    this.contextClassLoader = classloader;
+    contextClassLoaderIsSystemClassLoader = false;
+  }
+
+  /**
+   * Set this Thread's name.  There may be a security check,
+   * <code>checkAccess</code>.
+   *
+   * @param name the new name for this Thread
+   * @throws NullPointerException if name is null
+   * @throws SecurityException if you cannot modify this Thread
+   */
+  public final synchronized void setName(String name)
+  {
+    checkAccess();
+    // The Class Libraries book says ``threadName cannot be null''.  I
+    // take this to mean NullPointerException.
+    if (name == null)
+      throw new NullPointerException();
+    VMThread t = vmThread;
+    if (t != null)
+	t.setName(name);
+    else
+	this.name = name;
+  }
+
+  /**
+   * Yield to another thread. The Thread will not lose any locks it holds
+   * during this time. There are no guarantees which thread will be
+   * next to run, and it could even be this one, but most VMs will choose
+   * the highest priority thread that has been waiting longest.
+   */
+  public static void yield()
+  {
+    VMThread.yield();
+  }
+
+  /**
+   * Suspend the current Thread's execution for the specified amount of
+   * time. The Thread will not lose any locks it has during this time. There
+   * are no guarantees which thread will be next to run, but most VMs will
+   * choose the highest priority thread that has been waiting longest.
+   *
+   * @param ms the number of milliseconds to sleep.
+   * @throws InterruptedException if the Thread is (or was) interrupted;
+   *         it's <i>interrupted status</i> will be cleared
+   * @throws IllegalArgumentException if ms is negative
+   * @see #interrupt()
+   */
+  public static void sleep(long ms) throws InterruptedException
+  {
+    sleep(ms, 0);
+  }
+
+  /**
+   * Suspend the current Thread's execution for the specified amount of
+   * time. The Thread will not lose any locks it has during this time. There
+   * are no guarantees which thread will be next to run, but most VMs will
+   * choose the highest priority thread that has been waiting longest.
+   * <p>
+   * Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs
+   * do not offer that fine a grain of timing resolution. When ms is
+   * zero and ns is non-zero the Thread will sleep for at least one
+   * milli second. There is no guarantee that this thread can start up
+   * immediately when time expires, because some other thread may be
+   * active.  So don't expect real-time performance.
+   *
+   * @param ms the number of milliseconds to sleep
+   * @param ns the number of extra nanoseconds to sleep (0-999999)
+   * @throws InterruptedException if the Thread is (or was) interrupted;
+   *         it's <i>interrupted status</i> will be cleared
+   * @throws IllegalArgumentException if ms or ns is negative
+   *         or ns is larger than 999999.
+   * @see #interrupt()
+   */
+  public static void sleep(long ms, int ns) throws InterruptedException
+  {
+
+    // Check parameters
+    if (ms < 0 )
+      throw new IllegalArgumentException("Negative milliseconds: " + ms);
+
+    if (ns < 0 || ns > 999999)
+      throw new IllegalArgumentException("Nanoseconds ouf of range: " + ns);
+
+    // Really sleep
+    VMThread.sleep(ms, ns);
+  }
+
+  /**
+   * Start this Thread, calling the run() method of the Runnable this Thread
+   * was created with, or else the run() method of the Thread itself. This
+   * is the only way to start a new thread; calling run by yourself will just
+   * stay in the same thread. The virtual machine will remove the thread from
+   * its thread group when the run() method completes.
+   *
+   * @throws IllegalThreadStateException if the thread has already started
+   * @see #run()
+   */
+  public synchronized void start()
+  {
+    if (vmThread != null || group == null)
+	throw new IllegalThreadStateException();
+
+    VMThread.create(this, stacksize);
+  }
+  
+  /**
+   * Cause this Thread to stop abnormally because of the throw of a ThreadDeath
+   * error. If you stop a Thread that has not yet started, it will stop
+   * immediately when it is actually started.
+   *
+   * <p>This is inherently unsafe, as it can interrupt synchronized blocks and
+   * leave data in bad states.  Hence, there is a security check:
+   * <code>checkAccess(this)</code>, plus another one if the current thread
+   * is not this: <code>RuntimePermission("stopThread")</code>. If you must
+   * catch a ThreadDeath, be sure to rethrow it after you have cleaned up.
+   * ThreadDeath is the only exception which does not print a stack trace when
+   * the thread dies.
+   *
+   * @throws SecurityException if you cannot stop the Thread
+   * @see #interrupt()
+   * @see #checkAccess()
+   * @see #start()
+   * @see ThreadDeath
+   * @see ThreadGroup#uncaughtException(Thread, Throwable)
+   * @see SecurityManager#checkAccess(Thread)
+   * @see SecurityManager#checkPermission(Permission)
+   * @deprecated unsafe operation, try not to use
+   */
+  public final void stop()
+  {
+    stop(new ThreadDeath());
+  }
+
+  /**
+   * Cause this Thread to stop abnormally and throw the specified exception.
+   * If you stop a Thread that has not yet started, the stop is ignored
+   * (contrary to what the JDK documentation says).
+   * <b>WARNING</b>This bypasses Java security, and can throw a checked
+   * exception which the call stack is unprepared to handle. Do not abuse
+   * this power.
+   *
+   * <p>This is inherently unsafe, as it can interrupt synchronized blocks and
+   * leave data in bad states.  Hence, there is a security check:
+   * <code>checkAccess(this)</code>, plus another one if the current thread
+   * is not this: <code>RuntimePermission("stopThread")</code>. If you must
+   * catch a ThreadDeath, be sure to rethrow it after you have cleaned up.
+   * ThreadDeath is the only exception which does not print a stack trace when
+   * the thread dies.
+   *
+   * @param t the Throwable to throw when the Thread dies
+   * @throws SecurityException if you cannot stop the Thread
+   * @throws NullPointerException in the calling thread, if t is null
+   * @see #interrupt()
+   * @see #checkAccess()
+   * @see #start()
+   * @see ThreadDeath
+   * @see ThreadGroup#uncaughtException(Thread, Throwable)
+   * @see SecurityManager#checkAccess(Thread)
+   * @see SecurityManager#checkPermission(Permission)
+   * @deprecated unsafe operation, try not to use
+   */
+  public final synchronized void stop(Throwable t)
+  {
+    if (t == null)
+      throw new NullPointerException();
+    // Bypass System.getSecurityManager, for bootstrap efficiency.
+    SecurityManager sm = SecurityManager.current;
+    if (sm != null)
+      {
+        sm.checkAccess(this);
+        if (this != currentThread() || !(t instanceof ThreadDeath))
+          sm.checkPermission(new RuntimePermission("stopThread"));
+      }
+    VMThread vt = vmThread;
+    if (vt != null)
+	vt.stop(t);
+    else
+	stillborn = t;
+  }
+
+  /**
+   * Suspend this Thread.  It will not come back, ever, unless it is resumed.
+   *
+   * <p>This is inherently unsafe, as the suspended thread still holds locks,
+   * and can potentially deadlock your program.  Hence, there is a security
+   * check: <code>checkAccess</code>.
+   *
+   * @throws SecurityException if you cannot suspend the Thread
+   * @see #checkAccess()
+   * @see #resume()
+   * @deprecated unsafe operation, try not to use
+   */
+  public final synchronized void suspend()
+  {
+    checkAccess();
+    VMThread t = vmThread;
+    if (t != null)
+	t.suspend();
+  }
+
+  /**
+   * Set this Thread's priority. There may be a security check,
+   * <code>checkAccess</code>, then the priority is set to the smaller of
+   * priority and the ThreadGroup maximum priority.
+   *
+   * @param priority the new priority for this Thread
+   * @throws IllegalArgumentException if priority exceeds MIN_PRIORITY or
+   *         MAX_PRIORITY
+   * @throws SecurityException if you cannot modify this Thread
+   * @see #getPriority()
+   * @see #checkAccess()
+   * @see ThreadGroup#getMaxPriority()
+   * @see #MIN_PRIORITY
+   * @see #MAX_PRIORITY
+   */
+  public final synchronized void setPriority(int priority)
+  {
+    checkAccess();
+    if (priority < MIN_PRIORITY || priority > MAX_PRIORITY)
+      throw new IllegalArgumentException("Invalid thread priority value "
+                                         + priority + ".");
+    priority = Math.min(priority, group.getMaxPriority());
+    VMThread t = vmThread;
+    if (t != null)
+	t.setPriority(priority);
+    else
+	this.priority = priority;
+  }
+
+  /**
+   * Returns a string representation of this thread, including the
+   * thread's name, priority, and thread group.
+   *
+   * @return a human-readable String representing this Thread
+   */
+  public String toString()
+  {
+    return ("Thread[" + name + "," + priority + ","
+	    + (group == null ? "" : group.getName()) + "]");
+  }
+
+  /**
+   * Clean up code, called by VMThread when thread dies.
+   */
+  synchronized void die()
+  {
+    group.removeThread(this);
+    vmThread = null;
+    locals = null;
+  }
+
+  /**
+   * Returns the map used by ThreadLocal to store the thread local values.
+   */
+  static Map getThreadLocals()
+  {
+    Thread thread = currentThread();
+    Map locals = thread.locals;
+    if (locals == null)
+      {
+        locals = thread.locals = new WeakIdentityHashMap();
+      }
+    return locals;
+  }
+
+  /** 
+   * Assigns the given <code>UncaughtExceptionHandler</code> to this
+   * thread.  This will then be called if the thread terminates due
+   * to an uncaught exception, pre-empting that of the
+   * <code>ThreadGroup</code>.
+   *
+   * @param h the handler to use for this thread.
+   * @throws SecurityException if the current thread can't modify this thread.
+   * @since 1.5 
+   */
+  public void setUncaughtExceptionHandler(UncaughtExceptionHandler h)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe.
+    if (sm != null)
+      sm.checkAccess(this);    
+    exceptionHandler = h;
+  }
+
+  /** 
+   * <p>
+   * Returns the handler used when this thread terminates due to an
+   * uncaught exception.  The handler used is determined by the following:
+   * </p>
+   * <ul>
+   * <li>If this thread has its own handler, this is returned.</li>
+   * <li>If not, then the handler of the thread's <code>ThreadGroup</code>
+   * object is returned.</li>
+   * <li>If both are unavailable, then <code>null</code> is returned
+   *     (which can only happen when the thread was terminated since
+   *      then it won't have an associated thread group anymore).</li>
+   * </ul>
+   * 
+   * @return the appropriate <code>UncaughtExceptionHandler</code> or
+   *         <code>null</code> if one can't be obtained.
+   * @since 1.5 
+   */
+  public UncaughtExceptionHandler getUncaughtExceptionHandler()
+  {
+    return exceptionHandler != null ? exceptionHandler : group;
+  }
+
+  /** 
+   * <p>
+   * Sets the default uncaught exception handler used when one isn't
+   * provided by the thread or its associated <code>ThreadGroup</code>.
+   * This exception handler is used when the thread itself does not
+   * have an exception handler, and the thread's <code>ThreadGroup</code>
+   * does not override this default mechanism with its own.  As the group
+   * calls this handler by default, this exception handler should not defer
+   * to that of the group, as it may lead to infinite recursion.
+   * </p>
+   * <p>
+   * Uncaught exception handlers are used when a thread terminates due to
+   * an uncaught exception.  Replacing this handler allows default code to
+   * be put in place for all threads in order to handle this eventuality.
+   * </p>
+   *
+   * @param h the new default uncaught exception handler to use.
+   * @throws SecurityException if a security manager is present and
+   *                           disallows the runtime permission
+   *                           "setDefaultUncaughtExceptionHandler".
+   * @since 1.5 
+   */
+  public static void 
+    setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler h)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe.
+    if (sm != null)
+      sm.checkPermission(new RuntimePermission("setDefaultUncaughtExceptionHandler"));    
+    defaultHandler = h;
+  }
+
+  /** 
+   * Returns the handler used by default when a thread terminates
+   * unexpectedly due to an exception, or <code>null</code> if one doesn't
+   * exist.
+   *
+   * @return the default uncaught exception handler.
+   * @since 1.5 
+   */
+  public static UncaughtExceptionHandler getDefaultUncaughtExceptionHandler()
+  {
+    return defaultHandler;
+  }
+  
+  /** 
+   * Returns the unique identifier for this thread.  This ID is generated
+   * on thread creation, and may be re-used on its death.
+   *
+   * @return a positive long number representing the thread's ID.
+   * @since 1.5 
+   */
+  public long getId()
+  {
+    return threadId;
+  }
+
+  /**
+   * <p>
+   * This interface is used to handle uncaught exceptions
+   * which cause a <code>Thread</code> to terminate.  When
+   * a thread, t, is about to terminate due to an uncaught
+   * exception, the virtual machine looks for a class which
+   * implements this interface, in order to supply it with
+   * the dying thread and its uncaught exception.
+   * </p>
+   * <p>
+   * The virtual machine makes two attempts to find an
+   * appropriate handler for the uncaught exception, in
+   * the following order:
+   * </p>
+   * <ol>
+   * <li>
+   * <code>t.getUncaughtExceptionHandler()</code> --
+   * the dying thread is queried first for a handler
+   * specific to that thread.
+   * </li>
+   * <li>
+   * <code>t.getThreadGroup()</code> --
+   * the thread group of the dying thread is used to
+   * handle the exception.  If the thread group has
+   * no special requirements for handling the exception,
+   * it may simply forward it on to
+   * <code>Thread.getDefaultUncaughtExceptionHandler()</code>,
+   * the default handler, which is used as a last resort.
+   * </li>
+   * </ol>
+   * <p>
+   * The first handler found is the one used to handle
+   * the uncaught exception.
+   * </p>
+   *
+   * @author Tom Tromey <tromey at redhat.com>
+   * @author Andrew John Hughes <gnu_andrew at member.fsf.org>
+   * @since 1.5
+   * @see Thread#getUncaughtExceptionHandler()
+   * @see Thread#setUncaughtExceptionHandler(UncaughtExceptionHandler)
+   * @see Thread#getDefaultUncaughtExceptionHandler()
+   * @see
+   * Thread#setDefaultUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)
+   */
+  public interface UncaughtExceptionHandler
+  {
+    /**
+     * Invoked by the virtual machine with the dying thread
+     * and the uncaught exception.  Any exceptions thrown
+     * by this method are simply ignored by the virtual
+     * machine.
+     *
+     * @param thr the dying thread.
+     * @param exc the uncaught exception.
+     */
+    void uncaughtException(Thread thr, Throwable exc);
+  }
+
+  /**
+   * Returns the current state of the thread.  This
+   * is designed for monitoring thread behaviour, rather
+   * than for synchronization control.
+   *
+   * @return the current thread state.
+   */
+  public String getState()
+  {
+    VMThread t = vmThread;
+    if (t != null)
+      return t.getState();
+    if (group == null)
+      return "TERMINATED";
+    return "NEW";
+  }
+
+  /**
+   * <p>
+   * Returns a map of threads to stack traces for each
+   * live thread.  The keys of the map are {@link Thread}
+   * objects, which map to arrays of {@link StackTraceElement}s.
+   * The results obtained from Calling this method are
+   * equivalent to calling {@link getStackTrace()} on each
+   * thread in succession.  Threads may be executing while
+   * this takes place, and the results represent a snapshot
+   * of the thread at the time its {@link getStackTrace()}
+   * method is called.
+   * </p>
+   * <p>
+   * The stack trace information contains the methods called
+   * by the thread, with the most recent method forming the
+   * first element in the array.  The array will be empty
+   * if the virtual machine can not obtain information on the
+   * thread. 
+   * </p>
+   * <p>
+   * To execute this method, the current security manager
+   * (if one exists) must allow both the
+   * <code>"getStackTrace"</code> and
+   * <code>"modifyThreadGroup"</code> {@link RuntimePermission}s.
+   * </p>
+   * 
+   * @return a map of threads to arrays of {@link StackTraceElement}s.
+   * @throws SecurityException if a security manager exists, and
+   *                           prevents either or both the runtime
+   *                           permissions specified above.
+   * @since 1.5
+   * @see #getStackTrace()
+   */
+  public static Map getAllStackTraces()
+  {
+    ThreadGroup group = currentThread().group;
+    while (group.getParent() != null)
+      group = group.getParent();
+    int arraySize = group.activeCount();
+    Thread[] threadList = new Thread[arraySize];
+    int filled = group.enumerate(threadList);
+    while (filled == arraySize)
+      {
+	arraySize *= 2;
+	threadList = new Thread[arraySize];
+	filled = group.enumerate(threadList);
+      }
+    Map traces = new HashMap();
+    for (int a = 0; a < filled; ++a)
+      traces.put(threadList[a],
+		 threadList[a].getStackTrace());
+    return traces;
+  }
+
+  /**
+   * <p>
+   * Returns an array of {@link StackTraceElement}s
+   * representing the current stack trace of this thread.
+   * The first element of the array is the most recent
+   * method called, and represents the top of the stack.
+   * The elements continue in this order, with the last
+   * element representing the bottom of the stack.
+   * </p>
+   * <p>
+   * A zero element array is returned for threads which
+   * have not yet started (and thus have not yet executed
+   * any methods) or for those which have terminated.
+   * Where the virtual machine can not obtain a trace for
+   * the thread, an empty array is also returned.  The
+   * virtual machine may also omit some methods from the
+   * trace in non-zero arrays.
+   * </p>
+   * <p>
+   * To execute this method, the current security manager
+   * (if one exists) must allow both the
+   * <code>"getStackTrace"</code> and
+   * <code>"modifyThreadGroup"</code> {@link RuntimePermission}s.
+   * </p>
+   *
+   * @return a stack trace for this thread.
+   * @throws SecurityException if a security manager exists, and
+   *                           prevents the use of the
+   *                           <code>"getStackTrace"</code>
+   *                           permission.
+   * @since 1.5
+   * @see #getAllStackTraces()
+   */
+  public StackTraceElement[] getStackTrace()
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe.
+    if (sm != null)
+      sm.checkPermission(new RuntimePermission("getStackTrace"));
+    ThreadMXBean bean = ManagementFactory.getThreadMXBean();
+    ThreadInfo info = bean.getThreadInfo(threadId, Integer.MAX_VALUE);
+    return info.getStackTrace();
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ThreadDeath.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ThreadDeath.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,68 @@
+/* ThreadDeath.java - special exception registering Thread death
+   Copyright (C) 1998, 1999, 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 java.lang;
+
+/**
+ * ThreadDeath is thrown in a thread when someone calls <code>stop()</code>
+ * on that thread. <b>Important:</b> Make sure you rethrow this exception
+ * if you catch it.  If you don't, the thread will not die.
+ *
+ * <p>This is an Error rather than an exception, so that normal code will
+ * not catch it. It is intended for asynchronous cleanup when using the
+ * deprecated Thread.stop() method.
+ *
+ * @author John Keiser
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @see Thread#stop()
+ * @status updated to 1.4
+ */
+public class ThreadDeath extends Error
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -4417128565033088268L;
+
+  /**
+   * Create an error without a message.
+   */
+  public ThreadDeath()
+  {
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ThreadGroup.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ThreadGroup.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,791 @@
+/* ThreadGroup -- a group of Threads
+   Copyright (C) 1998, 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 java.lang;
+
+import java.lang.Thread.UncaughtExceptionHandler;
+import java.util.Vector;
+
+/**
+ * ThreadGroup allows you to group Threads together.  There is a hierarchy
+ * of ThreadGroups, and only the initial ThreadGroup has no parent.  A Thread
+ * may access information about its own ThreadGroup, but not its parents or
+ * others outside the tree.
+ *
+ * @author John Keiser
+ * @author Tom Tromey
+ * @author Bryce McKinlay
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Thread
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public class ThreadGroup implements UncaughtExceptionHandler
+{
+  /** The Initial, top-level ThreadGroup. */
+  static ThreadGroup root = new ThreadGroup();
+
+  /**
+   * This flag is set if an uncaught exception occurs. The runtime should
+   * check this and exit with an error status if it is set.
+   */
+  static boolean had_uncaught_exception;
+
+  /** The parent thread group. */
+  final ThreadGroup parent;
+
+  /** The group name, non-null. */
+  final String name;
+
+  /** The threads in the group. */
+  private final Vector threads = new Vector();
+
+  /** Child thread groups, or null when this group is destroyed. */
+  private Vector groups = new Vector();
+
+  /** If all threads in the group are daemons. */
+  private boolean daemon_flag = false;
+
+  /** The maximum group priority. */
+  private int maxpri;
+
+  /**
+   * Hidden constructor to build the root node.
+   */
+  private ThreadGroup()
+  {
+    name = "main";
+    parent = null;
+    maxpri = Thread.MAX_PRIORITY;
+  }
+
+  /**
+   * Create a new ThreadGroup using the given name and the current thread's
+   * ThreadGroup as a parent. There may be a security check,
+   * <code>checkAccess</code>.
+   *
+   * @param name the name to use for the ThreadGroup
+   * @throws SecurityException if the current thread cannot create a group
+   * @see #checkAccess()
+   */
+  public ThreadGroup(String name)
+  {
+    this(Thread.currentThread().group, name);
+  }
+
+  /**
+   * Create a new ThreadGroup using the given name and parent group. The new
+   * group inherits the maximum priority and daemon status of its parent
+   * group. There may be a security check, <code>checkAccess</code>.
+   *
+   * @param name the name to use for the ThreadGroup
+   * @param parent the ThreadGroup to use as a parent
+   * @throws NullPointerException if parent is null
+   * @throws SecurityException if the current thread cannot create a group
+   * @throws IllegalThreadStateException if the parent is destroyed
+   * @see #checkAccess()
+   */
+  public ThreadGroup(ThreadGroup parent, String name)
+  {
+    parent.checkAccess();
+    this.parent = parent;
+    this.name = name;
+    maxpri = parent.maxpri;
+    daemon_flag = parent.daemon_flag;
+    synchronized (parent)
+      {
+        if (parent.groups == null)
+          throw new IllegalThreadStateException();
+        parent.groups.add(this);
+      }
+  }
+
+  /**
+   * Get the name of this ThreadGroup.
+   *
+   * @return the name of this ThreadGroup
+   */
+  public final String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Get the parent of this ThreadGroup. If the parent is not null, there
+   * may be a security check, <code>checkAccess</code>.
+   *
+   * @return the parent of this ThreadGroup
+   * @throws SecurityException if permission is denied
+   */
+  public final ThreadGroup getParent()
+  {
+    if (parent != null)
+      parent.checkAccess();
+    return parent;
+  }
+
+  /**
+   * Get the maximum priority of Threads in this ThreadGroup. Threads created
+   * after this call in this group may not exceed this priority.
+   *
+   * @return the maximum priority of Threads in this ThreadGroup
+   */
+  public final int getMaxPriority()
+  {
+    return maxpri;
+  }
+
+  /**
+   * Tell whether this ThreadGroup is a daemon group.  A daemon group will
+   * be automatically destroyed when its last thread is stopped and
+   * its last thread group is destroyed.
+   *
+   * @return whether this ThreadGroup is a daemon group
+   */
+  public final boolean isDaemon()
+  {
+    return daemon_flag;
+  }
+
+  /**
+   * Tell whether this ThreadGroup has been destroyed or not.
+   *
+   * @return whether this ThreadGroup has been destroyed or not
+   * @since 1.1
+   */
+  public synchronized boolean isDestroyed()
+  {
+    return groups == null;
+  }
+
+  /**
+   * Set whether this ThreadGroup is a daemon group.  A daemon group will be
+   * destroyed when its last thread is stopped and its last thread group is
+   * destroyed. There may be a security check, <code>checkAccess</code>.
+   *
+   * @param daemon whether this ThreadGroup should be a daemon group
+   * @throws SecurityException if you cannot modify this ThreadGroup
+   * @see #checkAccess()
+   */
+  public final void setDaemon(boolean daemon)
+  {
+    checkAccess();
+    daemon_flag = daemon;
+  }
+
+  /**
+   * Set the maximum priority for Threads in this ThreadGroup. setMaxPriority
+   * can only be used to reduce the current maximum. If maxpri is greater
+   * than the current Maximum of the parent group, the current value is not
+   * changed. Otherwise, all groups which belong to this have their priority
+   * adjusted as well. Calling this does not affect threads already in this
+   * ThreadGroup. There may be a security check, <code>checkAccess</code>.
+   *
+   * @param maxpri the new maximum priority for this ThreadGroup
+   * @throws SecurityException if you cannot modify this ThreadGroup
+   * @see #getMaxPriority()
+   * @see #checkAccess()
+   */
+  public final synchronized void setMaxPriority(int maxpri)
+  {
+    checkAccess();
+    if (maxpri < Thread.MIN_PRIORITY || maxpri > Thread.MAX_PRIORITY)
+      return;
+    if (parent != null && maxpri > parent.maxpri)
+      maxpri = parent.maxpri;
+    this.maxpri = maxpri;
+    if (groups == null)
+      return;
+    int i = groups.size();
+    while (--i >= 0)
+      ((ThreadGroup) groups.get(i)).setMaxPriority(maxpri);
+  }
+
+  /**
+   * Check whether this ThreadGroup is an ancestor of the specified
+   * ThreadGroup, or if they are the same.
+   *
+   * @param group the group to test on
+   * @return whether this ThreadGroup is a parent of the specified group
+   */
+  public final boolean parentOf(ThreadGroup group)
+  {
+    while (group != null)
+      {
+        if (group == this)
+          return true;
+        group = group.parent;
+      }
+    return false;
+  }
+
+  /**
+   * Find out if the current Thread can modify this ThreadGroup. This passes
+   * the check on to <code>SecurityManager.checkAccess(this)</code>.
+   *
+   * @throws SecurityException if the current Thread cannot modify this
+   *         ThreadGroup
+   * @see SecurityManager#checkAccess(ThreadGroup)
+   */
+  public final void checkAccess()
+  {
+    // Bypass System.getSecurityManager, for bootstrap efficiency.
+    SecurityManager sm = SecurityManager.current;
+    if (sm != null)
+      sm.checkAccess(this);
+  }
+
+  /**
+   * Return an estimate of the total number of active threads in this
+   * ThreadGroup and all its descendants. This cannot return an exact number,
+   * since the status of threads may change after they were counted; but it
+   * should be pretty close. Based on a JDC bug,
+   * <a href="http://developer.java.sun.com/developer/bugParade/bugs/4089701.html">
+   * 4089701</a>, we take active to mean isAlive().
+   *
+   * @return count of active threads in this ThreadGroup and its descendants
+   */
+  public int activeCount()
+  {
+    int total = 0;
+    if (groups == null)
+      return total;
+    int i = threads.size();
+    while (--i >= 0)
+      if (((Thread) threads.get(i)).isAlive())
+        total++;
+    i = groups.size();
+    while (--i >= 0)
+      total += ((ThreadGroup) groups.get(i)).activeCount();
+    return total;
+  }
+
+  /**
+   * Copy all of the active Threads from this ThreadGroup and its descendants
+   * into the specified array.  If the array is not big enough to hold all
+   * the Threads, extra Threads will simply not be copied. There may be a
+   * security check, <code>checkAccess</code>.
+   *
+   * @param array the array to put the threads into
+   * @return the number of threads put into the array
+   * @throws SecurityException if permission was denied
+   * @throws NullPointerException if array is null
+   * @throws ArrayStoreException if a thread does not fit in the array
+   * @see #activeCount()
+   * @see #checkAccess()
+   * @see #enumerate(Thread[], boolean)
+   */
+  public int enumerate(Thread[] array)
+  {
+    return enumerate(array, 0, true);
+  }
+
+  /**
+   * Copy all of the active Threads from this ThreadGroup and, if desired,
+   * from its descendants, into the specified array. If the array is not big
+   * enough to hold all the Threads, extra Threads will simply not be copied.
+   * There may be a security check, <code>checkAccess</code>.
+   *
+   * @param array the array to put the threads into
+   * @param recurse whether to recurse into descendent ThreadGroups
+   * @return the number of threads put into the array
+   * @throws SecurityException if permission was denied
+   * @throws NullPointerException if array is null
+   * @throws ArrayStoreException if a thread does not fit in the array
+   * @see #activeCount()
+   * @see #checkAccess()
+   */
+  public int enumerate(Thread[] array, boolean recurse)
+  {
+    return enumerate(array, 0, recurse);
+  }
+
+  /**
+   * Get the number of active groups in this ThreadGroup.  This group itself
+   * is not included in the count. A sub-group is active if it has not been
+   * destroyed. This cannot return an exact number, since the status of
+   * threads may change after they were counted; but it should be pretty close.
+   *
+   * @return the number of active groups in this ThreadGroup
+   */
+  public int activeGroupCount()
+  {
+    if (groups == null)
+      return 0;
+    int total = groups.size();
+    int i = total;
+    while (--i >= 0)
+      total += ((ThreadGroup) groups.get(i)).activeGroupCount();
+    return total;
+  }
+
+  /**
+   * Copy all active ThreadGroups that are descendants of this ThreadGroup
+   * into the specified array.  If the array is not large enough to hold all
+   * active ThreadGroups, extra ThreadGroups simply will not be copied. There
+   * may be a security check, <code>checkAccess</code>.
+   *
+   * @param array the array to put the ThreadGroups into
+   * @return the number of ThreadGroups copied into the array
+   * @throws SecurityException if permission was denied
+   * @throws NullPointerException if array is null
+   * @throws ArrayStoreException if a group does not fit in the array
+   * @see #activeCount()
+   * @see #checkAccess()
+   * @see #enumerate(ThreadGroup[], boolean)
+   */
+  public int enumerate(ThreadGroup[] array)
+  {
+    return enumerate(array, 0, true);
+  }
+
+  /**
+   * Copy all active ThreadGroups that are children of this ThreadGroup into
+   * the specified array, and if desired, also all descendents.  If the array
+   * is not large enough to hold all active ThreadGroups, extra ThreadGroups
+   * simply will not be copied. There may be a security check,
+   * <code>checkAccess</code>.
+   *
+   * @param array the array to put the ThreadGroups into
+   * @param recurse whether to recurse into descendent ThreadGroups
+   * @return the number of ThreadGroups copied into the array
+   * @throws SecurityException if permission was denied
+   * @throws NullPointerException if array is null
+   * @throws ArrayStoreException if a group does not fit in the array
+   * @see #activeCount()
+   * @see #checkAccess()
+   */
+  public int enumerate(ThreadGroup[] array, boolean recurse)
+  {
+    return enumerate(array, 0, recurse);
+  }
+
+  /**
+   * Stop all Threads in this ThreadGroup and its descendants.
+   *
+   * <p>This is inherently unsafe, as it can interrupt synchronized blocks and
+   * leave data in bad states.  Hence, there is a security check:
+   * <code>checkAccess()</code>, followed by further checks on each thread
+   * being stopped.
+   *
+   * @throws SecurityException if permission is denied
+   * @see #checkAccess()
+   * @see Thread#stop(Throwable)
+   * @deprecated unsafe operation, try not to use
+   */
+  public final synchronized void stop()
+  {
+    checkAccess();
+    if (groups == null)
+      return;
+    int i = threads.size();
+    while (--i >= 0)
+      ((Thread) threads.get(i)).stop();
+    i = groups.size();
+    while (--i >= 0)
+      ((ThreadGroup) groups.get(i)).stop();
+  }
+
+  /**
+   * Interrupt all Threads in this ThreadGroup and its sub-groups. There may
+   * be a security check, <code>checkAccess</code>.
+   *
+   * @throws SecurityException if permission is denied
+   * @see #checkAccess()
+   * @see Thread#interrupt()
+   * @since 1.2
+   */
+  public final synchronized void interrupt()
+  {
+    checkAccess();
+    if (groups == null)
+      return;
+    int i = threads.size();
+    while (--i >= 0)
+      ((Thread) threads.get(i)).interrupt();
+    i = groups.size();
+    while (--i >= 0)
+      ((ThreadGroup) groups.get(i)).interrupt();
+  }
+
+  /**
+   * Suspend all Threads in this ThreadGroup and its descendants.
+   *
+   * <p>This is inherently unsafe, as suspended threads still hold locks,
+   * which can lead to deadlock.  Hence, there is a security check:
+   * <code>checkAccess()</code>, followed by further checks on each thread
+   * being suspended.
+   *
+   * @throws SecurityException if permission is denied
+   * @see #checkAccess()
+   * @see Thread#suspend()
+   * @deprecated unsafe operation, try not to use
+   */
+  public final synchronized void suspend()
+  {
+    checkAccess();
+    if (groups == null)
+      return;
+    int i = threads.size();
+    while (--i >= 0)
+      ((Thread) threads.get(i)).suspend();
+    i = groups.size();
+    while (--i >= 0)
+      ((ThreadGroup) groups.get(i)).suspend();
+  }
+
+  /**
+   * Resume all suspended Threads in this ThreadGroup and its descendants.
+   * To mirror suspend(), there is a security check:
+   * <code>checkAccess()</code>, followed by further checks on each thread
+   * being resumed.
+   *
+   * @throws SecurityException if permission is denied
+   * @see #checkAccess()
+   * @see Thread#suspend()
+   * @deprecated pointless, since suspend is deprecated
+   */
+  public final synchronized void resume()
+  {
+    checkAccess();
+    if (groups == null)
+      return;
+    int i = threads.size();
+    while (--i >= 0)
+      ((Thread) threads.get(i)).resume();
+    i = groups.size();
+    while (--i >= 0)
+      ((ThreadGroup) groups.get(i)).resume();
+  }
+
+  /**
+   * Destroy this ThreadGroup.  The group must be empty, meaning that all
+   * threads and sub-groups have completed execution. Daemon groups are
+   * destroyed automatically. There may be a security check,
+   * <code>checkAccess</code>.
+   *
+   * @throws IllegalThreadStateException if the ThreadGroup is not empty, or
+   *         was previously destroyed
+   * @throws SecurityException if permission is denied
+   * @see #checkAccess()
+   */
+  public final synchronized void destroy()
+  {
+    checkAccess();
+    if (! threads.isEmpty() || groups == null)
+      throw new IllegalThreadStateException();
+    int i = groups.size();
+    while (--i >= 0)
+      ((ThreadGroup) groups.get(i)).destroy();
+    groups = null;
+    if (parent != null)
+      parent.removeGroup(this);
+  }
+
+  /**
+   * Print out information about this ThreadGroup to System.out. This is
+   * meant for debugging purposes. <b>WARNING:</b> This method is not secure,
+   * and can print the name of threads to standard out even when you cannot
+   * otherwise get at such threads.
+   */
+  public void list()
+  {
+    list("");
+  }
+
+  /**
+   * When a Thread in this ThreadGroup does not catch an exception, the
+   * virtual machine calls this method. The default implementation simply
+   * passes the call to the parent; then in top ThreadGroup, it will
+   * ignore ThreadDeath and print the stack trace of any other throwable.
+   * Override this method if you want to handle the exception in a different
+   * manner.
+   *
+   * @param thread the thread that exited
+   * @param t the uncaught throwable
+   * @throws NullPointerException if t is null
+   * @see ThreadDeath
+   * @see System#err
+   * @see Throwable#printStackTrace()
+   */
+  public void uncaughtException(Thread thread, Throwable t)
+  {
+    if (parent != null)
+      parent.uncaughtException(thread, t);
+    else if (Thread.getDefaultUncaughtExceptionHandler() != null)
+      Thread.getDefaultUncaughtExceptionHandler().uncaughtException(thread, t);
+    else if (! (t instanceof ThreadDeath))
+      {
+        if (t == null)
+          throw new NullPointerException();
+        had_uncaught_exception = true;
+        try
+          {
+            if (thread != null)
+              System.err.print("Exception in thread \"" + thread.name + "\" ");
+            t.printStackTrace(System.err);
+          }
+        catch (Throwable x)
+          {
+            // This means that something is badly screwed up with the runtime,
+            // or perhaps someone overloaded the Throwable.printStackTrace to
+            // die. In any case, try to deal with it gracefully.
+            try
+              {
+                System.err.println(t);
+                System.err.println("*** Got " + x
+                                   + " while trying to print stack trace.");
+              }
+            catch (Throwable x2)
+              {
+                // Here, someone may have overloaded t.toString() or
+                // x.toString() to die. Give up all hope; we can't even chain
+                // the exception, because the chain would likewise die.
+                System.err.println("*** Catastrophic failure while handling "
+                                   + "uncaught exception.");
+                throw new InternalError();
+              }
+          }
+      }
+  }
+
+  /**
+   * Originally intended to tell the VM whether it may suspend Threads in
+   * low memory situations, this method was never implemented by Sun, and
+   * is hence a no-op.
+   *
+   * @param allow whether to allow low-memory thread suspension; ignored
+   * @return false
+   * @since 1.1
+   * @deprecated pointless, since suspend is deprecated
+   */
+  public boolean allowThreadSuspension(boolean allow)
+  {
+    return false;
+  }
+
+  /**
+   * Return a human-readable String representing this ThreadGroup. The format
+   * of the string is:<br>
+   * <code>getClass().getName() + "[name=" + getName() + ",maxpri="
+   * + getMaxPriority() + ']'</code>.
+   *
+   * @return a human-readable String representing this ThreadGroup
+   */
+  public String toString()
+  {
+    return getClass().getName() + "[name=" + name + ",maxpri=" + maxpri + ']';
+  }
+
+  /**
+   * Implements enumerate.
+   *
+   * @param list the array to put the threads into
+   * @param next the next open slot in the array
+   * @param recurse whether to recurse into descendent ThreadGroups
+   * @return the number of threads put into the array
+   * @throws SecurityException if permission was denied
+   * @throws NullPointerException if list is null
+   * @throws ArrayStoreException if a thread does not fit in the array
+   * @see #enumerate(Thread[])
+   * @see #enumerate(Thread[], boolean)
+   */
+  private int enumerate(Thread[] list, int next, boolean recurse)
+  {
+    checkAccess();
+    if (groups == null)
+      return next;
+    int i = threads.size();
+    while (--i >= 0 && next < list.length)
+      {
+        Thread t = (Thread) threads.get(i);
+        if (t.isAlive())
+          list[next++] = t;
+      }
+    if (recurse)
+      {
+        i = groups.size();
+        while (--i >= 0 && next < list.length)
+          {
+            ThreadGroup g = (ThreadGroup) groups.get(i);
+            next = g.enumerate(list, next, true);
+          }
+      }
+    return next;
+  }
+
+  /**
+   * Implements enumerate.
+   *
+   * @param list the array to put the groups into
+   * @param next the next open slot in the array
+   * @param recurse whether to recurse into descendent ThreadGroups
+   * @return the number of groups put into the array
+   * @throws SecurityException if permission was denied
+   * @throws NullPointerException if list is null
+   * @throws ArrayStoreException if a group does not fit in the array
+   * @see #enumerate(ThreadGroup[])
+   * @see #enumerate(ThreadGroup[], boolean)
+   */
+  private int enumerate(ThreadGroup[] list, int next, boolean recurse)
+  {
+    checkAccess();
+    if (groups == null)
+      return next;
+    int i = groups.size();
+    while (--i >= 0 && next < list.length)
+      {
+        ThreadGroup g = (ThreadGroup) groups.get(i);
+        list[next++] = g;
+        if (recurse && next != list.length)
+          next = g.enumerate(list, next, true);
+      }
+    return next;
+  }
+
+  /**
+   * Implements list.
+   *
+   * @param indentation the current level of indentation
+   * @see #list()
+   */
+  private void list(String indentation)
+  {
+    if (groups == null)
+      return;
+    System.out.println(indentation + this);
+    indentation += "    ";
+    int i = threads.size();
+    while (--i >= 0)
+      System.out.println(indentation + threads.get(i));
+    i = groups.size();
+    while (--i >= 0)
+      ((ThreadGroup) groups.get(i)).list(indentation);
+  }
+
+  /**
+   * Add a thread to the group. Called by Thread constructors.
+   *
+   * @param t the thread to add, non-null
+   * @throws IllegalThreadStateException if the group is destroyed
+   */
+  final synchronized void addThread(Thread t)
+  {
+    if (groups == null)
+      throw new IllegalThreadStateException("ThreadGroup is destroyed");
+    threads.add(t);
+  }
+
+  /**
+   * Called by the VM to remove a thread that has died.
+   *
+   * @param t the thread to remove, non-null
+   * @XXX A ThreadListener to call this might be nice.
+   */
+  final synchronized void removeThread(Thread t)
+  {
+    if (groups == null)
+      return;
+    threads.remove(t);
+    t.group = null;
+    // Daemon groups are automatically destroyed when all their threads die.
+    if (daemon_flag && groups.size() == 0 && threads.size() == 0)
+      {
+        // We inline destroy to avoid the access check.
+        groups = null;
+        if (parent != null)
+          parent.removeGroup(this);
+      }
+  }
+
+  /**
+   * Called when a group is destroyed, to remove it from its parent.
+   *
+   * @param g the destroyed group, non-null
+   */
+  final synchronized void removeGroup(ThreadGroup g)
+  {
+    groups.remove(g);
+    // Daemon groups are automatically destroyed when all their threads die.
+    if (daemon_flag && groups.size() == 0 && threads.size() == 0)
+      {
+        // We inline destroy to avoid the access check.
+        groups = null;
+        if (parent != null)
+          parent.removeGroup(this);
+      }
+  }
+
+  /*
+   * Helper method for the VM. Find a Thread by its Id.
+   *
+   * @param id The Thread Id.
+   * @return Thread object or null if thread doesn't exist.
+   */
+  static Thread getThreadFromId(long id)
+  {
+    return root.getThreadFromIdImpl(id);
+  }
+
+  private Thread getThreadFromIdImpl(long id)
+  {
+    synchronized (threads)
+      {
+        for (int i = 0; i < threads.size(); i++)
+          {
+            Thread t = (Thread) threads.get(i);
+            if (t.getId() == id)
+              return t;
+          }
+      }
+    Vector groups = this.groups;
+    if (groups != null)
+      {
+        synchronized (groups)
+          {
+            for (int i = 0; i < groups.size(); i++)
+              {
+                ThreadGroup g = (ThreadGroup) groups.get(i);
+                Thread t = g.getThreadFromIdImpl(id);
+                if (t != null)
+                  return t;
+              }
+          }
+      }
+    return null;
+  }
+} // class ThreadGroup

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ThreadLocal.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ThreadLocal.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,166 @@
+/* ThreadLocal -- a variable with a unique value per thread
+   Copyright (C) 2000, 2002, 2003, 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.lang;
+
+import java.util.Map;
+
+
+/**
+ * ThreadLocal objects have a different state associated with every
+ * Thread that accesses them. Every access to the ThreadLocal object
+ * (through the <code>get()</code> and <code>set()</code> methods)
+ * only affects the state of the object as seen by the currently
+ * executing Thread.
+ *
+ * <p>The first time a ThreadLocal object is accessed on a particular
+ * Thread, the state for that Thread's copy of the local variable is set by
+ * executing the method <code>initialValue()</code>.
+ * </p>
+ *
+ * <p>An example how you can use this:
+ * </p>
+ *
+ * <pre>
+ * class Connection
+ * {
+ *   private static ThreadLocal owner = new ThreadLocal()
+ *     {
+ *       public Object initialValue()
+ *       {
+ *         return("nobody");
+ *       }
+ *     };
+ * ...
+ * }
+ * </pre>
+ *
+ * <p>Now all instances of connection can see who the owner of the currently
+ * executing Thread is by calling <code>owner.get()</code>. By default any
+ * Thread would be associated with 'nobody'. But the Connection object could
+ * offer a method that changes the owner associated with the Thread on
+ * which the method was called by calling <code>owner.put("somebody")</code>.
+ * (Such an owner changing method should then be guarded by security checks.)
+ * </p>
+ *
+ * <p>When a Thread is garbage collected all references to values of
+ * the ThreadLocal objects associated with that Thread are removed.
+ * </p>
+ *
+ * @author Mark Wielaard (mark at klomp.org)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class ThreadLocal
+{
+  /**
+   * Placeholder to distinguish between uninitialized and null set by the
+   * user. Do not expose this to the public. Package visible for use by
+   * InheritableThreadLocal
+   */
+  static final Object NULL = new Object();
+
+  /**
+   * Creates a ThreadLocal object without associating any value to it yet.
+   */
+  public ThreadLocal()
+  {
+  }
+
+  /**
+   * Called once per thread on the first invocation of get(), if set() was
+   * not already called. The default implementation returns <code>null</code>.
+   * Often, this method is overridden to create the appropriate initial object
+   * for the current thread's view of the ThreadLocal.
+   *
+   * @return the initial value of the variable in this thread
+   */
+  protected Object initialValue()
+  {
+    return null;
+  }
+
+  /**
+   * Gets the value associated with the ThreadLocal object for the currently
+   * executing Thread. If this is the first time the current thread has called
+   * get(), and it has not already called set(), the value is obtained by
+   * <code>initialValue()</code>.
+   *
+   * @return the value of the variable in this thread
+   */
+  public Object get()
+  {
+    Map map = Thread.getThreadLocals();
+    // Note that we don't have to synchronize, as only this thread will
+    // ever modify the map.
+    Object value = map.get(this);
+    if (value == null)
+      {
+        value = initialValue();
+        map.put(this, value == null ? NULL : value);
+      }
+    return value == NULL ? null : value;
+  }
+
+  /**
+   * Sets the value associated with the ThreadLocal object for the currently
+   * executing Thread. This overrides any existing value associated with the
+   * current Thread and prevents <code>initialValue()</code> from being
+   * called if this is the first access to this ThreadLocal in this Thread.
+   *
+   * @param value the value to set this thread's view of the variable to
+   */
+  public void set(Object value)
+  {
+    Map map = Thread.getThreadLocals();
+    // Note that we don't have to synchronize, as only this thread will
+    // ever modify the map.
+    map.put(this, value == null ? NULL : value);
+  }
+
+  /**
+   * Removes the value associated with the ThreadLocal object for the
+   * currently executing Thread.
+   * @since 1.5
+   */
+  public void remove()
+  {
+    Map map = Thread.getThreadLocals();
+    map.remove(this);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Throwable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Throwable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,563 @@
+/* java.lang.Throwable -- Root class for all Exceptions and Errors
+   Copyright (C) 1998, 1999, 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.lang;
+
+import gnu.classpath.SystemProperties;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
+
+/**
+ * Throwable is the superclass of all exceptions that can be raised.
+ *
+ * <p>There are two special cases: {@link Error} and {@link RuntimeException}:
+ * these two classes (and their subclasses) are considered unchecked
+ * exceptions, and are either frequent enough or catastrophic enough that you
+ * do not need to declare them in <code>throws</code> clauses.  Everything
+ * else is a checked exception, and is ususally a subclass of
+ * {@link Exception}; these exceptions have to be handled or declared.
+ *
+ * <p>Instances of this class are usually created with knowledge of the
+ * execution context, so that you can get a stack trace of the problem spot
+ * in the code.  Also, since JDK 1.4, Throwables participate in "exception
+ * chaining."  This means that one exception can be caused by another, and
+ * preserve the information of the original.
+ *
+ * <p>One reason this is useful is to wrap exceptions to conform to an
+ * interface.  For example, it would be bad design to require all levels
+ * of a program interface to be aware of the low-level exceptions thrown
+ * at one level of abstraction. Another example is wrapping a checked
+ * exception in an unchecked one, to communicate that failure occured
+ * while still obeying the method throws clause of a superclass.
+ *
+ * <p>A cause is assigned in one of two ways; but can only be assigned once
+ * in the lifetime of the Throwable.  There are new constructors added to
+ * several classes in the exception hierarchy that directly initialize the
+ * cause, or you can use the <code>initCause</code> method. This second
+ * method is especially useful if the superclass has not been retrofitted
+ * with new constructors:<br>
+ * <pre>
+ * try
+ *   {
+ *     lowLevelOp();
+ *   }
+ * catch (LowLevelException lle)
+ *   {
+ *     throw (HighLevelException) new HighLevelException().initCause(lle);
+ *   }
+ * </pre>
+ * Notice the cast in the above example; without it, your method would need
+ * a throws clase that declared Throwable, defeating the purpose of chainig
+ * your exceptions.
+ *
+ * <p>By convention, exception classes have two constructors: one with no
+ * arguments, and one that takes a String for a detail message.  Further,
+ * classes which are likely to be used in an exception chain also provide
+ * a constructor that takes a Throwable, with or without a detail message
+ * string.
+ *
+ * <p>Another 1.4 feature is the StackTrace, a means of reflection that
+ * allows the program to inspect the context of the exception, and which is
+ * serialized, so that remote procedure calls can correctly pass exceptions.
+ *
+ * @author Brian Jones
+ * @author John Keiser
+ * @author Mark Wielaard
+ * @author Tom Tromey
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public class Throwable implements Serializable
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -3042686055658047285L;
+
+  /**
+   * The detail message.
+   *
+   * @serial specific details about the exception, may be null
+   */
+  private final String detailMessage;
+
+  /**
+   * The cause of the throwable, including null for an unknown or non-chained
+   * cause. This may only be set once; so the field is set to
+   * <code>this</code> until initialized.
+   *
+   * @serial the cause, or null if unknown, or this if not yet set
+   * @since 1.4
+   */
+  private Throwable cause = this;
+
+  /**
+   * The stack trace, in a serialized form.
+   *
+   * @serial the elements of the stack trace; this is non-null, and has
+   *         no null entries
+   * @since 1.4
+   */
+  private StackTraceElement[] stackTrace;
+
+  /**
+   * Instantiate this Throwable with an empty message. The cause remains
+   * uninitialized.  {@link #fillInStackTrace()} will be called to set
+   * up the stack trace.
+   */
+  public Throwable()
+  {
+    this((String) null);
+  }
+
+  /**
+   * Instantiate this Throwable with the given message. The cause remains
+   * uninitialized.  {@link #fillInStackTrace()} will be called to set
+   * up the stack trace.
+   *
+   * @param message the message to associate with the Throwable
+   */
+  public Throwable(String message)
+  {
+    fillInStackTrace();
+    detailMessage = message;
+  }
+
+  /**
+   * Instantiate this Throwable with the given message and cause. Note that
+   * the message is unrelated to the message of the cause.
+   * {@link #fillInStackTrace()} will be called to set up the stack trace.
+   *
+   * @param message the message to associate with the Throwable
+   * @param cause the cause, may be null
+   * @since 1.4
+   */
+  public Throwable(String message, Throwable cause)
+  {
+    this(message);
+    this.cause = cause;
+  }
+
+  /**
+   * Instantiate this Throwable with the given cause. The message is then
+   * built as <code>cause == null ? null : cause.toString()</code>.
+   * {@link #fillInStackTrace()} will be called to set up the stack trace.
+   *
+   * @param cause the cause, may be null
+   * @since 1.4
+   */
+  public Throwable(Throwable cause)
+  {
+    this(cause == null ? null : cause.toString(), cause);
+  }
+
+  /**
+   * Get the message associated with this Throwable.
+   *
+   * @return the error message associated with this Throwable, may be null
+   */
+  public String getMessage()
+  {
+    return detailMessage;
+  }
+
+  /**
+   * Get a localized version of this Throwable's error message.
+   * This method must be overridden in a subclass of Throwable
+   * to actually produce locale-specific methods.  The Throwable
+   * implementation just returns getMessage().
+   *
+   * @return a localized version of this error message
+   * @see #getMessage()
+   * @since 1.1
+   */
+  public String getLocalizedMessage()
+  {
+    return getMessage();
+  }
+
+  /**
+   * Returns the cause of this exception, or null if the cause is not known
+   * or non-existant. This cause is initialized by the new constructors,
+   * or by calling initCause.
+   *
+   * @return the cause of this Throwable
+   * @since 1.4
+   */
+  public Throwable getCause()
+  {
+    return cause == this ? null : cause;
+  }
+
+  /**
+   * Initialize the cause of this Throwable.  This may only be called once
+   * during the object lifetime, including implicitly by chaining
+   * constructors.
+   *
+   * @param cause the cause of this Throwable, may be null
+   * @return this
+   * @throws IllegalArgumentException if cause is this (a Throwable can't be
+   *         its own cause!)
+   * @throws IllegalStateException if the cause has already been set
+   * @since 1.4
+   */
+  public Throwable initCause(Throwable cause)
+  {
+    if (cause == this)
+      throw new IllegalArgumentException();
+    if (this.cause != this)
+      throw new IllegalStateException();
+    this.cause = cause;
+    return this;
+  }
+
+  /**
+   * Get a human-readable representation of this Throwable. The detail message
+   * is retrieved by getLocalizedMessage().  Then, with a null detail
+   * message, this string is simply the object's class name; otherwise
+   * the string is <code>getClass().getName() + ": " + message</code>.
+   *
+   * @return a human-readable String represting this Throwable
+   */
+  public String toString()
+  {
+    String msg = getLocalizedMessage();
+    return getClass().getName() + (msg == null ? "" : ": " + msg);
+  }
+
+  /**
+   * Print a stack trace to the standard error stream. This stream is the
+   * current contents of <code>System.err</code>. The first line of output
+   * is the result of {@link #toString()}, and the remaining lines represent
+   * the data created by {@link #fillInStackTrace()}. While the format is
+   * unspecified, this implementation uses the suggested format, demonstrated
+   * by this example:<br>
+   * <pre>
+   * public class Junk
+   * {
+   *   public static void main(String args[])
+   *   {
+   *     try
+   *       {
+   *         a();
+   *       }
+   *     catch(HighLevelException e)
+   *       {
+   *         e.printStackTrace();
+   *       }
+   *   }
+   *   static void a() throws HighLevelException
+   *   {
+   *     try
+   *       {
+   *         b();
+   *       }
+   *     catch(MidLevelException e)
+   *       {
+   *         throw new HighLevelException(e);
+   *       }
+   *   }
+   *   static void b() throws MidLevelException
+   *   {
+   *     c();
+   *   }
+   *   static void c() throws MidLevelException
+   *   {
+   *     try
+   *       {
+   *         d();
+   *       }
+   *     catch(LowLevelException e)
+   *       {
+   *         throw new MidLevelException(e);
+   *       }
+   *   }
+   *   static void d() throws LowLevelException
+   *   {
+   *     e();
+   *   }
+   *   static void e() throws LowLevelException
+   *   {
+   *     throw new LowLevelException();
+   *   }
+   * }
+   * class HighLevelException extends Exception
+   * {
+   *   HighLevelException(Throwable cause) { super(cause); }
+   * }
+   * class MidLevelException extends Exception
+   * {
+   *   MidLevelException(Throwable cause)  { super(cause); }
+   * }
+   * class LowLevelException extends Exception
+   * {
+   * }
+   * </pre>
+   * <p>
+   * <pre>
+   *  HighLevelException: MidLevelException: LowLevelException
+   *          at Junk.a(Junk.java:13)
+   *          at Junk.main(Junk.java:4)
+   *  Caused by: MidLevelException: LowLevelException
+   *          at Junk.c(Junk.java:23)
+   *          at Junk.b(Junk.java:17)
+   *          at Junk.a(Junk.java:11)
+   *          ... 1 more
+   *  Caused by: LowLevelException
+   *          at Junk.e(Junk.java:30)
+   *          at Junk.d(Junk.java:27)
+   *          at Junk.c(Junk.java:21)
+   *          ... 3 more
+   * </pre>
+   */
+  public void printStackTrace()
+  {
+    printStackTrace(System.err);
+  }
+
+  /**
+   * Print a stack trace to the specified PrintStream. See
+   * {@link #printStackTrace()} for the sample format.
+   *
+   * @param s the PrintStream to write the trace to
+   */
+  public void printStackTrace(PrintStream s)
+  {
+    s.print(stackTraceString());
+  }
+
+  /**
+   * Prints the exception, the detailed message and the stack trace
+   * associated with this Throwable to the given <code>PrintWriter</code>.
+   * The actual output written is implemention specific. Use the result of
+   * <code>getStackTrace()</code> when more precise information is needed.
+   *
+   * <p>This implementation first prints a line with the result of this
+   * object's <code>toString()</code> method.
+   * <br>
+   * Then for all elements given by <code>getStackTrace</code> it prints
+   * a line containing three spaces, the string "at " and the result of calling
+   * the <code>toString()</code> method on the <code>StackTraceElement</code>
+   * object. If <code>getStackTrace()</code> returns an empty array it prints
+   * a line containing three spaces and the string
+   * "<<No stacktrace available>>".
+   * <br>
+   * Then if <code>getCause()</code> doesn't return null it adds a line
+   * starting with "Caused by: " and the result of calling
+   * <code>toString()</code> on the cause.
+   * <br>
+   * Then for every cause (of a cause, etc) the stacktrace is printed the
+   * same as for the top level <code>Throwable</code> except that as soon
+   * as all the remaining stack frames of the cause are the same as the
+   * the last stack frames of the throwable that the cause is wrapped in
+   * then a line starting with three spaces and the string "... X more" is
+   * printed, where X is the number of remaining stackframes.
+   *
+   * @param pw the PrintWriter to write the trace to
+   * @since 1.1
+   */
+  public void printStackTrace (PrintWriter pw)
+  {
+    pw.print(stackTraceString());
+  }
+
+  /*
+   * We use inner class to avoid a static initializer in this basic class.
+   */
+  private static class StaticData
+  {
+    static final String nl = SystemProperties.getProperty("line.separator");
+  }
+
+  // Create whole stack trace in a stringbuffer so we don't have to print
+  // it line by line. This prevents printing multiple stack traces from
+  // different threads to get mixed up when written to the same PrintWriter.
+  private String stackTraceString()
+  {
+    StringBuffer sb = new StringBuffer();
+
+    // Main stacktrace
+    StackTraceElement[] stack = getStackTrace();
+    stackTraceStringBuffer(sb, this.toString(), stack, 0);
+
+    // The cause(s)
+    Throwable cause = getCause();
+    while (cause != null)
+      {
+	// Cause start first line
+        sb.append("Caused by: ");
+
+        // Cause stacktrace
+        StackTraceElement[] parentStack = stack;
+        stack = cause.getStackTrace();
+	if (parentStack == null || parentStack.length == 0)
+	  stackTraceStringBuffer(sb, cause.toString(), stack, 0);
+	else
+	  {
+	    int equal = 0; // Count how many of the last stack frames are equal
+	    int frame = stack.length-1;
+	    int parentFrame = parentStack.length-1;
+	    while (frame > 0 && parentFrame > 0)
+	      {
+		if (stack[frame].equals(parentStack[parentFrame]))
+		  {
+		    equal++;
+		    frame--;
+		    parentFrame--;
+		  }
+		else
+		  break;
+	      }
+	    stackTraceStringBuffer(sb, cause.toString(), stack, equal);
+	  }
+        cause = cause.getCause();
+      }
+
+    return sb.toString();
+  }
+
+  // Adds to the given StringBuffer a line containing the name and
+  // all stacktrace elements minus the last equal ones.
+  private static void stackTraceStringBuffer(StringBuffer sb, String name,
+					StackTraceElement[] stack, int equal)
+  {
+    String nl = StaticData.nl;
+    // (finish) first line
+    sb.append(name);
+    sb.append(nl);
+
+    // The stacktrace
+    if (stack == null || stack.length == 0)
+      {
+	sb.append("   <<No stacktrace available>>");
+	sb.append(nl);
+      }
+    else
+      {
+	for (int i = 0; i < stack.length-equal; i++)
+	  {
+	    sb.append("   at ");
+	    sb.append(stack[i] == null ? "<<Unknown>>" : stack[i].toString());
+	    sb.append(nl);
+	  }
+	if (equal > 0)
+	  {
+	    sb.append("   ...");
+	    sb.append(equal);
+	    sb.append(" more");
+	    sb.append(nl);
+	  }
+      }
+  }
+
+  /**
+   * Fill in the stack trace with the current execution stack.
+   *
+   * @return this same throwable
+   * @see #printStackTrace()
+   */
+  public Throwable fillInStackTrace()
+  {
+    vmState = VMThrowable.fillInStackTrace(this);
+    stackTrace = null; // Should be regenerated when used.
+
+    return this;
+  }
+
+  /**
+   * Provides access to the information printed in {@link #printStackTrace()}.
+   * The array is non-null, with no null entries, although the virtual
+   * machine is allowed to skip stack frames.  If the array is not 0-length,
+   * then slot 0 holds the information on the stack frame where the Throwable
+   * was created (or at least where <code>fillInStackTrace()</code> was
+   * called).
+   *
+   * @return an array of stack trace information, as available from the VM
+   * @since 1.4
+   */
+  public StackTraceElement[] getStackTrace()
+  {
+    if (stackTrace == null)
+      if (vmState == null)
+	stackTrace = new StackTraceElement[0];
+      else 
+	{
+	  stackTrace = vmState.getStackTrace(this);
+	  vmState = null; // No longer needed
+	}
+
+    return stackTrace;
+  }
+
+  /**
+   * Change the stack trace manually. This method is designed for remote
+   * procedure calls, which intend to alter the stack trace before or after
+   * serialization according to the context of the remote call.
+   * <p>
+   * The contents of the given stacktrace is copied so changes to the
+   * original array do not change the stack trace elements of this
+   * throwable.
+   *
+   * @param stackTrace the new trace to use
+   * @throws NullPointerException if stackTrace is null or has null elements
+   * @since 1.4
+   */
+  public void setStackTrace(StackTraceElement[] stackTrace)
+  {
+    int i = stackTrace.length;
+    StackTraceElement[] st = new StackTraceElement[i];
+
+    while (--i >= 0)
+      {
+	st[i] = stackTrace[i];
+	if (st[i] == null)
+	  throw new NullPointerException("Element " + i + " null");
+      }
+
+    this.stackTrace = st;
+  }
+
+  /**
+   * VM state when fillInStackTrace was called.
+   * Used by getStackTrace() to get an array of StackTraceElements.
+   * Cleared when no longer needed.
+   */
+  private transient VMThrowable vmState;
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/TypeNotPresentException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/TypeNotPresentException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,98 @@
+/* TypeNotPresentException.java -- Thrown when a string-based type is missing
+   Copyright (C) 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.lang;
+
+/**
+ * <p>
+ * Thrown when a type is accessed using a <code>String</code>-based
+ * representation, but no definition of the supplied type is found.
+ * This is effectively an unchecked equivalent of the existing
+ * <code>ClassNotFound</code> exception.  
+ * </p>
+ * <p>
+ * It may occur due to an attempt to load a missing class, interface or
+ * annotation, or when an undefined type variable is accessed.
+ * </p>
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @see ClassNotFoundException
+ * @since 1.5
+ */
+public class TypeNotPresentException
+  extends RuntimeException
+{
+  private static final long serialVersionUID = -5101214195716534496L;
+
+  /**
+   * Constructs a <code>TypeNotPresentException</code> for
+   * the supplied type.  The specified cause <code>Throwable</code>
+   * may be used to provide additional history, with regards to the
+   * root of the problem.  It is perfectly valid for this to be null,
+   * if the cause of the problem is unknown.
+   * 
+   * @param typeName the name of the missing type.
+   * @param cause the cause of this exception, or null if the cause
+   *              is unknown.
+   */
+  public TypeNotPresentException(String typeName, Throwable cause)
+  {
+    super("type \"" + typeName + "\" not found", cause);
+    this.typeName = typeName;
+  }
+
+  /**
+   * Returns the name of the missing type.
+   *
+   * @return the missing type's name.
+   */
+  public String typeName()
+  {
+    return typeName;
+  }
+
+  /**
+   * The name of the missing type.
+   *
+   * @serial the missing type's name.
+   */
+  // Name fixed by serialization.
+  private String typeName;
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/UnknownError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/UnknownError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* UnknownError.java -- thrown when the VM cannot provide more information
+   about a catastrophic error
+   Copyright (C) 1998, 1999, 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.lang;
+
+/**
+ * An <code>UnknownError</code> is thrown when a serious but unknown
+ * problem has occurred in the Java Virtual Machine.
+ *
+ * @author Brian Jones
+ * @status updated to 1.4
+ */
+public class UnknownError extends VirtualMachineError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 2524784860676771849L;
+
+  /**
+   * Create an error without a message.
+   */
+  public UnknownError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public UnknownError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/UnsatisfiedLinkError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/UnsatisfiedLinkError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* UnsatisfiedLinkError.java -- thrown when a native method cannot be loaded
+   Copyright (C) 1998, 1999, 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.lang;
+
+/**
+ * A <code>UnsatisfiedLinkError</code> is thrown if an appropriate
+ * native language definition of a method declared <code>native</code>
+ * cannot be found by the Java Virtual Machine.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @see Runtime
+ * @status updated to 1.4
+ */
+public class UnsatisfiedLinkError extends LinkageError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -4019343241616879428L;
+
+  /**
+   * Create an error without a message.
+   */
+  public UnsatisfiedLinkError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public UnsatisfiedLinkError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/UnsupportedClassVersionError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/UnsupportedClassVersionError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* UnsupportedClassVersionError.java -- thrown when a class file version
+   exceeds the capability of the virtual machine
+   Copyright (C) 1998, 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.lang;
+
+/**
+ * An <code>UnsupportedClassVersionError</code> is thrown when the
+ * Java Virtual Machine determines it does not support the major and minor
+ * version numbers in the class file it is attempting to read.
+ *
+ * @author Brian Jones
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class UnsupportedClassVersionError extends ClassFormatError
+{
+  /**
+   * Compatible with JDK 1.2+.
+   */
+  private static final long serialVersionUID = -7123279212883497373L;
+
+  /**
+   * Create an error without a message.
+   */
+  public UnsupportedClassVersionError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public UnsupportedClassVersionError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/UnsupportedOperationException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/UnsupportedOperationException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,127 @@
+/* UnsupportedOperationException.java -- thrown when an operation is not
+   supported
+   Copyright (C) 1998, 1999, 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.lang;
+
+/**
+ * This exception is thrown by an object when an operation is
+ * requested of it that it does not support.
+ *
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.2
+ * @status updated to 1.5
+ */
+public class UnsupportedOperationException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.2+.
+   */
+  private static final long serialVersionUID = -1242599979055084673L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public UnsupportedOperationException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public UnsupportedOperationException(String s)
+  {
+    super(s);
+  }
+
+  /**
+   * <p>
+   * Constructs a <code>UnsupportedOperationException</code> using
+   * the specified error message, which should give further details
+   * as to the reason for this exception.  The specified cause
+   * <code>Throwable</code> may be used to provide additional history,
+   * with regards to the root of the problem.  It is perfectly valid
+   * for this to be null, if the cause of the problem is unknown.
+   * </p>
+   * <p>
+   * <strong>Note</strong>: the detail message from the cause is not
+   * automatically incorporated into the resulting detail message of
+   * this exception.
+   * </p>
+   * 
+   * @param message the detail message, which should give the reason for
+   *                this exception being thrown.
+   * @param cause the cause of this exception, or null if the cause
+   *              is unknown.
+   * @since 1.5
+   */
+  public UnsupportedOperationException(String message, Throwable cause)
+  {
+    super(message, cause);
+  }
+
+  /**
+   * <p>
+   * Constructs a <code>UnsupportedOperationException</code> using
+   * the specified cause <code>Throwable</code>, which may be used
+   * to provide additional history, with regards to the root of the
+   * problem.  It is perfectly valid for this to be null, if the
+   * cause of the problem is unknown.
+   * </p>
+   * <p>
+   * The detail message is automatically constructed from the detail
+   * message of the supplied causal exception.  If the cause is null,
+   * then the detail message will also be null.  Otherwise, the detail
+   * message of this exception will be that of the causal exception.
+   * This makes this constructor very useful for simply wrapping another
+   * exception.
+   * </p>
+   * 
+   * @param cause the cause of this exception, or null if the cause
+   *              is unknown.
+   * @since 1.5
+   */
+  public UnsupportedOperationException(Throwable cause)
+  {
+    super(cause);
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/VerifyError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/VerifyError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* VerifyError.java -- thrown when a class fails verification
+   Copyright (C) 1998, 1999, 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.lang;
+
+/**
+ * A <code>VerifyError</code> is thrown if there is a security problem or
+ * internal inconsistency in a class file as detected by the "verifier."
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public class VerifyError extends LinkageError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 7001962396098498785L;
+
+  /**
+   * Create an error without a message.
+   */
+  public VerifyError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public VerifyError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/VirtualMachineError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/VirtualMachineError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* VirtualMachineError.java -- thrown when the Virtual Machine has a problem
+   Copyright (C) 1998, 1999, 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.lang;
+
+/**
+ * A <code>VirtualMachineError</code> or its subclasses are thrown to
+ * indicate there is something wrong with the Java Virtual Machine or that
+ * it does not have the resources needed for it to continue execution.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public abstract class VirtualMachineError extends Error
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 4161983926571568670L;
+
+  /**
+   * Create an error without a message.
+   */
+  public VirtualMachineError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public VirtualMachineError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Void.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Void.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,68 @@
+/* Void.class - defines void.class
+   Copyright (C) 1998, 1999, 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.lang;
+
+
+/**
+ * Void is a placeholder class so that the variable <code>Void.TYPE</code>
+ * (also available as <code>void.class</code>) can be supported for
+ * reflection return types.
+ *
+ * <p>This class could be Serializable, but that is up to Sun.</p>
+ *
+ * @author Paul Fisher
+ * @author John Keiser
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public final class Void
+{
+  /**
+   * The return type <code>void</code> is represented by this
+   * <code>Class</code> object.
+   */
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('V');
+
+  /**
+   * Void is non-instantiable.
+   */
+  private Void()
+  {
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/annotation/Annotation.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/annotation/Annotation.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,136 @@
+/* Annotation.java - Base interface for all annotations
+   Copyright (C) 2004 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 java.lang.annotation;
+
+/**
+ * This is the common interface for all annotations.  Note that classes
+ * that implement this class manually are not classed as annotations, and
+ * that this interface does not define an annotation type in itself.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface Annotation
+{
+
+  /**
+   * Returns the type of this annotation.
+   *
+   * @return the class of which this annotation is an instance.
+   */
+  /* FIXME[GENERICS]: Should return Class<? extends Annotation> */
+  Class annotationType();
+
+  /**
+   * <p>
+   * Returns true if the supplied object is equivalent to this annotation.
+   * For this property to hold, the following must be true of <code>o</code>:
+   * </p>
+   * <ul>
+   * <li>The object is also an instance of the same annotation type.</li>
+   * <li>The members of the supplied annotation are equal to those of this
+   * annotation, according to the following:
+   * <ul>
+   * <li>If the members are <code>float</code>s, then, for floats
+   * <code>x</code> and <code>y</code>, 
+   * <code>Float.valueOf(x).equals(Float.valueOf(y)</code> must return
+   * true.  This differs from the usual (<code>==</code>) comparison
+   * in that <code>NaN</code> is considered equal to itself and positive
+   * and negative zero are seen as different.</li>
+   * <li>Likewise, if the members are <code>double</code>s, then, for doubles
+   * <code>x</code> and <code>y</code>, 
+   * <code>Double.valueOf(x).equals(Double.valueOf(y)</code> must return
+   * true.  This differs from the usual (<code>==</code>) comparison
+   * in that <code>NaN</code> is considered equal to itself and positive
+   * and negative zero are seen as different.</li>
+   * <li>Strings, classes, enumerations and annotations are considered
+   * equal according to the <code>equals()</code> implementation for these
+   * types.</li>
+   * <li>Arrays are considered equal according to <code>Arrays.equals()</code>
+   * </li>
+   * <li>Any remaining types are considered equal using <code>==</code>.</li>
+   * </li>
+   * </ul>
+   *
+   * @param o the object to compare with this annotation.
+   * @return true if the supplied object is an annotation with equivalent
+   *         members.
+   */
+  boolean equals(Object o);
+
+  /**
+   * <p>
+   * Returns the hash code of the annotation.  This is computed as the
+   * sum of the hash codes of the annotation's members.
+   * </p>
+   * <p>
+   * The hash code of a member of the annotation is the result of XORing
+   * the hash code of its value with the result of multiplying the hash code
+   * of its name by 127.  Formally, if the value is <code>v</code> and the
+   * name is <code>n</code>, the hash code of the member is
+   * v.hashCode() XOR (127 * String.hashCode(n)).  <code>v.hashCode()</code>
+   * is defined as follows:
+   * </p>
+   * <ul>
+   * <li>The hash code of a primitive value (i.e. <code>byte</code>,
+   * <code>char</code>, <code>double</code>, <code>float</code>,
+   * <code>int</code>, <code>long</code>, <code>short</code> and
+   * <code>boolean</code>) is the hash code obtained from its corresponding
+   * wrapper class using <code>valueOf(v).hashCode()</code>, where
+   * <code>v</code> is the primitive value.</li>
+   * <li>The hash code of an enumeration, string, class or other annotation
+   * is obtained using <code>v.hashCode()</code>.</li>
+   * <li>The hash code of an array is computed using
+   * <code>Arrays.hashCode(v)</code>.</li>
+   * </ul>
+   *
+   * @return the hash code of the annotation, computed as the sum of its
+   *         member hashcodes.
+   */
+  int hashCode();
+
+  /**
+   * Returns a textual representation of the annotation.  This is
+   * implementation-dependent, but is expected to include the classname
+   * and the names and values of each member.
+   *
+   * @return a textual representation of the annotation.
+   */
+  String toString();
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/annotation/AnnotationFormatError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/annotation/AnnotationFormatError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,105 @@
+/* AnnotationFormatError.java - Thrown when an binary annotation is malformed
+   Copyright (C) 2004, 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 java.lang.annotation;
+
+/**
+ * Thrown when an annotation found in a class file is
+ * malformed.  When the virtual machine finds a class file
+ * containing annotations, it attempts to parse them.
+ * This error is thrown if this operation fails.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class AnnotationFormatError extends Error
+{
+  private static final long serialVersionUID = -4256701562333669892L;
+
+  /**
+   * Constructs a new <code>AnnotationFormatError</code>
+   * using the specified message to give details of the error.
+   *
+   * @param message the message to use in the error output.
+   */
+  public AnnotationFormatError(String message)
+  {
+    super(message);
+  }
+
+  /**
+   * <p>
+   * Constructs a new <code>AnnotationFormatError</code>
+   * using the specified message to give details of the error.
+   * The supplied cause <code>Throwable</code> is used to
+   * provide additional history, with regards to the root
+   * of the problem.  It is perfectly valid for this to be null, if
+   * the cause is unknown.
+   * </p>
+   * <p>
+   * <strong>Note</strong>: if a cause is supplied, the error
+   * message from this cause is not automatically included in the
+   * error message given by this error.
+   * </p>
+   *
+   * @param message the message to use in the error output
+   * @param cause the cause of this error, or null if the cause
+   *              is unknown.
+   */
+  public AnnotationFormatError(String message, Throwable cause)
+  {
+    super(message, cause);
+  }
+
+  /**
+   * Constructs a new <code>AnnotationFormatError</code> using
+   * the supplied cause <code>Throwable</code> to
+   * provide additional history, with regards to the root
+   * of the problem.  It is perfectly valid for this to be null, if
+   * the cause is unknown.  If the cause is not null, the error
+   * message from this cause will also be used as the message
+   * for this error.
+   *
+   * @param cause the cause of the error.
+   */
+  public AnnotationFormatError(Throwable cause)
+  {
+    super(cause);
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/annotation/AnnotationTypeMismatchException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/annotation/AnnotationTypeMismatchException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,116 @@
+/* AnnotationTypeMismatchException.java - Thrown when annotation has changed
+   Copyright (C) 2004, 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 java.lang.annotation;
+
+import java.lang.reflect.Method;
+
+/**
+ * Thrown when accessing an element within an annotation for
+ * which the type has changed, since compilation or serialization
+ * took place.  The mismatch between the compiled or serialized
+ * type and the current type causes this exception to be thrown.
+ * 
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class AnnotationTypeMismatchException extends RuntimeException
+{
+
+  /**
+   * For compatability with Sun's JDK
+   */
+  private static final long serialVersionUID = 8125925355765570191L;
+
+  /**
+   * Constructs an <code>AnnotationTypeMismatchException</code>
+   * which is due to a mismatched type in the annotation
+   * element, <code>m</code>. The erroneous type used for the
+   * data in <code>m</code> is represented by the string,
+   * <code>type</code>.  This string is of an undefined format,
+   * and may contain the value as well as the type.
+   *
+   * @param m the element from the annotation.
+   * @param type the name of the erroneous type found in <code>m</code>.
+   */
+  public AnnotationTypeMismatchException(Method m, String type)
+  {
+    this.element = m;
+    this.foundType = type;
+  }
+
+  /**
+   * Returns the element from the annotation, for which a
+   * mismatch occurred.
+   *
+   * @return the element with the mismatched type.
+   */
+  public Method element()
+  {
+    return element;
+  }
+
+  /**
+   * Returns the erroneous type used by the element,
+   * represented as a <code>String</code>.  The format
+   * of this <code>String</code> is not explicitly specified,
+   * and may contain the value as well as the type.
+   *
+   * @return the type found in the element.
+   */
+  public String foundType()
+  {
+    return foundType;
+  }
+
+  // Names are chosen from serialization spec.
+  /**
+   * The element from the annotation.
+   *
+   * @serial the element with the mismatched type.
+   */
+  private Method element;
+
+  /**
+   * The erroneous type used by the element.
+   *
+   * @serial the type found in the element.
+   */
+  private String foundType;
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/annotation/IncompleteAnnotationException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/annotation/IncompleteAnnotationException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,106 @@
+/* IncompleteAnnotationException.java - Thrown when annotation has changed
+   Copyright (C) 2004 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 java.lang.annotation;
+
+/**
+ * Thrown when accessing an element within an annotation which
+ * was added since compilation or serialization took place, and
+ * does not have a default value.  
+ * 
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class IncompleteAnnotationException extends RuntimeException
+{
+
+  /**
+   * Constructs a new <code>IncompleteAnnotationException</code>
+   * which indicates that the element, <code>name</code>, was missing
+   * from the annotation, <code>type</code> at compile time and does
+   * not have a default value.
+   *
+   * @param type the type of annotation from which an element is missing.
+   * @param name the name of the missing element.
+   */
+  public IncompleteAnnotationException(Class type, String name)
+  {
+    this.annotationType = type;
+    this.elementName = name;
+  }
+
+  /**
+   * Returns the class representing the type of annotation
+   * from which an element was missing.
+   *
+   * @return the type of annotation.
+   */
+  public Class annotationType()
+  {
+    return annotationType;
+  }
+
+  /**
+   * Returns the name of the missing annotation element.
+   *
+   * @return the element name.
+   */
+  public String elementName()
+  {
+    return elementName;
+  }
+
+  // Names are chosen from serialization spec.
+
+  /**
+   * The class representing the type of annotation from
+   * which an element was found to be missing.
+   *
+   * @serial the type of the annotation from which an
+   *         element was missing.
+   */
+  private Class annotationType;
+
+  /**
+   * The name of the missing element.
+   *
+   * @serial the name of the missing element. 
+   */
+  private String elementName;
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/annotation/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/annotation/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.lang.annotation package.
+   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. -->
+
+<html>
+<head><title>GNU Classpath - java.lang.annotation</title></head>
+
+<body>
+<p>Classes to handle annotations.</p>
+
+</body>
+</html>

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/instrument/ClassDefinition.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/instrument/ClassDefinition.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,88 @@
+/* ClassDefinition.java -- Class that binds a class with a new class file
+   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.lang.instrument;
+
+/**
+ * This class binds a class that will be redefined with a new
+ * class file.
+ *
+ * @author Nicolas Geoffray (nicolas.geoffray at menlina.com)
+ * @see Instrumentation#redefineClasses(java.lang.instrument.ClassDefinition[])
+ * @since 1.5
+ */
+public final class ClassDefinition
+{
+
+  /* The class it's related */
+  private Class theClass;
+
+  /* The new bytecode of theClass */
+  private byte[] theClassFile;
+
+  /**
+   * @param theClass the Class that will be redefined
+   * @param theClassFile the new class file
+   * @throws NullPointerException if one of the argument is null
+   */
+  /* FIXME[GENERICS]: Signature should be (Class<?>, byte[]) */
+  public ClassDefinition(Class theClass, byte[] theClassFile)
+  {
+    if (theClass == null || theClassFile == null)
+      throw new NullPointerException();
+    this.theClass = theClass;
+    this.theClassFile = theClassFile;
+  }
+
+  /**
+   * @return the Class
+   */
+  /* FIXME[GENERICS]: Should return Class<?> */
+  public Class getDefinitionClass()
+  {
+    return theClass;
+  }
+
+  /**
+   * @return the bytes
+   */
+  public byte[] getDefinitionClassFile()
+  {
+    return theClassFile;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/instrument/ClassFileTransformer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/instrument/ClassFileTransformer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,86 @@
+/* ClassFileTransformer.java -- Implementation of this interface is used by an agent to
+   transform class files.
+   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.lang.instrument;
+
+import java.security.ProtectionDomain;
+
+/**
+ * This interface should be implemented by classes wishing to transform
+ * classes bytecode when defining or redefining classes.
+ *
+ * @author Nicolas Geoffray (nicolas.geoffray at menlina.com)
+ * @see Instrumentation
+ * @see Instrumentation#addTransformer(java.lang.instrument.ClassFileTransformer)
+ * @see Instrumentation#removeTransformer(java.lang.instrument.ClassFileTransformer)
+ * @since 1.5
+ */
+public interface ClassFileTransformer
+{
+
+  /**
+   * Implementation of this method transforms a class by redefining its
+   * bytecodes. Once a ClassFileTransformer object registers itself to the
+   * Instrumentation object, this method will be called each time a class is
+   * defined (<code>ClassLoader.defineClass</code>) or redefined
+   * (<code>Instrumentation.redefineClasses</code>)
+   * @param loader the loader of the class
+   * @param className the name of the class with packages separated with "/"
+   * @param classBeingRedefined the class being redefined if it's the case,
+   * null otherwise
+   * @param protectionDomain the protection domain of the class being defined or
+   * redefined
+   * @param classfileBuffer the input byte buffer in class file format
+   * 
+   * @return a class file buffer or null when no transformation has been performed
+   * 
+   * @throws IllegalClassFormatException if the byte buffer does not represent
+   * a well-formed class file
+   * @see Instrumentation#redefineClasses(java.lang.instrument.ClassDefinition[])
+   *
+   */
+  /* FIXME[GENERICS]: Class should be Class<?> */
+  byte[] transform(ClassLoader loader,
+                 String className,
+                 Class classBeingRedefined,
+                 ProtectionDomain protectionDomain,
+                 byte[] classfileBuffer)
+                 throws IllegalClassFormatException;
+}
+

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/instrument/IllegalClassFormatException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/instrument/IllegalClassFormatException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,70 @@
+/* IllegalClassFormatException.java -- thrown when an array of byte does
+   not represent a valid class file
+   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.lang.instrument;
+
+/**
+ * @author Nicolas Geoffray (nicolas.geoffray at menlina.com)
+ * @since 1.5
+ */
+public class IllegalClassFormatException extends Exception
+{
+
+  /**
+   * Compatible with JDK 1.5+.
+   */
+  private static final long serialVersionUID = -3841736710924794009L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public IllegalClassFormatException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public IllegalClassFormatException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/instrument/Instrumentation.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/instrument/Instrumentation.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,139 @@
+/* Instrumentation.java -- Implementation of this interface is used to
+   instrument Java bytecode.
+   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.lang.instrument;
+
+/**
+ * An Instrumentation object has transformers that will
+ * be called each time a class is defined or redefined.
+ * The object is given to a <code>premain</code> function
+ * that is called before the <code>main</code> function.
+ *
+ * @author Nicolas Geoffray (nicolas.geoffray at menlina.com)
+ * @since 1.5
+ */
+public interface Instrumentation
+{
+  
+  /**
+   * Adds a <code>ClassFileTransformer</class> object
+   * to the instrumentation. Each time a class is defined
+   * or redefined, the <code>transform</code> method of the
+   * <code>transformer</code> object is called.
+   * 
+   * @param transformer the transformer to add
+   * @throws NullPointerException if transformer is null
+   */
+  void addTransformer(ClassFileTransformer transformer);
+  
+  /**
+   * Removes the given transformer from the set of transformers
+   * this Instrumentation object has.
+   * 
+   * @param transformer the transformer to remove
+   * @return true if the transformer was found and removed, false if
+   * the transformer was not found
+   * @throws NullPointerException if transformer is null
+   */
+  boolean removeTransformer(ClassFileTransformer transformer);
+
+  /**
+   * Returns if the current JVM supports class redefinition
+   * 
+   * @return true if the current JVM supports class redefinition
+   */
+  boolean isRedefineClassesSupported();
+
+  /**
+   * Redefine classes present in the definitions array, with
+   * the corresponding class files.
+   *
+   * @param definitions an array of classes to redefine
+   * 
+   * @throws ClassNotFoundException if a class cannot be found 
+   * @throws UnmodifiableClassException if a class cannot be modified 
+   * @throws UnsupportedOperationException if the JVM does not support
+   * redefinition or the redefinition made unsupported changes
+   * @throws ClassFormatError if a class file is not valid
+   * @throws NoClassDefFoundError if a class name is not equal to the name
+   * in the class file specified
+   * @throws UnsupportedClassVersionError if the class file version numbers
+   * are unsupported
+   * @throws ClassCircularityError if circularity occured with the new
+   * classes
+   * @throws LinkageError if a linkage error occurs 
+   * @throws NullPointerException if the definitions array is null, or any
+   * of its element
+   *
+   * @see #isRedefineClassesSupported()
+   * @see #addTransformer(java.lang.instrument.ClassFileTransformer)
+   * @see ClassFileTransformer
+   */
+  void redefineClasses(ClassDefinition[] definitions)
+                     throws ClassNotFoundException,
+                            UnmodifiableClassException;
+
+
+  /**
+   * Get all the classes loaded by the JVM.
+   * 
+   * @return an array containing all the classes loaded by the JVM. The array
+   * is empty if no class is loaded.
+   */
+  Class[] getAllLoadedClasses();
+
+  /**
+   * Get all the classes loaded by a given class loader
+   * 
+   * @param loader the loader
+   * 
+   * @return an array containing all the classes loaded by the given loader.
+   * The array is empty if no class was loaded by the loader.
+   */
+  Class[] getInitiatedClasses(ClassLoader loader);
+
+  /**
+   * Get the size of an object. It contains the size of all fields.
+   * 
+   * @param objectToSize the object
+   * @return the size of the object
+   * @throws NullPointerException if objectToSize is null.
+   */
+  long getObjectSize(Object objectToSize);
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/instrument/UnmodifiableClassException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/instrument/UnmodifiableClassException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,69 @@
+/* UnmodifiableClassException.java -- thrown when attempting to redefine
+   an unmodifiable class
+   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.lang.instrument;
+
+/**
+ * @author Nicolas Geoffray (nicolas.geoffray at menlina.com)
+ * @since 1.5
+ */
+public class UnmodifiableClassException extends Exception
+{
+  /**
+   * Compatible with JDK 1.5+.
+   */
+  private static final long serialVersionUID = 1716652643585309178L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public UnmodifiableClassException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public UnmodifiableClassException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/ClassLoadingMXBean.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/ClassLoadingMXBean.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,103 @@
+/* ClassLoadingMXBean.java - Interface for a class loading bean
+   Copyright (C) 2006 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 java.lang.management;
+
+/**
+ * Provides access to information about the class loading 
+ * behaviour of the current invocation of the virtual
+ * machine.  An instance of this bean is obtained by calling
+ * {@link ManagementFactory#getClassLoadingMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface ClassLoadingMXBean
+{
+
+  /**
+   * Returns the number of classes currently loaded by
+   * the virtual machine.
+   *
+   * @return the number of loaded classes.
+   */
+  int getLoadedClassCount();
+
+  /**
+   * Returns the total number of classes loaded by the
+   * virtual machine since it was started.  This is the
+   * sum of the currently loaded classes and those that
+   * have been unloaded.
+   *
+   * @return the total number of classes that have been
+   *         loaded by the virtual machine since it started.
+   */
+  long getTotalLoadedClassCount();
+
+  /**
+   * Returns the number of classes that have been unloaded
+   * by the virtual machine since it was started.
+   *
+   * @return the number of unloaded classes.
+   */
+  long getUnloadedClassCount();
+
+  /**
+   * Returns true if the virtual machine will emit additional
+   * information when classes are loaded and unloaded.  The
+   * format of the output is left up to the virtual machine.
+   *
+   * @return true if verbose class loading output is on.
+   */
+  boolean isVerbose();
+
+  /**
+   * Turns on or off the emission of additional information
+   * when classes are loaded and unloaded.  The format of the
+   * output is left up to the virtual machine.  This method
+   * may be called by multiple threads concurrently, but there
+   * is only one global setting of verbosity that is affected.
+   *
+   * @param verbose the new setting for verbose class loading
+   *                output.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("control").
+   */
+  void setVerbose(boolean verbose);
+
+}
+

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/CompilationMXBean.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/CompilationMXBean.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* CompilationMXBean.java - Interface for a compilation bean
+   Copyright (C) 2006 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 java.lang.management;
+
+/**
+ * Provides access to information about the Just-In-Time
+ * (JIT) compiler provided by the virtual machine, if one
+ * exists.  An instance of this bean is obtainable by
+ * calling {@link ManagementFactory#getCompilationMXBean()}
+ * if a JIT is available.  Otherwise, the method returns
+ * <code>null</code>.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface CompilationMXBean
+{
+  
+  /**
+   * Returns the name of the Just-In-Time (JIT) compiler.
+   *
+   * @return the name of the JIT compiler.
+   */
+  String getName();
+
+  /**
+   * Returns true if the virtual machine's JIT compiler
+   * supports monitoring of the time spent compiling.
+   *
+   * @return true if the JIT compiler can be monitored
+   *         for time spent compiling.
+   */
+  boolean isCompilationTimeMonitoringSupported();
+
+  /**
+   * Returns the accumulated time, in milliseconds, that
+   * the JIT compiler has spent compiling Java bytecodes
+   * to native machine code.  This value represents a single
+   * time measurement for the whole virtual machine, including
+   * all multiple threads of operation.  The value is not
+   * intended as a performance measurement.
+   *
+   * @return the accumulated number of milliseconds the JIT
+   *         compiler has spent compiling.
+   * @throws UnsupportedOperationException if time monitoring
+   *                                       is not supported.
+   */
+  long getTotalCompilationTime();
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/GarbageCollectorMXBean.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/GarbageCollectorMXBean.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* GarbageCollectorMXBean.java - Interface for a garbage collector bean
+   Copyright (C) 2006 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 java.lang.management;
+
+/**
+ * Provides access to information about the garbage collectors
+ * of the virtual machine.  Garbage collectors are responsible
+ * for removing unreferenced objects from memory.  A garbage
+ * collector is a type of memory manager, so this interface
+ * is combined with that of generic memory managers.  An instance
+ * of this bean for each garbage collector is obtained by calling
+ * {@link ManagementFactory#getGarbageCollectorMXBeans()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface GarbageCollectorMXBean
+  extends MemoryManagerMXBean
+{
+
+  /**
+   * Returns the number of collections the garbage collector
+   * represented by this bean has made.  -1 is returned if the
+   * collection count is undefined.
+   *
+   * @return the number of collections made, or -1 if this is
+   *         undefined.
+   */
+  long getCollectionCount();
+
+  /**
+   * Returns the accumulated number of milliseconds this garbage
+   * collector has spent freeing the memory used by unreferenced
+   * objects.  -1 is returned if the collection time is undefined.
+   * Note that the accumulated time may not change, even when the
+   * collection count increases, if the time taken is sufficiently
+   * short; this depends on the resolution of the timer used.
+   * 
+   * @return the accumulated number of milliseconds spent collecting,
+   *         or -1 if this is undefined.
+   */
+  long getCollectionTime();
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/ManagementFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/ManagementFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,331 @@
+/* ManagementFactory.java - Factory for obtaining system beans.
+   Copyright (C) 2006 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 java.lang.management;
+
+import gnu.classpath.SystemProperties;
+
+import gnu.java.lang.management.ClassLoadingMXBeanImpl;
+import gnu.java.lang.management.CompilationMXBeanImpl;
+import gnu.java.lang.management.GarbageCollectorMXBeanImpl;
+import gnu.java.lang.management.OperatingSystemMXBeanImpl;
+import gnu.java.lang.management.MemoryMXBeanImpl;
+import gnu.java.lang.management.MemoryManagerMXBeanImpl;
+import gnu.java.lang.management.MemoryPoolMXBeanImpl;
+import gnu.java.lang.management.RuntimeMXBeanImpl;
+import gnu.java.lang.management.ThreadMXBeanImpl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.NotCompliantMBeanException;
+
+/**
+ * <p>
+ * Provides access to the system's management beans via a series
+ * of static methods.  
+ * </p>
+ * <p>
+ * An instance of a system management bean can be obtained by
+ * using one of the following methods:
+ * </p>
+ * <ol>
+ * <li>Calling the appropriate static method of this factory.
+ * </li>
+ * </ol>
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class ManagementFactory
+{
+
+  /**
+   * The operating system management bean.
+   */
+  private static OperatingSystemMXBean osBean;
+
+  /**
+   * The runtime management bean.
+   */
+  private static RuntimeMXBean runtimeBean;
+
+  /**
+   * The class loading management bean.
+   */
+  private static ClassLoadingMXBean classLoadingBean;
+
+  /**
+   * The thread bean.
+   */
+  private static ThreadMXBean threadBean;
+
+  /**
+   * The memory bean.
+   */
+  private static MemoryMXBean memoryBean;
+
+  /**
+   * The compilation bean (may remain null).
+   */
+  private static CompilationMXBean compilationBean;
+
+  /**
+   * Private constructor to prevent instance creation.
+   */
+  private ManagementFactory() {}
+
+  /**
+   * Returns the operating system management bean for the
+   * operating system on which the virtual machine is running.
+   *
+   * @return an instance of {@link OperatingSystemMXBean} for
+   *         the underlying operating system.
+   */
+  public static OperatingSystemMXBean getOperatingSystemMXBean()
+  {
+    if (osBean == null)
+      try 
+	{
+	  osBean = new OperatingSystemMXBeanImpl();
+	}
+      catch (NotCompliantMBeanException e)
+	{
+	  throw new InternalError("The GNU implementation of the " +
+				  "operating system bean is not a " +
+				  "compliant management bean.");
+	}
+    return osBean;
+  }
+
+  /**
+   * Returns the runtime management bean for the
+   * running virtual machine.
+   *
+   * @return an instance of {@link RuntimeMXBean} for
+   *         this virtual machine.
+   */
+  public static RuntimeMXBean getRuntimeMXBean()
+  {
+    if (runtimeBean == null)
+      try
+	{
+	  runtimeBean = new RuntimeMXBeanImpl();
+	}
+      catch (NotCompliantMBeanException e)
+	{
+	  throw new InternalError("The GNU implementation of the " +
+				  "runtime bean is not a compliant " +
+				  "management bean.");
+	}
+    return runtimeBean;
+  }
+
+  /**
+   * Returns the class loading management bean for the
+   * running virtual machine.
+   *
+   * @return an instance of {@link ClassLoadingMXBean} for
+   *         this virtual machine.
+   */
+  public static ClassLoadingMXBean getClassLoadingMXBean()
+  {
+    if (classLoadingBean == null)
+      try
+	{
+	  classLoadingBean = new ClassLoadingMXBeanImpl();
+	}
+      catch (NotCompliantMBeanException e)
+	{
+	  throw new InternalError("The GNU implementation of the " +
+				  "class loading bean is not a " +
+				  "compliant management bean.");
+	}
+    return classLoadingBean;
+  }
+
+  /**
+   * Returns the thread management bean for the running
+   * virtual machine.
+   *
+   * @return an instance of {@link ThreadMXBean} for
+   *         this virtual machine.
+   */
+  public static ThreadMXBean getThreadMXBean()
+  {
+    if (threadBean == null)
+      try
+	{
+	  threadBean = new ThreadMXBeanImpl();
+	}
+      catch (NotCompliantMBeanException e)
+	{
+	  throw new InternalError("The GNU implementation of the " +
+				  "thread bean is not a compliant " +
+				  "management bean.");
+	}
+    return threadBean;
+  }
+
+  /**
+   * Returns the memory management bean for the running
+   * virtual machine.
+   *
+   * @return an instance of {@link MemoryMXBean} for
+   *         this virtual machine.
+   */
+  public static MemoryMXBean getMemoryMXBean()
+  {
+    if (memoryBean == null)
+      try
+	{
+	  memoryBean = new MemoryMXBeanImpl();
+	}
+      catch (NotCompliantMBeanException e)
+	{
+	  throw new InternalError("The GNU implementation of the " +
+				  "memory bean is not a compliant " +
+				  "management bean.");
+	}
+    return memoryBean;
+  }
+
+  /**
+   * Returns the compilation bean for the running
+   * virtual machine, if supported.  Otherwise,
+   * it returns <code>null</code>.
+   *
+   * @return an instance of {@link CompilationMXBean} for
+   *         this virtual machine, or <code>null</code>
+   *         if the virtual machine doesn't include
+   *         a Just-In-Time (JIT) compiler.
+   */
+  public static CompilationMXBean getCompilationMXBean()
+  {
+    if (compilationBean == null &&
+	SystemProperties.getProperty("gnu.java.compiler.name") != null)
+      try
+	{
+	  compilationBean = new CompilationMXBeanImpl();
+	}
+      catch (NotCompliantMBeanException e)
+	{
+	  throw new InternalError("The GNU implementation of the " +
+				  "compilation bean is not a compliant " +
+				  "management bean.");
+	}
+    return compilationBean;
+  }
+
+  /**
+   * Returns the memory pool beans for the running
+   * virtual machine.  These may change during the course
+   * of execution.
+   *
+   * @return a list of memory pool beans, one for each pool.
+   */
+  public static List getMemoryPoolMXBeans()
+  {
+    List poolBeans = new ArrayList();
+    String[] names = VMManagementFactory.getMemoryPoolNames();
+    for (int a = 0; a < names.length; ++a)
+      try
+	{
+	  poolBeans.add(new MemoryPoolMXBeanImpl(names[a]));
+	}
+      catch (NotCompliantMBeanException e)
+	{
+	  throw new InternalError("The GNU implementation of the " +
+				  "memory pool bean, " + a + ", is " +
+				  "not a compliant management bean.");
+	}
+    return poolBeans;
+  }
+
+  /**
+   * Returns the memory manager beans for the running
+   * virtual machine.  These may change during the course
+   * of execution.
+   *
+   * @return a list of memory manager beans, one for each manager.
+   */
+  public static List getMemoryManagerMXBeans()
+  {
+    List managerBeans = new ArrayList();
+    String[] names = VMManagementFactory.getMemoryManagerNames();
+    for (int a = 0; a < names.length; ++a)
+      try
+	{
+	  managerBeans.add(new MemoryManagerMXBeanImpl(names[a]));
+	}
+      catch (NotCompliantMBeanException e)
+	{
+	  throw new InternalError("The GNU implementation of the " +
+				  "memory manager bean, " + a + ", is " +
+				  "not a compliant management bean.");
+	}
+    managerBeans.addAll(getGarbageCollectorMXBeans());
+    return managerBeans;
+  }
+
+  /**
+   * Returns the garbage collector beans for the running
+   * virtual machine.  These may change during the course
+   * of execution.
+   *
+   * @return a list of garbage collector beans, one for each pool.
+   */
+  public static List getGarbageCollectorMXBeans()
+  {
+    List gcBeans = new ArrayList();
+    String[] names = VMManagementFactory.getGarbageCollectorNames();
+    for (int a = 0; a < names.length; ++a)
+      try
+	{
+	  gcBeans.add(new GarbageCollectorMXBeanImpl(names[a]));
+	}
+      catch (NotCompliantMBeanException e)
+	{
+	  throw new InternalError("The GNU implementation of the " +
+				  "garbage collector bean, " + a + 
+				  ", is not a compliant management " +
+				  "bean.");
+	}
+    return gcBeans;
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/ManagementPermission.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/ManagementPermission.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,132 @@
+/* ManagementPermission.java - Permissions for system management.
+   Copyright (C) 2006 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 java.lang.management;
+
+import java.security.BasicPermission;
+
+/**
+ * <p>
+ * Represents the permission to view or modify the data
+ * which forms part of the system management interfaces.
+ * Calls to methods of the system management beans,
+ * provided by the {@link ManagementFactory}, may perform
+ * checks against the current {@link java.lang.SecurityManager}
+ * (if any) before allowing the operation to proceed.
+ * Instances of this object are supplied to the
+ * {@link java.lang.SecurityManager} in order to perform
+ * these checks.  It is not normal for instances of this
+ * class to be created outside the use of the
+ * {@link java.lang.SecurityManager}.
+ * </p>
+ * <p>
+ * This object can represent two types of management
+ * permission:
+ * </p>
+ * <ul>
+ * <li><strong>monitor</strong> — this allows access
+ * to information such as the arguments supplied to the
+ * virtual machine, the currently loaded classes and the
+ * stack traces of running threads.  Malicious code may
+ * use this to obtain information about the system and
+ * exploit any vulnerabilities found.</li>
+ * <li><strong>control</strong> — this allows the
+ * information stored by the management beans to be altered.
+ * For example, additional debugging information (such
+ * as class loading traces) may be turned on or memory
+ * usage limits changed.  Malicious code could use
+ * this to alter the behaviour of the system.</li>
+ * </ul>
+ * 
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public final class ManagementPermission
+  extends BasicPermission
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = 1897496590799378737L;
+
+  /**
+   * Constructs a new <code>ManagementPermission</code>
+   * for one of the two permission targets, "monitor"
+   * and "control".
+   *
+   * @param name the name of the permission this instance
+   *             should represent; either "monitor" or
+   *             "control".
+   * @throws IllegalArgumentException if the name is not
+   *                                  either "monitor"
+   *                                  or "control".
+   */
+  public ManagementPermission(String name)
+  {
+    super(name);
+    if (!(name.equals("monitor") || name.equals("control")))
+      throw new IllegalArgumentException("Invalid permission.");
+  }
+
+  /**
+   * Constructs a new <code>ManagementPermission</code>
+   * for one of the two permission targets, "monitor"
+   * and "control".  Actions are not supported, so
+   * this value should be either <code>null</code>
+   * or the empty string.
+   *
+   * @param name the name of the permission this instance
+   *             should represent; either "monitor" or
+   *             "control".
+   * @param actions either <code>null</code> or the
+   *                empty string.
+   * @throws IllegalArgumentException if the name is not
+   *                                  either "monitor"
+   *                                  or "control", or
+   *                                  a value for actions
+   *                                  is specified.
+   */
+  public ManagementPermission(String name, String actions)
+  {
+    this(name);
+    if (!(actions == null || actions.equals("")))
+      throw new IllegalArgumentException("Invalid actions.");
+  }
+  
+}
+

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/MemoryMXBean.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/MemoryMXBean.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,172 @@
+/* MemoryMXBean.java - Interface for a memory bean
+   Copyright (C) 2006 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 java.lang.management;
+
+/**
+ * <p>
+ * Provides access to information about the memory used 
+ * by the virtual machine.  An instance of this bean is
+ * obtained by calling
+ * {@link ManagementFactory#getMemoryMXBean()}.
+ * </p>
+ * <p>
+ * The Java virtual machine uses two types of memory:
+ * heap memory and non-heap memory.  The heap is the
+ * storage location for class and array instances, and is
+ * thus the main source of memory associated with running
+ * Java programs.  The heap is created when the virtual
+ * machine is started, and is periodically scanned by the
+ * garbage collector(s), in order to reclaim memory which
+ * is no longer used (e.g. because an object reference has
+ * gone out of scope).
+ * </p>
+ * <p>
+ * Non-heap memory is used by the virtual machine in order to
+ * perform its duties.  Thus, it mainly acts as the storage
+ * location for structures created as a result of parsing Java
+ * bytecode, such as the constant pool and constructor/method
+ * declarations.  When a Just-In-Time (JIT) compiler is in
+ * operation, this will use non-heap memory to store compiled
+ * bytecode.
+ * </p>
+ * <p>
+ * Both types of memory may be non-contiguous.  During the
+ * lifetime of the virtual machine, the size of both may
+ * either change (either expanding or contracting) or stay
+ * the same.
+ * </p>
+ * <h2>Notifications</h2>
+ * <p>
+ * Implementations of this interface also conform to the
+ * {@link javax.management.NotificationEmitter} interface,
+ * and supply two notifications reflecting memory usage.
+ * These notifications occur when a usage threshold is
+ * exceeded; for more details of these, see the documentation
+ * of {@link MemoryPoolMXBean}.  If threshold monitoring
+ * is supported, then a notification will be emitted each time
+ * the threshold is crossed.  Another notification will not
+ * be emitted unless the usage level has dropped below the
+ * threshold again in the meantime.
+ * </p>
+ * <p>
+ * The emitted notifications are instances of
+ * {@link javax.management.Notification}, with a type of
+ * either
+ * {@link java.lang.management.MemoryNotificationInfo#MEMORY_THRESHOLD_EXCEEDED}
+ * or
+ * {@link java.lang.management.MemoryNotificationInfo#MEMORY_COLLECTION_THRESHOLD_EXCEEDED}
+ * (depending on whether the notification refers to the general
+ * usage threshold or the garbage collection threshold) and an instance
+ * of {@link java.lang.management.MemoryNotificationInfo} contained
+ * in the user data section.  This is wrapped inside an instance
+ * of {@link javax.management.openmbean.CompositeData}, as explained
+ * in the documentation for
+ * {@link java.lang.management.MemoryNotificationInfo}.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface MemoryMXBean
+{
+  
+  /**
+   * Instigates a garbage collection cycle.  The virtual
+   * machine's garbage collector should make the best
+   * attempt it can at reclaiming unused memory.  This
+   * is equivalent to invoking {@link java.lang.System.gc()}.
+   *
+   * @see java.lang.System#gc()
+   */
+  void gc();
+
+  /**
+   * Returns a {@link MemoryUsage} object representing the
+   * current state of the heap.  This incorporates various
+   * statistics on both the initial and current memory
+   * allocations used by the heap.
+   *
+   * @return a {@link MemoryUsage} object for the heap.
+   */
+  MemoryUsage getHeapMemoryUsage();
+
+  /**
+   * Returns a {@link MemoryUsage} object representing the
+   * current state of non-heap memory.  This incorporates
+   * various statistics on both the initial and current
+   * memory allocations used by non-heap memory..
+   *
+   * @return a {@link MemoryUsage} object for non-heap
+   *         memory.
+   */
+  MemoryUsage getNonHeapMemoryUsage();
+  
+  /**
+   * Returns the number of objects which are waiting to
+   * be garbage collected (finalized).  An object is
+   * finalized when the garbage collector determines that
+   * there are no more references to that object are in
+   * use.
+   *
+   * @return the number of objects awaiting finalization.
+   */
+  int getObjectPendingFinalizationCount();
+
+  /**
+   * Returns true if the virtual machine will emit additional
+   * information when memory is allocated and deallocated.  The
+   * format of the output is left up to the virtual machine.
+   *
+   * @return true if verbose memory output is on.
+   */
+  boolean isVerbose();
+
+  /**
+   * Turns on or off the emission of additional information
+   * when memory is allocated and deallocated.  The format of the
+   * output is left up to the virtual machine.  This method
+   * may be called by multiple threads concurrently, but there
+   * is only one global setting of verbosity that is affected.
+   *
+   * @param verbose the new setting for verbose memory output.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("control").
+   */
+  void setVerbose(boolean verbose);
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/MemoryManagerMXBean.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/MemoryManagerMXBean.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,77 @@
+/* MemoryManagerMXBean.java - Interface for a memory manager bean
+   Copyright (C) 2006 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 java.lang.management;
+
+/**
+ * Provides access to information about the memory managers
+ * of the virtual machine.  An instance of this bean for each
+ * memory manager is obtained by calling
+ * {@link ManagementFactory#getMemoryManagerMXBeans()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface MemoryManagerMXBean
+{
+
+  /** 
+   * Returns an array containing the names of the memory pools
+   * this memory manager manages.
+   * 
+   * @return an array containing the name of each memory pool
+   *         this manager is responsible for.
+   */
+  String[] getMemoryPoolNames();
+
+  /**
+   * Returns the name of the memory manager.
+   *
+   * @return the memory manager name.
+   */
+  String getName();
+
+  /**
+   * Returns true if this memory manager is still valid.  A memory
+   * manager becomes invalid when it is removed by the virtual machine
+   * and no longer used.
+   *
+   * @return true if this memory manager is valid.
+   */
+  boolean isValid();
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/MemoryNotificationInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/MemoryNotificationInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,215 @@
+/* MemoryNotificationInfo.java - Emitted memory notification info.
+   Copyright (C) 2006 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 java.lang.management;
+
+import gnu.java.lang.management.MemoryMXBeanImpl;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.SimpleType;
+
+/**
+ * <p>
+ * Represents the content of a notification emitted by the
+ * {@link MemoryMXBean}.  Such notifications are emitted when
+ * one of the memory pools exceeds its usage or collection
+ * usage threshold.  This object contains the following information,
+ * representing the state of the pool at the time of the
+ * notification:
+ * </p>
+ * <ul>
+ * <li>The name of the pool.</li>
+ * <li>The memory usage of the pool at the time of notification.</li>
+ * <li>The number of times the pool has exceeded this particular
+ * threshold in the past.</li>
+ * </ul>
+ * <p>
+ * Two types of notification are emitted by the {@link MemoryMXBean}:
+ * one for exceeding the usage threshold and one for exceeding the
+ * collection usage threshold.  The value returned by {@link #getCount()}
+ * is dependent on this type; if the threshold exceeded is the usage
+ * threshold, then the usage threshold count is returned.  If, instead,
+ * the collection usage threshold is exceeded, then the collection usage
+ * threshold count is returned.
+ * </p>
+ * <p>
+ * This data is held in the user data part of the notification (returned
+ * by {@link javax.management.Notification#getUserData()}) encapsulated in
+ * a {@link javax.management.openmbean.CompositeData} object.  The
+ * {@link #from(javax.management.openmbean.CompositeData)} method may be
+ * used to unwrap the value and obtain an instance of this class.
+ * </p>
+ * 
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class MemoryNotificationInfo
+{
+
+  /**
+   * The type of notification emitted when the usage threshold is exceeded.
+   * After a notification is emitted, the usage level must drop below the
+   * threshold again before another notification is emitted.  The value is
+   * <code>java.management.memory.threshold.exceeded</code>.
+   */
+  public static final String MEMORY_THRESHOLD_EXCEEDED = 
+    "java.management.memory.threshold.exceeded";
+
+  /**
+   * The type of notification emitted when the collection usage threshold
+   * is exceeded, following a garbage collection cycle.  The value is
+   * <code>java.management.memory.collection.threshold.exceeded</code>.
+   */
+  public static final String MEMORY_COLLECTION_THRESHOLD_EXCEEDED =
+    "java.management.memory.collection.threshold.exceeded";
+
+  /**
+   * The name of the memory pool which exceeded the threshold.
+   */
+  private String poolName;
+
+  /**
+   * The usage level of the memory pool at the time of notification.
+   */
+  private MemoryUsage usage;
+
+  /**
+   * The number of times the threshold has been crossed.
+   */
+  private long count;
+
+  /**
+   * Constructs a new {@link MemoryNotificationInfo} object using the
+   * specified pool name, usage level and threshold crossing count.
+   *
+   * @param poolName the name of the pool which has exceeded a threshold.
+   * @param usage the usage level of the pool at the time of notification.
+   * @param count the number of times the threshold has been crossed.
+   */
+  public MemoryNotificationInfo(String poolName, MemoryUsage usage, long count)
+  {
+    this.poolName = poolName;
+    this.usage = usage;
+    this.count = count;
+  }
+
+  /**
+   * <p>
+   * Returns a {@link MemoryNotificationInfo} instance using the values
+   * given in the supplied
+   * {@link javax.management.openmbean.CompositeData} object.
+   * The composite data instance should contain the following
+   * attributes with the specified types:
+   * </p>
+   * <table>
+   * <th><td>Name</td><td>Type</td></th>
+   * <tr><td>poolName</td><td>java.lang.String</td></tr>
+   * <tr><td>usage</td><td>javax.management.openmbean.CompositeData
+   * </td></tr>
+   * <tr><td>count</td><td>java.lang.Long</td></tr>
+   * </table>
+   * <p>
+   * The usage level is further described as:
+   * </p>
+   * <table>
+   * <th><td>Name</td><td>Type</td></th>
+   * <tr><td>init</td><td>java.lang.Long</td></tr>
+   * <tr><td>used</td><td>java.lang.Long</td></tr>
+   * <tr><td>committed</td><td>java.lang.Long</td></tr>
+   * <tr><td>max</td><td>java.lang.Long</td></tr>
+   * </table>
+   * 
+   * @param data the composite data structure to take values from.
+   * @return a new instance containing the values from the 
+   *         composite data structure, or <code>null</code>
+   *         if the data structure was also <code>null</code>.
+   * @throws IllegalArgumentException if the composite data structure
+   *                                  does not match the structure
+   *                                  outlined above.
+   */
+  public static MemoryNotificationInfo from(CompositeData data)
+  {
+    if (data == null)
+      return null;
+    CompositeType type = data.getCompositeType();
+    ThreadInfo.checkAttribute(type, "poolName", SimpleType.STRING);
+    ThreadInfo.checkAttribute(type, "usage", MemoryMXBeanImpl.usageType);
+    ThreadInfo.checkAttribute(type, "count", SimpleType.LONG);
+    MemoryUsage usage = MemoryUsage.from((CompositeData) data.get("usage"));
+    return new MemoryNotificationInfo(((String) data.get("poolName")),
+				      usage,
+				      ((Long) data.get("count")).longValue());
+  }
+
+  /**
+   * Returns the number of times the memory pool has crossed the usage
+   * threshold, as of the time of notification.  If this is the notification
+   * represented by the type {@link #MEMORY_THRESHOLD_EXCEEDED}, then the
+   * count is the usage threshold count.  If this is the notification
+   * represented by the type {@link #MEMORY_COLLECTION_THRESHOLD_EXCEEDED},
+   * then the count is the collection usage threshold count.
+   *
+   * @return the number of times the appropriate threshold has been crossed.
+   */
+  public long getCount()
+  {
+    return count;
+  }
+
+  /**
+   * Returns the name of the pool which has crossed a threshold.
+   *
+   * @return the name of the pool.
+   */
+  public String getPoolName()
+  {
+    return poolName;
+  }
+
+  /**
+   * Returns the usage levels at the time of notification.
+   *
+   * @return the usage levels.
+   */
+  public MemoryUsage getUsage()
+  {
+    return usage;
+  }
+
+}
+

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/MemoryPoolMXBean.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/MemoryPoolMXBean.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,318 @@
+/* MemoryPoolMXBean.java - Interface for a memory pool bean
+   Copyright (C) 2006 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 java.lang.management;
+
+/**
+ * <p>
+ * Provides access to information about one of the memory
+ * resources or pools used by the virtual machine.  Instances
+ * of this bean are obtained by calling
+ * {@link ManagementFactory#getMemoryPoolMXBeans()}.  One
+ * bean is returned for each memory pool provided.
+ * </p>
+ * <p>
+ * The memory pool bean allows the usage of the pool to be
+ * monitored.  The bean can provide statistics on the current
+ * and peak usage of the pool, and on the threshold levels the
+ * pool uses.
+ * </p>
+ * <p>
+ * {@link getUsage()} returns an approximation of the current
+ * usage of the pool.  Calls to this method are expected to be
+ * generally quick to perform; if the call is expensive, the
+ * documentation of the bean should specify so.  For memory
+ * pool beans that represent the memory used by garbage
+ * collectors, the usage level includes both referenced and
+ * unreferenced objects.
+ * </p>
+ * <p>
+ * {@link getPeakUsage()} and {@link resetPeakUsage()} enable
+ * the retrieval of the peak usage level and setting it to the
+ * current usage level, respectively.  Initially, the peak usage
+ * level is relative to the start of the virtual machine.
+ * </p>
+ * <p>
+ * Memory pools may also include optional support for usage thresholds.
+ * The usage threshold is a particular level of memory usage.  When this
+ * value is crossed (the current memory usage becomes equal to or greater
+ * than this threshold level), the usage threshold count is increased.
+ * This feature is designed for monitoring the trend in memory usage.
+ * Support for a collection usage threshold is also provided, for
+ * particular garbage collectors.  This is used to monitor the amount
+ * of memory left uncollected after a garbage collection cycle.  There
+ * is no need to make special garbage collection runs to support this;
+ * the level following collection just needs to be monitored.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface MemoryPoolMXBean
+{
+
+  /**
+   * Returns memory usage statistics after a best-effort attempt
+   * has been made to remove unused objects from the pool.  This
+   * method is designed for use by the pools of garbage collectors,
+   * in order to monitor the amount of memory used after collections.
+   * It will return <code>null</code> if such functionality is
+   * unsupported by the memory pool represented by this bean.
+   *
+   * @return the memory usage of the memory pool after the most
+   *         recent garbage collection cycle, or <code>null</code>
+   *         if this operation is not supported.
+   */
+  MemoryUsage getCollectionUsage();
+
+  /**
+   * Returns the collection usage threshold level in bytes.  This
+   * value is initially zero.
+   *
+   * @return the collection usage threshold in bytes.
+   * @throws UnsupportedOperationException if the collection usage
+   *                                       threshold is not supported.
+   * @see #getCollectionUsageThresholdCount()
+   * @see #isCollectionUsageThresholdExceeded()
+   * @see #isCollectionUsageThresholdSupported()
+   * @see #setCollectionUsageThreshold(long)
+   */
+  long getCollectionUsageThreshold();
+
+  /**
+   * Returns the number of times the usage level has matched or
+   * exceeded the collection usage threshold.
+   *
+   * @return the number of times the usage level has matched
+   *         or exceeded the collection usage threshold.
+   * @throws UnsupportedOperationException if the collection usage
+   *                                       threshold is not supported.
+   * @see #getCollectionUsageThreshold()
+   * @see #isCollectionUsageThresholdExceeded()
+   * @see #isCollectionUsageThresholdSupported()
+   * @see #setCollectionUsageThreshold(long)
+   */
+  long getCollectionUsageThresholdCount();
+
+  /**
+   * Returns the names of the memory managers associated with this
+   * pool.  Each pool has at least one memory manager.
+   *
+   * @return an array containing the name of each memory manager
+   *         responsible for this pool.
+   */
+  String[] getMemoryManagerNames();
+
+  /**
+   * Returns the name of the memory pool.
+   *
+   * @return the memory pool name.
+   */
+  String getName();
+
+  /**
+   * Returns memory usage statistics for the peak memory usage
+   * of the pool.  The peak is the maximum memory usage occurring
+   * since the virtual machine was started or since the peak
+   * was reset by {@link #resetPeakUsage()}.  The return value
+   * may be <code>null</code> if this pool is no longer valid.
+   *
+   * @return the memory usage of the memory pool at its peak,
+   *         or <code>null</code> if this pool is no longer valid.
+   */
+  MemoryUsage getPeakUsage();
+
+  /**
+   * Returns the type of memory used by this pool.  This can be
+   * either heap or non-heap memory.
+   *
+   * @return the type of this pool.
+   */
+  String getType();
+
+  /**
+   * Returns memory usage statistics for the current memory usage
+   * of the pool.  The return value may be <code>null</code> if
+   * this pool is no longer valid.  Obtaining these values is
+   * expected to be a relatively quick operation; if this will
+   * instead be an expensive operation to perform, the documentation
+   * of the implementating bean should specify that this is the
+   * case.  The values are intended to be an estimate for monitoring
+   * purposes.
+   *
+   * @return the memory usage of the memory pool at present,
+   *         or <code>null</code> if this pool is no longer valid.
+   */
+  MemoryUsage getUsage();
+
+  /**
+   * Returns the usage threshold level in bytes.  This
+   * value is initially defined by the virtual machine.
+   *
+   * @return the usage threshold in bytes.
+   * @throws UnsupportedOperationException if the usage threshold
+   *                                       is not supported.
+   * @see #getUsageThresholdCount()
+   * @see #isUsageThresholdExceeded()
+   * @see #isUsageThresholdSupported()
+   * @see #setUsageThreshold(long)
+   */
+  long getUsageThreshold();
+
+  /**
+   * Returns the number of times the usage level has matched or
+   * exceeded the usage threshold.
+   *
+   * @return the number of times the usage level has matched
+   *         or exceeded the usage threshold.
+   * @throws UnsupportedOperationException if the usage threshold
+   *                                       is not supported.
+   * @see #getUsageThreshold()
+   * @see #isUsageThresholdExceeded()
+   * @see #isUsageThresholdSupported()
+   * @see #setUsageThreshold(long)
+   */
+  long getUsageThresholdCount();
+
+  /**
+   * Returns true if the collection usage level is equal to 
+   * or greater than the collection usage threshold.
+   *
+   * @return true if the collection usage threshold has been
+   *         matched or exceeded.
+   * @throws UnsupportedOperationException if the collection usage
+   *                                       threshold is not supported.
+   * @see #getCollectionUsageThreshold()
+   * @see #getCollectionUsageThresholdCount()
+   * @see #isCollectionUsageThresholdSupported()
+   * @see #setCollectionUsageThreshold(long)
+   */
+  boolean isCollectionUsageThresholdExceeded();
+
+  /**
+   * Returns true if this memory pool supports a collection usage
+   * level threshold.
+   *
+   * @return true if a collection usage level threshold is supported.
+   * @see #getCollectionUsageThreshold()
+   * @see #getCollectionUsageThresholdCount()
+   * @see #isCollectionUsageThresholdExceeded()
+   * @see #setCollectionUsageThreshold(long)
+   */
+  boolean isCollectionUsageThresholdSupported();
+
+  /**
+   * Returns true if the usage level is equal to 
+   * or greater than the usage threshold.
+   *
+   * @return true if the usage threshold has been
+   *         matched or exceeded.
+   * @throws UnsupportedOperationException if the usage threshold
+   *                                       is not supported.
+   * @see #getUsageThreshold()
+   * @see #getUsageThresholdCount()
+   * @see #isUsageThresholdSupported()
+   * @see #setUsageThreshold(long)
+   */
+  boolean isUsageThresholdExceeded();
+
+  /**
+   * Returns true if this memory pool supports a usage level threshold.
+   *
+   * @return true if a usage level threshold is supported.
+   * @see #getUsageThreshold()
+   * @see #getUsageThresholdCount()
+   * @see #isUsageThresholdExceeded()
+   * @see #setUsageThreshold(long)
+   */
+  boolean isUsageThresholdSupported();
+  
+  /**
+   * Returns true if this memory pool is still valid.  A memory pool
+   * becomes invalid when it is removed by the virtual machine and
+   * no longer used.
+   *
+   * @return true if this memory pool is valid.
+   */
+  boolean isValid();
+
+  /**
+   * Resets the peak memory usage level to the current memory usage
+   * level.
+   *
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("control").
+   */
+  void resetPeakUsage();
+
+  /**
+   * Sets the collection threshold usage level to the given value.
+   * A value of zero disables the collection threshold.
+   *
+   * @param threshold the new threshold level.
+   * @throws IllegalArgumentException if the threshold hold level
+   *                                  is negative.
+   * @throws UnsupportedOperationException if the collection usage
+   *                                       threshold is not supported.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("control").
+   * @see #getCollectionUsageThreshold()
+   * @see #getCollectionUsageThresholdCount()
+   * @see #isCollectionUsageThresholdExceeded()
+   * @see #isCollectionUsageThresholdSupported()
+   */
+  void setCollectionUsageThreshold(long threshold);
+
+  /**
+   * Sets the threshold usage level to the given value.  A value of
+   * zero disables the threshold.
+   *
+   * @param threshold the new threshold level.
+   * @throws IllegalArgumentException if the threshold hold level
+   *                                  is negative.
+   * @throws UnsupportedOperationException if the usage threshold
+   *                                       is not supported.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("control").
+   * @see #getUsageThreshold()
+   * @see #getUsageThresholdCount()
+   * @see #isUsageThresholdExceeded()
+   * @see #isUsageThresholdSupported()
+   */
+  void setUsageThreshold(long threshold);
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/MemoryUsage.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/MemoryUsage.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,265 @@
+/* MemoryUsage.java - Information on the usage of a memory pool.
+   Copyright (C) 2006 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 java.lang.management;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.SimpleType;
+/**
+ * <p>
+ * Retains information on the usage of a particular memory
+ * pool, or heap/non-heap memory as a whole.  Memory usage
+ * is represented by four values (all in bytes):
+ * </p>
+ * <ul>
+ * <li><strong>Initial Level</strong>: This is the initial
+ * amount of memory allocated for the pool by the operating
+ * system.  This value may be undefined.</li>
+ * <li><strong>Used Level</strong>: This is the amount of
+ * memory currently in use.</li>
+ * <li><strong>Committed Level</strong>: This is the current
+ * amount of memory allocated for the pool by the operating
+ * system.  This value will always be equal to or greater than
+ * the current amount of memory in use.  It may drop below
+ * the initial amount, if the virtual machine judges this to
+ * be practical.</li>
+ * <li><strong>Maximum Level</strong>: This is the maximum
+ * amount of memory that may be allocated for the pool by
+ * the operating system.  Like the initial amount, it may
+ * be undefined.  If it is defined, it will be greater than
+ * or equal to the used and committed amounts and may change
+ * over time.  It is not guaranteed that the maximum amount
+ * of memory may actually be allocated to the pool.  For
+ * example, a request for an amount of memory greater than
+ * the current committed level, but less than the maximum,
+ * may still fail due to resources at the operating system
+ * level not being sufficient to fulfill the demand.</li>
+ * </ul>
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ * @see MemoryMXBean
+ * @see MemoryPoolMXBean
+ */
+public class MemoryUsage
+{
+
+  /**
+   * The initial amount of memory allocated.
+   */
+  private long init;
+
+  /**
+   * The amount of memory used.
+   */
+  private long used;
+
+  /**
+   * The amount of memory committed for use.
+   */
+  private long committed;
+
+  /**
+   * The maximum amount of memory available.
+   */
+  private long maximum;
+
+  /**
+   * Constructs a new {@link MemoryUsage} object with
+   * the specified allocation levels.
+   *
+   * @param init the initial amount of memory allocated,
+   *             or -1 if this value is undefined.  Must
+   *             be >= -1.
+   * @param used the amount of memory used.  Must be >= 0,
+   *             and <= committed.
+   * @param committed the amount of memory committed for use
+   *                  at present.  Must be >= 0 and <=
+   *                  maximum (if defined).
+   * @param maximum the maximum amount of memory that may be
+   *                used, or -1 if this value is undefined.
+   *                Must be >= -1.
+   * @throws IllegalArgumentException if the values break any
+   *                                  of the limits specified
+   *                                  above.
+   */
+  public MemoryUsage(long init, long used, long committed,
+		     long maximum)
+  {
+    if (init < -1)
+      throw new IllegalArgumentException("Initial value of "
+					 + init + " is too small.");
+    if (used < 0)
+      throw new IllegalArgumentException("Used value of "
+					 + used + " is too small.");
+    if (committed < 0)
+      throw new IllegalArgumentException("Committed value of "
+					 + committed + " is too small.");
+    if (committed < used)
+      throw new IllegalArgumentException("Committed value of "
+					 + committed + " is below "
+					 + used + ", the amount used.");
+    if (maximum < -1)
+      throw new IllegalArgumentException("Maximum value of "
+					 + maximum + " is too small.");
+    if (maximum != -1 && maximum < committed)
+      throw new IllegalArgumentException("Maximum value of " 
+					 + maximum + " is below "
+					 + committed + ", the amount "
+					 + "committed.");
+    this.init = init;
+    this.used = used;
+    this.committed = committed;
+    this.maximum = maximum;
+  }
+
+  /**
+   * <p>
+   * Returns a {@link MemoryUsage} instance using the values
+   * given in the supplied
+   * {@link javax.management.openmbean.CompositeData} object.
+   * The composite data instance should contain the following
+   * attributes:
+   * </p>
+   * <ul>
+   * <li>init</li>
+   * <li>used</li>
+   * <li>committed</li>
+   * <li>max</li>
+   * </ul>
+   * <p>
+   * All should have the type, <code>java.lang.Long</code>.
+   * </p>
+   * 
+   * @param data the composite data structure to take values from.
+   * @return a new instance containing the values from the 
+   *         composite data structure, or <code>null</code>
+   *         if the data structure was also <code>null</code>.
+   * @throws IllegalArgumentException if the composite data structure
+   *                                  does not match the structure
+   *                                  outlined above, or the values
+   *                                  are invalid.
+   */
+  public static MemoryUsage from(CompositeData data)
+  {
+    if (data == null)
+      return null;
+    CompositeType type = data.getCompositeType();
+    ThreadInfo.checkAttribute(type, "init", SimpleType.LONG);
+    ThreadInfo.checkAttribute(type, "used", SimpleType.LONG);
+    ThreadInfo.checkAttribute(type, "committed", SimpleType.LONG);
+    ThreadInfo.checkAttribute(type, "max", SimpleType.LONG);
+    return new MemoryUsage(((Long) data.get("init")).longValue(),
+			   ((Long) data.get("used")).longValue(),
+			   ((Long) data.get("committed")).longValue(),
+			   ((Long) data.get("max")).longValue());
+  }
+
+  /**
+   * Returns the amount of memory committed for use by this
+   * memory pool (in bytes).  This amount is guaranteed to
+   * be available, unlike the maximum.
+   *
+   * @return the committed amount of memory.
+   */
+  public long getCommitted()
+  {
+    return committed;
+  }
+
+  /**
+   * Returns the initial amount of memory allocated to the
+   * pool (in bytes).  This method may return -1, if the
+   * value is undefined.
+   *
+   * @return the initial amount of memory allocated, or -1
+   *         if this value is undefined.
+   */
+  public long getInit()
+  {
+    return init;
+  }
+
+  /**
+   * Returns the maximum amount of memory available for this
+   * pool (in bytes).  This amount is not guaranteed to 
+   * actually be usable.  This method may return -1, if the
+   * value is undefined.
+   *
+   * @return the maximum amount of memory available, or -1
+   *         if this value is undefined.
+   */
+  public long getMax()
+  {
+    return maximum;
+  }
+
+  /**
+   * Returns the amount of memory used (in bytes).
+   *
+   * @return the amount of used memory.
+   */
+  public long getUsed()
+  {
+    return used;
+  }
+
+  /**
+   * Returns a {@link java.lang.String} representation of
+   * this {@link MemoryUsage} object.  This takes the form
+   * <code>java.lang.management.MemoryUsage[init=i, used=u,
+   * committed=c, maximum=m]</code>, where <code>i</code>
+   * is the initial level, <code>u</code> is the used level,
+   * <code>c</code> is the committed level and <code>m</code>
+   * is the maximum level.
+   *
+   * @return the string specified above.
+   */
+  public String toString()
+  {
+    int megabyte = 1024 * 1024;
+    return getClass().getName() +
+      "[init=" + init + " bytes (~" + (init / megabyte) +
+      "MB), used=" + used + " bytes (~" + (used / megabyte) +
+      "MB), committed=" + committed + " bytes (~" + (committed / megabyte) +
+      "MB), maximum=" + maximum + " bytes (~" + (maximum / megabyte) +
+      "MB)]";
+  }
+
+}
+  

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/OperatingSystemMXBean.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/OperatingSystemMXBean.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,103 @@
+/* OperatingSystemMXBean.java - Interface for an operating system bean
+   Copyright (C) 2006 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 java.lang.management;
+
+/**
+ * Provides access to information about the underlying operating
+ * system.  An instance of this bean is obtained by calling
+ * {@link ManagementFactory#getOperatingSystemMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface OperatingSystemMXBean
+{
+
+  /**
+   * Returns the name of the underlying system architecture.  This
+   * is equivalent to obtaining the <code>os.arch</code> property
+   * via {@link System#getProperty(String)}.
+   *
+   * @return the name of the underlying system architecture on which
+   *         the VM is running.
+   * @throws SecurityException if a security manager exists which
+   *                           prevents access to the name property.
+   * @see java.lang.System#getProperty(String)
+   * @see java.lang.SecurityManager#checkPropertyAccess(String)
+   */
+  String getArch();
+
+  /**
+   * Returns the number of processors currently available to the
+   * virtual machine.  This number is subject to change during
+   * execution of the virtual machine, and will always be >= 1.
+   * The call is equivalent to {@link Runtime#availableProcessors()}.
+   *
+   * @return the number of processors available to the VM.
+   */
+  int getAvailableProcessors();
+
+  /**
+   * Returns the name of the underlying operating system.  This
+   * is equivalent to obtaining the <code>os.name</code> property
+   * via {@link System#getProperty(String)}.
+   *
+   * @return the name of the operating system on which the VM
+   *         is running.
+   * @throws SecurityException if a security manager exists which
+   *                           prevents access to the name property.
+   * @see java.lang.System#getProperty(String)
+   * @see java.lang.SecurityManager#checkPropertyAccess(String)
+   */
+  String getName();
+
+  /**
+   * Returns the version of the underlying operating system.  This
+   * is equivalent to obtaining the <code>os.version</code> property
+   * via {@link System#getProperty(String)}.
+   *
+   * @return the version of the operating system on which the VM
+   *         is running.
+   * @throws SecurityException if a security manager exists which
+   *                           prevents access to the name property.
+   * @see java.lang.System#getProperty(String)
+   * @see java.lang.SecurityManager#checkPropertyAccess(String)
+   */
+  String getVersion();
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/RuntimeMXBean.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/RuntimeMXBean.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,278 @@
+/* RuntimeMXBean.java - Interface for a runtime bean
+   Copyright (C) 2006 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 java.lang.management;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Provides access to information about the underlying virtual
+ * machine.  An instance of this bean is obtained by calling
+ * {@link ManagementFactory#getRuntimeMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface RuntimeMXBean
+{
+
+  /**
+   * <p>
+   * Returns the boot classpath used by the virtual machine.  This
+   * value follows the standard path syntax used by the underlying
+   * operating system (e.g. directories separated by ':' on UNIX
+   * or ';' on Windows). 
+   * </p>
+   * <p>
+   * Supplying this value is optional.  Users should check the
+   * return value of {@link isBootClassPathSupported()} prior to
+   * calling this method.
+   * </p>
+   *
+   * @return the boot classpath of the virtual machine, if supported.
+   * @throws UnsupportedOperationException in cases where this
+   *                                       functionality is not
+   *                                       supported by the VM.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("monitor").
+   * @see #isBootClassPathSupported()
+   * @see java.lang.management.ManagementPermission
+   */
+  String getBootClassPath();
+
+  /**
+   * Returns the classpath used by the system classloader.  This
+   * is equivalent to obtaining the <code>java.class.path</code>
+   * property via {@link System#getProperty(String)}.  This value
+   * follows the standard path syntax used by the underlying operating
+   * system (e.g. directories separated by ':' on UNIX or ';' on
+   * Windows). 
+   *
+   * @return the classpath used by the system class loader.
+   * @throws SecurityException if a security manager exists which
+   *                           prevents access to the classpath
+   *                           property.
+   * @see java.lang.System#getProperty(String)
+   * @see java.lang.SecurityManager#checkPropertyAccess(String)
+   */
+  String getClassPath();
+
+  /**
+   * Returns a list of the arguments given to the virtual machine,
+   * excluding those that apply to the <code>main()</code> method
+   * of the class file being executed.  These may not just be those
+   * specified at the command line, but may also include arguments
+   * from environment variables, configuration files, etc.  All
+   * command line arguments may not reach the virtual machine, so
+   * these are not included in this list.
+   *
+   * @return a list of arguments passed to the virtual machine.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("monitor").
+   * @see java.lang.management.ManagementPermission
+   */
+  List getInputArguments();
+
+  /**
+   * Returns the library path.  This is equivalent to obtaining the
+   * <code>java.library.path</code> property via
+   * {@link System#getProperty(String)}.  This value follows the
+   * standard path syntax used by the underlying operating
+   * system (e.g. directories separated by ':' on UNIX or ';' on
+   * Windows). 
+   *
+   * @return the library path.
+   * @throws SecurityException if a security manager exists which
+   *                           prevents access to the library path
+   *                           property.
+   * @see java.lang.System#getProperty(String)
+   * @see java.lang.SecurityManager#checkPropertyAccess(String)
+   */
+  String getLibraryPath();
+
+  /**
+   * Returns the version of the management specification
+   * implemented by the virtual machine.
+   *
+   * @return the version of the management specification
+   *         implemented.
+   */
+  String getManagementSpecVersion();
+
+  /**
+   * Returns the name of this virtual machine.  The content
+   * of this property is left up to the developer of the
+   * virtual machine.  It may include a number of system
+   * attributes and may differ between instances of the
+   * same virtual machine (for example, it might include
+   * the process identifier or the host name of the machine
+   * on which it is running).  The intention is that this
+   * name refers to the precise entity that the other data 
+   * supplied by this bean refers to, rather than the VM
+   * in general.
+   *
+   * @return the name of this virtual machine.
+   */
+  String getName();
+
+  /**
+   * Returns the specification name of the virtual machine.
+   * This is equivalent to obtaining the
+   * <code>java.vm.specification.name</code> property via
+   * {@link System#getProperty(String)}.  
+   *
+   * @return the specification name of the VM.
+   * @throws SecurityException if a security manager exists which
+   *                           prevents access to the VM
+   *                           specification name property.
+   * @see java.lang.System#getProperty(String)
+   * @see java.lang.SecurityManager#checkPropertyAccess(String)
+   */
+  String getSpecName();
+
+  /**
+   * Returns the specification vendor of the virtual machine.
+   * This is equivalent to obtaining the
+   * <code>java.vm.specification.vendor</code> property via
+   * {@link System#getProperty(String)}.  
+   *
+   * @return the specification vendor of the VM.
+   * @throws SecurityException if a security manager exists which
+   *                           prevents access to the VM
+   *                           specification vendor property.
+   * @see java.lang.System#getProperty(String)
+   * @see java.lang.SecurityManager#checkPropertyAccess(String)
+   */
+  String getSpecVendor();
+
+  /**
+   * Returns the specification version of the virtual machine.
+   * This is equivalent to obtaining the
+   * <code>java.vm.specification.version</code> property via
+   * {@link System#getProperty(String)}.  
+   *
+   * @return the specification version of the VM.
+   * @throws SecurityException if a security manager exists which
+   *                           prevents access to the VM
+   *                           specification version property.
+   * @see java.lang.System#getProperty(String)
+   * @see java.lang.SecurityManager#checkPropertyAccess(String)
+   */
+  String getSpecVersion();
+
+  /**
+   * Returns the approximate start time of the virtual machine
+   * in milliseconds.
+   * 
+   * @return the start time of the virtual machine.
+   */
+  long getStartTime();
+
+  /**
+   * Returns a map containing the keys and values of the system
+   * properties.  This gives largely the same result as calling
+   * {@link System#getProperties()}, but the resulting map
+   * is filtered so as to only provide keys and values that
+   * are <code>String</code>s.
+   *
+   * @return the map of system properties.
+   */
+  Map getSystemProperties();
+
+  /**
+   * Returns the uptime of the virtual machine in milliseconds.
+   * 
+   * @return the uptime of the virtual machine.
+   */
+  long getUptime();
+
+  /**
+   * Returns the implementation name of the virtual machine.
+   * This is equivalent to obtaining the
+   * <code>java.vm.name</code> property via
+   * {@link System#getProperty(String)}.  
+   *
+   * @return the implementation name of the VM.
+   * @throws SecurityException if a security manager exists which
+   *                           prevents access to the VM name
+   *                           property.
+   * @see java.lang.System#getProperty(String)
+   * @see java.lang.SecurityManager#checkPropertyAccess(String)
+   */
+  String getVmName();
+
+  /**
+   * Returns the implementation vendor of the virtual machine.
+   * This is equivalent to obtaining the
+   * <code>java.vm.vendor</code> property via
+   * {@link System#getProperty(String)}.  
+   *
+   * @return the implementation vendor of the VM.
+   * @throws SecurityException if a security manager exists which
+   *                           prevents access to the VM vendor
+   *                           property.
+   * @see java.lang.System#getProperty(String)
+   * @see java.lang.SecurityManager#checkPropertyAccess(String)
+   */
+  String getVmVendor();
+
+  /**
+   * Returns the implementation version of the virtual machine.
+   * This is equivalent to obtaining the
+   * <code>java.vm.version</code> property via
+   * {@link System#getProperty(String)}.  
+   *
+   * @return the implementation version of the VM.
+   * @throws SecurityException if a security manager exists which
+   *                           prevents access to the VM version
+   *                           property.
+   * @see java.lang.System#getProperty(String)
+   * @see java.lang.SecurityManager#checkPropertyAccess(String)
+   */
+  String getVmVersion();
+
+  /**
+   * Returns true if the virtual machine supports the boot classpath
+   * mechanism.
+   *
+   * @return true if the boot classpath property is supported by the
+   *         virtual machine.
+   */
+  boolean isBootClassPathSupported();
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/ThreadInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/ThreadInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,704 @@
+/* ThreadInfo.java - Information on a thread
+   Copyright (C) 2006 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 java.lang.management;
+
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+
+/**
+ * <p>
+ * A class which maintains information about a particular
+ * thread.  This information includes:
+ * </p>
+ * <ul>
+ * <li><strong>General Thread Information:</strong>
+ * <ul>
+ * <li>The identifier of the thread.</li>
+ * <li>The name of the thread.</li>
+ * </ul>
+ * </li>
+ * <li><strong>Execution Information:</strong>
+ * <ul>
+ * <li>The current state of the thread (e.g. blocked, runnable)</li>
+ * <li>The object upon which the thread is blocked, either because
+ * the thread is waiting to obtain the monitor of that object to enter
+ * one of its synchronized monitor, or because
+ * {@link java.lang.Object#wait()} has been called while the thread
+ * was within a method of that object.</li>
+ * <li>The thread identifier of the current thread holding an object's
+ * monitor, upon which the thread described here is blocked.</li>
+ * <li>The stack trace of the thread (if requested on creation
+ * of this object</li>
+ * </ul>
+ * <li><strong>Synchronization Statistics</strong>
+ * <ul>
+ * <li>The number of times the thread has been blocked waiting for
+ * an object's monitor or in a {@link java.lang.Object#wait()} call.</li>
+ * <li>The accumulated time the thread has been blocked waiting for
+ * an object's monitor on in a {@link java.lang.Object#wait()} call.
+ * The availability of these statistics depends on the virtual machine's
+ * support for thread contention monitoring (see
+ * {@link ThreadMXBean#isThreadContentionMonitoringSupported()}.</li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ * @see ThreadMXBean#isThreadContentionMonitoringSupported()
+ */
+public class ThreadInfo
+{
+
+  /**
+   * The id of the thread which this instance concerns.
+   */
+  private long threadId;
+
+  /**
+   * The name of the thread which this instance concerns.
+   */
+  private String threadName;
+
+  /**
+   * The state of the thread which this instance concerns.
+   */
+  private String threadState;
+
+  /**
+   * The number of times the thread has been blocked.
+   */
+  private long blockedCount;
+
+  /**
+   * The accumulated number of milliseconds the thread has
+   * been blocked (used only with thread contention monitoring
+   * support).
+   */
+  private long blockedTime;
+
+  /**
+   * The name of the monitor lock on which this thread
+   * is blocked (if any).
+   */
+  private String lockName;
+
+  /**
+   * The id of the thread which owns the monitor lock on
+   * which this thread is blocked, or <code>-1</code>
+   * if there is no owner.
+   */
+  private long lockOwnerId;
+
+  /**
+   * The name of the thread which owns the monitor lock on
+   * which this thread is blocked, or <code>null</code>
+   * if there is no owner.
+   */
+  private String lockOwnerName;
+
+  /**
+   * The number of times the thread has been in a waiting
+   * state.
+   */
+  private long waitedCount;
+
+  /**
+   * The accumulated number of milliseconds the thread has
+   * been waiting (used only with thread contention monitoring
+   * support).
+   */
+  private long waitedTime;
+
+  /**
+   * True if the thread is in a native method.
+   */
+  private boolean isInNative;
+
+  /**
+   * True if the thread is suspended.
+   */
+  private boolean isSuspended;
+
+  /**
+   * The stack trace of the thread.
+   */
+  private StackTraceElement[] trace;
+
+  /**
+   * Cache a local reference to the thread management bean.
+   */
+  private static ThreadMXBean bean = null;
+
+  /**
+   * Constructs a new {@link ThreadInfo} corresponding
+   * to the thread specified.
+   *
+   * @param thread the thread on which the new instance
+   *               will be based.
+   * @param blockedCount the number of times the thread
+   *                     has been blocked.
+   * @param blockedTime the accumulated number of milliseconds
+   *                    the specified thread has been blocked
+   *                    (only used with contention monitoring enabled)
+   * @param lock the monitor lock the thread is waiting for
+   *             (only used if blocked)
+   * @param lockOwner the thread which owns the monitor lock, or
+   *                  <code>null</code> if it doesn't have an owner
+   *                  (only used if blocked)
+   * @param waitedCount the number of times the thread has been in a
+   *                    waiting state.
+   * @param waitedTime the accumulated number of milliseconds the
+   *                   specified thread has been waiting
+   *                   (only used with contention monitoring enabled)
+   * @param isInNative true if the thread is in a native method.
+   * @param isSuspended true if the thread is suspended.
+   * @param trace the stack trace of the thread to a pre-determined
+   *              depth (see VMThreadMXBeanImpl)
+   */
+  private ThreadInfo(Thread thread, long blockedCount, long blockedTime,
+		     Object lock, Thread lockOwner, long waitedCount,
+		     long waitedTime, boolean isInNative, boolean isSuspended,
+		     StackTraceElement[] trace)
+  {
+    this(thread.getId(), thread.getName(), thread.getState(), blockedCount,
+	 blockedTime, lock.getClass().getName() + "@" + 
+	 Integer.toHexString(System.identityHashCode(lock)), lockOwner.getId(),
+	 lockOwner.getName(), waitedCount, waitedTime, isInNative, isSuspended,
+	 trace);
+  }
+
+  /**
+   * Constructs a new {@link ThreadInfo} corresponding
+   * to the thread details specified.
+   *
+   * @param threadId the id of the thread on which this
+   *                 new instance will be based.
+   * @param threadName the name of the thread on which
+   *                 this new instance will be based.
+   * @param threadState the state of the thread on which
+   *                 this new instance will be based.
+   * @param blockedCount the number of times the thread
+   *                     has been blocked.
+   * @param blockedTime the accumulated number of milliseconds
+   *                    the specified thread has been blocked
+   *                    (only used with contention monitoring enabled)
+   * @param lockName the name of the monitor lock the thread is waiting for
+   *                 (only used if blocked)
+   * @param lockOwnerId the id of the thread which owns the monitor
+   *                  lock, or <code>-1</code> if it doesn't have an owner
+   *                  (only used if blocked)
+   * @param lockOwnerName the name of the thread which owns the monitor
+   *                  lock, or <code>null</code> if it doesn't have an 
+   *                  owner (only used if blocked)
+   * @param waitedCount the number of times the thread has been in a
+   *                    waiting state.
+   * @param waitedTime the accumulated number of milliseconds the
+   *                   specified thread has been waiting
+   *                   (only used with contention monitoring enabled)
+   * @param isInNative true if the thread is in a native method.
+   * @param isSuspended true if the thread is suspended.
+   * @param trace the stack trace of the thread to a pre-determined
+   *              depth (see VMThreadMXBeanImpl)
+   */
+  private ThreadInfo(long threadId, String threadName, String threadState,
+		     long blockedCount, long blockedTime, String lockName, 
+		     long lockOwnerId, String lockOwnerName, long waitedCount,
+		     long waitedTime, boolean isInNative, boolean isSuspended,
+		     StackTraceElement[] trace)
+  {
+    this.threadId = threadId;
+    this.threadName = threadName;
+    this.threadState = threadState;
+    this.blockedCount = blockedCount;
+    this.blockedTime = blockedTime;
+    this.lockName = lockName;
+    this.lockOwnerId = lockOwnerId;
+    this.lockOwnerName = lockOwnerName;
+    this.waitedCount = waitedCount;
+    this.waitedTime = waitedTime;
+    this.isInNative = isInNative;
+    this.isSuspended = isSuspended;
+    this.trace = trace;
+  }
+
+  /**
+   * Checks for an attribute in a {@link CompositeData} structure
+   * with the correct type.
+   *
+   * @param ctype the composite data type to check.
+   * @param name the name of the attribute.
+   * @param type the type to check for.
+   * @throws IllegalArgumentException if the attribute is absent
+   *                                  or of the wrong type.
+   */
+  static void checkAttribute(CompositeType ctype, String name,
+			     OpenType type)
+    throws IllegalArgumentException
+  {
+    OpenType foundType = ctype.getType(name);
+    if (foundType == null)
+      throw new IllegalArgumentException("Could not find a field named " +
+					 name);
+    if (!(foundType.equals(type)))
+      throw new IllegalArgumentException("Field " + name + " is not of " +
+					 "type " + type.getClassName());
+  }
+
+  /**
+   * <p>
+   * Returns a {@link ThreadInfo} instance using the values
+   * given in the supplied
+   * {@link javax.management.openmbean.CompositeData} object.
+   * The composite data instance should contain the following
+   * attributes with the specified types:
+   * </p>
+   * <table>
+   * <th><td>Name</td><td>Type</td></th>
+   * <tr><td>threadId</td><td>java.lang.Long</td></tr>
+   * <tr><td>threadName</td><td>java.lang.String</td></tr>
+   * <tr><td>threadState</td><td>java.lang.String</td></tr>
+   * <tr><td>suspended</td><td>java.lang.Boolean</td></tr>
+   * <tr><td>inNative</td><td>java.lang.Boolean</td></tr>
+   * <tr><td>blockedCount</td><td>java.lang.Long</td></tr>
+   * <tr><td>blockedTime</td><td>java.lang.Long</td></tr>
+   * <tr><td>waitedCount</td><td>java.lang.Long</td></tr>
+   * <tr><td>waitedTime</td><td>java.lang.Long</td></tr>
+   * <tr><td>lockName</td><td>java.lang.String</td></tr>
+   * <tr><td>lockOwnerId</td><td>java.lang.Long</td></tr>
+   * <tr><td>lockOwnerName</td><td>java.lang.String</td></tr>
+   * <tr><td>stackTrace</td><td>javax.management.openmbean.CompositeData[]
+   * </td></tr>
+   * </table>
+   * <p>
+   * The stack trace is further described as:
+   * </p>
+   * <table>
+   * <th><td>Name</td><td>Type</td></th>
+   * <tr><td>className</td><td>java.lang.String</td></tr>
+   * <tr><td>methodName</td><td>java.lang.String</td></tr>
+   * <tr><td>fileName</td><td>java.lang.String</td></tr>
+   * <tr><td>lineNumber</td><td>java.lang.Integer</td></tr>
+   * <tr><td>nativeMethod</td><td>java.lang.Boolean</td></tr>
+   * </table>
+   * 
+   * @param data the composite data structure to take values from.
+   * @return a new instance containing the values from the 
+   *         composite data structure, or <code>null</code>
+   *         if the data structure was also <code>null</code>.
+   * @throws IllegalArgumentException if the composite data structure
+   *                                  does not match the structure
+   *                                  outlined above.
+   */
+  public static ThreadInfo from(CompositeData data)
+  {
+    if (data == null)
+      return null;
+    CompositeType type = data.getCompositeType();
+    checkAttribute(type, "threadId", SimpleType.LONG);
+    checkAttribute(type, "threadName", SimpleType.STRING);
+    checkAttribute(type, "threadState", SimpleType.STRING);
+    checkAttribute(type, "suspended", SimpleType.BOOLEAN);
+    checkAttribute(type, "inNative", SimpleType.BOOLEAN);
+    checkAttribute(type, "blockedCount", SimpleType.LONG);
+    checkAttribute(type, "blockedTime", SimpleType.LONG);
+    checkAttribute(type, "waitedCount", SimpleType.LONG);
+    checkAttribute(type, "waitedTime", SimpleType.LONG);
+    checkAttribute(type, "lockName", SimpleType.STRING);
+    checkAttribute(type, "lockOwnerId", SimpleType.LONG);
+    checkAttribute(type, "lockOwnerName", SimpleType.STRING);
+    try
+      {
+	CompositeType seType = 
+	  new CompositeType(StackTraceElement.class.getName(),
+			    "An element of a stack trace",
+			    new String[] { "className", "methodName",
+					   "fileName", "lineNumber",
+					   "nativeMethod" 
+			    },
+			    new String[] { "Name of the class",
+					   "Name of the method",
+					   "Name of the source code file",
+					   "Line number",
+					   "True if this is a native method" 
+			    },
+			    new OpenType[] {
+			      SimpleType.STRING, SimpleType.STRING,
+			      SimpleType.STRING, SimpleType.INTEGER,
+			      SimpleType.BOOLEAN 
+			    });
+	checkAttribute(type, "stackTrace", new ArrayType(1, seType));
+      }
+    catch (OpenDataException e)
+      {
+	throw new IllegalStateException("Something went wrong in creating " +
+					"the composite data type for the " +
+					"stack trace element.", e);
+      }
+    CompositeData[] dTraces = (CompositeData[]) data.get("stackTrace");
+    StackTraceElement[] traces = new StackTraceElement[dTraces.length];
+    for (int a = 0; a < dTraces.length; ++a)
+	/* FIXME: We can't use the boolean as there is no available
+	   constructor. */
+      traces[a] = 
+	new StackTraceElement((String) dTraces[a].get("className"),
+			      (String) dTraces[a].get("methodName"),
+			      (String) dTraces[a].get("fileName"),
+			      ((Integer) 
+			       dTraces[a].get("lineNumber")).intValue());
+    return new ThreadInfo(((Long) data.get("threadId")).longValue(),
+			  (String) data.get("threadName"),
+			  (String) data.get("threadState"),
+			  ((Long) data.get("blockedCount")).longValue(),
+			  ((Long) data.get("blockedTime")).longValue(),
+			  (String) data.get("lockName"),
+			  ((Long) data.get("lockOwnerId")).longValue(),
+			  (String) data.get("lockOwnerName"),  
+			  ((Long) data.get("waitedCount")).longValue(),
+			  ((Long) data.get("waitedTime")).longValue(),
+			  ((Boolean) data.get("inNative")).booleanValue(),
+			  ((Boolean) data.get("suspended")).booleanValue(),
+			  traces);
+  }
+
+  /**
+   * Returns the number of times this thread has been
+   * in the {@link java.lang.Thread.State#BLOCKED} state.
+   * A thread enters this state when it is waiting to
+   * obtain an object's monitor.  This may occur either
+   * on entering a synchronized method for the first time,
+   * or on re-entering it following a call to
+   * {@link java.lang.Object#wait()}.
+   *
+   * @return the number of times this thread has been blocked.
+   */
+  public long getBlockedCount()
+  {
+    return blockedCount;
+  }
+
+  /**
+   * <p>
+   * Returns the accumulated number of milliseconds this
+   * thread has been in the
+   * {@link java.lang.Thread.State#BLOCKED} state
+   * since thread contention monitoring was last enabled.
+   * A thread enters this state when it is waiting to
+   * obtain an object's monitor.  This may occur either
+   * on entering a synchronized method for the first time,
+   * or on re-entering it following a call to
+   * {@link java.lang.Object#wait()}.
+   * </p>
+   * <p>
+   * Use of this method requires virtual machine support
+   * for thread contention monitoring and for this support
+   * to be enabled.
+   * </p>
+   * 
+   * @return the accumulated time (in milliseconds) that this
+   *         thread has spent in the blocked state, since
+   *         thread contention monitoring was enabled, or -1
+   *         if thread contention monitoring is disabled.
+   * @throws UnsupportedOperationException if the virtual
+   *                                       machine does not
+   *                                       support contention
+   *                                       monitoring.
+   * @see ThreadMXBean#isThreadContentionMonitoringEnabled()
+   * @see ThreadMXBean#isThreadContentionMonitoringSupported()
+   */
+  public long getBlockedTime()
+  {
+    if (bean == null)
+      bean = ManagementFactory.getThreadMXBean();
+    // Will throw UnsupportedOperationException for us
+    if (bean.isThreadContentionMonitoringEnabled())
+      return blockedTime;
+    else
+      return -1;
+  }
+
+  /**
+   * <p>
+   * Returns a {@link java.lang.String} representation of
+   * the monitor lock on which this thread is blocked.  If
+   * the thread is not blocked, this method returns
+   * <code>null</code>.
+   * </p>
+   * <p>
+   * The returned {@link java.lang.String} is constructed
+   * using the class name and identity hashcode (usually
+   * the memory address of the object) of the lock.  The
+   * two are separated by the '@' character, and the identity
+   * hashcode is represented in hexadecimal.  Thus, for a
+   * lock, <code>l</code>, the returned value is
+   * the result of concatenating
+   * <code>l.getClass().getName()</code>, <code>"@"</code>
+   * and
+   * <code>Integer.toHexString(System.identityHashCode(l))</code>.
+   * The value is only unique to the extent that the identity
+   * hash code is also unique.
+   * </p>
+   *
+   * @return a string representing the lock on which this
+   *         thread is blocked, or <code>null</code> if
+   *         the thread is not blocked.
+   */
+  public String getLockName()
+  {
+    if (threadState.equals("BLOCKED"))
+      return null;
+    return lockName;
+  }
+
+  /**
+   * Returns the identifier of the thread which owns the
+   * monitor lock this thread is waiting for.  -1 is returned
+   * if either this thread is not blocked, or the lock is
+   * not held by any other thread.
+   * 
+   * @return the thread identifier of thread holding the lock
+   *         this thread is waiting for, or -1 if the thread
+   *         is not blocked or the lock is not held by another
+   *         thread.
+   */
+  public long getLockOwnerId()
+  {
+    if (threadState.equals("BLOCKED"))
+      return -1;
+    return lockOwnerId;
+  }
+
+  /**
+   * Returns the name of the thread which owns the
+   * monitor lock this thread is waiting for.  <code>null</code>
+   * is returned if either this thread is not blocked,
+   * or the lock is not held by any other thread.
+   * 
+   * @return the thread identifier of thread holding the lock
+   *         this thread is waiting for, or <code>null</code>
+   *         if the thread is not blocked or the lock is not
+   *         held by another thread.
+   */
+  public String getLockOwnerName()
+  {
+    if (threadState.equals("BLOCKED"))
+      return null;
+    return lockOwnerName;
+  }
+
+  /**
+   * <p>
+   * Returns the stack trace of this thread to the depth
+   * specified on creation of this {@link ThreadInfo}
+   * object.  If the depth is zero, an empty array will
+   * be returned.  For non-zero arrays, the elements
+   * start with the most recent trace at position zero.
+   * The bottom of the stack represents the oldest method
+   * invocation which meets the depth requirements.
+   * </p>
+   * <p>
+   * Some virtual machines may not be able to return
+   * stack trace information for a thread.  In these
+   * cases, an empty array will also be returned.
+   * </p>
+   * 
+   * @return an array of {@link java.lang.StackTraceElement}s
+   *         representing the trace of this thread.
+   */
+  public StackTraceElement[] getStackTrace()
+  {
+    return trace;
+  }
+
+  /**
+   * Returns the identifier of the thread associated with
+   * this instance of {@link ThreadInfo}.
+   *
+   * @return the thread's identifier.
+   */
+  public long getThreadId()
+  {
+    return threadId;
+  }
+
+  /**
+   * Returns the name of the thread associated with
+   * this instance of {@link ThreadInfo}.
+   *
+   * @return the thread's name.
+   */
+  public String getThreadName()
+  {
+    return threadName;
+  }
+
+  /**
+   * Returns the state of the thread associated with
+   * this instance of {@link ThreadInfo}.
+   *
+   * @return the thread's state.
+   */
+  public String getThreadState()
+  {
+    return threadState;
+  }
+    
+  /**
+   * Returns the number of times this thread has been
+   * in the {@link java.lang.Thread.State#WAITING} 
+   * or {@link java.lang.Thread.State#TIMED_WAITING} state.
+   * A thread enters one of these states when it is waiting
+   * due to a call to {@link java.lang.Object.wait()},
+   * {@link java.lang.Object.join()} or
+   * {@link java.lang.concurrent.locks.LockSupport.park()},
+   * either with an infinite or timed delay, respectively. 
+   *
+   * @return the number of times this thread has been waiting.
+   */
+  public long getWaitedCount()
+  {
+    return waitedCount;
+  }
+
+  /**
+   * <p>
+   * Returns the accumulated number of milliseconds this
+   * thread has been in the
+   * {@link java.lang.Thread.State#WAITING} or
+   * {@link java.lang.Thread.State#TIMED_WAITING} state,
+   * since thread contention monitoring was last enabled.
+   * A thread enters one of these states when it is waiting
+   * due to a call to {@link java.lang.Object.wait()},
+   * {@link java.lang.Object.join()} or
+   * {@link java.lang.concurrent.locks.LockSupport.park()},
+   * either with an infinite or timed delay, respectively. 
+   * </p>
+   * <p>
+   * Use of this method requires virtual machine support
+   * for thread contention monitoring and for this support
+   * to be enabled.
+   * </p>
+   * 
+   * @return the accumulated time (in milliseconds) that this
+   *         thread has spent in one of the waiting states, since
+   *         thread contention monitoring was enabled, or -1
+   *         if thread contention monitoring is disabled.
+   * @throws UnsupportedOperationException if the virtual
+   *                                       machine does not
+   *                                       support contention
+   *                                       monitoring.
+   * @see ThreadMXBean#isThreadContentionMonitoringEnabled()
+   * @see ThreadMXBean#isThreadContentionMonitoringSupported()
+   */
+  public long getWaitedTime()
+  {
+    if (bean == null)
+      bean = ManagementFactory.getThreadMXBean();
+    // Will throw UnsupportedOperationException for us
+    if (bean.isThreadContentionMonitoringEnabled())
+      return waitedTime;
+    else
+      return -1;
+  }
+
+  /**
+   * Returns true if the thread is in a native method.  This
+   * excludes native code which forms part of the virtual
+   * machine itself, or which results from Just-In-Time
+   * compilation.
+   *
+   * @return true if the thread is in a native method, false
+   *         otherwise.
+   */
+  public boolean isInNative()
+  {
+    return isInNative;
+  }
+
+  /**
+   * Returns true if the thread has been suspended using
+   * {@link java.lang.Thread#suspend()}.
+   *
+   * @return true if the thread is suspended, false otherwise.
+   */
+  public boolean isSuspended()
+  {
+    return isSuspended;
+  }
+
+  /**
+   * Returns a {@link java.lang.String} representation of
+   * this {@link ThreadInfo} object.  This takes the form
+   * <code>java.lang.management.ThreadInfo[id=tid, name=n,
+   * state=s, blockedCount=bc, waitedCount=wc, isInNative=iin,
+   * isSuspended=is]</code>, where <code>tid</code> is
+   * the thread identifier, <code>n</code> is the
+   * thread name, <code>s</code> is the thread state,
+   * <code>bc</code> is the blocked state count,
+   * <code>wc</code> is the waiting state count and
+   * <code>iin</code> and <code>is</code> are boolean
+   * flags to indicate the thread is in native code or
+   * suspended respectively.  If the thread is blocked,
+   * <code>lock=l, lockOwner=lo</code> is also included,
+   * where <code>l</code> is the lock waited for, and
+   * <code>lo</code> is the thread which owns the lock
+   * (or null if there is no owner).
+   *
+   * @return the string specified above.
+   */
+  public String toString()
+  {
+    return getClass().getName() +
+      "[id=" + threadId + 
+      ", name=" + threadName +
+      ", state=" + threadState +
+      ", blockedCount=" + blockedCount +
+      ", waitedCount=" + waitedCount +
+      ", isInNative=" + isInNative + 
+      ", isSuspended=" + isSuspended +
+      (threadState.equals("BLOCKED") ? 
+       ", lockOwnerId=" + lockOwnerId +
+       ", lockOwnerName=" + lockOwnerName : "") +
+      "]";
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/ThreadMXBean.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/ThreadMXBean.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,497 @@
+/* ThreadMXBean.java - Interface for a thread bean
+   Copyright (C) 2006 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 java.lang.management;
+
+/**
+ * <p>
+ * Provides access to information about the threads 
+ * of the virtual machine.  An instance of this bean is
+ * obtained by calling
+ * {@link ManagementFactory#getThreadMXBean()}.
+ * </p>
+ * <p>
+ * Each thread within the virtual machine is given an
+ * identifier, which is guaranteed to be unique to a
+ * particular thread over its lifetime (after which it
+ * may be reused). The identifier for a thread may be
+ * obtained by calling {@link java.lang.Thread#getId()}.
+ * This identifier is used within implementations of this
+ * interface to obtain information about a particular thread
+ * (or series of threads, in the case of an array of identifiers).
+ * </p>
+ * <p>
+ * This bean supports some optional behaviour, which all
+ * virtual machines may not choose to implement.  Specifically,
+ * this includes the monitoring of the CPU time used by a
+ * thread, and the monitoring of thread contention.  The former
+ * is further subdivided into the monitoring of either just
+ * the current thread or all threads.  The methods
+ * {@link #isThreadCpuTimeSupported()},
+ * {@link #isCurrentThreadCpuTimeSupported()} and
+ * {@link #isThreadContentionMonitoringSupported()} may be
+ * used to determine whether or not this functionality is
+ * supported.
+ * </p>
+ * <p>
+ * Furthermore, both these facilities may be disabled.
+ * In fact, thread contention monitoring is disabled by
+ * default, and must be explictly turned on by calling
+ * the {@link #setThreadContentionMonitoringEnabled(boolean)}
+ * method.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface ThreadMXBean
+{
+
+  /**
+   * <p>
+   * This method obtains a list of threads which are deadlocked
+   * waiting to obtain monitor ownership.  On entering a synchronized
+   * method of an object, or re-entering it after returning from an
+   * {@link java.lang.Object#wait()} call, a thread obtains ownership
+   * of the object's monitor.  
+   * </p>
+   * <p>
+   * Deadlocks can occur in this situation if one or more threads end up
+   * waiting for a monitor, P, while also retaining ownership of a monitor,
+   * Q, required by the thread that currently owns P.  To give a simple
+   * example, imagine thread A calls a synchronized method, R, obtaining the
+   * monitor, P.  It then sleeps within that method, allowing thread B
+   * to run, but still retaining ownership of P.  B calls another
+   * synchronized method, S, which causes it to obtain the monitor, Q,
+   * of a different object.  While in that method, it then wants to
+   * call the original synchronized method, R,  called by A.  Doing so
+   * requires ownership of P, which is still held by A.  Hence, it
+   * becomes blocked.  
+   * </p>
+   * <p>
+   * A then finishes its sleep, becomes runnable, and is then allowed
+   * to run, being the only eligible thread in this scenario.  A tries
+   * to call the synchronized method, S.  It also gets blocked, because
+   * B still holds the monitor, Q.  Hence, the two threads, A and B,
+   * are deadlocked, as neither can give up its monitor without first
+   * obtaining the monitor held by the other thread.
+   * </p>
+   * <p>
+   * Calling this method in this scenario would return the thread IDs
+   * of A and B.  Note that this method is not designed for controlling
+   * synchronization, but for troubleshooting problems which cause such
+   * deadlocks; it may be prohibitively expensive to use in normal
+   * operation.
+   * </p>
+   * 
+   * @return an array of thread identifiers, corresponding to threads
+   *         which are currently in a deadlocked situation.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("monitor").
+   */
+  long[] findMonitorDeadlockedThreads();
+
+  /**
+   * Returns all live thread identifiers at the time of initial
+   * execution.  Some thread identifiers in the returned array
+   * may refer to terminated threads, if this occurs during the
+   * lifetime of this method.
+   *
+   * @return an array of thread identifiers, corresponding to
+   *         current live threads.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("monitor").
+   */
+  long[] getAllThreadIds();
+
+  /**
+   * <p>
+   * Returns the total number of nanoseconds of CPU time
+   * the current thread has used.  This is equivalent to calling
+   * <code>{@link #getThreadCpuTime()}(Thread.currentThread.getId())</code>.
+   * </p> 
+   * <p>
+   * Note that the value is only nanosecond-precise, and not accurate; there
+   * is no guarantee that the difference between two values is really a
+   * nanosecond.  Also, the value is prone to overflow if the offset
+   * exceeds 2^63.  The use of this method depends on virtual machine
+   * support for measurement of the CPU time of the current thread,
+   * and on this functionality being enabled.
+   * </p>
+   *
+   * @return the total number of nanoseconds of CPU time the current
+   *         thread has used, or -1 if CPU time monitoring is disabled.
+   * @throws UnsupportedOperationException if CPU time monitoring is not
+   *                                       supported.
+   * @see #getCurrentThreadUserTime()
+   * @see #isCurrentThreadCpuTimeSupported()
+   * @see #isThreadCpuTimeEnabled()
+   * @see #setThreadCpuTimeEnabled(boolean)
+   */
+  long getCurrentThreadCpuTime();
+
+  /**
+   * <p>
+   * Returns the total number of nanoseconds of CPU time
+   * the current thread has executed in user mode.  This is
+   * equivalent to calling
+   * <code>{@link #getThreadUserTime()}(Thread.currentThread.getId())</code>.
+   * </p> 
+   * <p>
+   * Note that the value is only nanosecond-precise, and not accurate; there
+   * is no guarantee that the difference between two values is really a
+   * nanosecond.  Also, the value is prone to overflow if the offset
+   * exceeds 2^63.  The use of this method depends on virtual machine
+   * support for measurement of the CPU time of the current thread,
+   * and on this functionality being enabled.
+   * </p>
+   *
+   * @return the total number of nanoseconds of CPU time the current
+   *         thread has executed in user mode, or -1 if CPU time
+   *         monitoring is disabled.
+   * @throws UnsupportedOperationException if CPU time monitoring is not
+   *                                       supported.
+   * @see #getCurrentThreadCpuTime()
+   * @see #isCurrentThreadCpuTimeSupported()
+   * @see #isThreadCpuTimeEnabled()
+   * @see #setThreadCpuTimeEnabled(boolean)
+   */
+  long getCurrentThreadUserTime();
+
+  /**
+   * Returns the number of live daemon threads.
+   *
+   * @return the number of live daemon threads.
+   */
+  int getDaemonThreadCount();
+
+  /**
+   * Returns the peak number of live threads since
+   * the virtual machine was started or the count
+   * reset using {@link #resetPeakThreadCount()}.
+   *
+   * @return the peak live thread count.
+   * @see #resetPeakThreadCount()
+   */
+  int getPeakThreadCount();
+
+  /**
+   * Returns the number of live threads, including
+   * both daemon threads and non-daemon threads.
+   *
+   * @return the current number of live threads.
+   */
+  int getThreadCount();
+
+  /**
+   * <p>
+   * Returns the total number of nanoseconds of CPU time
+   * the specified thread has used.  
+   * </p> 
+   * <p>
+   * Note that the value is only nanosecond-precise, and not accurate; there
+   * is no guarantee that the difference between two values is really a
+   * nanosecond.  Also, the value is prone to overflow if the offset
+   * exceeds 2^63.  The use of this method depends on virtual machine
+   * support for measurement of the CPU time of the current thread,
+   * and on this functionality being enabled.
+   * </p>
+   *
+   * @param id the thread identifier of the thread whose CPU time is being
+   *           monitored.
+   * @return the total number of nanoseconds of CPU time the specified
+   *         thread has used, or -1 if CPU time monitoring is disabled.
+   * @throws IllegalArgumentException if <code>id</code> <= 0.
+   * @throws UnsupportedOperationException if CPU time monitoring is not
+   *                                       supported.
+   * @see #getThreadUserTime(long)
+   * @see #isThreadCpuTimeSupported()
+   * @see #isThreadCpuTimeEnabled()
+   * @see #setThreadCpuTimeEnabled(boolean)
+   */
+  long getThreadCpuTime(long id);
+
+  /**
+   * Returns information on the specified thread without any
+   * stack trace information.  This is equivalent to
+   * <code>{@link #getThreadInfo}(id, 0)</code>.  If the
+   * identifier specifies a thread which is either non-existant
+   * or not alive, then the method returns <code>null</code>.
+   * 
+   * @param id the identifier of the thread to return information
+   *           on.
+   * @return a {@link ThreadInfo} object pertaining to the specified
+   *         thread, or <code>null</code> if the identifier specifies
+   *         a thread that doesn't exist or is not alive.
+   * @throws IllegalArgumentException if <code>id</code> <= 0.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("monitor").
+   */
+  ThreadInfo getThreadInfo(long id);
+
+  /**
+   * Returns information on the specified threads without any
+   * stack trace information.  This is equivalent to
+   * <code>{@link #getThreadInfo}(ids, 0)</code>.  If an
+   * identifier specifies a thread which is either non-existant
+   * or not alive, then the corresponding element in the returned
+   * array is <code>null</code>.
+   * 
+   * @param ids an array of thread identifiers to return information
+   *           on.
+   * @return an array of {@link ThreadInfo} objects matching the
+   *         specified threads.  The corresponding element is 
+   *         <code>null</code> if the identifier specifies
+   *         a thread that doesn't exist or is not alive.
+   * @throws IllegalArgumentException if an identifier in the array is
+   *                                  <= 0.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("monitor").
+   */
+  ThreadInfo[] getThreadInfo(long[] ids);
+
+  /**
+   * Returns information on the specified thread with
+   * stack trace information to the supplied depth.  If the
+   * identifier specifies a thread which is either non-existant
+   * or not alive, then the method returns <code>null</code>.
+   * A maximum depth of 0 corresponds to an empty stack trace
+   * (an empty array is returned by the appropriate
+   * {@link ThreadInfo} method).  A maximum depth of
+   * <code>Integer.MAX_VALUE</code> returns the full stack trace.
+   *
+   * @param id the identifier of the thread to return information
+   *           on.
+   * @param maxDepth the maximum depth of the stack trace.
+   *                 Values of 0 or <code>Integer.MAX_VALUE</code>
+   *                 correspond to an empty and full stack trace
+   *                 respectively.
+   * @return a {@link ThreadInfo} object pertaining to the specified
+   *         thread, or <code>null</code> if the identifier specifies
+   *         a thread that doesn't exist or is not alive.
+   * @throws IllegalArgumentException if <code>id</code> <= 0.
+   * @throws IllegalArgumentException if <code>maxDepth</code> < 0.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("monitor").
+   */
+  ThreadInfo getThreadInfo(long id, int maxDepth);
+
+  /**
+   * Returns information on the specified threads with
+   * stack trace information to the supplied depth.  If an
+   * identifier specifies a thread which is either non-existant
+   * or not alive, then the corresponding element in the returned
+   * array is <code>null</code>.  A maximum depth of 0 corresponds
+   * to an empty stack trace (an empty array is returned by the
+   * appropriate {@link ThreadInfo} method).  A maximum depth of
+   * <code>Integer.MAX_VALUE</code> returns the full stack trace.
+   * 
+   * @param ids an array of thread identifiers to return information
+   *           on.
+   * @param maxDepth the maximum depth of the stack trace.
+   *                 Values of 0 or <code>Integer.MAX_VALUE</code>
+   *                 correspond to an empty and full stack trace
+   *                 respectively.
+   * @return an array of {@link ThreadInfo} objects matching the
+   *         specified threads.  The corresponding element is 
+   *         <code>null</code> if the identifier specifies
+   *         a thread that doesn't exist or is not alive.
+   * @throws IllegalArgumentException if an identifier in the array is
+   *                                  <= 0.
+   * @throws IllegalArgumentException if <code>maxDepth</code> < 0.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("monitor").
+   */
+  ThreadInfo[] getThreadInfo(long[] ids, int maxDepth);
+
+  /**
+   * <p>
+   * Returns the total number of nanoseconds of CPU time
+   * the specified thread has executed in user mode.  
+   * </p> 
+   * <p>
+   * Note that the value is only nanosecond-precise, and not accurate; there
+   * is no guarantee that the difference between two values is really a
+   * nanosecond.  Also, the value is prone to overflow if the offset
+   * exceeds 2^63.  The use of this method depends on virtual machine
+   * support for measurement of the CPU time of the current thread,
+   * and on this functionality being enabled.
+   * </p>
+   *
+   * @param id the thread identifier of the thread whose CPU time is being
+   *           monitored.
+   * @return the total number of nanoseconds of CPU time the specified
+   *         thread has executed in user mode, or -1 if CPU time monitoring
+   *         is disabled.
+   * @throws IllegalArgumentException if <code>id</code> <= 0.
+   * @throws UnsupportedOperationException if CPU time monitoring is not
+   *                                       supported.
+   * @see #getThreadCpuTime(long)
+   * @see #isThreadCpuTimeSupported()
+   * @see #isThreadCpuTimeEnabled()
+   * @see #setThreadCpuTimeEnabled(boolean)
+   */
+  long getThreadUserTime(long id);
+
+  /**
+   * Returns the total number of threads that have been
+   * created and started during the lifetime of the virtual
+   * machine.
+   *
+   * @return the total number of started threads.
+   */
+  long getTotalStartedThreadCount();
+
+  /**
+   * Returns true if the virtual machine supports the monitoring
+   * of the CPU time used by the current thread.  This is implied
+   * by {@link isThreadCpuTimeSupported()} returning true.
+   *
+   * @return true if monitoring of the CPU time used by the current
+   *         thread is supported by the virtual machine.
+   * @see #isThreadCpuTimeEnabled()
+   * @see #isThreadCpuTimeSupported()
+   * @see #setThreadCpuTimeEnabled(boolean)
+   */
+  boolean isCurrentThreadCpuTimeSupported();
+
+  /**
+   * Returns true if thread contention monitoring is currently
+   * enabled.
+   *
+   * @return true if thread contention monitoring is enabled.
+   * @throws UnsupportedOperationException if the virtual
+   *                                       machine does not
+   *                                       support contention
+   *                                       monitoring.
+   * @see #isThreadContentionMonitoringSupported()
+   * @see #setThreadContentionMonitoringEnabled(boolean)
+   */
+  boolean isThreadContentionMonitoringEnabled();
+
+  /**
+   * Returns true if thread contention monitoring is supported
+   * by the virtual machine.
+   *
+   * @return true if thread contention monitoring is supported
+   *         by the virtual machine.
+   * @see #isThreadContentionMonitoringEnabled()
+   * @see #setThreadContentionMonitoringEnabled(boolean)
+   */
+  boolean isThreadContentionMonitoringSupported();
+
+  /**
+   * Returns true if monitoring of the CPU time used by a thread
+   * is currently enabled.
+   *
+   * @return true if thread CPU time monitoring is enabled.
+   * @throws UnsupportedOperationException if the virtual
+   *                                       machine does not
+   *                                       support CPU time
+   *                                       monitoring.
+   * @see #isCurrentThreadCpuTimeSupported()
+   * @see #isThreadCpuTimeSupported()
+   * @see #setThreadCpuTimeEnabled(boolean)
+   */
+  boolean isThreadCpuTimeEnabled();
+
+  /**
+   * Returns true if the virtual machine supports the monitoring
+   * of the CPU time used by all threads.  This implies
+   * that {@link isCurrentThreadCpuTimeSupported()} returns true.
+   *
+   * @return true if monitoring of the CPU time used by the current
+   *         thread is supported by the virtual machine.
+   * @see #isCurrentThreadCpuTimeSupported()
+   * @see #isThreadCpuTimeEnabled()
+   * @see #setThreadCpuTimeEnabled(boolean)
+   */
+  boolean isThreadCpuTimeSupported();
+
+  /**
+   * Resets the peak live thread count to the
+   * current number of live threads, as returned
+   * by {@link #getThreadCount()}.
+   *
+   * @see #getPeakThreadCount()
+   * @see #getThreadCount()
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("control").
+   */
+  void resetPeakThreadCount();
+
+  /**
+   * Toggles the monitoring of thread contention.  Thread
+   * contention monitoring is disabled by default.  Each
+   * time contention monitoring is re-enabled, the times
+   * it maintains are reset.
+   *
+   * @param enable true if monitoring should be enabled,
+   *               false if it should be disabled.
+   * @throws UnsupportedOperationException if the virtual
+   *                                       machine does not
+   *                                       support contention
+   *                                       monitoring.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("control").
+   * @see #isThreadContentionMonitoringEnabled()
+   * @see #isThreadContentionMonitoringSupported()
+   */
+  void setThreadContentionMonitoringEnabled(boolean enable);
+
+  /**
+   * Toggles the monitoring of CPU time used by threads. The
+   * initial setting is dependent on the underlying virtual
+   * machine.  On enabling CPU time monitoring, the virtual
+   * machine may take any value up to and including the current
+   * time as the start time for monitoring.
+   *
+   * @param enable true if monitoring should be enabled,
+   *               false if it should be disabled.
+   * @throws UnsupportedOperationException if the virtual
+   *                                       machine does not
+   *                                       support CPU time
+   *                                       monitoring.
+   * @throws SecurityException if a security manager exists and
+   *                           denies ManagementPermission("control").
+   * @see #isCurrentThreadCpuTimeSupported()
+   * @see #isThreadCpuTimeEnabled()
+   * @see #isThreadCpuTimeSupported()
+   */
+  void setThreadCpuTimeEnabled(boolean enable);
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/management/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.lang.management package.
+   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. -->
+
+<html>
+<head><title>GNU Classpath - java.lang.management</title></head>
+
+<body>
+
+<p>
+A series of management beans which provide access to information about the
+virtual machine and its underlying operating system.
+</p>
+<p>The following beans are provided:</p> 
+<ul>
+<li>
+<span style="font-weight: bold;">{@link java.lang.management.OperatingSystemMXBean} </span>
+— Information about the underlying operating system.
+</li> 
+</ul>
+<h2>Accessing the Beans</h2>
+<p>
+An instance of a bean can be obtained by using one of the following methods:
+</p>
+<ol>
+<li>Calling the appropriate static method of the {@link java.lang.management.ManagementFactory}
+</li>
+</ol>
+</body>
+</html>

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/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.lang 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.lang</title></head>
+
+<body>
+<p>Core classes including wrappers for primitive types, classes, packages
+and class loaders, representations of the system, processes, threads and
+the core exception hierarchy.</p>
+
+</body>
+</html>

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ref/PhantomReference.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ref/PhantomReference.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* java.lang.ref.PhantomReference
+   Copyright (C) 1999 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.lang.ref;
+
+/**
+ * A phantom reference is useful, to get notified, when an object got
+ * finalized.  You can't access that object though, since it is
+ * finalized.  This is the reason, why <code>get()</code> always
+ * returns null.
+ *
+ * @author Jochen Hoenicke 
+ */
+public class PhantomReference 
+  extends Reference
+{
+  /**
+   * Creates a new phantom reference.
+   * @param referent the object that should be watched.
+   * @param q the queue that should be notified, if the referent was
+   * finalized.  This mustn't be <code>null</code>.
+   * @exception NullPointerException if q is null.
+   */
+  public PhantomReference(Object referent, ReferenceQueue q)
+  {
+    super(referent, q);
+  }
+  
+  /**
+   * Returns the object, this reference refers to.
+   * @return <code>null</code>, since the refered object may be
+   * finalized and thus not accessible.  
+   */
+  public Object get()
+  {
+    return null;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ref/Reference.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ref/Reference.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,177 @@
+/* java.lang.ref.Reference
+   Copyright (C) 1999, 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.lang.ref;
+
+/**
+ * This is the base class of all references.  A reference allows
+ * refering to an object without preventing the garbage collector to
+ * collect it.  The only way to get the referred object is via the
+ * <code>get()</code>-method.  This method will return
+ * <code>null</code> if the object was collected. <br>
+ *
+ * A reference may be registered with a queue.  When a referred
+ * element gets collected the reference will be put on the queue, so
+ * that you will be notified. <br>
+ *
+ * There are currently three types of references:  soft reference,
+ * weak reference and phantom reference. <br>
+ *
+ * Soft references will be cleared if the garbage collector is told
+ * to free some memory and there are no unreferenced or weakly referenced
+ * objects.  It is useful for caches. <br>
+ *
+ * Weak references will be cleared as soon as the garbage collector
+ * determines that the refered object is only weakly reachable.  They
+ * are useful as keys in hashtables (see <code>WeakHashtable</code>) as
+ * you get notified when nobody has the key anymore.
+ *
+ * Phantom references don't prevent finalization.  If an object is only
+ * phantom reachable, it will be finalized, and the reference will be
+ * enqueued, but not cleared.  Since you mustn't access an finalized
+ * object, the <code>get</code> method of a phantom reference will never
+ * work.  It is useful to keep track, when an object is finalized.
+ *
+ * @author Jochen Hoenicke
+ * @see java.util.WeakHashMap
+ */
+public abstract class Reference
+{
+  /**
+   * The underlying object.  This field is handled in a special way by
+   * the garbage collector.
+   */
+  Object referent;
+
+  /**
+   * The queue this reference is registered on. This is null, if this
+   * wasn't registered to any queue or reference was already enqueued.
+   */
+  ReferenceQueue queue;
+
+  /**
+   * Link to the next entry on the queue.  If this is null, this
+   * reference is not enqueued.  Otherwise it points to the next
+   * reference.  The last reference on a queue will point to itself
+   * (not to null, that value is used to mark a not enqueued
+   * reference).  
+   */
+  Reference nextOnQueue;
+
+  /**
+   * This lock should be taken by the garbage collector, before
+   * determining reachability.  It will prevent the get()-method to
+   * return the reference so that reachability doesn't change.
+   */
+  static Object lock = new Object();
+
+  /**
+   * Creates a new reference that is not registered to any queue.
+   * Since it is package private, it is not possible to overload this
+   * class in a different package.  
+   * @param ref the object we refer to.
+   */
+  Reference(Object ref)
+  {
+    referent = ref;
+  }
+
+  /**
+   * Creates a reference that is registered to a queue.  Since this is
+   * package private, it is not possible to overload this class in a
+   * different package.  
+   * @param ref the object we refer to.
+   * @param q the reference queue to register on.
+   * @exception NullPointerException if q is null.
+   */
+  Reference(Object ref, ReferenceQueue q)
+  {
+    if (q == null)
+      throw new NullPointerException();
+    referent = ref;
+    queue = q;
+  }
+
+  /**
+   * Returns the object, this reference refers to.
+   * @return the object, this reference refers to, or null if the 
+   * reference was cleared.
+   */
+  public Object get()
+  {
+    synchronized (lock)
+      {
+	return referent;
+      }
+  }
+
+  /**
+   * Clears the reference, so that it doesn't refer to its object
+   * anymore.  For soft and weak references this is called by the
+   * garbage collector.  For phantom references you should call 
+   * this when enqueuing the reference.
+   */
+  public void clear()
+  {
+    referent = null;
+  }
+
+  /**
+   * Tells if the object is enqueued on a reference queue.
+   * @return true if it is enqueued, false otherwise.
+   */
+  public boolean isEnqueued()
+  {
+    return nextOnQueue != null;
+  }
+
+  /**
+   * Enqueue an object on a reference queue.  This is normally executed
+   * by the garbage collector.
+   */
+  public boolean enqueue() 
+  {
+    if (queue != null && nextOnQueue == null)
+      {
+	queue.enqueue(this);
+	queue = null;
+	return true;
+      }
+    return false;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ref/ReferenceQueue.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ref/ReferenceQueue.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,145 @@
+/* java.lang.ref.ReferenceQueue
+   Copyright (C) 1999 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.lang.ref;
+
+/**
+ * This is the queue, where references can enqueue themselve on.  Each
+ * reference may be registered to a queue at initialization time and
+ * will be appended to the queue, when the enqueue method is called.
+ *
+ * The enqueue method may be automatically called by the garbage
+ * collector if it detects, that the object is only reachable through
+ * the Reference objects.
+ *
+ * @author Jochen Hoenicke
+ * @see Reference#enqueue()
+ */
+public class ReferenceQueue
+{
+  /**
+   * This is a linked list of references.  If this is null, the list is
+   * empty.  Otherwise this points to the first reference on the queue.
+   * The first reference will point to the next reference via the 
+   * <code>nextOnQueue</code> field.  The last reference will point to
+   * itself (not to null, since <code>nextOnQueue</code> is used to 
+   * determine if a reference is enqueued).
+   */
+  private Reference first;
+
+  /**
+   * Creates a new empty reference queue.
+   */
+  public ReferenceQueue()
+  {
+  }
+
+  /**
+   * Checks if there is a reference on the queue, returning it
+   * immediately.  The reference will be dequeued.
+   *
+   * @return a reference on the queue, if there is one,
+   * <code>null</code> otherwise.  
+   */
+  public synchronized Reference poll()
+  { 
+    return dequeue();
+  }
+
+  /**
+   * This is called by reference to enqueue itself on this queue.  
+   * @param ref the reference that should be enqueued.
+   */
+  synchronized void enqueue(Reference ref)
+  {
+    /* last reference will point to itself */
+    ref.nextOnQueue = first == null ? ref : first;
+    first = ref;
+    /* this wakes only one remove thread. */
+    notify();
+  }
+
+  /**
+   * Remove a reference from the queue, if there is one.
+   * @return the first element of the queue, or null if there isn't any.
+   */
+  private Reference dequeue()
+  {
+    if (first == null)
+      return null;
+
+    Reference result = first;
+    first = (first == first.nextOnQueue) ? null : first.nextOnQueue;
+    result.nextOnQueue = null;
+    return result;
+  }
+
+  /**
+   * Removes a reference from the queue, blocking for <code>timeout</code>
+   * until a reference is enqueued.
+   * @param timeout the timeout period in milliseconds, <code>0</code> means
+   * wait forever.
+   * @return the reference removed from the queue, or 
+   * <code>null</code> if timeout period expired.  
+   * @exception InterruptedException if the wait was interrupted.
+   */
+  public synchronized Reference remove(long timeout)
+    throws InterruptedException
+  {
+    if (first == null)
+      {
+	wait(timeout);
+      }
+
+    return dequeue();
+  }
+    
+
+  /**
+   * Removes a reference from the queue, blocking until a reference is
+   * enqueued.
+   *
+   * @return the reference removed from the queue.  
+   * @exception InterruptedException if the wait was interrupted.
+   */
+  public Reference remove()
+    throws InterruptedException
+  {
+    return remove(0L);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ref/SoftReference.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ref/SoftReference.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,84 @@
+/* java.lang.ref.SoftReference
+   Copyright (C) 1999 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.lang.ref;
+
+/**
+ * A soft reference will be cleared, if the object is only softly
+ * reachable and the garbage collection needs more memory.  The garbage
+ * collection will use an intelligent strategy to determine which soft
+ * references it should clear.  This makes a soft reference ideal for
+ * caches.<br>
+ *
+ * @author Jochen Hoenicke 
+ */
+public class SoftReference 
+  extends Reference
+{
+  /**
+   * Create a new soft reference, that is not registered to any queue.
+   * @param referent the object we refer to.
+   */
+  public SoftReference(Object referent)
+  {
+    super(referent);
+  }
+
+  /**
+   * Create a new soft reference.
+   * @param referent the object we refer to.
+   * @param q the reference queue to register on.
+   * @exception NullPointerException if q is null.
+   */
+  public SoftReference(Object referent, ReferenceQueue q)
+  {
+    super(referent, q);
+  }
+  
+  /**
+   * Returns the object, this reference refers to.
+   * @return the object, this reference refers to, or null if the 
+   * reference was cleared.
+   */
+  public Object get()
+  {
+    /* Why is this overloaded??? 
+     * Maybe for a kind of LRU strategy. */
+    return super.get();
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ref/WeakReference.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ref/WeakReference.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* java.lang.ref.WeakReference
+   Copyright (C) 1999 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.lang.ref;
+
+/**
+ * A weak reference will be cleared, if the object is only weakly
+ * reachable.  It is useful for lookup tables, where you aren't
+ * interested in an entry, if the key isn't reachable anymore.
+ * <code>WeakHashtable</code> is a complete implementation of such a
+ * table. <br>
+ *
+ * It is also useful to make objects unique: You create a set of weak
+ * references to those objects, and when you create a new object you
+ * look in this set, if the object already exists and return it.  If
+ * an object is not referenced anymore, the reference will
+ * automatically cleared, and you may remove it from the set. <br>
+ *
+ * @author Jochen Hoenicke 
+ * @see java.util.WeakHashMap 
+ */
+public class WeakReference 
+  extends Reference
+{
+  /**
+   * Create a new weak reference, that is not registered to any queue.
+   * @param referent the object we refer to.
+   */
+  public WeakReference(Object referent)
+  {
+    super(referent);
+  }
+
+  /**
+   * Create a new weak reference.
+   * @param referent the object we refer to.
+   * @param q the reference queue to register on.
+   * @exception NullPointerException if q is null.
+   */
+  public WeakReference(Object referent, ReferenceQueue q)
+  {
+    super(referent, q);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ref/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ref/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.lang.ref 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.lang.ref</title></head>
+
+<body>
+<p>Low level manipulation and monitoring of object references.</p>
+
+</body>
+</html>

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/AccessibleObject.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/AccessibleObject.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,184 @@
+/* java.lang.reflect.AccessibleObject
+   Copyright (C) 2001, 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.lang.reflect;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * This class is the superclass of various reflection classes, and
+ * allows sufficiently trusted code to bypass normal restrictions to
+ * do necessary things like invoke private methods outside of the
+ * class during Serialization.  If you don't have a good reason
+ * to mess with this, don't try. Fortunately, there are adequate
+ * security checks before you can set a reflection object as accessible.
+ *
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Field
+ * @see Constructor
+ * @see Method
+ * @see ReflectPermission
+ * @since 1.2
+ * @status updated to 1.5
+ */
+public class AccessibleObject
+    implements AnnotatedElement
+{
+  /**
+   * True if this object is marked accessible, which means the reflected
+   * object bypasses normal security checks.
+   */
+  // default visibility for use by inherited classes
+  boolean flag = false;
+
+  /**
+   * Only the three reflection classes that extend this can create an
+   * accessible object.  This is not serializable for security reasons.
+   */
+  protected AccessibleObject()
+  {
+  }
+
+  /**
+   * Return the accessibility status of this object.
+   *
+   * @return true if this object bypasses security checks
+   */
+  public boolean isAccessible()
+  {
+    return flag;
+  }
+
+  /**
+   * Convenience method to set the flag on a number of objects with a single
+   * security check. If a security manager exists, it is checked for
+   * <code>ReflectPermission("suppressAccessChecks")</code>.<p>
+   *
+   * It is forbidden to set the accessibility flag to true on any constructor
+   * for java.lang.Class. This will result in a SecurityException. If the 
+   * SecurityException is thrown for any of the passed AccessibleObjects,
+   * the accessibility flag will be set on AccessibleObjects in the array prior 
+   * to the one which resulted in the exception.
+   *
+   * @param array the array of accessible objects
+   * @param flag the desired state of accessibility, true to bypass security
+   * @throws NullPointerException if array is null
+   * @throws SecurityException if the request is denied
+   * @see SecurityManager#checkPermission(java.security.Permission)
+   * @see RuntimePermission
+   */
+  public static void setAccessible(AccessibleObject[] array, boolean flag)
+  {
+    checkPermission();
+    for (int i = 0; i < array.length; i++)
+      array[i].secureSetAccessible(flag);
+  }
+
+  /**
+   * Sets the accessibility flag for this reflection object. If a security
+   * manager exists, it is checked for
+   * <code>ReflectPermission("suppressAccessChecks")</code>.<p>
+   *
+   * It is forbidden to set the accessibility flag to true on any constructor for 
+   * java.lang.Class. This will result in a SecurityException.
+   *
+   * @param flag the desired state of accessibility, true to bypass security
+   * @throws NullPointerException if array is null
+   * @throws SecurityException if the request is denied
+   * @see SecurityManager#checkPermission(java.security.Permission)
+   * @see RuntimePermission
+   */
+  public void setAccessible(boolean flag)
+  {
+    checkPermission();
+    secureSetAccessible(flag);
+  }
+
+  /**
+   * Performs the specified security check, for
+   * <code>ReflectPermission("suppressAccessChecks")</code>.
+   *
+   * @throws SecurityException if permission is denied
+   */
+  private static void checkPermission()
+  {
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkPermission(new ReflectPermission("suppressAccessChecks"));
+  }
+
+  /**
+   * Performs the actual accessibility change, this must always be invoked
+   * after calling checkPermission.
+   *
+   * @param flag the desired status
+   * @throws SecurityException if flag is true and this is a constructor
+   * for <code>java.lang.Class</code>.
+   */
+  private void secureSetAccessible(boolean flag)
+  {
+    if (flag &&
+        (this instanceof Constructor
+          && ((Constructor) this).getDeclaringClass() == Class.class))
+      throw new SecurityException("Cannot make object accessible: " + this);
+    this.flag = flag;
+  }
+
+  /* FIXME[GENERICS]: <T extends Annotation> T getAnnotation(Class <T>) */
+  public Annotation getAnnotation(Class annotationClass)
+  {
+    throw new AssertionError("Subclass must override this method");
+  }
+
+  public Annotation[] getAnnotations()
+  {
+    return getDeclaredAnnotations();
+  }
+
+  public Annotation[] getDeclaredAnnotations()
+  {
+    throw new AssertionError("Subclass must override this method");
+  }
+
+  /* FIXME[GENERICS]: Signature is Class<? extends Annotation> */
+  public boolean isAnnotationPresent(Class annotationClass)
+  {
+    return getAnnotation(annotationClass) != null;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/AnnotatedElement.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/AnnotatedElement.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,117 @@
+/* AnnotatedElement.java
+   Copyright (C) 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.lang.reflect;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * <p>
+ * Represents an element that can be annotated.  The methods of this interface
+ * provide reflection-based access to the annotations associated with a
+ * particular element, such as a class, field, method or package.  Each
+ * annotation returned by these methods is both immutable and serializable.
+ * The returned arrays may be freely modified, without any effect on the
+ * arrays returned to future callers.
+ * </p>
+ * <p>
+ * If an annotation refers to a type or enumeration constant that is
+ * inaccessible, then a <code>TypeNotPresentException</code> or
+ * <code>EnumConstantNotPresentException</code> will be thrown.  Likewise,
+ * invalid annotations will produce either a
+ * <code>AnnotationTypeMismatchException</code> or
+ * <code>IncompleteAnnotationException</code>.
+ * </p>
+ * 
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface AnnotatedElement
+{
+
+  /**
+   * Returns the element's annotation for the specified annotation type,
+   * or <code>null</code> if no such annotation exists.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return this element's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @throws NullPointerException if the annotation class is <code>null</code>.
+   */
+  /* FIXME[GENERICS]: <T extends Annotation> T getAnnotation(Class <T>) */
+  Annotation getAnnotation(Class annotationClass);
+
+  /**
+   * Returns all annotations associated with the element.  If there are
+   * no annotations associated with the element, then a zero-length array
+   * will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of the
+   * element, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return this element's annotations.
+   */
+  Annotation[] getAnnotations();
+
+  /**
+   * Returns all annotations directly defined by the element.  If there are
+   * no annotations directly associated with the element, then a zero-length
+   * array will be returned.  The returned array may be modified by the client
+   * code, but this will have no effect on the annotation content of this
+   * class, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by the element.
+   * @since 1.5
+   */
+  Annotation[] getDeclaredAnnotations();
+
+  /**
+   * Returns true if an annotation for the specified type is associated
+   * with the element.  This is primarily a short-hand for using marker
+   * annotations.
+   *
+   * @param annotationClass the type of annotation to look for.
+   * @return true if an annotation exists for the specified type.
+   * @since 1.5
+   */
+  /* FIXME[GENERICS]: Signature is Class<? extends Annotation> */
+  boolean isAnnotationPresent(Class annotationClass);
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/Array.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/Array.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,656 @@
+/* java.lang.reflect.Array - manipulate arrays by reflection
+   Copyright (C) 1998, 1999, 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.lang.reflect;
+
+/**
+ * Array holds static helper functions that allow you to create and
+ * manipulate arrays by reflection. Operations know how to perform widening
+ * conversions, but throw {@link IllegalArgumentException} if you attempt
+ * a narrowing conversion. Also, when accessing primitive arrays, this
+ * class performs object wrapping and unwrapping as necessary.<p>
+ *
+ * <B>Note:</B> This class returns and accepts types as Classes, even
+ * primitive types; there are Class types defined that represent each
+ * different primitive type.  They are <code>java.lang.Boolean.TYPE,
+ * java.lang.Byte.TYPE,</code>, also available as <code>boolean.class,
+ * byte.class</code>, etc.  These are not to be confused with the
+ * classes <code>java.lang.Boolean, java.lang.Byte</code>, etc., which are
+ * real classes. Note also that the shorthand <code>Object[].class</code>
+ * is a convenient way to get array Classes.<p>
+ *
+ * <B>Performance note:</B> This class performs best when it does not have
+ * to convert primitive types.  The further along the chain it has to convert,
+ * the worse performance will be.  You're best off using the array as whatever
+ * type it already is, and then converting the result.  You will do even
+ * worse if you do this and use the generic set() function.
+ *
+ * @author John Keiser
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @author Per Bothner (bothner at cygnus.com)
+ * @see java.lang.Boolean#TYPE
+ * @see java.lang.Byte#TYPE
+ * @see java.lang.Short#TYPE
+ * @see java.lang.Character#TYPE
+ * @see java.lang.Integer#TYPE
+ * @see java.lang.Long#TYPE
+ * @see java.lang.Float#TYPE
+ * @see java.lang.Double#TYPE
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public final class Array
+{
+
+  /**
+   * This class is uninstantiable.
+   */
+  private Array()
+  {
+  }
+
+  /**
+   * Creates a new single-dimensioned array.
+   * @param componentType the type of the array to create
+   * @param length the length of the array to create
+   * @return the created array, cast to an Object
+   * @throws NullPointerException if <code>componentType</code> is null
+   * @throws IllegalArgumentException if <code>componentType</code> is
+   *         <code>Void.TYPE</code>
+   * @throws NegativeArraySizeException when length is less than 0
+   * @throws OutOfMemoryError if memory allocation fails
+   */
+  public static Object newInstance(Class componentType, int length)
+  {
+    if (! componentType.isPrimitive())
+      return VMArray.createObjectArray(componentType, length);
+    if (componentType == boolean.class)
+      return new boolean[length];
+    if (componentType == byte.class)
+      return new byte[length];
+    if (componentType == char.class)
+      return new char[length];
+    if (componentType == short.class)
+      return new short[length];
+    if (componentType == int.class)
+      return new int[length];
+    if (componentType == long.class)
+      return new long[length];
+    if (componentType == float.class)
+      return new float[length];
+    if (componentType == double.class)
+      return new double[length];
+    // assert componentType == void.class
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * Creates a new multi-dimensioned array.  The new array has the same
+   * component type as the argument class, and the number of dimensions
+   * in the new array is the sum of the dimensions of the argument class
+   * and the length of the argument dimensions. Virtual Machine limitations
+   * forbid too many dimensions (usually 255 is the maximum); but even
+   * 50 dimensions of 2 elements in each dimension would exceed your memory
+   * long beforehand!
+   *
+   * @param componentType the type of the array to create.
+   * @param dimensions the dimensions of the array to create.  Each element
+   *        in <code>dimensions</code> makes another dimension of the new
+   *        array.  Thus, <code>Array.newInstance(java.lang.Boolean,
+   *        new int[]{1,2,3})</code> is the same as
+   *        <code>new java.lang.Boolean[1][2][3]</code>
+   * @return the created array, cast to an Object
+   * @throws NullPointerException if componentType or dimension is null
+   * @throws IllegalArgumentException if the the size of
+   *         <code>dimensions</code> is 0 or exceeds the maximum number of
+   *         array dimensions in the VM; or if componentType is Void.TYPE
+   * @throws NegativeArraySizeException when any of the dimensions is less
+   *         than 0
+   * @throws OutOfMemoryError if memory allocation fails
+   */
+  public static Object newInstance(Class componentType, int[] dimensions)
+  {
+    if (dimensions.length <= 0)
+      throw new IllegalArgumentException ("Empty dimensions array.");
+    return createMultiArray(componentType, dimensions,
+                                  dimensions.length - 1);
+  }
+
+  /**
+   * Gets the array length.
+   * @param array the array
+   * @return the length of the array
+   * @throws IllegalArgumentException if <code>array</code> is not an array
+   * @throws NullPointerException if <code>array</code> is null
+   */
+  public static int getLength(Object array)
+  {
+    if (array instanceof Object[])
+      return ((Object[]) array).length;
+    if (array instanceof boolean[])
+      return ((boolean[]) array).length;
+    if (array instanceof byte[])
+      return ((byte[]) array). length;
+    if (array instanceof char[])
+      return ((char[]) array).length;
+    if (array instanceof short[])
+      return ((short[]) array).length;
+    if (array instanceof int[])
+      return ((int[]) array).length;
+    if (array instanceof long[])
+      return ((long[]) array).length;
+    if (array instanceof float[])
+      return ((float[]) array).length;
+    if (array instanceof double[])
+      return ((double[]) array).length;
+    if (array == null)
+      throw new NullPointerException();
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * Gets an element of an array.  Primitive elements will be wrapped in
+   * the corresponding class type.
+   *
+   * @param array the array to access
+   * @param index the array index to access
+   * @return the element at <code>array[index]</code>
+   * @throws IllegalArgumentException if <code>array</code> is not an array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #getBoolean(Object, int)
+   * @see #getByte(Object, int)
+   * @see #getChar(Object, int)
+   * @see #getShort(Object, int)
+   * @see #getInt(Object, int)
+   * @see #getLong(Object, int)
+   * @see #getFloat(Object, int)
+   * @see #getDouble(Object, int)
+   */
+  public static Object get(Object array, int index)
+  {
+    if (array instanceof Object[])
+      return ((Object[]) array)[index];
+    if (array instanceof boolean[])
+      return ((boolean[]) array)[index] ? Boolean.TRUE : Boolean.FALSE;
+    if (array instanceof byte[])
+      return new Byte(((byte[]) array)[index]);
+    if (array instanceof char[])
+      return new Character(((char[]) array)[index]);
+    if (array instanceof short[])
+      return new Short(((short[]) array)[index]);
+    if (array instanceof int[])
+      return new Integer(((int[]) array)[index]);
+    if (array instanceof long[])
+      return new Long(((long[]) array)[index]);
+    if (array instanceof float[])
+      return new Float(((float[]) array)[index]);
+    if (array instanceof double[])
+      return new Double(((double[]) array)[index]);
+    if (array == null)
+      throw new NullPointerException();
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * Gets an element of a boolean array.
+   *
+   * @param array the array to access
+   * @param index the array index to access
+   * @return the boolean element at <code>array[index]</code>
+   * @throws IllegalArgumentException  if <code>array</code> is not a boolean
+   *         array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #get(Object, int)
+   */
+  public static boolean getBoolean(Object array, int index)
+  {
+    if (array instanceof boolean[])
+      return ((boolean[]) array)[index];
+    if (array == null)
+      throw new NullPointerException();
+    throw new IllegalArgumentException();
+  }
+  
+  /**
+   * Gets an element of a byte array.
+   *
+   * @param array the array to access
+   * @param index the array index to access
+   * @return the byte element at <code>array[index]</code>
+   * @throws IllegalArgumentException  if <code>array</code> is not a byte
+   *         array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #get(Object, int)
+   */
+  public static byte getByte(Object array, int index)
+  {
+    if (array instanceof byte[])
+      return ((byte[]) array)[index];
+    if (array == null)
+      throw new NullPointerException();
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * Gets an element of a char array.
+   *
+   * @param array the array to access
+   * @param index the array index to access
+   * @return the char element at <code>array[index]</code>
+   * @throws IllegalArgumentException  if <code>array</code> is not a char
+   *         array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #get(Object, int)
+   */
+  public static char getChar(Object array, int index)
+  {
+    if (array instanceof char[])
+      return ((char[]) array)[index];
+    if (array == null)
+      throw new NullPointerException();
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * Gets an element of a short array.
+   *
+   * @param array the array to access
+   * @param index the array index to access
+   * @return the short element at <code>array[index]</code>
+   * @throws IllegalArgumentException  if <code>array</code> is not a byte
+   *         or char array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #get(Object, int)
+   */
+  public static short getShort(Object array, int index)
+  {
+    if (array instanceof short[])
+      return ((short[]) array)[index];
+    return getByte(array, index);
+  }
+
+  /**
+   * Gets an element of an int array.
+   *
+   * @param array the array to access
+   * @param index the array index to access
+   * @return the int element at <code>array[index]</code>
+   * @throws IllegalArgumentException  if <code>array</code> is not a byte,
+   *         char, short, or int array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #get(Object, int)
+   */
+  public static int getInt(Object array, int index)
+  {
+    if (array instanceof int[])
+      return ((int[]) array)[index];
+    if (array instanceof char[])
+      return ((char[]) array)[index];
+    return getShort(array, index);
+  }
+
+  /**
+   * Gets an element of a long array.
+   *
+   * @param array the array to access
+   * @param index the array index to access
+   * @return the long element at <code>array[index]</code>
+   * @throws IllegalArgumentException  if <code>array</code> is not a byte,
+   *         char, short, int, or long array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #get(Object, int)
+   */
+  public static long getLong(Object array, int index)
+  {
+    if (array instanceof long[])
+      return ((long[]) array)[index];
+    return getInt(array, index);
+  }
+
+  /**
+   * Gets an element of a float array.
+   *
+   * @param array the array to access
+   * @param index the array index to access
+   * @return the float element at <code>array[index]</code>
+   * @throws IllegalArgumentException  if <code>array</code> is not a byte,
+   *         char, short, int, long, or float array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #get(Object, int)
+   */
+  public static float getFloat(Object array, int index)
+  {
+    if (array instanceof float[])
+      return ((float[]) array)[index];
+    return getLong(array, index);
+  }
+
+  /**
+   * Gets an element of a double array.
+   *
+   * @param array the array to access
+   * @param index the array index to access
+   * @return the double element at <code>array[index]</code>
+   * @throws IllegalArgumentException  if <code>array</code> is not a byte,
+   *         char, short, int, long, float, or double array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #get(Object, int)
+   */
+  public static double getDouble(Object array, int index)
+  {
+    if (array instanceof double[])
+      return ((double[]) array)[index];
+    return getFloat(array, index);
+  }
+
+  /**
+   * Sets an element of an array. If the array is primitive, then the new
+   * value is unwrapped and widened.
+   *
+   * @param array the array to set a value of
+   * @param index the array index to set the value to
+   * @param value the value to set
+   * @throws IllegalArgumentException if <code>array</code> is not an array,
+   *         or the array is primitive and unwrapping value fails, or the
+   *         value is not assignable to the array component type
+   * @throws NullPointerException if array is null, or if array is primitive
+   *         and value is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #setBoolean(Object, int, boolean)
+   * @see #setByte(Object, int, byte)
+   * @see #setChar(Object, int, char)
+   * @see #setShort(Object, int, short)
+   * @see #setInt(Object, int, int)
+   * @see #setLong(Object, int, long)
+   * @see #setFloat(Object, int, float)
+   * @see #setDouble(Object, int, double)
+   */
+  public static void set(Object array, int index, Object value)
+  {
+    if (array instanceof Object[])
+      {
+	// Too bad the API won't let us throw the easier ArrayStoreException!
+	if (value != null
+	    && ! array.getClass().getComponentType().isInstance(value))
+	  throw new IllegalArgumentException();
+	((Object[]) array)[index] = value;
+      }
+    else if (value instanceof Byte)
+      setByte(array, index, ((Byte) value).byteValue());
+    else if (value instanceof Short)
+      setShort(array, index, ((Short) value).shortValue());
+    else if (value instanceof Integer)
+      setInt(array, index, ((Integer) value).intValue());
+    else if (value instanceof Long)
+      setLong(array, index, ((Long) value).longValue());
+    else if (value instanceof Float)
+      setFloat(array, index, ((Float) value).floatValue());
+    else if (value instanceof Double)
+      setDouble(array, index, ((Double) value).doubleValue());
+    else if (value instanceof Character)
+      setChar(array, index, ((Character) value).charValue());
+    else if (value instanceof Boolean)
+      setBoolean(array, index, ((Boolean) value).booleanValue());
+    else if (array == null)
+      throw new NullPointerException();
+    else
+      throw new IllegalArgumentException();
+  }
+
+  /**
+   * Sets an element of a boolean array.
+   *
+   * @param array the array to set a value of
+   * @param index the array index to set the value to
+   * @param value the value to set
+   * @throws IllegalArgumentException if <code>array</code> is not a boolean
+   *         array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #set(Object, int, Object)
+   */
+  public static void setBoolean(Object array, int index, boolean value)
+  {
+    if (array instanceof boolean[])
+      ((boolean[]) array)[index] = value;
+    else if (array == null)
+      throw new NullPointerException();
+    else
+      throw new IllegalArgumentException();
+  }
+
+  /**
+   * Sets an element of a byte array.
+   *
+   * @param array the array to set a value of
+   * @param index the array index to set the value to
+   * @param value the value to set
+   * @throws IllegalArgumentException if <code>array</code> is not a byte,
+   *         short, int, long, float, or double array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #set(Object, int, Object)
+   */
+  public static void setByte(Object array, int index, byte value)
+  {
+    if (array instanceof byte[])
+      ((byte[]) array)[index] = value;
+    else
+      setShort(array, index, value);
+  }
+
+  /**
+   * Sets an element of a char array.
+   *
+   * @param array the array to set a value of
+   * @param index the array index to set the value to
+   * @param value the value to set
+   * @throws IllegalArgumentException if <code>array</code> is not a char,
+   *         int, long, float, or double array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #set(Object, int, Object)
+   */
+  public static void setChar(Object array, int index, char value)
+  {
+    if (array instanceof char[])
+      ((char[]) array)[index] = value;
+    else
+      setInt(array, index, value);
+  }
+
+  /**
+   * Sets an element of a short array.
+   *
+   * @param array the array to set a value of
+   * @param index the array index to set the value to
+   * @param value the value to set
+   * @throws IllegalArgumentException if <code>array</code> is not a short,
+   *         int, long, float, or double array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #set(Object, int, Object)
+   */
+  public static void setShort(Object array, int index, short value)
+  {
+    if (array instanceof short[])
+      ((short[]) array)[index] = value;
+    else
+      setInt(array, index, value);
+  }
+
+  /**
+   * Sets an element of an int array.
+   *
+   * @param array the array to set a value of
+   * @param index the array index to set the value to
+   * @param value the value to set
+   * @throws IllegalArgumentException if <code>array</code> is not an int,
+   *         long, float, or double array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #set(Object, int, Object)
+   */
+  public static void setInt(Object array, int index, int value)
+  {
+    if (array instanceof int[])
+      ((int[]) array)[index] = value;
+    else
+      setLong(array, index, value);
+  }
+
+  /**
+   * Sets an element of a long array.
+   *
+   * @param array the array to set a value of
+   * @param index the array index to set the value to
+   * @param value the value to set
+   * @throws IllegalArgumentException if <code>array</code> is not a long,
+   *         float, or double array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #set(Object, int, Object)
+   */
+  public static void setLong(Object array, int index, long value)
+  {
+    if (array instanceof long[])
+      ((long[]) array)[index] = value;
+    else
+      setFloat(array, index, value);
+  }
+
+  /**
+   * Sets an element of a float array.
+   *
+   * @param array the array to set a value of
+   * @param index the array index to set the value to
+   * @param value the value to set
+   * @throws IllegalArgumentException if <code>array</code> is not a float
+   *         or double array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #set(Object, int, Object)
+   */
+  public static void setFloat(Object array, int index, float value)
+  {
+    if (array instanceof float[])
+      ((float[]) array)[index] = value;
+    else
+      setDouble(array, index, value);
+  }
+
+  /**
+   * Sets an element of a double array.
+   *
+   * @param array the array to set a value of
+   * @param index the array index to set the value to
+   * @param value the value to set
+   * @throws IllegalArgumentException if <code>array</code> is not a double
+   *         array
+   * @throws NullPointerException if <code>array</code> is null
+   * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+   *         bounds
+   * @see #set(Object, int, Object)
+   */
+  public static void setDouble(Object array, int index, double value)
+  {
+    if (array instanceof double[])
+      ((double[]) array)[index] = value;
+    else if (array == null)
+      throw new NullPointerException();
+    else
+      throw new IllegalArgumentException();
+  }
+
+  /**
+   * Dynamically and recursively create a multi-dimensioned array of objects.
+   *
+   * @param type guaranteed to be a valid object type
+   * @param dimensions the dimensions of the array
+   * @param index index of the current dimension to build
+   * @return the new multi-dimensioned array
+   * @throws NegativeArraySizeException if any entry of dimensions is negative
+   * @throws OutOfMemoryError if memory allocation fails
+   */
+  // This would be faster if implemented natively, using the multianewarray
+  // bytecode instead of this recursive call
+  private static Object createMultiArray(Class type, int[] dimensions,
+                                         int index)
+  {
+    if (index == 0)
+      return newInstance(type, dimensions[0]);
+
+    Object toAdd = createMultiArray(type, dimensions, index - 1);
+    Class thisType = toAdd.getClass();
+    Object[] retval
+      = (Object[]) VMArray.createObjectArray(thisType, dimensions[index]);
+    if (dimensions[index] > 0)
+      retval[0] = toAdd;
+    int i = dimensions[index];
+    while (--i > 0)
+      retval[i] = createMultiArray(type, dimensions, index - 1);
+    return retval;
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/GenericArrayType.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/GenericArrayType.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,61 @@
+/* GenericArrayType.java - Represent an array type with a generic component
+   Copyright (C) 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.lang.reflect;
+
+/**
+ * Represents the type of an array's components, which may be
+ * either a parameterized type or a type variable.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface GenericArrayType 
+  extends Type
+{
+
+  /**
+   * Returns the <code>Type</code> of the components within the array.
+   *
+   * @return a <code>Type</code> instance representing the type of
+   *         the array's components.
+   */
+  Type getGenericComponentType();
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/GenericDeclaration.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/GenericDeclaration.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* GenericDeclaration.java
+   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 java.lang.reflect;
+
+/**
+ * Represents an entity that declares one or more type parameters.
+ * This includes classes and methods (including constructors).
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface GenericDeclaration
+{
+  /**
+   * Returns a <code>TypeVariable</code> object for each type variable
+   * declared by this entity, in order of declaration.  An empty array
+   * is returned if no type variables are declared.
+   * 
+   * @return an array of <code>TypeVariable</code> objects.
+   * @throws GenericSignatureFormatError if the signature format within the
+   *         class file does not conform to that specified in the 3rd edition
+   *         of the Java Virtual Machine Specification.
+   */
+  /* FIXME[GENERICS]: Should be TypeVariable<?>[] */
+  TypeVariable[] getTypeParameters();
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/GenericSignatureFormatError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/GenericSignatureFormatError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* GenericSignatureFormatError.java - Thrown when a signature is malformed.
+   Copyright (C) 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.lang.reflect;
+
+/**
+ * Thrown on encountering a syntactically malformed signature in
+ * a reflective method.  During reflection, the generic type signature
+ * of a type, method or constructor may be interpreted by the virtual
+ * machine.  This error is thrown if this operation fails.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public class GenericSignatureFormatError
+  extends ClassFormatError
+{
+  private static final long serialVersionUID = 6709919147137911034L;
+
+  /**
+   * Constructs a new <code>GenericSignatureFormatError</code>.
+   */
+  public GenericSignatureFormatError()
+  {
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/InvocationHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/InvocationHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,137 @@
+/* java.lang.reflect.InvocationHandler - dynamically executes methods in
+   proxy instances
+   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.lang.reflect;
+
+/**
+ * This interface defines an invocation handler.  Suppose you are using
+ * reflection, and found a method that requires that its parameter
+ * be an object of a given interface.  You want to call this method,
+ * but have no idea what classes implement that interface.  So, you can
+ * create a {@link Proxy} instance, a convenient way to dynamically
+ * generate a class that meets all the necessary properties of that
+ * interface.  But in order for the proxy instance to do any good, it
+ * needs to know what to do when interface methods are invoked!  So,
+ * this interface is basically a cool wrapper that provides runtime
+ * code generation needed by proxy instances.
+ *
+ * <p>While this interface was designed for use by Proxy, it will also
+ * work on any object in general.</p>
+ *
+ * <p>Hints for implementing this class:</p>
+ * 
+ * <ul>
+ * <li>Don't forget that Object.equals, Object.hashCode, and
+ *     Object.toString will call this handler.  In particular,
+ *     a naive call to proxy.equals, proxy.hashCode, or proxy.toString
+ *     will put you in an infinite loop.  And remember that string
+ *     concatenation also invokes toString.</li>
+ * <li>Obey the contract of the Method object you are handling, or
+ *     the proxy instance will be forced to throw a
+ *     {@link NullPointerException}, {@link ClassCastException},
+ *     or {@link UndeclaredThrowableException}.</li>
+ * <li>Be prepared to wrap/unwrap primitives as necessary.</li>
+ * <li>The Method object may be owned by a different interface than
+ *     what was actually used as the qualifying type of the method
+ *     invocation in the Java source code. This means that it might
+ *     not always be safe to throw an exception listed as belonging
+ *     to the method's throws clause.</li>
+ * </ul>
+ *
+ * <p><small>For a fun time, create an InvocationHandler that handles the
+ * methods of a proxy instance of the InvocationHandler interface!</small></p>
+ *
+ * @see Proxy
+ * @see UndeclaredThrowableException
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.3
+ * @status updated to 1.4
+ */
+public interface InvocationHandler
+{
+  /**
+   * When a method is invoked on a proxy instance, it is wrapped and
+   * this method is called instead, so that you may decide at runtime
+   * how the original method should behave.
+   *
+   * @param proxy the instance that the wrapped method should be
+   *        invoked on.  When this method is called by a Proxy object,
+   *        `proxy' will be an instance of {@link Proxy}, and oddly enough,
+   *        <code>Proxy.getInvocationHandler(proxy)</code> will return
+   *        <code>this</code>!
+   * @param method the reflected method to invoke on the proxy.
+   *        When this method is called by a Proxy object, 'method'
+   *        will be the reflection object owned by the declaring
+   *        class or interface, which may be a supertype of the
+   *        interfaces the proxy directly implements.
+   * @param args the arguments passed to the original method, or
+   *        <code>null</code> if the method takes no arguments.
+   *        (But also be prepared to handle a 0-length array).
+   *        Arguments of primitive type, such as <code>boolean</code>
+   *        or <code>int</code>, are wrapped in the appropriate
+   *        class such as {@link Boolean} or {@link Integer}.
+   * @return whatever is necessary to return from the wrapped method.
+   *         If the wrapped method is <code>void</code>, the proxy
+   *         instance will ignore it.  If the wrapped method returns
+   *         a primitive, this must be the correct wrapper type whose value
+   *         is exactly assignable to the appropriate type (no widening
+   *         will be performed); a null object in this case causes a
+   *         {@link NullPointerException}.  In all remaining cases, if
+   *         the returned object is not assignment compatible to the
+   *         declared type of the original method, the proxy instance
+   *         will generate a {@link ClassCastException}.
+   * @throws Throwable this interface is listed as throwing anything,
+   *         but the implementation should only throw unchecked
+   *         exceptions and exceptions listed in the throws clause of
+   *         all methods being overridden by the proxy instance.  If
+   *         something is thrown that is not compatible with the throws
+   *         clause of all overridden methods, the proxy instance will
+   *         wrap the exception in an UndeclaredThrowableException.
+   *         Note that an exception listed in the throws clause of the
+   *         `method' parameter might not be declared in additional
+   *         interfaces also implemented by the proxy object.
+   *
+   * @see Proxy
+   * @see UndeclaredThrowableException
+   */
+  Object invoke(Object proxy, Method method, Object[] args)
+    throws Throwable;
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/InvocationTargetException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/InvocationTargetException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,123 @@
+/* InvocationTargetException.java -- Wrapper exception for reflection
+   Copyright (C) 1998, 1999, 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 java.lang.reflect;
+
+/**
+ * InvocationTargetException is sort of a way to "wrap" whatever exception
+ * comes up when a method or constructor is called via Reflection. As of
+ * JDK 1.4, it was retrofitted to match the exception chaining of all other
+ * exceptions, but <code>getTargetException()</code> still works.
+ *
+ * @author John Keiser
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Method#invoke(Object,Object[])
+ * @see Constructor#newInstance(Object[])
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class InvocationTargetException extends Exception
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = 4085088731926701167L;
+
+  /**
+   * The chained exception. This field is only around for serial compatibility.
+   *
+   * @serial the chained exception
+   */
+  private final Throwable target;
+
+  /**
+   * Construct an exception with null as the cause. The cause is initialized
+   * to null.
+   */
+  protected InvocationTargetException()
+  {
+    this(null, null);
+  }
+
+  /**
+   * Create an <code>InvocationTargetException</code> using another
+   * exception.
+   *
+   * @param targetException the exception to wrap
+   */
+  public InvocationTargetException(Throwable targetException)
+  {
+    this(targetException, null);
+  }
+
+  /**
+   * Create an <code>InvocationTargetException</code> using another
+   * exception and an error message.
+   *
+   * @param targetException the exception to wrap
+   * @param err an extra reason for the exception-throwing
+   */
+  public InvocationTargetException(Throwable targetException, String err)
+  {
+    super(err, targetException);
+    target = targetException;
+  }
+
+  /**
+   * Get the wrapped (targeted) exception.
+   *
+   * @return the targeted exception
+   * @see #getCause()
+   */
+  public Throwable getTargetException()
+  {
+    return target;
+  }
+
+  /**
+   * Returns the cause of this exception (which may be null).
+   *
+   * @return the cause
+   * @since 1.4
+   */
+  public Throwable getCause()
+  {
+    return target;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/MalformedParameterizedTypeException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/MalformedParameterizedTypeException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,60 @@
+/* MalformedParameterizedTypeException.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.lang.reflect;
+
+/** 
+ * This exception class is thrown when one of the reflection
+ * methods encountered an invalid parameterized type within
+ * the metadata of a class.  One possible reason for this
+ * exception being thrown is the specification of too few or
+ * too many type variables.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5 
+ */
+public class MalformedParameterizedTypeException 
+  extends RuntimeException
+{
+  private static final long serialVersionUID = -5696557788586220964L;
+
+  public MalformedParameterizedTypeException()
+  {
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/Member.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/Member.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,109 @@
+/* java.lang.reflect.Member - common query methods in reflection
+   Copyright (C) 1998, 1999, 2001, 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.lang.reflect;
+
+/**
+ * Member is an interface that represents any member of a class (field or
+ * method) or a constructor. You can get information about the declaring
+ * class, name or modifiers of the member with this interface.
+ *
+ * @author John Keiser
+ * @author Per Bothner (bothner at cygnus.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Class
+ * @see Field
+ * @see Method
+ * @see Constructor
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public interface Member
+{
+  /**
+   * Represents all members, whether public, private, protected or
+   * package-protected, but only which are declared in this class.
+   * Used in SecurityManager.checkMemberAccess() to determine the
+   * type of members to access.
+   * @see SecurityManager#checkMemberAccess(Class, int)
+   */
+  int DECLARED = 1;
+
+  /**
+   * Represents public members only, but includes all inherited members.
+   *  Used in SecurityManager.checkMemberAccess() to determine the type of
+   * members to access.
+   * @see SecurityManager#checkMemberAccess(Class, int)
+   */
+  int PUBLIC = 0;
+
+  /**
+   * Gets the class that declared this member. This is not the class where
+   * this method was called, or even the class where this Member object
+   * came to life, but the class that declares the member this represents.
+   *
+   * @return the class that declared this member
+   */
+  Class getDeclaringClass();
+
+  /**
+   * Gets the simple name of this member. This will be a valid Java
+   * identifier, with no qualification.
+   *
+   * @return the name of this member
+   */
+  String getName();
+
+  /**
+   * Gets the modifiers this member uses.  Use the <code>Modifier</code>
+   * class to interpret the values.
+   *
+   * @return an integer representing the modifiers to this Member
+   * @see Modifier
+   */
+  int getModifiers();
+
+  /**
+   * Return true if this member is synthetic, meaning that it was
+   * created by the compiler and does not appear in the user's
+   * source code.
+   * @return true if the member is synthetic
+   * @since 1.5
+   */
+  boolean isSynthetic();
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/Modifier.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/Modifier.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,364 @@
+/* java.lang.reflect.Modifier
+   Copyright (C) 1998, 1999, 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.lang.reflect;
+
+/**
+ * Modifier is a helper class with static methods to determine whether an
+ * int returned from getModifiers() represents static, public, protected,
+ * native, final, etc... and provides an additional method to print
+ * out all of the modifiers in an int in order.
+ * <p>
+ * The methods in this class use the bitmask values in the VM spec to
+ * determine the modifiers of an int. This means that a VM must return a
+ * standard mask, conformant with the VM spec.  I don't know if this is how
+ * Sun does it, but I'm willing to bet money that it is.
+ *
+ * @author John Keiser
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Member#getModifiers()
+ * @see Method#getModifiers()
+ * @see Field#getModifiers()
+ * @see Constructor#getModifiers()
+ * @see Class#getModifiers()
+ * @since 1.1
+ */
+public class Modifier
+{
+  /** <STRONG>This constructor really shouldn't be here ... there are no
+   * instance methods or variables of this class, so instantiation is
+   * worthless.  However, this function is in the 1.1 spec, so it is added
+   * for completeness.</STRONG>
+   */
+  public Modifier()
+  {
+  }
+
+  /**
+   * Public: accessible from any other class.
+   */
+  public static final int PUBLIC = 0x0001;
+
+  /**
+   * Private: accessible only from the same enclosing class.
+   */
+  public static final int PRIVATE = 0x0002;
+
+  /**
+   * Protected: accessible only to subclasses, or within the package.
+   */
+  public static final int PROTECTED = 0x0004;
+
+  /**
+   * Static:<br><ul>
+   * <li>Class: no enclosing instance for nested class.</li>
+   * <li>Field or Method: can be accessed or invoked without an
+   *     instance of the declaring class.</li>
+   * </ul>
+   */
+  public static final int STATIC = 0x0008;
+
+  /**
+   * Final:<br><ul>
+   * <li>Class: no subclasses allowed.</li>
+   * <li>Field: cannot be changed.</li>
+   * <li>Method: cannot be overriden.</li>
+   * </ul>
+   */
+  public static final int FINAL = 0x0010;
+
+  /**
+   * Synchronized: Method: lock the class while calling this method.
+   */
+  public static final int SYNCHRONIZED = 0x0020;
+
+  /**
+   * Volatile: Field: cannot be cached.
+   */
+  public static final int VOLATILE = 0x0040;
+
+  /**
+   * Transient: Field: not serialized or deserialized.
+   */
+  public static final int TRANSIENT = 0x0080;
+
+  /**
+   * Native: Method: use JNI to call this method.
+   */
+  public static final int NATIVE = 0x0100;
+
+  /**
+   * Interface: Class: is an interface.
+   */
+  public static final int INTERFACE = 0x0200;
+
+  /**
+   * Abstract:<br><ul>
+   * <li>Class: may not be instantiated.</li>
+   * <li>Method: may not be called.</li>
+   * </ul>
+   */
+  public static final int ABSTRACT = 0x0400;
+
+  /**
+   * Strictfp: Method: expressions are FP-strict.<p>
+   * Also used as a modifier for classes, to mean that all initializers
+   * and constructors are FP-strict, but does not show up in
+   * Class.getModifiers.
+   */
+  public static final int STRICT = 0x0800;
+
+
+  /**
+   * Super - treat invokespecial as polymorphic so that super.foo() works
+   * according to the JLS. This is a reuse of the synchronized constant
+   * to patch a hole in JDK 1.0. *shudder*.
+   */
+  static final int SUPER = 0x0020;
+
+  /**
+   * All the flags, only used by code in this package.
+   */
+  static final int ALL_FLAGS = 0xfff;
+
+  /**
+   * Flag indicating a bridge method.
+   */
+  static final int BRIDGE = 0x40;
+
+  /**
+   * Flag indicating a varargs method.
+   */
+  static final int VARARGS = 0x80;
+
+  /**
+   * Flag indicating a synthetic member.
+   */
+  static final int SYNTHETIC = 0x1000;
+
+  /**
+   * Flag indicating an enum constant or an enum class.
+   */
+  static final int ENUM = 0x4000;
+
+  /**
+   * Check whether the given modifier is abstract.
+   * @param mod the modifier.
+   * @return <code>true</code> if abstract, <code>false</code> otherwise.
+   */
+  public static boolean isAbstract(int mod)
+  {
+    return (mod & ABSTRACT) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is final.
+   * @param mod the modifier.
+   * @return <code>true</code> if final, <code>false</code> otherwise.
+   */
+  public static boolean isFinal(int mod)
+  {
+    return (mod & FINAL) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is an interface.
+   * @param mod the modifier.
+   * @return <code>true</code> if an interface, <code>false</code> otherwise.
+   */
+  public static boolean isInterface(int mod)
+  {
+    return (mod & INTERFACE) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is native.
+   * @param mod the modifier.
+   * @return <code>true</code> if native, <code>false</code> otherwise.
+   */
+  public static boolean isNative(int mod)
+  {
+    return (mod & NATIVE) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is private.
+   * @param mod the modifier.
+   * @return <code>true</code> if private, <code>false</code> otherwise.
+   */
+  public static boolean isPrivate(int mod)
+  {
+    return (mod & PRIVATE) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is protected.
+   * @param mod the modifier.
+   * @return <code>true</code> if protected, <code>false</code> otherwise.
+   */
+  public static boolean isProtected(int mod)
+  {
+    return (mod & PROTECTED) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is public.
+   * @param mod the modifier.
+   * @return <code>true</code> if public, <code>false</code> otherwise.
+   */
+  public static boolean isPublic(int mod)
+  {
+    return (mod & PUBLIC) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is static.
+   * @param mod the modifier.
+   * @return <code>true</code> if static, <code>false</code> otherwise.
+   */
+  public static boolean isStatic(int mod)
+  {
+    return (mod & STATIC) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is strictfp.
+   * @param mod the modifier.
+   * @return <code>true</code> if strictfp, <code>false</code> otherwise.
+   */
+  public static boolean isStrict(int mod)
+  {
+    return (mod & STRICT) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is synchronized.
+   * @param mod the modifier.
+   * @return <code>true</code> if synchronized, <code>false</code> otherwise.
+   */
+  public static boolean isSynchronized(int mod)
+  {
+    return (mod & SYNCHRONIZED) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is transient.
+   * @param mod the modifier.
+   * @return <code>true</code> if transient, <code>false</code> otherwise.
+   */
+  public static boolean isTransient(int mod)
+  {
+    return (mod & TRANSIENT) != 0;
+  }
+
+  /**
+   * Check whether the given modifier is volatile.
+   * @param mod the modifier.
+   * @return <code>true</code> if volatile, <code>false</code> otherwise.
+   */
+  public static boolean isVolatile(int mod)
+  {
+    return (mod & VOLATILE) != 0;
+  }
+
+  /**
+   * Get a string representation of all the modifiers represented by the
+   * given int. The keywords are printed in this order:
+   * <code><public|protected|private> abstract static final transient
+   * volatile synchronized native strictfp interface</code>.
+   *
+   * @param mod the modifier.
+   * @return the String representing the modifiers.
+   */
+  public static String toString(int mod)
+  {
+    return toString(mod, new StringBuilder()).toString();
+  }
+
+  /**
+   * Package helper method that can take a StringBuilder.
+   * @param mod the modifier
+   * @param r the StringBuilder to which the String representation is appended
+   * @return r, with information appended
+   */
+  static StringBuilder toString(int mod, StringBuilder r)
+  {
+    r.append(toString(mod, new StringBuffer()));
+    return r;
+  }
+
+  /**
+   * Package helper method that can take a StringBuffer.
+   * @param mod the modifier
+   * @param r the StringBuffer to which the String representation is appended
+   * @return r, with information appended
+   */
+  static StringBuffer toString(int mod, StringBuffer r)
+  {
+    if (isPublic(mod))
+      r.append("public ");
+    if (isProtected(mod))
+      r.append("protected ");
+    if (isPrivate(mod))
+      r.append("private ");
+    if (isAbstract(mod))
+      r.append("abstract ");
+    if (isStatic(mod))
+      r.append("static ");
+    if (isFinal(mod))
+      r.append("final ");
+    if (isTransient(mod))
+      r.append("transient ");
+    if (isVolatile(mod))
+      r.append("volatile ");
+    if (isSynchronized(mod))
+      r.append("synchronized ");
+    if (isNative(mod))
+      r.append("native ");
+    if (isStrict(mod))
+      r.append("strictfp ");
+    if (isInterface(mod))
+      r.append("interface ");
+    
+    // Trim trailing space.
+    if ((mod & ALL_FLAGS) != 0)
+      r.setLength(r.length() - 1);
+    return r;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/ParameterizedType.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/ParameterizedType.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,122 @@
+/* ParameterizedType.java -- Represents parameterized types e.g. List<String>
+   Copyright (C) 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.lang.reflect;
+
+/**
+ * <p>
+ * Represents a type which is parameterized over one or more other
+ * types.  For example, <code>List<Integer></code> is a parameterized
+ * type, with <code>List</code> parameterized over the type
+ * <code>Integer</code>.
+ * </p>
+ * <p>
+ * Instances of this classes are created as needed, during reflection.
+ * On creating a parameterized type, <code>p</code>, the
+ * <code>GenericTypeDeclaration</code> corresponding to <code>p</code>
+ * is created and resolved.  Each type argument of <code>p</code>
+ * is then created recursively; details of this process are availble
+ * in the documentation of <code>TypeVariable</code>.  This creation
+ * process only happens once; repetition has no effect.
+ * </p>
+ * <p>
+ * Implementors of this interface must implement an appropriate
+ * <code>equals()</code> method.  This method should equate any
+ * two instances of the implementing class that have the same
+ * <code>GenericTypeDeclaration</code> and <code>Type</code>
+ * parameters.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @see GenericDeclaration
+ * @see TypeVariable
+ * @since 1.5
+ */
+public interface ParameterizedType
+  extends Type
+{
+
+  /**
+   * <p>
+   * Returns an array of <code>Type</code> objects, which gives
+   * the parameters of this type.
+   * </p>
+   * <p>
+   * <strong>Note</code>: the returned array may be empty.  This
+   * occurs if the supposed <code>ParameterizedType</code> is simply
+   * a normal type wrapped inside a parameterized type.
+   * </p>
+   *
+   * @return an array of <code>Type</code>s, representing the arguments
+   *         of this type.
+   * @throws TypeNotPresentException if any of the types referred to by
+   *         the parameters of this type do not actually exist.
+   * @throws MalformedParameterizedTypeException if any of the types
+   *         refer to a type which can not be instantiated.
+   */
+  Type[] getActualTypeArguments();
+
+  /**
+   * Returns the type of which this type is a member.  For example,
+   * in <code>Top<String>.Bottom<Integer></code>,
+   * <code>Bottom<Integer></code> is a member of
+   * <code>Top<String></code>, and so the latter is returned
+   * by this method.  Calling this method on top-level types (such as
+   * <code>Top<String></code>) returns null.
+   *
+   * @return the type which owns this type.
+   * @throws TypeNotPresentException if the owner type referred to by
+   *         this type do not actually exist.
+   * @throws MalformedParameterizedTypeException if the owner type
+   *         referred to by this type can not be instantiated.
+   */
+  Type getOwnerType();
+
+  /**
+   * Returns a version of this type without parameters, which corresponds
+   * to the class or interface which declared the type.  For example,
+   * the raw type corresponding to <code>List<Double></code>
+   * is <code>List</code>, which was declared by the <code>List</code>
+   * class.
+   *
+   * @return the raw variant of this type (i.e. the type without
+   *         parameters).
+   */
+  Type getRawType();
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/Proxy.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/Proxy.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1543 @@
+/* Proxy.java -- build a proxy class that implements reflected interfaces
+   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.lang.reflect;
+
+import gnu.java.lang.reflect.TypeSignature;
+
+import java.io.Serializable;
+import java.security.ProtectionDomain;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This class allows you to dynamically create an instance of any (or
+ * even multiple) interfaces by reflection, and decide at runtime
+ * how that instance will behave by giving it an appropriate
+ * {@link InvocationHandler}.  Proxy classes serialize specially, so
+ * that the proxy object can be reused between VMs, without requiring
+ * a persistent copy of the generated class code.
+ *
+ * <h3>Creation</h3>
+ * To create a proxy for some interface Foo:
+ *
+ * <pre>
+ *   InvocationHandler handler = new MyInvocationHandler(...);
+ *   Class proxyClass = Proxy.getProxyClass(
+ *       Foo.class.getClassLoader(), new Class[] { Foo.class });
+ *   Foo f = (Foo) proxyClass
+ *       .getConstructor(new Class[] { InvocationHandler.class })
+ *       .newInstance(new Object[] { handler });
+ * </pre>
+ * or more simply:
+ * <pre>
+ *   Foo f = (Foo) Proxy.newProxyInstance(Foo.class.getClassLoader(),
+ *                                        new Class[] { Foo.class },
+ *                                        handler);
+ * </pre>
+ *
+ * <h3>Dynamic Proxy Classes</h3>
+ * A dynamic proxy class is created at runtime, and has the following
+ * properties:
+ * <ul>
+ *  <li>The class is <code>public</code> and <code>final</code>,
+ *      and is neither <code>abstract</code> nor an inner class.</li>
+ *  <li>The class has no canonical name (there is no formula you can use
+ *      to determine or generate its name), but begins with the
+ *      sequence "$Proxy".  Abuse this knowledge at your own peril.
+ *      (For now, '$' in user identifiers is legal, but it may not
+ *      be that way forever. You weren't using '$' in your
+ *      identifiers, were you?)</li>
+ *  <li>The class extends Proxy, and explicitly implements all the
+ *      interfaces specified at creation, in order (this is important
+ *      for determining how method invocation is resolved).  Note that
+ *      a proxy class implements {@link Serializable}, at least
+ *      implicitly, since Proxy does, but true serial behavior
+ *      depends on using a serializable invocation handler as well.</li>
+ *  <li>If at least one interface is non-public, the proxy class
+ *      will be in the same package.  Otherwise, the package is
+ *      unspecified.  This will work even if the package is sealed
+ *      from user-generated classes, because Proxy classes are
+ *      generated by a trusted source.  Meanwhile, the proxy class
+ *      belongs to the classloader you designated.</li>
+ *  <li>Reflection works as expected: {@link Class#getInterfaces()} and
+ *      {@link Class#getMethods()} work as they do on normal classes.</li>
+ *  <li>The method {@link #isProxyClass(Class)} will distinguish between
+ *      true proxy classes and user extensions of this class.  It only
+ *      returns true for classes created by {@link #getProxyClass}.</li>
+ *  <li>The {@link ProtectionDomain} of a proxy class is the same as for
+ *      bootstrap classes, such as Object or Proxy, since it is created by
+ *      a trusted source.  This protection domain will typically be granted
+ *      {@link java.security.AllPermission}. But this is not a security
+ *      risk, since there are adequate permissions on reflection, which is
+ *      the only way to create an instance of the proxy class.</li>
+ *  <li>The proxy class contains a single constructor, which takes as
+ *      its only argument an {@link InvocationHandler}.  The method
+ *      {@link #newProxyInstance(ClassLoader, Class[], InvocationHandler)}
+ *      is shorthand to do the necessary reflection.</li>
+ * </ul>
+ *
+ * <h3>Proxy Instances</h3>
+ * A proxy instance is an instance of a proxy class.  It has the
+ * following properties, many of which follow from the properties of a
+ * proxy class listed above:
+ * <ul>
+ *  <li>For a proxy class with Foo listed as one of its interfaces, the
+ *      expression <code>proxy instanceof Foo</code> will return true,
+ *      and the expression <code>(Foo) proxy</code> will succeed without
+ *      a {@link ClassCastException}.</li>
+ *  <li>Each proxy instance has an invocation handler, which can be
+ *      accessed by {@link #getInvocationHandler(Object)}.  Any call
+ *      to an interface method, including {@link Object#hashCode()},
+ *      {@link Object#equals(Object)}, or {@link Object#toString()},
+ *      but excluding the public final methods of Object, will be
+ *      encoded and passed to the {@link InvocationHandler#invoke}
+ *      method of this handler.</li>
+ * </ul>
+ *
+ * <h3>Inheritance Issues</h3>
+ * A proxy class may inherit a method from more than one interface.
+ * The order in which interfaces are listed matters, because it determines
+ * which reflected {@link Method} object will be passed to the invocation
+ * handler.  This means that the dynamically generated class cannot
+ * determine through which interface a method is being invoked.<p>
+ *
+ * In short, if a method is declared in Object (namely, hashCode,
+ * equals, or toString), then Object will be used; otherwise, the
+ * leftmost interface that inherits or declares a method will be used,
+ * even if it has a more permissive throws clause than what the proxy
+ * class is allowed. Thus, in the invocation handler, it is not always
+ * safe to assume that every class listed in the throws clause of the
+ * passed Method object can safely be thrown; fortunately, the Proxy
+ * instance is robust enough to wrap all illegal checked exceptions in
+ * {@link UndeclaredThrowableException}.
+ *
+ * @see InvocationHandler
+ * @see UndeclaredThrowableException
+ * @see Class
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.3
+ * @status updated to 1.4, except for the use of ProtectionDomain
+ */
+public class Proxy implements Serializable
+{
+  /**
+   * Compatible with JDK 1.3+.
+   */
+  private static final long serialVersionUID = -2222568056686623797L;
+
+  /**
+   * Map of ProxyType to proxy class.
+   *
+   * @XXX This prevents proxy classes from being garbage collected.
+   * java.util.WeakHashSet is not appropriate, because that collects the
+   * keys, but we are interested in collecting the elements.
+   */
+  private static final Map proxyClasses = new HashMap();
+
+  /**
+   * The invocation handler for this proxy instance.  For Proxy, this
+   * field is unused, but it appears here in order to be serialized in all
+   * proxy classes.
+   *
+   * <em>NOTE</em>: This implementation is more secure for proxy classes
+   * than what Sun specifies. Sun does not require h to be immutable, but
+   * this means you could change h after the fact by reflection.  However,
+   * by making h immutable, we may break non-proxy classes which extend
+   * Proxy.
+   * @serial invocation handler associated with this proxy instance
+   */
+  protected InvocationHandler h;
+
+  /**
+   * Constructs a new Proxy from a subclass (usually a proxy class),
+   * with the specified invocation handler.
+   *
+   * <em>NOTE</em>: This throws a NullPointerException if you attempt
+   * to create a proxy instance with a null handler using reflection.
+   * This behavior is not yet specified by Sun; see Sun Bug 4487672.
+   *
+   * @param handler the invocation handler, may be null if the subclass
+   *        is not a proxy class
+   * @throws NullPointerException if handler is null and this is a proxy
+   *         instance
+   */
+  protected Proxy(InvocationHandler handler)
+  {
+    if (handler == null && isProxyClass(getClass()))
+      throw new NullPointerException("invalid handler");
+    h = handler;
+  }
+
+  /**
+   * Returns the proxy {@link Class} for the given ClassLoader and array
+   * of interfaces, dynamically generating it if necessary.
+   *
+   * <p>There are several restrictions on this method, the violation of
+   * which will result in an IllegalArgumentException or
+   * NullPointerException:</p>
+   * 
+   * <ul>
+   * <li>All objects in `interfaces' must represent distinct interfaces.
+   *     Classes, primitive types, null, and duplicates are forbidden.</li>
+   * <li>The interfaces must be visible in the specified ClassLoader.
+   *     In other words, for each interface i:
+   *     <code>Class.forName(i.getName(), false, loader) == i</code>
+   *     must be true.</li>
+   * <li>All non-public interfaces (if any) must reside in the same
+   *     package, or the proxy class would be non-instantiable.  If
+   *     there are no non-public interfaces, the package of the proxy
+   *     class is unspecified.</li>
+   * <li>All interfaces must be compatible - if two declare a method
+   *     with the same name and parameters, the return type must be
+   *     the same and the throws clause of the proxy class will be
+   *     the maximal subset of subclasses of the throws clauses for
+   *     each method that is overridden.</li>
+   * <li>VM constraints limit the number of interfaces a proxy class
+   *     may directly implement (however, the indirect inheritance
+   *     of {@link Serializable} does not count against this limit).
+   *     Even though most VMs can theoretically have 65535
+   *     superinterfaces for a class, the actual limit is smaller
+   *     because a class's constant pool is limited to 65535 entries,
+   *     and not all entries can be interfaces.</li>
+   * </ul>
+   *
+   * <p>Note that different orders of interfaces produce distinct classes.</p>
+   *
+   * @param loader the class loader to define the proxy class in; null
+   *        implies the bootstrap class loader
+   * @param interfaces the array of interfaces the proxy class implements,
+   *        may be empty, but not null
+   * @return the Class object of the proxy class
+   * @throws IllegalArgumentException if the constraints above were
+   *         violated, except for problems with null
+   * @throws NullPointerException if `interfaces' is null or contains
+   *         a null entry
+   */
+  // synchronized so that we aren't trying to build the same class
+  // simultaneously in two threads
+  public static synchronized Class getProxyClass(ClassLoader loader,
+                                                 Class[] interfaces)
+  {
+    interfaces = (Class[]) interfaces.clone();
+    ProxyType pt = new ProxyType(loader, interfaces);
+    Class clazz = (Class) proxyClasses.get(pt);
+    if (clazz == null)
+      {
+        if (VMProxy.HAVE_NATIVE_GET_PROXY_CLASS)
+          clazz = VMProxy.getProxyClass(loader, interfaces);
+        else
+          {
+            ProxyData data = (VMProxy.HAVE_NATIVE_GET_PROXY_DATA
+                              ? VMProxy.getProxyData(loader, interfaces)
+                              : ProxyData.getProxyData(pt));
+
+            clazz = (VMProxy.HAVE_NATIVE_GENERATE_PROXY_CLASS
+		     ? VMProxy.generateProxyClass(loader, data)
+                     : new ClassFactory(data).generate(loader));
+          }
+
+        Object check = proxyClasses.put(pt, clazz);
+        // assert check == null && clazz != null;
+        if (check != null || clazz == null)
+          throw new InternalError(/*"Fatal flaw in getProxyClass"*/);
+      }
+    return clazz;
+  }
+
+  /**
+   * Combines several methods into one.  This is equivalent to:
+   * <pre>
+   *   Proxy.getProxyClass(loader, interfaces)
+   *       .getConstructor(new Class[] {InvocationHandler.class})
+   *       .newInstance(new Object[] {handler});
+   * </pre>
+   * except that it will not fail with the normal problems caused
+   * by reflection.  It can still fail for the same reasons documented
+   * in getProxyClass, or if handler is null.
+   *
+   * @param loader the class loader to define the proxy class in; null
+   *        implies the bootstrap class loader
+   * @param interfaces the array of interfaces the proxy class implements,
+   *        may be empty, but not null
+   * @param handler the invocation handler, may not be null
+   * @return a proxy instance implementing the specified interfaces
+   * @throws IllegalArgumentException if the constraints for getProxyClass
+   *         were violated, except for problems with null
+   * @throws NullPointerException if `interfaces' is null or contains
+   *         a null entry, or if handler is null
+   * @see #getProxyClass(ClassLoader, Class[])
+   * @see Class#getConstructor(Class[])
+   * @see Constructor#newInstance(Object[])
+   */
+  public static Object newProxyInstance(ClassLoader loader,
+                                        Class[] interfaces,
+                                        InvocationHandler handler)
+  {
+    try
+      {
+        // getProxyClass() and Proxy() throw the necessary exceptions
+        return getProxyClass(loader, interfaces)
+          .getConstructor(new Class[] {InvocationHandler.class})
+          .newInstance(new Object[] {handler});
+      }
+    catch (RuntimeException e)
+      {
+        // Let IllegalArgumentException, NullPointerException escape.
+        // assert e instanceof IllegalArgumentException
+        //   || e instanceof NullPointerException;
+        throw e;
+      }
+    catch (InvocationTargetException e)
+      {
+        // Let wrapped NullPointerException escape.
+        // assert e.getTargetException() instanceof NullPointerException
+        throw (NullPointerException) e.getCause();
+      }
+    catch (Exception e)
+      {
+        // Covers InstantiationException, IllegalAccessException,
+        // NoSuchMethodException, none of which should be generated
+        // if the proxy class was generated correctly.
+        // assert false;
+        throw (Error) new InternalError("Unexpected: " + e).initCause(e);
+      }
+  }
+
+  /**
+   * Returns true if and only if the Class object is a dynamically created
+   * proxy class (created by <code>getProxyClass</code> or by the
+   * syntactic sugar of <code>newProxyInstance</code>).
+   *
+   * <p>This check is secure (in other words, it is not simply
+   * <code>clazz.getSuperclass() == Proxy.class</code>), it will not
+   * be spoofed by non-proxy classes that extend Proxy.
+   *
+   * @param clazz the class to check, must not be null
+   * @return true if the class represents a proxy class
+   * @throws NullPointerException if clazz is null
+   */
+  // This is synchronized on the off chance that another thread is
+  // trying to add a class to the map at the same time we read it.
+  public static synchronized boolean isProxyClass(Class clazz)
+  {
+    if (! Proxy.class.isAssignableFrom(clazz))
+      return false;
+    // This is a linear search, even though we could do an O(1) search
+    // using new ProxyType(clazz.getClassLoader(), clazz.getInterfaces()).
+    return proxyClasses.containsValue(clazz);
+  }
+
+  /**
+   * Returns the invocation handler for the given proxy instance.<p>
+   *
+   * <em>NOTE</em>: We guarantee a non-null result if successful,
+   * but Sun allows the creation of a proxy instance with a null
+   * handler.  See the comments for {@link #Proxy(InvocationHandler)}.
+   *
+   * @param proxy the proxy instance, must not be null
+   * @return the invocation handler, guaranteed non-null.
+   * @throws IllegalArgumentException if
+   *         <code>Proxy.isProxyClass(proxy.getClass())</code> returns false.
+   * @throws NullPointerException if proxy is null
+   */
+  public static InvocationHandler getInvocationHandler(Object proxy)
+  {
+    if (! isProxyClass(proxy.getClass()))
+      throw new IllegalArgumentException("not a proxy instance");
+    return ((Proxy) proxy).h;
+  }
+
+  /**
+   * Helper class for mapping unique ClassLoader and interface combinations
+   * to proxy classes.
+   *
+   * @author Eric Blake (ebb9 at email.byu.edu)
+   */
+  private static final class ProxyType
+  {
+    /**
+     * Store the class loader (may be null)
+     */
+    final ClassLoader loader;
+
+    /**
+     * Store the interfaces (never null, all elements are interfaces)
+     */
+    final Class[] interfaces;
+
+    /**
+     * Construct the helper object.
+     *
+     * @param loader the class loader to define the proxy class in; null
+     *        implies the bootstrap class loader
+     * @param interfaces an array of interfaces
+     */
+    ProxyType(ClassLoader loader, Class[] interfaces)
+    {
+      this.loader = loader;
+      this.interfaces = interfaces;
+    }
+
+    /**
+     * Calculates the hash code.
+     *
+     * @return a combination of the classloader and interfaces hashcodes.
+     */
+    public int hashCode()
+    {
+      int hash = loader == null ? 0 : loader.hashCode();
+      for (int i = 0; i < interfaces.length; i++)
+        hash = hash * 31 + interfaces[i].hashCode();
+      return hash;
+    }
+
+    /**
+     * Calculates equality.
+     *
+     * @param other object to compare to
+     * @return true if it is a ProxyType with same data
+     */
+    public boolean equals(Object other)
+    {
+      ProxyType pt = (ProxyType) other;
+      if (loader != pt.loader || interfaces.length != pt.interfaces.length)
+        return false;
+      for (int i = 0; i < interfaces.length; i++)
+        if (interfaces[i] != pt.interfaces[i])
+          return false;
+      return true;
+    }
+  } // class ProxyType
+
+  /**
+   * Helper class which allows hashing of a method name and signature
+   * without worrying about return type, declaring class, or throws clause,
+   * and which reduces the maximally common throws clause between two methods
+   *
+   * @author Eric Blake (ebb9 at email.byu.edu)
+   */
+  private static final class ProxySignature
+  {
+    /**
+     * The core signatures which all Proxy instances handle.
+     */
+    static final HashMap coreMethods = new HashMap();
+    static
+    {
+      try
+        {
+          ProxySignature sig
+            = new ProxySignature(Object.class
+                                 .getMethod("equals",
+                                            new Class[] {Object.class}));
+          coreMethods.put(sig, sig);
+          sig = new ProxySignature(Object.class.getMethod("hashCode", null));
+          coreMethods.put(sig, sig);
+          sig = new ProxySignature(Object.class.getMethod("toString", null));
+          coreMethods.put(sig, sig);
+        }
+      catch (Exception e)
+        {
+          // assert false;
+          throw (Error) new InternalError("Unexpected: " + e).initCause(e);
+        }
+    }
+
+    /**
+     * The underlying Method object, never null
+     */
+    final Method method;
+
+    /**
+     * The set of compatible thrown exceptions, may be empty
+     */
+    final Set exceptions = new HashSet();
+
+    /**
+     * Construct a signature
+     *
+     * @param method the Method this signature is based on, never null
+     */
+    ProxySignature(Method method)
+    {
+      this.method = method;
+      Class[] exc = method.getExceptionTypes();
+      int i = exc.length;
+      while (--i >= 0)
+        {
+          // discard unchecked exceptions
+          if (Error.class.isAssignableFrom(exc[i])
+              || RuntimeException.class.isAssignableFrom(exc[i]))
+            continue;
+          exceptions.add(exc[i]);
+        }
+    }
+
+    /**
+     * Given a method, make sure it's return type is identical
+     * to this, and adjust this signature's throws clause appropriately
+     *
+     * @param other the signature to merge in
+     * @throws IllegalArgumentException if the return types conflict
+     */
+    void checkCompatibility(ProxySignature other)
+    {
+      if (method.getReturnType() != other.method.getReturnType())
+        throw new IllegalArgumentException("incompatible return types: "
+                                           + method + ", " + other.method);
+
+      // if you can think of a more efficient way than this O(n^2) search,
+      // implement it!
+      int size1 = exceptions.size();
+      int size2 = other.exceptions.size();
+      boolean[] valid1 = new boolean[size1];
+      boolean[] valid2 = new boolean[size2];
+      Iterator itr = exceptions.iterator();
+      int pos = size1;
+      while (--pos >= 0)
+        {
+          Class c1 = (Class) itr.next();
+          Iterator itr2 = other.exceptions.iterator();
+          int pos2 = size2;
+          while (--pos2 >= 0)
+            {
+              Class c2 = (Class) itr2.next();
+              if (c2.isAssignableFrom(c1))
+                valid1[pos] = true;
+              if (c1.isAssignableFrom(c2))
+                valid2[pos2] = true;
+            }
+        }
+      pos = size1;
+      itr = exceptions.iterator();
+      while (--pos >= 0)
+        {
+          itr.next();
+          if (! valid1[pos])
+            itr.remove();
+        }
+      pos = size2;
+      itr = other.exceptions.iterator();
+      while (--pos >= 0)
+        {
+          itr.next();
+          if (! valid2[pos])
+            itr.remove();
+        }
+      exceptions.addAll(other.exceptions);
+    }
+
+    /**
+     * Calculates the hash code.
+     *
+     * @return a combination of name and parameter types
+     */
+    public int hashCode()
+    {
+      int hash = method.getName().hashCode();
+      Class[] types = method.getParameterTypes();
+      for (int i = 0; i < types.length; i++)
+        hash = hash * 31 + types[i].hashCode();
+      return hash;
+    }
+
+    /**
+     * Calculates equality.
+     *
+     * @param other object to compare to
+     * @return true if it is a ProxySignature with same data
+     */
+    public boolean equals(Object other)
+    {
+      ProxySignature ps = (ProxySignature) other;
+      Class[] types1 = method.getParameterTypes();
+      Class[] types2 = ps.method.getParameterTypes();
+      if (! method.getName().equals(ps.method.getName())
+          || types1.length != types2.length)
+        return false;
+      int i = types1.length;
+      while (--i >= 0)
+        if (types1[i] != types2[i])
+          return false;
+      return true;
+    }
+  } // class ProxySignature
+
+  /**
+   * A flat representation of all data needed to generate bytecode/instantiate
+   * a proxy class.  This is basically a struct.
+   *
+   * @author Eric Blake (ebb9 at email.byu.edu)
+   */
+  static final class ProxyData
+  {
+    /**
+     * The package this class is in <b>including the trailing dot</b>
+     * or an empty string for the unnamed (aka default) package.
+     */
+    String pack = "";
+
+    /**
+     * The interfaces this class implements.  Non-null, but possibly empty.
+     */
+    Class[] interfaces;
+
+    /**
+     * The Method objects this class must pass as the second argument to
+     * invoke (also useful for determining what methods this class has).
+     * Non-null, non-empty (includes at least Object.hashCode, Object.equals,
+     * and Object.toString).
+     */
+    Method[] methods;
+
+    /**
+     * The exceptions that do not need to be wrapped in
+     * UndeclaredThrowableException. exceptions[i] is the same as, or a
+     * subset of subclasses, of methods[i].getExceptionTypes(), depending on
+     * compatible throws clauses with multiple inheritance. It is unspecified
+     * if these lists include or exclude subclasses of Error and
+     * RuntimeException, but excluding them is harmless and generates a
+     * smaller class.
+     */
+    Class[][] exceptions;
+
+    /**
+     * For unique id's
+     */
+    private static int count;
+
+    /**
+     * The id of this proxy class
+     */
+    final int id = count++;
+
+    /**
+     * Construct a ProxyData with uninitialized data members.
+     */
+    ProxyData()
+    {
+    }
+
+    /**
+     * Return the name of a package (including the trailing dot)
+     * given the name of a class.
+     * Returns an empty string if no package.  We use this in preference to
+     * using Class.getPackage() to avoid problems with ClassLoaders
+     * that don't set the package.
+     */
+    private static String getPackage(Class k)
+    {
+      String name = k.getName();
+      int idx = name.lastIndexOf('.');
+      return name.substring(0, idx + 1);
+    }
+
+    /**
+     * Verifies that the arguments are legal, and sets up remaining data
+     * This should only be called when a class must be generated, as
+     * it is expensive.
+     *
+     * @param pt the ProxyType to convert to ProxyData
+     * @return the flattened, verified ProxyData structure for use in
+     *         class generation
+     * @throws IllegalArgumentException if `interfaces' contains
+     *         non-interfaces or incompatible combinations, and verify is true
+     * @throws NullPointerException if interfaces is null or contains null
+     */
+    static ProxyData getProxyData(ProxyType pt)
+    {
+      Map method_set = (Map) ProxySignature.coreMethods.clone();
+      boolean in_package = false; // true if we encounter non-public interface
+
+      ProxyData data = new ProxyData();
+      data.interfaces = pt.interfaces;
+
+      // if interfaces is too large, we croak later on when the constant
+      // pool overflows
+      int i = data.interfaces.length;
+      while (--i >= 0)
+        {
+          Class inter = data.interfaces[i];
+          if (! inter.isInterface())
+            throw new IllegalArgumentException("not an interface: " + inter);
+          try
+            {
+              if (Class.forName(inter.getName(), false, pt.loader) != inter)
+                throw new IllegalArgumentException("not accessible in "
+                                                   + "classloader: " + inter);
+            }
+          catch (ClassNotFoundException e)
+            {
+              throw new IllegalArgumentException("not accessible in "
+                                                 + "classloader: " + inter);
+            }
+          if (! Modifier.isPublic(inter.getModifiers()))
+            if (in_package)
+              {
+		String p = getPackage(inter);
+                if (! data.pack.equals(p))
+                  throw new IllegalArgumentException("non-public interfaces "
+                                                     + "from different "
+                                                     + "packages");
+              }
+            else
+              {
+                in_package = true;
+                data.pack = getPackage(inter);
+              }
+          for (int j = i-1; j >= 0; j--)
+            if (data.interfaces[j] == inter)
+              throw new IllegalArgumentException("duplicate interface: "
+                                                 + inter);
+          Method[] methods = inter.getMethods();
+          int j = methods.length;
+          while (--j >= 0)
+            {
+              if (isCoreObjectMethod(methods[j]))
+                {
+                  // In the case of an attempt to redefine a public non-final
+                  // method of Object, we must skip it
+                  continue;
+                }
+              ProxySignature sig = new ProxySignature(methods[j]);
+              ProxySignature old = (ProxySignature) method_set.put(sig, sig);
+              if (old != null)
+                sig.checkCompatibility(old);
+            }
+        }
+
+      i = method_set.size();
+      data.methods = new Method[i];
+      data.exceptions = new Class[i][];
+      Iterator itr = method_set.values().iterator();
+      while (--i >= 0)
+        {
+          ProxySignature sig = (ProxySignature) itr.next();
+          data.methods[i] = sig.method;
+          data.exceptions[i] = (Class[]) sig.exceptions
+            .toArray(new Class[sig.exceptions.size()]);
+        }
+      return data;
+    }
+
+    /**
+     * Checks whether the method is similar to a public non-final method of
+     * Object or not (i.e. with the same name and parameter types). Note that we
+     * can't rely, directly or indirectly (via Collection.contains) on
+     * Method.equals as it would also check the declaring class, what we do not
+     * want. We only want to check that the given method have the same signature
+     * as a core method (same name and parameter types)
+     * 
+     * @param method the method to check
+     * @return whether the method has the same name and parameter types as
+     *         Object.equals, Object.hashCode or Object.toString
+     * @see java.lang.Object#equals(Object)
+     * @see java.lang.Object#hashCode()
+     * @see java.lang.Object#toString()
+     */
+    private static boolean isCoreObjectMethod(Method method)
+    {
+      String methodName = method.getName();
+      if (methodName.equals("equals"))
+        {
+          return Arrays.equals(method.getParameterTypes(),
+                               new Class[] { Object.class });
+        }
+      if (methodName.equals("hashCode"))
+        {
+          return method.getParameterTypes().length == 0;
+        }
+      if (methodName.equals("toString"))
+        {
+          return method.getParameterTypes().length == 0;
+        }
+      return false;
+    }
+    
+  } // class ProxyData
+
+  /**
+   * Does all the work of building a class. By making this a nested class,
+   * this code is not loaded in memory if the VM has a native
+   * implementation instead.
+   *
+   * @author Eric Blake (ebb9 at email.byu.edu)
+   */
+  private static final class ClassFactory
+  {
+    /** Constants for assisting the compilation */
+    private static final byte FIELD = 1;
+    private static final byte METHOD = 2;
+    private static final byte INTERFACE = 3;
+    private static final String CTOR_SIG
+      = "(Ljava/lang/reflect/InvocationHandler;)V";
+    private static final String INVOKE_SIG = "(Ljava/lang/Object;"
+      + "Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;";
+
+    /** Bytecodes for insertion in the class definition byte[] */
+    private static final char ACONST_NULL = 1;
+    private static final char ICONST_0 = 3;
+    private static final char BIPUSH = 16;
+    private static final char SIPUSH = 17;
+    private static final char ILOAD = 21;
+    private static final char ILOAD_0 = 26;
+    private static final char ALOAD_0 = 42;
+    private static final char ALOAD_1 = 43;
+    private static final char AALOAD = 50;
+    private static final char AASTORE = 83;
+    private static final char DUP = 89;
+    private static final char DUP_X1 = 90;
+    private static final char SWAP = 95;
+    private static final char IRETURN = 172;
+    private static final char LRETURN = 173;
+    private static final char FRETURN = 174;
+    private static final char DRETURN = 175;
+    private static final char ARETURN = 176;
+    private static final char RETURN = 177;
+    private static final char GETSTATIC = 178;
+    private static final char GETFIELD = 180;
+    private static final char INVOKEVIRTUAL = 182;
+    private static final char INVOKESPECIAL = 183;
+    private static final char INVOKEINTERFACE = 185;
+    private static final char NEW = 187;
+    private static final char ANEWARRAY = 189;
+    private static final char ATHROW = 191;
+    private static final char CHECKCAST = 192;
+
+    // Implementation note: we use StringBuffers to hold the byte data, since
+    // they automatically grow.  However, we only use the low 8 bits of
+    // every char in the array, so we are using twice the necessary memory
+    // for the ease StringBuffer provides.
+
+    /** The constant pool. */
+    private final StringBuffer pool = new StringBuffer();
+    /** The rest of the class data. */
+    private final StringBuffer stream = new StringBuffer();
+
+    /** Map of strings to byte sequences, to minimize size of pool. */
+    private final Map poolEntries = new HashMap();
+
+    /** The VM name of this proxy class. */
+    private final String qualName;
+
+    /**
+     * The Method objects the proxy class refers to when calling the
+     * invocation handler.
+     */
+    private final Method[] methods;
+
+    /**
+     * Initializes the buffers with the bytecode contents for a proxy class.
+     *
+     * @param data the remainder of the class data
+     * @throws IllegalArgumentException if anything else goes wrong this
+     *         late in the game; as far as I can tell, this will only happen
+     *         if the constant pool overflows, which is possible even when
+     *         the user doesn't exceed the 65535 interface limit
+     */
+    ClassFactory(ProxyData data)
+    {
+      methods = data.methods;
+
+      // magic = 0xcafebabe
+      // minor_version = 0
+      // major_version = 46
+      // constant_pool_count: place-holder for now
+      pool.append("\u00ca\u00fe\u00ba\u00be\0\0\0\56\0\0");
+      // constant_pool[], filled in as we go
+
+      // access_flags
+      putU2(Modifier.SUPER | Modifier.FINAL | Modifier.PUBLIC);
+      // this_class
+      qualName = (data.pack + "$Proxy" + data.id);
+      putU2(classInfo(TypeSignature.getEncodingOfClass(qualName, false)));
+      // super_class
+      putU2(classInfo("java/lang/reflect/Proxy"));
+
+      // interfaces_count
+      putU2(data.interfaces.length);
+      // interfaces[]
+      for (int i = 0; i < data.interfaces.length; i++)
+        putU2(classInfo(data.interfaces[i]));
+
+      // Recall that Proxy classes serialize specially, so we do not need
+      // to worry about a <clinit> method for this field.  Instead, we
+      // just assign it by reflection after the class is successfully loaded.
+      // fields_count - private static Method[] m;
+      putU2(1);
+      // fields[]
+      // m.access_flags
+      putU2(Modifier.PRIVATE | Modifier.STATIC);
+      // m.name_index
+      putU2(utf8Info("m"));
+      // m.descriptor_index
+      putU2(utf8Info("[Ljava/lang/reflect/Method;"));
+      // m.attributes_count
+      putU2(0);
+      // m.attributes[]
+
+      // methods_count - # handler methods, plus <init>
+      putU2(methods.length + 1);
+      // methods[]
+      // <init>.access_flags
+      putU2(Modifier.PUBLIC);
+      // <init>.name_index
+      putU2(utf8Info("<init>"));
+      // <init>.descriptor_index
+      putU2(utf8Info(CTOR_SIG));
+      // <init>.attributes_count - only Code is needed
+      putU2(1);
+      // <init>.Code.attribute_name_index
+      putU2(utf8Info("Code"));
+      // <init>.Code.attribute_length = 18
+      // <init>.Code.info:
+      //   $Proxynn(InvocationHandler h) { super(h); }
+      // <init>.Code.max_stack = 2
+      // <init>.Code.max_locals = 2
+      // <init>.Code.code_length = 6
+      // <init>.Code.code[]
+      stream.append("\0\0\0\22\0\2\0\2\0\0\0\6" + ALOAD_0 + ALOAD_1
+                    + INVOKESPECIAL);
+      putU2(refInfo(METHOD, "java/lang/reflect/Proxy", "<init>", CTOR_SIG));
+      // <init>.Code.exception_table_length = 0
+      // <init>.Code.exception_table[]
+      // <init>.Code.attributes_count = 0
+      // <init>.Code.attributes[]
+      stream.append(RETURN + "\0\0\0\0");
+
+      for (int i = methods.length - 1; i >= 0; i--)
+        emitMethod(i, data.exceptions[i]);
+
+      // attributes_count
+      putU2(0);
+      // attributes[] - empty; omit SourceFile attribute
+      // XXX should we mark this with a Synthetic attribute?
+    }
+
+    /**
+     * Produce the bytecode for a single method.
+     *
+     * @param i the index of the method we are building
+     * @param e the exceptions possible for the method
+     */
+    private void emitMethod(int i, Class[] e)
+    {
+      // First, we precalculate the method length and other information.
+
+      Method m = methods[i];
+      Class[] paramtypes = m.getParameterTypes();
+      int wrap_overhead = 0; // max words taken by wrapped primitive
+      int param_count = 1; // 1 for this
+      int code_length = 16; // aload_0, getfield, aload_0, getstatic, const,
+      // aaload, const/aconst_null, invokeinterface
+      if (i > 5)
+        {
+          if (i > Byte.MAX_VALUE)
+            code_length += 2; // sipush
+          else
+            code_length++; // bipush
+        }
+      if (paramtypes.length > 0)
+        {
+          code_length += 3; // anewarray
+          if (paramtypes.length > Byte.MAX_VALUE)
+            code_length += 2; // sipush
+          else if (paramtypes.length > 5)
+            code_length++; // bipush
+          for (int j = 0; j < paramtypes.length; j++)
+            {
+              code_length += 4; // dup, const, load, store
+              Class type = paramtypes[j];
+              if (j > 5)
+                {
+                  if (j > Byte.MAX_VALUE)
+                    code_length += 2; // sipush
+                  else
+                    code_length++; // bipush
+                }
+              if (param_count >= 4)
+                code_length++; // 2-byte load
+              param_count++;
+              if (type.isPrimitive())
+                {
+                  code_length += 7; // new, dup, invokespecial
+                  if (type == long.class || type == double.class)
+                    {
+                      wrap_overhead = 3;
+                      param_count++;
+                    }
+                  else if (wrap_overhead < 2)
+                    wrap_overhead = 2;
+                }
+            }
+        }
+      int end_pc = code_length;
+      Class ret_type = m.getReturnType();
+      if (ret_type == void.class)
+        code_length++; // return
+      else if (ret_type.isPrimitive())
+        code_length += 7; // cast, invokevirtual, return
+      else
+        code_length += 4; // cast, return
+      int exception_count = 0;
+      boolean throws_throwable = false;
+      for (int j = 0; j < e.length; j++)
+        if (e[j] == Throwable.class)
+          {
+            throws_throwable = true;
+            break;
+          }
+      if (! throws_throwable)
+        {
+          exception_count = e.length + 3; // Throwable, Error, RuntimeException
+          code_length += 9; // new, dup_x1, swap, invokespecial, athrow
+        }
+      int handler_pc = code_length - 1;
+      StringBuffer signature = new StringBuffer("(");
+      for (int j = 0; j < paramtypes.length; j++)
+        signature.append(TypeSignature.getEncodingOfClass(paramtypes[j]));
+      signature.append(")").append(TypeSignature.getEncodingOfClass(ret_type));
+
+      // Now we have enough information to emit the method.
+
+      // handler.access_flags
+      putU2(Modifier.PUBLIC | Modifier.FINAL);
+      // handler.name_index
+      putU2(utf8Info(m.getName()));
+      // handler.descriptor_index
+      putU2(utf8Info(signature.toString()));
+      // handler.attributes_count - Code is necessary, Exceptions possible
+      putU2(e.length > 0 ? 2 : 1);
+
+      // handler.Code.info:
+      //   type name(args) {
+      //     try {
+      //       return (type) h.invoke(this, methods[i], new Object[] {args});
+      //     } catch (<declared Exceptions> e) {
+      //       throw e;
+      //     } catch (Throwable t) {
+      //       throw new UndeclaredThrowableException(t);
+      //     }
+      //   }
+      // Special cases:
+      //  if arg_n is primitive, wrap it
+      //  if method throws Throwable, try-catch is not needed
+      //  if method returns void, return statement not needed
+      //  if method returns primitive, unwrap it
+      //  save space by sharing code for all the declared handlers
+
+      // handler.Code.attribute_name_index
+      putU2(utf8Info("Code"));
+      // handler.Code.attribute_length
+      putU4(12 + code_length + 8 * exception_count);
+      // handler.Code.max_stack
+      putU2(param_count == 1 ? 4 : 7 + wrap_overhead);
+      // handler.Code.max_locals
+      putU2(param_count);
+      // handler.Code.code_length
+      putU4(code_length);
+      // handler.Code.code[]
+      putU1(ALOAD_0);
+      putU1(GETFIELD);
+      putU2(refInfo(FIELD, "java/lang/reflect/Proxy", "h",
+                    "Ljava/lang/reflect/InvocationHandler;"));
+      putU1(ALOAD_0);
+      putU1(GETSTATIC);
+      putU2(refInfo(FIELD, TypeSignature.getEncodingOfClass(qualName, false),
+                    "m", "[Ljava/lang/reflect/Method;"));
+      putConst(i);
+      putU1(AALOAD);
+      if (paramtypes.length > 0)
+        {
+          putConst(paramtypes.length);
+          putU1(ANEWARRAY);
+          putU2(classInfo("java/lang/Object"));
+          param_count = 1;
+          for (int j = 0; j < paramtypes.length; j++, param_count++)
+            {
+              putU1(DUP);
+              putConst(j);
+              if (paramtypes[j].isPrimitive())
+                {
+                  putU1(NEW);
+                  putU2(classInfo(wrapper(paramtypes[j])));
+                  putU1(DUP);
+                }
+              putLoad(param_count, paramtypes[j]);
+              if (paramtypes[j].isPrimitive())
+                {
+                  putU1(INVOKESPECIAL);
+                  putU2(refInfo(METHOD, wrapper(paramtypes[j]), "<init>",
+                                '(' + (TypeSignature
+                                       .getEncodingOfClass(paramtypes[j])
+                                       + ")V")));
+                  if (paramtypes[j] == long.class
+                      || paramtypes[j] == double.class)
+                    param_count++;
+                }
+              putU1(AASTORE);
+            }
+        }
+      else
+        putU1(ACONST_NULL);
+      putU1(INVOKEINTERFACE);
+      putU2(refInfo(INTERFACE, "java/lang/reflect/InvocationHandler",
+                    "invoke", INVOKE_SIG));
+      putU1(4); // InvocationHandler, this, Method, Object[]
+      putU1(0);
+      if (ret_type == void.class)
+        putU1(RETURN);
+      else if (ret_type.isPrimitive())
+        {
+          putU1(CHECKCAST);
+          putU2(classInfo(wrapper(ret_type)));
+          putU1(INVOKEVIRTUAL);
+          putU2(refInfo(METHOD, wrapper(ret_type),
+                        ret_type.getName() + "Value",
+                        "()" + TypeSignature.getEncodingOfClass(ret_type)));
+          if (ret_type == long.class)
+            putU1(LRETURN);
+          else if (ret_type == float.class)
+            putU1(FRETURN);
+          else if (ret_type == double.class)
+            putU1(DRETURN);
+          else
+            putU1(IRETURN);
+        }
+      else
+        {
+          putU1(CHECKCAST);
+          putU2(classInfo(ret_type));
+          putU1(ARETURN);
+        }
+      if (! throws_throwable)
+        {
+          putU1(NEW);
+          putU2(classInfo("java/lang/reflect/UndeclaredThrowableException"));
+          putU1(DUP_X1);
+          putU1(SWAP);
+          putU1(INVOKESPECIAL);
+          putU2(refInfo(METHOD,
+                        "java/lang/reflect/UndeclaredThrowableException",
+                        "<init>", "(Ljava/lang/Throwable;)V"));
+          putU1(ATHROW);
+        }
+
+      // handler.Code.exception_table_length
+      putU2(exception_count);
+      // handler.Code.exception_table[]
+      if (! throws_throwable)
+        {
+          // handler.Code.exception_table.start_pc
+          putU2(0);
+          // handler.Code.exception_table.end_pc
+          putU2(end_pc);
+          // handler.Code.exception_table.handler_pc
+          putU2(handler_pc);
+          // handler.Code.exception_table.catch_type
+          putU2(classInfo("java/lang/Error"));
+          // handler.Code.exception_table.start_pc
+          putU2(0);
+          // handler.Code.exception_table.end_pc
+          putU2(end_pc);
+          // handler.Code.exception_table.handler_pc
+          putU2(handler_pc);
+          // handler.Code.exception_table.catch_type
+          putU2(classInfo("java/lang/RuntimeException"));
+          for (int j = 0; j < e.length; j++)
+            {
+              // handler.Code.exception_table.start_pc
+              putU2(0);
+              // handler.Code.exception_table.end_pc
+              putU2(end_pc);
+              // handler.Code.exception_table.handler_pc
+              putU2(handler_pc);
+              // handler.Code.exception_table.catch_type
+              putU2(classInfo(e[j]));
+            }
+          // handler.Code.exception_table.start_pc
+          putU2(0);
+          // handler.Code.exception_table.end_pc
+          putU2(end_pc);
+          // handler.Code.exception_table.handler_pc -
+          //   -8 for undeclared handler, which falls thru to normal one
+          putU2(handler_pc - 8);
+          // handler.Code.exception_table.catch_type
+          putU2(0);
+        }
+      // handler.Code.attributes_count
+      putU2(0);
+      // handler.Code.attributes[]
+
+      if (e.length > 0)
+        {
+          // handler.Exceptions.attribute_name_index
+          putU2(utf8Info("Exceptions"));
+          // handler.Exceptions.attribute_length
+          putU4(2 * e.length + 2);
+          // handler.Exceptions.number_of_exceptions
+          putU2(e.length);
+          // handler.Exceptions.exception_index_table[]
+          for (int j = 0; j < e.length; j++)
+            putU2(classInfo(e[j]));
+        }
+    }
+
+    /**
+     * Creates the Class object that corresponds to the bytecode buffers
+     * built when this object was constructed.
+     *
+     * @param loader the class loader to define the proxy class in; null
+     *        implies the bootstrap class loader
+     * @return the proxy class Class object
+     */
+    Class generate(ClassLoader loader)
+    {
+      byte[] bytecode = new byte[pool.length() + stream.length()];
+      // More efficient to bypass calling charAt() repetitively.
+      char[] c = pool.toString().toCharArray();
+      int i = c.length;
+      while (--i >= 0)
+        bytecode[i] = (byte) c[i];
+      c = stream.toString().toCharArray();
+      i = c.length;
+      int j = bytecode.length;
+      while (i > 0)
+        bytecode[--j] = (byte) c[--i];
+
+      // Patch the constant pool size, which we left at 0 earlier.
+      int count = poolEntries.size() + 1;
+      bytecode[8] = (byte) (count >> 8);
+      bytecode[9] = (byte) count;
+
+      try
+        {
+          Class vmClassLoader = Class.forName("java.lang.VMClassLoader");
+          Class[] types = {ClassLoader.class, String.class,
+                           byte[].class, int.class, int.class,
+                           ProtectionDomain.class };
+          Method m = vmClassLoader.getDeclaredMethod("defineClass", types);
+          // We can bypass the security check of setAccessible(true), since
+	  // we're in the same package.
+          m.flag = true;
+
+          Object[] args = {loader, qualName, bytecode, new Integer(0),
+                           new Integer(bytecode.length),
+                           Object.class.getProtectionDomain() };
+          Class clazz = (Class) m.invoke(null, args);
+
+          // Finally, initialize the m field of the proxy class, before
+          // returning it.
+          Field f = clazz.getDeclaredField("m");
+          f.flag = true;
+          // we can share the array, because it is not publicized
+          f.set(null, methods);
+
+          return clazz;
+        }
+      catch (Exception e)
+        {
+          // assert false;
+          throw (Error) new InternalError("Unexpected: " + e).initCause(e);
+        }
+    }
+
+    /**
+     * Put a single byte on the stream.
+     *
+     * @param i the information to add (only lowest 8 bits are used)
+     */
+    private void putU1(int i)
+    {
+      stream.append((char) i);
+    }
+
+    /**
+     * Put two bytes on the stream.
+     *
+     * @param i the information to add (only lowest 16 bits are used)
+     */
+    private void putU2(int i)
+    {
+      stream.append((char) (i >> 8)).append((char) i);
+    }
+
+    /**
+     * Put four bytes on the stream.
+     *
+     * @param i the information to add (treated as unsigned)
+     */
+    private void putU4(int i)
+    {
+      stream.append((char) (i >> 24)).append((char) (i >> 16));
+      stream.append((char) (i >> 8)).append((char) i);
+    }
+
+    /**
+     * Put bytecode to load a constant integer on the stream. This only
+     * needs to work for values less than Short.MAX_VALUE.
+     *
+     * @param i the int to add
+     */
+    private void putConst(int i)
+    {
+      if (i >= -1 && i <= 5)
+        putU1(ICONST_0 + i);
+      else if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE)
+        {
+          putU1(BIPUSH);
+          putU1(i);
+        }
+      else
+        {
+          putU1(SIPUSH);
+          putU2(i);
+        }
+    }
+
+    /**
+     * Put bytecode to load a given local variable on the stream.
+     *
+     * @param i the slot to load
+     * @param type the base type of the load
+     */
+    private void putLoad(int i, Class type)
+    {
+      int offset = 0;
+      if (type == long.class)
+        offset = 1;
+      else if (type == float.class)
+        offset = 2;
+      else if (type == double.class)
+        offset = 3;
+      else if (! type.isPrimitive())
+        offset = 4;
+      if (i < 4)
+        putU1(ILOAD_0 + 4 * offset + i);
+      else
+        {
+          putU1(ILOAD + offset);
+          putU1(i);
+        }
+    }
+
+    /**
+     * Given a primitive type, return its wrapper class name.
+     *
+     * @param clazz the primitive type (but not void.class)
+     * @return the internal form of the wrapper class name
+     */
+    private String wrapper(Class clazz)
+    {
+      if (clazz == boolean.class)
+        return "java/lang/Boolean";
+      if (clazz == byte.class)
+        return "java/lang/Byte";
+      if (clazz == short.class)
+        return "java/lang/Short";
+      if (clazz == char.class)
+        return "java/lang/Character";
+      if (clazz == int.class)
+        return "java/lang/Integer";
+      if (clazz == long.class)
+        return "java/lang/Long";
+      if (clazz == float.class)
+        return "java/lang/Float";
+      if (clazz == double.class)
+        return "java/lang/Double";
+      // assert false;
+      return null;
+    }
+
+    /**
+     * Returns the entry of this String in the Constant pool, adding it
+     * if necessary.
+     *
+     * @param str the String to resolve
+     * @return the index of the String in the constant pool
+     */
+    private char utf8Info(String str)
+    {
+      String utf8 = toUtf8(str);
+      int len = utf8.length();
+      return poolIndex("\1" + (char) (len >> 8) + (char) (len & 0xff) + utf8);
+    }
+
+    /**
+     * Returns the entry of the appropriate class info structure in the
+     * Constant pool, adding it if necessary.
+     *
+     * @param name the class name, in internal form
+     * @return the index of the ClassInfo in the constant pool
+     */
+    private char classInfo(String name)
+    {
+      char index = utf8Info(name);
+      char[] c = {7, (char) (index >> 8), (char) (index & 0xff)};
+      return poolIndex(new String(c));
+    }
+
+    /**
+     * Returns the entry of the appropriate class info structure in the
+     * Constant pool, adding it if necessary.
+     *
+     * @param clazz the class type
+     * @return the index of the ClassInfo in the constant pool
+     */
+    private char classInfo(Class clazz)
+    {
+      return classInfo(TypeSignature.getEncodingOfClass(clazz.getName(),
+                                                        false));
+    }
+
+    /**
+     * Returns the entry of the appropriate fieldref, methodref, or
+     * interfacemethodref info structure in the Constant pool, adding it
+     * if necessary.
+     *
+     * @param structure FIELD, METHOD, or INTERFACE
+     * @param clazz the class name, in internal form
+     * @param name the simple reference name
+     * @param type the type of the reference
+     * @return the index of the appropriate Info structure in the constant pool
+     */
+    private char refInfo(byte structure, String clazz, String name,
+                         String type)
+    {
+      char cindex = classInfo(clazz);
+      char ntindex = nameAndTypeInfo(name, type);
+      // relies on FIELD == 1, METHOD == 2, INTERFACE == 3
+      char[] c = {(char) (structure + 8),
+                  (char) (cindex >> 8), (char) (cindex & 0xff),
+                  (char) (ntindex >> 8), (char) (ntindex & 0xff)};
+      return poolIndex(new String(c));
+    }
+
+    /**
+     * Returns the entry of the appropriate nameAndTyperef info structure
+     * in the Constant pool, adding it if necessary.
+     *
+     * @param name the simple name
+     * @param type the reference type
+     * @return the index of the NameAndTypeInfo structure in the constant pool
+     */
+    private char nameAndTypeInfo(String name, String type)
+    {
+      char nindex = utf8Info(name);
+      char tindex = utf8Info(type);
+      char[] c = {12, (char) (nindex >> 8), (char) (nindex & 0xff),
+                  (char) (tindex >> 8), (char) (tindex & 0xff)};
+      return poolIndex(new String(c));
+    }
+
+    /**
+     * Converts a regular string to a UTF8 string, where the upper byte
+     * of every char is 0, and '\\u0000' is not in the string.  This is
+     * basically to use a String as a fancy byte[], and while it is less
+     * efficient in memory use, it is easier for hashing.
+     *
+     * @param str the original, in straight unicode
+     * @return a modified string, in UTF8 format in the low bytes
+     */
+    private String toUtf8(String str)
+    {
+      final char[] ca = str.toCharArray();
+      final int len = ca.length;
+
+      // Avoid object creation, if str is already fits UTF8.
+      int i;
+      for (i = 0; i < len; i++)
+        if (ca[i] == 0 || ca[i] > '\u007f')
+          break;
+      if (i == len)
+        return str;
+
+      final StringBuffer sb = new StringBuffer(str);
+      sb.setLength(i);
+      for ( ; i < len; i++)
+        {
+          final char c = ca[i];
+          if (c > 0 && c <= '\u007f')
+            sb.append(c);
+          else if (c <= '\u07ff') // includes '\0'
+            {
+              sb.append((char) (0xc0 | (c >> 6)));
+              sb.append((char) (0x80 | (c & 0x6f)));
+            }
+          else
+            {
+              sb.append((char) (0xe0 | (c >> 12)));
+              sb.append((char) (0x80 | ((c >> 6) & 0x6f)));
+              sb.append((char) (0x80 | (c & 0x6f)));
+            }
+        }
+      return sb.toString();
+    }
+
+    /**
+     * Returns the location of a byte sequence (conveniently wrapped in
+     * a String with all characters between \u0001 and \u00ff inclusive)
+     * in the constant pool, adding it if necessary.
+     *
+     * @param sequence the byte sequence to look for
+     * @return the index of the sequence
+     * @throws IllegalArgumentException if this would make the constant
+     *         pool overflow
+     */
+    private char poolIndex(String sequence)
+    {
+      Integer i = (Integer) poolEntries.get(sequence);
+      if (i == null)
+        {
+          // pool starts at index 1
+          int size = poolEntries.size() + 1;
+          if (size >= 65535)
+            throw new IllegalArgumentException("exceeds VM limitations");
+          i = new Integer(size);
+          poolEntries.put(sequence, i);
+          pool.append(sequence);
+        }
+      return (char) i.intValue();
+    }
+  } // class ClassFactory
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/README (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/README Thu Nov  8 16:56:19 2007
@@ -0,0 +1,4 @@
+README for java.lang.reflect:
+
+java.lang.reflect is now mostly empty.  We've carved out the classes that have
+to do with the VM and put them into the VM interface.

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/ReflectPermission.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/ReflectPermission.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,102 @@
+/* ReflectPermission.java - named permission for reflaction
+   Copyright (C) 2000, 2001, 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.lang.reflect;
+
+import java.security.BasicPermission;
+
+/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
+ * "The Java Language Specification", ISBN 0-201-63451-1
+ * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
+ */
+
+/**
+ * This class implements permissions for reflection.  This is a named
+ * permission, and the only defined name is suppressAccessChecks, which
+ * allows suppression of normal Java objects when using reflection.
+ *
+ * <table>
+ *  <tr>
+ *   <th>Permission Target Name</th>
+ *   <th>What Permission Allows</th>
+ *   <th>Risk of Allowing Permission</th>
+ *  </tr>
+ *  <tr>
+ *   <td><code>suppressAccessChecks</code></td>
+ *   <td>Ability to access fields, invoke methods, and construct objects
+ *       via reflection, including non-public members in contexts where
+ *       such access is not legal at compile-time.</td>
+ *   <td>This is dangerous. It exposes possibly confidential information,
+ *       and malicious code could interfere with the internals of the Virtual
+ *       Machine by corrupting private data.</td>
+ *  </tr>
+ * </table>
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public final class ReflectPermission
+  extends BasicPermission
+{
+  /**
+   * Compatible with JDK 1.2.
+   */
+  private static final long serialVersionUID = 7412737110241507485L;
+
+  /**
+   * Construct a ReflectPermission with the given name.
+   *
+   * @param name The permission name
+   */
+  public ReflectPermission(String name)
+  {
+    super(name);
+  }
+
+  /**
+   * Construct a ReflectPermission with the given name.
+   *
+   * @param name The permission name
+   * @param actions The actions; this is ignored and should be null
+   */
+  public ReflectPermission(String name, String actions)
+  {
+    super(name, actions);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/TODO (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/TODO Thu Nov  8 16:56:19 2007
@@ -0,0 +1,4 @@
+TODO for java.lang.reflect Java side
+
+- more tests!
+- Java 2 support (waiting on java.lang Java 2 support)

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/TODO

------------------------------------------------------------------------------
    svn:executable = *

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/Type.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/Type.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* Type.java - Superinterface for all types.
+   Copyright (C) 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.lang.reflect;
+
+/**
+ * Represents any <code>Type</code> within the Java programming
+ * language.  This may be a primitive type (e.g. <code>int</code>,
+ * an array type (e.g. <code>double[]>/code>), a raw type
+ * (e.g. <code>Calendar</code>), a parameterized type
+ * (e.g. <code>List<Boolean></code>, or a type
+ * variable (e.g. <code>T extends String</code>).
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */ 
+public interface Type
+{
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/TypeVariable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/TypeVariable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,99 @@
+/* TypeVariable.java
+   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 java.lang.reflect;
+
+/**
+ * <p> 
+ * This is a common interface for all type variables provided by
+ * the Java language.  Instances are created the first time a type
+ * variable is needed by one of the reflective methods declared in
+ * this package.
+ * </p>
+ * <p> 
+ * Creating a type variable requires resolving the appropriate type.
+ * This may involve resolving other classes as a side effect (e.g.
+ * if the type is nested inside other classes).  Creation should not
+ * involve resolving the bounds.  Repeated creation has no effect; an
+ * equivalent instance is returned.  Caching is not required, but all
+ * instances must be <code>equal()</code> to each other.
+ * </p>
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */ 
+/* FIXME[GENERICS]: Should be TypeVariable<T extends GenericDeclaration> */
+public interface TypeVariable
+  extends Type
+{
+
+  /**
+   * Returns an array of <code>Type</code> objects which represent the upper
+   * bounds of this type variable.  There is always a default bound of
+   * <code>Object</code>.  Any <code>ParameterizedType</code>s will be
+   * created as necessary, and other types resolved.
+   *
+   * @return an array of <code>Type</code> objects representing the upper
+   *         bounds.
+   * @throws TypeNotPresentException if any of the bounds refer to a
+   *         non-existant type.
+   * @throws MalformedParameterizedTypeException if the creation of a
+   *         <code>ParameterizedType</code> fails.
+   */
+  Type[] getBounds();
+
+
+  /**
+   * Returns a representation of the declaration used to declare this
+   * type variable.
+   *
+   * @return the <code>GenericDeclaration</code> object for this type
+   *         variable.
+   */
+  /* FIXME[GENERICS]: Should return type T */
+  GenericDeclaration getGenericDeclaration();
+
+  /**
+   * Returns the name of the type variable, as written in the source
+   * code.
+   *
+   * @return the name of the type variable.
+   */
+  String getName();
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/UndeclaredThrowableException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/UndeclaredThrowableException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,128 @@
+/* UndeclaredThrowableException.java -- wraps an undeclared checked exception
+   thrown by a Proxy invocation handler
+   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.lang.reflect;
+
+/**
+ * This exception class is thrown by a {@link Proxy} instance if
+ * the {@link InvocationHandler#invoke(Object, Method, Object[]) invoke}
+ * method of that instance's InvocationHandler attempts to throw an
+ * exception that not declared by the throws clauses of all of the
+ * interface methods that the proxy instance is implementing.
+ *
+ * <p>When thrown by Proxy, this class will always wrap a checked
+ * exception, never {@link Error} or {@link RuntimeException},
+ * which are unchecked.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Proxy
+ * @see InvocationHandler
+ * @since 1.3
+ * @status updated to 1.4
+ */
+public class UndeclaredThrowableException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.3+.
+   */
+  private static final long serialVersionUID = 330127114055056639L;
+
+  /**
+   * The immutable exception that this wraps. This field is redundant
+   * with {@link Throwable#getCause()}, but is necessary for serial compatibility.
+   *
+   * @serial the chained exception
+   */
+  private final Throwable undeclaredThrowable;
+
+  /**
+   * Wraps the given checked exception into a RuntimeException, with no
+   * detail message.  {@link Throwable#initCause(Throwable)} will fail
+   * on this instance.
+   *
+   * @param cause the undeclared throwable that caused this exception,
+   *        may be null
+   */
+  public UndeclaredThrowableException(Throwable cause)
+  {
+    this(cause, null);
+  }
+
+  /**
+   * Wraps the given checked exception into a RuntimeException, with the
+   * specified detail message.  {@link Throwable#initCause(Throwable)} will
+   * fail on this instance.
+   *
+   * @param cause the undeclared throwable that caused this exception,
+   *        may be null
+   * @param message the message, may be null
+   */
+  public UndeclaredThrowableException(Throwable cause, String message)
+  {
+    super(message, cause);
+    undeclaredThrowable = cause;
+  }
+
+  /**
+   * Returns the cause of this exception.  If this exception was created
+   * by a {@link Proxy} instance, it will be a non-null checked
+   * exception.  This method pre-dates exception chaining, and is now
+   * simply a longer way to call <code>getCause()</code>.
+   *
+   * @return the cause of this exception, may be null
+   * @see #getCause()
+   */
+  public Throwable getUndeclaredThrowable()
+  {
+    return undeclaredThrowable;
+  }
+
+  /**
+   * Returns the cause of this exception.  If this exception was created
+   * by a {@link Proxy} instance, it will be a non-null checked
+   * exception.
+   *
+   * @return the cause of this exception, may be null
+   * @since 1.4
+   */
+  public Throwable getCause()
+  {
+    return undeclaredThrowable;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/WildcardType.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/WildcardType.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,115 @@
+/* WildcardType.java -- A wildcard type expression e.g. ? extends String
+   Copyright (C) 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.lang.reflect;
+
+/**
+ * Represents a wildcard type expression, where the type variable
+ * is unnamed.  The simplest example of this is <code>?</code>,
+ * which represents any unbounded type.  Another example is
+ * <code>? extends Number</code>, which specifies any type
+ * which is a subclass of <code>Number</code> (<code>Number</code>
+ * is the upper bound).
+ * </p>
+ * <p>
+ * <code>? super String</code> gives the type a less common lower bound,
+ * which means that the type must be either a <code>String</code> or one
+ * of its superclasses. This can be useful in working with collections.
+ * You may want a method to add instances of a class to a collection
+ * with a more generic type (e.g. adding <code>String</code>s to
+ * a list of <code>Object</code>s), but don't want to allow users
+ * to pass in a collection with a more specific type.
+ * </p>
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface WildcardType extends Type
+{
+
+  /**
+   * <p>
+   * Returns an array of <code>Type</code>s, which specify the
+   * lower bounds of this type.  The default lower bound is
+   * <code>null</code>, which causes this method to return an
+   * empty array.
+   * </p>
+   * <p>
+   * In generating the array of <code>Type</code>s, each
+   * <code>ParameterizedType</code> or <code>TypeVariable</code> is
+   * created, (see the documentation for these classes for details of this
+   * process), if necessary, while all other types are simply
+   * resolved.
+   * </p>
+   *
+   * @return an array of <code>Type</code> objects, representing
+   *         the wildcard type's lower bounds.
+   * @throws TypeNotPresentException if any of the types referred to by
+   *         the lower bounds of this type do not actually exist.
+   * @throws MalformedParameterizedTypeException if any of the types
+   *         refer to a type which can not be instantiated.
+   */ 
+  Type[] getLowerBounds();
+
+  /**
+   * <p>
+   * Returns an array of <code>Type</code>s, which specify the
+   * upper bounds of this type.  The default upper bound is
+   * <code>Object</code>, which causes this method to return an
+   * array, containing just the <code>Type</code> instance for
+   * <code>Object</code>.
+   * </p>
+   * <p>
+   * In generating the array of <code>Type</code>s, each
+   * <code>ParameterizedType</code> or <code>TypeVariable</code> is
+   * created, (see the documentation for these classes for details of this
+   * process), if necessary, while all other types are simply
+   * resolved.
+   * </p>
+   *
+   * @return an array of <code>Type</code> objects, representing
+   *         the wildcard type's upper bounds.
+   * @throws TypeNotPresentException if any of the types referred to by
+   *         the upper bounds of this type do not actually exist.
+   * @throws MalformedParameterizedTypeException if any of the types
+   *         refer to a type which can not be instantiated.
+   */ 
+  Type[] getUpperBounds();
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/reflect/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.lang.reflect 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.lang.reflect</title></head>
+
+<body>
+<p>Runtime inspection and manipulation of object classes, methods, arguments
+and fields.</p>
+
+</body>
+</html>

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/math/BigDecimal.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/math/BigDecimal.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1514 @@
+/* java.math.BigDecimal -- Arbitrary precision decimals.
+   Copyright (C) 1999, 2000, 2001, 2003, 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.math;
+
+public class BigDecimal extends Number implements Comparable
+{
+  private BigInteger intVal;
+  private int scale;
+  private int precision = 0;
+  private static final long serialVersionUID = 6108874887143696463L;
+
+  /**
+   * The constant zero as a BigDecimal with scale zero.
+   * @since 1.5
+   */
+  public static final BigDecimal ZERO = 
+    new BigDecimal (BigInteger.ZERO, 0);
+
+  /**
+   * The constant one as a BigDecimal with scale zero.
+   * @since 1.5
+   */
+  public static final BigDecimal ONE = 
+    new BigDecimal (BigInteger.ONE, 0);
+
+  /**
+   * The constant ten as a BigDecimal with scale zero.
+   * @since 1.5
+   */
+  public static final BigDecimal TEN = 
+    new BigDecimal (BigInteger.TEN, 0);
+
+  public static final int ROUND_UP = 0;
+  public static final int ROUND_DOWN = 1;
+  public static final int ROUND_CEILING = 2;
+  public static final int ROUND_FLOOR = 3;
+  public static final int ROUND_HALF_UP = 4;
+  public static final int ROUND_HALF_DOWN = 5;
+  public static final int ROUND_HALF_EVEN = 6;
+  public static final int ROUND_UNNECESSARY = 7;
+
+  /**
+   * Constructs a new BigDecimal whose unscaled value is val and whose
+   * scale is zero.
+   * @param val the value of the new BigDecimal
+   * @since 1.5
+   */
+  public BigDecimal (int val)
+  {
+    this.intVal = BigInteger.valueOf(val);
+    this.scale = 0;
+  }
+  
+  /**
+   * Constructs a BigDecimal using the BigDecimal(int) constructor and then
+   * rounds according to the MathContext.
+   * @param val the value for the initial (unrounded) BigDecimal
+   * @param mc the MathContext specifying the rounding
+   * @throws ArithmeticException if the result is inexact but the rounding type
+   * is RoundingMode.UNNECESSARY
+   * @since 1.5
+   */
+  public BigDecimal (int val, MathContext mc)
+  {
+    this (val);
+    if (mc.getPrecision() != 0)
+      {
+        BigDecimal result = this.round(mc);
+        this.intVal = result.intVal;
+        this.scale = result.scale;
+        this.precision = result.precision;
+      }    
+  }
+  
+  /**
+   * Constructs a new BigDecimal whose unscaled value is val and whose
+   * scale is zero.
+   * @param val the value of the new BigDecimal
+   */
+  public BigDecimal (long val)
+  {
+    this.intVal = BigInteger.valueOf(val);
+    this.scale = 0;
+  }
+  
+  /**
+   * Constructs a BigDecimal from the long in the same way as BigDecimal(long)
+   * and then rounds according to the MathContext.
+   * @param val the long from which we create the initial BigDecimal
+   * @param mc the MathContext that specifies the rounding behaviour
+   * @throws ArithmeticException if the result is inexact but the rounding type
+   * is RoundingMode.UNNECESSARY
+   * @since 1.5
+   */
+  public BigDecimal (long val, MathContext mc)
+  {
+    this(val);
+    if (mc.getPrecision() != 0)
+      {
+        BigDecimal result = this.round(mc);
+        this.intVal = result.intVal;
+        this.scale = result.scale;
+        this.precision = result.precision;
+      }    
+  }
+  
+  /**
+   * Constructs a BigDecimal whose value is given by num rounded according to 
+   * mc.  Since num is already a BigInteger, the rounding refers only to the 
+   * precision setting in mc, if mc.getPrecision() returns an int lower than
+   * the number of digits in num, then rounding is necessary.
+   * @param num the unscaledValue, before rounding
+   * @param mc the MathContext that specifies the precision
+   * @throws ArithmeticException if the result is inexact but the rounding type
+   * is RoundingMode.UNNECESSARY
+   * * @since 1.5
+   */
+  public BigDecimal (BigInteger num, MathContext mc)
+  {
+    this (num, 0);
+    if (mc.getPrecision() != 0)
+      {
+        BigDecimal result = this.round(mc);
+        this.intVal = result.intVal;
+        this.scale = result.scale;
+        this.precision = result.precision;
+      }
+  }
+  
+  /**
+   * Constructs a BigDecimal from the String val according to the same
+   * rules as the BigDecimal(String) constructor and then rounds 
+   * according to the MathContext mc.
+   * @param val the String from which we construct the initial BigDecimal
+   * @param mc the MathContext that specifies the rounding
+   * @throws ArithmeticException if the result is inexact but the rounding type
+   * is RoundingMode.UNNECESSARY   
+   * @since 1.5
+   */
+  public BigDecimal (String val, MathContext mc)
+  {
+    this (val);
+    if (mc.getPrecision() != 0)
+      {
+        BigDecimal result = this.round(mc);
+        this.intVal = result.intVal;
+        this.scale = result.scale;
+        this.precision = result.precision;
+      }
+  }
+  
+  /**
+   * Constructs a BigDecimal whose unscaled value is num and whose
+   * scale is zero.
+   * @param num the value of the new BigDecimal
+   */
+  public BigDecimal (BigInteger num) 
+  {
+    this (num, 0);
+  }
+
+  /**
+   * Constructs a BigDecimal whose unscaled value is num and whose
+   * scale is scale.
+   * @param num
+   * @param scale
+   */
+  public BigDecimal (BigInteger num, int scale)
+  {
+    this.intVal = num;
+    this.scale = scale;
+  }
+  
+  /**
+   * Constructs a BigDecimal using the BigDecimal(BigInteger, int) 
+   * constructor and then rounds according to the MathContext.
+   * @param num the unscaled value of the unrounded BigDecimal
+   * @param scale the scale of the unrounded BigDecimal
+   * @param mc the MathContext specifying the rounding
+   * @throws ArithmeticException if the result is inexact but the rounding type
+   * is RoundingMode.UNNECESSARY
+   * @since 1.5
+   */
+  public BigDecimal (BigInteger num, int scale, MathContext mc)
+  {
+    this (num, scale);
+    if (mc.getPrecision() != 0)
+      {
+        BigDecimal result = this.round(mc);
+        this.intVal = result.intVal;
+        this.scale = result.scale;
+        this.precision = result.precision;
+      }
+  }
+
+  /**
+   * Constructs a BigDecimal in the same way as BigDecimal(double) and then
+   * rounds according to the MathContext.
+   * @param num the double from which the initial BigDecimal is created
+   * @param mc the MathContext that specifies the rounding behaviour
+   * @throws ArithmeticException if the result is inexact but the rounding type
+   * is RoundingMode.UNNECESSARY 
+   * @since 1.5
+   */
+  public BigDecimal (double num, MathContext mc)
+  {
+    this (num);
+    if (mc.getPrecision() != 0)
+      {
+        BigDecimal result = this.round(mc);
+        this.intVal = result.intVal;
+        this.scale = result.scale;
+        this.precision = result.precision;
+      }
+  }
+  
+  public BigDecimal (double num) throws NumberFormatException 
+  {
+    if (Double.isInfinite (num) || Double.isNaN (num))
+      throw new NumberFormatException ("invalid argument: " + num);
+    // Note we can't convert NUM to a String and then use the
+    // String-based constructor.  The BigDecimal documentation makes
+    // it clear that the two constructors work differently.
+
+    final int mantissaBits = 52;
+    final int exponentBits = 11;
+    final long mantMask = (1L << mantissaBits) - 1;
+    final long expMask = (1L << exponentBits) - 1;
+
+    long bits = Double.doubleToLongBits (num);
+    long mantissa = bits & mantMask;
+    long exponent = (bits >>> mantissaBits) & expMask;
+    boolean denormal = exponent == 0;
+
+    // Correct the exponent for the bias.
+    exponent -= denormal ? 1022 : 1023;
+
+    // Now correct the exponent to account for the bits to the right
+    // of the decimal.
+    exponent -= mantissaBits;
+    // Ordinary numbers have an implied leading `1' bit.
+    if (! denormal)
+      mantissa |= (1L << mantissaBits);
+
+    // Shave off factors of 10.
+    while (exponent < 0 && (mantissa & 1) == 0)
+      {
+	++exponent;
+	mantissa >>= 1;
+      }
+
+    intVal = BigInteger.valueOf (bits < 0 ? - mantissa : mantissa);
+    if (exponent < 0)
+      {
+	// We have MANTISSA * 2 ^ (EXPONENT).
+	// Since (1/2)^N == 5^N * 10^-N we can easily convert this
+	// into a power of 10.
+	scale = (int) (- exponent);
+	BigInteger mult = BigInteger.valueOf (5).pow (scale);
+	intVal = intVal.multiply (mult);
+      }
+    else
+      {
+	intVal = intVal.shiftLeft ((int) exponent);
+	scale = 0;
+      }
+  }
+
+  /**
+   * Constructs a BigDecimal from the char subarray and rounding 
+   * according to the MathContext.
+   * @param in the char array
+   * @param offset the start of the subarray
+   * @param len the length of the subarray
+   * @param mc the MathContext for rounding
+   * @throws NumberFormatException if the char subarray is not a valid 
+   * BigDecimal representation
+   * @throws ArithmeticException if the result is inexact but the rounding 
+   * mode is RoundingMode.UNNECESSARY
+   * @since 1.5
+   */
+  public BigDecimal(char[] in, int offset, int len, MathContext mc)
+  {
+    this(in, offset, len);
+    // If mc has precision other than zero then we must round.
+    if (mc.getPrecision() != 0)
+      {
+        BigDecimal temp = this.round(mc);
+        this.intVal = temp.intVal;
+        this.scale = temp.scale;
+        this.precision = temp.precision;
+      }
+  }
+  
+  /**
+   * Constructs a BigDecimal from the char array and rounding according
+   * to the MathContext. 
+   * @param in the char array
+   * @param mc the MathContext
+   * @throws NumberFormatException if <code>in</code> is not a valid BigDecimal
+   * representation
+   * @throws ArithmeticException if the result is inexact but the rounding mode
+   * is RoundingMode.UNNECESSARY
+   * @since 1.5
+   */
+  public BigDecimal(char[] in, MathContext mc)
+  {
+    this(in, 0, in.length);
+    // If mc has precision other than zero then we must round.
+    if (mc.getPrecision() != 0)
+      {
+        BigDecimal temp = this.round(mc);
+        this.intVal = temp.intVal;
+        this.scale = temp.scale;
+        this.precision = temp.precision;
+      } 
+  }
+  
+  /**
+   * Constructs a BigDecimal from the given char array, accepting the same
+   * sequence of characters as the BigDecimal(String) constructor.
+   * @param in the char array
+   * @throws NumberFormatException if <code>in</code> is not a valid BigDecimal
+   * representation
+   * @since 1.5
+   */
+  public BigDecimal(char[] in)
+  {
+    this(in, 0, in.length);
+  }
+  
+  /**
+   * Constructs a BigDecimal from a char subarray, accepting the same sequence
+   * of characters as the BigDecimal(String) constructor.  
+   * @param in the char array
+   * @param offset the start of the subarray
+   * @param len the length of the subarray
+   * @throws NumberFormatException if <code>in</code> is not a valid
+   * BigDecimal representation.
+   * @since 1.5
+   */
+  public BigDecimal(char[] in, int offset, int len)
+  {
+    //  start is the index into the char array where the significand starts
+    int start = offset;
+    //  end is one greater than the index of the last character used
+    int end = offset + len;
+    //  point is the index into the char array where the exponent starts
+    //  (or, if there is no exponent, this is equal to end)
+    int point = offset;
+    //  dot is the index into the char array where the decimal point is 
+    //  found, or -1 if there is no decimal point
+    int dot = -1;
+    
+    //  The following examples show what these variables mean.  Note that
+    //  point and dot don't yet have the correct values, they will be 
+    //  properly assigned in a loop later on in this method.
+    //
+    //  Example 1
+    //
+    //         +  1  0  2  .  4  6  9
+    //  __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
+    //
+    //  offset = 2, len = 8, start = 3, dot = 6, point = end = 10
+    //
+    //  Example 2
+    //
+    //         +  2  3  4  .  6  1  3  E  -  1
+    //  __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
+    //
+    //  offset = 2, len = 11, start = 3, dot = 6, point = 10, end = 13
+    //
+    //  Example 3
+    //
+    //         -  1  2  3  4  5  e  7  
+    //  __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
+    //
+    //  offset = 2, len = 8, start = 3, dot = -1, point = 8, end = 10 
+    
+    //  Determine the sign of the number.
+    boolean negative = false;
+    if (in[offset] == '+')
+      {
+        ++start;
+        ++point;
+      }
+    else if (in[offset] == '-')
+      {
+        ++start;
+        ++point;
+        negative = true;
+      }
+
+    //  Check each character looking for the decimal point and the 
+    //  start of the exponent.
+    while (point < end)
+      {
+        char c = in[point];
+        if (c == '.')
+          {
+            // If dot != -1 then we've seen more than one decimal point.
+            if (dot != -1)
+              throw new NumberFormatException("multiple `.'s in number");
+            dot = point;
+          }
+        // Break when we reach the start of the exponent.
+        else if (c == 'e' || c == 'E')
+          break;
+        // Throw an exception if the character was not a decimal or an 
+        // exponent and is not a digit.
+        else if (!Character.isDigit(c))
+          throw new NumberFormatException("unrecognized character at " + point
+                                          + ": " + c);
+        ++point;
+      }
+
+    // val is a StringBuilder from which we'll create a BigInteger
+    // which will be the unscaled value for this BigDecimal
+    StringBuilder val = new StringBuilder(point - start - 1);
+    if (dot != -1)
+      {
+        // If there was a decimal we must combine the two parts that 
+        // contain only digits and we must set the scale properly.
+        val.append(in, start, dot - start);
+        val.append(in, dot + 1, point - dot - 1);
+        scale = point - 1 - dot;
+      }
+    else
+      {
+        // If there was no decimal then the unscaled value is just the number
+        // formed from all the digits and the scale is zero.
+        val.append(in, start, point - start);
+        scale = 0;
+      }
+    if (val.length() == 0)
+      throw new NumberFormatException("no digits seen");
+
+    // Prepend a negative sign if necessary.
+    if (negative)
+      val.insert(0, '-');
+    intVal = new BigInteger(val.toString());
+
+    // Now parse exponent.
+    // If point < end that means we broke out of the previous loop when we
+    // saw an 'e' or an 'E'.
+    if (point < end)
+      {
+        point++;
+        // Ignore a '+' sign.
+        if (in[point] == '+')
+          point++;
+
+        // Throw an exception if there were no digits found after the 'e'
+        // or 'E'.
+        if (point >= end)
+          throw new NumberFormatException("no exponent following e or E");
+
+        try
+          {
+            // Adjust the scale according to the exponent.  
+            // Remember that the value of a BigDecimal is
+            // unscaledValue x Math.pow(10, -scale)
+            scale -= Integer.parseInt(new String(in, point, end - point));
+          }
+        catch (NumberFormatException ex)
+          {
+            throw new NumberFormatException("malformed exponent");
+          }
+      }
+  }
+  
+  public BigDecimal (String num) throws NumberFormatException 
+  {
+    int len = num.length();
+    int start = 0, point = 0;
+    int dot = -1;
+    boolean negative = false;
+    if (num.charAt(0) == '+')
+      {
+	++start;
+	++point;
+      }
+    else if (num.charAt(0) == '-')
+      {
+	++start;
+	++point;
+	negative = true;
+      }
+
+    while (point < len)
+      {
+	char c = num.charAt (point);
+	if (c == '.')
+	  {
+	    if (dot >= 0)
+	      throw new NumberFormatException ("multiple `.'s in number");
+	    dot = point;
+	  }
+	else if (c == 'e' || c == 'E')
+	  break;
+	else if (Character.digit (c, 10) < 0)
+	  throw new NumberFormatException ("unrecognized character: " + c);
+	++point;
+      }
+
+    String val;
+    if (dot >= 0)
+      {
+	val = num.substring (start, dot) + num.substring (dot + 1, point);
+	scale = point - 1 - dot;
+      }
+    else
+      {
+	val = num.substring (start, point);
+	scale = 0;
+      }
+    if (val.length () == 0)
+      throw new NumberFormatException ("no digits seen");
+
+    if (negative)
+      val = "-" + val;
+    intVal = new BigInteger (val);
+
+    // Now parse exponent.
+    if (point < len)
+      {
+        point++;
+        if (num.charAt(point) == '+')
+          point++;
+
+        if (point >= len )
+          throw new NumberFormatException ("no exponent following e or E");
+	
+        try 
+	  {	    
+        scale -= Integer.parseInt (num.substring (point));
+	  }
+        catch (NumberFormatException ex) 
+	  {
+	    throw new NumberFormatException ("malformed exponent");
+	  }
+      }
+  }
+
+  public static BigDecimal valueOf (long val) 
+  {
+    return valueOf (val, 0);
+  }
+
+  public static BigDecimal valueOf (long val, int scale) 
+    throws NumberFormatException 
+  {
+    if ((scale == 0) && ((int)val == val))
+      switch ((int) val)
+	{
+	case 0:
+	  return ZERO;
+	case 1:
+	  return ONE;
+	}
+
+    return new BigDecimal (BigInteger.valueOf (val), scale);
+  }
+
+  public BigDecimal add (BigDecimal val) 
+  {
+    // For addition, need to line up decimals.  Note that the movePointRight
+    // method cannot be used for this as it might return a BigDecimal with
+    // scale == 0 instead of the scale we need.
+    BigInteger op1 = intVal;
+    BigInteger op2 = val.intVal;
+    if (scale < val.scale)
+      op1 = op1.multiply (BigInteger.TEN.pow (val.scale - scale));
+    else if (scale > val.scale)
+      op2 = op2.multiply (BigInteger.TEN.pow (scale - val.scale));
+
+    return new BigDecimal (op1.add (op2), Math.max (scale, val.scale));
+  }
+  
+  /**
+   * Returns a BigDecimal whose value is found first by calling the 
+   * method add(val) and then by rounding according to the MathContext mc.
+   * @param val the augend
+   * @param mc the MathContext for rounding
+   * @throws ArithmeticException if the value is inexact but the rounding is
+   * RoundingMode.UNNECESSARY
+   * @return <code>this</code> + <code>val</code>, rounded if need be
+   * @since 1.5
+   */
+  public BigDecimal add (BigDecimal val, MathContext mc)
+  {
+    return add(val).round(mc);
+  }
+
+  public BigDecimal subtract (BigDecimal val) 
+  {
+    return this.add(val.negate());
+  }
+
+  /**
+   * Returns a BigDecimal whose value is found first by calling the 
+   * method subtract(val) and then by rounding according to the MathContext mc.
+   * @param val the subtrahend
+   * @param mc the MathContext for rounding
+   * @throws ArithmeticException if the value is inexact but the rounding is
+   * RoundingMode.UNNECESSARY
+   * @return <code>this</code> - <code>val</code>, rounded if need be
+   * @since 1.5
+   */
+  public BigDecimal subtract (BigDecimal val, MathContext mc)
+  {
+    return subtract(val).round(mc);
+  }
+
+  public BigDecimal multiply (BigDecimal val) 
+  {
+    return new BigDecimal (intVal.multiply (val.intVal), scale + val.scale);
+  }
+  
+  /**
+   * Returns a BigDecimal whose value is (this x val) before it is rounded
+   * according to the MathContext mc. 
+   * @param val the multiplicand
+   * @param mc the MathContext for rounding
+   * @return a new BigDecimal with value approximately (this x val)
+   * @throws ArithmeticException if the value is inexact but the rounding mode
+   * is RoundingMode.UNNECESSARY
+   * @since 1.5
+   */
+  public BigDecimal multiply (BigDecimal val, MathContext mc)
+  {
+    return multiply(val).round(mc);
+  }
+
+  public BigDecimal divide (BigDecimal val, int roundingMode) 
+    throws ArithmeticException, IllegalArgumentException 
+  {
+    return divide (val, scale, roundingMode);
+  }
+   
+  public BigDecimal divide(BigDecimal val, int newScale, int roundingMode)
+    throws ArithmeticException, IllegalArgumentException 
+  {
+    if (roundingMode < 0 || roundingMode > 7)
+      throw 
+	new IllegalArgumentException("illegal rounding mode: " + roundingMode);
+
+    if (intVal.signum () == 0)	// handle special case of 0.0/0.0
+      return newScale == 0 ? ZERO : new BigDecimal (ZERO.intVal, newScale);
+    
+    // Ensure that pow gets a non-negative value.
+    BigInteger valIntVal = val.intVal;
+    int power = newScale - (scale - val.scale);
+    if (power < 0)
+      {
+	// Effectively increase the scale of val to avoid an
+	// ArithmeticException for a negative power.
+        valIntVal = valIntVal.multiply (BigInteger.TEN.pow (-power));
+	power = 0;
+      }
+
+    BigInteger dividend = intVal.multiply (BigInteger.TEN.pow (power));
+    
+    BigInteger parts[] = dividend.divideAndRemainder (valIntVal);
+
+    BigInteger unrounded = parts[0];
+    if (parts[1].signum () == 0) // no remainder, no rounding necessary
+      return new BigDecimal (unrounded, newScale);
+
+    if (roundingMode == ROUND_UNNECESSARY)
+      throw new ArithmeticException ("Rounding necessary");
+
+    int sign = intVal.signum () * valIntVal.signum ();
+
+    if (roundingMode == ROUND_CEILING)
+      roundingMode = (sign > 0) ? ROUND_UP : ROUND_DOWN;
+    else if (roundingMode == ROUND_FLOOR)
+      roundingMode = (sign < 0) ? ROUND_UP : ROUND_DOWN;
+    else
+      {
+	// half is -1 if remainder*2 < positive intValue (*power), 0 if equal,
+	// 1 if >. This implies that the remainder to round is less than,
+	// equal to, or greater than half way to the next digit.
+	BigInteger posRemainder
+	  = parts[1].signum () < 0 ? parts[1].negate() : parts[1];
+	valIntVal = valIntVal.signum () < 0 ? valIntVal.negate () : valIntVal;
+	int half = posRemainder.shiftLeft(1).compareTo(valIntVal);
+
+	switch(roundingMode)
+	  {
+	  case ROUND_HALF_UP:
+	    roundingMode = (half < 0) ? ROUND_DOWN : ROUND_UP;
+	    break;
+	  case ROUND_HALF_DOWN:
+	    roundingMode = (half > 0) ? ROUND_UP : ROUND_DOWN;
+	    break;
+	  case ROUND_HALF_EVEN:
+	    if (half < 0)
+	      roundingMode = ROUND_DOWN;
+	    else if (half > 0)
+	      roundingMode = ROUND_UP;
+	    else if (unrounded.testBit(0)) // odd, then ROUND_HALF_UP
+	      roundingMode = ROUND_UP;
+	    else                           // even, ROUND_HALF_DOWN
+	      roundingMode = ROUND_DOWN;
+	    break;
+	  }
+      }
+
+    if (roundingMode == ROUND_UP)
+      unrounded = unrounded.add (BigInteger.valueOf (sign > 0 ? 1 : -1));
+
+    // roundingMode == ROUND_DOWN
+    return new BigDecimal (unrounded, newScale);
+  }
+  
+  /**
+   * Performs division, if the resulting quotient requires rounding
+   * (has a nonterminating decimal expansion), 
+   * an ArithmeticException is thrown. 
+   * #see divide(BigDecimal, int, int)
+   * @since 1.5
+   */
+  public BigDecimal divide(BigDecimal divisor)
+    throws ArithmeticException, IllegalArgumentException 
+  {
+    return divide(divisor, scale, ROUND_UNNECESSARY);
+  }
+
+  /**
+   * Returns a BigDecimal whose value is the remainder in the quotient
+   * this / val.  This is obtained by 
+   * subtract(divideToIntegralValue(val).multiply(val)).  
+   * @param val the divisor
+   * @return a BigDecimal whose value is the remainder
+   * @throws ArithmeticException if val == 0
+   * @since 1.5
+   */
+  public BigDecimal remainder(BigDecimal val)
+  {
+    return subtract(divideToIntegralValue(val).multiply(val));
+  }
+
+  /**
+   * Returns a BigDecimal array, the first element of which is the integer part
+   * of this / val, and the second element of which is the remainder of 
+   * that quotient.
+   * @param val the divisor
+   * @return the above described BigDecimal array
+   * @throws ArithmeticException if val == 0
+   * @since 1.5
+   */
+  public BigDecimal[] divideAndRemainder(BigDecimal val)
+  {
+    BigDecimal[] result = new BigDecimal[2];
+    result[0] = divideToIntegralValue(val);
+    result[1] = subtract(result[0].multiply(val));
+    return result;
+  }
+  
+  /**
+   * Returns a BigDecimal whose value is the integer part of the quotient 
+   * this / val.  The preferred scale is this.scale - val.scale.
+   * @param val the divisor
+   * @return a BigDecimal whose value is the integer part of this / val.
+   * @throws ArithmeticException if val == 0
+   * @since 1.5
+   */
+  public BigDecimal divideToIntegralValue(BigDecimal val)
+  {
+    return divide(val, ROUND_DOWN).floor().setScale(scale - val.scale, ROUND_DOWN);
+  }
+  
+  /**
+   * Mutates this BigDecimal into one with no fractional part, whose value is 
+   * equal to the largest integer that is <= to this BigDecimal.  Note that
+   * since this method is private it is okay to mutate this BigDecimal.
+   * @return the BigDecimal obtained through the floor operation on this 
+   * BigDecimal.
+   */
+  private BigDecimal floor()
+  {
+    if (scale <= 0)
+      return this;
+    String intValStr = intVal.toString();
+    intValStr = intValStr.substring(0, intValStr.length() - scale);
+    intVal = new BigInteger(intValStr).multiply(BigInteger.TEN.pow(scale));
+    return this;
+  }
+    
+  public int compareTo (Object obj) 
+  {
+    return compareTo((BigDecimal) obj);
+  }
+
+  public int compareTo (BigDecimal val)
+  {
+    if (scale == val.scale)
+      return intVal.compareTo (val.intVal);
+
+    BigInteger thisParts[] = 
+      intVal.divideAndRemainder (BigInteger.TEN.pow (scale));
+    BigInteger valParts[] =
+      val.intVal.divideAndRemainder (BigInteger.TEN.pow (val.scale));
+    
+    int compare;
+    if ((compare = thisParts[0].compareTo (valParts[0])) != 0)
+      return compare;
+
+    // quotients are the same, so compare remainders
+
+    // Add some trailing zeros to the remainder with the smallest scale
+    if (scale < val.scale)
+      thisParts[1] = thisParts[1].multiply
+			(BigInteger.valueOf (10).pow (val.scale - scale));
+    else if (scale > val.scale)
+      valParts[1] = valParts[1].multiply
+			(BigInteger.valueOf (10).pow (scale - val.scale));
+
+    // and compare them
+    return thisParts[1].compareTo (valParts[1]);
+  }
+
+  public boolean equals (Object o) 
+  {
+    return (o instanceof BigDecimal 
+	    && scale == ((BigDecimal) o).scale
+	    && compareTo ((BigDecimal) o) == 0);
+  }
+
+  public int hashCode() 
+  {
+    return intValue() ^ scale;
+  }
+
+  public BigDecimal max (BigDecimal val)
+  {
+    switch (compareTo (val)) 
+      {
+      case 1:
+	return this;
+      default:
+	return val;
+      }
+  }
+
+  public BigDecimal min (BigDecimal val) 
+  {
+    switch (compareTo (val)) 
+      {
+      case -1:
+	return this;
+      default:
+	return val;
+      }
+  }
+
+  public BigDecimal movePointLeft (int n)
+  {
+    return (n < 0) ? movePointRight (-n) : new BigDecimal (intVal, scale + n);
+  }
+
+  public BigDecimal movePointRight (int n)
+  {
+    if (n < 0)
+      return movePointLeft (-n);
+
+    if (scale >= n)
+      return new BigDecimal (intVal, scale - n);
+
+    return new BigDecimal (intVal.multiply 
+			   (BigInteger.TEN.pow (n - scale)), 0);
+  }
+
+  public int signum () 
+  {
+    return intVal.signum ();
+  }
+
+  public int scale () 
+  {
+    return scale;
+  }
+  
+  public BigInteger unscaledValue()
+  {
+    return intVal;
+  }
+
+  public BigDecimal abs () 
+  {
+    return new BigDecimal (intVal.abs (), scale);
+  }
+
+  public BigDecimal negate () 
+  {
+    return new BigDecimal (intVal.negate (), scale);
+  }
+  
+  /**
+   * Returns a BigDecimal whose value is found first by negating this via
+   * the negate() method, then by rounding according to the MathContext mc.
+   * @param mc the MathContext for rounding
+   * @return a BigDecimal whose value is approximately (-this)
+   * @throws ArithmeticException if the value is inexact but the rounding mode
+   * is RoundingMode.UNNECESSARY
+   * @since 1.5
+   */
+  public BigDecimal negate(MathContext mc)
+  {
+    BigDecimal result = negate();
+    if (mc.getPrecision() != 0)
+      result = result.round(mc);
+    return result;
+  }
+  
+  /**
+   * Returns this BigDecimal.  This is included for symmetry with the 
+   * method negate().
+   * @return this
+   * @since 1.5
+   */
+  public BigDecimal plus()
+  {
+    return this;
+  }
+  
+  /**
+   * Returns a BigDecimal whose value is found by rounding <code>this</code> 
+   * according to the MathContext.  This is the same as round(MathContext).
+   * @param mc the MathContext for rounding
+   * @return a BigDecimal whose value is <code>this</code> before being rounded
+   * @throws ArithmeticException if the value is inexact but the rounding mode
+   * is RoundingMode.UNNECESSARY
+   * @since 1.5
+   */
+  public BigDecimal plus(MathContext mc)
+  {
+    return round(mc);
+  }
+   
+  /**
+   * Returns a BigDecimal which is this BigDecimal rounded according to the
+   * MathContext rounding settings.
+   * @param mc the MathContext that tells us how to round
+   * @return the rounded BigDecimal
+   */
+  public BigDecimal round(MathContext mc)
+  {
+    int mcPrecision = mc.getPrecision();
+    int numToChop = precision() - mcPrecision;
+    // If mc specifies not to chop any digits or if we've already chopped 
+    // enough digits (say by using a MathContext in the constructor for this
+    // BigDecimal) then just return this.
+    if (mcPrecision == 0 || numToChop <= 0)
+      return this;
+    
+    // Make a new BigDecimal which is the correct power of 10 to chop off
+    // the required number of digits and then call divide.
+    BigDecimal div = new BigDecimal(BigInteger.TEN.pow(numToChop));
+    BigDecimal rounded = divide(div, scale, 4);
+    rounded.scale -= numToChop;
+    rounded.precision = mcPrecision;
+    return rounded;
+  }
+
+  /**
+   * Returns the precision of this BigDecimal (the number of digits in the
+   * unscaled value).  The precision of a zero value is 1.
+   * @return the number of digits in the unscaled value, or 1 if the value 
+   * is zero.
+   */
+  public int precision()
+  {
+    if (precision == 0)
+      {
+	String s = intVal.toString();
+	precision = s.length() - (( s.charAt(0) == '-' ) ? 1 : 0);
+      }
+    return precision;
+  }
+  
+  /**
+   * Returns the String representation of this BigDecimal, using scientific
+   * notation if necessary.  The following steps are taken to generate
+   * the result:
+   * 
+   * 1. the BigInteger unscaledValue's toString method is called and if
+   * <code>scale == 0<code> is returned.
+   * 2. an <code>int adjExp</code> is created which is equal to the negation
+   * of <code>scale</code> plus the number of digits in the unscaled value, 
+   * minus one.
+   * 3. if <code>scale >= 0 && adjExp >= -6</code> then we represent this 
+   * BigDecimal without scientific notation.  A decimal is added if the 
+   * scale is positive and zeros are prepended as necessary.
+   * 4. if scale is negative or adjExp is less than -6 we use scientific
+   * notation.  If the unscaled value has more than one digit, a decimal 
+   * as inserted after the first digit, the character 'E' is appended
+   * and adjExp is appended.
+   */
+  public String toString()
+  {
+    // bigStr is the String representation of the unscaled value.  If
+    // scale is zero we simply return this.
+    String bigStr = intVal.toString();
+    if (scale == 0)
+      return bigStr;
+
+    boolean negative = (bigStr.charAt(0) == '-');
+    int point = bigStr.length() - scale - (negative ? 1 : 0);
+
+    StringBuilder val = new StringBuilder();
+
+    if (scale >= 0 && (point - 1) >= -6)
+      {
+	// Convert to character form without scientific notation.
+        if (point <= 0)
+          {
+            // Zeros need to be prepended to the StringBuilder.
+            if (negative)
+              val.append('-');
+            // Prepend a '0' and a '.' and then as many more '0's as necessary.
+            val.append('0').append('.');
+            while (point < 0)
+              {
+                val.append('0');
+                point++;
+              }
+            // Append the unscaled value.
+            val.append(bigStr.substring(negative ? 1 : 0));
+          }
+        else
+          {
+            // No zeros need to be prepended so the String is simply the 
+            // unscaled value with the decimal point inserted.
+            val.append(bigStr);
+            val.insert(point + (negative ? 1 : 0), '.');
+          }
+      }
+    else
+      {
+        // We must use scientific notation to represent this BigDecimal.
+        val.append(bigStr);
+        // If there is more than one digit in the unscaled value we put a 
+        // decimal after the first digit.
+        if (bigStr.length() > 1)
+          val.insert( ( negative ? 2 : 1 ), '.');
+        // And then append 'E' and the exponent = (point - 1).
+        val.append('E');
+        if (point - 1 >= 0)
+          val.append('+');
+        val.append( point - 1 );
+      }
+    return val.toString();
+  }
+
+  /**
+   * Returns the String representation of this BigDecimal, using engineering
+   * notation if necessary.  This is similar to toString() but when exponents 
+   * are used the exponent is made to be a multiple of 3 such that the integer
+   * part is between 1 and 999.
+   * 
+   * @return a String representation of this BigDecimal in engineering notation
+   * @since 1.5
+   */
+  public String toEngineeringString()
+  {
+    // bigStr is the String representation of the unscaled value.  If
+    // scale is zero we simply return this.
+    String bigStr = intVal.toString();
+    if (scale == 0)
+      return bigStr;
+
+    boolean negative = (bigStr.charAt(0) == '-');
+    int point = bigStr.length() - scale - (negative ? 1 : 0);
+
+    // This is the adjusted exponent described above.
+    int adjExp = point - 1;
+    StringBuilder val = new StringBuilder();
+
+    if (scale >= 0 && adjExp >= -6)
+      {
+        // Convert to character form without scientific notation.
+        if (point <= 0)
+          {
+            // Zeros need to be prepended to the StringBuilder.
+            if (negative)
+              val.append('-');
+            // Prepend a '0' and a '.' and then as many more '0's as necessary.
+            val.append('0').append('.');
+            while (point < 0)
+              {
+                val.append('0');
+                point++;
+              }
+            // Append the unscaled value.
+            val.append(bigStr.substring(negative ? 1 : 0));
+          }
+        else
+          {
+            // No zeros need to be prepended so the String is simply the 
+            // unscaled value with the decimal point inserted.
+            val.append(bigStr);
+            val.insert(point + (negative ? 1 : 0), '.');
+          }
+      }
+    else
+      {
+        // We must use scientific notation to represent this BigDecimal.
+        // The exponent must be a multiple of 3 and the integer part
+        // must be between 1 and 999.
+        val.append(bigStr);        
+        int zeros = adjExp % 3;
+        int dot = 1;
+        if (adjExp > 0)
+          {
+            // If the exponent is positive we just move the decimal to the
+            // right and decrease the exponent until it is a multiple of 3.
+            dot += zeros;
+            adjExp -= zeros;
+          }
+        else
+          {
+            // If the exponent is negative then we move the dot to the right
+            // and decrease the exponent (increase its magnitude) until 
+            // it is a multiple of 3.  Note that this is not adjExp -= zeros
+            // because the mod operator doesn't give us the distance to the 
+            // correct multiple of 3.  (-5 mod 3) is -2 but the distance from
+            // -5 to the correct multiple of 3 (-6) is 1, not 2.
+            if (zeros == -2)
+              {
+                dot += 1;
+                adjExp -= 1;
+              }
+            else if (zeros == -1)
+              {
+                dot += 2;
+                adjExp -= 2;
+              }
+          }
+
+        // Either we have to append zeros because, for example, 1.1E+5 should
+        // be 110E+3, or we just have to put the decimal in the right place.
+        if (dot > val.length())
+          {
+            while (dot > val.length())
+              val.append('0');
+          }
+        else if (bigStr.length() > dot)
+          val.insert(dot + (negative ? 1 : 0), '.');
+        
+        // And then append 'E' and the exponent (adjExp).
+        val.append('E');
+        if (adjExp >= 0)
+          val.append('+');
+        val.append(adjExp);
+      }
+    return val.toString();
+  }
+  
+  /**
+   * Returns a String representation of this BigDecimal without using 
+   * scientific notation.  This is how toString() worked for releases 1.4
+   * and previous.  Zeros may be added to the end of the String.  For
+   * example, an unscaled value of 1234 and a scale of -3 would result in 
+   * the String 1234000, but the toString() method would return 
+   * 1.234E+6.
+   * @return a String representation of this BigDecimal
+   * @since 1.5
+   */
+  public String toPlainString()
+  {
+    // If the scale is zero we simply return the String representation of the 
+    // unscaled value.
+    String bigStr = intVal.toString();
+    if (scale == 0)
+      return bigStr;
+
+    // Remember if we have to put a negative sign at the start.
+    boolean negative = (bigStr.charAt(0) == '-');
+
+    int point = bigStr.length() - scale - (negative ? 1 : 0);
+
+    StringBuffer sb = new StringBuffer(bigStr.length() + 2
+                                       + (point <= 0 ? (-point + 1) : 0));
+    if (point <= 0)
+      {
+        // We have to prepend zeros and a decimal point.
+        if (negative)
+          sb.append('-');
+        sb.append('0').append('.');
+        while (point < 0)
+          {
+            sb.append('0');
+            point++;
+          }
+        sb.append(bigStr.substring(negative ? 1 : 0));
+      }
+    else if (point < bigStr.length())
+      {
+        // No zeros need to be prepended or appended, just put the decimal
+        // in the right place.
+        sb.append(bigStr);
+        sb.insert(point + (negative ? 1 : 0), '.');
+      }
+    else
+      {
+        // We must append zeros instead of using scientific notation.
+        sb.append(bigStr);
+        for (int i = bigStr.length(); i < point; i++)
+          sb.append('0');
+      }
+    return sb.toString();
+  }
+  
+  /**
+   * Converts this BigDecimal to a BigInteger.  Any fractional part will
+   * be discarded.
+   * @return a BigDecimal whose value is equal to floor[this]
+   */
+  public BigInteger toBigInteger () 
+  {
+    // If scale > 0 then we must divide, if scale > 0 then we must multiply,
+    // and if scale is zero then we just return intVal;
+    if (scale > 0)
+      return intVal.divide (BigInteger.TEN.pow (scale));
+    else if (scale < 0)
+      return intVal.multiply(BigInteger.TEN.pow(-scale));
+    return intVal;
+  }
+  
+  /**
+   * Converts this BigDecimal into a BigInteger, throwing an 
+   * ArithmeticException if the conversion is not exact.
+   * @return a BigInteger whose value is equal to the value of this BigDecimal
+   * @since 1.5
+   */
+  public BigInteger toBigIntegerExact()
+  {
+    if (scale > 0)
+      {
+        // If we have to divide, we must check if the result is exact.
+        BigInteger[] result = 
+          intVal.divideAndRemainder(BigInteger.TEN.pow(scale));
+        if (result[1].equals(BigInteger.ZERO))
+          return result[0];
+        throw new ArithmeticException("No exact BigInteger representation");
+      }
+    else if (scale < 0)
+      // If we're multiplying instead, then we needn't check for exactness.
+      return intVal.multiply(BigInteger.TEN.pow(-scale));
+    // If the scale is zero we can simply return intVal.
+    return intVal;
+  }
+
+  public int intValue () 
+  {
+    return toBigInteger ().intValue ();
+  }
+  
+  /**
+   * Returns a BigDecimal which is numerically equal to this BigDecimal but 
+   * with no trailing zeros in the representation.  For example, if this 
+   * BigDecimal has [unscaledValue, scale] = [6313000, 4] this method returns
+   * a BigDecimal with [unscaledValue, scale] = [6313, 1].  As another 
+   * example, [12400, -2] would become [124, -4].
+   * @return a numerically equal BigDecimal with no trailing zeros
+   */
+  public BigDecimal stripTrailingZeros()  
+  {
+    String intValStr = intVal.toString();
+    int newScale = scale;
+    int pointer = intValStr.length() - 1;
+    // This loop adjusts pointer which will be used to give us the substring
+    // of intValStr to use in our new BigDecimal, and also accordingly
+    // adjusts the scale of our new BigDecimal.
+    while (intValStr.charAt(pointer) == '0')
+      {
+        pointer --;
+        newScale --;
+      }
+    // Create a new BigDecimal with the appropriate substring and then
+    // set its scale.
+    BigDecimal result = new BigDecimal(intValStr.substring(0, pointer + 1));    
+    result.scale = newScale;
+    return result;
+  }
+
+  public long longValue ()
+  {
+    return toBigInteger().longValue();
+  }
+
+  public float floatValue() 
+  {
+    return Float.valueOf(toString()).floatValue();
+  }
+
+  public double doubleValue() 
+  {
+    return Double.valueOf(toString()).doubleValue();
+  }
+
+  public BigDecimal setScale (int scale) throws ArithmeticException
+  {
+    return setScale (scale, ROUND_UNNECESSARY);
+  }
+
+  public BigDecimal setScale (int scale, int roundingMode)
+    throws ArithmeticException, IllegalArgumentException
+  {
+    // NOTE: The 1.5 JRE doesn't throw this, ones prior to it do and
+    // the spec says it should. Nevertheless, if 1.6 doesn't fix this
+    // we should consider removing it.
+    if( scale < 0 ) throw new ArithmeticException("Scale parameter < 0.");
+    return divide (ONE, scale, roundingMode);
+  }
+   
+  /**
+   * Returns a new BigDecimal constructed from the BigDecimal(String) 
+   * constructor using the Double.toString(double) method to obtain
+   * the String.
+   * @param val the double value used in Double.toString(double)
+   * @return a BigDecimal representation of val
+   * @throws NumberFormatException if val is NaN or infinite
+   * @since 1.5
+   */
+  public static BigDecimal valueOf(double val)
+  {
+    if (Double.isInfinite(val) || Double.isNaN(val))
+      throw new NumberFormatException("argument cannot be NaN or infinite.");
+    return new BigDecimal(Double.toString(val));
+  }
+  
+  /**
+   * Returns a BigDecimal whose numerical value is the numerical value
+   * of this BigDecimal multiplied by 10 to the power of <code>n</code>. 
+   * @param n the power of ten
+   * @return the new BigDecimal
+   * @since 1.5
+   */
+  public BigDecimal scaleByPowerOfTen(int n)
+  {
+    BigDecimal result = new BigDecimal(intVal, scale - n);
+    result.precision = precision;
+    return result;
+  }
+  
+  /**
+   * Returns a BigDecimal whose value is <code>this</code> to the power of 
+   * <code>n</code>. 
+   * @param n the power
+   * @return the new BigDecimal
+   * @since 1.5
+   */
+  public BigDecimal pow(int n)
+  {
+    if (n < 0 || n > 999999999)
+      throw new ArithmeticException("n must be between 0 and 999999999");
+    BigDecimal result = new BigDecimal(intVal.pow(n), scale * n);
+    return result;
+  }
+  
+  /**
+   * Returns a BigDecimal whose value is determined by first calling pow(n)
+   * and then by rounding according to the MathContext mc.
+   * @param n the power
+   * @param mc the MathContext
+   * @return the new BigDecimal
+   * @throws ArithmeticException if n < 0 or n > 999999999 or if the result is
+   * inexact but the rounding is RoundingMode.UNNECESSARY
+   * @since 1.5
+   */
+  public BigDecimal pow(int n, MathContext mc)
+  {
+    // FIXME: The specs claim to use the X3.274-1996 algorithm.  We
+    // currently do not.
+    return pow(n).round(mc);
+  }
+  
+  /**
+   * Returns a BigDecimal whose value is the absolute value of this BigDecimal
+   * with rounding according to the given MathContext.
+   * @param mc the MathContext
+   * @return the new BigDecimal
+   */
+  public BigDecimal abs(MathContext mc)
+  {
+    BigDecimal result = abs();
+    result = result.round(mc);
+    return result;
+  }
+  
+  /**
+   * Returns the size of a unit in the last place of this BigDecimal.  This
+   * returns a BigDecimal with [unscaledValue, scale] = [1, this.scale()].
+   * @return the size of a unit in the last place of <code>this</code>.
+   * @since 1.5
+   */
+  public BigDecimal ulp()
+  {
+    return new BigDecimal(BigInteger.ONE, scale);
+  }
+  
+  /**
+   * Converts this BigDecimal to a long value.
+   * @return the long value
+   * @throws ArithmeticException if rounding occurs or if overflow occurs
+   * @since 1.5
+   */
+  public long longValueExact()
+  {
+    // Set scale will throw an exception if rounding occurs.
+    BigDecimal temp = setScale(0, ROUND_UNNECESSARY);
+    BigInteger tempVal = temp.intVal;
+    // Check for overflow.
+    long result = intVal.longValue();
+    if (tempVal.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 1
+        || (result < 0 && signum() == 1) || (result > 0 && signum() == -1))
+      throw new ArithmeticException("this BigDecimal is too " +
+            "large to fit into the return type");
+    
+    return intVal.longValue();
+  }
+  
+  /**
+   * Converts this BigDecimal into an int by first calling longValueExact
+   * and then checking that the <code>long</code> returned from that
+   * method fits into an <code>int</code>.
+   * @return an int whose value is <code>this</code>
+   * @throws ArithmeticException if this BigDecimal has a fractional part
+   * or is too large to fit into an int.
+   * @since 1.5
+   */
+  public int intValueExact()
+  {
+    long temp = longValueExact();
+    int result = (int)temp;
+    if (result != temp)
+      throw new ArithmeticException ("this BigDecimal cannot fit into an int");
+    return result;
+  }
+  
+  /**
+   * Converts this BigDecimal into a byte by first calling longValueExact
+   * and then checking that the <code>long</code> returned from that
+   * method fits into a <code>byte</code>.
+   * @return a byte whose value is <code>this</code>
+   * @throws ArithmeticException if this BigDecimal has a fractional part
+   * or is too large to fit into a byte.
+   * @since 1.5
+   */
+  public byte byteValueExact()
+  {
+    long temp = longValueExact();
+    byte result = (byte)temp;
+    if (result != temp)
+      throw new ArithmeticException ("this BigDecimal cannot fit into a byte");
+    return result;
+  }
+  
+  /**
+   * Converts this BigDecimal into a short by first calling longValueExact
+   * and then checking that the <code>long</code> returned from that
+   * method fits into a <code>short</code>.
+   * @return a short whose value is <code>this</code>
+   * @throws ArithmeticException if this BigDecimal has a fractional part
+   * or is too large to fit into a short.
+   * @since 1.5
+   */
+  public short shortValueExact()
+  {
+    long temp = longValueExact();
+    short result = (short)temp;
+    if (result != temp)
+      throw new ArithmeticException ("this BigDecimal cannot fit into a short");
+    return result;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/math/BigInteger.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/math/BigInteger.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,2251 @@
+/* java.math.BigInteger -- Arbitary precision integers
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 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.math;
+
+import gnu.java.math.MPN;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Random;
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998) and
+ * "Applied Cryptography, Second Edition" by Bruce Schneier (Wiley, 1996).
+ * 
+ * Based primarily on IntNum.java BitOps.java by Per Bothner (per at bothner.com)
+ * (found in Kawa 1.6.62).
+ *
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @date December 20, 1999.
+ * @status believed complete and correct.
+ */
+public class BigInteger extends Number implements Comparable
+{
+  /** All integers are stored in 2's-complement form.
+   * If words == null, the ival is the value of this BigInteger.
+   * Otherwise, the first ival elements of words make the value
+   * of this BigInteger, stored in little-endian order, 2's-complement form. */
+  private transient int ival;
+  private transient int[] words;
+
+  // Serialization fields.
+  private int bitCount = -1;
+  private int bitLength = -1;
+  private int firstNonzeroByteNum = -2;
+  private int lowestSetBit = -2;
+  private byte[] magnitude;
+  private int signum;
+  private static final long serialVersionUID = -8287574255936472291L;
+
+
+  /** We pre-allocate integers in the range minFixNum..maxFixNum. 
+   * Note that we must at least preallocate 0, 1, and 10.  */
+  private static final int minFixNum = -100;
+  private static final int maxFixNum = 1024;
+  private static final int numFixNum = maxFixNum-minFixNum+1;
+  private static final BigInteger[] smallFixNums = new BigInteger[numFixNum];
+
+  static {
+    for (int i = numFixNum;  --i >= 0; )
+      smallFixNums[i] = new BigInteger(i + minFixNum);
+  }
+
+  /**
+   * The constant zero as a BigInteger.
+   * @since 1.2
+   */
+  public static final BigInteger ZERO = smallFixNums[-minFixNum];
+
+  /**
+   * The constant one as a BigInteger.
+   * @since 1.2
+   */
+  public static final BigInteger ONE = smallFixNums[1 - minFixNum];
+  
+  /**
+   * The constant ten as a BigInteger.
+   * @since 1.5
+   */
+  public static final BigInteger TEN = smallFixNums[10 - minFixNum];
+
+  /* Rounding modes: */
+  private static final int FLOOR = 1;
+  private static final int CEILING = 2;
+  private static final int TRUNCATE = 3;
+  private static final int ROUND = 4;
+
+  /** When checking the probability of primes, it is most efficient to
+   * first check the factoring of small primes, so we'll use this array.
+   */
+  private static final int[] primes =
+    {   2,   3,   5,   7,  11,  13,  17,  19,  23,  29,  31,  37,  41,  43,
+       47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97, 101, 103, 107,
+      109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,
+      191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251 };
+
+  /** HAC (Handbook of Applied Cryptography), Alfred Menezes & al. Table 4.4. */
+  private static final int[] k =
+      {100,150,200,250,300,350,400,500,600,800,1250, Integer.MAX_VALUE};
+  private static final int[] t =
+      { 27, 18, 15, 12,  9,  8,  7,  6,  5,  4,   3, 2};
+
+  private BigInteger()
+  {
+  }
+
+  /* Create a new (non-shared) BigInteger, and initialize to an int. */
+  private BigInteger(int value)
+  {
+    ival = value;
+  }
+
+  public BigInteger(String val, int radix)
+  {
+    BigInteger result = valueOf(val, radix);
+    this.ival = result.ival;
+    this.words = result.words;
+  }
+
+  public BigInteger(String val)
+  {
+    this(val, 10);
+  }
+
+  /* Create a new (non-shared) BigInteger, and initialize from a byte array. */
+  public BigInteger(byte[] val)
+  {
+    if (val == null || val.length < 1)
+      throw new NumberFormatException();
+
+    words = byteArrayToIntArray(val, val[0] < 0 ? -1 : 0);
+    BigInteger result = make(words, words.length);
+    this.ival = result.ival;
+    this.words = result.words;
+  }
+
+  public BigInteger(int signum, byte[] magnitude)
+  {
+    if (magnitude == null || signum > 1 || signum < -1)
+      throw new NumberFormatException();
+
+    if (signum == 0)
+      {
+	int i;
+	for (i = magnitude.length - 1; i >= 0 && magnitude[i] == 0; --i)
+	  ;
+	if (i >= 0)
+	  throw new NumberFormatException();
+        return;
+      }
+
+    // Magnitude is always positive, so don't ever pass a sign of -1.
+    words = byteArrayToIntArray(magnitude, 0);
+    BigInteger result = make(words, words.length);
+    this.ival = result.ival;
+    this.words = result.words;
+
+    if (signum < 0)
+      setNegative();
+  }
+
+  public BigInteger(int numBits, Random rnd)
+  {
+    if (numBits < 0)
+      throw new IllegalArgumentException();
+
+    init(numBits, rnd);
+  }
+
+  private void init(int numBits, Random rnd)
+  {
+    int highbits = numBits & 31;
+    if (highbits > 0)
+      highbits = rnd.nextInt() >>> (32 - highbits);
+    int nwords = numBits / 32;
+
+    while (highbits == 0 && nwords > 0)
+      {
+	highbits = rnd.nextInt();
+	--nwords;
+      }
+    if (nwords == 0 && highbits >= 0)
+      {
+	ival = highbits;
+      }
+    else
+      {
+	ival = highbits < 0 ? nwords + 2 : nwords + 1;
+	words = new int[ival];
+	words[nwords] = highbits;
+	while (--nwords >= 0)
+	  words[nwords] = rnd.nextInt();
+      }
+  }
+
+  public BigInteger(int bitLength, int certainty, Random rnd)
+  {
+    this(bitLength, rnd);
+
+    // Keep going until we find a probable prime.
+    while (true)
+      {
+	if (isProbablePrime(certainty))
+	  return;
+
+	init(bitLength, rnd);
+      }
+  }
+
+  /** 
+   *  Return a BigInteger that is bitLength bits long with a
+   *  probability < 2^-100 of being composite.
+   *
+   *  @param bitLength length in bits of resulting number
+   *  @param rnd random number generator to use
+   *  @throws ArithmeticException if bitLength < 2
+   *  @since 1.4
+   */
+  public static BigInteger probablePrime(int bitLength, Random rnd)
+  {
+    if (bitLength < 2)
+      throw new ArithmeticException();
+
+    return new BigInteger(bitLength, 100, rnd);
+  }
+
+  /** Return a (possibly-shared) BigInteger with a given long value. */
+  public static BigInteger valueOf(long val)
+  {
+    if (val >= minFixNum && val <= maxFixNum)
+      return smallFixNums[(int) val - minFixNum];
+    int i = (int) val;
+    if ((long) i == val)
+      return new BigInteger(i);
+    BigInteger result = alloc(2);
+    result.ival = 2;
+    result.words[0] = i;
+    result.words[1] = (int)(val >> 32);
+    return result;
+  }
+
+  /** Make a canonicalized BigInteger from an array of words.
+   * The array may be reused (without copying). */
+  private static BigInteger make(int[] words, int len)
+  {
+    if (words == null)
+      return valueOf(len);
+    len = BigInteger.wordsNeeded(words, len);
+    if (len <= 1)
+      return len == 0 ? ZERO : valueOf(words[0]);
+    BigInteger num = new BigInteger();
+    num.words = words;
+    num.ival = len;
+    return num;
+  }
+
+  /** Convert a big-endian byte array to a little-endian array of words. */
+  private static int[] byteArrayToIntArray(byte[] bytes, int sign)
+  {
+    // Determine number of words needed.
+    int[] words = new int[bytes.length/4 + 1];
+    int nwords = words.length;
+
+    // Create a int out of modulo 4 high order bytes.
+    int bptr = 0;
+    int word = sign;
+    for (int i = bytes.length % 4; i > 0; --i, bptr++)
+      word = (word << 8) | (bytes[bptr] & 0xff);
+    words[--nwords] = word;
+
+    // Elements remaining in byte[] are a multiple of 4.
+    while (nwords > 0)
+      words[--nwords] = bytes[bptr++] << 24 |
+			(bytes[bptr++] & 0xff) << 16 |
+			(bytes[bptr++] & 0xff) << 8 |
+			(bytes[bptr++] & 0xff);
+    return words;
+  }
+
+  /** Allocate a new non-shared BigInteger.
+   * @param nwords number of words to allocate
+   */
+  private static BigInteger alloc(int nwords)
+  {
+    BigInteger result = new BigInteger();
+    if (nwords > 1)
+    result.words = new int[nwords];
+    return result;
+  }
+
+  /** Change words.length to nwords.
+   * We allow words.length to be upto nwords+2 without reallocating.
+   */
+  private void realloc(int nwords)
+  {
+    if (nwords == 0)
+      {
+	if (words != null)
+	  {
+	    if (ival > 0)
+	      ival = words[0];
+	    words = null;
+	  }
+      }
+    else if (words == null
+	     || words.length < nwords
+	     || words.length > nwords + 2)
+      {
+	int[] new_words = new int [nwords];
+	if (words == null)
+	  {
+	    new_words[0] = ival;
+	    ival = 1;
+	  }
+	else
+	  {
+	    if (nwords < ival)
+	      ival = nwords;
+	    System.arraycopy(words, 0, new_words, 0, ival);
+	  }
+	words = new_words;
+      }
+  }
+
+  private boolean isNegative()
+  {
+    return (words == null ? ival : words[ival - 1]) < 0;
+  }
+
+  public int signum()
+  {
+    if (ival == 0 && words == null)
+      return 0;
+    int top = words == null ? ival : words[ival-1];
+    return top < 0 ? -1 : 1;
+  }
+
+  private static int compareTo(BigInteger x, BigInteger y)
+  {
+    if (x.words == null && y.words == null)
+      return x.ival < y.ival ? -1 : x.ival > y.ival ? 1 : 0;
+    boolean x_negative = x.isNegative();
+    boolean y_negative = y.isNegative();
+    if (x_negative != y_negative)
+      return x_negative ? -1 : 1;
+    int x_len = x.words == null ? 1 : x.ival;
+    int y_len = y.words == null ? 1 : y.ival;
+    if (x_len != y_len)
+      return (x_len > y_len) != x_negative ? 1 : -1;
+    return MPN.cmp(x.words, y.words, x_len);
+  }
+
+  // JDK1.2
+  public int compareTo(Object obj)
+  {
+    if (obj instanceof BigInteger)
+      return compareTo(this, (BigInteger) obj);
+    throw new ClassCastException();
+  }
+
+  public int compareTo(BigInteger val)
+  {
+    return compareTo(this, val);
+  }
+
+  public BigInteger min(BigInteger val)
+  {
+    return compareTo(this, val) < 0 ? this : val;
+  }
+
+  public BigInteger max(BigInteger val)
+  {
+    return compareTo(this, val) > 0 ? this : val;
+  }
+
+  private boolean isZero()
+  {
+    return words == null && ival == 0;
+  }
+
+  private boolean isOne()
+  {
+    return words == null && ival == 1;
+  }
+
+  /** Calculate how many words are significant in words[0:len-1].
+   * Returns the least value x such that x>0 && words[0:x-1]==words[0:len-1],
+   * when words is viewed as a 2's complement integer.
+   */
+  private static int wordsNeeded(int[] words, int len)
+  {
+    int i = len;
+    if (i > 0)
+      {
+	int word = words[--i];
+	if (word == -1)
+	  {
+	    while (i > 0 && (word = words[i - 1]) < 0)
+	      {
+		i--;
+		if (word != -1) break;
+	      }
+	  }
+	else
+	  {
+	    while (word == 0 && i > 0 && (word = words[i - 1]) >= 0)  i--;
+	  }
+      }
+    return i + 1;
+  }
+
+  private BigInteger canonicalize()
+  {
+    if (words != null
+	&& (ival = BigInteger.wordsNeeded(words, ival)) <= 1)
+      {
+	if (ival == 1)
+	  ival = words[0];
+	words = null;
+      }
+    if (words == null && ival >= minFixNum && ival <= maxFixNum)
+      return smallFixNums[ival - minFixNum];
+    return this;
+  }
+
+  /** Add two ints, yielding a BigInteger. */
+  private static BigInteger add(int x, int y)
+  {
+    return valueOf((long) x + (long) y);
+  }
+
+  /** Add a BigInteger and an int, yielding a new BigInteger. */
+  private static BigInteger add(BigInteger x, int y)
+  {
+    if (x.words == null)
+      return BigInteger.add(x.ival, y);
+    BigInteger result = new BigInteger(0);
+    result.setAdd(x, y);
+    return result.canonicalize();
+  }
+
+  /** Set this to the sum of x and y.
+   * OK if x==this. */
+  private void setAdd(BigInteger x, int y)
+  {
+    if (x.words == null)
+      {
+	set((long) x.ival + (long) y);
+	return;
+      }
+    int len = x.ival;
+    realloc(len + 1);
+    long carry = y;
+    for (int i = 0;  i < len;  i++)
+      {
+	carry += ((long) x.words[i] & 0xffffffffL);
+	words[i] = (int) carry;
+	carry >>= 32;
+      }
+    if (x.words[len - 1] < 0)
+      carry--;
+    words[len] = (int) carry;
+    ival = wordsNeeded(words, len + 1);
+  }
+
+  /** Destructively add an int to this. */
+  private void setAdd(int y)
+  {
+    setAdd(this, y);
+  }
+
+  /** Destructively set the value of this to a long. */
+  private void set(long y)
+  {
+    int i = (int) y;
+    if ((long) i == y)
+      {
+	ival = i;
+	words = null;
+      }
+    else
+      {
+	realloc(2);
+	words[0] = i;
+	words[1] = (int) (y >> 32);
+	ival = 2;
+      }
+  }
+
+  /** Destructively set the value of this to the given words.
+  * The words array is reused, not copied. */
+  private void set(int[] words, int length)
+  {
+    this.ival = length;
+    this.words = words;
+  }
+
+  /** Destructively set the value of this to that of y. */
+  private void set(BigInteger y)
+  {
+    if (y.words == null)
+      set(y.ival);
+    else if (this != y)
+      {
+	realloc(y.ival);
+	System.arraycopy(y.words, 0, words, 0, y.ival);
+	ival = y.ival;
+      }
+  }
+
+  /** Add two BigIntegers, yielding their sum as another BigInteger. */
+  private static BigInteger add(BigInteger x, BigInteger y, int k)
+  {
+    if (x.words == null && y.words == null)
+      return valueOf((long) k * (long) y.ival + (long) x.ival);
+    if (k != 1)
+      {
+	if (k == -1)
+	  y = BigInteger.neg(y);
+	else
+	  y = BigInteger.times(y, valueOf(k));
+      }
+    if (x.words == null)
+      return BigInteger.add(y, x.ival);
+    if (y.words == null)
+      return BigInteger.add(x, y.ival);
+    // Both are big
+    if (y.ival > x.ival)
+      { // Swap so x is longer then y.
+	BigInteger tmp = x;  x = y;  y = tmp;
+      }
+    BigInteger result = alloc(x.ival + 1);
+    int i = y.ival;
+    long carry = MPN.add_n(result.words, x.words, y.words, i);
+    long y_ext = y.words[i - 1] < 0 ? 0xffffffffL : 0;
+    for (; i < x.ival;  i++)
+      {
+	carry += ((long) x.words[i] & 0xffffffffL) + y_ext;;
+	result.words[i] = (int) carry;
+	carry >>>= 32;
+      }
+    if (x.words[i - 1] < 0)
+      y_ext--;
+    result.words[i] = (int) (carry + y_ext);
+    result.ival = i+1;
+    return result.canonicalize();
+  }
+
+  public BigInteger add(BigInteger val)
+  {
+    return add(this, val, 1);
+  }
+
+  public BigInteger subtract(BigInteger val)
+  {
+    return add(this, val, -1);
+  }
+
+  private static BigInteger times(BigInteger x, int y)
+  {
+    if (y == 0)
+      return ZERO;
+    if (y == 1)
+      return x;
+    int[] xwords = x.words;
+    int xlen = x.ival;
+    if (xwords == null)
+      return valueOf((long) xlen * (long) y);
+    boolean negative;
+    BigInteger result = BigInteger.alloc(xlen + 1);
+    if (xwords[xlen - 1] < 0)
+      {
+	negative = true;
+	negate(result.words, xwords, xlen);
+	xwords = result.words;
+      }
+    else
+      negative = false;
+    if (y < 0)
+      {
+	negative = !negative;
+	y = -y;
+      }
+    result.words[xlen] = MPN.mul_1(result.words, xwords, xlen, y);
+    result.ival = xlen + 1;
+    if (negative)
+      result.setNegative();
+    return result.canonicalize();
+  }
+
+  private static BigInteger times(BigInteger x, BigInteger y)
+  {
+    if (y.words == null)
+      return times(x, y.ival);
+    if (x.words == null)
+      return times(y, x.ival);
+    boolean negative = false;
+    int[] xwords;
+    int[] ywords;
+    int xlen = x.ival;
+    int ylen = y.ival;
+    if (x.isNegative())
+      {
+	negative = true;
+	xwords = new int[xlen];
+	negate(xwords, x.words, xlen);
+      }
+    else
+      {
+	negative = false;
+	xwords = x.words;
+      }
+    if (y.isNegative())
+      {
+	negative = !negative;
+	ywords = new int[ylen];
+	negate(ywords, y.words, ylen);
+      }
+    else
+      ywords = y.words;
+    // Swap if x is shorter then y.
+    if (xlen < ylen)
+      {
+	int[] twords = xwords;  xwords = ywords;  ywords = twords;
+	int tlen = xlen;  xlen = ylen;  ylen = tlen;
+      }
+    BigInteger result = BigInteger.alloc(xlen+ylen);
+    MPN.mul(result.words, xwords, xlen, ywords, ylen);
+    result.ival = xlen+ylen;
+    if (negative)
+      result.setNegative();
+    return result.canonicalize();
+  }
+
+  public BigInteger multiply(BigInteger y)
+  {
+    return times(this, y);
+  }
+
+  private static void divide(long x, long y,
+			     BigInteger quotient, BigInteger remainder,
+			     int rounding_mode)
+  {
+    boolean xNegative, yNegative;
+    if (x < 0)
+      {
+	xNegative = true;
+	if (x == Long.MIN_VALUE)
+	  {
+	    divide(valueOf(x), valueOf(y),
+		   quotient, remainder, rounding_mode);
+	    return;
+	  }
+	x = -x;
+      }
+    else
+      xNegative = false;
+
+    if (y < 0)
+      {
+	yNegative = true;
+	if (y == Long.MIN_VALUE)
+	  {
+	    if (rounding_mode == TRUNCATE)
+	      { // x != Long.Min_VALUE implies abs(x) < abs(y)
+		if (quotient != null)
+		  quotient.set(0);
+		if (remainder != null)
+		  remainder.set(x);
+	      }
+	    else
+	      divide(valueOf(x), valueOf(y),
+		      quotient, remainder, rounding_mode);
+	    return;
+	  }
+	y = -y;
+      }
+    else
+      yNegative = false;
+
+    long q = x / y;
+    long r = x % y;
+    boolean qNegative = xNegative ^ yNegative;
+
+    boolean add_one = false;
+    if (r != 0)
+      {
+	switch (rounding_mode)
+	  {
+	  case TRUNCATE:
+	    break;
+	  case CEILING:
+	  case FLOOR:
+	    if (qNegative == (rounding_mode == FLOOR))
+	      add_one = true;
+	    break;
+	  case ROUND:
+	    add_one = r > ((y - (q & 1)) >> 1);
+	    break;
+	  }
+      }
+    if (quotient != null)
+      {
+	if (add_one)
+	  q++;
+	if (qNegative)
+	  q = -q;
+	quotient.set(q);
+      }
+    if (remainder != null)
+      {
+	// The remainder is by definition: X-Q*Y
+	if (add_one)
+	  {
+	    // Subtract the remainder from Y.
+	    r = y - r;
+	    // In this case, abs(Q*Y) > abs(X).
+	    // So sign(remainder) = -sign(X).
+	    xNegative = ! xNegative;
+	  }
+	else
+	  {
+	    // If !add_one, then: abs(Q*Y) <= abs(X).
+	    // So sign(remainder) = sign(X).
+	  }
+	if (xNegative)
+	  r = -r;
+	remainder.set(r);
+      }
+  }
+
+  /** Divide two integers, yielding quotient and remainder.
+   * @param x the numerator in the division
+   * @param y the denominator in the division
+   * @param quotient is set to the quotient of the result (iff quotient!=null)
+   * @param remainder is set to the remainder of the result
+   *  (iff remainder!=null)
+   * @param rounding_mode one of FLOOR, CEILING, TRUNCATE, or ROUND.
+   */
+  private static void divide(BigInteger x, BigInteger y,
+			     BigInteger quotient, BigInteger remainder,
+			     int rounding_mode)
+  {
+    if ((x.words == null || x.ival <= 2)
+	&& (y.words == null || y.ival <= 2))
+      {
+	long x_l = x.longValue();
+	long y_l = y.longValue();
+	if (x_l != Long.MIN_VALUE && y_l != Long.MIN_VALUE)
+	  {
+	    divide(x_l, y_l, quotient, remainder, rounding_mode);
+	    return;
+	  }
+      }
+
+    boolean xNegative = x.isNegative();
+    boolean yNegative = y.isNegative();
+    boolean qNegative = xNegative ^ yNegative;
+
+    int ylen = y.words == null ? 1 : y.ival;
+    int[] ywords = new int[ylen];
+    y.getAbsolute(ywords);
+    while (ylen > 1 && ywords[ylen - 1] == 0)  ylen--;
+
+    int xlen = x.words == null ? 1 : x.ival;
+    int[] xwords = new int[xlen+2];
+    x.getAbsolute(xwords);
+    while (xlen > 1 && xwords[xlen-1] == 0)  xlen--;
+
+    int qlen, rlen;
+
+    int cmpval = MPN.cmp(xwords, xlen, ywords, ylen);
+    if (cmpval < 0)  // abs(x) < abs(y)
+      { // quotient = 0;  remainder = num.
+	int[] rwords = xwords;  xwords = ywords;  ywords = rwords;
+	rlen = xlen;  qlen = 1;  xwords[0] = 0;
+      }
+    else if (cmpval == 0)  // abs(x) == abs(y)
+      {
+	xwords[0] = 1;  qlen = 1;  // quotient = 1
+	ywords[0] = 0;  rlen = 1;  // remainder = 0;
+      }
+    else if (ylen == 1)
+      {
+	qlen = xlen;
+	// Need to leave room for a word of leading zeros if dividing by 1
+	// and the dividend has the high bit set.  It might be safe to
+	// increment qlen in all cases, but it certainly is only necessary
+	// in the following case.
+	if (ywords[0] == 1 && xwords[xlen-1] < 0)
+	  qlen++;
+	rlen = 1;
+	ywords[0] = MPN.divmod_1(xwords, xwords, xlen, ywords[0]);
+      }
+    else  // abs(x) > abs(y)
+      {
+	// Normalize the denominator, i.e. make its most significant bit set by
+	// shifting it normalization_steps bits to the left.  Also shift the
+	// numerator the same number of steps (to keep the quotient the same!).
+
+	int nshift = MPN.count_leading_zeros(ywords[ylen - 1]);
+	if (nshift != 0)
+	  {
+	    // Shift up the denominator setting the most significant bit of
+	    // the most significant word.
+	    MPN.lshift(ywords, 0, ywords, ylen, nshift);
+
+	    // Shift up the numerator, possibly introducing a new most
+	    // significant word.
+	    int x_high = MPN.lshift(xwords, 0, xwords, xlen, nshift);
+	    xwords[xlen++] = x_high;
+	  }
+
+	if (xlen == ylen)
+	  xwords[xlen++] = 0;
+	MPN.divide(xwords, xlen, ywords, ylen);
+	rlen = ylen;
+	MPN.rshift0 (ywords, xwords, 0, rlen, nshift);
+
+	qlen = xlen + 1 - ylen;
+	if (quotient != null)
+	  {
+	    for (int i = 0;  i < qlen;  i++)
+	      xwords[i] = xwords[i+ylen];
+	  }
+      }
+
+    if (ywords[rlen-1] < 0)
+      {
+        ywords[rlen] = 0;
+        rlen++;
+      }
+
+    // Now the quotient is in xwords, and the remainder is in ywords.
+
+    boolean add_one = false;
+    if (rlen > 1 || ywords[0] != 0)
+      { // Non-zero remainder i.e. in-exact quotient.
+	switch (rounding_mode)
+	  {
+	  case TRUNCATE:
+	    break;
+	  case CEILING:
+	  case FLOOR:
+	    if (qNegative == (rounding_mode == FLOOR))
+	      add_one = true;
+	    break;
+	  case ROUND:
+	    // int cmp = compareTo(remainder<<1, abs(y));
+	    BigInteger tmp = remainder == null ? new BigInteger() : remainder;
+	    tmp.set(ywords, rlen);
+	    tmp = shift(tmp, 1);
+	    if (yNegative)
+	      tmp.setNegative();
+	    int cmp = compareTo(tmp, y);
+	    // Now cmp == compareTo(sign(y)*(remainder<<1), y)
+	    if (yNegative)
+	      cmp = -cmp;
+	    add_one = (cmp == 1) || (cmp == 0 && (xwords[0]&1) != 0);
+	  }
+      }
+    if (quotient != null)
+      {
+	quotient.set(xwords, qlen);
+	if (qNegative)
+	  {
+	    if (add_one)  // -(quotient + 1) == ~(quotient)
+	      quotient.setInvert();
+	    else
+	      quotient.setNegative();
+	  }
+	else if (add_one)
+	  quotient.setAdd(1);
+      }
+    if (remainder != null)
+      {
+	// The remainder is by definition: X-Q*Y
+	remainder.set(ywords, rlen);
+	if (add_one)
+	  {
+	    // Subtract the remainder from Y:
+	    // abs(R) = abs(Y) - abs(orig_rem) = -(abs(orig_rem) - abs(Y)).
+	    BigInteger tmp;
+	    if (y.words == null)
+	      {
+		tmp = remainder;
+		tmp.set(yNegative ? ywords[0] + y.ival : ywords[0] - y.ival);
+	      }
+	    else
+	      tmp = BigInteger.add(remainder, y, yNegative ? 1 : -1);
+	    // Now tmp <= 0.
+	    // In this case, abs(Q) = 1 + floor(abs(X)/abs(Y)).
+	    // Hence, abs(Q*Y) > abs(X).
+	    // So sign(remainder) = -sign(X).
+	    if (xNegative)
+	      remainder.setNegative(tmp);
+	    else
+	      remainder.set(tmp);
+	  }
+	else
+	  {
+	    // If !add_one, then: abs(Q*Y) <= abs(X).
+	    // So sign(remainder) = sign(X).
+	    if (xNegative)
+	      remainder.setNegative();
+	  }
+      }
+  }
+
+  public BigInteger divide(BigInteger val)
+  {
+    if (val.isZero())
+      throw new ArithmeticException("divisor is zero");
+
+    BigInteger quot = new BigInteger();
+    divide(this, val, quot, null, TRUNCATE);
+    return quot.canonicalize();
+  }
+
+  public BigInteger remainder(BigInteger val)
+  {
+    if (val.isZero())
+      throw new ArithmeticException("divisor is zero");
+
+    BigInteger rem = new BigInteger();
+    divide(this, val, null, rem, TRUNCATE);
+    return rem.canonicalize();
+  }
+
+  public BigInteger[] divideAndRemainder(BigInteger val)
+  {
+    if (val.isZero())
+      throw new ArithmeticException("divisor is zero");
+
+    BigInteger[] result = new BigInteger[2];
+    result[0] = new BigInteger();
+    result[1] = new BigInteger();
+    divide(this, val, result[0], result[1], TRUNCATE);
+    result[0].canonicalize();
+    result[1].canonicalize();
+    return result;
+  }
+
+  public BigInteger mod(BigInteger m)
+  {
+    if (m.isNegative() || m.isZero())
+      throw new ArithmeticException("non-positive modulus");
+
+    BigInteger rem = new BigInteger();
+    divide(this, m, null, rem, FLOOR);
+    return rem.canonicalize();
+  }
+
+  /** Calculate the integral power of a BigInteger.
+   * @param exponent the exponent (must be non-negative)
+   */
+  public BigInteger pow(int exponent)
+  {
+    if (exponent <= 0)
+      {
+	if (exponent == 0)
+	  return ONE;
+	  throw new ArithmeticException("negative exponent");
+      }
+    if (isZero())
+      return this;
+    int plen = words == null ? 1 : ival;  // Length of pow2.
+    int blen = ((bitLength() * exponent) >> 5) + 2 * plen;
+    boolean negative = isNegative() && (exponent & 1) != 0;
+    int[] pow2 = new int [blen];
+    int[] rwords = new int [blen];
+    int[] work = new int [blen];
+    getAbsolute(pow2);	// pow2 = abs(this);
+    int rlen = 1;
+    rwords[0] = 1; // rwords = 1;
+    for (;;)  // for (i = 0;  ; i++)
+      {
+	// pow2 == this**(2**i)
+	// prod = this**(sum(j=0..i-1, (exponent>>j)&1))
+	if ((exponent & 1) != 0)
+	  { // r *= pow2
+	    MPN.mul(work, pow2, plen, rwords, rlen);
+	    int[] temp = work;  work = rwords;  rwords = temp;
+	    rlen += plen;
+	    while (rwords[rlen - 1] == 0)  rlen--;
+	  }
+	exponent >>= 1;
+	if (exponent == 0)
+	  break;
+	// pow2 *= pow2;
+	MPN.mul(work, pow2, plen, pow2, plen);
+	int[] temp = work;  work = pow2;  pow2 = temp;  // swap to avoid a copy
+	plen *= 2;
+	while (pow2[plen - 1] == 0)  plen--;
+      }
+    if (rwords[rlen - 1] < 0)
+      rlen++;
+    if (negative)
+      negate(rwords, rwords, rlen);
+    return BigInteger.make(rwords, rlen);
+  }
+
+  private static int[] euclidInv(int a, int b, int prevDiv)
+  {
+    if (b == 0)
+      throw new ArithmeticException("not invertible");
+
+    if (b == 1)
+	// Success:  values are indeed invertible!
+	// Bottom of the recursion reached; start unwinding.
+	return new int[] { -prevDiv, 1 };
+
+    int[] xy = euclidInv(b, a % b, a / b);	// Recursion happens here.
+    a = xy[0]; // use our local copy of 'a' as a work var
+    xy[0] = a * -prevDiv + xy[1];
+    xy[1] = a;
+    return xy;
+  }
+
+  private static void euclidInv(BigInteger a, BigInteger b,
+                                BigInteger prevDiv, BigInteger[] xy)
+  {
+    if (b.isZero())
+      throw new ArithmeticException("not invertible");
+
+    if (b.isOne())
+      {
+	// Success:  values are indeed invertible!
+	// Bottom of the recursion reached; start unwinding.
+	xy[0] = neg(prevDiv);
+        xy[1] = ONE;
+	return;
+      }
+
+    // Recursion happens in the following conditional!
+
+    // If a just contains an int, then use integer math for the rest.
+    if (a.words == null)
+      {
+        int[] xyInt = euclidInv(b.ival, a.ival % b.ival, a.ival / b.ival);
+	xy[0] = new BigInteger(xyInt[0]);
+        xy[1] = new BigInteger(xyInt[1]);
+      }
+    else
+      {
+	BigInteger rem = new BigInteger();
+	BigInteger quot = new BigInteger();
+	divide(a, b, quot, rem, FLOOR);
+        // quot and rem may not be in canonical form. ensure
+        rem.canonicalize();
+        quot.canonicalize();
+	euclidInv(b, rem, quot, xy);
+      }
+
+    BigInteger t = xy[0];
+    xy[0] = add(xy[1], times(t, prevDiv), -1);
+    xy[1] = t;
+  }
+
+  public BigInteger modInverse(BigInteger y)
+  {
+    if (y.isNegative() || y.isZero())
+      throw new ArithmeticException("non-positive modulo");
+
+    // Degenerate cases.
+    if (y.isOne())
+      return ZERO;
+    if (isOne())
+      return ONE;
+
+    // Use Euclid's algorithm as in gcd() but do this recursively
+    // rather than in a loop so we can use the intermediate results as we
+    // unwind from the recursion.
+    // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference.
+    BigInteger result = new BigInteger();
+    boolean swapped = false;
+
+    if (y.words == null)
+      {
+	// The result is guaranteed to be less than the modulus, y (which is
+	// an int), so simplify this by working with the int result of this
+	// modulo y.  Also, if this is negative, make it positive via modulo
+	// math.  Note that BigInteger.mod() must be used even if this is
+	// already an int as the % operator would provide a negative result if
+	// this is negative, BigInteger.mod() never returns negative values.
+        int xval = (words != null || isNegative()) ? mod(y).ival : ival;
+        int yval = y.ival;
+
+	// Swap values so x > y.
+	if (yval > xval)
+	  {
+	    int tmp = xval; xval = yval; yval = tmp;
+	    swapped = true;
+	  }
+	// Normally, the result is in the 2nd element of the array, but
+	// if originally x < y, then x and y were swapped and the result
+	// is in the 1st element of the array.
+	result.ival =
+	  euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1];
+
+	// Result can't be negative, so make it positive by adding the
+	// original modulus, y.ival (not the possibly "swapped" yval).
+	if (result.ival < 0)
+	  result.ival += y.ival;
+      }
+    else
+      {
+	// As above, force this to be a positive value via modulo math.
+	BigInteger x = isNegative() ? this.mod(y) : this;
+
+	// Swap values so x > y.
+	if (x.compareTo(y) < 0)
+	  {
+	    result = x; x = y; y = result; // use 'result' as a work var
+	    swapped = true;
+	  }
+	// As above (for ints), result will be in the 2nd element unless
+	// the original x and y were swapped.
+	BigInteger rem = new BigInteger();
+	BigInteger quot = new BigInteger();
+	divide(x, y, quot, rem, FLOOR);
+        // quot and rem may not be in canonical form. ensure
+        rem.canonicalize();
+        quot.canonicalize();
+	BigInteger[] xy = new BigInteger[2];
+	euclidInv(y, rem, quot, xy);
+	result = swapped ? xy[0] : xy[1];
+
+	// Result can't be negative, so make it positive by adding the
+	// original modulus, y (which is now x if they were swapped).
+	if (result.isNegative())
+	  result = add(result, swapped ? x : y, 1);
+      }
+    
+    return result;
+  }
+
+  public BigInteger modPow(BigInteger exponent, BigInteger m)
+  {
+    if (m.isNegative() || m.isZero())
+      throw new ArithmeticException("non-positive modulo");
+
+    if (exponent.isNegative())
+      return modInverse(m).modPow(exponent.negate(), m);
+    if (exponent.isOne())
+      return mod(m);
+
+    // To do this naively by first raising this to the power of exponent
+    // and then performing modulo m would be extremely expensive, especially
+    // for very large numbers.  The solution is found in Number Theory
+    // where a combination of partial powers and moduli can be done easily.
+    //
+    // We'll use the algorithm for Additive Chaining which can be found on
+    // p. 244 of "Applied Cryptography, Second Edition" by Bruce Schneier.
+    BigInteger s = ONE;
+    BigInteger t = this;
+    BigInteger u = exponent;
+
+    while (!u.isZero())
+      {
+	if (u.and(ONE).isOne())
+	  s = times(s, t).mod(m);
+	u = u.shiftRight(1);
+	t = times(t, t).mod(m);
+      }
+
+    return s;
+  }
+
+  /** Calculate Greatest Common Divisor for non-negative ints. */
+  private static int gcd(int a, int b)
+  {
+    // Euclid's algorithm, copied from libg++.
+    int tmp;
+    if (b > a)
+      {
+	tmp = a; a = b; b = tmp;
+      }
+    for(;;)
+      {
+	if (b == 0)
+	  return a;
+        if (b == 1)
+	  return b;
+        tmp = b;
+	    b = a % b;
+	    a = tmp;
+	  }
+      }
+
+  public BigInteger gcd(BigInteger y)
+  {
+    int xval = ival;
+    int yval = y.ival;
+    if (words == null)
+      {
+	if (xval == 0)
+	  return abs(y);
+	if (y.words == null
+	    && xval != Integer.MIN_VALUE && yval != Integer.MIN_VALUE)
+	  {
+	    if (xval < 0)
+	      xval = -xval;
+	    if (yval < 0)
+	      yval = -yval;
+	    return valueOf(gcd(xval, yval));
+	  }
+	xval = 1;
+      }
+    if (y.words == null)
+      {
+	if (yval == 0)
+	  return abs(this);
+	yval = 1;
+      }
+    int len = (xval > yval ? xval : yval) + 1;
+    int[] xwords = new int[len];
+    int[] ywords = new int[len];
+    getAbsolute(xwords);
+    y.getAbsolute(ywords);
+    len = MPN.gcd(xwords, ywords, len);
+    BigInteger result = new BigInteger(0);
+    result.ival = len;
+    result.words = xwords;
+    return result.canonicalize();
+  }
+
+  /**
+   * <p>Returns <code>true</code> if this BigInteger is probably prime,
+   * <code>false</code> if it's definitely composite. If <code>certainty</code>
+   * is <code><= 0</code>, <code>true</code> is returned.</p>
+   *
+   * @param certainty a measure of the uncertainty that the caller is willing
+   * to tolerate: if the call returns <code>true</code> the probability that
+   * this BigInteger is prime exceeds <code>(1 - 1/2<sup>certainty</sup>)</code>.
+   * The execution time of this method is proportional to the value of this
+   * parameter.
+   * @return <code>true</code> if this BigInteger is probably prime,
+   * <code>false</code> if it's definitely composite.
+   */
+  public boolean isProbablePrime(int certainty)
+  {
+    if (certainty < 1)
+      return true;
+
+    /** We'll use the Rabin-Miller algorithm for doing a probabilistic
+     * primality test.  It is fast, easy and has faster decreasing odds of a
+     * composite passing than with other tests.  This means that this
+     * method will actually have a probability much greater than the
+     * 1 - .5^certainty specified in the JCL (p. 117), but I don't think
+     * anyone will complain about better performance with greater certainty.
+     *
+     * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied
+     * Cryptography, Second Edition" by Bruce Schneier.
+     */
+
+    // First rule out small prime factors
+    BigInteger rem = new BigInteger();
+    int i;
+    for (i = 0; i < primes.length; i++)
+      {
+	if (words == null && ival == primes[i])
+	  return true;
+
+        divide(this, smallFixNums[primes[i] - minFixNum], null, rem, TRUNCATE);
+        if (rem.canonicalize().isZero())
+	  return false;
+      }
+
+    // Now perform the Rabin-Miller test.
+
+    // Set b to the number of times 2 evenly divides (this - 1).
+    // I.e. 2^b is the largest power of 2 that divides (this - 1).
+    BigInteger pMinus1 = add(this, -1);
+    int b = pMinus1.getLowestSetBit();
+
+    // Set m such that this = 1 + 2^b * m.
+    BigInteger m = pMinus1.divide(valueOf(2L << b - 1));
+
+    // The HAC (Handbook of Applied Cryptography), Alfred Menezes & al. Note
+    // 4.49 (controlling the error probability) gives the number of trials
+    // for an error probability of 1/2**80, given the number of bits in the
+    // number to test.  we shall use these numbers as is if/when 'certainty'
+    // is less or equal to 80, and twice as much if it's greater.
+    int bits = this.bitLength();
+    for (i = 0; i < k.length; i++)
+      if (bits <= k[i])
+        break;
+    int trials = t[i];
+    if (certainty > 80)
+      trials *= 2;
+    BigInteger z;
+    for (int t = 0; t < trials; t++)
+      {
+        // The HAC (Handbook of Applied Cryptography), Alfred Menezes & al.
+        // Remark 4.28 states: "...A strategy that is sometimes employed
+        // is to fix the bases a to be the first few primes instead of
+        // choosing them at random.
+	z = smallFixNums[primes[t] - minFixNum].modPow(m, this);
+	if (z.isOne() || z.equals(pMinus1))
+	  continue;			// Passes the test; may be prime.
+
+	for (i = 0; i < b; )
+	  {
+	    if (z.isOne())
+	      return false;
+	    i++;
+	    if (z.equals(pMinus1))
+	      break;			// Passes the test; may be prime.
+
+	    z = z.modPow(valueOf(2), this);
+	  }
+
+	if (i == b && !z.equals(pMinus1))
+	  return false;
+      }
+    return true;
+  }
+
+  private void setInvert()
+  {
+    if (words == null)
+      ival = ~ival;
+    else
+      {
+	for (int i = ival;  --i >= 0; )
+	  words[i] = ~words[i];
+      }
+  }
+
+  private void setShiftLeft(BigInteger x, int count)
+  {
+    int[] xwords;
+    int xlen;
+    if (x.words == null)
+      {
+	if (count < 32)
+	  {
+	    set((long) x.ival << count);
+	    return;
+	  }
+	xwords = new int[1];
+	xwords[0] = x.ival;
+	xlen = 1;
+      }
+    else
+      {
+	xwords = x.words;
+	xlen = x.ival;
+      }
+    int word_count = count >> 5;
+    count &= 31;
+    int new_len = xlen + word_count;
+    if (count == 0)
+      {
+	realloc(new_len);
+	for (int i = xlen;  --i >= 0; )
+	  words[i+word_count] = xwords[i];
+      }
+    else
+      {
+	new_len++;
+	realloc(new_len);
+	int shift_out = MPN.lshift(words, word_count, xwords, xlen, count);
+	count = 32 - count;
+	words[new_len-1] = (shift_out << count) >> count;  // sign-extend.
+      }
+    ival = new_len;
+    for (int i = word_count;  --i >= 0; )
+      words[i] = 0;
+  }
+
+  private void setShiftRight(BigInteger x, int count)
+  {
+    if (x.words == null)
+      set(count < 32 ? x.ival >> count : x.ival < 0 ? -1 : 0);
+    else if (count == 0)
+      set(x);
+    else
+      {
+	boolean neg = x.isNegative();
+	int word_count = count >> 5;
+	count &= 31;
+	int d_len = x.ival - word_count;
+	if (d_len <= 0)
+	  set(neg ? -1 : 0);
+	else
+	  {
+	    if (words == null || words.length < d_len)
+	      realloc(d_len);
+	    MPN.rshift0 (words, x.words, word_count, d_len, count);
+	    ival = d_len;
+	    if (neg)
+	      words[d_len-1] |= -2 << (31 - count);
+	  }
+      }
+  }
+
+  private void setShift(BigInteger x, int count)
+  {
+    if (count > 0)
+      setShiftLeft(x, count);
+    else
+      setShiftRight(x, -count);
+  }
+
+  private static BigInteger shift(BigInteger x, int count)
+  {
+    if (x.words == null)
+      {
+	if (count <= 0)
+	  return valueOf(count > -32 ? x.ival >> (-count) : x.ival < 0 ? -1 : 0);
+	if (count < 32)
+	  return valueOf((long) x.ival << count);
+      }
+    if (count == 0)
+      return x;
+    BigInteger result = new BigInteger(0);
+    result.setShift(x, count);
+    return result.canonicalize();
+  }
+
+  public BigInteger shiftLeft(int n)
+  {
+    return shift(this, n);
+  }
+
+  public BigInteger shiftRight(int n)
+  {
+    return shift(this, -n);
+  }
+
+  private void format(int radix, StringBuffer buffer)
+  {
+    if (words == null)
+      buffer.append(Integer.toString(ival, radix));
+    else if (ival <= 2)
+      buffer.append(Long.toString(longValue(), radix));
+    else
+      {
+	boolean neg = isNegative();
+	int[] work;
+	if (neg || radix != 16)
+	  {
+	    work = new int[ival];
+	    getAbsolute(work);
+	  }
+	else
+	  work = words;
+	int len = ival;
+
+	if (radix == 16)
+	  {
+	    if (neg)
+	      buffer.append('-');
+	    int buf_start = buffer.length();
+	    for (int i = len;  --i >= 0; )
+	      {
+		int word = work[i];
+		for (int j = 8;  --j >= 0; )
+		  {
+		    int hex_digit = (word >> (4 * j)) & 0xF;
+		    // Suppress leading zeros:
+		    if (hex_digit > 0 || buffer.length() > buf_start)
+		      buffer.append(Character.forDigit(hex_digit, 16));
+		  }
+	      }
+	  }
+	else
+	  {
+	    int i = buffer.length();
+	    for (;;)
+	      {
+		int digit = MPN.divmod_1(work, work, len, radix);
+		buffer.append(Character.forDigit(digit, radix));
+		while (len > 0 && work[len-1] == 0) len--;
+		if (len == 0)
+		  break;
+	      }
+	    if (neg)
+	      buffer.append('-');
+	    /* Reverse buffer. */
+	    int j = buffer.length() - 1;
+	    while (i < j)
+	      {
+		char tmp = buffer.charAt(i);
+		buffer.setCharAt(i, buffer.charAt(j));
+		buffer.setCharAt(j, tmp);
+		i++;  j--;
+	      }
+	  }
+      }
+  }
+
+  public String toString()
+  {
+    return toString(10);
+  }
+
+  public String toString(int radix)
+  {
+    if (words == null)
+      return Integer.toString(ival, radix);
+    if (ival <= 2)
+      return Long.toString(longValue(), radix);
+    int buf_size = ival * (MPN.chars_per_word(radix) + 1);
+    StringBuffer buffer = new StringBuffer(buf_size);
+    format(radix, buffer);
+    return buffer.toString();
+  }
+
+  public int intValue()
+  {
+    if (words == null)
+      return ival;
+    return words[0];
+  }
+
+  public long longValue()
+  {
+    if (words == null)
+      return ival;
+    if (ival == 1)
+      return words[0];
+    return ((long)words[1] << 32) + ((long)words[0] & 0xffffffffL);
+  }
+
+  public int hashCode()
+  {
+    // FIXME: May not match hashcode of JDK.
+    return words == null ? ival : (words[0] + words[ival - 1]);
+  }
+
+  /* Assumes x and y are both canonicalized. */
+  private static boolean equals(BigInteger x, BigInteger y)
+  {
+    if (x.words == null && y.words == null)
+      return x.ival == y.ival;
+    if (x.words == null || y.words == null || x.ival != y.ival)
+      return false;
+    for (int i = x.ival; --i >= 0; )
+      {
+	if (x.words[i] != y.words[i])
+	  return false;
+      }
+    return true;
+  }
+
+  /* Assumes this and obj are both canonicalized. */
+  public boolean equals(Object obj)
+  {
+    if (! (obj instanceof BigInteger))
+      return false;
+    return equals(this, (BigInteger) obj);
+  }
+
+  private static BigInteger valueOf(String s, int radix)
+       throws NumberFormatException
+  {
+    int len = s.length();
+    // Testing (len < MPN.chars_per_word(radix)) would be more accurate,
+    // but slightly more expensive, for little practical gain.
+    if (len <= 15 && radix <= 16)
+      return valueOf(Long.parseLong(s, radix));
+    
+    int byte_len = 0;
+    byte[] bytes = new byte[len];
+    boolean negative = false;
+    for (int i = 0;  i < len;  i++)
+      {
+	char ch = s.charAt(i);
+	if (ch == '-')
+	  negative = true;
+	else if (ch == '_' || (byte_len == 0 && (ch == ' ' || ch == '\t')))
+	  continue;
+	else
+	  {
+	    int digit = Character.digit(ch, radix);
+	    if (digit < 0)
+	      break;
+	    bytes[byte_len++] = (byte) digit;
+	  }
+      }
+    return valueOf(bytes, byte_len, negative, radix);
+  }
+
+  private static BigInteger valueOf(byte[] digits, int byte_len,
+				    boolean negative, int radix)
+  {
+    int chars_per_word = MPN.chars_per_word(radix);
+    int[] words = new int[byte_len / chars_per_word + 1];
+    int size = MPN.set_str(words, digits, byte_len, radix);
+    if (size == 0)
+      return ZERO;
+    if (words[size-1] < 0)
+      words[size++] = 0;
+    if (negative)
+      negate(words, words, size);
+    return make(words, size);
+  }
+
+  public double doubleValue()
+  {
+    if (words == null)
+      return (double) ival;
+    if (ival <= 2)
+      return (double) longValue();
+    if (isNegative())
+      return neg(this).roundToDouble(0, true, false);
+      return roundToDouble(0, false, false);
+  }
+
+  public float floatValue()
+  {
+    return (float) doubleValue();
+  }
+
+  /** Return true if any of the lowest n bits are one.
+   * (false if n is negative).  */
+  private boolean checkBits(int n)
+  {
+    if (n <= 0)
+      return false;
+    if (words == null)
+      return n > 31 || ((ival & ((1 << n) - 1)) != 0);
+    int i;
+    for (i = 0; i < (n >> 5) ; i++)
+      if (words[i] != 0)
+	return true;
+    return (n & 31) != 0 && (words[i] & ((1 << (n & 31)) - 1)) != 0;
+  }
+
+  /** Convert a semi-processed BigInteger to double.
+   * Number must be non-negative.  Multiplies by a power of two, applies sign,
+   * and converts to double, with the usual java rounding.
+   * @param exp power of two, positive or negative, by which to multiply
+   * @param neg true if negative
+   * @param remainder true if the BigInteger is the result of a truncating
+   * division that had non-zero remainder.  To ensure proper rounding in
+   * this case, the BigInteger must have at least 54 bits.  */
+  private double roundToDouble(int exp, boolean neg, boolean remainder)
+  {
+    // Compute length.
+    int il = bitLength();
+
+    // Exponent when normalized to have decimal point directly after
+    // leading one.  This is stored excess 1023 in the exponent bit field.
+    exp += il - 1;
+
+    // Gross underflow.  If exp == -1075, we let the rounding
+    // computation determine whether it is minval or 0 (which are just
+    // 0x0000 0000 0000 0001 and 0x0000 0000 0000 0000 as bit
+    // patterns).
+    if (exp < -1075)
+      return neg ? -0.0 : 0.0;
+
+    // gross overflow
+    if (exp > 1023)
+      return neg ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
+
+    // number of bits in mantissa, including the leading one.
+    // 53 unless it's denormalized
+    int ml = (exp >= -1022 ? 53 : 53 + exp + 1022);
+
+    // Get top ml + 1 bits.  The extra one is for rounding.
+    long m;
+    int excess_bits = il - (ml + 1);
+    if (excess_bits > 0)
+      m = ((words == null) ? ival >> excess_bits
+	   : MPN.rshift_long(words, ival, excess_bits));
+    else
+      m = longValue() << (- excess_bits);
+
+    // Special rounding for maxval.  If the number exceeds maxval by
+    // any amount, even if it's less than half a step, it overflows.
+    if (exp == 1023 && ((m >> 1) == (1L << 53) - 1))
+      {
+	if (remainder || checkBits(il - ml))
+	  return neg ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
+	else
+	  return neg ? - Double.MAX_VALUE : Double.MAX_VALUE;
+      }
+
+    // Normal round-to-even rule: round up if the bit dropped is a one, and
+    // the bit above it or any of the bits below it is a one.
+    if ((m & 1) == 1
+	&& ((m & 2) == 2 || remainder || checkBits(excess_bits)))
+      {
+	m += 2;
+	// Check if we overflowed the mantissa
+	if ((m & (1L << 54)) != 0)
+	  {
+	    exp++;
+	    // renormalize
+	    m >>= 1;
+	  }
+	// Check if a denormalized mantissa was just rounded up to a
+	// normalized one.
+	else if (ml == 52 && (m & (1L << 53)) != 0)
+	  exp++;
+      }
+	
+    // Discard the rounding bit
+    m >>= 1;
+
+    long bits_sign = neg ? (1L << 63) : 0;
+    exp += 1023;
+    long bits_exp = (exp <= 0) ? 0 : ((long)exp) << 52;
+    long bits_mant = m & ~(1L << 52);
+    return Double.longBitsToDouble(bits_sign | bits_exp | bits_mant);
+  }
+
+  /** Copy the abolute value of this into an array of words.
+   * Assumes words.length >= (this.words == null ? 1 : this.ival).
+   * Result is zero-extended, but need not be a valid 2's complement number.
+   */
+  private void getAbsolute(int[] words)
+  {
+    int len;
+    if (this.words == null)
+      {
+	len = 1;
+	words[0] = this.ival;
+      }
+    else
+      {
+	len = this.ival;
+	for (int i = len;  --i >= 0; )
+	  words[i] = this.words[i];
+      }
+    if (words[len - 1] < 0)
+      negate(words, words, len);
+    for (int i = words.length;  --i > len; )
+      words[i] = 0;
+  }
+
+  /** Set dest[0:len-1] to the negation of src[0:len-1].
+   * Return true if overflow (i.e. if src is -2**(32*len-1)).
+   * Ok for src==dest. */
+  private static boolean negate(int[] dest, int[] src, int len)
+  {
+    long carry = 1;
+    boolean negative = src[len-1] < 0;
+    for (int i = 0;  i < len;  i++)
+      {
+        carry += ((long) (~src[i]) & 0xffffffffL);
+        dest[i] = (int) carry;
+        carry >>= 32;
+      }
+    return (negative && dest[len-1] < 0);
+  }
+
+  /** Destructively set this to the negative of x.
+   * It is OK if x==this.*/
+  private void setNegative(BigInteger x)
+  {
+    int len = x.ival;
+    if (x.words == null)
+      {
+	if (len == Integer.MIN_VALUE)
+	  set(- (long) len);
+	else
+	  set(-len);
+	return;
+      }
+    realloc(len + 1);
+    if (negate(words, x.words, len))
+      words[len++] = 0;
+    ival = len;
+  }
+
+  /** Destructively negate this. */
+  private void setNegative()
+  {
+    setNegative(this);
+  }
+
+  private static BigInteger abs(BigInteger x)
+  {
+    return x.isNegative() ? neg(x) : x;
+  }
+
+  public BigInteger abs()
+  {
+    return abs(this);
+  }
+
+  private static BigInteger neg(BigInteger x)
+  {
+    if (x.words == null && x.ival != Integer.MIN_VALUE)
+      return valueOf(- x.ival);
+    BigInteger result = new BigInteger(0);
+    result.setNegative(x);
+    return result.canonicalize();
+  }
+
+  public BigInteger negate()
+  {
+    return neg(this);
+  }
+
+  /** Calculates ceiling(log2(this < 0 ? -this : this+1))
+   * See Common Lisp: the Language, 2nd ed, p. 361.
+   */
+  public int bitLength()
+  {
+    if (words == null)
+      return MPN.intLength(ival);
+      return MPN.intLength(words, ival);
+  }
+
+  public byte[] toByteArray()
+  {
+    // Determine number of bytes needed.  The method bitlength returns
+    // the size without the sign bit, so add one bit for that and then
+    // add 7 more to emulate the ceil function using integer math.
+    byte[] bytes = new byte[(bitLength() + 1 + 7) / 8];
+    int nbytes = bytes.length;
+
+    int wptr = 0;
+    int word;
+
+    // Deal with words array until one word or less is left to process.
+    // If BigInteger is an int, then it is in ival and nbytes will be <= 4.
+    while (nbytes > 4)
+      {
+	word = words[wptr++];
+	for (int i = 4; i > 0; --i, word >>= 8)
+          bytes[--nbytes] = (byte) word;
+      }
+
+    // Deal with the last few bytes.  If BigInteger is an int, use ival.
+    word = (words == null) ? ival : words[wptr];
+    for ( ; nbytes > 0; word >>= 8)
+      bytes[--nbytes] = (byte) word;
+
+    return bytes;
+  }
+
+  /** Return the boolean opcode (for bitOp) for swapped operands.
+   * I.e. bitOp(swappedOp(op), x, y) == bitOp(op, y, x).
+   */
+  private static int swappedOp(int op)
+  {
+    return
+    "\000\001\004\005\002\003\006\007\010\011\014\015\012\013\016\017"
+    .charAt(op);
+  }
+
+  /** Do one the the 16 possible bit-wise operations of two BigIntegers. */
+  private static BigInteger bitOp(int op, BigInteger x, BigInteger y)
+  {
+    switch (op)
+      {
+        case 0:  return ZERO;
+        case 1:  return x.and(y);
+        case 3:  return x;
+        case 5:  return y;
+        case 15: return valueOf(-1);
+      }
+    BigInteger result = new BigInteger();
+    setBitOp(result, op, x, y);
+    return result.canonicalize();
+  }
+
+  /** Do one the the 16 possible bit-wise operations of two BigIntegers. */
+  private static void setBitOp(BigInteger result, int op,
+			       BigInteger x, BigInteger y)
+  {
+    if (y.words == null) ;
+    else if (x.words == null || x.ival < y.ival)
+      {
+	BigInteger temp = x;  x = y;  y = temp;
+	op = swappedOp(op);
+      }
+    int xi;
+    int yi;
+    int xlen, ylen;
+    if (y.words == null)
+      {
+	yi = y.ival;
+	ylen = 1;
+      }
+    else
+      {
+	yi = y.words[0];
+	ylen = y.ival;
+      }
+    if (x.words == null)
+      {
+	xi = x.ival;
+	xlen = 1;
+      }
+    else
+      {
+	xi = x.words[0];
+	xlen = x.ival;
+      }
+    if (xlen > 1)
+      result.realloc(xlen);
+    int[] w = result.words;
+    int i = 0;
+    // Code for how to handle the remainder of x.
+    // 0:  Truncate to length of y.
+    // 1:  Copy rest of x.
+    // 2:  Invert rest of x.
+    int finish = 0;
+    int ni;
+    switch (op)
+      {
+      case 0:  // clr
+	ni = 0;
+	break;
+      case 1: // and
+	for (;;)
+	  {
+	    ni = xi & yi;
+	    if (i+1 >= ylen) break;
+	    w[i++] = ni;  xi = x.words[i];  yi = y.words[i];
+	  }
+	if (yi < 0) finish = 1;
+	break;
+      case 2: // andc2
+	for (;;)
+	  {
+	    ni = xi & ~yi;
+	    if (i+1 >= ylen) break;
+	    w[i++] = ni;  xi = x.words[i];  yi = y.words[i];
+	  }
+	if (yi >= 0) finish = 1;
+	break;
+      case 3:  // copy x
+	ni = xi;
+	finish = 1;  // Copy rest
+	break;
+      case 4: // andc1
+	for (;;)
+	  {
+	    ni = ~xi & yi;
+	    if (i+1 >= ylen) break;
+	    w[i++] = ni;  xi = x.words[i];  yi = y.words[i];
+	  }
+	if (yi < 0) finish = 2;
+	break;
+      case 5: // copy y
+	for (;;)
+	  {
+	    ni = yi;
+	    if (i+1 >= ylen) break;
+	    w[i++] = ni;  xi = x.words[i];  yi = y.words[i];
+	  }
+	break;
+      case 6:  // xor
+	for (;;)
+	  {
+	    ni = xi ^ yi;
+	    if (i+1 >= ylen) break;
+	    w[i++] = ni;  xi = x.words[i];  yi = y.words[i];
+	  }
+	finish = yi < 0 ? 2 : 1;
+	break;
+      case 7:  // ior
+	for (;;)
+	  {
+	    ni = xi | yi;
+	    if (i+1 >= ylen) break;
+	    w[i++] = ni;  xi = x.words[i];  yi = y.words[i];
+	  }
+	if (yi >= 0) finish = 1;
+	break;
+      case 8:  // nor
+	for (;;)
+	  {
+	    ni = ~(xi | yi);
+	    if (i+1 >= ylen) break;
+	    w[i++] = ni;  xi = x.words[i];  yi = y.words[i];
+	  }
+	if (yi >= 0)  finish = 2;
+	break;
+      case 9:  // eqv [exclusive nor]
+	for (;;)
+	  {
+	    ni = ~(xi ^ yi);
+	    if (i+1 >= ylen) break;
+	    w[i++] = ni;  xi = x.words[i];  yi = y.words[i];
+	  }
+	finish = yi >= 0 ? 2 : 1;
+	break;
+      case 10:  // c2
+	for (;;)
+	  {
+	    ni = ~yi;
+	    if (i+1 >= ylen) break;
+	    w[i++] = ni;  xi = x.words[i];  yi = y.words[i];
+	  }
+	break;
+      case 11:  // orc2
+	for (;;)
+	  {
+	    ni = xi | ~yi;
+	    if (i+1 >= ylen) break;
+	    w[i++] = ni;  xi = x.words[i];  yi = y.words[i];
+	  }
+	if (yi < 0)  finish = 1;
+	break;
+      case 12:  // c1
+	ni = ~xi;
+	finish = 2;
+	break;
+      case 13:  // orc1
+	for (;;)
+	  {
+	    ni = ~xi | yi;
+	    if (i+1 >= ylen) break;
+	    w[i++] = ni;  xi = x.words[i];  yi = y.words[i];
+	  }
+	if (yi >= 0) finish = 2;
+	break;
+      case 14:  // nand
+	for (;;)
+	  {
+	    ni = ~(xi & yi);
+	    if (i+1 >= ylen) break;
+	    w[i++] = ni;  xi = x.words[i];  yi = y.words[i];
+	  }
+	if (yi < 0) finish = 2;
+	break;
+      default:
+      case 15:  // set
+	ni = -1;
+	break;
+      }
+    // Here i==ylen-1; w[0]..w[i-1] have the correct result;
+    // and ni contains the correct result for w[i+1].
+    if (i+1 == xlen)
+      finish = 0;
+    switch (finish)
+      {
+      case 0:
+	if (i == 0 && w == null)
+	  {
+	    result.ival = ni;
+	    return;
+	  }
+	w[i++] = ni;
+	break;
+      case 1:  w[i] = ni;  while (++i < xlen)  w[i] = x.words[i];  break;
+      case 2:  w[i] = ni;  while (++i < xlen)  w[i] = ~x.words[i];  break;
+      }
+    result.ival = i;
+  }
+
+  /** Return the logical (bit-wise) "and" of a BigInteger and an int. */
+  private static BigInteger and(BigInteger x, int y)
+  {
+    if (x.words == null)
+      return valueOf(x.ival & y);
+    if (y >= 0)
+      return valueOf(x.words[0] & y);
+    int len = x.ival;
+    int[] words = new int[len];
+    words[0] = x.words[0] & y;
+    while (--len > 0)
+      words[len] = x.words[len];
+    return make(words, x.ival);
+  }
+
+  /** Return the logical (bit-wise) "and" of two BigIntegers. */
+  public BigInteger and(BigInteger y)
+  {
+    if (y.words == null)
+      return and(this, y.ival);
+    else if (words == null)
+      return and(y, ival);
+
+    BigInteger x = this;
+    if (ival < y.ival)
+      {
+        BigInteger temp = this;  x = y;  y = temp;
+      }
+    int i;
+    int len = y.isNegative() ? x.ival : y.ival;
+    int[] words = new int[len];
+    for (i = 0;  i < y.ival;  i++)
+      words[i] = x.words[i] & y.words[i];
+    for ( ; i < len;  i++)
+      words[i] = x.words[i];
+    return make(words, len);
+  }
+
+  /** Return the logical (bit-wise) "(inclusive) or" of two BigIntegers. */
+  public BigInteger or(BigInteger y)
+  {
+    return bitOp(7, this, y);
+  }
+
+  /** Return the logical (bit-wise) "exclusive or" of two BigIntegers. */
+  public BigInteger xor(BigInteger y)
+  {
+    return bitOp(6, this, y);
+  }
+
+  /** Return the logical (bit-wise) negation of a BigInteger. */
+  public BigInteger not()
+  {
+    return bitOp(12, this, ZERO);
+  }
+
+  public BigInteger andNot(BigInteger val)
+  {
+    return and(val.not());
+  }
+
+  public BigInteger clearBit(int n)
+  {
+    if (n < 0)
+      throw new ArithmeticException();
+
+    return and(ONE.shiftLeft(n).not());
+  }
+
+  public BigInteger setBit(int n)
+  {
+    if (n < 0)
+      throw new ArithmeticException();
+
+    return or(ONE.shiftLeft(n));
+  }
+
+  public boolean testBit(int n)
+  {
+    if (n < 0)
+      throw new ArithmeticException();
+
+    return !and(ONE.shiftLeft(n)).isZero();
+  }
+
+  public BigInteger flipBit(int n)
+  {
+    if (n < 0)
+      throw new ArithmeticException();
+
+    return xor(ONE.shiftLeft(n));
+  }
+
+  public int getLowestSetBit()
+  {
+    if (isZero())
+      return -1;
+
+    if (words == null)
+      return MPN.findLowestBit(ival);
+    else
+      return MPN.findLowestBit(words);
+  }
+
+  // bit4count[I] is number of '1' bits in I.
+  private static final byte[] bit4_count = { 0, 1, 1, 2,  1, 2, 2, 3,
+					     1, 2, 2, 3,  2, 3, 3, 4};
+
+  private static int bitCount(int i)
+  {
+    int count = 0;
+    while (i != 0)
+      {
+	count += bit4_count[i & 15];
+	i >>>= 4;
+      }
+    return count;
+  }
+
+  private static int bitCount(int[] x, int len)
+  {
+    int count = 0;
+    while (--len >= 0)
+      count += bitCount(x[len]);
+    return count;
+  }
+
+  /** Count one bits in a BigInteger.
+   * If argument is negative, count zero bits instead. */
+  public int bitCount()
+  {
+    int i, x_len;
+    int[] x_words = words;
+    if (x_words == null)
+      {
+	x_len = 1;
+	i = bitCount(ival);
+      }
+    else
+      {
+	x_len = ival;
+	i = bitCount(x_words, x_len);
+      }
+    return isNegative() ? x_len * 32 - i : i;
+  }
+
+  private void readObject(ObjectInputStream s)
+    throws IOException, ClassNotFoundException
+  {
+    s.defaultReadObject();
+    if (magnitude.length == 0 || signum == 0)
+      {
+        this.ival = 0;
+        this.words = null;
+      }
+    else
+      {
+        words = byteArrayToIntArray(magnitude, signum < 0 ? -1 : 0);
+        BigInteger result = make(words, words.length);
+        this.ival = result.ival;
+        this.words = result.words;        
+      }    
+  }
+
+  private void writeObject(ObjectOutputStream s)
+    throws IOException, ClassNotFoundException
+  {
+    signum = signum();
+    magnitude = signum == 0 ? new byte[0] : toByteArray();
+    s.defaultWriteObject();
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/math/MathContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/math/MathContext.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,144 @@
+/* MathContext.java -- 
+   Copyright (C) 1999, 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 java.math;
+
+import java.io.Serializable;
+
+/**
+ * Immutable objects describing settings such as rounding mode and digit
+ * precision for numerical operations such as those in the BigDecimal class.
+ * @author Anthony Balkissoon abalkiss at redhat dot com
+ *
+ */
+public final class MathContext implements Serializable
+{
+  
+  /**
+   * This is the serialVersionUID reported here:
+   * java.sun.com/j2se/1.5.0/docs/api/serialized-form.html#java.math.MathContext
+   */
+  private static final long serialVersionUID = 5579720004786848255L;
+  
+  private int precision;
+    
+  /**
+   * Constructs a new MathContext with the specified precision and with HALF_UP
+   * rounding.
+   * @param setPrecision the precision for the new MathContext
+   * 
+   * @throws IllegalArgumentException if precision is < 0.
+   */
+  public MathContext(int setPrecision)
+  {
+    if (setPrecision < 0)
+      throw new IllegalArgumentException("Precision cannot be less than zero.");
+    precision = setPrecision;
+  }
+    
+  /**
+   * Constructs a MathContext from a String that has the same form as one
+   * produced by the toString() method.
+   * @param val
+   * 
+   * @throws IllegalArgumentException if the String is not in the correct
+   * format or if the precision specified is < 0.
+   */
+  public MathContext(String val)
+  {
+    try
+    {
+      int roundingModeIndex = val.indexOf("roundingMode", 10);
+      precision = Integer.parseInt(val.substring(10, roundingModeIndex - 1));
+    }
+    catch (NumberFormatException nfe)
+    {
+      throw new IllegalArgumentException("String not in correct format");
+    }
+    catch (IllegalArgumentException iae)
+    {
+      throw new IllegalArgumentException("String not in correct format");
+    }
+    if (precision < 0)
+      throw new IllegalArgumentException("Precision cannot be less than 0.");
+  }
+  
+  /**
+   * Returns true if x is a MathContext and has the same precision setting
+   * and rounding mode as this MathContext.
+   * 
+   * @return true if the above conditions hold
+   */
+  public boolean equals(Object x)
+  {
+    if (!(x instanceof MathContext))
+      return false;
+    MathContext mc = (MathContext)x;
+    return mc.precision == this.precision;
+  }
+  
+  /**
+   * Returns the precision setting.
+   * @return the precision setting.
+   */
+  public int getPrecision()
+  {
+    return precision;
+  }
+  
+  /**
+   * Returns "precision=p roundingMode=MODE" where p is an int giving the 
+   * precision and MODE is UP, DOWN, HALF_UP, HALF_DOWN, HALF_EVEN, CEILING,
+   * FLOOR, or UNNECESSARY corresponding to rounding modes.
+   * 
+   * @return a String describing this MathContext
+   */
+  public String toString()
+  {
+    return "precision="+precision;
+  }
+  
+  /**
+   * Returns the hashcode for this MathContext.
+   * @return the hashcode for this MathContext.
+   */
+  public int hashCode()
+  {
+    return precision;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/math/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/math/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.math 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.math</title></head>
+
+<body>
+<p>Arbitrary large decimals and integers.</p>
+
+</body>
+</html>

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/Authenticator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/Authenticator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,313 @@
+/* Authenticator.java -- Abstract class for obtaining authentication info
+   Copyright (C) 1998, 2000, 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.net;
+
+
+/**
+  * This abstract class provides a model for obtaining authentication
+  * information (in the form of a username and password) required by
+  * some network operations (such as hitting a password protected
+  * web site).
+  * <p>
+  * To make use of this feature, a programmer must create a subclass
+  * that knows how to obtain the necessary info.  An example
+  * would be a class that popped up a dialog box to prompt the user.
+  * After creating an instance of that subclass, the static
+  * <code>setDefault</code> method of this class is called to set up
+  * that instance as the object to use on subsequent calls to obtain
+  * authorization.
+  *
+  * @since 1.2
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  * @status Believed to be JDK 1.4 complete
+  */
+public abstract class Authenticator
+{
+  /*
+   * Class Variables
+   */
+
+  /**
+    * This is the default Authenticator object to use for password requests
+    */
+  private static Authenticator defaultAuthenticator;
+
+  /*
+   * Instance Variables
+   */
+
+  /**
+    * The hostname of the site requesting authentication
+    */
+  private String host;
+
+  /**
+    * InternetAddress of the site requesting authentication
+    */
+  private InetAddress addr;
+
+  /**
+    * The port number of the site requesting authentication
+    */
+  private int port;
+
+  /**
+    * The protocol name of the site requesting authentication
+    */
+  private String protocol;
+
+  /**
+    * The prompt to display to the user when requesting authentication info
+    */
+  private String prompt;
+
+  /**
+    * The authentication scheme in use
+    */
+  private String scheme;
+
+  /*
+   * Class Methods
+   */
+
+  /**
+    * This method sets the default <code>Authenticator</code> object (an
+    * instance of a subclass of <code>Authenticator</code>) to use when
+    * prompting the user for
+    * information.  Note that this method checks to see if the caller is
+    * allowed to set this value (the "setDefaultAuthenticator" permission)
+    * and throws a <code>SecurityException</code> if it is not.
+    *
+    * @param defAuth The new default <code>Authenticator</code> object to use
+    *
+    * @exception SecurityException If the caller does not have permission
+    * to perform this operation
+    */
+  public static void setDefault(Authenticator defAuth)
+  {
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkPermission(new NetPermission("setDefaultAuthenticator"));
+
+    defaultAuthenticator = defAuth;
+  }
+
+  /**
+    * This method is called whenever a username and password for a given
+    * network operation is required.  First, a security check is made to see
+    * if the caller has the "requestPasswordAuthentication"
+    * permission.  If not, the method thows an exception.  If there is no
+    * default <code>Authenticator</code> object, the method then returns
+    * <code>null</code>.  Otherwise, the default authenticators's instance
+    * variables are initialized and it's <code>getPasswordAuthentication</code>
+    * method is called to get the actual authentication information to return.
+    *
+    * @param addr The address requesting authentication
+    * @param port The port requesting authentication
+    * @param protocol The protocol requesting authentication
+    * @param prompt The prompt to display to the user when requesting
+    *        authentication info
+    * @param scheme The authentication scheme in use
+    *
+    * @return A <code>PasswordAuthentication</code> object with the user's
+    *         authentication info.
+    *
+    * @exception SecurityException If the caller does not have permission to
+    *         perform this operation
+    */
+  public static PasswordAuthentication requestPasswordAuthentication(InetAddress addr,
+                                                                     int port,
+                                                                     String protocol,
+                                                                     String prompt,
+                                                                     String scheme)
+    throws SecurityException
+  {
+    return requestPasswordAuthentication(null, addr, port, protocol, prompt,
+                                         scheme);
+  }
+
+  /**
+    * This method is called whenever a username and password for a given
+    * network operation is required.  First, a security check is made to see
+    * if the caller has the "requestPasswordAuthentication"
+    * permission.  If not, the method thows an exception.  If there is no
+    * default <code>Authenticator</code> object, the method then returns
+    * <code>null</code>.  Otherwise, the default authenticators's instance
+    * variables are initialized and it's <code>getPasswordAuthentication</code>
+    * method is called to get the actual authentication information to return.
+    * This method is the preferred one as it can be used with hostname
+    * when addr is unknown.
+    *
+    * @param host The hostname requesting authentication
+    * @param addr The address requesting authentication
+    * @param port The port requesting authentication
+    * @param protocol The protocol requesting authentication
+    * @param prompt The prompt to display to the user when requesting
+    *        authentication info
+    * @param scheme The authentication scheme in use
+    *
+    * @return A <code>PasswordAuthentication</code> object with the user's
+    *         authentication info.
+    *
+    * @exception SecurityException If the caller does not have permission to
+    *         perform this operation
+    *
+    * @since 1.4
+    */
+  public static PasswordAuthentication requestPasswordAuthentication(String host,
+                                                                     InetAddress addr,
+                                                                     int port,
+                                                                     String protocol,
+                                                                     String prompt,
+                                                                     String scheme)
+    throws SecurityException
+  {
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkPermission(new NetPermission("requestPasswordAuthentication"));
+
+    if (defaultAuthenticator == null)
+      return null;
+
+    defaultAuthenticator.host = host;
+    defaultAuthenticator.addr = addr;
+    defaultAuthenticator.port = port;
+    defaultAuthenticator.protocol = protocol;
+    defaultAuthenticator.prompt = prompt;
+    defaultAuthenticator.scheme = scheme;
+
+    return defaultAuthenticator.getPasswordAuthentication();
+  }
+
+  /*
+   * Constructors
+   */
+
+  /**
+    * Default, no-argument constructor for subclasses to call.
+    */
+  public Authenticator()
+  {
+  }
+
+  /*
+   * Instance Methods
+   */
+
+  /**
+    * This method returns the address of the site that is requesting
+    * authentication.
+    *
+    * @return The requesting site's address
+    */
+  protected final InetAddress getRequestingSite()
+  {
+    return addr;
+  }
+
+  /**
+   * Returns the hostname of the host or proxy requesting authorization,
+   * or <code>null</code> if not available.
+   *
+   * @return The name of the host requesting authentication, or
+   * <code>null</code> if it is not available.
+   *
+   * @since 1.4
+   */
+  protected final String getRequestingHost()
+  {
+    return host;
+  }
+
+  /**
+    * This method returns the port of the site that is requesting
+    * authentication.
+    *
+    * @return The requesting port
+    */
+  protected final int getRequestingPort()
+  {
+    return port;
+  }
+
+  /**
+    * This method returns the requesting protocol of the operation that is
+    * requesting authentication
+    *
+    * @return The requesting protocol
+    */
+  protected final String getRequestingProtocol()
+  {
+    return protocol;
+  }
+
+  /**
+    * Returns the prompt that should be used when requesting authentication
+    * information from the user
+    *
+    * @return The user prompt
+    */
+  protected final String getRequestingPrompt()
+  {
+    return prompt;
+  }
+
+  /**
+    * This method returns the authentication scheme in use
+    *
+    * @return The authentication scheme
+    */
+  protected final String getRequestingScheme()
+  {
+    return scheme;
+  }
+
+  /**
+    * This method is called whenever a request for authentication is made.  It
+    * can call the other getXXX methods to determine the information relevant
+    * to this request.  Subclasses should override this method, which returns
+    * <code>null</code> by default.
+    *
+    * @return The <code>PasswordAuthentication</code> information
+    */
+  protected PasswordAuthentication getPasswordAuthentication()
+  {
+    return null;
+  }
+} // class Authenticator

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/BindException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/BindException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* BindException.java -- An exception occurred while binding to a socket
+   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.net;
+
+
+/**
+ * This exception indicates that an error occurred while attempting to bind
+ * socket to a particular port.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class BindException extends SocketException
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = -5945005768251722951L;
+
+  /**
+   * Create a new instance without a descriptive error message.
+   */
+  public BindException()
+  {
+  }
+
+  /**
+   * Create a new instance with a descriptive error message, such as the
+   * text from strerror(3).
+   *
+   * @param message a message describing the error that occurred
+   */
+  public BindException(String message)
+  {
+    super(message);
+  }
+} // class BindException

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/ConnectException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/ConnectException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* ConnectException.java -- An exception occurred while connecting to a host
+   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.net;
+
+
+/**
+ * This exception indicates that an error occurred while attempting to
+ * connect to a remote host.  Often this indicates that the remote host
+ * refused the connection (ie, is not listening on the target socket).
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ConnectException extends SocketException
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = 3831404271622369215L;
+
+  /**
+   * Create a new instance without a descriptive error message.
+   */
+  public ConnectException()
+  {
+  }
+
+  /**
+   * Create a new instance with a descriptive error message, such as the
+   * text from strerror(3).
+   *
+   * @param message a message describing the error that occurred
+   */
+  public ConnectException(String message)
+  {
+    super(message);
+  }
+} // class ConnectException

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/ContentHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/ContentHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,126 @@
+/* ContentHandler.java -- Abstract class for handling content from URL's
+   Copyright (C) 1998, 1999, 2000, 2001, 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.net;
+
+import java.io.IOException;
+
+/**
+ * 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.
+ */
+
+/**
+  * This is an abstract class that is the superclass for classes that read
+  * objects from URL's.  Calling the <code>getContent()</code> method in the
+  * <code>URL</code> class or the <code>URLConnection</code> class will cause
+  * an instance of a subclass of <code>ContentHandler</code> to be created for
+  * the MIME type of the object being downloaded from the URL.  Thus, this
+  * class is seldom needed by applications/applets directly, but only
+  * indirectly through methods in other classes.
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  * @author Warren Levy (warrenl at cygnus.com)
+  */
+public abstract class ContentHandler
+{
+  /*
+   * Constructors
+   */
+
+  /**
+    * Default, no-argument constructor.
+    */
+  public ContentHandler()
+  {
+  }
+
+  /*
+   * Instance Methods
+   */
+
+  /**
+    * This method reads from the <code>InputStream</code> of the passed in URL
+    * connection and uses the data downloaded to create an <code>Object</code>
+    * represening the content.  For example, if the URL is pointing to a GIF
+    * file, this method might return an <code>Image</code> object.  This method
+    * must be implemented by subclasses.
+    *
+    * @param urlc A <code>URLConnection</code> object to read data from.
+    *
+    * @return An object representing the data read
+    *
+    * @exception IOException If an error occurs
+    */
+  public abstract Object getContent(URLConnection urlc)
+    throws IOException;
+
+  /**
+    * This method reads from the <code>InputStream</code> of the passed in URL
+    * connection and uses the data downloaded to create an <code>Object</code>
+    * represening the content.  For example, if the URL is pointing to a GIF
+    * file, this method might return an <code>Image</code> object.  This method
+    * must be implemented by subclasses.  This method uses the list of
+    * supplied classes as candidate types.  If the data read doesn't match
+    * any of the supplied type, <code>null</code> is returned.
+    *
+    * @param urlc A <code>URLConnection</code> object to read data from.
+    * @param classes An array of types of objects that are candidate types
+    * for the data to be read.
+    *
+    * @return An object representing the data read, or <code>null</code>
+    * if the data does not match any of the candidate types.
+    *
+    * @exception IOException If an error occurs
+    *
+    * @since 1.3
+    */
+  public Object getContent(URLConnection urlc, Class[] classes)
+    throws IOException
+  {
+    Object obj = getContent(urlc);
+
+    for (int i = 0; i < classes.length; i++)
+      {
+	if (classes[i].isInstance(obj))
+	  return obj;
+      }
+
+    return null;
+  }
+} // class ContentHandler

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/ContentHandlerFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/ContentHandlerFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* ContentHandlerFactory.java -- Interface for creating content handlers
+   Copyright (C) 1998, 1999, 2000, 2001, 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.net;
+
+
+/**
+ * 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.
+ */
+/**
+  * This interface maps MIME types to <code>ContentHandler</code> objects.
+  * It consists of one method that, when passed a MIME type, returns a
+  * handler for that type.
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  * @author Warren Levy (warrenl at cygnus.com)
+  */
+public interface ContentHandlerFactory
+{
+  /**
+    * This method is passed a MIME type as a string and is responsible for
+    * returning the appropriate <code>ContentHandler</code> object.
+    *
+    * @param mimeType The MIME type to map to a <code>ContentHandler</code>
+    *
+    * @return The <code>ContentHandler</code> for the passed in MIME type
+    */
+  ContentHandler createContentHandler(String mimeType);
+} // interface ContentHandlerFactory

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/DatagramPacket.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/DatagramPacket.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,391 @@
+/* DatagramPacket.java -- Class to model a packet to be sent via UDP
+   Copyright (C) 1998, 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.net;
+
+
+/*
+ * 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.
+ */
+
+/**
+ * This class models a packet of data that is to be sent across the network
+ * using a connectionless protocol such as UDP.  It contains the data
+ * to be send, as well as the destination address and port.  Note that
+ * datagram packets can arrive in any order and are not guaranteed to be
+ * delivered at all.
+ * <p>
+ * This class can also be used for receiving data from the network.
+ * <p>
+ * Note that for all method below where the buffer length passed by the
+ * caller cannot exceed the actually length of the byte array passed as
+ * the buffer, if this condition is not true, then the method silently
+ * reduces the length value to maximum allowable value.
+ *
+ * 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.
+ *
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Aarom M. Renn (arenn at urbanophile.com) (Documentation comments)
+ * @date April 28, 1999.
+ */
+public final class DatagramPacket
+{
+  /**
+   * The data buffer to send
+   */
+  private byte[] buffer;
+
+  /**
+   * This is the offset into the buffer to start sending from or receiving to.
+   */
+  private int offset;
+
+  /**
+   * The length of the data buffer to send.
+   */
+  int length;
+
+  /**
+   * The maximal length of the buffer.
+   */
+  int maxlen;
+
+  /**
+   * The address to which the packet should be sent or from which it
+   * was received.
+   */
+  private InetAddress address;
+
+  /**
+   * The port to which the packet should be sent or from which it was
+   * was received.
+   */
+  private int port;
+
+  /**
+   * This method initializes a new instance of <code>DatagramPacket</code>
+   * which has the specified buffer, offset, and length.
+   *
+   * @param buf The buffer for holding the incoming datagram.
+   * @param offset The offset into the buffer to start writing.
+   * @param length The maximum number of bytes to read.
+   *
+   * @since 1.2
+   */
+  public DatagramPacket(byte[] buf, int offset, int length)
+  {
+    setData(buf, offset, length);
+    address = null;
+    port = -1;
+  }
+
+  /**
+   * Initializes a new instance of <code>DatagramPacket</code> for
+   * receiving packets from the network.
+   *
+   * @param buf A buffer for storing the returned packet data
+   * @param length The length of the buffer (must be <= buf.length)
+   */
+  public DatagramPacket(byte[] buf, int length)
+  {
+    this(buf, 0, length);
+  }
+
+  /**
+   * Initializes a new instance of <code>DatagramPacket</code> for
+   * transmitting packets across the network.
+   *
+   * @param buf A buffer containing the data to send
+   * @param offset The offset into the buffer to start writing from.
+   * @param length The length of the buffer (must be <= buf.length)
+   * @param address The address to send to
+   * @param port The port to send to
+   *
+   * @since 1.2
+   */
+  public DatagramPacket(byte[] buf, int offset, int length,
+                        InetAddress address, int port)
+  {
+    setData(buf, offset, length);
+    setAddress(address);
+    setPort(port);
+  }
+
+  /**
+   * Initializes a new instance of <code>DatagramPacket</code> for
+   * transmitting packets across the network.
+   *
+   * @param buf A buffer containing the data to send
+   * @param length The length of the buffer (must be <= buf.length)
+   * @param address The address to send to
+   * @param port The port to send to
+   */
+  public DatagramPacket(byte[] buf, int length, InetAddress address, int port)
+  {
+    this(buf, 0, length, address, port);
+  }
+
+  /**
+   * Initializes a new instance of <code>DatagramPacket</code> for
+   * transmitting packets across the network.
+   *
+   * @param buf A buffer containing the data to send
+   * @param offset The offset into the buffer to start writing from.
+   * @param length The length of the buffer (must be <= buf.length)
+   * @param address The socket address to send to
+   *
+   * @exception SocketException If an error occurs
+   * @exception IllegalArgumentException If address type is not supported
+   *
+   * @since 1.4
+   */
+  public DatagramPacket(byte[] buf, int offset, int length,
+                        SocketAddress address) throws SocketException
+  {
+    if (! (address instanceof InetSocketAddress))
+      throw new IllegalArgumentException("unsupported address type");
+
+    InetSocketAddress tmp = (InetSocketAddress) address;
+    setData(buf, offset, length);
+    setAddress(tmp.getAddress());
+    setPort(tmp.getPort());
+  }
+
+  /**
+   * Initializes a new instance of <code>DatagramPacket</code> for
+   * transmitting packets across the network.
+   *
+   * @param buf A buffer containing the data to send
+   * @param length The length of the buffer (must be <= buf.length)
+   * @param address The socket address to send to
+   *
+   * @exception SocketException If an error occurs
+   * @exception IllegalArgumentException If address type is not supported
+   *
+   * @since 1.4
+   */
+  public DatagramPacket(byte[] buf, int length, SocketAddress address)
+    throws SocketException
+  {
+    this(buf, 0, length, address);
+  }
+
+  /**
+   * Returns the address that this packet is being sent to or, if it was used
+   * to receive a packet, the address that is was received from.  If the
+   * constructor that doesn not take an address was used to create this object
+   * and no packet was actually read into this object, then this method
+   * returns <code>null</code>.
+   *
+   * @return The address for this packet.
+   */
+  public synchronized InetAddress getAddress()
+  {
+    return address;
+  }
+
+  /**
+   * Returns the port number this packet is being sent to or, if it was used
+   * to receive a packet, the port that it was received from. If the
+   * constructor that doesn not take an address was used to create this object
+   * and no packet was actually read into this object, then this method
+   * will return 0.
+   *
+   * @return The port number for this packet
+   */
+  public synchronized int getPort()
+  {
+    return port;
+  }
+
+  /**
+   * Returns the data buffer for this packet
+   *
+   * @return This packet's data buffer
+   */
+  public synchronized byte[] getData()
+  {
+    return buffer;
+  }
+
+  /**
+   * This method returns the current offset value into the data buffer
+   * where data will be sent from.
+   *
+   * @return The buffer offset.
+   *
+   * @since 1.2
+   */
+  public synchronized int getOffset()
+  {
+    return offset;
+  }
+
+  /**
+   * Returns the length of the data in the buffer
+   *
+   * @return The length of the data
+   */
+  public synchronized int getLength()
+  {
+    return length;
+  }
+
+  /**
+   * This sets the address to which the data packet will be transmitted.
+   *
+   * @param address The destination address
+   *
+   * @since 1.1
+   */
+  public synchronized void setAddress(InetAddress address)
+  {
+    this.address = address;
+  }
+
+  /**
+   * This sets the port to which the data packet will be transmitted.
+   *
+   * @param port The destination port
+   *
+   * @since 1.1
+   */
+  public synchronized void setPort(int port)
+  {
+    if (port < 0 || port > 65535)
+      throw new IllegalArgumentException("Invalid port: " + port);
+
+    this.port = port;
+  }
+
+  /**
+   * Sets the address of the remote host this package will be sent
+   *
+   * @param address The socket address of the remove host
+   *
+   * @exception IllegalArgumentException If address type is not supported
+   *
+   * @since 1.4
+   */
+  public void setSocketAddress(SocketAddress address)
+    throws IllegalArgumentException
+  {
+    if (address == null)
+      throw new IllegalArgumentException("address may not be null");
+
+    InetSocketAddress tmp = (InetSocketAddress) address;
+    this.address = tmp.getAddress();
+    this.port = tmp.getPort();
+  }
+
+  /**
+   * Gets the socket address of the host this packet
+   * will be sent to/is coming from
+   *
+   * @return The socket address of the remote host
+   *
+   * @since 1.4
+   */
+  public SocketAddress getSocketAddress()
+  {
+    return new InetSocketAddress(address, port);
+  }
+
+  /**
+   * Sets the data buffer for this packet.
+   *
+   * @param buf The new buffer for this packet
+   *
+   * @exception NullPointerException If the argument is null
+   *
+   * @since 1.1
+   */
+  public void setData(byte[] buf)
+  {
+    setData(buf, 0, buf.length);
+  }
+
+  /**
+   * This method sets the data buffer for the packet.
+   *
+   * @param buf The byte array containing the data for this packet.
+   * @param offset The offset into the buffer to start reading data from.
+   * @param length The number of bytes of data in the buffer.
+   *
+   * @exception NullPointerException If the argument is null
+   *
+   * @since 1.2
+   */
+  public synchronized void setData(byte[] buf, int offset, int length)
+  {
+    // This form of setData must be used if offset is to be changed.
+    if (buf == null)
+      throw new NullPointerException("Null buffer");
+    if (offset < 0)
+      throw new IllegalArgumentException("Invalid offset: " + offset);
+
+    buffer = buf;
+    this.offset = offset;
+    setLength(length);
+  }
+
+  /**
+   * Sets the length of the data in the buffer.
+   *
+   * @param length The new length.  (Where len <= buf.length)
+   *
+   * @exception IllegalArgumentException If the length is negative or
+   * if the length is greater than the packet's data buffer length
+   *
+   * @since 1.1
+   */
+  public synchronized void setLength(int length)
+  {
+    if (length < 0)
+      throw new IllegalArgumentException("Invalid length: " + length);
+    if (offset + length > buffer.length)
+      throw new IllegalArgumentException("Potential buffer overflow - offset: "
+                                         + offset + " length: " + length);
+
+    this.length = length;
+    this.maxlen = length;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/DatagramSocket.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/DatagramSocket.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,939 @@
+/* DatagramSocket.java -- A class to model UDP sockets
+   Copyright (C) 1998, 1999, 2000, 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.net;
+
+import gnu.classpath.SystemProperties;
+
+import gnu.java.net.PlainDatagramSocketImpl;
+import gnu.java.nio.DatagramChannelImpl;
+
+import java.io.IOException;
+import java.nio.channels.DatagramChannel;
+import java.nio.channels.IllegalBlockingModeException;
+
+
+/**
+ * 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.
+ */
+/**
+ * This class models a connectionless datagram socket that sends
+ * individual packets of data across the network.  In the TCP/IP world,
+ * this means UDP.  Datagram packets do not have guaranteed delivery,
+ * or any guarantee about the order the data will be received on the
+ * remote host.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @date May 3, 1999.
+ */
+public class DatagramSocket
+{
+  /**
+   * This is the user DatagramSocketImplFactory for this class.  If this
+   * variable is null, a default factory is used.
+   */
+  private static DatagramSocketImplFactory factory;
+
+  /**
+   * This is the implementation object used by this socket.
+   */
+  private DatagramSocketImpl impl;
+
+  /**
+   * True if socket implementation was created.
+   */
+  private boolean implCreated;
+
+  /**
+   * This is the address we are "connected" to
+   */
+  private InetAddress remoteAddress;
+
+  /**
+   * This is the port we are "connected" to
+   */
+  private int remotePort = -1;
+
+  /**
+   * True if socket is bound.
+   */
+  private boolean bound;
+
+  /**
+   * Creates a <code>DatagramSocket</code> from a specified
+   * <code>DatagramSocketImpl</code> instance
+   *
+   * @param impl The <code>DatagramSocketImpl</code> the socket will be
+   * created from
+   *
+   * @since 1.4
+   */
+  protected DatagramSocket(DatagramSocketImpl impl)
+  {
+    if (impl == null)
+      throw new NullPointerException("impl may not be null");
+
+    this.impl = impl;
+    this.remoteAddress = null;
+    this.remotePort = -1;
+  }
+
+  /**
+   * Initializes a new instance of <code>DatagramSocket</code> that binds to
+   * a random port and every address on the local machine.
+   *
+   * @exception SocketException If an error occurs.
+   * @exception SecurityException If a security manager exists and
+   * its <code>checkListen</code> method doesn't allow the operation.
+   */
+  public DatagramSocket() throws SocketException
+  {
+    this(new InetSocketAddress(0));
+  }
+
+  /**
+   * Initializes a new instance of <code>DatagramSocket</code> that binds to
+   * the specified port and every address on the local machine.
+   *
+   * @param port The local port number to bind to.
+   *
+   * @exception SecurityException If a security manager exists and its
+   * <code>checkListen</code> method doesn't allow the operation.
+   * @exception SocketException If an error occurs.
+   */
+  public DatagramSocket(int port) throws SocketException
+  {
+    this(new InetSocketAddress(port));
+  }
+
+  /**
+   * Initializes a new instance of <code>DatagramSocket</code> that binds to
+   * the specified local port and address.
+   *
+   * @param port The local port number to bind to.
+   * @param addr The local address to bind to.
+   *
+   * @exception SecurityException If a security manager exists and its
+   * checkListen method doesn't allow the operation.
+   * @exception SocketException If an error occurs.
+   */
+  public DatagramSocket(int port, InetAddress addr) throws SocketException
+  {
+    this(new InetSocketAddress(addr, port));
+  }
+
+  /**
+   * Initializes a new instance of <code>DatagramSocket</code> that binds to
+   * the specified local port and address.
+   *
+   * @param address The local address and port number to bind to.
+   *
+   * @exception SecurityException If a security manager exists and its
+   * <code>checkListen</code> method doesn't allow the operation.
+   * @exception SocketException If an error occurs.
+   *
+   * @since 1.4
+   */
+  public DatagramSocket(SocketAddress address) throws SocketException
+  {
+    String propVal = SystemProperties.getProperty("impl.prefix");
+    if (propVal == null || propVal.equals(""))
+      {
+        if (factory != null)
+          impl = factory.createDatagramSocketImpl();
+        else
+          impl = new PlainDatagramSocketImpl();
+      }
+    else
+      try
+        {
+	  impl =
+	    (DatagramSocketImpl) Class.forName("java.net." + propVal
+	                                       + "DatagramSocketImpl")
+	                              .newInstance();
+        }
+      catch (Exception e)
+        {
+	  System.err.println("Could not instantiate class: java.net."
+	                     + propVal + "DatagramSocketImpl");
+	  impl = new PlainDatagramSocketImpl();
+        }
+
+    if (address != null)
+      bind(address);
+  }
+
+  // This needs to be accessible from java.net.MulticastSocket
+  DatagramSocketImpl getImpl() throws SocketException
+  {
+    try
+      {
+	if (! implCreated)
+	  {
+	    impl.create();
+	    implCreated = true;
+	  }
+
+	return impl;
+      }
+    catch (IOException e)
+      {
+	SocketException se = new SocketException();
+	se.initCause(e);
+	throw se;
+      }
+  }
+
+  /**
+   * Closes this datagram socket.
+   */
+  public void close()
+  {
+    if (isClosed())
+      return;
+
+    try
+      {
+	getImpl().close();
+      }
+    catch (SocketException e)
+      {
+	// Ignore this case, just close the socket in finally clause.
+      }
+    finally
+      {
+	remoteAddress = null;
+	remotePort = -1;
+	impl = null;
+      }
+
+    try
+      {
+	if (getChannel() != null)
+	  getChannel().close();
+      }
+    catch (IOException e)
+      {
+	// Do nothing.
+      }
+  }
+
+  /**
+   * This method returns the remote address to which this socket is
+   * connected.  If this socket is not connected, then this method will
+   * return <code>null</code>.
+   *
+   * @return The remote address.
+   *
+   * @since 1.2
+   */
+  public InetAddress getInetAddress()
+  {
+    return remoteAddress;
+  }
+
+  /**
+   * This method returns the remote port to which this socket is
+   * connected.  If this socket is not connected, then this method will
+   * return -1.
+   *
+   * @return The remote port.
+   *
+   * @since 1.2
+   */
+  public int getPort()
+  {
+    return remotePort;
+  }
+
+  /**
+   * Returns the local address this datagram socket is bound to.
+   *
+   * @return The local address is the socket is bound or null
+   *
+   * @since 1.1
+   */
+  public InetAddress getLocalAddress()
+  {
+    if (! isBound())
+      return null;
+
+    InetAddress localAddr;
+
+    try
+      {
+	localAddr =
+	  (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
+
+	SecurityManager s = System.getSecurityManager();
+	if (s != null)
+	  s.checkConnect(localAddr.getHostName(), -1);
+      }
+    catch (SecurityException e)
+      {
+	localAddr = InetAddress.ANY_IF;
+      }
+    catch (SocketException e)
+      {
+	// This cannot happen as we are bound.
+	return null;
+      }
+
+    return localAddr;
+  }
+
+  /**
+   * Returns the local port this socket is bound to.
+   *
+   * @return The local port number.
+   */
+  public int getLocalPort()
+  {
+    if (isClosed())
+      return -1;
+
+    try
+      {
+	return getImpl().getLocalPort();
+      }
+    catch (SocketException e)
+      {
+	// This cannot happen as we are bound.
+	return 0;
+      }
+  }
+
+  /**
+   * Returns the value of the socket's SO_TIMEOUT setting.  If this method
+   * returns 0 then SO_TIMEOUT is disabled.
+   *
+   * @return The current timeout in milliseconds.
+   *
+   * @exception SocketException If an error occurs.
+   *
+   * @since 1.1
+   */
+  public synchronized int getSoTimeout() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object buf = getImpl().getOption(SocketOptions.SO_TIMEOUT);
+
+    if (buf instanceof Integer)
+      return ((Integer) buf).intValue();
+
+    throw new SocketException("unexpected type");
+  }
+
+  /**
+   * Sets the value of the socket's SO_TIMEOUT value.  A value of 0 will
+   * disable SO_TIMEOUT.  Any other value is the number of milliseconds
+   * a socket read/write will block before timing out.
+   *
+   * @param timeout The new SO_TIMEOUT value in milliseconds.
+   *
+   * @exception SocketException If an error occurs.
+   *
+   * @since 1.1
+   */
+  public synchronized void setSoTimeout(int timeout) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (timeout < 0)
+      throw new IllegalArgumentException("Invalid timeout: " + timeout);
+
+    getImpl().setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
+  }
+
+  /**
+   * This method returns the value of the system level socket option
+   * SO_SNDBUF, which is used by the operating system to tune buffer
+   * sizes for data transfers.
+   *
+   * @return The send buffer size.
+   *
+   * @exception SocketException If an error occurs.
+   *
+   * @since 1.2
+   */
+  public int getSendBufferSize() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object buf = getImpl().getOption(SocketOptions.SO_SNDBUF);
+
+    if (buf instanceof Integer)
+      return ((Integer) buf).intValue();
+
+    throw new SocketException("unexpected type");
+  }
+
+  /**
+   * This method sets the value for the system level socket option
+   * SO_SNDBUF to the specified value.  Note that valid values for this
+   * option are specific to a given operating system.
+   *
+   * @param size The new send buffer size.
+   *
+   * @exception SocketException If an error occurs.
+   * @exception IllegalArgumentException If size is 0 or negative.
+   *
+   * @since 1.2
+   */
+  public void setSendBufferSize(int size) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (size < 0)
+      throw new IllegalArgumentException("Buffer size is less than 0");
+
+    getImpl().setOption(SocketOptions.SO_SNDBUF, new Integer(size));
+  }
+
+  /**
+   * This method returns the value of the system level socket option
+   * SO_RCVBUF, which is used by the operating system to tune buffer
+   * sizes for data transfers.
+   *
+   * @return The receive buffer size.
+   *
+   * @exception SocketException If an error occurs.
+   *
+   * @since 1.2
+   */
+  public int getReceiveBufferSize() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object buf = getImpl().getOption(SocketOptions.SO_RCVBUF);
+
+    if (buf instanceof Integer)
+      return ((Integer) buf).intValue();
+
+    throw new SocketException("unexpected type");
+  }
+
+  /**
+   * This method sets the value for the system level socket option
+   * SO_RCVBUF to the specified value.  Note that valid values for this
+   * option are specific to a given operating system.
+   *
+   * @param size The new receive buffer size.
+   *
+   * @exception SocketException If an error occurs.
+   * @exception IllegalArgumentException If size is 0 or negative.
+   *
+   * @since 1.2
+   */
+  public void setReceiveBufferSize(int size) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (size < 0)
+      throw new IllegalArgumentException("Buffer size is less than 0");
+
+    getImpl().setOption(SocketOptions.SO_RCVBUF, new Integer(size));
+  }
+
+  /**
+   * This method connects this socket to the specified address and port.
+   * When a datagram socket is connected, it will only send or receive
+   * packets to and from the host to which it is connected. A multicast
+   * socket that is connected may only send and not receive packets.
+   *
+   * @param address The address to connect this socket to.
+   * @param port The port to connect this socket to.
+   *
+   * @exception IllegalArgumentException If address or port are invalid.
+   * @exception SecurityException If the caller is not allowed to send
+   * datagrams to or receive from this address and port.
+   *
+   * @since 1.2
+   */
+  public void connect(InetAddress address, int port)
+  {
+    if (address == null)
+      throw new IllegalArgumentException("Connect address may not be null");
+
+    if ((port < 1) || (port > 65535))
+      throw new IllegalArgumentException("Port number is illegal: " + port);
+
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkConnect(address.getHostName(), port);
+
+    try
+      {
+	getImpl().connect(address, port);
+	remoteAddress = address;
+	remotePort = port;
+      }
+    catch (SocketException e)
+      {
+	// This means simply not connected or connect not implemented.
+      }
+  }
+
+  /**
+   * This method disconnects this socket from the address/port it was
+   * connected to.  If the socket was not connected in the first place,
+   * this method does nothing.
+   *
+   * @since 1.2
+   */
+  public void disconnect()
+  {
+    if (! isConnected())
+      return;
+
+    try
+      {
+	getImpl().disconnect();
+      }
+    catch (SocketException e)
+      {
+	// This cannot happen as we are connected.
+      }
+    finally
+      {
+	remoteAddress = null;
+	remotePort = -1;
+      }
+  }
+
+  /**
+   * Reads a datagram packet from the socket.  Note that this method
+   * will block until a packet is received from the network.  On return,
+   * the passed in <code>DatagramPacket</code> is populated with the data
+   * received and all the other information about the packet.
+   *
+   * @param p A <code>DatagramPacket</code> for storing the data
+   *
+   * @exception IOException If an error occurs.
+   * @exception SocketTimeoutException If setSoTimeout was previously called
+   * and the timeout has expired.
+   * @exception PortUnreachableException If the socket is connected to a
+   * currently unreachable destination. Note, there is no guarantee that the
+   * exception will be thrown.
+   * @exception IllegalBlockingModeException If this socket has an associated
+   * channel, and the channel is in non-blocking mode.
+   * @exception SecurityException If a security manager exists and its
+   * checkAccept method doesn't allow the receive.
+   */
+  public synchronized void receive(DatagramPacket p) throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (remoteAddress != null && remoteAddress.isMulticastAddress())
+      throw new IOException
+	("Socket connected to a multicast address my not receive");
+
+    if (getChannel() != null && ! getChannel().isBlocking()
+        && ! ((DatagramChannelImpl) getChannel()).isInChannelOperation())
+      throw new IllegalBlockingModeException();
+
+    getImpl().receive(p);
+
+    SecurityManager s = System.getSecurityManager();
+    if (s != null && isConnected())
+      s.checkAccept(p.getAddress().getHostName(), p.getPort());
+  }
+
+  /**
+   * Sends the specified packet.  The host and port to which the packet
+   * are to be sent should be set inside the packet.
+   *
+   * @param p The datagram packet to send.
+   *
+   * @exception IOException If an error occurs.
+   * @exception SecurityException If a security manager exists and its
+   * checkMulticast or checkConnect method doesn't allow the send.
+   * @exception PortUnreachableException If the socket is connected to a
+   * currently unreachable destination. Note, there is no guarantee that the
+   * exception will be thrown.
+   * @exception IllegalBlockingModeException If this socket has an associated
+   * channel, and the channel is in non-blocking mode.
+   */
+  public void send(DatagramPacket p) throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    // JDK1.2: Don't do security checks if socket is connected; see jdk1.2 api.
+    SecurityManager s = System.getSecurityManager();
+    if (s != null && ! isConnected())
+      {
+	InetAddress addr = p.getAddress();
+	if (addr.isMulticastAddress())
+	  s.checkMulticast(addr);
+	else
+	  s.checkConnect(addr.getHostAddress(), p.getPort());
+      }
+
+    if (isConnected())
+      {
+	if (p.getAddress() != null
+	    && (remoteAddress != p.getAddress() || remotePort != p.getPort()))
+	  throw new IllegalArgumentException
+	    ("DatagramPacket address does not match remote address");
+      }
+
+    // FIXME: if this is a subclass of MulticastSocket,
+    // use getTimeToLive for TTL val.
+    if (getChannel() != null && ! getChannel().isBlocking()
+        && ! ((DatagramChannelImpl) getChannel()).isInChannelOperation())
+      throw new IllegalBlockingModeException();
+
+    getImpl().send(p);
+  }
+
+  /**
+   * Binds the socket to the given socket address.
+   *
+   * @param address The socket address to bind to.
+   *
+   * @exception SocketException If an error occurs.
+   * @exception SecurityException If a security manager exists and
+   * its checkListen method doesn't allow the operation.
+   * @exception IllegalArgumentException If address type is not supported.
+   *
+   * @since 1.4
+   */
+  public void bind(SocketAddress address) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (! (address instanceof InetSocketAddress))
+      throw new IllegalArgumentException("unsupported address type");
+
+    InetAddress addr = ((InetSocketAddress) address).getAddress();
+    int port = ((InetSocketAddress) address).getPort();
+
+    if (port < 0 || port > 65535)
+      throw new IllegalArgumentException("Invalid port: " + port);
+
+    SecurityManager s = System.getSecurityManager();
+    if (s != null)
+      s.checkListen(port);
+
+    if (addr == null)
+      addr = InetAddress.ANY_IF;
+
+    try
+      {
+	getImpl().bind(port, addr);
+	bound = true;
+      }
+    catch (SocketException exception)
+      {
+	getImpl().close();
+	throw exception;
+      }
+    catch (RuntimeException exception)
+      {
+	getImpl().close();
+	throw exception;
+      }
+    catch (Error error)
+      {
+	getImpl().close();
+	throw error;
+      }
+  }
+
+  /**
+   * Checks if the datagram socket is closed.
+   *
+   * @return True if socket is closed, false otherwise.
+   *
+   * @since 1.4
+   */
+  public boolean isClosed()
+  {
+    return impl == null;
+  }
+
+  /**
+   * Returns the datagram channel assoziated with this datagram socket.
+   *
+   * @return The associated <code>DatagramChannel</code> object or null
+   *
+   * @since 1.4
+   */
+  public DatagramChannel getChannel()
+  {
+    return null;
+  }
+
+  /**
+   * Connects the datagram socket to a specified socket address.
+   *
+   * @param address The socket address to connect to.
+   *
+   * @exception SocketException If an error occurs.
+   * @exception IllegalArgumentException If address type is not supported.
+   *
+   * @since 1.4
+   */
+  public void connect(SocketAddress address) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (! (address instanceof InetSocketAddress))
+      throw new IllegalArgumentException("unsupported address type");
+
+    InetSocketAddress tmp = (InetSocketAddress) address;
+    connect(tmp.getAddress(), tmp.getPort());
+  }
+
+  /**
+   * Returns the binding state of the socket.
+   *
+   * @return True if socket bound, false otherwise.
+   *
+   * @since 1.4
+   */
+  public boolean isBound()
+  {
+    return bound;
+  }
+
+  /**
+   * Returns the connection state of the socket.
+   *
+   * @return True if socket is connected, false otherwise.
+   *
+   * @since 1.4
+   */
+  public boolean isConnected()
+  {
+    return remoteAddress != null;
+  }
+
+  /**
+   * Returns the SocketAddress of the host this socket is conneted to
+   * or null if this socket is not connected.
+   *
+   * @return The socket address of the remote host if connected or null
+   *
+   * @since 1.4
+   */
+  public SocketAddress getRemoteSocketAddress()
+  {
+    if (! isConnected())
+      return null;
+
+    return new InetSocketAddress(remoteAddress, remotePort);
+  }
+
+  /**
+   * Returns the local SocketAddress this socket is bound to.
+   *
+   * @return The local SocketAddress or null if the socket is not bound.
+   *
+   * @since 1.4
+   */
+  public SocketAddress getLocalSocketAddress()
+  {
+    if (! isBound())
+      return null;
+
+    return new InetSocketAddress(getLocalAddress(), getLocalPort());
+  }
+
+  /**
+   * Enables/Disables SO_REUSEADDR.
+   *
+   * @param on Whether or not to have SO_REUSEADDR turned on.
+   *
+   * @exception SocketException If an error occurs.
+   *
+   * @since 1.4
+   */
+  public void setReuseAddress(boolean on) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    getImpl().setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(on));
+  }
+
+  /**
+   * Checks if SO_REUSEADDR is enabled.
+   *
+   * @return True if SO_REUSEADDR is set on the socket, false otherwise.
+   *
+   * @exception SocketException If an error occurs.
+   *
+   * @since 1.4
+   */
+  public boolean getReuseAddress() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object buf = getImpl().getOption(SocketOptions.SO_REUSEADDR);
+
+    if (buf instanceof Boolean)
+      return ((Boolean) buf).booleanValue();
+
+    throw new SocketException("unexpected type");
+  }
+
+  /**
+   * Enables/Disables SO_BROADCAST
+   *
+   * @param enable True if SO_BROADCAST should be enabled, false otherwise.
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  public void setBroadcast(boolean enable) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    getImpl().setOption(SocketOptions.SO_BROADCAST, Boolean.valueOf(enable));
+  }
+
+  /**
+   * Checks if SO_BROADCAST is enabled
+   *
+   * @return Whether SO_BROADCAST is set
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  public boolean getBroadcast() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object buf = getImpl().getOption(SocketOptions.SO_BROADCAST);
+
+    if (buf instanceof Boolean)
+      return ((Boolean) buf).booleanValue();
+
+    throw new SocketException("unexpected type");
+  }
+
+  /**
+   * Sets the traffic class value
+   *
+   * @param tc The traffic class
+   *
+   * @exception SocketException If an error occurs
+   * @exception IllegalArgumentException If tc value is illegal
+   *
+   * @see DatagramSocket#getTrafficClass()
+   *
+   * @since 1.4
+   */
+  public void setTrafficClass(int tc) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (tc < 0 || tc > 255)
+      throw new IllegalArgumentException();
+
+    getImpl().setOption(SocketOptions.IP_TOS, new Integer(tc));
+  }
+
+  /**
+   * Returns the current traffic class
+   *
+   * @return The current traffic class.
+   *
+   * @see DatagramSocket#setTrafficClass(int tc)
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  public int getTrafficClass() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object buf = getImpl().getOption(SocketOptions.IP_TOS);
+
+    if (buf instanceof Integer)
+      return ((Integer) buf).intValue();
+
+    throw new SocketException("unexpected type");
+  }
+
+  /**
+   * Sets the datagram socket implementation factory for the application
+   *
+   * @param fac The factory to set
+   *
+   * @exception IOException If an error occurs
+   * @exception SocketException If the factory is already defined
+   * @exception SecurityException If a security manager exists and its
+   * checkSetFactory method doesn't allow the operation
+   */
+  public static void setDatagramSocketImplFactory(DatagramSocketImplFactory fac)
+    throws IOException
+  {
+    if (factory != null)
+      throw new SocketException("DatagramSocketImplFactory already defined");
+
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkSetFactory();
+
+    factory = fac;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/DatagramSocketImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/DatagramSocketImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,296 @@
+/* DatagramSocketImpl.java -- Abstract class for UDP socket implementations
+   Copyright (C) 1998, 1999 2000, 2001,
+                 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.net;
+
+import java.io.FileDescriptor;
+import java.io.IOException;
+
+
+/**
+ * This abstract class models a datagram socket implementation.  An
+ * actual implementation class would implement these methods, probably
+ * via redirecting them to native code.
+ * <p>
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * <p>
+ * Status:  Believed complete and correct.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @since 1.1
+ */
+public abstract class DatagramSocketImpl implements SocketOptions
+{
+  /**
+   * The local port to which this socket is bound
+   */
+  protected int localPort;
+
+  /**
+   * The FileDescriptor object for this object.
+   */
+  protected FileDescriptor fd;
+
+  /**
+   * Default, no-argument constructor for subclasses to call.
+   */
+  public DatagramSocketImpl()
+  {
+  }
+
+  /**
+   * This method binds the socket to the specified local port and address.
+   *
+   * @param lport The port number to bind to
+   * @param laddr The address to bind to
+   *
+   * @exception SocketException If an error occurs
+   */
+  protected abstract void bind(int lport, InetAddress laddr)
+    throws SocketException;
+
+  /**
+   * This methods closes the socket
+   */
+  protected abstract void close();
+
+  /**
+   * Creates a new datagram socket.
+   *
+   * @exception SocketException If an error occurs
+   */
+  protected abstract void create() throws SocketException;
+
+  /**
+   * Takes a peek at the next packet received in order to retrieve the
+   * address of the sender
+   *
+   * @param i The <code>InetAddress</code> to fill in with the information
+   *          about the sender if the next packet
+   *
+   * @return The port number of the sender of the packet
+   *
+   * @exception IOException If an error occurs
+   * @exception PortUnreachableException May be thrown if the socket is
+   * connected to a currently unreachable destination. Note, there is no
+   * guarantee that the exception will be thrown.
+   */
+  protected abstract int peek(InetAddress i) throws IOException;
+
+  /**
+   * Takes a peek at the next packet received.  This packet is not consumed.
+   * With the next peekData/receive operation this packet will be read again.
+   *
+   * @param p The <code>DatagramPacket</code> to fill in with the data sent.
+   *
+   * @return The port number of the sender of the packet.
+   *
+   * @exception IOException If an error occurs
+   * @exception PortUnreachableException May be thrown if the socket is
+   * connected to a currently unreachable destination. Note, there is no
+   * guarantee that the exception will be thrown.
+   *
+   * @since 1.4
+   */
+  protected abstract int peekData(DatagramPacket p) throws IOException;
+
+  /**
+   * Transmits the specified packet of data to the network.  The destination
+   * host and port should be encoded in the packet.
+   *
+   * @param p The packet to send
+   *
+   * @exception IOException If an error occurs
+   * @exception PortUnreachableException May be thrown if the socket is
+   * connected to a currently unreachable destination. Note, there is no
+   * guarantee that the exception will be thrown.
+   */
+  protected abstract void send(DatagramPacket p) throws IOException;
+
+  /**
+   * Receives a packet of data from the network  Will block until a packet
+   * arrives.  The packet info in populated into the passed in
+   * <code>DatagramPacket</code> object.
+   *
+   * @param p A place to store the incoming packet.
+   *
+   * @exception IOException If an error occurs
+   * @exception PortUnreachableException May be thrown if the socket is
+   * connected to a currently unreachable destination. Note, there is no
+   * guarantee that the exception will be thrown.
+   */
+  protected abstract void receive(DatagramPacket p) throws IOException;
+
+  /**
+   * Connects the socket to a host specified by address and port.
+   *
+   * @param address The <code>InetAddress</code> of the host to connect to
+   * @param port The port number of the host to connect to
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  protected void connect(InetAddress address, int port)
+    throws SocketException
+  {
+    // This method has to be overwritten by real implementations
+  }
+
+  /**
+   * Disconnects the socket.
+   *
+   * @since 1.4
+   */
+  protected void disconnect()
+  {
+    // This method has to be overwritten by real implementations
+  }
+
+  /**
+   * Sets the Time to Live (TTL) setting on this socket to the specified
+   * value. <b>Use <code>setTimeToLive(int)</code></b> instead.
+   *
+   * @param ttl The new Time to Live value
+   *
+   * @exception IOException If an error occurs
+   * @deprecated
+   */
+  protected abstract void setTTL(byte ttl) throws IOException;
+
+  /**
+   * This method returns the current Time to Live (TTL) setting on this
+   * socket.  <b>Use <code>getTimeToLive()</code></b> instead.
+   *
+   * @return the current time-to-live
+   * 
+   * @exception IOException If an error occurs
+   * 
+   * @deprecated // FIXME: when ?
+   */
+  protected abstract byte getTTL() throws IOException;
+
+  /**
+   * Sets the Time to Live (TTL) setting on this socket to the specified
+   * value.
+   *
+   * @param ttl The new Time to Live value
+   *
+   * @exception IOException If an error occurs
+   */
+  protected abstract void setTimeToLive(int ttl) throws IOException;
+
+  /**
+   * This method returns the current Time to Live (TTL) setting on this
+   * socket.
+   *
+   * @return the current time-to-live
+   * 
+   * @exception IOException If an error occurs
+   */
+  protected abstract int getTimeToLive() throws IOException;
+
+  /**
+   * Causes this socket to join the specified multicast group
+   *
+   * @param inetaddr The multicast address to join with
+   *
+   * @exception IOException If an error occurs
+   */
+  protected abstract void join(InetAddress inetaddr) throws IOException;
+
+  /**
+   * Causes the socket to leave the specified multicast group.
+   *
+   * @param inetaddr The multicast address to leave
+   *
+   * @exception IOException If an error occurs
+   */
+  protected abstract void leave(InetAddress inetaddr) throws IOException;
+
+  /**
+   * Causes this socket to join the specified multicast group on a specified
+   * device
+   *
+   * @param mcastaddr The address to leave
+   * @param netIf The specified network interface to join the group at
+   *
+   * @exception IOException If an error occurs
+   *
+   * @since 1.4
+   */
+  protected abstract void joinGroup(SocketAddress mcastaddr,
+                                    NetworkInterface netIf)
+    throws IOException;
+
+  /**
+   * Leaves a multicast group
+   *
+   * @param mcastaddr The address to join
+   * @param netIf The specified network interface to leave the group at
+   *
+   * @exception IOException If an error occurs
+   *
+   * @since 1.4
+   */
+  protected abstract void leaveGroup(SocketAddress mcastaddr,
+                                     NetworkInterface netIf)
+    throws IOException;
+
+  /**
+   * Returns the FileDescriptor for this socket
+   * 
+   * @return the file descriptor associated with this socket
+   */
+  protected FileDescriptor getFileDescriptor()
+  {
+    return fd;
+  }
+
+  /**
+   * Returns the local port this socket is bound to
+   *
+   * @return the local port
+   */
+  protected int getLocalPort()
+  {
+    return localPort;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/DatagramSocketImplFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/DatagramSocketImplFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,60 @@
+/* DatagramSocketImplFactory.java --
+   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.net;
+
+
+/** Written using on-line Java Platform 1.4 API Specification.
+  * Status: Believed complete and correct.
+  */
+/**
+  * This interface defines one method which returns a
+  * <code>DatagramSocketImpl</code> object.
+  * This should not be needed by ordinary applications.
+  *
+  * @author Michael Koch (konqueror at gmx.de)
+  * @since 1.3
+  */
+public interface DatagramSocketImplFactory
+{
+  /**
+   * This method returns an instance of the DatagramSocketImpl object
+   *
+   * @return A DatagramSocketImpl object
+   */
+  DatagramSocketImpl createDatagramSocketImpl();
+} // interface DatagramSocketImplFactory

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/FileNameMap.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/FileNameMap.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* FileNameMap.java -- Maps filenames to MIME types
+   Copyright (C) 1998, 1999, 2000, 2001, 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.net;
+
+
+/**
+ * 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.
+ */
+/**
+  * This interface has one method which, when passed a filename, returns
+  * the MIME type associated with that filename.
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  * @author Warren Levy (warrenl at cygnus.com)
+  * @since 1.1
+  */
+public interface FileNameMap
+{
+  /**
+    * This method is passed a filename and is responsible for determining
+    * the appropriate MIME type for that file.
+    *
+    * @param filename The name of the file to generate a MIME type for.
+    *
+    * @return The MIME type for the filename passed in.
+    */
+  String getContentTypeFor(String filename);
+} // interface FileNameMap

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/HttpURLConnection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/HttpURLConnection.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,589 @@
+/* HttpURLConnection.java -- Subclass of communications links using
+   Hypertext Transfer Protocol.
+   Copyright (C) 1998, 1999, 2000, 2002, 2003  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 java.net;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+import java.security.Permission;
+
+
+/*
+ * 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.
+ */
+
+/**
+ * This class provides a common abstract implementation for those
+ * URL connection classes that will connect using the HTTP protocol.
+ * In addition to the functionality provided by the URLConnection
+ * class, it defines constants for HTTP return code values and
+ * methods for setting the HTTP request method and determining whether
+ * or not to follow redirects.
+ *
+ * @since 1.1
+ *
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public abstract class HttpURLConnection extends URLConnection
+{
+  /* HTTP Success Response Codes */
+
+  /**
+   * Indicates that the client may continue with its request.  This value
+   * is specified as part of RFC 2068 but was not included in Sun's JDK, so
+   * beware of using this value
+   */
+  static final int HTTP_CONTINUE = 100;
+
+  /**
+   * Indicates the request succeeded.
+   */
+  public static final int HTTP_OK = 200;
+
+  /**
+   * The requested resource has been created.
+   */
+  public static final int HTTP_CREATED = 201;
+
+  /**
+   * The request has been accepted for processing but has not completed.
+   * There is no guarantee that the requested action will actually ever
+   * be completed succesfully, but everything is ok so far.
+   */
+  public static final int HTTP_ACCEPTED = 202;
+
+  /**
+   * The meta-information returned in the header is not the actual data
+   * from the original server, but may be from a local or other copy.
+   * Normally this still indicates a successful completion.
+   */
+  public static final int HTTP_NOT_AUTHORITATIVE = 203;
+
+  /**
+   * The server performed the request, but there is no data to send
+   * back.  This indicates that the user's display should not be changed.
+   */
+  public static final int HTTP_NO_CONTENT = 204;
+
+  /**
+   * The server performed the request, but there is no data to sent back,
+   * however, the user's display should be "reset" to clear out any form
+   * fields entered.
+   */
+  public static final int HTTP_RESET = 205;
+
+  /**
+   * The server completed the partial GET request for the resource.
+   */
+  public static final int HTTP_PARTIAL = 206;
+
+  /* HTTP Redirection Response Codes */
+
+  /**
+   * There is a list of choices available for the requested resource.
+   */
+  public static final int HTTP_MULT_CHOICE = 300;
+
+  /**
+   * The resource has been permanently moved to a new location.
+   */
+  public static final int HTTP_MOVED_PERM = 301;
+
+  /**
+   * The resource requested has been temporarily moved to a new location.
+   */
+  public static final int HTTP_MOVED_TEMP = 302;
+
+  /**
+   * The response to the request issued is available at another location.
+   */
+  public static final int HTTP_SEE_OTHER = 303;
+
+  /**
+   * The document has not been modified since the criteria specified in
+   * a conditional GET.
+   */
+  public static final int HTTP_NOT_MODIFIED = 304;
+
+  /**
+   * The requested resource needs to be accessed through a proxy.
+   */
+  public static final int HTTP_USE_PROXY = 305;
+
+  /* HTTP Client Error Response Codes */
+
+  /**
+   * The request was misformed or could not be understood.
+   */
+  public static final int HTTP_BAD_REQUEST = 400;
+
+  /**
+   * The request made requires user authorization.  Try again with
+   * a correct authentication header.
+   */
+  public static final int HTTP_UNAUTHORIZED = 401;
+
+  /**
+   * Code reserved for future use - I hope way in the future.
+   */
+  public static final int HTTP_PAYMENT_REQUIRED = 402;
+
+  /**
+   * There is no permission to access the requested resource.
+   */
+  public static final int HTTP_FORBIDDEN = 403;
+
+  /**
+   * The requested resource was not found.
+   */
+  public static final int HTTP_NOT_FOUND = 404;
+
+  /**
+   * The specified request method is not allowed for this resource.
+   */
+  public static final int HTTP_BAD_METHOD = 405;
+
+  /**
+   * Based on the input headers sent, the resource returned in response
+   * to the request would not be acceptable to the client.
+   */
+  public static final int HTTP_NOT_ACCEPTABLE = 406;
+
+  /**
+   * The client must authenticate with a proxy prior to attempting this
+   * request.
+   */
+  public static final int HTTP_PROXY_AUTH = 407;
+
+  /**
+   * The request timed out.
+   */
+  public static final int HTTP_CLIENT_TIMEOUT = 408;
+
+  /**
+   * There is a conflict between the current state of the resource and the
+   * requested action.
+   */
+  public static final int HTTP_CONFLICT = 409;
+
+  /**
+   * The requested resource is no longer available.  This ususally indicates
+   * a permanent condition.
+   */
+  public static final int HTTP_GONE = 410;
+
+  /**
+   * A Content-Length header is required for this request, but was not
+   * supplied.
+   */
+  public static final int HTTP_LENGTH_REQUIRED = 411;
+
+  /**
+   * A client specified pre-condition was not met on the server.
+   */
+  public static final int HTTP_PRECON_FAILED = 412;
+
+  /**
+   * The request sent was too large for the server to handle.
+   */
+  public static final int HTTP_ENTITY_TOO_LARGE = 413;
+
+  /**
+   * The name of the resource specified was too long.
+   */
+  public static final int HTTP_REQ_TOO_LONG = 414;
+
+  /**
+   * The request is in a format not supported by the requested resource.
+   */
+  public static final int HTTP_UNSUPPORTED_TYPE = 415;
+
+  /* HTTP Server Error Response Codes */
+
+  /**
+   * This error code indicates that some sort of server error occurred.
+   *
+   * @deprecated
+   */
+  public static final int HTTP_SERVER_ERROR = 500;
+
+  /**
+   * The server encountered an unexpected error (such as a CGI script crash)
+   * that prevents the request from being fulfilled.
+   */
+  public static final int HTTP_INTERNAL_ERROR = 500;
+
+  /**
+   * The server does not support the requested functionality.
+   * @since 1.3
+   */
+  public static final int HTTP_NOT_IMPLEMENTED = 501;
+
+  /**
+   * The proxy encountered a bad response from the server it was proxy-ing for
+   */
+  public static final int HTTP_BAD_GATEWAY = 502;
+
+  /**
+   * The HTTP service is not availalble, such as because it is overloaded
+   * and does not want additional requests.
+   */
+  public static final int HTTP_UNAVAILABLE = 503;
+
+  /**
+   * The proxy timed out getting a reply from the remote server it was
+   * proxy-ing for.
+   */
+  public static final int HTTP_GATEWAY_TIMEOUT = 504;
+
+  /**
+   * This server does not support the protocol version requested.
+   */
+  public static final int HTTP_VERSION = 505;
+
+  // Non-HTTP response static variables
+
+  /**
+   * Flag to indicate whether or not redirects should be automatically
+   * followed by default.
+   */
+  private static boolean followRedirects = true;
+
+  /**
+   * This is a list of valid request methods, separated by "|" characters.
+   */
+  private static final String valid_methods =
+    "|GET|POST|HEAD|OPTIONS|PUT|DELETE|TRACE|";
+
+  // Instance Variables
+
+  /**
+   * The requested method in use for this connection. Default is GET.
+   */
+  protected String method = "GET";
+
+  /**
+   * The response code received from the server
+   */
+  protected int responseCode = -1;
+
+  /**
+   * The response message string received from the server.
+   */
+  protected String responseMessage;
+
+  /**
+   * If this instance should follow redirect requests.
+   */
+  protected boolean instanceFollowRedirects = followRedirects;
+
+  /**
+   * Whether we already got a valid response code for this connection.
+   * Used by <code>getResponseCode()</code> and
+   * <code>getResponseMessage()</code>.
+   */
+  private boolean gotResponseVals;
+
+  /**
+   * Create an HttpURLConnection for the specified URL
+   *
+   * @param url The URL to create this connection for.
+   */
+  protected HttpURLConnection(URL url)
+  {
+    super(url);
+  }
+
+  /**
+   * Closes the connection to the server.
+   */
+  public abstract void disconnect();
+
+  /**
+   * Returns a boolean indicating whether or not this connection is going
+   * through a proxy
+   *
+   * @return true if through a proxy, false otherwise
+   */
+  public abstract boolean usingProxy();
+
+  /**
+   * Sets whether HTTP redirects (requests with response code 3xx) should be
+   * automatically followed by this class. True by default
+   *
+   * @param set true if redirects should be followed, false otherwis.
+   *
+   * @exception SecurityException If a security manager exists and its
+   * checkSetFactory method doesn't allow the operation
+   */
+  public static void setFollowRedirects(boolean set)
+  {
+    // Throw an exception if an extant security mgr precludes
+    // setting the factory.
+    SecurityManager s = System.getSecurityManager();
+    if (s != null)
+      s.checkSetFactory();
+
+    followRedirects = set;
+  }
+
+  /**
+   * Returns a boolean indicating whether or not HTTP redirects will
+   * automatically be followed or not.
+   *
+   * @return true if redirects will be followed, false otherwise
+   */
+  public static boolean getFollowRedirects()
+  {
+    return followRedirects;
+  }
+
+  /**
+   * Returns the value of this HttpURLConnection's instanceFollowRedirects
+   * field
+   * 
+   * @return true if following redirects is enabled, false otherwise
+   */
+  public boolean getInstanceFollowRedirects()
+  {
+    return instanceFollowRedirects;
+  }
+
+  /**
+   * Sets the value of this HttpURLConnection's instanceFollowRedirects field
+   *
+   * @param follow true to enable following redirects, false otherwise
+   */
+  public void setInstanceFollowRedirects(boolean follow)
+  {
+    instanceFollowRedirects = follow;
+  }
+
+  /**
+   * Set the method for the URL request, one of:
+   * GET POST HEAD OPTIONS PUT DELETE TRACE are legal
+   *
+   * @param method the method to use
+   *
+   * @exception ProtocolException If the method cannot be reset or if the
+   * requested method isn't valid for HTTP
+   */
+  public void setRequestMethod(String method) throws ProtocolException
+  {
+    if (connected)
+      throw new ProtocolException("Already connected");
+
+    method = method.toUpperCase();
+    if (valid_methods.indexOf("|" + method + "|") != -1)
+      this.method = method;
+    else
+      throw new ProtocolException("Invalid HTTP request method: " + method);
+  }
+
+  /**
+   * The request method currently in use for this connection.
+   *
+   * @return The request method
+   */
+  public String getRequestMethod()
+  {
+    return method;
+  }
+
+  /**
+   * Gets the status code from an HTTP response message, or -1 if
+   * the response code could not be determined.
+   * Note that all valid response codes have class variables
+   * defined for them in this class.
+   *
+   * @return The response code
+   *
+   * @exception IOException If an error occurs
+   */
+  public int getResponseCode() throws IOException
+  {
+    if (! gotResponseVals)
+      getResponseVals();
+    return responseCode;
+  }
+
+  /**
+   * Gets the HTTP response message, if any, returned along with the
+   * response code from a server. Null if no response message was set
+   * or an error occured while connecting.
+   *
+   * @return The response message
+   *
+   * @exception IOException If an error occurs
+   */
+  public String getResponseMessage() throws IOException
+  {
+    if (! gotResponseVals)
+      getResponseVals();
+    return responseMessage;
+  }
+
+  private void getResponseVals() throws IOException
+  {
+    // getHeaderField() will connect for us, but do it here first in
+    // order to pick up IOExceptions.
+    if (! connected)
+      connect();
+
+    gotResponseVals = true;
+
+    // If responseCode not yet explicitly set by subclass
+    if (responseCode == -1)
+      {
+	// Response is the first header received from the connection.
+	String respField = getHeaderField(0);
+
+	if (respField == null || ! respField.startsWith("HTTP/"))
+	  {
+	    // Set to default values on failure.
+	    responseCode = -1;
+	    responseMessage = null;
+	    return;
+	  }
+
+	int firstSpc;
+	int nextSpc;
+	firstSpc = respField.indexOf(' ');
+	nextSpc = respField.indexOf(' ', firstSpc + 1);
+	responseMessage = respField.substring(nextSpc + 1);
+	String codeStr = respField.substring(firstSpc + 1, nextSpc);
+	try
+	  {
+	    responseCode = Integer.parseInt(codeStr);
+	  }
+	catch (NumberFormatException e)
+	  {
+	    // Set to default values on failure.
+	    responseCode = -1;
+	    responseMessage = null;
+	  }
+      }
+  }
+
+  /**
+   * Returns a permission object representing the permission necessary to make
+   * the connection represented by this object
+   *
+   * @return the permission necessary for this connection
+   *
+   * @exception IOException If an error occurs
+   */
+  public Permission getPermission() throws IOException
+  {
+    URL url = getURL();
+    String host = url.getHost();
+    int port = url.getPort();
+    if (port == -1)
+      port = 80;
+
+    host = host + ":" + port;
+
+    return new SocketPermission(host, "connect");
+  }
+
+  /**
+   * This method allows the caller to retrieve any data that might have
+   * been sent despite the fact that an error occurred.  For example, the
+   * HTML page sent along with a 404 File Not Found error.  If the socket
+   * is not connected, or if no error occurred or no data was returned,
+   * this method returns <code>null</code>.
+   *
+   * @return An <code>InputStream</code> for reading error data.
+   */
+  public InputStream getErrorStream()
+  {
+    if (! connected)
+      return null;
+
+    int code;
+    try
+      {
+	code = getResponseCode();
+      }
+    catch (IOException e)
+      {
+	code = -1;
+      }
+
+    if (code == -1)
+      return null;
+
+    if (((code / 100) != 4) || ((code / 100) != 5))
+      return null;
+
+    try
+      {
+	PushbackInputStream pbis = new PushbackInputStream(getInputStream());
+
+	int i = pbis.read();
+	if (i == -1)
+	  return null;
+
+	pbis.unread(i);
+	return pbis;
+      }
+    catch (IOException e)
+      {
+	return null;
+      }
+  }
+
+  /**
+   * Returns the value of the named field parsed as date
+   *
+   * @param key the key of the header field
+   * @param value the default value if the header field is not present
+   *
+   * @return the value of the header field
+   */
+  public long getHeaderFieldDate(String key, long value)
+  {
+    // FIXME: implement this correctly
+    // http://www.w3.org/Protocols/HTTP-NG/ng-notes.txt
+    return super.getHeaderFieldDate(key, value);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/Inet4Address.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/Inet4Address.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,271 @@
+/* Inet4Address.java --
+   Copyright (C) 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.net;
+
+import java.io.ObjectStreamException;
+
+/*
+ * Written using on-line Java Platform 1.4 API Specification and
+ * RFC 1884 (http://www.ietf.org/rfc/rfc1884.txt),
+ * RFC 1918 (http://www.ietf.org/rfc/rfc1918.txt),
+ * RFC 2365 (http://www.ietf.org/rfc/rfc2365.txt)
+ *
+ * @author Michael Koch
+ * @status Believed complete and correct.
+ */
+public final class Inet4Address extends InetAddress
+{
+  /**
+   * For compatability with Sun's JDK 1.4.2 rev. 5
+   */
+  static final long serialVersionUID = 3286316764910316507L;
+
+  /**
+   * The address family of these addresses (used for serialization).
+   */
+  private static final int FAMILY = 2; // AF_INET
+
+  /**
+   * Inet4Address objects are serialized as InetAddress objects.
+   */
+  private Object writeReplace() throws ObjectStreamException
+  {
+    return new InetAddress(addr, hostName, FAMILY);
+  }
+  
+  /**
+   * Initializes this object's addr instance variable from the passed in
+   * byte array.  Note that this constructor is protected and is called
+   * only by static methods in this class.
+   *
+   * @param addr The IP number of this address as an array of bytes
+   * @param host The hostname of this IP address.
+   */
+  Inet4Address(byte[] addr, String host)
+  {
+    super(addr, host, FAMILY);
+  }
+
+  /**
+   * Checks if the address is a multicast address
+   *
+   * @since 1.1
+   */
+  public boolean isMulticastAddress()
+  {
+    return (addr[0] & 0xf0) == 0xe0;
+  }
+
+  /**
+   * Checks if this address is a loopback address
+   */
+  public boolean isLoopbackAddress()
+  {
+    return (addr[0] & 0xff) == 0x7f;
+  }
+
+  /**
+   * Checks if this address is a wildcard address
+   *
+   * @since 1.4
+   */
+  public boolean isAnyLocalAddress()
+  {
+    return equals(InetAddress.ANY_IF);
+  }
+
+  /**
+   * Checks if this address is a link local address
+   *
+   * @since 1.4
+   */
+  public boolean isLinkLocalAddress()
+  {
+    return false;
+  }
+
+  /**
+   * Checks if this address is a site local address
+   *
+   * @since 1.4
+   */
+  public boolean isSiteLocalAddress()
+  {
+    // 10.0.0.0/8
+    if ((addr[0] & 0xff) == 0x0a)
+      return true;
+
+    // 172.16.0.0/12
+    if ((addr[0] & 0xff) == 0xac && (addr[1] & 0xf0) == 0x10)
+      return true;
+
+    // 192.168.0.0/16
+    if ((addr[0] & 0xff) == 0xc0 && (addr[1] & 0xff) == 0xa8)
+      return true;
+
+    return false;
+  }
+
+  /**
+   * Checks if this multicast address has global scope
+   *
+   * @since 1.4
+   */
+  public boolean isMCGlobal()
+  {
+    return false;
+  }
+
+  /**
+   * Checks if this multicast address has node scope
+   *
+   * @since 1.4
+   */
+  public boolean isMCNodeLocal()
+  {
+    return false;
+  }
+
+  /**
+   * Checks if this multicast address has link scope
+   *
+   * @since 1.4
+   */
+  public boolean isMCLinkLocal()
+  {
+    if (! isMulticastAddress())
+      return false;
+
+    return ((addr[0] & 0xff) == 0xe0
+	    && (addr[1] & 0xff)  == 0x00
+	    && (addr[2] & 0xff)  == 0x00);
+  }
+
+  /**
+   * Checks if this multicast address has site scope
+   *
+   * @since 1.4
+   */
+  public boolean isMCSiteLocal()
+  {
+    return false;
+  }
+
+  /**
+   * Checks if this multicast address has organization scope
+   *
+   * @since 1.4
+   */
+  public boolean isMCOrgLocal()
+  {
+    return false;
+  }
+
+  /**
+   * Returns the address of the current instance
+   */
+  public byte[] getAddress()
+  {
+    return (byte[]) addr.clone();
+  }
+
+  /**
+   * Returns the address as string
+   *
+   * @since 1.0.2
+   */
+  public String getHostAddress()
+  {
+    StringBuffer sb = new StringBuffer(40);
+
+    int len = addr.length;
+    int i = 0;
+    
+    for ( ; ; )
+      {
+        sb.append(addr[i] & 0xff);
+        i++;
+	
+        if (i == len)
+          break;
+	
+        sb.append('.');
+      }
+
+    return sb.toString();
+  }
+
+  /**
+   * Computes the hashcode of the instance
+   */
+  public int hashCode()
+  {
+    int hash = 0;
+    int len = addr.length;
+    int i = len > 4 ? len - 4 : 0;
+
+    for (; i < len; i++)
+      hash = (hash << 8) | (addr[i] & 0xFF);
+
+    return hash;
+  }
+
+  /**
+   * Compare the current Inet4Address instance with obj
+   *
+   * @param obj Object to compare with
+   */
+  public boolean equals(Object obj)
+  {
+    if (! (obj instanceof InetAddress))
+      return false;
+
+    byte[] addr1 = addr;
+    byte[] addr2 = ((InetAddress) obj).addr;
+
+    if (addr1.length != addr2.length)
+      return false;
+
+    for (int i = addr1.length; --i >= 0;)
+      if (addr1[i] != addr2[i])
+	return false;
+
+    return true;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/Inet6Address.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/Inet6Address.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,427 @@
+/* Inet6Address.java --
+   Copyright (C) 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.net;
+
+import java.util.Arrays;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+
+/*
+ * Written using on-line Java Platform 1.4 API Specification and
+ * RFC 1884 (http://www.ietf.org/rfc/rfc1884.txt)
+ * 
+ * @author Michael Koch
+ * @status Updated to 1.5. Serialization compatibility is tested.
+ */
+public final class Inet6Address extends InetAddress
+{
+  static final long serialVersionUID = 6880410070516793377L;
+
+  /**
+   * Needed for serialization
+   */
+  byte[] ipaddress;
+
+  /**
+   * The scope ID, if any. 
+   * @since 1.5
+   * @serial 
+   */
+  private int scope_id;
+
+  /**
+   * The scope ID, if any. 
+   * @since 1.5
+   * @serial 
+   */
+  private boolean scope_id_set;
+
+  /**
+   * Whether ifname is set or not.
+   * @since 1.5
+   * @serial 
+   */
+  private boolean scope_ifname_set;
+
+  /**
+   * Name of the network interface, used only by the serialization methods
+   * @since 1.5
+   * @serial 
+   */
+  private String ifname;
+
+  /**
+   * Scope network interface, or <code>null</code>.
+   */
+  private transient NetworkInterface nif; 
+
+  /**
+   * The address family of these addresses (used for serialization).
+   */
+  private static final int FAMILY = 10; // AF_INET6
+
+  /**
+   * Create an Inet6Address object
+   *
+   * @param addr The IP address
+   * @param host The hostname
+   */
+  Inet6Address(byte[] addr, String host)
+  {
+    super(addr, host, FAMILY);
+    // Super constructor clones the addr.  Get a reference to the clone.
+    this.ipaddress = this.addr;
+    ifname = null;
+    scope_ifname_set = scope_id_set = false;
+    scope_id = 0;
+    nif = null;
+  }
+
+  /**
+   * Utility routine to check if the InetAddress is an IP multicast address
+   *
+   * @since 1.1
+   */
+  public boolean isMulticastAddress()
+  {
+    return ipaddress[0] == 0xFF;
+  }
+
+  /**
+   * Utility routine to check if the InetAddress in a wildcard address
+   *
+   * @since 1.4
+   */
+  public boolean isAnyLocalAddress()
+  {
+    byte[] anylocal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+    return Arrays.equals(ipaddress, anylocal);
+  }
+
+  /**
+   * Utility routine to check if the InetAddress is a loopback address
+   *
+   * @since 1.4
+   */
+  public boolean isLoopbackAddress()
+  {
+    byte[] loopback = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
+
+    return Arrays.equals(ipaddress, loopback);
+  }
+
+  /**
+   * Utility routine to check if the InetAddress is an link local address
+   *
+   * @since 1.4
+   */
+  public boolean isLinkLocalAddress()
+  {
+    return ipaddress[0] == 0xFA;
+  }
+
+  /**
+   * Utility routine to check if the InetAddress is a site local address
+   *
+   * @since 1.4
+   */
+  public boolean isSiteLocalAddress()
+  {
+    return ipaddress[0] == 0xFB;
+  }
+
+  /**
+   * Utility routine to check if the multicast address has global scope
+   *
+   * @since 1.4
+   */
+  public boolean isMCGlobal()
+  {
+    if (! isMulticastAddress())
+      return false;
+
+    return (ipaddress[1] & 0x0F) == 0xE;
+  }
+
+  /**
+   * Utility routine to check if the multicast address has node scope
+   *
+   * @since 1.4
+   */
+  public boolean isMCNodeLocal()
+  {
+    if (! isMulticastAddress())
+      return false;
+
+    return (ipaddress[1] & 0x0F) == 0x1;
+  }
+
+  /**
+   * Utility routine to check if the multicast address has link scope
+   *
+   * @since 1.4
+   */
+  public boolean isMCLinkLocal()
+  {
+    if (! isMulticastAddress())
+      return false;
+
+    return (ipaddress[1] & 0x0F) == 0x2;
+  }
+
+  /**
+   * Utility routine to check if the multicast address has site scope
+   *
+   * @since 1.4
+   */
+  public boolean isMCSiteLocal()
+  {
+    if (! isMulticastAddress())
+      return false;
+
+    return (ipaddress[1] & 0x0F) == 0x5;
+  }
+
+  /**
+   * Utility routine to check if the multicast address has organization scope
+   *
+   * @since 1.4
+   */
+  public boolean isMCOrgLocal()
+  {
+    if (! isMulticastAddress())
+      return false;
+
+    return (ipaddress[1] & 0x0F) == 0x8;
+  }
+
+  /**
+   * Returns the raw IP address of this InetAddress object. The result is in
+   * network byte order: the highest order byte of the address is i
+   * n getAddress()[0]
+   */
+  public byte[] getAddress()
+  {
+    return (byte[]) ipaddress.clone();
+  }
+
+  /**
+   * Creates a scoped Inet6Address where the scope has an integer id.
+   *
+   * @throws UnkownHostException if the address is an invalid number of bytes.
+   * @since 1.5
+   */  
+  public static Inet6Address getByAddress(String host, byte[] addr, 
+					  int scopeId)
+    throws UnknownHostException
+  {
+    if( addr.length != 16 )
+      throw new UnknownHostException("Illegal address length: " + addr.length
+				     + " bytes.");
+    Inet6Address ip = new Inet6Address( addr, host );
+    ip.scope_id = scopeId;
+    ip.scope_id_set = true;
+    return ip;
+  }
+
+  /**
+   * Creates a scoped Inet6Address where the scope is a given
+   * NetworkInterface.
+   *
+   * @throws UnkownHostException if the address is an invalid number of bytes.
+   * @since 1.5
+   */  
+  public static Inet6Address getByAddress(String host, byte[] addr, 
+					  NetworkInterface nif)
+    throws UnknownHostException
+  {
+    if( addr.length != 16 )
+      throw new UnknownHostException("Illegal address length: " + addr.length
+				     + " bytes.");
+    Inet6Address ip = new Inet6Address( addr, host );
+    ip.nif = nif;
+
+    return ip;
+  }
+
+  /**
+   * Returns the <code>NetworkInterface</code> of the address scope
+   * if it is a scoped address and the scope is given in the form of a
+   * NetworkInterface. 
+   * (I.e. the address was created using  the 
+   * getByAddress(String, byte[], NetworkInterface) method)
+   * Otherwise this method returns <code>null</code>.
+   * @since 1.5
+   */
+  public NetworkInterface getScopedInterface()
+  {
+    return nif;
+  }
+
+  /**
+   * Returns the scope ID of the address scope if it is a scoped adress using
+   * an integer to identify the scope.
+   *
+   * Otherwise this method returns 0.
+   * @since 1.5
+   */
+  public int getScopeId()
+  {
+    // check scope_id_set because some JDK-serialized objects seem to have
+    // scope_id set to a nonzero value even when scope_id_set == false
+    if( scope_id_set )
+      return scope_id; 
+    return 0;
+  }
+
+  /**
+   * Returns the IP address string in textual presentation
+   */
+  public String getHostAddress()
+  {
+    StringBuffer sbuf = new StringBuffer(40);
+
+    for (int i = 0; i < 16; i += 2)
+      {
+	int x = ((ipaddress[i] & 0xFF) << 8) | (ipaddress[i + 1] & 0xFF);
+
+	if (i > 0)
+	  sbuf.append(':');
+
+	sbuf.append(Integer.toHexString(x));
+      }
+    if( nif != null )
+      sbuf.append( "%" + nif.getName() );
+    else if( scope_id_set )
+      sbuf.append( "%" + scope_id );
+
+    return sbuf.toString();
+  }
+
+  /**
+   * Returns a hashcode for this IP address
+   * (The hashcode is independent of scope)
+   */
+  public int hashCode()
+  {
+    return super.hashCode();
+  }
+
+  /**
+   * Compares this object against the specified object
+   */
+  public boolean equals(Object obj)
+  {
+    if (! (obj instanceof Inet6Address))
+      return false;
+
+    Inet6Address ip = (Inet6Address)obj;
+    if (ipaddress.length != ip.ipaddress.length)
+      return false;
+
+    for (int i = 0; i < ip.ipaddress.length; i++)
+      if (ipaddress[i] != ip.ipaddress[i])
+	return false;
+
+    if( ip.nif != null && nif != null )
+      return nif.equals( ip.nif );
+    if( ip.nif != nif )
+      return false;
+    if( ip.scope_id_set != scope_id_set )
+      return false;
+    if( scope_id_set )
+      return (scope_id == ip.scope_id);
+    return true;
+  }
+
+  /**
+   * Utility routine to check if the InetAddress is an
+   * IPv4 compatible IPv6 address
+   *
+   * @since 1.4
+   */
+  public boolean isIPv4CompatibleAddress()
+  {
+    if (ipaddress[0] != 0x00 || ipaddress[1] != 0x00 || ipaddress[2] != 0x00
+        || ipaddress[3] != 0x00 || ipaddress[4] != 0x00
+        || ipaddress[5] != 0x00 || ipaddress[6] != 0x00
+        || ipaddress[7] != 0x00 || ipaddress[8] != 0x00
+        || ipaddress[9] != 0x00 || ipaddress[10] != 0x00
+        || ipaddress[11] != 0x00)
+      return false;
+
+    return true;
+  }
+
+  /**
+   * Required for 1.5-compatible serialization.
+   * @since 1.5
+   */
+  private void readObject(ObjectInputStream s)
+    throws IOException, ClassNotFoundException
+  {  
+    s.defaultReadObject();
+    try
+      {
+	if( scope_ifname_set )
+	  nif = NetworkInterface.getByName( ifname );
+      }
+    catch( SocketException se )
+      {
+	// FIXME: Ignore this? or throw an IOException?
+      }
+  }
+
+  /**
+   * Required for 1.5-compatible serialization.
+   * @since 1.5
+   */
+  private void writeObject(ObjectOutputStream s)
+    throws IOException
+  {
+    if( nif != null )
+      {
+	ifname = nif.getName();
+	scope_ifname_set = true;
+      }
+    s.defaultWriteObject();
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/InetAddress.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/InetAddress.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,655 @@
+/* InetAddress.java -- Class to model an Internet address
+   Copyright (C) 1998, 1999, 2002, 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.net;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+
+/**
+ * This class models an Internet address.  It does not have a public
+ * constructor.  Instead, new instances of this objects are created
+ * using the static methods getLocalHost(), getByName(), and
+ * getAllByName().
+ *
+ * <p>This class fulfills the function of the C style functions gethostname(),
+ * gethostbyname(), and gethostbyaddr().  It resolves Internet DNS names
+ * into their corresponding numeric addresses and vice versa.</p>
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Per Bothner
+ * @author Gary Benson (gbenson at redhat.com)
+ *
+ * @specnote This class is not final since JK 1.4
+ */
+public class InetAddress implements Serializable
+{
+  private static final long serialVersionUID = 3286316764910316507L;
+
+  /**
+   * Dummy InetAddress, used to bind socket to any (all) network interfaces.
+   */
+  static InetAddress ANY_IF;
+  static
+  {
+    byte[] addr;
+    try
+      {
+	addr = VMInetAddress.lookupInaddrAny();
+      }
+    catch (UnknownHostException e)
+      {
+	// Make one up and hope it works.
+	addr = new byte[] {0, 0, 0, 0};
+      }
+    try
+      {
+	ANY_IF = getByAddress(addr);
+      }
+    catch (UnknownHostException e)
+      {
+	throw new RuntimeException("should never happen", e);
+      }
+    ANY_IF.hostName = ANY_IF.getHostName();
+  }
+  
+  /**
+   * Stores static localhost address object.
+   */
+  static InetAddress LOCALHOST;
+  static
+  {
+    try
+      {
+	LOCALHOST = getByAddress("localhost", new byte[] {127, 0, 0, 1});
+      }
+    catch (UnknownHostException e)
+      {
+	throw new RuntimeException("should never happen", e);
+      }
+  }    
+
+  /**
+   * The Serialized Form specifies that an int 'address' is saved/restored.
+   * This class uses a byte array internally so we'll just do the conversion
+   * at serialization time and leave the rest of the algorithm as is.
+   */
+  private int address;
+
+  /**
+   * An array of octets representing an IP address.
+   */
+  transient byte[] addr;
+
+  /**
+   * The name of the host for this address.
+   */
+  String hostName;
+
+  /**
+   * Needed for serialization.
+   */
+  private int family;
+
+  /**
+   * Constructor.  Prior to the introduction of IPv6 support in 1.4,
+   * methods such as InetAddress.getByName() would return InetAddress
+   * objects.  From 1.4 such methods returned either Inet4Address or
+   * Inet6Address objects, but for compatibility Inet4Address objects
+   * are serialized as InetAddresses.  As such, there are only two
+   * places where it is appropriate to invoke this constructor: within
+   * subclasses constructors and within Inet4Address.writeReplace().
+   *
+   * @param ipaddr The IP number of this address as an array of bytes
+   * @param hostname The hostname of this IP address.
+   * @param family The address family of this IP address.
+   */
+  InetAddress(byte[] ipaddr, String hostname, int family)
+  {
+    addr = (null == ipaddr) ? null : (byte[]) ipaddr.clone();
+    hostName = hostname;
+    this.family = family;
+  }
+
+  /**
+   * Returns true if this address is a multicast address, false otherwise.
+   * An address is multicast if the high four bits are "1110".  These are
+   * also known as "Class D" addresses.
+   *
+   * <p>This method cannot be abstract for backward compatibility reasons. By
+   * default it always throws {@link UnsupportedOperationException} unless
+   * overridden.</p>
+   * 
+   * @return true if mulitcast, false if not
+   *
+   * @since 1.1
+   */
+  public boolean isMulticastAddress()
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Utility routine to check if the InetAddress in a wildcard address
+   *
+   * <p>This method cannot be abstract for backward compatibility reasons. By
+   * default it always throws {@link UnsupportedOperationException} unless
+   * overridden.</p>
+   * 
+   * @since 1.4
+   */
+  public boolean isAnyLocalAddress()
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Utility routine to check if the InetAddress is a loopback address
+   *
+   * <p>This method cannot be abstract for backward compatibility reasons. By
+   * default it always throws {@link UnsupportedOperationException} unless
+   * overridden.</p>
+   * 
+   * @since 1.4
+   */
+  public boolean isLoopbackAddress()
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Utility routine to check if InetAddress is a link local address
+   *
+   * <p>This method cannot be abstract for backward compatibility reasons. By
+   * default it always throws {@link UnsupportedOperationException} unless
+   * overridden.</p>
+   * 
+   * @since 1.4
+   */
+  public boolean isLinkLocalAddress()
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Utility routine to check if InetAddress is a site local address
+   *
+   * <p>This method cannot be abstract for backward compatibility reasons. By
+   * default it always throws {@link UnsupportedOperationException} unless
+   * overridden.</p>
+   * 
+   * @since 1.4
+   */
+  public boolean isSiteLocalAddress()
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Utility routine to check if InetAddress is a global multicast address
+   *
+   * <p>This method cannot be abstract for backward compatibility reasons. By
+   * default it always throws {@link UnsupportedOperationException} unless
+   * overridden.</p>
+   * 
+   * @since 1.4
+   */
+  public boolean isMCGlobal()
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Utility routine to check if InetAddress is a node local multicast address.
+   *
+   * <p>This method cannot be abstract for backward compatibility reasons. By
+   * default it always throws {@link UnsupportedOperationException} unless
+   * overridden.</p>
+   * 
+   * @since 1.4
+   */
+  public boolean isMCNodeLocal()
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Utility routine to check if InetAddress is a link local multicast address.
+   *
+   * <p>This method cannot be abstract for backward compatibility reasons. By
+   * default it always throws {@link UnsupportedOperationException} unless
+   * overridden.</p>
+   * 
+   * @since 1.4
+   */
+  public boolean isMCLinkLocal()
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Utility routine to check if InetAddress is a site local multicast address.
+   *
+   * <p>This method cannot be abstract for backward compatibility reasons. By
+   * default it always throws {@link UnsupportedOperationException} unless
+   * overridden.</p>
+   * 
+   * @since 1.4
+   */
+  public boolean isMCSiteLocal()
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Utility routine to check if InetAddress is a organization local
+   * multicast address.
+   *
+   * <p>This method cannot be abstract for backward compatibility reasons. By
+   * default it always throws {@link UnsupportedOperationException} unless
+   * overridden.</p>
+   * 
+   * @since 1.4
+   */
+  public boolean isMCOrgLocal()
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Returns the hostname for this address.  This will return the IP address
+   * as a String if there is no hostname available for this address
+   *
+   * @return The hostname for this address
+   */
+  public String getHostName()
+  {
+    if (hostName == null)
+      hostName = getCanonicalHostName();
+
+    return hostName;
+  }
+
+  /**
+   * Returns the canonical hostname represented by this InetAddress
+   */
+  String internalGetCanonicalHostName()
+  {
+    try
+      {
+	return ResolverCache.getHostByAddr(addr);
+      }
+    catch (UnknownHostException e)
+      {
+	return getHostAddress();
+      }
+  }
+
+  /**
+   * Returns the canonical hostname represented by this InetAddress
+   * 
+   * @since 1.4
+   */
+  public String getCanonicalHostName()
+  {
+    String hostname = internalGetCanonicalHostName();
+
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      {
+        try
+	  {
+            sm.checkConnect(hostname, -1);
+	  }
+	catch (SecurityException e)
+	  {
+	    return getHostAddress();
+	  }
+      }
+
+    return hostname;
+  }
+
+  /**
+   * Returns the IP address of this object as a byte array.
+   *
+   * @return IP address
+   */
+  public byte[] getAddress()
+  {
+    // An experiment shows that JDK1.2 returns a different byte array each
+    // time.  This makes sense, in terms of security.
+    return (byte[]) addr.clone();
+  }
+
+  /**
+   * Returns the IP address of this object as a String.
+   *
+   * <p>This method cannot be abstract for backward compatibility reasons. By
+   * default it always throws {@link UnsupportedOperationException} unless
+   * overridden.</p>
+   * 
+   * @return The IP address of this object in String form
+   *
+   * @since 1.0.2
+   */
+  public String getHostAddress()
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Returns a hash value for this address.  Useful for creating hash
+   * tables.  Overrides Object.hashCode()
+   *
+   * @return A hash value for this address.
+   */
+  public int hashCode()
+  {
+    // There hashing algorithm is not specified, but a simple experiment
+    // shows that it is equal to the address, as a 32-bit big-endian integer.
+    int hash = 0;
+    int len = addr.length;
+    int i = len > 4 ? len - 4 : 0;
+
+    for (; i < len; i++)
+      hash = (hash << 8) | (addr[i] & 0xff);
+
+    return hash;
+  }
+
+  /**
+   * Tests this address for equality against another InetAddress.  The two
+   * addresses are considered equal if they contain the exact same octets.
+   * This implementation overrides Object.equals()
+   *
+   * @param obj The address to test for equality
+   *
+   * @return true if the passed in object's address is equal to this one's,
+   * false otherwise
+   */
+  public boolean equals(Object obj)
+  {
+    if (! (obj instanceof InetAddress))
+      return false;
+
+    // "The Java Class Libraries" 2nd edition says "If a machine has
+    // multiple names instances of InetAddress for different name of
+    // that same machine are not equal.  This is because they have
+    // different host names."  This violates the description in the
+    // JDK 1.2 API documentation.  A little experimentation
+    // shows that the latter is correct.
+    byte[] addr2 = ((InetAddress) obj).addr;
+
+    if (addr.length != addr2.length)
+      return false;
+
+    for (int i = 0; i < addr.length; i++)
+      if (addr[i] != addr2[i])
+	return false;
+
+    return true;
+  }
+
+  /**
+   * Converts this address to a String.  This string contains the IP in
+   * dotted decimal form. For example: "127.0.0.1"  This method is equivalent
+   * to getHostAddress() and overrides Object.toString()
+   *
+   * @return This address in String form
+   */
+  public String toString()
+  {
+    String addr = getHostAddress();
+    String host = (hostName != null) ? hostName : "";
+    return host + "/" + addr;
+  }
+
+  /**
+   * Returns an InetAddress object given the raw IP address.
+   *
+   * The argument is in network byte order: the highest order byte of the
+   * address is in getAddress()[0].
+   *
+   * @param addr The IP address to create the InetAddress object from
+   *
+   * @exception UnknownHostException If IP address has illegal length
+   *
+   * @since 1.4
+   */
+  public static InetAddress getByAddress(byte[] addr)
+    throws UnknownHostException
+  {
+    return getByAddress(null, addr);
+  }
+
+  /**
+   * Creates an InetAddress based on the provided host name and IP address.
+   * No name service is checked for the validity of the address.
+   *
+   * @param host The hostname of the InetAddress object to create
+   * @param addr The IP address to create the InetAddress object from
+   *
+   * @exception UnknownHostException If IP address is of illegal length
+   *
+   * @since 1.4
+   */
+  public static InetAddress getByAddress(String host, byte[] addr)
+    throws UnknownHostException
+  {
+    if (addr.length == 4)
+      return new Inet4Address(addr, host);
+
+    if (addr.length == 16)
+      {
+	for (int i = 0; i < 12; i++)
+	  {
+	    if (addr[i] != (i < 10 ? 0 : (byte) 0xFF))
+	      return new Inet6Address(addr, host);
+	  }
+	  
+	byte[] ip4addr = new byte[4];
+	ip4addr[0] = addr[12];
+	ip4addr[1] = addr[13];
+	ip4addr[2] = addr[14];
+	ip4addr[3] = addr[15];
+	return new Inet4Address(ip4addr, host);
+      }
+
+    throw new UnknownHostException("IP address has illegal length");
+  }
+
+  /**
+   * Returns an InetAddress object representing the IP address of
+   * the given literal IP address in dotted decimal format such as
+   * "127.0.0.1".  This is used by SocketPermission.setHostPort()
+   * to parse literal IP addresses without performing a DNS lookup.
+   *
+   * @param literal The literal IP address to create the InetAddress
+   * object from
+   *
+   * @return The address of the host as an InetAddress object, or
+   * null if the IP address is invalid.
+   */
+  static InetAddress getByLiteral(String literal)
+  {
+    byte[] address = VMInetAddress.aton(literal);
+    if (address == null)
+      return null;
+    
+    try
+      {
+	return getByAddress(address);
+      }
+    catch (UnknownHostException e)
+      {
+	throw new RuntimeException("should never happen", e);
+      }
+  }
+
+  /**
+   * Returns an InetAddress object representing the IP address of the given
+   * hostname.  This name can be either a hostname such as "www.urbanophile.com"
+   * or an IP address in dotted decimal format such as "127.0.0.1".  If the
+   * hostname is null or "", the hostname of the local machine is supplied by
+   * default.  This method is equivalent to returning the first element in
+   * the InetAddress array returned from GetAllByName.
+   *
+   * @param hostname The name of the desired host, or null for the local 
+   * loopback address.
+   *
+   * @return The address of the host as an InetAddress object.
+   *
+   * @exception UnknownHostException If no IP address for the host could
+   * be found
+   * @exception SecurityException If a security manager exists and its
+   * checkConnect method doesn't allow the operation
+   */
+  public static InetAddress getByName(String hostname)
+    throws UnknownHostException
+  {
+    InetAddress[] addresses = getAllByName(hostname);
+    return addresses[0];
+  }
+
+  /**
+   * Returns an array of InetAddress objects representing all the host/ip
+   * addresses of a given host, given the host's name.  This name can be
+   * either a hostname such as "www.urbanophile.com" or an IP address in
+   * dotted decimal format such as "127.0.0.1".  If the value is null, the
+   * hostname of the local machine is supplied by default.
+   *
+   * @param hostname The name of the desired host, or null for the
+   * local loopback address.
+   *
+   * @return All addresses of the host as an array of InetAddress objects.
+   *
+   * @exception UnknownHostException If no IP address for the host could
+   * be found
+   * @exception SecurityException If a security manager exists and its
+   * checkConnect method doesn't allow the operation
+   */
+  public static InetAddress[] getAllByName(String hostname)
+    throws UnknownHostException
+  {
+    // If null or the empty string is supplied, the loopback address
+    // is returned.
+    if (hostname == null || hostname.length() == 0)
+      return new InetAddress[] {LOCALHOST};
+
+    // Check if hostname is an IP address
+    InetAddress address = getByLiteral(hostname);
+    if (address != null)
+      return new InetAddress[] {address};
+
+    // Perform security check before resolving
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkConnect(hostname, -1);
+
+    // Resolve the hostname
+    byte[][] iplist = ResolverCache.getHostByName(hostname);
+    if (iplist.length == 0)
+      throw new UnknownHostException(hostname);
+
+    InetAddress[] addresses = new InetAddress[iplist.length];
+    for (int i = 0; i < iplist.length; i++)
+      addresses[i] = getByAddress(hostname, iplist[i]);
+
+    return addresses;
+  }
+
+  /**
+   * Returns an InetAddress object representing the address of the current
+   * host.
+   *
+   * @return The local host's address
+   *
+   * @exception UnknownHostException If no IP address for the host could
+   * be found
+   */
+  public static InetAddress getLocalHost() throws UnknownHostException
+  {
+    String hostname = VMInetAddress.getLocalHostname();
+    try
+      {
+	return getByName(hostname);
+      }
+    catch (SecurityException e)
+      {
+	return LOCALHOST;
+      }
+  }
+
+  /**
+   * Inet4Address objects are serialized as InetAddress objects.
+   * This deserializes them back into Inet4Address objects.
+   */
+  private Object readResolve() throws ObjectStreamException
+  {
+    return new Inet4Address(addr, hostName);
+  }
+
+  private void readObject(ObjectInputStream ois)
+    throws IOException, ClassNotFoundException
+  {
+    ois.defaultReadObject();
+    addr = new byte[4];
+    addr[3] = (byte) address;
+
+    for (int i = 2; i >= 0; --i)
+      addr[i] = (byte) (address >>= 8);
+  }
+
+  private void writeObject(ObjectOutputStream oos) throws IOException
+  {
+    // Build a 32 bit address from the last 4 bytes of a 4 byte IPv4 address
+    // or a 16 byte IPv6 address.
+    int len = addr.length;
+    int i = len - 4;
+
+    for (; i < len; i++)
+      address = address << 8 | (addr[i] & 0xff);
+
+    oos.defaultWriteObject();
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/InetSocketAddress.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/InetSocketAddress.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,261 @@
+/* InetSocketAddress.java --
+   Copyright (C) 2002, 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.net;
+
+
+/**
+ * InetSocketAddress instances represent socket addresses
+ * in the java.nio package. They encapsulate a InetAddress and
+ * a port number.
+ *
+ * @since 1.4
+ */
+public class InetSocketAddress extends SocketAddress
+{
+  /**
+   * Compatible with JDK 1.4+
+   */
+  private static final long serialVersionUID = 5076001401234631237L;
+
+  /**
+   * Name of host.
+   */
+  private String hostname;
+
+  /**
+   * Address of host.
+   */
+  private InetAddress addr;
+
+  /**
+   * Port of host.
+   */
+  private int port;
+
+  /**
+   * Constructs an InetSocketAddress instance.
+   *
+   * @param addr Address of the socket
+   * @param port Port if the socket
+   *
+   * @exception IllegalArgumentException If the port number is illegel
+   */
+  public InetSocketAddress(InetAddress addr, int port)
+    throws IllegalArgumentException
+  {
+    if (port < 0 || port > 65535)
+      throw new IllegalArgumentException("Bad port number: " + port);
+
+    if (addr == null)
+      addr = InetAddress.ANY_IF;
+
+    this.addr = addr;
+    this.port = port;
+  }
+
+  /**
+   * Constructs an InetSocketAddress instance.
+   *
+   * @param port Port if the socket
+   *
+   * @exception IllegalArgumentException If the port number is illegal
+   */
+  public InetSocketAddress(int port) throws IllegalArgumentException
+  {
+    this((InetAddress) null, port);
+  }
+
+  /**
+   * Constructs an InetSocketAddress instance.
+   *
+   * @param hostname The hostname for the socket address
+   * @param port The port for the socket address
+   *
+   * @exception IllegalArgumentException If the port number is illegal or
+   * the hostname argument is null
+   */
+  public InetSocketAddress(String hostname, int port)
+  {
+    this(hostname, port, true);
+  }
+
+  /**
+   * Constructs an InetSocketAddress instance.
+   *
+   * @param hostname The hostname for the socket address
+   * @param port The port for the socket address
+   * @param resolve <code>true</code> if the address has to be resolved,
+   * <code>false</code> otherwise
+   *
+   * @exception IllegalArgumentException If the port number is illegal or
+   * the hostname argument is null
+   */
+  private InetSocketAddress(String hostname, int port, boolean resolve)
+  {
+    if (hostname == null)
+      throw new IllegalArgumentException("Null host name value");
+
+    if (port < 0 || port > 65535)
+      throw new IllegalArgumentException("Bad port number: " + port);
+
+    this.port = port;
+    this.hostname = hostname;
+    this.addr = null;
+
+    if (resolve)
+    {
+      try
+        {
+          this.addr = InetAddress.getByName(hostname);
+        }
+      catch (Exception e) // UnknownHostException, SecurityException
+        {
+          // Do nothing here. this.addr is already set to null.
+        }
+    }
+
+  }
+
+  /**
+   * Creates an unresolved <code>InetSocketAddress</code> object.
+   *
+   * @param hostname The hostname for the socket address
+   * @param port The port for the socket address
+   *
+   * @exception IllegalArgumentException If the port number is illegal or
+   * the hostname argument is null
+   *
+   * @since 1.5
+   */
+  public static InetSocketAddress createUnresolved(String hostname, int port)
+  {
+    return new InetSocketAddress(hostname, port, false);
+  }
+
+  /**
+   * Test if obj is a <code>InetSocketAddress</code> and
+   * has the same address and port
+   *
+   * @param obj The obj to compare this address with.
+   *
+   * @return True if obj is equal.
+   */
+  public final boolean equals(Object obj)
+  {
+    // InetSocketAddress objects are equal when addr and port are equal.
+    // The hostname may differ.
+    if (obj instanceof InetSocketAddress)
+      {
+	InetSocketAddress sa = (InetSocketAddress) obj;
+
+	if (addr == null && sa.addr != null)
+	  return false;
+	else if (addr == null && sa.addr == null) // we know hostname != null
+	  return hostname.equals(sa.hostname) && sa.port == port;
+	else
+	  return addr.equals(sa.addr) && sa.port == port;
+      }
+
+    return false;
+  }
+
+  /**
+   * Returns the <code>InetAddress</code> or
+   * <code>null</code> if its unresolved
+   *
+   * @return The IP address of this address.
+   */
+  public final InetAddress getAddress()
+  {
+    return addr;
+  }
+
+  /**
+   * Returns <code>hostname</code>
+   *
+   * @return The hostname of this address.
+   */
+  public final String getHostName()
+  {
+    if (hostname == null) // we know addr != null
+      hostname = addr.getHostName();
+
+    return hostname;
+  }
+
+  /**
+   * Returns the <code>port</code>
+   *
+   * @return The port of this address.
+   */
+  public final int getPort()
+  {
+    return port;
+  }
+
+  /**
+   * Returns the hashcode of the <code>InetSocketAddress</code>
+   *
+   * @return The hashcode for this address.
+   */
+  public final int hashCode()
+  {
+    return port + addr.hashCode();
+  }
+
+  /**
+   * Checks wether the address has been resolved or not
+   *
+   * @return True if address is unresolved.
+   */
+  public final boolean isUnresolved()
+  {
+    return addr == null;
+  }
+
+  /**
+   * Returns the <code>InetSocketAddress</code> as string
+   *
+   * @return A string representation of this address.
+   */
+  public String toString()
+  {
+    // Note: if addr is null, then hostname != null.
+    return (addr == null ? hostname : addr.toString()) + ":" + port;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/JarURLConnection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/JarURLConnection.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,229 @@
+/* JarURLConnection.java -- Class for manipulating remote jar files
+   Copyright (C) 1998, 2002, 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.net;
+
+import java.io.IOException;
+import java.security.cert.Certificate;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+
+/**
+ * This abstract class represents a common superclass for implementations
+ * of jar URL's.  A jar URL is a special type of URL that allows JAR
+ * files on remote systems to be accessed.  It has the form:
+ * <p>
+ * jar:<standard URL pointing to jar filei>!/file/within/jarfile
+ * <p> for example:
+ * <p>
+ * jar:http://www.urbanophile.com/java/foo.jar!/com/urbanophile/bar.class
+ * <p>
+ * That example URL points to the file /com/urbanophile/bar.class in the
+ * remote JAR file http://www.urbanophile.com/java/foo.jar.  The HTTP
+ * protocol is used only as an example.  Any supported remote protocol
+ * can be used.
+ * <p>
+ * This class currently works by retrieving the entire jar file into a
+ * local cache file, then performing standard jar operations on it.
+ * (At least this is true for the default protocol implementation).
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Kresten Krab Thorup (krab at gnu.org)
+ * @date Aug 10, 1999.
+ *
+ * @since 1.2
+ */
+public abstract class JarURLConnection extends URLConnection
+{
+  /**
+   * This is the actual URL that points the remote jar file.  This is parsed
+   * out of the jar URL by the constructor.
+   */
+  private final URL jarFileURL;
+
+  /**
+   * The connection to the jar file itself. A JarURLConnection
+   * can represent an entry in a jar file or an entire jar file.  In
+   * either case this describes just the jar file itself.
+   */
+  protected URLConnection jarFileURLConnection;
+
+  /**
+   * This is the jar file "entry name" or portion after the "!/" in the
+   * URL which represents the pathname inside the actual jar file.
+   */
+  private final String entryName;
+
+  /**
+   * Creates a JarURLConnection from an URL object
+   *
+   * @param url The URL object for this connection.
+   *
+   * @exception MalformedURLException If url is invalid
+   *
+   * @specnote This constructor is protected since JDK 1.4
+   */
+  protected JarURLConnection(URL url) throws MalformedURLException
+  {
+    super(url);
+
+    if (! url.getProtocol().equals("jar"))
+      throw new MalformedURLException(url + ": Not jar protocol.");
+
+    String spec = url.getFile();
+    int bang = spec.indexOf("!/");
+    if (bang == -1)
+      throw new MalformedURLException(url + ": No `!/' in spec.");
+
+    // Extract the url for the jar itself.
+    jarFileURL = new URL(spec.substring(0, bang));
+
+    // Get the name of the entry, if any.
+    entryName = spec.length() == (bang + 2) ? null : spec.substring(bang + 2);
+  }
+
+  /**
+   * This method returns the "real" URL where the JarFile is located.
+   * //****Is this right?*****
+   *
+   * @return The remote URL
+   */
+  public URL getJarFileURL()
+  {
+    return jarFileURL;
+  }
+
+  /**
+   * Returns the "entry name" portion of the jar URL.  This is the portion
+   * after the "!/" in the jar URL that represents the pathname inside the
+   * actual jar file.
+   *
+   * @return The entry name.
+   */
+  public String getEntryName()
+  {
+    return entryName;
+  }
+
+  /**
+   * Returns the entry in this jar file specified by the URL.
+   *
+   * @return The jar entry
+   *
+   * @exception IOException If an error occurs
+   */
+  public JarEntry getJarEntry() throws IOException
+  {
+    if (entryName == null)
+      return null;
+    JarFile jarFile = getJarFile();
+    return jarFile != null ? jarFile.getJarEntry(entryName) : null;
+  }
+
+  /**
+   * Returns a read-only JarFile object for the remote jar file
+   *
+   * @return The JarFile object
+   *
+   * @exception IOException If an error occurs
+   */
+  public abstract JarFile getJarFile() throws IOException;
+
+  /**
+   * Returns an array of Certificate objects for the jar file entry specified
+   * by this URL or null if there are none
+   *
+   * @return A Certificate array
+   *
+   * @exception IOException If an error occurs
+   */
+  public Certificate[] getCertificates() throws IOException
+  {
+    JarEntry entry = getJarEntry();
+
+    return entry != null ? entry.getCertificates() : null;
+  }
+
+  /**
+   * Returns the main Attributes for the jar file specified in the URL or
+   * null if there are none
+   *
+   * @return The main Attributes for the JAR file for this connection
+   *
+   * @exception IOException If an error occurs
+   */
+  public Attributes getMainAttributes() throws IOException
+  {
+    Manifest manifest = getManifest();
+
+    return manifest != null ? manifest.getMainAttributes() : null;
+  }
+
+  /**
+   * Returns the Attributes for the Jar entry specified by the URL or null
+   * if none
+   *
+   * @return The Attributes object for this connection if the URL for it points
+   * to a JAR file entry, null otherwise
+   *
+   * @exception IOException If an error occurs
+   */
+  public Attributes getAttributes() throws IOException
+  {
+    JarEntry entry = getJarEntry();
+
+    return entry != null ? entry.getAttributes() : null;
+  }
+
+  /**
+   * Returns a Manifest object for this jar file, or null if there is no
+   * manifest.
+   *
+   * @return The Manifest for this connection, or null if none
+   *
+   * @exception IOException If an error occurs
+   */
+  public Manifest getManifest() throws IOException
+  {
+    JarFile file = getJarFile();
+
+    return file != null ? file.getManifest() : null;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/MalformedURLException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/MalformedURLException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* MalformedURLException.java -- A URL was not in a valid format
+   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.net;
+
+import java.io.IOException;
+
+
+/**
+ * This exception indicates that a URL passed to an object was not in a
+ * valid format.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class MalformedURLException extends IOException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -182787522200415866L;
+
+  /**
+   * Create a new instance without a descriptive error message.
+   */
+  public MalformedURLException()
+  {
+  }
+
+  /**
+   * Create a new instance with a descriptive error message.
+   *
+   * @param message a message describing the error that occurred
+   */
+  public MalformedURLException(String message)
+  {
+    super(message);
+  }
+} // class MalformedURLException

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/MimeTypeMapper.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/MimeTypeMapper.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,345 @@
+/* MimeTypeMapper.java -- A class for mapping file names to MIME types
+   Copyright (C) 1998 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.net;
+
+import gnu.classpath.SystemProperties;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.LineNumberReader;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+
+
+/**
+ * This non-public class is used to implement the FileNameMap interface
+ * which defines a mechanism for mapping filenames to MIME types.
+ *
+ * @version 0.5
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+class MimeTypeMapper implements FileNameMap
+{
+  /**
+   * This array of strings is used to identify a MIME type based on a file
+   * extension.  This is list is based on the Apache mime.types file.
+   */
+  protected static final String[][] mime_strings =
+    {
+       { "ai", "application/postscript" }
+     , { "aif", "audio/x-aiff" }
+     , { "aifc", "audio/x-aiff" }
+     , { "aiff", "audio/x-aiff" }
+     , { "asc", "text/plain" }
+     , { "au", "audio/basic" }
+     , { "avi", "video/x-msvideo" }
+     , { "bcpio", "application/x-bcpio" }
+     , { "bin", "application/octet-stream" }
+     , { "bmp", "image/bmp" }
+     , { "bz2", "application/x-bzip2" }
+     , { "cdf", "application/x-netcdf" }
+     , { "chrt", "application/x-kchart" }
+     , { "class", "application/octet-stream" }
+     , { "cpio", "application/x-cpio" }
+     , { "cpt", "application/mac-compactpro" }
+     , { "csh", "application/x-csh" }
+     , { "css", "text/css" }
+     , { "dcr", "application/x-director" }
+     , { "dir", "application/x-director" }
+     , { "djv", "image/vnd.djvu" }
+     , { "djvu", "image/vnd.djvu" }
+     , { "dll", "application/octet-stream" }
+     , { "dms", "application/octet-stream" }
+     , { "doc", "application/msword" }
+     , { "dvi", "application/x-dvi" }
+     , { "dxr", "application/x-director" }
+     , { "eps", "application/postscript" }
+     , { "etx", "text/x-setext" }
+     , { "exe", "application/octet-stream" }
+     , { "ez", "application/andrew-inset" }
+     , { "gif", "image/gif" }
+     , { "gtar", "application/x-gtar" }
+     , { "gz", "application/x-gzip" }
+     , { "hdf", "application/x-hdf" }
+     , { "hqx", "application/mac-binhex40" }
+     , { "htm", "text/html" }
+     , { "html", "text/html" }
+     , { "ice", "x-conference/x-cooltalk" }
+     , { "ief", "image/ief" }
+     , { "iges", "model/iges" }
+     , { "igs", "model/iges" }
+     , { "img", "application/octet-stream" }
+     , { "iso", "application/octet-stream" }
+     , { "jpe", "image/jpeg" }
+     , { "jpeg", "image/jpeg" }
+     , { "jpg", "image/jpeg" }
+     , { "js", "application/x-javascript" }
+     , { "kar", "audio/midi" }
+     , { "kil", "application/x-killustrator" }
+     , { "kpr", "application/x-kpresenter" }
+     , { "kpt", "application/x-kpresenter" }
+     , { "ksp", "application/x-kspread" }
+     , { "kwd", "application/x-kword" }
+     , { "kwt", "application/x-kword" }
+     , { "latex", "application/x-latex" }
+     , { "lha", "application/octet-stream" }
+     , { "lzh", "application/octet-stream" }
+     , { "m3u", "audio/x-mpegurl" }
+     , { "man", "application/x-troff-man" }
+     , { "me", "application/x-troff-me" }
+     , { "mesh", "model/mesh" }
+     , { "mid", "audio/midi" }
+     , { "midi", "audio/midi" }
+     , { "mif", "application/vnd.mif" }
+     , { "mov", "video/quicktime" }
+     , { "movie", "video/x-sgi-movie" }
+     , { "mp2", "audio/mpeg" }
+     , { "mp3", "audio/mpeg" }
+     , { "mpe", "video/mpeg" }
+     , { "mpeg", "video/mpeg" }
+     , { "mpg", "video/mpeg" }
+     , { "mpga", "audio/mpeg" }
+     , { "ms", "application/x-troff-ms" }
+     , { "msh", "model/mesh" }
+     , { "mxu", "video/vnd.mpegurl" }
+     , { "nc", "application/x-netcdf" }
+     , { "ogg", "application/ogg" }
+     , { "pbm", "image/x-portable-bitmap" }
+     , { "pdb", "chemical/x-pdb" }
+     , { "pdf", "application/pdf" }
+     , { "pgm", "image/x-portable-graymap" }
+     , { "pgn", "application/x-chess-pgn" }
+     , { "png", "image/png" }
+     , { "pnm", "image/x-portable-anymap" }
+     , { "ppm", "image/x-portable-pixmap" }
+     , { "ppt", "application/vnd.ms-powerpoint" }
+     , { "ps", "application/postscript" }
+     , { "qt", "video/quicktime" }
+     , { "ra", "audio/x-realaudio" }
+     , { "ram", "audio/x-pn-realaudio" }
+     , { "ras", "image/x-cmu-raster" }
+     , { "rgb", "image/x-rgb" }
+     , { "rm", "audio/x-pn-realaudio" }
+     , { "roff", "application/x-troff" }
+     , { "rpm", "application/x-rpm" }
+     , { "rtf", "text/rtf" }
+     , { "rtx", "text/richtext" }
+     , { "sgm", "text/sgml" }
+     , { "sgml", "text/sgml" }
+     , { "sh", "application/x-sh" }
+     , { "shar", "application/x-shar" }
+     , { "silo", "model/mesh" }
+     , { "sit", "application/x-stuffit" }
+     , { "skd", "application/x-koan" }
+     , { "skm", "application/x-koan" }
+     , { "skp", "application/x-koan" }
+     , { "skt", "application/x-koan" }
+     , { "smi", "application/smil" }
+     , { "smil", "application/smil" }
+     , { "snd", "audio/basic" }
+     , { "so", "application/octet-stream" }
+     , { "spl", "application/x-futuresplash" }
+     , { "src", "application/x-wais-source" }
+     , { "stc", "application/vnd.sun.xml.calc.template" }
+     , { "std", "application/vnd.sun.xml.draw.template" }
+     , { "sti", "application/vnd.sun.xml.impress.template" }
+     , { "stw", "application/vnd.sun.xml.writer.template" }
+     , { "sv4cpio", "application/x-sv4cpio" }
+     , { "sv4crc", "application/x-sv4crc" }
+     , { "swf", "application/x-shockwave-flash" }
+     , { "sxc", "application/vnd.sun.xml.calc" }
+     , { "sxd", "application/vnd.sun.xml.draw" }
+     , { "sxg", "application/vnd.sun.xml.writer.global" }
+     , { "sxi", "application/vnd.sun.xml.impress" }
+     , { "sxm", "application/vnd.sun.xml.math" }
+     , { "sxw", "application/vnd.sun.xml.writer" }
+     , { "t", "application/x-troff" }
+     , { "tar", "application/x-tar" }
+     , { "tcl", "application/x-tcl" }
+     , { "tex", "application/x-tex" }
+     , { "texi", "application/x-texinfo" }
+     , { "texinfo", "application/x-texinfo" }
+     , { "tgz", "application/x-gzip" }
+     , { "tif", "image/tiff" }
+     , { "tiff", "image/tiff" }
+     , { "torrent", "application/x-bittorrent" }
+     , { "tr", "application/x-troff" }
+     , { "tsv", "text/tab-separated-values" }
+     , { "txt", "text/plain" }
+     , { "ustar", "application/x-ustar" }
+     , { "vcd", "application/x-cdlink" }
+     , { "vrml", "model/vrml" }
+     , { "wav", "audio/x-wav" }
+     , { "wbmp", "image/vnd.wap.wbmp" }
+     , { "wbxml", "application/vnd.wap.wbxml" }
+     , { "wml", "text/vnd.wap.wml" }
+     , { "wmlc", "application/vnd.wap.wmlc" }
+     , { "wmls", "text/vnd.wap.wmlscript" }
+     , { "wmlsc", "application/vnd.wap.wmlscriptc" }
+     , { "wrl", "model/vrml" }
+     , { "xbm", "image/x-xbitmap" }
+     , { "xht", "application/xhtml+xml" }
+     , { "xhtml", "application/xhtml+xml" }
+     , { "xls", "application/vnd.ms-excel" }
+     , { "xml", "text/xml" }
+     , { "xpm", "image/x-xpixmap" }
+     , { "xsl", "text/xml" }
+     , { "xwd", "image/x-xwindowdump" }
+     , { "xyz", "chemical/x-xyz" }
+     , { "zip", "application/zip" }
+    };
+
+  /**
+   * The MIME types above are put into this Hashtable for faster lookup.
+   */
+  private Hashtable mime_types = new Hashtable(150);
+
+  /**
+   * Create a new <code>MimeTypeMapper</code> object.
+   */
+  public MimeTypeMapper()
+  {
+    for (int i = 0; i < mime_strings.length; i++)
+      mime_types.put(mime_strings[i][0], mime_strings[i][1]);
+
+    // Now read from the system mime database, if it exists.  Entries found
+    // here override our internal ones.
+    try
+      {
+        // On Linux this usually means /etc/mime.types.
+        String file
+          = SystemProperties.getProperty("gnu.classpath.mime.types.file");
+        if (file != null)
+          fillFromFile(mime_types, file);
+      }
+    catch (IOException ignore)
+      {
+      }
+  }
+
+  public static void fillFromFile (Map table, String fname) 
+    throws IOException
+  {
+    LineNumberReader reader = 
+      new LineNumberReader (new FileReader (fname));
+
+    while (reader.ready ())
+      {
+        StringTokenizer tokenizer = 
+          new StringTokenizer (reader.readLine ());
+
+        try
+          {
+            String t = tokenizer.nextToken ();
+
+            if (! t.startsWith ("#"))
+              {
+                while (true)
+                  {
+                    // Read the next extension
+                    String e = tokenizer.nextToken ();
+                    if ((e != null) && (! e.startsWith ("#")))
+                      table.put (e, t);
+                    else
+                      break;
+                  }
+              }
+          }
+        catch (NoSuchElementException ex)
+          {
+            // Do nothing.
+          }
+      }
+  }
+
+  /**
+   * The method returns the MIME type of the filename passed as an argument.
+   * The value returned is based on the extension of the filename.  The
+   * default content type returned if this method cannot determine the
+   * actual content type is "application/octet-stream"
+   *
+   * @param filename The name of the file to return the MIME type for
+   *
+   * @return The MIME type
+   */
+  public String getContentTypeFor(String filename)
+  {
+    int index = filename.lastIndexOf(".");
+    if (index != -1)
+      {
+	if (index == filename.length())
+	  return "application/octet-stream";
+	else
+	  filename = filename.substring(index + 1);
+      }
+
+    String type = (String) mime_types.get(filename);
+    if (type == null)
+      return "application/octet-stream";
+    else
+      return type;
+  }
+
+  /**
+   * Run this class as a program to create a new mime_strings table.
+   */
+  public static void main(String[] args) throws IOException
+  {
+    TreeMap map = new TreeMap();
+    // It is fine to hard-code the name here.  This is only ever
+    // used by maintainers, who can hack it if they need to re-run
+    // it.
+    fillFromFile(map, "/etc/mime.types");
+    Iterator it = map.keySet().iterator();
+    boolean first = true;
+    while (it.hasNext())
+      {
+        String key = (String) it.next();
+        String value = (String) map.get(key);
+        // Put the "," first since it is easier to make correct syntax this way.
+        System.out.println("      " + (first ? "  " : ", ") 
+                           + "{ \"" + key + "\", \"" + value + "\" }");
+        first = false;
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/MulticastSocket.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/MulticastSocket.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,486 @@
+/* MulticastSocket.java -- Class for using multicast sockets
+   Copyright (C) 1998, 1999, 2000, 2001, 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.net;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+
+/**
+ * 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.
+ */
+/**
+ * This class models a multicast UDP socket.  A multicast address is a
+ * class D internet address (one whose most significant bits are 1110).
+ * A multicast group consists of a multicast address and a well known
+ * port number.  All members of the group listening on that address and
+ * port will receive all the broadcasts to the group.
+ * <p>
+ * Please note that applets are not allowed to use multicast sockets
+ *
+ * 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.
+ *
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com) (Documentation comments)
+ * @since 1.1
+ * @date May 18, 1999.
+ */
+public class MulticastSocket extends DatagramSocket
+{
+  /**
+   * Create a MulticastSocket that this not bound to any address
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkListen method doesn't allow the operation
+   */
+  public MulticastSocket() throws IOException
+  {
+    this(new InetSocketAddress(0));
+  }
+
+  /**
+   * Create a multicast socket bound to the specified port
+   *
+   * @param port The port to bind to
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkListen method doesn't allow the operation
+   */
+  public MulticastSocket(int port) throws IOException
+  {
+    this(new InetSocketAddress(port));
+  }
+
+  /**
+   * Create a multicast socket bound to the specified SocketAddress.
+   *
+   * @param address The SocketAddress the multicast socket will be bound to
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkListen method doesn't allow the operation
+   *
+   * @since 1.4
+   */
+  public MulticastSocket(SocketAddress address) throws IOException
+  {
+    super((SocketAddress) null);
+    setReuseAddress(true);
+    if (address != null)
+      bind(address);
+  }
+
+  /**
+   * Returns the interface being used for multicast packets
+   *
+   * @return The multicast interface
+   *
+   * @exception SocketException If an error occurs
+   */
+  public InetAddress getInterface() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    return (InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF);
+  }
+
+  /**
+   * Returns the current value of the "Time to Live" option.  This is the
+   * number of hops a packet can make before it "expires".   This method id
+   * deprecated.  Use <code>getTimeToLive</code> instead.
+   *
+   * @return The TTL value
+   *
+   * @exception IOException If an error occurs
+   *
+   * @deprecated 1.2 Replaced by getTimeToLive()
+   *
+   * @see MulticastSocket#getTimeToLive()
+   */
+  public byte getTTL() throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    // Use getTTL here rather than getTimeToLive in case we're using an impl
+    // other than the default PlainDatagramSocketImpl and it doesn't have
+    // getTimeToLive yet.
+    return getImpl().getTTL();
+  }
+
+  /**
+   * Returns the current value of the "Time to Live" option.  This is the
+   * number of hops a packet can make before it "expires".
+   *
+   * @return The TTL value
+   *
+   * @exception IOException If an error occurs
+   *
+   * @since 1.2
+   */
+  public int getTimeToLive() throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    return getImpl().getTimeToLive();
+  }
+
+  /**
+   * Sets the interface to use for sending multicast packets.
+   *
+   * @param addr The new interface to use.
+   *
+   * @exception SocketException If an error occurs.
+   *
+   * @since 1.4
+   */
+  public void setInterface(InetAddress addr) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    getImpl().setOption(SocketOptions.IP_MULTICAST_IF, addr);
+  }
+
+  /**
+   * Sets the local network interface used to send multicast messages
+   *
+   * @param netIf The local network interface used to send multicast messages
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @see MulticastSocket#getNetworkInterface()
+   *
+   * @since 1.4
+   */
+  public void setNetworkInterface(NetworkInterface netIf)
+    throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Enumeration e = netIf.getInetAddresses();
+
+    if (! e.hasMoreElements())
+      throw new SocketException("no network devices found");
+
+    InetAddress address = (InetAddress) e.nextElement();
+    getImpl().setOption(SocketOptions.IP_MULTICAST_IF, address);
+  }
+
+  /**
+   * Gets the local network interface which is used to send multicast messages
+   *
+   * @return The local network interface to send multicast messages
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @see MulticastSocket#setNetworkInterface(NetworkInterface netIf)
+   *
+   * @since 1.4
+   */
+  public NetworkInterface getNetworkInterface() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    InetAddress address =
+      (InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF);
+    NetworkInterface netIf = NetworkInterface.getByInetAddress(address);
+
+    return netIf;
+  }
+
+  /**
+   * Disable/Enable local loopback of multicast packets.  The option is used by
+   * the platform's networking code as a hint for setting whether multicast
+   * data will be looped back to the local socket.
+   *
+   * Because this option is a hint, applications that want to verify what
+   * loopback mode is set to should call #getLoopbackMode
+   *
+   * @param disable True to disable loopback mode
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  public void setLoopbackMode(boolean disable) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    getImpl().setOption(SocketOptions.IP_MULTICAST_LOOP,
+                        Boolean.valueOf(disable));
+  }
+
+  /**
+   * Checks if local loopback mode is enabled
+   *
+   * @return true if loopback mode is enabled, false otherwise
+   * 
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  public boolean getLoopbackMode() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object buf = getImpl().getOption(SocketOptions.IP_MULTICAST_LOOP);
+
+    if (buf instanceof Boolean)
+      return ((Boolean) buf).booleanValue();
+
+    throw new SocketException("unexpected type");
+  }
+
+  /**
+   * Sets the "Time to Live" value for a socket.  The value must be between
+   * 1 and 255.
+   *
+   * @param ttl The new TTL value
+   *
+   * @exception IOException If an error occurs
+   *
+   * @deprecated 1.2 Replaced by <code>setTimeToLive</code>
+   *
+   * @see MulticastSocket#setTimeToLive(int ttl)
+   */
+  public void setTTL(byte ttl) throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    // Use setTTL here rather than setTimeToLive in case we're using an impl
+    // other than the default PlainDatagramSocketImpl and it doesn't have
+    // setTimeToLive yet.
+    getImpl().setTTL(ttl);
+  }
+
+  /**
+   * Sets the "Time to Live" value for a socket.  The value must be between
+   * 1 and 255.
+   *
+   * @param ttl The new TTL value
+   *
+   * @exception IOException If an error occurs
+   *
+   * @since 1.2
+   */
+  public void setTimeToLive(int ttl) throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (ttl <= 0 || ttl > 255)
+      throw new IllegalArgumentException("Invalid ttl: " + ttl);
+
+    getImpl().setTimeToLive(ttl);
+  }
+
+  /**
+   * Joins the specified multicast group.
+   *
+   * @param mcastaddr The address of the group to join
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkMulticast method doesn't allow the operation
+   */
+  public void joinGroup(InetAddress mcastaddr) throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (! mcastaddr.isMulticastAddress())
+      throw new IOException("Not a Multicast address");
+
+    SecurityManager s = System.getSecurityManager();
+    if (s != null)
+      s.checkMulticast(mcastaddr);
+
+    getImpl().join(mcastaddr);
+  }
+
+  /**
+   * Leaves the specified multicast group
+   *
+   * @param mcastaddr The address of the group to leave
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkMulticast method doesn't allow the operation
+   */
+  public void leaveGroup(InetAddress mcastaddr) throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (! mcastaddr.isMulticastAddress())
+      throw new IOException("Not a Multicast address");
+
+    SecurityManager s = System.getSecurityManager();
+    if (s != null)
+      s.checkMulticast(mcastaddr);
+
+    getImpl().leave(mcastaddr);
+  }
+
+  /**
+   * Joins the specified mulitcast group on a specified interface.
+   *
+   * @param mcastaddr The multicast address to join
+   * @param netIf The local network interface to receive the multicast
+   * messages on or null to defer the interface set by #setInterface or
+   * #setNetworkInterface
+   *
+   * @exception IOException If an error occurs
+   * @exception IllegalArgumentException If address type is not supported
+   * @exception SecurityException If a security manager exists and its
+   * checkMulticast method doesn't allow the operation
+   *
+   * @see MulticastSocket#setInterface(InetAddress addr)
+   * @see MulticastSocket#setNetworkInterface(NetworkInterface netIf)
+   *
+   * @since 1.4
+   */
+  public void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf)
+    throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (! (mcastaddr instanceof InetSocketAddress))
+      throw new IllegalArgumentException("SocketAddress type not supported");
+
+    InetSocketAddress tmp = (InetSocketAddress) mcastaddr;
+
+    if (! tmp.getAddress().isMulticastAddress())
+      throw new IOException("Not a Multicast address");
+
+    SecurityManager s = System.getSecurityManager();
+    if (s != null)
+      s.checkMulticast(tmp.getAddress());
+
+    getImpl().joinGroup(mcastaddr, netIf);
+  }
+
+  /**
+   * Leaves the specified mulitcast group on a specified interface.
+   *
+   * @param mcastaddr The multicast address to leave
+   * @param netIf The local networki interface or null to defer to the
+   * interface set by setInterface or setNetworkInterface
+   *
+   * @exception IOException If an error occurs
+   * @exception IllegalArgumentException If address type is not supported
+   * @exception SecurityException If a security manager exists and its
+   * checkMulticast method doesn't allow the operation
+   *
+   * @see MulticastSocket#setInterface(InetAddress addr)
+   * @see MulticastSocket#setNetworkInterface(NetworkInterface netIf)
+   *
+   * @since 1.4
+   */
+  public void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf)
+    throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    InetSocketAddress tmp = (InetSocketAddress) mcastaddr;
+
+    if (! tmp.getAddress().isMulticastAddress())
+      throw new IOException("Not a Multicast address");
+
+    SecurityManager s = System.getSecurityManager();
+    if (s != null)
+      s.checkMulticast(tmp.getAddress());
+
+    getImpl().leaveGroup(mcastaddr, netIf);
+  }
+
+  /**
+   * Sends a packet of data to a multicast address with a TTL that is
+   * different from the default TTL on this socket.  The default TTL for
+   * the socket is not changed.
+   *
+   * @param packet The packet of data to send
+   * @param ttl The TTL for this packet
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkConnect or checkMulticast method doesn't allow the operation
+   *
+   * @deprecated
+   */
+  public synchronized void send(DatagramPacket packet, byte ttl)
+    throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    SecurityManager s = System.getSecurityManager();
+    if (s != null)
+      {
+	InetAddress addr = packet.getAddress();
+	if (addr.isMulticastAddress())
+	  s.checkPermission(new SocketPermission(addr.getHostName()
+	                                         + packet.getPort(),
+	                                         "accept,connect"));
+	else
+	  s.checkConnect(addr.getHostAddress(), packet.getPort());
+      }
+
+    int oldttl = getImpl().getTimeToLive();
+    getImpl().setTimeToLive(((int) ttl) & 0xFF);
+    getImpl().send(packet);
+    getImpl().setTimeToLive(oldttl);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/NetPermission.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/NetPermission.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,90 @@
+/* NetPermission.java -- A class for basic miscellaneous network permission
+   Copyright (C) 1998, 2000, 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.net;
+
+import java.security.BasicPermission;
+
+
+/**
+ * This class is used to model miscellaneous network permissions.  It is
+ * a subclass of <code>BasicPermission</code>.  This means that it models a
+ * "boolean" permission.  One that you either have or do not have.  Thus
+ * there is no permitted action list associated with this object.
+ *
+ * The following permission names are defined for this class:
+ *
+ * <ul>
+ * <li>setDefaultAuthenticator - Grants the ability to install a facility
+ * to collect username and password information when requested by a
+ * web site or proxy server.</li>
+ * <li>requestPasswordAuthentication - Grants the ability to ask the
+ * authentication facility for the user's password.</li>
+ * <li>specifyStreamHandler - Grants the permission to specify the
+ * stream handler class used when loading from a URL.</li>
+ * </ul>
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public final class NetPermission extends BasicPermission
+{
+  static final long serialVersionUID = -8343910153355041693L;
+
+  /**
+   * Initializes a new instance of <code>NetPermission</code> with the
+   * specified name.
+   *
+   * @param name The name of this permission.
+   */
+  public NetPermission(String name)
+  {
+    super(name);
+  }
+
+  /**
+   * Initializes a new instance of <code>NetPermission</code> with the
+   * specified name and perms.  Note that the perms field is irrelevant and is
+   * ignored.  This constructor should never need to be used.
+   *
+   * @param name The name of this permission
+   * @param perms The permitted actions of this permission (ignored)
+   */
+  public NetPermission(String name, String perms)
+  {
+    super(name);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/NetworkInterface.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/NetworkInterface.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,297 @@
+/* NetworkInterface.java --
+   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.net;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Vector;
+
+/**
+ * This class models a network interface on the host computer.  A network
+ * interface contains a name (typically associated with a specific
+ * hardware adapter) and a list of addresses that are bound to it.
+ * For example, an ethernet interface may be named "eth0" and have the
+ * address 192.168.1.101 assigned to it.
+ *
+ * @author Michael Koch (konqueror at gmx.de)
+ * @since 1.4
+ */
+public final class NetworkInterface
+{
+  private String name;
+  private Vector inetAddresses;
+
+  NetworkInterface(String name, InetAddress address)
+  {
+    this.name = name;
+    this.inetAddresses = new Vector(1, 1);
+    this.inetAddresses.add(address);
+  }
+
+  NetworkInterface(String name, InetAddress[] addresses)
+  {
+    this.name = name;
+    this.inetAddresses = new Vector(addresses.length, 1);
+
+    for (int i = 0; i < addresses.length; i++)
+      this.inetAddresses.add(addresses[i]);
+  }
+
+  /**
+   * Returns the name of the network interface
+   *
+   * @return The name of the interface.
+   */
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Returns all available addresses of the network interface
+   *
+   * If a @see SecurityManager is available all addresses are checked
+   * with @see SecurityManager::checkConnect() if they are available.
+   * Only <code>InetAddresses</code> are returned where the security manager
+   * doesn't throw an exception.
+   *
+   * @return An enumeration of all addresses.
+   */
+  public Enumeration getInetAddresses()
+  {
+    SecurityManager s = System.getSecurityManager();
+
+    if (s == null)
+      return inetAddresses.elements();
+
+    Vector tmpInetAddresses = new Vector(1, 1);
+
+    for (Enumeration addresses = inetAddresses.elements();
+         addresses.hasMoreElements();)
+      {
+	InetAddress addr = (InetAddress) addresses.nextElement();
+	try
+	  {
+	    s.checkConnect(addr.getHostAddress(), 58000);
+	    tmpInetAddresses.add(addr);
+	  }
+	catch (SecurityException e)
+	  {
+	    // Ignore.
+	  }
+      }
+
+    return tmpInetAddresses.elements();
+  }
+
+  /**
+   * Returns the display name of the interface
+   *
+   * @return The display name of the interface
+   */
+  public String getDisplayName()
+  {
+    return name;
+  }
+
+  /**
+   * Returns an network interface by name
+   *
+   * @param name The name of the interface to return
+   * 
+   * @return a <code>NetworkInterface</code> object representing the interface,
+   * or null if there is no interface with that name.
+   *
+   * @exception SocketException If an error occurs
+   * @exception NullPointerException If the specified name is null
+   */
+  public static NetworkInterface getByName(String name)
+    throws SocketException
+  {
+    for (Enumeration e = getNetworkInterfaces(); e.hasMoreElements();)
+      {
+	NetworkInterface tmp = (NetworkInterface) e.nextElement();
+
+	if (name.equals(tmp.getName()))
+	  return tmp;
+      }
+
+    // No interface with the given name found.
+    return null;
+  }
+
+  /**
+   * Return a network interface by its address
+   *
+   * @param addr The address of the interface to return
+   *
+   * @return the interface, or <code>null</code> if none found
+   *
+   * @exception SocketException If an error occurs
+   * @exception NullPointerException If the specified addess is null
+   */
+  public static NetworkInterface getByInetAddress(InetAddress addr)
+    throws SocketException
+  {
+    for (Enumeration interfaces = getNetworkInterfaces();
+         interfaces.hasMoreElements();)
+      {
+	NetworkInterface tmp = (NetworkInterface) interfaces.nextElement();
+
+	for (Enumeration addresses = tmp.inetAddresses.elements();
+	     addresses.hasMoreElements();)
+	  {
+	    if (addr.equals((InetAddress) addresses.nextElement()))
+	      return tmp;
+	  }
+      }
+
+    throw new SocketException("no network interface is bound to such an IP address");
+  }
+
+  static private Collection condense(Collection interfaces) 
+  {
+    final Map condensed = new HashMap();
+
+    final Iterator interfs = interfaces.iterator();
+    while (interfs.hasNext()) {
+
+      final NetworkInterface face = (NetworkInterface) interfs.next();
+      final String name = face.getName();
+      
+      if (condensed.containsKey(name))
+	{
+	  final NetworkInterface conface = (NetworkInterface) condensed.get(name);
+	  if (!conface.inetAddresses.containsAll(face.inetAddresses))
+	    {
+	      final Iterator faceAddresses = face.inetAddresses.iterator();
+	      while (faceAddresses.hasNext())
+		{
+		  final InetAddress faceAddress = (InetAddress) faceAddresses.next();
+		  if (!conface.inetAddresses.contains(faceAddress))
+		    {
+		      conface.inetAddresses.add(faceAddress);
+		    }
+		}
+	    }
+	}
+      else
+	{
+	  condensed.put(name, face);
+	}
+    }
+
+    return condensed.values();
+  }
+
+  /**
+   * Return an <code>Enumeration</code> of all available network interfaces
+   *
+   * @return all interfaces
+   * 
+   * @exception SocketException If an error occurs
+   */
+  public static Enumeration getNetworkInterfaces() throws SocketException
+  {
+    Vector networkInterfaces = VMNetworkInterface.getInterfaces();
+
+    if (networkInterfaces.isEmpty())
+      return null;
+
+    Collection condensed = condense(networkInterfaces);
+
+    return Collections.enumeration(condensed);
+  }
+
+  /**
+   * Checks if the current instance is equal to obj
+   *
+   * @param obj The object to compare with
+   *
+   * @return <code>true</code> if equal, <code>false</code> otherwise
+   */
+  public boolean equals(Object obj)
+  {
+    if (! (obj instanceof NetworkInterface))
+      return false;
+
+    NetworkInterface tmp = (NetworkInterface) obj;
+
+    return (name.equals(tmp.name) && inetAddresses.equals(tmp.inetAddresses));
+  }
+
+  /**
+   * Returns the hashcode of the current instance
+   *
+   * @return the hashcode
+   */
+  public int hashCode()
+  {
+    // FIXME: hash correctly
+    return name.hashCode() + inetAddresses.hashCode();
+  }
+
+  /**
+   * Returns a string representation of the interface
+   *
+   * @return the string
+   */
+  public String toString()
+  {
+    // FIXME: check if this is correct
+    String result;
+    String separator = System.getProperty("line.separator");
+
+    result =
+      "name: " + getDisplayName() + " (" + getName() + ") addresses:"
+      + separator;
+
+    for (Enumeration e = inetAddresses.elements(); e.hasMoreElements();)
+      {
+	InetAddress address = (InetAddress) e.nextElement();
+	result += address.toString() + ";" + separator;
+      }
+
+    return result;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/NoRouteToHostException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/NoRouteToHostException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* NoRouteToHostException.java -- Cannot connect to a host
+   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.net;
+
+
+/**
+  * This exception indicates that there is no TCP/IP route to the requested
+  * host.  This is often due to a misconfigured routing table.
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  * @author Warren Levy (warrenl at cygnus.com)
+  * @since 1.1
+  * @status updated to 1.4
+  */
+public class NoRouteToHostException extends SocketException
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = -1897550894873493790L;
+
+  /**
+   * Create an instance without a descriptive error message.
+   */
+  public NoRouteToHostException()
+  {
+  }
+
+  /**
+   * Create an instance with a descriptive error message, such as the text
+   * from strerror(3).
+   *
+   * @param message a message describing the error that occurred
+   */
+  public NoRouteToHostException(String message)
+  {
+    super(message);
+  }
+} // class NoRouteToHostException

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/PasswordAuthentication.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/PasswordAuthentication.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,92 @@
+/* PasswordAuthentication.java -- Container class for username/password pairs
+   Copyright (C) 1998, 2000, 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.net;
+
+
+/**
+ * This class serves a container for username/password pairs.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ *
+ * @since 1.2
+ */
+public final class PasswordAuthentication
+{
+  /**
+   * The username
+   */
+  private String username;
+
+  /**
+   * The password
+   */
+  private char[] password;
+
+  /**
+   * Creates a new <code>PasswordAuthentication</code> object from the
+   * specified username and password.
+   *
+   * @param username The username for this object
+   * @param password The password for this object
+   */
+  public PasswordAuthentication(String username, char[] password)
+  {
+    this.username = username;
+    this.password = password;
+  }
+
+  /**
+   * Returns the username associated with this object
+   *
+   * @return The username
+   */
+  public String getUserName()
+  {
+    return username;
+  }
+
+  /**
+   * Returns the password associated with this object
+   *
+   * @return The password
+   */
+  public char[] getPassword()
+  {
+    return password;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/PortUnreachableException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/PortUnreachableException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* PortUnreachableException.java -- received an ICMP port unreachable datagram
+   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.net;
+
+
+/**
+ * This exception signals that an ICMP port unreachable datagram has been
+ * received.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public class PortUnreachableException extends SocketException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 8462541992376507323L;
+
+  /**
+   * Create a new instance without a descriptive error message.
+   */
+  public PortUnreachableException()
+  {
+  }
+
+  /**
+   * Create a new instance with a descriptive error message.
+   *
+   * @param message a message describing the error that occurred
+   */
+  public PortUnreachableException(String message)
+  {
+    super(message);
+  }
+} // class PortUnreachableException

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/ProtocolException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/ProtocolException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* ProtocolException.java -- a low level protocol error occurred
+   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.net;
+
+import java.io.IOException;
+
+
+/**
+ * This exception indicates that some sort of low level protocol
+ * exception occurred.  Look in the descriptive message (if any) for
+ * details on what went wrong.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class ProtocolException extends IOException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -6098449442062388080L;
+
+  /**
+   * Create a new instance without a descriptive error message.
+   */
+  public ProtocolException()
+  {
+  }
+
+  /**
+   * Create a new instance with a descriptive error message.
+   *
+   * @param message a message describing the error that occurred
+   */
+  public ProtocolException(String message)
+  {
+    super(message);
+  }
+} // class ProtocolException

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/ResolverCache.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/ResolverCache.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,269 @@
+/* ResolverCache.java -- A cache of resolver lookups for InetAddress.
+   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.net;
+
+import java.security.Security;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+/**
+ * This class provides a cache of name service resolutions.  By
+ * default successful resolutions are cached forever to guard
+ * against DNS spoofing attacks and failed resolutions are cached
+ * for 10 seconds to improve performance.  The length of time that
+ * results remain in the cache is determined by the following
+ * security properties:
+ * <dl>
+ *   <dt><code>networkaddress.cache.ttl</code></dt>
+ *   <dd>
+ *     This property specifies the length of time in seconds that
+ *     successful resolutions remain in the cache.  The default is
+ *     -1, indicating to cache forever.
+ *   </dd>
+ *   <dt><code>networkaddress.cache.negative.ttl</code></dt>
+ *   <dd>
+ *     This property specifies the length of time in seconds that
+ *     unsuccessful resolutions remain in the cache.  The default
+ *     is 10, indicating to cache for 10 seconds.
+ *   </dd>
+ * In both cases, a value of -1 indicates to cache forever and a
+ * value of 0 indicates not to cache.
+ *
+ * @author Gary Benson (gbenson at redhat.com)
+ */
+class ResolverCache
+{
+  /**
+   * The time in seconds for which successful lookups are cached.
+   */
+  private static final int POSITIVE_TTL =
+    getTTL("networkaddress.cache.ttl", -1);
+
+  /**
+   * The time in seconds for which unsuccessful lookups are cached.
+   */
+  private static final int NEGATIVE_TTL =
+    getTTL("networkaddress.cache.negative.ttl", 10);
+
+  /**
+   * Helper function to set the TTLs.
+   */
+  private static int getTTL(String propName, int defaultValue)
+  {
+    String propValue = Security.getProperty(propName);
+    if (propValue == null)
+      return defaultValue;
+
+    return Integer.parseInt(propValue);
+  }
+
+  /**
+   * The cache itself.
+   */
+  private static HashMap cache = new HashMap();
+
+  /**
+   * List of entries which may expire.
+   */
+  private static LinkedList killqueue = new LinkedList();
+
+  /**
+   * Return the hostname for the specified IP address.
+   *
+   * @param ip The IP address as a byte array
+   *
+   * @return The hostname
+   *
+   * @exception UnknownHostException If the reverse lookup fails
+   */
+  public static String getHostByAddr(byte[] addr) throws UnknownHostException
+  {
+    Object key = makeHashableAddress(addr);
+    Entry entry = (Entry) get(key);
+    if (entry != null)
+      {
+	if (entry.value == null)
+	  throw new UnknownHostException();
+	return (String) entry.value;
+      }
+
+    try
+      {
+	String hostname = VMInetAddress.getHostByAddr(addr);
+	put(new Entry(key, hostname));
+	return hostname;
+      }
+    catch (UnknownHostException e)
+      {
+	put(new Entry(key, null));
+	throw e;
+      }
+  }
+
+  /**
+   * Return a list of all IP addresses for the specified hostname.
+   *
+   * @param hostname The hostname
+   *
+   * @return An list of IP addresses as byte arrays
+   *
+   * @exception UnknownHostException If the lookup fails
+   */
+  public static byte[][] getHostByName(String hostname)
+    throws UnknownHostException
+  {
+    Entry entry = (Entry) get(hostname);
+    if (entry != null)
+      {
+	if (entry.value == null)
+	  throw new UnknownHostException();
+	return (byte[][]) entry.value;
+      }
+
+    try
+      {
+	byte[][] addrs = VMInetAddress.getHostByName(hostname);
+	put(new Entry(hostname, addrs));
+	return addrs;
+      }
+    catch (UnknownHostException e)
+      {
+	put(new Entry(hostname, null));
+	throw e;
+      }
+  }
+
+  /**
+   * Convert an IP address expressed as a byte array into something
+   * we can use as a hashtable key.
+   */
+  private static Object makeHashableAddress(byte[] addr)
+  {
+    char[] chars = new char[addr.length];
+    for (int i = 0; i < addr.length; i++)
+      chars[i] = (char) addr[i];
+    return new String(chars);
+  }
+
+  /**
+   * Return the entry in the cache associated with the supplied key,
+   * or <code>null</code> if the cache does not contain an entry
+   * associated with this key.
+   */
+  private static synchronized Entry get(Object key)
+  {
+    reap();
+    return (Entry) cache.get(key);
+  }
+
+  /**
+   * Insert the supplied entry into the cache.
+   */
+  private static synchronized void put(Entry entry)
+  {
+    reap();
+    if (entry.expires != 0)
+      {
+	if (entry.expires != -1)
+	  killqueue.add(entry);
+	cache.put(entry.key, entry);
+      }
+  }
+
+  /**
+   * Clear expired entries.  This method is not synchronized, so
+   * it must only be called by methods that are.
+   */
+  private static void reap()
+  {
+    if (!killqueue.isEmpty())
+      {
+	long now = System.currentTimeMillis();
+
+	Iterator iter = killqueue.iterator();
+	while (iter.hasNext())
+	  {
+	    Entry entry = (Entry) iter.next();
+	    if (entry.expires > now)
+	      break;
+	    cache.remove(entry.key);
+	    iter.remove();
+	  }
+      }
+  }
+  
+  /**
+   * An entry in the cache.
+   */
+  private static class Entry
+  {
+    /**
+     * The key by which this entry is referenced.
+     */
+    public final Object key;
+
+    /**
+     * The entry itself.  A null value indicates a failed lookup.
+     */
+    public final Object value;
+    
+    /**
+     * The time when this cache entry expires.  If set to -1 then
+     * this entry will never expire.  If set to 0 then this entry
+     * expires immediately and will not be inserted into the cache.
+     */
+    public final long expires;
+
+    /**
+     * Constructor.
+     */
+    public Entry(Object key, Object value)
+    {
+      this.key = key;
+      this.value = value;
+
+      int ttl = value != null ? POSITIVE_TTL : NEGATIVE_TTL;
+      if (ttl < 1)
+	expires = ttl;
+      else
+	expires = System.currentTimeMillis() + ttl * 1000;
+    }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/STATUS (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/STATUS Thu Nov  8 16:56:19 2007
@@ -0,0 +1,48 @@
+X      ContentHandlerFactory 
+X      FileNameMap 
+X      SocketImplFactory 
+X      URLStreamHandlerFactory 
+*      Authenticator 
+*      ContentHandler 
++      DatagramPacket 
++      DatagramSocket 
++      DatagramSocketImpl 
++      HttpURLConnection 
++      InetAddress 
+*      JarURLConnection 
++      MulticastSocket 
+*      NetPermission 
+*      PasswordAuthentication 
++      PlainDatagramSocketImpl
++      PlainSocketImpl (internal)
++      ServerSocket 
++      Socket 
++      SocketImpl 
++      SocketInputStream (internal)
++      SocketOptions (internal)
++      SocketOutputStream (internal)
+*      SocketPermission 
++      URL 
+      URLClassLoader 
++      URLConnection 
+*      URLEncoder 
++      URLStreamHandler 
+X      BindException 
+X      ConnectException 
+X      MalformedURLException 
+X      NoRouteToHostException 
+X      ProtocolException 
+X      SocketException 
+X      UnknownHostException 
+X      UnknownServiceException 
+
+---------------
++      Native InetAddress
++      Native SocketImpl
++      Native DatagramSocketImpl
++     Protocol Handler for HTTP
+      Protocol Handler for FTP
++      ContentHandler for text
+      ContentHandler for gif
+      ContentHandler for jpeg
+

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/ServerSocket.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/ServerSocket.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,599 @@
+/* ServerSocket.java -- Class for implementing server side sockets
+   Copyright (C) 1998, 1999, 2000, 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.net;
+
+import gnu.java.net.PlainSocketImpl;
+
+import java.io.IOException;
+import java.nio.channels.IllegalBlockingModeException;
+import java.nio.channels.ServerSocketChannel;
+
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status:  I believe all methods are implemented.
+ */
+
+/**
+ * This class models server side sockets.  The basic model is that the
+ * server socket is created and bound to some well known port.  It then
+ * listens for and accepts connections.  At that point the client and
+ * server sockets are ready to communicate with one another utilizing
+ * whatever application layer protocol they desire.
+ *
+ * As with the <code>Socket</code> class, most instance methods of this class
+ * simply redirect their calls to an implementation class.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Per Bothner (bothner at cygnus.com)
+ */
+public class ServerSocket
+{
+  /**
+   * This is the user defined SocketImplFactory, if one is supplied
+   */
+  private static SocketImplFactory factory;
+
+  /**
+   * This is the SocketImp object to which most instance methods in this
+   * class are redirected
+   */
+  private SocketImpl impl;
+
+  /**
+   * We need to retain the local address even after the socket is closed.
+   */
+  private InetSocketAddress local;
+
+  /*
+   * This constructor is only used by java.nio.
+   */
+
+  // FIXME: Workaround a bug in gcj.
+  //ServerSocket (PlainSocketImpl impl) throws IOException
+  ServerSocket(SocketImpl impl) throws IOException
+  {
+    if (impl == null)
+      throw new NullPointerException("impl may not be null");
+
+    this.impl = impl;
+    this.impl.create(true);
+  }
+
+  /*
+   * This method is only used by java.nio.
+   */
+
+  // FIXME: Workaround a bug in gcj.
+  //PlainSocketImpl getImpl()
+  SocketImpl getImpl()
+  {
+    return impl;
+  }
+
+  /**
+   * Constructor that simply sets the implementation.
+   *
+   * @exception IOException If an error occurs
+   *
+   * @specnote This constructor is public since JDK 1.4
+   */
+  public ServerSocket() throws IOException
+  {
+    if (factory != null)
+      impl = factory.createSocketImpl();
+    else
+      impl = new PlainSocketImpl();
+
+    impl.create(true);
+  }
+
+  /**
+   * Creates a server socket and binds it to the specified port.  If the
+   * port number is 0, a random free port will be chosen.  The pending
+   * connection queue on this socket will be set to 50.
+   *
+   * @param port The port number to bind to
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkListen method doesn't allow the operation
+   */
+  public ServerSocket(int port) throws IOException
+  {
+    this(port, 50);
+  }
+
+  /**
+   * Creates a server socket and binds it to the specified port.  If the
+   * port number is 0, a random free port will be chosen.  The pending
+   * connection queue on this socket will be set to the value passed as
+   * arg2.
+   *
+   * @param port The port number to bind to
+   * @param backlog The length of the pending connection queue
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkListen method doesn't allow the operation
+   */
+  public ServerSocket(int port, int backlog) throws IOException
+  {
+    this(port, backlog, null);
+  }
+
+  /**
+   * Creates a server socket and binds it to the specified port.  If the
+   * port number is 0, a random free port will be chosen.  The pending
+   * connection queue on this socket will be set to the value passed as
+   * backlog.  The third argument specifies a particular local address to
+   * bind t or null to bind to all local address.
+   *
+   * @param port The port number to bind to
+   * @param backlog The length of the pending connection queue
+   * @param bindAddr The address to bind to, or null to bind to all addresses
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkListen method doesn't allow the operation
+   *
+   * @since 1.1
+   */
+  public ServerSocket(int port, int backlog, InetAddress bindAddr)
+    throws IOException
+  {
+    this();
+
+    // bind/listen socket
+    bind(new InetSocketAddress(bindAddr, port), backlog);
+  }
+
+  /**
+   * Binds the server socket to a specified socket address
+   *
+   * @param endpoint The socket address to bind to
+   *
+   * @exception IOException If an error occurs
+   * @exception IllegalArgumentException If address type is not supported
+   * @exception SecurityException If a security manager exists and its
+   * checkListen method doesn't allow the operation
+   *
+   * @since 1.4
+   */
+  public void bind(SocketAddress endpoint) throws IOException
+  {
+    bind(endpoint, 50);
+  }
+
+  /**
+   * Binds the server socket to a specified socket address
+   *
+   * @param endpoint The socket address to bind to
+   * @param backlog The length of the pending connection queue
+   *
+   * @exception IOException If an error occurs
+   * @exception IllegalArgumentException If address type is not supported
+   * @exception SecurityException If a security manager exists and its
+   * checkListen method doesn't allow the operation
+   *
+   * @since 1.4
+   */
+  public void bind(SocketAddress endpoint, int backlog)
+    throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("ServerSocket is closed");
+
+    if (! (endpoint instanceof InetSocketAddress))
+      throw new IllegalArgumentException("Address type not supported");
+
+    InetSocketAddress tmp = (InetSocketAddress) endpoint;
+
+    SecurityManager s = System.getSecurityManager();
+    if (s != null)
+      s.checkListen(tmp.getPort());
+
+    InetAddress addr = tmp.getAddress();
+
+    // Initialize addr with 0.0.0.0.
+    if (addr == null)
+      addr = InetAddress.ANY_IF;
+
+    try
+      {
+	impl.bind(addr, tmp.getPort());
+	impl.listen(backlog);
+	local = new InetSocketAddress(
+            (InetAddress) impl.getOption(SocketOptions.SO_BINDADDR),
+            impl.getLocalPort());
+      }
+    catch (IOException exception)
+      {
+	close();
+	throw exception;
+      }
+    catch (RuntimeException exception)
+      {
+	close();
+	throw exception;
+      }
+    catch (Error error)
+      {
+	close();
+	throw error;
+      }
+  }
+
+  /**
+   * This method returns the local address to which this socket is bound
+   *
+   * @return The socket's local address
+   */
+  public InetAddress getInetAddress()
+  {
+    if (local == null)
+      return null;
+
+    return local.getAddress();
+  }
+
+  /**
+   * This method returns the local port number to which this socket is bound
+   *
+   * @return The socket's port number
+   */
+  public int getLocalPort()
+  {
+    if (local == null)
+      return -1;
+
+    return local.getPort();
+  }
+
+  /**
+   * Returns the local socket address
+   *
+   * @return the local socket address, null if not bound
+   * 
+   * @since 1.4
+   */
+  public SocketAddress getLocalSocketAddress()
+  {
+    return local;
+  }
+
+  /**
+   * Accepts a new connection and returns a connected <code>Socket</code>
+   * instance representing that connection.  This method will block until a
+   * connection is available.
+   *
+   * @return socket object for the just accepted connection
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkListen method doesn't allow the operation
+   * @exception IllegalBlockingModeException If this socket has an associated
+   * channel, and the channel is in non-blocking mode
+   * @exception SocketTimeoutException If a timeout was previously set with
+   * setSoTimeout and the timeout has been reached
+   */
+  public Socket accept() throws IOException
+  {
+    Socket socket = new Socket();
+
+    try
+      {
+	implAccept(socket);
+      }
+    catch (IOException e)
+      {
+	try
+	  {
+	    socket.close();
+	  }
+	catch (IOException e2)
+	  {
+	    // Ignore.
+	  }
+
+	throw e;
+      }
+
+    return socket;
+  }
+
+  /**
+   * This protected method is used to help subclasses override
+   * <code>ServerSocket.accept()</code>.  The passed in socket will be
+   * connected when this method returns.
+   *
+   * @param socket The socket that is used for the accepted connection
+   *
+   * @exception IOException If an error occurs
+   * @exception IllegalBlockingModeException If this socket has an associated
+   * channel, and the channel is in non-blocking mode
+   *
+   * @since 1.1
+   */
+  protected final void implAccept(Socket socket) throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("ServerSocket is closed");
+
+    // FIXME: Add a security check to make sure we're allowed to 
+    // connect to the remote host.
+
+    // The Sun spec says that if we have an associated channel and
+    // it is in non-blocking mode, we throw an IllegalBlockingModeException.
+    // However, in our implementation if the channel itself initiated this
+    // operation, then we must honor it regardless of its blocking mode.
+    if (getChannel() != null && ! getChannel().isBlocking()
+        && ! ((PlainSocketImpl) getImpl()).isInChannelOperation())
+      throw new IllegalBlockingModeException();
+
+    impl.accept(socket.impl);
+    socket.implCreated = true;
+    socket.bound = true;
+  }
+
+  /**
+   * Closes this socket and stops listening for connections
+   *
+   * @exception IOException If an error occurs
+   */
+  public void close() throws IOException
+  {
+    if (isClosed())
+      return;
+
+    impl.close();
+    impl = null;
+
+    if (getChannel() != null)
+      getChannel().close();
+  }
+
+  /**
+   * Returns the unique <code>ServerSocketChannel</code> object
+   * associated with this socket, if any.
+   *
+   * <p>The socket only has a <code>ServerSocketChannel</code> if its created
+   * by <code>ServerSocketChannel.open()</code>.</p>
+   *
+   * @return the associated socket channel, null if none exists
+   * 
+   * @since 1.4
+   */
+  public ServerSocketChannel getChannel()
+  {
+    return null;
+  }
+
+  /**
+   * Returns true when the socket is bound, otherwise false
+   *
+   * @return true if socket is bound, false otherwise
+   * 
+   * @since 1.4
+   */
+  public boolean isBound()
+  {
+    return local != null;
+  }
+
+  /**
+   * Returns true if the socket is closed, otherwise false
+   *
+   * @return true if socket is closed, false otherwise
+   * 
+   * @since 1.4
+   */
+  public boolean isClosed()
+  {
+    return impl == null;
+  }
+
+  /**
+   * Sets the value of SO_TIMEOUT.  A value of 0 implies that SO_TIMEOUT is
+   * disabled (ie, operations never time out).  This is the number of
+   * milliseconds a socket operation can block before an
+   * InterruptedIOException is thrown.
+   *
+   * @param timeout The new SO_TIMEOUT value
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.1
+   */
+  public void setSoTimeout(int timeout) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("ServerSocket is closed");
+
+    if (timeout < 0)
+      throw new IllegalArgumentException("SO_TIMEOUT value must be >= 0");
+
+    impl.setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
+  }
+
+  /**
+   * Retrieves the current value of the SO_TIMEOUT setting.  A value of 0
+   * implies that SO_TIMEOUT is disabled (ie, operations never time out).
+   * This is the number of milliseconds a socket operation can block before
+   * an InterruptedIOException is thrown.
+   *
+   * @return The value of SO_TIMEOUT
+   *
+   * @exception IOException If an error occurs
+   *
+   * @since 1.1
+   */
+  public int getSoTimeout() throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("ServerSocket is closed");
+
+    Object timeout = impl.getOption(SocketOptions.SO_TIMEOUT);
+
+    if (! (timeout instanceof Integer))
+      throw new IOException("Internal Error");
+
+    return ((Integer) timeout).intValue();
+  }
+
+  /**
+   * Enables/Disables the SO_REUSEADDR option
+   *
+   * @param on true if SO_REUSEADDR should be enabled, false otherwise
+   * 
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  public void setReuseAddress(boolean on) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("ServerSocket is closed");
+
+    impl.setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(on));
+  }
+
+  /**
+   * Checks if the SO_REUSEADDR option is enabled
+   *
+   * @return true if SO_REUSEADDR is set, false otherwise
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  public boolean getReuseAddress() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("ServerSocket is closed");
+
+    Object reuseaddr = impl.getOption(SocketOptions.SO_REUSEADDR);
+
+    if (! (reuseaddr instanceof Boolean))
+      throw new SocketException("Internal Error");
+
+    return ((Boolean) reuseaddr).booleanValue();
+  }
+
+  /**
+   * This method sets the value for the system level socket option
+   * SO_RCVBUF to the specified value.  Note that valid values for this
+   * option are specific to a given operating system.
+   *
+   * @param size The new receive buffer size.
+   *
+   * @exception SocketException If an error occurs or Socket is not connected
+   * @exception IllegalArgumentException If size is 0 or negative
+   *
+   * @since 1.4
+   */
+  public void setReceiveBufferSize(int size) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("ServerSocket is closed");
+
+    if (size <= 0)
+      throw new IllegalArgumentException("SO_RCVBUF value must be > 0");
+
+    impl.setOption(SocketOptions.SO_RCVBUF, new Integer(size));
+  }
+
+  /**
+   * This method returns the value of the system level socket option
+   * SO_RCVBUF, which is used by the operating system to tune buffer
+   * sizes for data transfers.
+   *
+   * @return The receive buffer size.
+   *
+   * @exception SocketException If an error occurs or Socket is not connected
+   *
+   * @since 1.4
+   */
+  public int getReceiveBufferSize() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("ServerSocket is closed");
+
+    Object buf = impl.getOption(SocketOptions.SO_RCVBUF);
+
+    if (! (buf instanceof Integer))
+      throw new SocketException("Internal Error: Unexpected type");
+
+    return ((Integer) buf).intValue();
+  }
+
+  /**
+   * Returns the value of this socket as a <code>String</code>.
+   *
+   * @return This socket represented as a <code>String</code>.
+   */
+  public String toString()
+  {
+    if (! isBound())
+      return "ServerSocket[unbound]";
+
+    return ("ServerSocket[addr=" + getInetAddress() + ",port="
+           + impl.getPort() + ",localport=" + impl.getLocalPort() + "]");
+  }
+
+  /**
+   * Sets the <code>SocketImplFactory</code> for all
+   * <code>ServerSocket</code>'s.  This may only be done
+   * once per virtual machine.  Subsequent attempts will generate an
+   * exception.  Note that a <code>SecurityManager</code> check is made prior
+   * to setting the factory.  If insufficient privileges exist to set the
+   * factory, an exception will be thrown
+   *
+   * @param fac the factory to set
+   *
+   * @exception SecurityException If this operation is not allowed by the
+   * <code>SecurityManager</code>.
+   * @exception SocketException If the factory object is already defined
+   * @exception IOException If any other error occurs
+   */
+  public static synchronized void setSocketFactory(SocketImplFactory fac)
+    throws IOException
+  {
+    factory = fac;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/Socket.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/Socket.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1269 @@
+/* Socket.java -- Client socket implementation
+   Copyright (C) 1998, 1999, 2000, 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.net;
+
+import gnu.java.net.PlainSocketImpl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.channels.IllegalBlockingModeException;
+import java.nio.channels.SocketChannel;
+
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Status:  I believe all methods are implemented.
+ */
+
+/**
+ * This class models a client site socket.  A socket is a TCP/IP endpoint
+ * for network communications conceptually similar to a file handle.
+ * <p>
+ * This class does not actually do any work.  Instead, it redirects all of
+ * its calls to a socket implementation object which implements the
+ * <code>SocketImpl</code> interface.  The implementation class is
+ * instantiated by factory class that implements the
+ * <code>SocketImplFactory interface</code>.  A default
+ * factory is provided, however the factory may be set by a call to
+ * the <code>setSocketImplFactory</code> method.  Note that this may only be
+ * done once per virtual machine.  If a subsequent attempt is made to set the
+ * factory, a <code>SocketException</code> will be thrown.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Per Bothner (bothner at cygnus.com)
+ */
+public class Socket
+{
+  /**
+   * This is the user SocketImplFactory for this class.  If this variable is
+   * null, a default factory is used.
+   */
+  static SocketImplFactory factory;
+
+  /**
+   * The implementation object to which calls are redirected
+   */
+  // package-private because ServerSocket.implAccept() needs to access it.
+  SocketImpl impl;
+
+  /**
+   * True if socket implementation was created by calling their
+   * create() method.
+   */
+  // package-private because ServerSocket.implAccept() needs to access it.
+  boolean implCreated;
+
+  /**
+   * True if the socket is bound.
+   * Package private so it can be set from ServerSocket when accept is called.
+   */
+  boolean bound;
+
+  /**
+   * True if input is shutdown.
+   */
+  private boolean inputShutdown;
+
+  /**
+   * True if output is shutdown.
+   */
+  private boolean outputShutdown;
+
+  /**
+   * Initializes a new instance of <code>Socket</code> object without
+   * connecting to a remote host.  This useful for subclasses of socket that
+   * might want this behavior.
+   *
+   * @specnote This constructor is public since JDK 1.4
+   * @since 1.1
+   */
+  public Socket()
+  {
+    if (factory != null)
+      impl = factory.createSocketImpl();
+    else
+      impl = new PlainSocketImpl();
+  }
+
+  /**
+   * Initializes a new instance of <code>Socket</code> object without
+   * connecting to a remote host.  This is useful for subclasses of socket
+   * that might want this behavior.
+   * <p>
+   * Additionally, this socket will be created using the supplied
+   * implementation class instead the default class or one returned by a
+   * factory.  If this value is <code>null</code>, the default Socket
+   * implementation is used.
+   *
+   * @param impl The <code>SocketImpl</code> to use for this
+   *             <code>Socket</code>
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.1
+   */
+  protected Socket(SocketImpl impl) throws SocketException
+  {
+    if (impl == null)
+      this.impl = new PlainSocketImpl();
+    else
+      this.impl = impl;
+  }
+
+  /**
+   * Initializes a new instance of <code>Socket</code> and connects to the
+   * hostname and port specified as arguments.
+   *
+   * @param host The name of the host to connect to
+   * @param port The port number to connect to
+   *
+   * @exception UnknownHostException If the hostname cannot be resolved to a
+   * network address.
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkConnect method doesn't allow the operation
+   */
+  public Socket(String host, int port)
+    throws UnknownHostException, IOException
+  {
+    this(InetAddress.getByName(host), port, null, 0, true);
+  }
+
+  /**
+   * Initializes a new instance of <code>Socket</code> and connects to the
+   * address and port number specified as arguments.
+   *
+   * @param address The address to connect to
+   * @param port The port number to connect to
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkConnect method doesn't allow the operation
+   */
+  public Socket(InetAddress address, int port) throws IOException
+  {
+    this(address, port, null, 0, true);
+  }
+
+  /**
+   * Initializes a new instance of <code>Socket</code> that connects to the
+   * named host on the specified port and binds to the specified local address
+   * and port.
+   *
+   * @param host The name of the remote host to connect to.
+   * @param port The remote port to connect to.
+   * @param localAddr The local address to bind to.
+   * @param localPort The local port to bind to.
+   *
+   * @exception SecurityException If the <code>SecurityManager</code>
+   * exists and does not allow a connection to the specified host/port or
+   * binding to the specified local host/port.
+   * @exception IOException If a connection error occurs.
+   *
+   * @since 1.1
+   */
+  public Socket(String host, int port, InetAddress localAddr, int localPort)
+    throws IOException
+  {
+    this(InetAddress.getByName(host), port, localAddr, localPort, true);
+  }
+
+  /**
+   * Initializes a new instance of <code>Socket</code> and connects to the
+   * address and port number specified as arguments, plus binds to the
+   * specified local address and port.
+   *
+   * @param address The remote address to connect to
+   * @param port The remote port to connect to
+   * @param localAddr The local address to connect to
+   * @param localPort The local port to connect to
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkConnect method doesn't allow the operation
+   *
+   * @since 1.1
+   */
+  public Socket(InetAddress address, int port, InetAddress localAddr,
+                int localPort) throws IOException
+  {
+    this(address, port, localAddr, localPort, true);
+  }
+
+  /**
+   * Initializes a new instance of <code>Socket</code> and connects to the
+   * hostname and port specified as arguments.  If the stream argument is set
+   * to <code>true</code>, then a stream socket is created.  If it is
+   * <code>false</code>, a datagram socket is created.
+   *
+   * @param host The name of the host to connect to
+   * @param port The port to connect to
+   * @param stream <code>true</code> for a stream socket, <code>false</code>
+   * for a datagram socket
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkConnect method doesn't allow the operation
+   *
+   * @deprecated Use the <code>DatagramSocket</code> class to create
+   * datagram oriented sockets.
+   */
+  public Socket(String host, int port, boolean stream)
+    throws IOException
+  {
+    this(InetAddress.getByName(host), port, null, 0, stream);
+  }
+
+  /**
+   * Initializes a new instance of <code>Socket</code> and connects to the
+   * address and port number specified as arguments.  If the stream param is
+   * <code>true</code>, a stream socket will be created, otherwise a datagram
+   * socket is created.
+   *
+   * @param host The address to connect to
+   * @param port The port number to connect to
+   * @param stream <code>true</code> to create a stream socket,
+   * <code>false</code> to create a datagram socket.
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkConnect method doesn't allow the operation
+   *
+   * @deprecated Use the <code>DatagramSocket</code> class to create
+   * datagram oriented sockets.
+   */
+  public Socket(InetAddress host, int port, boolean stream)
+    throws IOException
+  {
+    this(host, port, null, 0, stream);
+  }
+
+  /**
+   * This constructor is where the real work takes place.  Connect to the
+   * specified address and port.  Use default local values if not specified,
+   * otherwise use the local host and port passed in.  Create as stream or
+   * datagram based on "stream" argument.
+   * <p>
+   *
+   * @param raddr The remote address to connect to
+   * @param rport The remote port to connect to
+   * @param laddr The local address to connect to
+   * @param lport The local port to connect to
+   * @param stream true for a stream socket, false for a datagram socket
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkConnect method doesn't allow the operation
+   */
+  private Socket(InetAddress raddr, int rport, InetAddress laddr, int lport,
+                 boolean stream) throws IOException
+  {
+    this();
+
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkConnect(raddr.getHostName(), rport);
+
+    // bind socket
+    SocketAddress bindaddr =
+      laddr == null ? null : new InetSocketAddress(laddr, lport);
+    bind(bindaddr);
+
+    // connect socket
+    connect(new InetSocketAddress(raddr, rport));
+
+    // FIXME: JCL p. 1586 says if localPort is unspecified, bind to any port,
+    // i.e. '0' and if localAddr is unspecified, use getLocalAddress() as
+    // that default.  JDK 1.2 doc infers not to do a bind.
+  }
+
+  private SocketImpl getImpl() throws SocketException
+  {
+    try
+      {
+	if (! implCreated)
+	  {
+	    impl.create(true);
+	    implCreated = true;
+	  }
+      }
+    catch (IOException e)
+      {
+	SocketException se = new SocketException(e.toString());
+	se.initCause(e);
+	throw se;
+      }
+
+    return impl;
+  }
+
+  /**
+   * Binds the socket to the givent local address/port
+   *
+   * @param bindpoint The address/port to bind to
+   *
+   * @exception IOException If an error occurs
+   * @exception SecurityException If a security manager exists and its
+   * checkConnect method doesn't allow the operation
+   * @exception IllegalArgumentException If the address type is not supported
+   *
+   * @since 1.4
+   */
+  public void bind(SocketAddress bindpoint) throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    // XXX: JDK 1.4.1 API documentation says that if bindpoint is null the
+    // socket will be bound to an ephemeral port and a valid local address.
+    if (bindpoint == null)
+      bindpoint = new InetSocketAddress(InetAddress.ANY_IF, 0);
+
+    if (! (bindpoint instanceof InetSocketAddress))
+      throw new IllegalArgumentException();
+
+    InetSocketAddress tmp = (InetSocketAddress) bindpoint;
+
+    // bind to address/port
+    try
+      {
+	getImpl().bind(tmp.getAddress(), tmp.getPort());
+	bound = true;
+      }
+    catch (IOException exception)
+      {
+	close();
+	throw exception;
+      }
+    catch (RuntimeException exception)
+      {
+	close();
+	throw exception;
+      }
+    catch (Error error)
+      {
+	close();
+	throw error;
+      }
+  }
+
+  /**
+   * Connects the socket with a remote address.
+   *
+   * @param endpoint The address to connect to
+   *
+   * @exception IOException If an error occurs
+   * @exception IllegalArgumentException If the addess type is not supported
+   * @exception IllegalBlockingModeException If this socket has an associated
+   * channel, and the channel is in non-blocking mode
+   *
+   * @since 1.4
+   */
+  public void connect(SocketAddress endpoint) throws IOException
+  {
+    connect(endpoint, 0);
+  }
+
+  /**
+   * Connects the socket with a remote address. A timeout of zero is
+   * interpreted as an infinite timeout. The connection will then block
+   * until established or an error occurs.
+   *
+   * @param endpoint The address to connect to
+   * @param timeout The length of the timeout in milliseconds, or
+   * 0 to indicate no timeout.
+   *
+   * @exception IOException If an error occurs
+   * @exception IllegalArgumentException If the address type is not supported
+   * @exception IllegalBlockingModeException If this socket has an associated
+   * channel, and the channel is in non-blocking mode
+   * @exception SocketTimeoutException If the timeout is reached
+   *
+   * @since 1.4
+   */
+  public void connect(SocketAddress endpoint, int timeout)
+    throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (! (endpoint instanceof InetSocketAddress))
+      throw new IllegalArgumentException("unsupported address type");
+
+    // The Sun spec says that if we have an associated channel and
+    // it is in non-blocking mode, we throw an IllegalBlockingModeException.
+    // However, in our implementation if the channel itself initiated this
+    // operation, then we must honor it regardless of its blocking mode.
+    if (getChannel() != null && ! getChannel().isBlocking()
+        && ! ((PlainSocketImpl) getImpl()).isInChannelOperation())
+      throw new IllegalBlockingModeException();
+
+    if (! isBound())
+      bind(null);
+
+    getImpl().connect(endpoint, timeout);
+  }
+
+  /**
+   * Returns the address of the remote end of the socket.  If this socket
+   * is not connected, then <code>null</code> is returned.
+   *
+   * @return The remote address this socket is connected to
+   */
+  public InetAddress getInetAddress()
+  {
+    if (! isConnected())
+      return null;
+
+    try
+      {
+	return getImpl().getInetAddress();
+      }
+    catch (SocketException e)
+      {
+	// This cannot happen as we are connected.
+      }
+
+    return null;
+  }
+
+  /**
+   * Returns the local address to which this socket is bound.  If this socket
+   * is not connected, then a wildcard address, for which
+   * @see InetAddress#isAnyLocalAddress() is <code>true</code>, is returned.
+   *
+   * @return The local address
+   *
+   * @since 1.1
+   */
+  public InetAddress getLocalAddress()
+  {
+    if (! isBound())
+      return InetAddress.ANY_IF;
+
+    InetAddress addr = null;
+
+    try
+      {
+	addr = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
+      }
+    catch (SocketException e)
+      {
+	// (hopefully) shouldn't happen
+	// throw new java.lang.InternalError
+	//      ("Error in PlainSocketImpl.getOption");
+	return null;
+      }
+
+    // FIXME: According to libgcj, checkConnect() is supposed to be called
+    // before performing this operation.  Problems: 1) We don't have the
+    // addr until after we do it, so we do a post check.  2). The docs I
+    // see don't require this in the Socket case, only DatagramSocket, but
+    // we'll assume they mean both.
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkConnect(addr.getHostName(), getLocalPort());
+
+    return addr;
+  }
+
+  /**
+   * Returns the port number of the remote end of the socket connection.  If
+   * this socket is not connected, then 0 is returned.
+   *
+   * @return The remote port this socket is connected to
+   */
+  public int getPort()
+  {
+    if (! isConnected())
+      return 0;
+
+    try
+      {
+	return getImpl().getPort();
+      }
+    catch (SocketException e)
+      {
+	// This cannot happen as we are connected.
+      }
+
+    return 0;
+  }
+
+  /**
+   * Returns the local port number to which this socket is bound.  If this
+   * socket is not connected, then -1 is returned.
+   *
+   * @return The local port
+   */
+  public int getLocalPort()
+  {
+    if (! isBound())
+      return -1;
+
+    try
+      {
+	if (getImpl() != null)
+	  return getImpl().getLocalPort();
+      }
+    catch (SocketException e)
+      {
+	// This cannot happen as we are bound.
+      }
+
+    return -1;
+  }
+
+  /**
+   * Returns local socket address.
+   *
+   * @return the local socket address, null if not bound
+   *
+   * @since 1.4
+   */
+  public SocketAddress getLocalSocketAddress()
+  {
+    if (! isBound())
+      return null;
+
+    InetAddress addr = getLocalAddress();
+
+    try
+      {
+	return new InetSocketAddress(addr, getImpl().getLocalPort());
+      }
+    catch (SocketException e)
+      {
+	// This cannot happen as we are bound.
+	return null;
+      }
+  }
+
+  /**
+   * Returns the remote socket address.
+   *
+   * @return the remote socket address, null of not connected
+   *
+   * @since 1.4
+   */
+  public SocketAddress getRemoteSocketAddress()
+  {
+    if (! isConnected())
+      return null;
+
+    try
+      {
+	return new InetSocketAddress(getImpl().getInetAddress(),
+	                             getImpl().getPort());
+      }
+    catch (SocketException e)
+      {
+	// This cannot happen as we are connected.
+	return null;
+      }
+  }
+
+  /**
+   * Returns an InputStream for reading from this socket.
+   *
+   * @return The InputStream object
+   *
+   * @exception IOException If an error occurs or Socket is not connected
+   */
+  public InputStream getInputStream() throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (! isConnected())
+      throw new IOException("not connected");
+
+    return getImpl().getInputStream();
+  }
+
+  /**
+   * Returns an OutputStream for writing to this socket.
+   *
+   * @return The OutputStream object
+   *
+   * @exception IOException If an error occurs or Socket is not connected
+   */
+  public OutputStream getOutputStream() throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (! isConnected())
+      throw new IOException("not connected");
+
+    return getImpl().getOutputStream();
+  }
+
+  /**
+   * Sets the TCP_NODELAY option on the socket.
+   *
+   * @param on true to enable, false to disable
+   *
+   * @exception SocketException If an error occurs or Socket is not connected
+   *
+   * @since 1.1
+   */
+  public void setTcpNoDelay(boolean on) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    getImpl().setOption(SocketOptions.TCP_NODELAY, Boolean.valueOf(on));
+  }
+
+  /**
+   * Tests whether or not the TCP_NODELAY option is set on the socket.
+   * Returns true if enabled, false if disabled. When on it disables the
+   * Nagle algorithm which means that packets are always send immediatly and
+   * never merged together to reduce network trafic.
+   *
+   * @return Whether or not TCP_NODELAY is set
+   *
+   * @exception SocketException If an error occurs or Socket not connected
+   *
+   * @since 1.1
+   */
+  public boolean getTcpNoDelay() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object on = getImpl().getOption(SocketOptions.TCP_NODELAY);
+
+    if (on instanceof Boolean)
+      return (((Boolean) on).booleanValue());
+    else
+      throw new SocketException("Internal Error");
+  }
+
+  /**
+   * Sets the value of the SO_LINGER option on the socket.  If the
+   * SO_LINGER option is set on a socket and there is still data waiting to
+   * be sent when the socket is closed, then the close operation will block
+   * until either that data is delivered or until the timeout period
+   * expires.  The linger interval is specified in hundreths of a second
+   * (platform specific?)
+   *
+   * @param on true to enable SO_LINGER, false to disable
+   * @param linger The SO_LINGER timeout in hundreths of a second or -1 if
+   * SO_LINGER not set.
+   *
+   * @exception SocketException If an error occurs or Socket not connected
+   * @exception IllegalArgumentException If linger is negative
+   *
+   * @since 1.1
+   */
+  public void setSoLinger(boolean on, int linger) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (on)
+      {
+	if (linger < 0)
+	  throw new IllegalArgumentException("SO_LINGER must be >= 0");
+
+	if (linger > 65535)
+	  linger = 65535;
+
+	getImpl().setOption(SocketOptions.SO_LINGER, new Integer(linger));
+      }
+    else
+      getImpl().setOption(SocketOptions.SO_LINGER, Boolean.valueOf(false));
+  }
+
+  /**
+   * Returns the value of the SO_LINGER option on the socket.  If the
+   * SO_LINGER option is set on a socket and there is still data waiting to
+   * be sent when the socket is closed, then the close operation will block
+   * until either that data is delivered or until the timeout period
+   * expires.  This method either returns the timeouts (in hundredths of
+   * of a second (platform specific?)) if SO_LINGER is set, or -1 if
+   * SO_LINGER is not set.
+   *
+   * @return The SO_LINGER timeout in hundreths of a second or -1
+   * if SO_LINGER not set
+   *
+   * @exception SocketException If an error occurs or Socket is not connected
+   *
+   * @since 1.1
+   */
+  public int getSoLinger() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object linger = getImpl().getOption(SocketOptions.SO_LINGER);
+
+    if (linger instanceof Integer)
+      return (((Integer) linger).intValue());
+    else
+      return -1;
+  }
+
+  /**
+   * Sends urgent data through the socket
+   *
+   * @param data The data to send.
+   * Only the lowest eight bits of data are sent
+   *
+   * @exception IOException If an error occurs
+   *
+   * @since 1.4
+   */
+  public void sendUrgentData(int data) throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    getImpl().sendUrgentData(data);
+  }
+
+  /**
+   * Enables/disables the SO_OOBINLINE option
+   *
+   * @param on True if SO_OOBLINE should be enabled
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  public void setOOBInline(boolean on) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    getImpl().setOption(SocketOptions.SO_OOBINLINE, Boolean.valueOf(on));
+  }
+
+  /**
+   * Returns the current setting of the SO_OOBINLINE option for this socket
+   *
+   * @return True if SO_OOBINLINE is set, false otherwise.
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  public boolean getOOBInline() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object buf = getImpl().getOption(SocketOptions.SO_OOBINLINE);
+
+    if (buf instanceof Boolean)
+      return (((Boolean) buf).booleanValue());
+    else
+      throw new SocketException("Internal Error: Unexpected type");
+  }
+
+  /**
+   * Sets the value of the SO_TIMEOUT option on the socket.  If this value
+   * is set, and an read/write is performed that does not complete within
+   * the timeout period, a short count is returned (or an EWOULDBLOCK signal
+   * would be sent in Unix if no data had been read).  A value of 0 for
+   * this option implies that there is no timeout (ie, operations will
+   * block forever).  On systems that have separate read and write timeout
+   * values, this method returns the read timeout.  This
+   * value is in milliseconds.
+   *
+   * @param timeout The length of the timeout in milliseconds, or
+   * 0 to indicate no timeout.
+   *
+   * @exception SocketException If an error occurs or Socket not connected
+   *
+   * @since 1.1
+   */
+  public synchronized void setSoTimeout(int timeout) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (timeout < 0)
+      throw new IllegalArgumentException("SO_TIMEOUT value must be >= 0");
+
+    getImpl().setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
+  }
+
+  /**
+   * Returns the value of the SO_TIMEOUT option on the socket.  If this value
+   * is set, and an read/write is performed that does not complete within
+   * the timeout period, a short count is returned (or an EWOULDBLOCK signal
+   * would be sent in Unix if no data had been read).  A value of 0 for
+   * this option implies that there is no timeout (ie, operations will
+   * block forever).  On systems that have separate read and write timeout
+   * values, this method returns the read timeout.  This
+   * value is in thousandths of a second (implementation specific?).
+   *
+   * @return The length of the timeout in thousandth's of a second or 0
+   * if not set
+   *
+   * @exception SocketException If an error occurs or Socket not connected
+   *
+   * @since 1.1
+   */
+  public synchronized int getSoTimeout() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object timeout = getImpl().getOption(SocketOptions.SO_TIMEOUT);
+    if (timeout instanceof Integer)
+      return (((Integer) timeout).intValue());
+    else
+      return 0;
+  }
+
+  /**
+   * This method sets the value for the system level socket option
+   * SO_SNDBUF to the specified value.  Note that valid values for this
+   * option are specific to a given operating system.
+   *
+   * @param size The new send buffer size.
+   *
+   * @exception SocketException If an error occurs or Socket not connected
+   * @exception IllegalArgumentException If size is 0 or negative
+   *
+   * @since 1.2
+   */
+  public void setSendBufferSize(int size) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (size <= 0)
+      throw new IllegalArgumentException("SO_SNDBUF value must be > 0");
+
+    getImpl().setOption(SocketOptions.SO_SNDBUF, new Integer(size));
+  }
+
+  /**
+   * This method returns the value of the system level socket option
+   * SO_SNDBUF, which is used by the operating system to tune buffer
+   * sizes for data transfers.
+   *
+   * @return The send buffer size.
+   *
+   * @exception SocketException If an error occurs or socket not connected
+   *
+   * @since 1.2
+   */
+  public int getSendBufferSize() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object buf = getImpl().getOption(SocketOptions.SO_SNDBUF);
+
+    if (buf instanceof Integer)
+      return (((Integer) buf).intValue());
+    else
+      throw new SocketException("Internal Error: Unexpected type");
+  }
+
+  /**
+   * This method sets the value for the system level socket option
+   * SO_RCVBUF to the specified value.  Note that valid values for this
+   * option are specific to a given operating system.
+   *
+   * @param size The new receive buffer size.
+   *
+   * @exception SocketException If an error occurs or Socket is not connected
+   * @exception IllegalArgumentException If size is 0 or negative
+   *
+   * @since 1.2
+   */
+  public void setReceiveBufferSize(int size) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (size <= 0)
+      throw new IllegalArgumentException("SO_RCVBUF value must be > 0");
+
+    getImpl().setOption(SocketOptions.SO_RCVBUF, new Integer(size));
+  }
+
+  /**
+   * This method returns the value of the system level socket option
+   * SO_RCVBUF, which is used by the operating system to tune buffer
+   * sizes for data transfers.
+   *
+   * @return The receive buffer size.
+   *
+   * @exception SocketException If an error occurs or Socket is not connected
+   *
+   * @since 1.2
+   */
+  public int getReceiveBufferSize() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object buf = getImpl().getOption(SocketOptions.SO_RCVBUF);
+
+    if (buf instanceof Integer)
+      return (((Integer) buf).intValue());
+    else
+      throw new SocketException("Internal Error: Unexpected type");
+  }
+
+  /**
+   * This method sets the value for the socket level socket option
+   * SO_KEEPALIVE.
+   *
+   * @param on True if SO_KEEPALIVE should be enabled
+   *
+   * @exception SocketException If an error occurs or Socket is not connected
+   *
+   * @since 1.3
+   */
+  public void setKeepAlive(boolean on) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    getImpl().setOption(SocketOptions.SO_KEEPALIVE, Boolean.valueOf(on));
+  }
+
+  /**
+   * This method returns the value of the socket level socket option
+   * SO_KEEPALIVE.
+   *
+   * @return The setting
+   *
+   * @exception SocketException If an error occurs or Socket is not connected
+   *
+   * @since 1.3
+   */
+  public boolean getKeepAlive() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object buf = getImpl().getOption(SocketOptions.SO_KEEPALIVE);
+
+    if (buf instanceof Boolean)
+      return (((Boolean) buf).booleanValue());
+    else
+      throw new SocketException("Internal Error: Unexpected type");
+  }
+
+  /**
+   * Closes the socket.
+   *
+   * @exception IOException If an error occurs
+   */
+  public synchronized void close() throws IOException
+  {
+    if (isClosed())
+      return;
+
+    getImpl().close();
+    impl = null;
+    bound = false;
+
+    if (getChannel() != null)
+      getChannel().close();
+  }
+
+  /**
+   * Converts this <code>Socket</code> to a <code>String</code>.
+   *
+   * @return The <code>String</code> representation of this <code>Socket</code>
+   */
+  public String toString()
+  {
+    try
+      {
+	if (isConnected())
+	  return ("Socket[addr=" + getImpl().getInetAddress() + ",port="
+	         + getImpl().getPort() + ",localport="
+	         + getImpl().getLocalPort() + "]");
+      }
+    catch (SocketException e)
+      {
+	// This cannot happen as we are connected.
+      }
+
+    return "Socket[unconnected]";
+  }
+
+  /**
+   * Sets the <code>SocketImplFactory</code>.  This may be done only once per
+   * virtual machine.  Subsequent attempts will generate a
+   * <code>SocketException</code>.  Note that a <code>SecurityManager</code>
+   * check is made prior to setting the factory.  If
+   * insufficient privileges exist to set the factory, then an
+   * <code>IOException</code> will be thrown.
+   *
+   * @param fac the factory to set
+   *
+   * @exception SecurityException If the <code>SecurityManager</code> does
+   * not allow this operation.
+   * @exception SocketException If the SocketImplFactory is already defined
+   * @exception IOException If any other error occurs
+   */
+  public static synchronized void setSocketImplFactory(SocketImplFactory fac)
+    throws IOException
+  {
+    // See if already set
+    if (factory != null)
+      throw new SocketException("SocketImplFactory already defined");
+
+    // Check permissions
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkSetFactory();
+
+    if (fac == null)
+      throw new SocketException("SocketImplFactory cannot be null");
+
+    factory = fac;
+  }
+
+  /**
+   * Closes the input side of the socket stream.
+   *
+   * @exception IOException If an error occurs.
+   *
+   * @since 1.3
+   */
+  public void shutdownInput() throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    getImpl().shutdownInput();
+    inputShutdown = true;
+  }
+
+  /**
+   * Closes the output side of the socket stream.
+   *
+   * @exception IOException If an error occurs.
+   *
+   * @since 1.3
+   */
+  public void shutdownOutput() throws IOException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    getImpl().shutdownOutput();
+    outputShutdown = true;
+  }
+
+  /**
+   * Returns the socket channel associated with this socket.
+   *
+   * @return the associated socket channel,
+   * null if no associated channel exists
+   *
+   * @since 1.4
+   */
+  public SocketChannel getChannel()
+  {
+    return null;
+  }
+
+  /**
+   * Checks if the SO_REUSEADDR option is enabled
+   *
+   * @return True if SO_REUSEADDR is set, false otherwise.
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  public boolean getReuseAddress() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object reuseaddr = getImpl().getOption(SocketOptions.SO_REUSEADDR);
+
+    if (! (reuseaddr instanceof Boolean))
+      throw new SocketException("Internal Error");
+
+    return ((Boolean) reuseaddr).booleanValue();
+  }
+
+  /**
+   * Enables/Disables the SO_REUSEADDR option
+   *
+   * @param reuseAddress true if SO_REUSEADDR should be enabled,
+   * false otherwise
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  public void setReuseAddress(boolean reuseAddress) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    getImpl().setOption(SocketOptions.SO_REUSEADDR,
+                        Boolean.valueOf(reuseAddress));
+  }
+
+  /**
+   * Returns the current traffic class
+   *
+   * @return The current traffic class.
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @see Socket#setTrafficClass(int tc)
+   *
+   * @since 1.4
+   */
+  public int getTrafficClass() throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    Object obj = getImpl().getOption(SocketOptions.IP_TOS);
+
+    if (obj instanceof Integer)
+      return ((Integer) obj).intValue();
+    else
+      throw new SocketException("Unexpected type");
+  }
+
+  /**
+   * Sets the traffic class value
+   *
+   * @param tc The traffic class
+   *
+   * @exception SocketException If an error occurs
+   * @exception IllegalArgumentException If tc value is illegal
+   *
+   * @see Socket#getTrafficClass()
+   *
+   * @since 1.4
+   */
+  public void setTrafficClass(int tc) throws SocketException
+  {
+    if (isClosed())
+      throw new SocketException("socket is closed");
+
+    if (tc < 0 || tc > 255)
+      throw new IllegalArgumentException();
+
+    getImpl().setOption(SocketOptions.IP_TOS, new Integer(tc));
+  }
+
+  /**
+   * Checks if the socket is connected
+   *
+   * @return True if socket is connected, false otherwise.
+   *
+   * @since 1.4
+   */
+  public boolean isConnected()
+  {
+    try
+      {
+	if (getImpl() == null)
+	  return false;
+
+	return getImpl().getInetAddress() != null;
+      }
+    catch (SocketException e)
+      {
+	return false;
+      }
+  }
+
+  /**
+   * Checks if the socket is already bound.
+   *
+   * @return True if socket is bound, false otherwise.
+   *
+   * @since 1.4
+   */
+  public boolean isBound()
+  {
+    return bound;
+  }
+
+  /**
+   * Checks if the socket is closed.
+   *
+   * @return True if socket is closed, false otherwise.
+   *
+   * @since 1.4
+   */
+  public boolean isClosed()
+  {
+    return impl == null;
+  }
+
+  /**
+   * Checks if the socket's input stream is shutdown
+   *
+   * @return True if input is shut down.
+   *
+   * @since 1.4
+   */
+  public boolean isInputShutdown()
+  {
+    return inputShutdown;
+  }
+
+  /**
+   * Checks if the socket's output stream is shutdown
+   *
+   * @return True if output is shut down.
+   *
+   * @since 1.4
+   */
+  public boolean isOutputShutdown()
+  {
+    return outputShutdown;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketAddress.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketAddress.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* SocketAddress.java --
+   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.net;
+
+import java.io.Serializable;
+
+
+/**
+ * Abstract base class for InetSocketAddress.
+ * InetSocketAddress is to my knowledge the only derived
+ * class. [Ronald]
+ *
+ * @since 1.4
+ */
+public abstract class SocketAddress implements Serializable
+{
+  /**
+   * Compatible with JDK 1.4+
+   */
+  static final long serialVersionUID = 5215720748342549866L;
+
+  /**
+   * Initializes the socket address.
+   */
+  public SocketAddress()
+  {
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* SocketException.java -- An exception occurred while performing a socket op
+   Copyright (C) 1998, 1999, 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.net;
+
+import java.io.IOException;
+
+
+/**
+ * This exception indicates that a generic error occurred related to an
+ * operation on a socket.  Check the descriptive message (if any) for
+ * details on the nature of this error
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Per Bothner
+ * @status updated to 1.4
+ */
+public class SocketException extends IOException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -5935874303556886934L;
+
+  /**
+   * Create a new instance without a descriptive error message.
+   */
+  public SocketException()
+  {
+  }
+
+  /**
+   * Create a new instance with a descriptive error message.
+   *
+   * @param message a message describing the error that occurred
+   */
+  public SocketException(String message)
+  {
+    super(message);
+  }
+} // class SocketException

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,321 @@
+/* SocketImpl.java -- Abstract socket implementation class
+   Copyright (C) 1998, 1999, 2000, 2001, 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.net;
+
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+
+/* Written using on-line Java Platform 1.2 API Specification.
+ * Believed complete and correct.
+ */
+
+/**
+ * This abstract class serves as the parent class for socket implementations.
+ * The implementation class serves an intermediary to native routines that
+ * perform system specific socket operations.
+ * <p>
+ * A default implementation is provided by the system, but this can be
+ * changed via installing a <code>SocketImplFactory</code> (through a call
+ * to the static method <code>Socket.setSocketImplFactory</code>).  A
+ * subclass of <code>Socket</code> can also pass in a <code>SocketImpl</code>
+ * to the <code>Socket(SocketImpl)</code> constructor to use an
+ * implementation different from the system default without installing
+ * a factory.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Per Bothner (bothner at cygnus.com)
+ */
+public abstract class SocketImpl implements SocketOptions
+{
+  /**
+   * The address of the remote end of the socket connection
+   */
+  protected InetAddress address;
+
+  /**
+   * A FileDescriptor object representing this socket connection.
+   */
+  protected FileDescriptor fd;
+
+  /**
+   * The port number the socket is bound to locally
+   */
+  protected int localport = -1;
+
+  /**
+   * The port number of the remote end of the socket connection
+   */
+  protected int port;
+
+  /**
+   * Default, no-argument constructor for use by subclasses.
+   */
+  public SocketImpl()
+  {
+  }
+
+  /**
+   * Creates a new socket that is not bound to any local address/port and
+   * is not connected to any remote address/port.  This will be created as
+   * a stream socket if the stream parameter is true, or a datagram socket
+   * if the stream parameter is false.
+   *
+   * @param stream true for a stream socket, false for a datagram socket
+   *
+   * @exception IOException If an error occurs
+   */
+  protected abstract void create(boolean stream) throws IOException;
+
+  /**
+   * Connects to the remote hostname and port specified as arguments.
+   *
+   * @param host The remote hostname to connect to
+   * @param port The remote port to connect to
+   *
+   * @exception IOException If an error occurs
+   */
+  protected abstract void connect(String host, int port)
+    throws IOException;
+
+  /**
+   * Connects to the remote address and port specified as arguments.
+   *
+   * @param host The remote address to connect to
+   * @param port The remote port to connect to
+   *
+   * @exception IOException If an error occurs
+   */
+  protected abstract void connect(InetAddress host, int port)
+    throws IOException;
+
+  /**
+   * Connects to the socket to the host specified in address. This
+   * method blocks until successful connected or the timeout occurs.
+   * A timeout of zero means no timout.
+   *
+   * @param address Data of remote host
+   * @param timeout time to wait to stop connecting
+   *
+   * @exception IOException If an error occurs
+   *
+   * @since 1.4
+   */
+  protected abstract void connect(SocketAddress address, int timeout)
+    throws IOException;
+
+  /**
+   * Binds to the specified port on the specified addr.  Note that this addr
+   * must represent a local IP address.
+   * <p>
+   * Note that it is unspecified how to bind to all interfaces on the localhost
+   * (INADDR_ANY).
+   *
+   * @param host The address to bind to
+   * @param port The port number to bind to
+   *
+   * @exception IOException If an error occurs
+   */
+  protected abstract void bind(InetAddress host, int port)
+    throws IOException;
+
+  /**
+   * Starts listening for connections on a socket. The backlog parameter
+   * is how many pending connections will queue up waiting to be serviced
+   * before being accept'ed.  If the queue of pending requests exceeds this
+   * number, additional connections will be refused.
+   *
+   * @param backlog The length of the pending connection queue
+   *
+   * @exception IOException If an error occurs
+   */
+  protected abstract void listen(int backlog) throws IOException;
+
+  /**
+   * Accepts a connection on this socket.
+   *
+   * @param s The implementation object for the accepted connection.
+   *
+   * @exception IOException If an error occurs
+   */
+  protected abstract void accept(SocketImpl s) throws IOException;
+
+  /**
+   * Returns an <code>InputStream</code> object for reading from this socket.
+   *
+   * @return An <code>InputStream</code> for reading from this socket.
+   *
+   * @exception IOException If an error occurs
+   */
+  protected abstract InputStream getInputStream() throws IOException;
+
+  /**
+   * Returns an <code>OutputStream</code> object for writing to this socket
+   *
+   * @return An <code>OutputStream</code> for writing to this socket.
+   *
+   * @exception IOException If an error occurs.
+   */
+  protected abstract OutputStream getOutputStream() throws IOException;
+
+  /**
+   * Returns the number of bytes that the caller can read from this socket
+   * without blocking.
+   *
+   * @return The number of readable bytes before blocking
+   *
+   * @exception IOException If an error occurs
+   */
+  protected abstract int available() throws IOException;
+
+  /**
+   * Closes the socket.  This will normally cause any resources, such as the
+   * InputStream, OutputStream and associated file descriptors  to be freed.
+   * <p>
+   * Note that if the SO_LINGER option is set on this socket, then the
+   * operation could block.
+   *
+   * @exception IOException If an error occurs
+   */
+  protected abstract void close() throws IOException;
+
+  /**
+   * Returns the FileDescriptor objects for this socket.
+   *
+   * @return A FileDescriptor for this socket.
+   */
+  protected FileDescriptor getFileDescriptor()
+  {
+    return fd;
+  }
+
+  /**
+   * Returns the remote address this socket is connected to
+   *
+   * @return The remote address
+   */
+  protected InetAddress getInetAddress()
+  {
+    return address;
+  }
+
+  /**
+   * Returns the remote port this socket is connected to
+   *
+   * @return The remote port
+   */
+  protected int getPort()
+  {
+    return port;
+  }
+
+  /**
+   * Returns true or false when this socket supports sending urgent data
+   * or not.
+   *
+   * @return true if the socket implementation supports sending urgent data,
+   * false otherwise
+   *
+   * @since 1.4
+   */
+  protected boolean supportsUrgentData()
+  {
+    // This method has to be overwritten by socket classes that support
+    // sending urgend data.
+    return false;
+  }
+
+  /**
+   * Sends one byte of urgent data to the socket.
+   *
+   * @param data The byte to send, the low eight bits of it
+   *
+   * @exception IOException If an error occurs
+   *
+   * @since 1.4
+   */
+  protected abstract void sendUrgentData(int data) throws IOException;
+
+  /**
+   * Returns the local port this socket is bound to
+   *
+   * @return The local port
+   */
+  protected int getLocalPort()
+  {
+    return localport;
+  }
+
+  /**
+   * Returns a <code>String</code> representing the remote host and port of
+   * this socket.
+   *
+   * @return A <code>String</code> for this socket.
+   */
+  public String toString()
+  {
+    return "[addr="
+           + ((address == null) ? "0.0.0.0/0.0.0.0" : address.toString())
+           + ",port=" + port + ",localport=" + localport + "]";
+  }
+
+  /**
+   * Shut down the input side of this socket.  Subsequent reads will
+   * return end-of-file.
+   *
+   * @exception IOException if an error occurs
+   */
+  protected void shutdownInput() throws IOException
+  {
+    throw new IOException("Not implemented in this socket class");
+  }
+
+  /**
+   * Shut down the output side of this socket.  Subsequent writes will
+   * fail with an IOException.
+   *
+   * @exception IOException if an error occurs
+   */
+  protected void shutdownOutput() throws IOException
+  {
+    throw new IOException("Not implemented in this socket class");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketImplFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketImplFactory.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,59 @@
+/* SocketImplFactory.java -- Interface to create a SocketImpl object
+   Copyright (C) 1998, 1999, 2000, 2001, 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.net;
+
+
+/** Written using on-line Java Platform 1.2 API Specification.
+  * Status:  Believed complete and correct.
+  */
+/**
+  * This interface defines one method which returns a <code>SocketImpl</code>
+  * object.  This should not be needed by ordinary applications.
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  * @author Per Bothner (bothner at cygnus.com)
+  */
+public interface SocketImplFactory
+{
+  /**
+    * This method returns an instance of the <code>SocketImpl</code> object
+    *
+    * @return A <code>SocketImpl</code> object
+    */
+  SocketImpl createSocketImpl();
+} // interface SocketImplFactory

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketOptions.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketOptions.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,166 @@
+/* SocketOptions.java -- Implements options for sockets (duh!)
+   Copyright (C) 1998, 1999, 2000, 2001,
+                 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.net;
+
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status:  Believed complete and correct.
+ */
+/**
+ * This interface is used by <code>SocketImpl</code> and
+ * <code>DatagramSocketImpl</code> to implement options
+ * on sockets.
+ *
+ * @since 1.2
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status should be completely JDK 1.4 compatible
+ */
+public interface SocketOptions
+{
+  /**
+   * Option id for the SO_KEEPALIVE value
+   * @since 1.3
+   */
+  int SO_KEEPALIVE = 0x8;
+
+  /**
+   * Option id for the SO_LINGER value
+   */
+  int SO_LINGER = 0x80; // 128
+
+  /**
+   * Option id for the SO_TIMEOUT value
+   */
+  int SO_TIMEOUT = 0x1006; // 4102
+
+  /**
+   * Retrieve the local address to which the socket is bound.
+   */
+  int SO_BINDADDR = 0x0F; // 15
+
+  /**
+   * Option id for the send buffer size
+   * @since 1.2
+   */
+  int SO_SNDBUF = 0x1001; // 4097
+
+  /**
+   * Option id for the receive buffer size
+   * @since 1.2
+   */
+  int SO_RCVBUF = 0x1002; // 4098
+
+  /**
+   * Sets the SO_REUSEADDR parameter on a socket
+   */
+  int SO_REUSEADDR = 0x04; // 4
+
+  /**
+   * Sets SO_BROADCAST for a socket
+   * @since 1.4
+   */
+  int SO_BROADCAST = 0x20; // 32
+
+  /**
+   * Sets SO_OOBINLINE for a socket
+   * @since 1.4
+   */
+  int SO_OOBINLINE = 0x1003; // 4099
+
+  /**
+   * Option id for the TCP_NODELAY value
+   */
+  int TCP_NODELAY = 0x01; // 1
+
+  /**
+   * Options id for the IP_MULTICAST_IF value
+   */
+  int IP_MULTICAST_IF = 0x10; // 16
+
+  /**
+   * same as above
+   * @since 1.4
+   */
+  int IP_MULTICAST_IF2 = 0x1F; // 31
+
+  /**
+   * This option enables or disables local loopback of multicast datagrams.
+   * @since 1.4
+   */
+  int IP_MULTICAST_LOOP = 0x12; // 18
+
+  /**
+   * This option sets the type-of-service or traffic class field in the
+   * IP header for a TCP or UDP socket.
+   * @since 1.4
+   */
+  int IP_TOS = 0x03; // 3
+
+  /**
+   * Sets the specified option on a socket to the passed in object.  For
+   * options that take an integer argument, the passed in object is an
+   * <code>Integer</code>.  For options that are set to on or off, the
+   * value passed will be a <code>Boolean</code>.   The <code>optionId</code>
+   * parameter is one of the defined constants in this interface.
+   *
+   * @param optionId The identifier of the option
+   * @param val The value to set the option to
+   *
+   * @exception SocketException If an error occurs
+   */
+  void setOption(int optionId, Object val) throws SocketException;
+
+  /**
+   * Returns the current setting of the specified option.  The
+   * <code>Object</code> returned will be an <code>Integer</code> for options
+   * that have integer values.  For options that are set to on or off, a
+   * <code>Boolean</code> will be returned.   The <code>optionId</code>
+   * parameter is one of the defined constants in this interface.
+   *
+   * @param optionId The option identifier
+   *
+   * @return The current value of the option
+   *
+   * @exception SocketException If an error occurs
+   */
+  Object getOption(int optionId) throws SocketException;
+} // interface SocketOptions

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketPermission.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketPermission.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,634 @@
+/* SocketPermission.java -- Class modeling permissions for socket operations
+   Copyright (C) 1998, 2000, 2001, 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.net;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.util.StringTokenizer;
+
+
+/**
+ * This class models a specific set of permssions for connecting to a
+ * host.  There are two elements to this, the host/port combination and
+ * the permission list.
+ * <p>
+ * The host/port combination is specified as followed
+ * <p>
+ * <pre>
+ * hostname[:[-]port[-[port]]]
+ * </pre>
+ * <p>
+ * The hostname portion can be either a hostname or IP address.  If it is
+ * a hostname, a wildcard is allowed in hostnames.  This wildcard is a "*"
+ * and matches one or more characters.  Only one "*" may appear in the
+ * host and it must be the leftmost character.  For example,
+ * "*.urbanophile.com" matches all hosts in the "urbanophile.com" domain.
+ * <p>
+ * The port portion can be either a single value, or a range of values
+ * treated as inclusive.  The first or the last port value in the range
+ * can be omitted in which case either the minimum or maximum legal
+ * value for a port (respectively) is used by default.  Here are some
+ * examples:
+ * <p><ul>
+ * <li>8080 - Represents port 8080 only</li>
+ * <li>2000-3000 - Represents ports 2000 through 3000 inclusive</li>
+ * <li>-4000 - Represents ports 0 through 4000 inclusive</li>
+ * <li>1024- - Represents ports 1024 through 65535 inclusive</li>
+ * </ul><p>
+ * The permission list is a comma separated list of individual permissions.
+ * These individual permissions are:
+ * <p>
+ * <pre>
+ * accept
+ * connect
+ * listen
+ * resolve
+ * </pre>
+ * <p>
+ * The "listen" permission is only relevant if the host is localhost.  If
+ * any permission at all is specified, then resolve permission is implied to
+ * exist.
+ * <p>
+ * Here are a variety of examples of how to create SocketPermission's
+ * <p><pre>
+ * SocketPermission("www.urbanophile.com", "connect");
+ *   Can connect to any port on www.urbanophile.com
+ * SocketPermission("www.urbanophile.com:80", "connect,accept");
+ *   Can connect to or accept connections from www.urbanophile.com on port 80
+ * SocketPermission("localhost:1024-", "listen,accept,connect");
+ *   Can connect to, accept from, an listen on any local port number 1024
+ *   and up.
+ * SocketPermission("*.edu", "connect");
+ *   Can connect to any host in the edu domain
+ * SocketPermission("197.197.20.1", "accept");
+ *   Can accept connections from 197.197.20.1
+ * </pre><p>
+ *
+ * This class also supports IPv6 addresses.  These should be specified
+ * in either RFC 2732 format or in full uncompressed form.
+ *
+ * @since 1.2
+ *
+ * @author Written by Aaron M. Renn (arenn at urbanophile.com)
+ * @author Extensively modified by Gary Benson (gbenson at redhat.com)
+ */
+public final class SocketPermission extends Permission implements Serializable
+{
+  static final long serialVersionUID = -7204263841984476862L;
+
+  /**
+   * A hostname (possibly wildcarded).  Will be set if and only if
+   * this object was initialized with a hostname.
+   */
+  private transient String hostname = null;
+
+  /**
+   * An IP address (IPv4 or IPv6).  Will be set if and only if this
+   * object was initialized with a single literal IP address.
+   */  
+  private transient InetAddress address = null;
+  
+  /**
+   * A range of ports.
+   */
+  private transient int minport;
+  private transient int maxport;
+
+  /**
+   * Values used for minimum and maximum ports when one or both bounds
+   * are omitted.  This class is essentially independent of the
+   * networking code it describes, so we do not limit ports to the
+   * usual network limits of 1 and 65535.
+   */
+  private static final int MIN_PORT = 0;
+  private static final int MAX_PORT = Integer.MAX_VALUE;
+
+  /**
+   * The actions for which we have permission.  This field is present
+   * to make the serialized form correct and should not be used by
+   * anything other than writeObject: everything else should use
+   * actionmask.
+   */
+  private String actions;
+
+  /**
+   * A bitmask representing the actions for which we have permission.
+   */
+  private transient int actionmask;
+
+  /**
+   * The available actions, in the canonical order required for getActions().
+   */
+  private static final String[] ACTIONS = new String[] {
+    "connect", "listen", "accept", "resolve"};
+
+  /**
+   * Initializes a new instance of <code>SocketPermission</code> with the
+   * specified host/port combination and actions string.
+   *
+   * @param hostport The hostname/port number combination
+   * @param actions The actions string
+   */
+  public SocketPermission(String hostport, String actions)
+  {
+    super(processHostport(hostport));
+
+    setHostPort(getName());
+    setActions(actions);
+  }
+
+  /**
+   * There are two cases in which hostport needs rewriting before
+   * being passed to the superclass constructor.  If hostport is an
+   * empty string then it is substituted with "localhost".  And if
+   * the host part of hostport is a literal IPv6 address in the full
+   * uncompressed form not enclosed with "[" and "]" then we enclose
+   * it with them.
+   */
+  private static String processHostport(String hostport)
+  {
+    if (hostport.length() == 0)
+      return "localhost";
+
+    if (hostport.charAt(0) == '[')
+      return hostport;
+
+    int colons = 0;
+    boolean colon_allowed = true;
+    for (int i = 0; i < hostport.length(); i++)
+      {
+	if (hostport.charAt(i) == ':')
+	  {
+	    if (!colon_allowed)
+	      throw new IllegalArgumentException("Ambiguous hostport part");
+	    colons++;
+	    colon_allowed = false;
+	  }
+	else
+	  colon_allowed = true;
+      }
+
+    switch (colons)
+      {
+      case 0:
+      case 1:
+	// a hostname or IPv4 address
+	return hostport;
+	
+      case 7:
+	// an IPv6 address with no ports
+	return "[" + hostport + "]";
+
+      case 8:
+	// an IPv6 address with ports
+	int last_colon = hostport.lastIndexOf(':');
+	return "[" + hostport.substring(0, last_colon) + "]"
+	  + hostport.substring(last_colon);
+
+      default:
+	throw new IllegalArgumentException("Ambiguous hostport part");
+      }
+  }
+  
+  /**
+   * Parse the hostport argument to the constructor.
+   */
+  private void setHostPort(String hostport)
+  {
+    // Split into host and ports
+    String host, ports;
+    if (hostport.charAt(0) == '[')
+      {
+	// host is a bracketed IPv6 address
+	int end = hostport.indexOf("]");
+	if (end == -1)
+	  throw new IllegalArgumentException("Unmatched '['");
+	host = hostport.substring(1, end);
+
+	address = InetAddress.getByLiteral(host);
+	if (address == null)
+	  throw new IllegalArgumentException("Bad IPv6 address");
+
+	if (end == hostport.length() - 1)
+	  ports = "";
+	else if (hostport.charAt(end + 1) == ':')
+	  ports = hostport.substring(end + 2);
+	else
+	  throw new IllegalArgumentException("Bad character after ']'");
+      }
+    else
+      {
+	// host is a hostname or IPv4 address
+	int sep = hostport.indexOf(":");
+	if (sep == -1)
+	  {
+	    host = hostport;
+	    ports = "";
+	  }
+	else
+	  {
+	    host = hostport.substring(0, sep);
+	    ports = hostport.substring(sep + 1);
+	  }
+
+	address = InetAddress.getByLiteral(host);
+	if (address == null)
+	  {
+	    if (host.lastIndexOf('*') > 0)
+	      throw new IllegalArgumentException("Bad hostname");
+
+	    hostname = host;
+	  }
+      }
+
+    // Parse and validate the ports
+    if (ports.length() == 0)
+      {
+	minport = MIN_PORT;
+	maxport = MAX_PORT;
+      }
+    else
+      {
+	int sep = ports.indexOf("-");
+	if (sep == -1)
+	  {
+	    // a single port
+	    minport = maxport = Integer.parseInt(ports);
+	  }
+	else
+	  {
+	    if (ports.indexOf("-", sep + 1) != -1)
+	      throw new IllegalArgumentException("Unexpected '-'");
+
+	    if (sep == 0)
+	      {
+		// an upper bound
+		minport = MIN_PORT;
+		maxport = Integer.parseInt(ports.substring(1));
+	      }
+	    else if (sep == ports.length() - 1)
+	      {
+		// a lower bound
+		minport =
+		  Integer.parseInt(ports.substring(0, ports.length() - 1));
+		maxport = MAX_PORT;
+	      }
+	    else
+	      {
+		// a range with two bounds
+		minport = Integer.parseInt(ports.substring(0, sep));
+		maxport = Integer.parseInt(ports.substring(sep + 1));
+	      }
+	  }
+      }
+  }
+  
+  /**
+   * Parse the actions argument to the constructor.
+   */
+  private void setActions(String actionstring)
+  {
+    actionmask = 0;
+
+    boolean resolve_needed = false;
+    boolean resolve_present = false;
+    
+    StringTokenizer t = new StringTokenizer(actionstring, ",");
+    while (t.hasMoreTokens())
+      {
+	String action = t.nextToken();
+	action = action.trim().toLowerCase();
+	setAction(action);
+
+	if (action.equals("resolve"))
+	  resolve_present = true;
+	else
+	  resolve_needed = true;
+      }
+
+    if (resolve_needed && !resolve_present)
+      setAction("resolve");
+  }
+
+  /**
+   * Parse one element of the actions argument to the constructor.
+   */
+  private void setAction(String action)
+  {
+    for (int i = 0; i < ACTIONS.length; i++)
+      {
+	if (action.equals(ACTIONS[i]))
+	  {
+	    actionmask |= 1 << i;
+	    return;
+	  }
+      }
+    throw new IllegalArgumentException("Unknown action " + action);
+  }
+
+  /**
+   * Tests this object for equality against another.  This will be true if
+   * and only if the passed object is an instance of
+   * <code>SocketPermission</code> and both its hostname/port combination
+   * and permissions string are identical.
+   *
+   * @param obj The object to test against for equality
+   *
+   * @return <code>true</code> if object is equal to this object,
+   *         <code>false</code> otherwise.
+   */
+  public boolean equals(Object obj)
+  {
+    SocketPermission p;
+
+    if (obj instanceof SocketPermission)
+      p = (SocketPermission) obj;
+    else
+      return false;
+
+    if (p.actionmask != actionmask ||
+	p.minport != minport ||
+	p.maxport != maxport)
+      return false;
+
+    if (address != null)
+      {
+	if (p.address == null)
+	  return false;
+	else
+	  return p.address.equals(address);
+      }
+    else
+      {
+	if (p.hostname == null)
+	  return false;
+	else
+	  return p.hostname.equals(hostname);
+      }
+  }
+
+  /**
+   * Returns a hash code value for this object.  Overrides the
+   * <code>Permission.hashCode()</code>.
+   *
+   * @return A hash code
+   */
+  public int hashCode()
+  {
+    int code = actionmask + minport + maxport;
+    if (address != null)
+      code += address.hashCode();
+    else
+      code += hostname.hashCode();
+    return code;
+  }
+
+  /**
+   * Returns the list of permission actions in this object in canonical
+   * order.  The canonical order is "connect,listen,accept,resolve"
+   *
+   * @return The permitted action string.
+   */
+  public String getActions()
+  {
+    StringBuffer sb = new StringBuffer("");
+
+    for (int i = 0; i < ACTIONS.length; i++)
+      {
+	if ((actionmask & (1 << i)) != 0)
+	  {
+	    if (sb.length() != 0)
+	      sb.append(",");
+	    sb.append(ACTIONS[i]);
+	  }
+      }
+
+    return sb.toString();
+  }
+
+  /**
+   * Returns a new <code>PermissionCollection</code> object that can hold
+   * <code>SocketPermission</code>'s.
+   *
+   * @return A new <code>PermissionCollection</code>.
+   */
+  public PermissionCollection newPermissionCollection()
+  {
+    // FIXME: Implement
+
+    return null;
+  }
+
+  /**
+   * Returns an array of all IP addresses represented by this object.
+   */
+  private InetAddress[] getAddresses()
+  {
+    if (address != null)
+      return new InetAddress[] {address};
+
+    try
+      {
+	return InetAddress.getAllByName(hostname);
+      }
+    catch (UnknownHostException e)
+      {
+	return new InetAddress[0];
+      }
+  }
+
+  /**
+   * Returns the canonical hostname represented by this object,
+   * or null if this object represents a wildcarded domain.
+   */
+  private String getCanonicalHostName()
+  {
+    if (address != null)
+      return address.internalGetCanonicalHostName();
+    if (hostname.charAt(0) == '*')
+      return null;
+    try
+      {
+	return InetAddress.getByName(hostname).internalGetCanonicalHostName();
+      }
+    catch (UnknownHostException e)
+      {
+	return null;
+      }
+  }
+  
+  /**
+   * Returns true if the permission object passed it is implied by the
+   * this permission.  This will be true if:
+   * 
+   * <ul>
+   * <li>The argument is of type <code>SocketPermission</code></li>
+   * <li>The actions list of the argument are in this object's actions</li>
+   * <li>The port range of the argument is within this objects port range</li>
+   * <li>The hostname is equal to or a subset of this objects hostname</li>
+   * </ul>
+   *
+   * <p>The argument's hostname will be a subset of this object's hostname if:</p>
+   * 
+   * <ul>
+   * <li>The argument's hostname or IP address is equal to this object's.</li>
+   * <li>The argument's canonical hostname is equal to this object's.</li>
+   * <li>The argument's canonical name matches this domains hostname with
+   * wildcards</li>
+   * </ul>
+   *
+   * @param perm The <code>Permission</code> to check against
+   *
+   * @return <code>true</code> if the <code>Permission</code> is implied by
+   * this object, <code>false</code> otherwise.
+   */
+  public boolean implies(Permission perm)
+  {
+    SocketPermission p;
+
+    // First make sure we are the right object type
+    if (perm instanceof SocketPermission)
+      p = (SocketPermission) perm;
+    else
+      return false;
+
+    // If p was initialised with an empty hostname then we do not
+    // imply it. This is not part of the spec, but it seems necessary.
+    if (p.hostname != null && p.hostname.length() == 0)
+      return false;
+    
+    // Next check the actions
+    if ((p.actionmask & actionmask) != p.actionmask)
+	return false;
+
+    // Then check the ports
+    if ((p.minport < minport) || (p.maxport > maxport))
+      return false;
+
+    // Finally check the hosts
+    String p_canon = null;
+
+    // Return true if this object was initialized with a single
+    // IP address which one of p's IP addresses is equal to.
+    if (address != null)
+      {
+	InetAddress[] addrs = p.getAddresses();
+	for (int i = 0; i < addrs.length; i++)
+	  {
+	    if (address.equals(addrs[i]))
+	      return true;
+	  }
+      }
+
+    // Return true if this object is a wildcarded domain that
+    // p's canonical name matches.
+    if (hostname != null && hostname.charAt(0) == '*')
+      {
+	p_canon = p.getCanonicalHostName();
+	if (p_canon != null && p_canon.endsWith(hostname.substring(1)))
+	  return true;
+	
+      }
+
+    // Return true if this one of this object's IP addresses
+    // is equal to one of p's.
+    if (address == null)
+      {
+	InetAddress[] addrs = p.getAddresses();
+	InetAddress[] p_addrs = p.getAddresses();
+
+	for (int i = 0; i < addrs.length; i++)
+	  {
+	    for (int j = 0; j < p_addrs.length; j++)
+	      {
+		if (addrs[i].equals(p_addrs[j]))
+		  return true;
+	      }
+	  }
+      }
+
+    // Return true if this object's canonical name equals p's.
+    String canon = getCanonicalHostName();
+    if (canon != null)
+      {
+	if (p_canon == null)
+	  p_canon = p.getCanonicalHostName();
+	if (p_canon != null && canon.equals(p_canon))
+	  return true;
+      }
+
+    // Didn't make it
+    return false;
+  }
+
+  /**
+   * Deserializes a <code>SocketPermission</code> object from
+   * an input stream.
+   *
+   * @param input the input stream.
+   * @throws IOException if an I/O error occurs in the stream.
+   * @throws ClassNotFoundException if the class of the
+   *         serialized object could not be found.
+   */
+  private void readObject(ObjectInputStream input)
+    throws IOException, ClassNotFoundException
+  {
+    input.defaultReadObject();
+    setHostPort(getName());
+    setActions(actions);
+  }
+
+  /**
+   * Serializes a <code>SocketPermission</code> object to an
+   * output stream.
+   *
+   * @param output the output stream.
+   * @throws IOException if an I/O error occurs in the stream.
+   */
+  private void writeObject(ObjectOutputStream output)
+    throws IOException
+  {
+    actions = getActions();
+    output.defaultWriteObject();
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketTimeoutException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/SocketTimeoutException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* SocketTimeoutException.java -- the socket timed out
+   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.net;
+
+import java.io.InterruptedIOException;
+
+
+/**
+ * This exception signals that a socket read or accept timed out.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public class SocketTimeoutException extends InterruptedIOException
+{
+  /**
+   * Compatible with JDK 1.4+.
+   */
+  private static final long serialVersionUID = -8846654841826352300L;
+
+  /**
+   * Create a new instance without a descriptive error message.
+   */
+  public SocketTimeoutException()
+  {
+  }
+
+  /**
+   * Create a new instance with a descriptive error message.
+   *
+   * @param message a message describing the error that occurred
+   */
+  public SocketTimeoutException(String message)
+  {
+    super(message);
+  }
+} // class SocketTimeoutException

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/net/TODO (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/net/TODO Thu Nov  8 16:56:19 2007
@@ -0,0 +1,24 @@
+-- DNS cache purging.
+
+-- Implement ContentHandler chaining (non-JDK feature)
+
+-- Implement MIME type by file determination chaining using external
+   disk files. (non-JDK feature)
+
+-- Implement determining MIME type from an InputStream
+
+-- Datagram peek()'s
+
+-- Finalize methods for sockets
+
+-- HTTP - caching (supported by JDK?)
+
+-- HTTP - all protocol support beyond basic GET functionality
+
+-- Fix call to Date(String) in URLConnection.getHeaderFieldDate() when
+   I figure out why DateFormat isn't working.
+
+-- Finish off all JDK 1.2 permissions stuff
+
+-- Write URLClassLoader
+





More information about the llvm-commits mailing list