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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/io/StringWriter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/io/StringWriter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,191 @@
+/* StringWriter.java -- Writes bytes to a StringBuffer
+   Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+// Wow is this a dumb class.  CharArrayWriter can do all this and
+// more.  I would redirect all calls to one in fact, but the javadocs say
+// use a StringBuffer so I will comply.
+
+/**
+  * This class writes chars to an internal <code>StringBuffer</code> that
+  * can then be used to retrieve a <code>String</code>.
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  * @author Tom Tromey (tromey at cygnus.com)
+  */
+public class StringWriter extends Writer
+{
+  /**
+   * This is the default size of the buffer if the user doesn't specify it.
+   * @specnote The JCL Volume 1 says that 16 is the default size.
+   */
+  private static final int DEFAULT_BUFFER_SIZE = 16;
+
+  /**
+   * This method closes the stream.  The contents of the internal buffer
+   * can still be retrieved, but future writes are not guaranteed to work.
+   *
+   * @exception IOException If an error orrurs.
+   */
+  public void close () throws IOException
+  {
+    // JCL says this does nothing.  This seems to violate the Writer
+    // contract, in that other methods should still throw an
+    // IOException after a close.  Still, we just follow JCL.
+  }
+
+  /**
+   * This method flushes any buffered characters to the underlying output.
+   * It does nothing in this class.
+   */
+  public void flush ()
+  {
+  }
+
+  /**
+   * This method returns the <code>StringBuffer</code> object that this
+   * object is writing to.  Note that this is the actual internal buffer, so
+   * any operations performed on it will affect this stream object.
+   *
+   * @return The <code>StringBuffer</code> object being written to
+   */
+  public StringBuffer getBuffer ()
+  {
+    return buffer;
+  }
+
+  /**
+   * This method initializes a new <code>StringWriter</code> to write to a
+   * <code>StringBuffer</code> initially sized to a default size of 16
+   * chars.
+   */
+  public StringWriter ()
+  {
+    this (DEFAULT_BUFFER_SIZE);
+  }
+
+  /**
+   * This method initializes a new <code>StringWriter</code> to write to a
+   * <code>StringBuffer</code> with the specified initial size.
+   *
+   * @param size The initial size to make the <code>StringBuffer</code>
+   */
+  public StringWriter (int size)
+  {
+    super ();
+    buffer = new StringBuffer (size);
+    lock = buffer;
+  }
+
+  /**
+   * This method returns the contents of the internal <code>StringBuffer</code>
+   * as a <code>String</code>.
+   *
+   * @return A <code>String</code> representing the chars written to
+   * this stream. 
+   */
+  public String toString ()
+  {
+    return buffer.toString();
+  }
+
+  /**
+   * This method writes a single character to the output, storing it in
+   * the internal buffer.
+   *
+   * @param oneChar The <code>char</code> to write, passed as an int.
+   */
+  public void write (int oneChar)
+  {
+    buffer.append((char) (oneChar & 0xFFFF));
+  }
+
+  /**
+   * This method writes <code>len</code> chars from the specified
+   * array starting at index <code>offset</code> in that array to this
+   * stream by appending the chars to the end of the internal buffer.
+   *
+   * @param chars The array of chars to write
+   * @param offset The index into the array to start writing from
+   * @param len The number of chars to write
+   */
+  public void write (char[] chars, int offset, int len)
+  {
+    buffer.append(chars, offset, len);
+  }
+
+  /**
+   * This method writes the characters in the specified <code>String</code>
+   * to the stream by appending them to the end of the internal buffer.
+   *
+   * @param str The <code>String</code> to write to the stream.
+   */
+  public void write (String str)
+  {
+    buffer.append(str);
+  }
+
+  /**
+   * This method writes out <code>len</code> characters of the specified
+   * <code>String</code> to the stream starting at character position
+   * <code>offset</code> into the stream.  This is done by appending the
+   * characters to the internal buffer.
+   *
+   * @param str The <code>String</code> to write characters from
+   * @param offset The character position to start writing from
+   * @param len The number of characters to write.
+   */ 
+  public void write (String str, int offset, int len)
+  {
+//      char[] tmpbuf = new char[len];
+//      str.getChars(offset, offset+len, tmpbuf, 0);
+//      buf.append(tmpbuf, 0, tmpbuf.length);
+    // This implementation assumes that String.substring is more
+    // efficient than using String.getChars and copying the data
+    // twice.  For libgcj, this is true.  For Classpath, it is not.
+    // FIXME.
+    buffer.append(str.substring(offset, offset + len));
+  }
+
+  /**
+   * This is the <code>StringBuffer</code> that we use to store bytes that
+   * are written.
+   */
+  private StringBuffer buffer;
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/io/SyncFailedException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/io/SyncFailedException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,66 @@
+/* SyncFailedException.java -- a file sync failed
+   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.io;
+
+/**
+ * Thrown when a file synchronization fails.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @see FileDescriptor#sync()
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class SyncFailedException extends IOException
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = -2353342684412443330L;
+
+  /**
+   * Create an exception with a descriptive error message.
+   *
+   * @param message the descriptive error message
+   */
+  public SyncFailedException(String message)
+  {
+    super(message);
+  }
+} // class SyncFailedException

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/io/UTFDataFormatException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/io/UTFDataFormatException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* UTFDataFormatException.java -- thrown on bad format in UTF data
+   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.io;
+
+/**
+ * When reading a UTF string from an input stream, this exception is thrown
+ * to indicate that the data read is invalid.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @see DataInput
+ * @see DataInputStream#readUTF(DataInput)
+ * @status updated to 1.4
+ */
+public class UTFDataFormatException extends IOException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 420743449228280612L;
+
+  /**
+   * Create a new UTFDataFormatException without a descriptive error message.
+   */
+  public UTFDataFormatException()
+  {
+  }
+
+  /**
+   * Create a new UTFDataFormatException with a descriptive error message.
+   *
+   * @param message the descriptive error message
+   */
+  public UTFDataFormatException(String message)
+  {
+    super(message);
+  }
+} // class UTFDataFormatException

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/io/UnsupportedEncodingException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/io/UnsupportedEncodingException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* UnsupportedEncodingException.java -- the requested encoding isn't 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.io;
+
+/**
+ * This exception is thrown when the requested character encoding is 
+ * not supported.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Per Bothner (bothner at cygnus.com)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class UnsupportedEncodingException extends IOException
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = -4274276298326136670L;
+
+  /**
+   * Create an exception without a descriptive error message.
+   */
+  public UnsupportedEncodingException()
+  {
+  }
+
+  /**
+   * Create an exception with a descriptive error message.
+   *
+   * @param message the descriptive error message
+   */
+  public UnsupportedEncodingException(String message)
+  {
+    super(message);
+  }
+} // class UnsupportedEncodingException

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/io/WriteAbortedException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/io/WriteAbortedException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,109 @@
+/* WriteAbortedException.java -- wraps an exception thrown while writing
+   Copyright (C) 1998, 2000, 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+/**
+  * This exception is thrown when another ObjectStreamException occurs during
+  * a serialization read or write. The stream is reset, and deserialized
+  * objects are discarded.
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  * @author Eric Blake (ebb9 at email.byu.edu)
+  * @since 1.1
+  * @status updated to 1.4
+  */
+public class WriteAbortedException extends ObjectStreamException
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = -3326426625597282442L;
+
+  /**
+   * The cause of this exception. This pre-dates the exception chaining
+   * of Throwable; and although you can change this field, you are wiser
+   * to leave it alone.
+   *
+   * @serial the exception cause
+   */
+  public Exception detail;
+
+  /**
+   * Create a new WriteAbortedException with a specified message and
+   * cause.
+   *
+   * @param msg the message
+   * @param detail the cause
+   */
+  public WriteAbortedException(String msg, Exception detail)
+  {
+    super(msg);
+    initCause(detail);
+    this.detail = detail;
+  }
+
+  /**
+   * This method returns a message indicating what went wrong, in this
+   * format:
+   * <code>super.getMessage() + (detail == null ? "" : "; " + detail)</code>.
+   *
+   * @return the chained message
+   */
+  public String getMessage()
+  {
+    if (detail == this || detail == null)
+      return super.getMessage();
+    return super.getMessage() + "; " + detail;
+  }
+
+  /**
+   * Returns the cause of this exception. Note that this may not be the
+   * original cause, thanks to the <code>detail</code> field being public
+   * and non-final (yuck). However, to avoid violating the contract of
+   * Throwable.getCause(), this returns null if <code>detail == this</code>,
+   * as no exception can be its own cause.
+   *
+   * @return the cause
+   * @since 1.4
+   */
+  public Throwable getCause()
+  {
+    return detail == this ? null : detail;
+  }
+} // class WriteAbortedException

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/io/Writer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/io/Writer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,192 @@
+/* Writer.java -- Base class for character output streams
+   Copyright (C) 1998, 1999, 2001, 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.io;
+
+/* Written using "Java Class Libraries", 2nd edition, plus online
+ * API docs for JDK 1.2 beta from http://www.javasoft.com.
+ * Status:  Believed complete and correct.
+ */
+
+/**
+ * This abstract class forms the base of the hierarchy of classes that 
+ * write output as a stream of chars.  It provides a common set of methods
+ * for writing chars to stream.  Subclasses implement and/or extend these
+ * methods to write chars in a particular manner or to a particular 
+ * destination such as a file on disk or network connection.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Per Bothner (bothner at cygnus.com)
+ */
+public abstract class Writer
+{
+  /**
+   * This is the object used to synchronize criticial code sections for
+   * thread safety.  Subclasses should use this field instead of using
+   * synchronized methods or explicity synchronizations on <code>this</code>
+   */
+  protected Object lock;
+
+  /**
+   * This is the default no-argument constructor for this class.  This method
+   * will set up the class to synchronize criticial sections on itself.
+   */
+  protected Writer()
+  {
+    lock = this;
+  }
+
+  /**
+   * This method initializes a <code>Writer</code> that will synchronize
+   * on the specified <code>Object</code>.
+   *
+   * @param lock The <code>Object</code> to use for synchronizing critical
+   *             sections. Must not be null.
+   */
+  protected Writer(Object lock)
+  {
+    if (lock == null)
+      throw new NullPointerException();
+
+    this.lock = lock;
+  }
+
+  /**
+   * This method forces any data that may have been buffered to be written
+   * to the underlying output device.  Please note that the host environment
+   * might perform its own buffering unbeknowst to Java.  In that case, a
+   * write made (for example, to a disk drive) might be cached in OS
+   * buffers instead of actually being written to disk.
+   *
+   * @exception IOException If an error occurs
+   */
+  public abstract void flush() throws IOException;
+
+  /**
+   * This method closes the stream.  Any internal or native resources 
+   * associated
+   * with this stream are freed.  Any subsequent attempt to access the stream
+   * might throw an exception.
+   * <p>
+   * This method in this class does nothing.
+   *
+   * @exception IOException If an error occurs
+   */
+  public abstract void close() throws IOException;
+
+  /**
+   * This method writes a single char to the output stream. 
+   *
+   * @param b The char to be written to the output stream, passed as an int
+   *
+   * @exception IOException If an error occurs
+   */
+  public void write(int b) throws IOException
+  {
+    char[] buf = new char[1];
+
+    buf[0] = (char)b;
+    write(buf, 0, buf.length);
+  }
+
+  /**
+   * This method all the writes char from the passed array to the output 
+   * stream. This method is equivalent to 
+   * <code>write(buf, 0, buf.length)</code> which
+   * is exactly how it is implemented in this class.
+   *
+   * @param buf The array of char to write
+   *
+   * @exception IOException If an error occurs
+   */
+  public void write(char[] buf) throws IOException
+  {
+    write(buf, 0, buf.length);
+  }
+
+  /**
+   * This method writes <code>len</code> char from the specified array
+   * <code>buf</code> starting at index <code>offset</code> into the array.
+   * <p>
+   * Subclasses must provide an implementation of this abstract method.
+   *
+   * @param buf The array of char to write from
+   * @param offset The index into the array to start writing from
+   * @param len The number of char to write
+   * 
+   * @exception IOException If an error occurs
+   */
+  public abstract void write(char[] buf, int offset, int len) 
+    throws IOException;
+
+  /**
+   * This method writes all the characters in a <code>String</code> to the
+   * output.
+   *
+   * @param str The <code>String</code> whose chars are to be written.
+   *
+   * @exception IOException If an error occurs
+   */
+  public void write(String str) throws IOException
+  {
+    write(str, 0, str.length());
+  } 
+
+  /**
+   * This method writes <code>len</code> chars from the <code>String</code>
+   * starting at position <code>offset</code>.
+   *
+   * @param str The <code>String</code> that is to be written
+   * @param offset The character offset into the <code>String</code> to start
+   *               writing from
+   * @param len The number of chars to write
+   *
+   * @exception IOException If an error occurs
+   */
+  public void write(String str, int offset, int len) throws IOException
+  {
+    // FIXME - for libgcj re-write using native code to not require 
+    // copied buffer.
+    char[] buf = new char[len];
+
+    str.getChars(offset, offset + len, buf, 0);
+    write(buf, 0, len);
+  }
+
+} // class Writer
+

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/io/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/io/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.io 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.io</title></head>
+
+<body>
+<p>Classes for manipulating character and byte streams and files.</p>
+
+</body>
+</html>

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/AbstractMethodError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/AbstractMethodError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* AbstractMethodError.java -- thrown if an abstract method is invoked
+   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;
+
+/**
+ * An <code>AbstractMethodError</code> is thrown when an application attempts
+ * to access an abstract method.  Compilers typically detect this error, but
+ * it can be thrown at run time if the definition of a class has changed
+ * since the application was last compiled. This can also occur when
+ * reflecting on methods.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public class AbstractMethodError extends IncompatibleClassChangeError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -1654391082989018462L;
+
+  /**
+   * Create an error without a message.
+   */
+  public AbstractMethodError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public AbstractMethodError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Appendable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Appendable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,122 @@
+/* Appendable.java -- Something to which characters can be appended
+   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;
+
+import java.io.IOException;
+
+/**
+ * <p>
+ * An <code>Appendable</code> object is one to which a sequence of Unicode
+ * characters can be added.  The appended characters must be valid Unicode
+ * characters, and may include supplementary characters, composed of multiple
+ * 16-bit <code>char</code> values.
+ * </p>
+ * <p>
+ * The behaviour of the <code>Appendable</code> object is heavily dependent
+ * on the particular implementation being used.  Some implementations may be
+ * thread-safe, while others may not.  Likewise, some implementing classes
+ * may produce errors which aren't propogated to the invoking class, due
+ * to differences in the error handling used.
+ * </p>
+ * <p>
+ * <strong>Note</strong>: implementation of this interface is required for
+ * any class that wishes to receive data from a <code>Formatter</code>
+ * instance.
+ * </p>
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+public interface Appendable
+{
+
+  /**
+   * Appends the Unicode character, c, to this <code>Appendable</code>
+   * object.
+   *
+   * @param c the character to append.
+   * @return a reference to this object.
+   * @throws IOException if an I/O error occurs.
+   */
+  Appendable append(char c)
+    throws IOException;
+
+  /**
+   * Appends the specified sequence of Unicode characters to this
+   * <code>Appendable</code> object.  The entire sequence may not
+   * be appended, if constrained by the underlying implementation.
+   * For example, a buffer may reach its size limit before the entire
+   * sequence is appended.
+   *
+   * @param seq the character sequence to append.  If seq is null,
+   *        then the string "null" (the string representation of null)
+   *        is appended.
+   * @return a reference to this object.
+   * @throws IOException if an I/O error occurs.
+   */
+  Appendable append(CharSequence seq)
+    throws IOException;
+
+  /**
+   * Appends the specified subsequence of Unicode characters to this
+   * <code>Appendable</code> object, starting and ending at the specified
+   * positions within the sequence.  The entire sequence may not
+   * be appended, if constrained by the underlying implementation.
+   * For example, a buffer may reach its size limit before the entire
+   * sequence is appended.  The behaviour of this method matches the
+   * behaviour of <code>append(seq.subSequence(start,end))</code> when
+   * the sequence is not null.
+   *
+   * @param seq the character sequence to append.  If seq is null,
+   *        then the string "null" (the string representation of null)
+   *        is appended.
+   * @param start the index of the first Unicode character to use from
+   *        the sequence.
+   * @param end the index of the last Unicode character to use from the
+   *        sequence.
+   * @return a reference to this object.
+   * @throws IOException if an I/O error occurs.
+   * @throws IndexOutOfBoundsException if either of the indices are negative,
+   *         the start index occurs after the end index, or the end index is
+   *         beyond the end of the sequence.
+   */
+  Appendable append(CharSequence seq, int start, int end)
+    throws IOException;
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ArithmeticException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ArithmeticException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,77 @@
+/* ArithmeticException.java -- exception thrown to indicate conditions
+   like divide by zero.
+   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;
+
+/**
+ * Thrown when a math error has occured, such as trying to divide an
+ * integer by zero. For example:<br>
+ * <pre>
+ * int i = 0;
+ * int j = 2 / i;
+ * </pre>
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class ArithmeticException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 2256477558314496007L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public ArithmeticException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public ArithmeticException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ArrayIndexOutOfBoundsException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ArrayIndexOutOfBoundsException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,87 @@
+/* ArrayIndexOutOfBoundsException.java -- exception thrown when accessing
+   an illegal index.
+   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;
+
+/**
+ * Thrown when attempting to access a position outside the valid range of
+ * an array. For example:<br>
+ * <pre>
+ * int[] i = { 1 };
+ * i[1] = 2;
+ * </pre>
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -5116101128118950844L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public ArrayIndexOutOfBoundsException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public ArrayIndexOutOfBoundsException(String s)
+  {
+    super(s);
+  }
+
+  /**
+   * Create an exception indicating the illegal index.
+   *
+   * @param index the invalid index
+   */
+  public ArrayIndexOutOfBoundsException(int index)
+  {
+    super("Array index out of range: " + index);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ArrayStoreException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ArrayStoreException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,77 @@
+/* ArrayStoreException.java -- exception thrown to when trying to store an
+   object into an array of a different type.
+   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;
+
+/**
+ * Thrown when trying to store an object of the wrong runtime type in an
+ * array. For example:<br>
+ * <pre>
+ * Object[] o = new Integer[1];
+ * o[0] = "oops";
+ * </pre>
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class ArrayStoreException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -4522193890499838241L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public ArrayStoreException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public ArrayStoreException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/AssertionError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/AssertionError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,148 @@
+/* AssertionError.java -- indication of a failed assertion
+   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang;
+
+/**
+ * An assertion error normally occurs as a result of the <code>assert</code>
+ * statement added in JDK 1.4, to indicate that an assertion failed. There
+ * are enough constructors to ensure that
+ * <code>new AssertionError(<em>expression</em>)</code> will work for all
+ * expressions, regardless of type, as if the error message were given by
+ * the string <code>"" + <em>expression</em></code>. This extends Error,
+ * because you usually do not want to inadvertently trap an assertion failure.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public class AssertionError extends Error
+{
+  /**
+   * Compatible with JDK 1.4+.
+   */
+  private static final long serialVersionUID = -5013299493970297370L;
+
+  /**
+   * Construct an AssertionError with no detail message.
+   */
+  public AssertionError()
+  {
+  }
+
+  /**
+   * Construct an AssertionError with the string conversion of the given
+   * object as its error message. If the object is a Throwable, it is also
+   * set as the cause of this error.
+   *
+   * @param msg the source of the error message
+   * @see Throwable#getCause()
+   */
+  public AssertionError(Object msg)
+  {
+    super("" + msg);
+    if (msg instanceof Throwable)
+      initCause((Throwable) msg);
+  }
+
+  /**
+   * Construct an AssertionError with the string conversion of the given
+   * boolean as its error message.
+   *
+   * @param msg the source of the error message
+   */
+  public AssertionError(boolean msg)
+  {
+    super(msg ? "true" : "false");
+  }
+
+  /**
+   * Construct an AssertionError with the string conversion of the given
+   * char as its error message.
+   *
+   * @param msg the source of the error message
+   */
+  public AssertionError(char msg)
+  {
+    super(String.valueOf(msg));
+  }
+
+  /**
+   * Construct an AssertionError with the string conversion of the given
+   * int as its error message.
+   *
+   * @param msg the source of the error message
+   */
+  public AssertionError(int msg)
+  {
+    super(Integer.toString(msg, 10));
+  }
+
+  /**
+   * Construct an AssertionError with the string conversion of the given
+   * long as its error message.
+   *
+   * @param msg the source of the error message
+   */
+  public AssertionError(long msg)
+  {
+    super(Long.toString(msg));
+  }
+
+  /**
+   * Construct an AssertionError with the string conversion of the given
+   * float as its error message.
+   *
+   * @param msg the source of the error message
+   */
+  public AssertionError(float msg)
+  {
+    super(Float.toString(msg));
+  }
+
+  /**
+   * Construct an AssertionError with the string conversion of the given
+   * double as its error message.
+   *
+   * @param msg the source of the error message
+   */
+  public AssertionError(double msg)
+  {
+    super(Double.toString(msg));
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Boolean.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Boolean.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,259 @@
+/* Boolean.java -- object wrapper for boolean
+   Copyright (C) 1998, 2001, 2002, 2005, 2006  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang;
+
+import java.io.Serializable;
+
+/**
+ * Instances of class <code>Boolean</code> represent primitive
+ * <code>boolean</code> values.
+ *
+ * @author Paul Fisher
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status updated to 1.5
+ */
+public final class Boolean implements Serializable, Comparable
+{
+  /**
+   * Compatible with JDK 1.0.2+.
+   */
+  private static final long serialVersionUID = -3665804199014368530L;
+
+  /**
+   * This field is a <code>Boolean</code> object representing the
+   * primitive value <code>true</code>. This instance is returned
+   * by the static <code>valueOf()</code> methods if they return
+   * a <code>Boolean</code> representing <code>true</code>.
+   */
+  public static final Boolean TRUE = new Boolean(true);
+
+  /**
+   * This field is a <code>Boolean</code> object representing the
+   * primitive value <code>false</code>. This instance is returned
+   * by the static <code>valueOf()</code> methods if they return
+   * a <code>Boolean</code> representing <code>false</code>.
+   */
+  public static final Boolean FALSE = new Boolean(false);
+
+  /**
+   * The primitive type <code>boolean</code> is represented by this
+   * <code>Class</code> object.
+   *
+   * @since 1.1
+   */
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('Z');
+
+  /**
+   * The immutable value of this Boolean.
+   * @serial the wrapped value
+   */
+  private final boolean value;
+
+  /**
+   * Create a <code>Boolean</code> object representing the value of the
+   * argument <code>value</code>. In general the use of the static
+   * method <code>valueof(boolean)</code> is more efficient since it will
+   * not create a new object.
+   *
+   * @param value the primitive value of this <code>Boolean</code>
+   * @see #valueOf(boolean)
+   */
+  public Boolean(boolean value)
+  {
+    this.value = value;
+  }
+
+  /**
+   * Creates a <code>Boolean</code> object representing the primitive
+   * <code>true</code> if and only if <code>s</code> matches
+   * the string "true" ignoring case, otherwise the object will represent
+   * the primitive <code>false</code>. In general the use of the static
+   * method <code>valueof(String)</code> is more efficient since it will
+   * not create a new object.
+   *
+   * @param s the <code>String</code> representation of <code>true</code>
+   *        or false
+   */
+  public Boolean(String s)
+  {
+    value = "true".equalsIgnoreCase(s);
+  }
+
+  /**
+   * Return the primitive <code>boolean</code> value of this
+   * <code>Boolean</code> object.
+   *
+   * @return true or false, depending on the value of this Boolean
+   */
+  public boolean booleanValue()
+  {
+    return value;
+  }
+
+  /**
+   * Returns the Boolean <code>TRUE</code> if the given boolean is
+   * <code>true</code>, otherwise it will return the Boolean
+   * <code>FALSE</code>.
+   *
+   * @param b the boolean to wrap
+   * @return the wrapper object
+   * @see #TRUE
+   * @see #FALSE
+   * @since 1.4
+   */
+  public static Boolean valueOf(boolean b)
+  {
+    return b ? TRUE : FALSE;
+  }
+
+  /**
+   * Returns the Boolean <code>TRUE</code> if and only if the given
+   * String is equal, ignoring case, to the the String "true", otherwise
+   * it will return the Boolean <code>FALSE</code>.
+   *
+   * @param s the string to convert
+   * @return a wrapped boolean from the string
+   */
+  public static Boolean valueOf(String s)
+  {
+    return "true".equalsIgnoreCase(s) ? TRUE : FALSE;
+  }
+
+  /**
+   * Returns "true" if the value of the give boolean is <code>true</code> and
+   * returns "false" if the value of the given boolean is <code>false</code>.
+   *
+   * @param b the boolean to convert
+   * @return the string representation of the boolean
+   * @since 1.4
+   */
+  public static String toString(boolean b)
+  {
+    return b ? "true" : "false";
+  }
+
+  /**
+   * Returns "true" if the value of this object is <code>true</code> and
+   * returns "false" if the value of this object is <code>false</code>.
+   *
+   * @return the string representation of this
+   */
+  public String toString()
+  {
+    return value ? "true" : "false";
+  }
+
+  /**
+   * Returns the integer <code>1231</code> if this object represents
+   * the primitive <code>true</code> and the integer <code>1237</code>
+   * otherwise.
+   *
+   * @return the hash code
+   */
+  public int hashCode()
+  {
+    return value ? 1231 : 1237;
+  }
+
+  /**
+   * If the <code>obj</code> is an instance of <code>Boolean</code> and
+   * has the same primitive value as this object then <code>true</code>
+   * is returned.  In all other cases, including if the <code>obj</code>
+   * is <code>null</code>, <code>false</code> is returned.
+   *
+   * @param obj possibly an instance of any <code>Class</code>
+   * @return true if <code>obj</code> equals this
+   */
+  public boolean equals(Object obj)
+  {
+    return obj instanceof Boolean && value == ((Boolean) obj).value;
+  }
+
+  /**
+   * If the value of the system property <code>name</code> matches
+   * "true" ignoring case then the function returns <code>true</code>.
+   *
+   * @param name the property name to look up
+   * @return true if the property resulted in "true"
+   * @throws SecurityException if accessing the system property is forbidden
+   * @see System#getProperty(String)
+   */
+  public static boolean getBoolean(String name)
+  {
+    if (name == null || "".equals(name))
+      return false;
+    return "true".equalsIgnoreCase(System.getProperty(name));
+  }
+
+  /**
+   * Compares this Boolean to another.
+   *
+   * @param other the Boolean to compare this Boolean to
+   * @return 0 if both Booleans represent the same value, a positive number 
+   * if this Boolean represents true and the other false, and a negative
+   * number otherwise.
+   * @since 1.5
+   */
+  public int compareTo(Boolean other)
+  {
+    return value == other.value ? 0 : (value ? 1 : -1);
+  }
+
+  /**
+   * Bridge method
+   */
+  public int compareTo(Object other)
+  {
+    return compareTo((Boolean)other);
+  }
+
+  /**
+   * If the String argument is "true", ignoring case, return true.
+   * Otherwise, return false.
+   *
+   * @param b String to parse
+   * @since 1.5
+   */
+  public static boolean parseBoolean(String b)
+  {
+    return "true".equalsIgnoreCase(b) ? true : false;
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Byte.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Byte.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,387 @@
+/* Byte.java -- object wrapper for byte
+   Copyright (C) 1998, 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;
+
+/**
+ * Instances of class <code>Byte</code> represent primitive <code>byte</code>
+ * values.
+ *
+ * Additionally, this class provides various helper functions and variables
+ * useful to bytes.
+ *
+ * @author Paul Fisher
+ * @author John Keiser
+ * @author Per Bothner
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.1
+ * @status updated to 1.5
+ */
+public final class Byte extends Number implements Comparable
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = -7183698231559129828L;
+
+  /**
+   * The minimum value a <code>byte</code> can represent is -128 (or
+   * -2<sup>7</sup>).
+   */
+  public static final byte MIN_VALUE = -128;
+
+  /**
+   * The maximum value a <code>byte</code> can represent is 127 (or
+   * 2<sup>7</sup> - 1).
+   */
+  public static final byte MAX_VALUE = 127;
+
+  /**
+   * The primitive type <code>byte</code> is represented by this
+   * <code>Class</code> object.
+   */
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('B');
+
+  /**
+   * The number of bits needed to represent a <code>byte</code>.
+   * @since 1.5
+   */
+  public static final int SIZE = 8;
+
+  // This caches Byte values, and is used by boxing conversions via
+  // valueOf().  We're required to cache all possible values here.
+  private static Byte[] byteCache = new Byte[MAX_VALUE - MIN_VALUE + 1];
+
+  /**
+   * The immutable value of this Byte.
+   *
+   * @serial the wrapped byte
+   */
+  private final byte value;
+
+  /**
+   * Create a <code>Byte</code> object representing the value of the
+   * <code>byte</code> argument.
+   *
+   * @param value the value to use
+   */
+  public Byte(byte value)
+  {
+    this.value = value;
+  }
+
+  /**
+   * Create a <code>Byte</code> object representing the value specified
+   * by the <code>String</code> argument
+   *
+   * @param s the string to convert
+   * @throws NumberFormatException if the String does not contain a byte
+   * @see #valueOf(String)
+   */
+  public Byte(String s)
+  {
+    value = parseByte(s, 10);
+  }
+
+  /**
+   * Converts the <code>byte</code> to a <code>String</code> and assumes
+   * a radix of 10.
+   *
+   * @param b the <code>byte</code> to convert to <code>String</code>
+   * @return the <code>String</code> representation of the argument
+   */
+  public static String toString(byte b)
+  {
+    return String.valueOf(b);
+  }
+
+  /**
+   * Converts the specified <code>String</code> into a <code>byte</code>.
+   * This function assumes a radix of 10.
+   *
+   * @param s the <code>String</code> to convert
+   * @return the <code>byte</code> value of <code>s</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>byte</code>
+   * @see #parseByte(String)
+   */
+  public static byte parseByte(String s)
+  {
+    return parseByte(s, 10);
+  }
+
+  /**
+   * Converts the specified <code>String</code> into an <code>int</code>
+   * using the specified radix (base). The string must not be <code>null</code>
+   * or empty. It may begin with an optional '-', which will negate the answer,
+   * provided that there are also valid digits. Each digit is parsed as if by
+   * <code>Character.digit(d, radix)</code>, and must be in the range
+   * <code>0</code> to <code>radix - 1</code>. Finally, the result must be
+   * within <code>MIN_VALUE</code> to <code>MAX_VALUE</code>, inclusive.
+   * Unlike Double.parseDouble, you may not have a leading '+'.
+   *
+   * @param s the <code>String</code> to convert
+   * @param radix the radix (base) to use in the conversion
+   * @return the <code>String</code> argument converted to <code>byte</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>byte</code>
+   */
+  public static byte parseByte(String s, int radix)
+  {
+    int i = Integer.parseInt(s, radix, false);
+    if ((byte) i != i)
+      throw new NumberFormatException();
+    return (byte) i;
+  }
+
+  /**
+   * Creates a new <code>Byte</code> object using the <code>String</code>
+   * and specified radix (base).
+   *
+   * @param s the <code>String</code> to convert
+   * @param radix the radix (base) to convert with
+   * @return the new <code>Byte</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>byte</code>
+   * @see #parseByte(String, int)
+   */
+  public static Byte valueOf(String s, int radix)
+  {
+    return new Byte(parseByte(s, radix));
+  }
+
+  /**
+   * Creates a new <code>Byte</code> object using the <code>String</code>,
+   * assuming a radix of 10.
+   *
+   * @param s the <code>String</code> to convert
+   * @return the new <code>Byte</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>byte</code>
+   * @see #Byte(String)
+   * @see #parseByte(String)
+   */
+  public static Byte valueOf(String s)
+  {
+    return new Byte(parseByte(s, 10));
+  }
+
+  /**
+   * Returns a <code>Byte</code> object wrapping the value.
+   * In contrast to the <code>Byte</code> constructor, this method
+   * will cache some values.  It is used by boxing conversion.
+   *
+   * @param val the value to wrap
+   * @return the <code>Byte</code>
+   * 
+   * @since 1.5
+   */
+  public static Byte valueOf(byte val)
+  {
+    synchronized (byteCache)
+      {
+    if (byteCache[val - MIN_VALUE] == null)
+      byteCache[val - MIN_VALUE] = new Byte(val);
+    return byteCache[val - MIN_VALUE];
+      }
+  }
+
+ /**
+   * Convert the specified <code>String</code> into a <code>Byte</code>.
+   * The <code>String</code> may represent decimal, hexadecimal, or
+   * octal numbers.
+   *
+   * <p>The extended BNF grammar is as follows:<br>
+   * <pre>
+   * <em>DecodableString</em>:
+   *      ( [ <code>-</code> ] <em>DecimalNumber</em> )
+   *    | ( [ <code>-</code> ] ( <code>0x</code> | <code>0X</code>
+   *              | <code>#</code> ) { <em>HexDigit</em> }+ )
+   *    | ( [ <code>-</code> ] <code>0</code> { <em>OctalDigit</em> } )
+   * <em>DecimalNumber</em>:
+   *        <em>DecimalDigit except '0'</em> { <em>DecimalDigit</em> }
+   * <em>DecimalDigit</em>:
+   *        <em>Character.digit(d, 10) has value 0 to 9</em>
+   * <em>OctalDigit</em>:
+   *        <em>Character.digit(d, 8) has value 0 to 7</em>
+   * <em>DecimalDigit</em>:
+   *        <em>Character.digit(d, 16) has value 0 to 15</em>
+   * </pre>
+   * Finally, the value must be in the range <code>MIN_VALUE</code> to
+   * <code>MAX_VALUE</code>, or an exception is thrown.
+   *
+   * @param s the <code>String</code> to interpret
+   * @return the value of the String as a <code>Byte</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>byte</code>
+   * @throws NullPointerException if <code>s</code> is null
+   * @see Integer#decode(String)
+   */
+  public static Byte decode(String s)
+  {
+    int i = Integer.parseInt(s, 10, true);
+    if ((byte) i != i)
+      throw new NumberFormatException();
+    return new Byte((byte) i);
+  }
+
+  /**
+   * Return the value of this <code>Byte</code>.
+   *
+   * @return the byte value
+   */
+  public byte byteValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Byte</code> as a <code>short</code>.
+   *
+   * @return the short value
+   */
+  public short shortValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Byte</code> as an <code>int</code>.
+   *
+   * @return the int value
+   */
+  public int intValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Byte</code> as a <code>long</code>.
+   *
+   * @return the long value
+   */
+  public long longValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Byte</code> as a <code>float</code>.
+   *
+   * @return the float value
+   */
+  public float floatValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Byte</code> as a <code>double</code>.
+   *
+   * @return the double value
+   */
+  public double doubleValue()
+  {
+    return value;
+  }
+
+  /**
+   * Converts the <code>Byte</code> value to a <code>String</code> and
+   * assumes a radix of 10.
+   *
+   * @return the <code>String</code> representation of this <code>Byte</code>
+   * @see Integer#toString()
+   */
+  public String toString()
+  {
+    return String.valueOf(value);
+  }
+
+  /**
+   * Return a hashcode representing this Object. <code>Byte</code>'s hash
+   * code is simply its value.
+   *
+   * @return this Object's hash code
+   */
+  public int hashCode()
+  {
+    return value;
+  }
+
+  /**
+   * Returns <code>true</code> if <code>obj</code> is an instance of
+   * <code>Byte</code> and represents the same byte value.
+   *
+   * @param obj the object to compare
+   * @return whether these Objects are semantically equal
+   */
+  public boolean equals(Object obj)
+  {
+    return obj instanceof Byte && value == ((Byte) obj).value;
+  }
+
+  /**
+   * Compare two Bytes numerically by comparing their <code>byte</code> values.
+   * The result is positive if the first is greater, negative if the second
+   * is greater, and 0 if the two are equal.
+   *
+   * @param b the Byte to compare
+   * @return the comparison
+   * @since 1.2
+   */
+  public int compareTo(Byte b)
+  {
+    return value - b.value;
+  }
+
+  /**
+   * Behaves like <code>compareTo(Byte)</code> unless the Object
+   * is not a <code>Byte</code>.
+   *
+   * @param o the object to compare
+   * @return the comparison
+   * @throws ClassCastException if the argument is not a <code>Byte</code>
+   * @see #compareTo(Byte)
+   * @see Comparable
+   * @since 1.2
+   */
+  public int compareTo(Object o)
+  {
+    return compareTo((Byte) o);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/CharSequence.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/CharSequence.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,99 @@
+/* CharSequence.java -- Anything that has an indexed sequence of chars
+   Copyright (C) 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;
+
+/**
+ * General functions on a sequence of chars. This interface is implemented
+ * by <code>String</code>, <code>StringBuffer</code> and
+ * <code>CharBuffer</code> to give a uniform way to get chars at a certain
+ * index, the number of characters in the sequence and a subrange of the
+ * chars. Indexes start at 0 and the last index is <code>length()-1</code>.
+ *
+ * <p>Even when classes implement this interface they are not always
+ * exchangeble because they might implement their compare, equals or hash
+ * function differently. This means that in general one should not use a
+ * <code>CharSequence</code> as keys in collections since two sequences
+ * with the same chars at the same indexes with the same length might not
+ * have the same hash code, be equal or be comparable since the are
+ * represented by different classes.
+ *
+ * @author Mark Wielaard (mark at klomp.org)
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public interface CharSequence
+{
+  /**
+   * Returns the character at the given index.
+   *
+   * @param i the index to retrieve from
+   * @return the character at that location
+   * @throws IndexOutOfBoundsException if i < 0 || i >= length() - 1
+   */
+  char charAt(int i);
+
+  /**
+   * Returns the length of the sequence. This is the number of 16-bit
+   * characters in the sequence, which may differ from the length of the
+   * underlying encoding.
+   *
+   * @return the sequence length
+   */
+  int length();
+
+  /**
+   * Returns a new <code>CharSequence</code> of the indicated range.
+   *
+   * @param begin the start index (inclusive)
+   * @param end the end index (exclusive)
+   * @return a subsequence of this
+   * @throws IndexOutOfBoundsException if begin > end || begin < 0 ||
+   *         end > length()
+   */
+  CharSequence subSequence(int begin, int end);
+
+  /**
+   * Returns the complete <code>CharSequence</code> as a <code>String</code>.
+   * Classes that implement this interface should return a <code>String</code>
+   * which contains only the characters in the sequence in the correct order.
+   *
+   * @return the character sequence as a String
+   */
+  String toString();
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Character.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Character.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,4571 @@
+/* java.lang.Character -- Wrapper class for char, and Unicode subsets
+   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;
+
+import gnu.java.lang.CharData;
+
+import java.io.Serializable;
+import java.text.Collator;
+import java.util.Locale;
+
+/**
+ * Wrapper class for the primitive char data type.  In addition, this class
+ * allows one to retrieve property information and perform transformations
+ * on the defined characters in the Unicode Standard, Version 4.0.0.
+ * java.lang.Character is designed to be very dynamic, and as such, it
+ * retrieves information on the Unicode character set from a separate
+ * database, gnu.java.lang.CharData, which can be easily upgraded.
+ *
+ * <p>For predicates, boundaries are used to describe
+ * the set of characters for which the method will return true.
+ * This syntax uses fairly normal regular expression notation.
+ * See 5.13 of the Unicode Standard, Version 4.0, for the
+ * boundary specification.
+ *
+ * <p>See <a href="http://www.unicode.org">http://www.unicode.org</a>
+ * for more information on the Unicode Standard.
+ *
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Paul N. Fisher
+ * @author Jochen Hoenicke
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see CharData
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public final class Character implements Serializable, Comparable
+{
+  /**
+   * A subset of Unicode blocks.
+   *
+   * @author Paul N. Fisher
+   * @author Eric Blake (ebb9 at email.byu.edu)
+   * @since 1.2
+   */
+  public static class Subset
+  {
+    /** The name of the subset. */
+    private final String name;
+
+    /**
+     * Construct a new subset of characters.
+     *
+     * @param name the name of the subset
+     * @throws NullPointerException if name is null
+     */
+    protected Subset(String name)
+    {
+      // Note that name.toString() is name, unless name was null.
+      this.name = name.toString();
+    }
+
+    /**
+     * Compares two Subsets for equality. This is <code>final</code>, and
+     * restricts the comparison on the <code>==</code> operator, so it returns
+     * true only for the same object.
+     *
+     * @param o the object to compare
+     * @return true if o is this
+     */
+    public final boolean equals(Object o)
+    {
+      return o == this;
+    }
+
+    /**
+     * Makes the original hashCode of Object final, to be consistent with
+     * equals.
+     *
+     * @return the hash code for this object
+     */
+    public final int hashCode()
+    {
+      return super.hashCode();
+    }
+
+    /**
+     * Returns the name of the subset.
+     *
+     * @return the name
+     */
+    public final String toString()
+    {
+      return name;
+    }
+  } // class Subset
+
+  /**
+   * A family of character subsets in the Unicode specification. A character
+   * is in at most one of these blocks.
+   *
+   * This inner class was generated automatically from
+   * <code>doc/unicode/Blocks-4.0.0.txt</code>, by some perl scripts.
+   * This Unicode definition file can be found on the
+   * <a href="http://www.unicode.org">http://www.unicode.org</a> website.
+   * JDK 1.5 uses Unicode version 4.0.0.
+   *
+   * @author scripts/unicode-blocks.pl (written by Eric Blake)
+   * @since 1.2
+   */
+  public static final class UnicodeBlock extends Subset
+  {
+    /** The start of the subset. */
+    private final int start;
+
+    /** The end of the subset. */
+    private final int end;
+
+    /** The canonical name of the block according to the Unicode standard. */
+    private final String canonicalName;
+
+    /** Constants for the <code>forName()</code> method */
+    private static final int CANONICAL_NAME = 0;
+    private static final int NO_SPACES_NAME = 1;
+    private static final int CONSTANT_NAME = 2;
+
+    /**
+     * Constructor for strictly defined blocks.
+     *
+     * @param start the start character of the range
+     * @param end the end character of the range
+     * @param name the block name
+     * @param canonicalName the name of the block as defined in the Unicode
+     *        standard.
+     */
+    private UnicodeBlock(int start, int end, String name,
+             String canonicalName)
+    {
+      super(name);
+      this.start = start;
+      this.end = end;
+      this.canonicalName = canonicalName;
+    }
+
+    /**
+     * Returns the Unicode character block which a character belongs to.
+     * <strong>Note</strong>: This method does not support the use of
+     * supplementary characters.  For such support, <code>of(int)</code>
+     * should be used instead.
+     *
+     * @param ch the character to look up
+     * @return the set it belongs to, or null if it is not in one
+     */
+    public static UnicodeBlock of(char ch)
+    {
+      return of((int) ch);
+    }
+
+    /**
+     * Returns the Unicode character block which a code point belongs to.
+     *
+     * @param codePoint the character to look up
+     * @return the set it belongs to, or null if it is not in one.
+     * @throws IllegalArgumentException if the specified code point is
+     *         invalid.
+     * @since 1.5
+     */
+    public static UnicodeBlock of(int codePoint)
+    {
+      if (codePoint > MAX_CODE_POINT)
+    throw new IllegalArgumentException("The supplied integer value is " +
+                       "too large to be a codepoint.");
+      // Simple binary search for the correct block.
+      int low = 0;
+      int hi = sets.length - 1;
+      while (low <= hi)
+        {
+          int mid = (low + hi) >> 1;
+          UnicodeBlock b = sets[mid];
+          if (codePoint < b.start)
+            hi = mid - 1;
+          else if (codePoint > b.end)
+            low = mid + 1;
+          else
+            return b;
+        }
+      return null;
+    }
+
+    /**
+     * <p>
+     * Returns the <code>UnicodeBlock</code> with the given name, as defined
+     * by the Unicode standard.  The version of Unicode in use is defined by
+     * the <code>Character</code> class, and the names are given in the
+     * <code>Blocks-<version>.txt</code> file corresponding to that version.
+     * The name may be specified in one of three ways:
+     * </p>
+     * <ol>
+     * <li>The canonical, human-readable name used by the Unicode standard.
+     * This is the name with all spaces and hyphens retained.  For example,
+     * `Basic Latin' retrieves the block, UnicodeBlock.BASIC_LATIN.</li>
+     * <li>The canonical name with all spaces removed e.g. `BasicLatin'.</li>
+     * <li>The name used for the constants specified by this class, which
+     * is the canonical name with all spaces and hyphens replaced with
+     * underscores e.g. `BASIC_LATIN'</li>
+     * </ol>
+     * <p>
+     * The names are compared case-insensitively using the case comparison
+     * associated with the U.S. English locale.  The method recognises the
+     * previous names used for blocks as well as the current ones.  At
+     * present, this simply means that the deprecated `SURROGATES_AREA'
+     * will be recognised by this method (the <code>of()</code> methods
+     * only return one of the three new surrogate blocks).
+     * </p>
+     *
+     * @param blockName the name of the block to look up.
+     * @return the specified block.
+     * @throws NullPointerException if the <code>blockName</code> is
+     *         <code>null</code>.
+     * @throws IllegalArgumentException if the name does not match any Unicode
+     *         block.
+     * @since 1.5
+     */
+    public static final UnicodeBlock forName(String blockName)
+    {
+      int type;
+      if (blockName.indexOf(' ') != -1)
+        type = CANONICAL_NAME;
+      else if (blockName.indexOf('_') != -1)
+        type = CONSTANT_NAME;
+      else
+        type = NO_SPACES_NAME;
+      Collator usCollator = Collator.getInstance(Locale.US);
+      usCollator.setStrength(Collator.PRIMARY);
+      /* Special case for deprecated blocks not in sets */
+      switch (type)
+      {
+        case CANONICAL_NAME:
+          if (usCollator.compare(blockName, "Surrogates Area") == 0)
+            return SURROGATES_AREA;
+          break;
+        case NO_SPACES_NAME:
+          if (usCollator.compare(blockName, "SurrogatesArea") == 0)
+            return SURROGATES_AREA;
+          break;
+        case CONSTANT_NAME:
+          if (usCollator.compare(blockName, "SURROGATES_AREA") == 0) 
+            return SURROGATES_AREA;
+          break;
+      }
+      /* Other cases */
+      int setLength = sets.length;
+      switch (type)
+      {
+        case CANONICAL_NAME:
+          for (int i = 0; i < setLength; i++)
+            {
+              UnicodeBlock block = sets[i];
+              if (usCollator.compare(blockName, block.canonicalName) == 0)
+                return block;
+            }
+          break;
+        case NO_SPACES_NAME:
+          for (int i = 0; i < setLength; i++)
+            {
+              UnicodeBlock block = sets[i];
+              String nsName = block.canonicalName.replaceAll(" ","");
+              if (usCollator.compare(blockName, nsName) == 0)
+                return block;
+            }        
+          break;
+        case CONSTANT_NAME:
+          for (int i = 0; i < setLength; i++)
+            {
+              UnicodeBlock block = sets[i];
+              if (usCollator.compare(blockName, block.toString()) == 0)
+                return block;
+            }
+          break;
+      }
+      throw new IllegalArgumentException("No Unicode block found for " +
+                                         blockName + ".");
+    }
+
+    /**
+     * Basic Latin.
+     * 0x0000 - 0x007F.
+     */
+    public static final UnicodeBlock BASIC_LATIN
+      = new UnicodeBlock(0x0000, 0x007F,
+                         "BASIC_LATIN", 
+                         "Basic Latin");
+
+    /**
+     * Latin-1 Supplement.
+     * 0x0080 - 0x00FF.
+     */
+    public static final UnicodeBlock LATIN_1_SUPPLEMENT
+      = new UnicodeBlock(0x0080, 0x00FF,
+                         "LATIN_1_SUPPLEMENT", 
+                         "Latin-1 Supplement");
+
+    /**
+     * Latin Extended-A.
+     * 0x0100 - 0x017F.
+     */
+    public static final UnicodeBlock LATIN_EXTENDED_A
+      = new UnicodeBlock(0x0100, 0x017F,
+                         "LATIN_EXTENDED_A", 
+                         "Latin Extended-A");
+
+    /**
+     * Latin Extended-B.
+     * 0x0180 - 0x024F.
+     */
+    public static final UnicodeBlock LATIN_EXTENDED_B
+      = new UnicodeBlock(0x0180, 0x024F,
+                         "LATIN_EXTENDED_B", 
+                         "Latin Extended-B");
+
+    /**
+     * IPA Extensions.
+     * 0x0250 - 0x02AF.
+     */
+    public static final UnicodeBlock IPA_EXTENSIONS
+      = new UnicodeBlock(0x0250, 0x02AF,
+                         "IPA_EXTENSIONS", 
+                         "IPA Extensions");
+
+    /**
+     * Spacing Modifier Letters.
+     * 0x02B0 - 0x02FF.
+     */
+    public static final UnicodeBlock SPACING_MODIFIER_LETTERS
+      = new UnicodeBlock(0x02B0, 0x02FF,
+                         "SPACING_MODIFIER_LETTERS", 
+                         "Spacing Modifier Letters");
+
+    /**
+     * Combining Diacritical Marks.
+     * 0x0300 - 0x036F.
+     */
+    public static final UnicodeBlock COMBINING_DIACRITICAL_MARKS
+      = new UnicodeBlock(0x0300, 0x036F,
+                         "COMBINING_DIACRITICAL_MARKS", 
+                         "Combining Diacritical Marks");
+
+    /**
+     * Greek.
+     * 0x0370 - 0x03FF.
+     */
+    public static final UnicodeBlock GREEK
+      = new UnicodeBlock(0x0370, 0x03FF,
+                         "GREEK", 
+                         "Greek");
+
+    /**
+     * Cyrillic.
+     * 0x0400 - 0x04FF.
+     */
+    public static final UnicodeBlock CYRILLIC
+      = new UnicodeBlock(0x0400, 0x04FF,
+                         "CYRILLIC", 
+                         "Cyrillic");
+
+    /**
+     * Cyrillic Supplementary.
+     * 0x0500 - 0x052F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock CYRILLIC_SUPPLEMENTARY
+      = new UnicodeBlock(0x0500, 0x052F,
+                         "CYRILLIC_SUPPLEMENTARY", 
+                         "Cyrillic Supplementary");
+
+    /**
+     * Armenian.
+     * 0x0530 - 0x058F.
+     */
+    public static final UnicodeBlock ARMENIAN
+      = new UnicodeBlock(0x0530, 0x058F,
+                         "ARMENIAN", 
+                         "Armenian");
+
+    /**
+     * Hebrew.
+     * 0x0590 - 0x05FF.
+     */
+    public static final UnicodeBlock HEBREW
+      = new UnicodeBlock(0x0590, 0x05FF,
+                         "HEBREW", 
+                         "Hebrew");
+
+    /**
+     * Arabic.
+     * 0x0600 - 0x06FF.
+     */
+    public static final UnicodeBlock ARABIC
+      = new UnicodeBlock(0x0600, 0x06FF,
+                         "ARABIC", 
+                         "Arabic");
+
+    /**
+     * Syriac.
+     * 0x0700 - 0x074F.
+     * @since 1.4
+     */
+    public static final UnicodeBlock SYRIAC
+      = new UnicodeBlock(0x0700, 0x074F,
+                         "SYRIAC", 
+                         "Syriac");
+
+    /**
+     * Thaana.
+     * 0x0780 - 0x07BF.
+     * @since 1.4
+     */
+    public static final UnicodeBlock THAANA
+      = new UnicodeBlock(0x0780, 0x07BF,
+                         "THAANA", 
+                         "Thaana");
+
+    /**
+     * Devanagari.
+     * 0x0900 - 0x097F.
+     */
+    public static final UnicodeBlock DEVANAGARI
+      = new UnicodeBlock(0x0900, 0x097F,
+                         "DEVANAGARI", 
+                         "Devanagari");
+
+    /**
+     * Bengali.
+     * 0x0980 - 0x09FF.
+     */
+    public static final UnicodeBlock BENGALI
+      = new UnicodeBlock(0x0980, 0x09FF,
+                         "BENGALI", 
+                         "Bengali");
+
+    /**
+     * Gurmukhi.
+     * 0x0A00 - 0x0A7F.
+     */
+    public static final UnicodeBlock GURMUKHI
+      = new UnicodeBlock(0x0A00, 0x0A7F,
+                         "GURMUKHI", 
+                         "Gurmukhi");
+
+    /**
+     * Gujarati.
+     * 0x0A80 - 0x0AFF.
+     */
+    public static final UnicodeBlock GUJARATI
+      = new UnicodeBlock(0x0A80, 0x0AFF,
+                         "GUJARATI", 
+                         "Gujarati");
+
+    /**
+     * Oriya.
+     * 0x0B00 - 0x0B7F.
+     */
+    public static final UnicodeBlock ORIYA
+      = new UnicodeBlock(0x0B00, 0x0B7F,
+                         "ORIYA", 
+                         "Oriya");
+
+    /**
+     * Tamil.
+     * 0x0B80 - 0x0BFF.
+     */
+    public static final UnicodeBlock TAMIL
+      = new UnicodeBlock(0x0B80, 0x0BFF,
+                         "TAMIL", 
+                         "Tamil");
+
+    /**
+     * Telugu.
+     * 0x0C00 - 0x0C7F.
+     */
+    public static final UnicodeBlock TELUGU
+      = new UnicodeBlock(0x0C00, 0x0C7F,
+                         "TELUGU", 
+                         "Telugu");
+
+    /**
+     * Kannada.
+     * 0x0C80 - 0x0CFF.
+     */
+    public static final UnicodeBlock KANNADA
+      = new UnicodeBlock(0x0C80, 0x0CFF,
+                         "KANNADA", 
+                         "Kannada");
+
+    /**
+     * Malayalam.
+     * 0x0D00 - 0x0D7F.
+     */
+    public static final UnicodeBlock MALAYALAM
+      = new UnicodeBlock(0x0D00, 0x0D7F,
+                         "MALAYALAM", 
+                         "Malayalam");
+
+    /**
+     * Sinhala.
+     * 0x0D80 - 0x0DFF.
+     * @since 1.4
+     */
+    public static final UnicodeBlock SINHALA
+      = new UnicodeBlock(0x0D80, 0x0DFF,
+                         "SINHALA", 
+                         "Sinhala");
+
+    /**
+     * Thai.
+     * 0x0E00 - 0x0E7F.
+     */
+    public static final UnicodeBlock THAI
+      = new UnicodeBlock(0x0E00, 0x0E7F,
+                         "THAI", 
+                         "Thai");
+
+    /**
+     * Lao.
+     * 0x0E80 - 0x0EFF.
+     */
+    public static final UnicodeBlock LAO
+      = new UnicodeBlock(0x0E80, 0x0EFF,
+                         "LAO", 
+                         "Lao");
+
+    /**
+     * Tibetan.
+     * 0x0F00 - 0x0FFF.
+     */
+    public static final UnicodeBlock TIBETAN
+      = new UnicodeBlock(0x0F00, 0x0FFF,
+                         "TIBETAN", 
+                         "Tibetan");
+
+    /**
+     * Myanmar.
+     * 0x1000 - 0x109F.
+     * @since 1.4
+     */
+    public static final UnicodeBlock MYANMAR
+      = new UnicodeBlock(0x1000, 0x109F,
+                         "MYANMAR", 
+                         "Myanmar");
+
+    /**
+     * Georgian.
+     * 0x10A0 - 0x10FF.
+     */
+    public static final UnicodeBlock GEORGIAN
+      = new UnicodeBlock(0x10A0, 0x10FF,
+                         "GEORGIAN", 
+                         "Georgian");
+
+    /**
+     * Hangul Jamo.
+     * 0x1100 - 0x11FF.
+     */
+    public static final UnicodeBlock HANGUL_JAMO
+      = new UnicodeBlock(0x1100, 0x11FF,
+                         "HANGUL_JAMO", 
+                         "Hangul Jamo");
+
+    /**
+     * Ethiopic.
+     * 0x1200 - 0x137F.
+     * @since 1.4
+     */
+    public static final UnicodeBlock ETHIOPIC
+      = new UnicodeBlock(0x1200, 0x137F,
+                         "ETHIOPIC", 
+                         "Ethiopic");
+
+    /**
+     * Cherokee.
+     * 0x13A0 - 0x13FF.
+     * @since 1.4
+     */
+    public static final UnicodeBlock CHEROKEE
+      = new UnicodeBlock(0x13A0, 0x13FF,
+                         "CHEROKEE", 
+                         "Cherokee");
+
+    /**
+     * Unified Canadian Aboriginal Syllabics.
+     * 0x1400 - 0x167F.
+     * @since 1.4
+     */
+    public static final UnicodeBlock UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS
+      = new UnicodeBlock(0x1400, 0x167F,
+                         "UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS", 
+                         "Unified Canadian Aboriginal Syllabics");
+
+    /**
+     * Ogham.
+     * 0x1680 - 0x169F.
+     * @since 1.4
+     */
+    public static final UnicodeBlock OGHAM
+      = new UnicodeBlock(0x1680, 0x169F,
+                         "OGHAM", 
+                         "Ogham");
+
+    /**
+     * Runic.
+     * 0x16A0 - 0x16FF.
+     * @since 1.4
+     */
+    public static final UnicodeBlock RUNIC
+      = new UnicodeBlock(0x16A0, 0x16FF,
+                         "RUNIC", 
+                         "Runic");
+
+    /**
+     * Tagalog.
+     * 0x1700 - 0x171F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock TAGALOG
+      = new UnicodeBlock(0x1700, 0x171F,
+                         "TAGALOG", 
+                         "Tagalog");
+
+    /**
+     * Hanunoo.
+     * 0x1720 - 0x173F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock HANUNOO
+      = new UnicodeBlock(0x1720, 0x173F,
+                         "HANUNOO", 
+                         "Hanunoo");
+
+    /**
+     * Buhid.
+     * 0x1740 - 0x175F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock BUHID
+      = new UnicodeBlock(0x1740, 0x175F,
+                         "BUHID", 
+                         "Buhid");
+
+    /**
+     * Tagbanwa.
+     * 0x1760 - 0x177F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock TAGBANWA
+      = new UnicodeBlock(0x1760, 0x177F,
+                         "TAGBANWA", 
+                         "Tagbanwa");
+
+    /**
+     * Khmer.
+     * 0x1780 - 0x17FF.
+     * @since 1.4
+     */
+    public static final UnicodeBlock KHMER
+      = new UnicodeBlock(0x1780, 0x17FF,
+                         "KHMER", 
+                         "Khmer");
+
+    /**
+     * Mongolian.
+     * 0x1800 - 0x18AF.
+     * @since 1.4
+     */
+    public static final UnicodeBlock MONGOLIAN
+      = new UnicodeBlock(0x1800, 0x18AF,
+                         "MONGOLIAN", 
+                         "Mongolian");
+
+    /**
+     * Limbu.
+     * 0x1900 - 0x194F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock LIMBU
+      = new UnicodeBlock(0x1900, 0x194F,
+                         "LIMBU", 
+                         "Limbu");
+
+    /**
+     * Tai Le.
+     * 0x1950 - 0x197F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock TAI_LE
+      = new UnicodeBlock(0x1950, 0x197F,
+                         "TAI_LE", 
+                         "Tai Le");
+
+    /**
+     * Khmer Symbols.
+     * 0x19E0 - 0x19FF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock KHMER_SYMBOLS
+      = new UnicodeBlock(0x19E0, 0x19FF,
+                         "KHMER_SYMBOLS", 
+                         "Khmer Symbols");
+
+    /**
+     * Phonetic Extensions.
+     * 0x1D00 - 0x1D7F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock PHONETIC_EXTENSIONS
+      = new UnicodeBlock(0x1D00, 0x1D7F,
+                         "PHONETIC_EXTENSIONS", 
+                         "Phonetic Extensions");
+
+    /**
+     * Latin Extended Additional.
+     * 0x1E00 - 0x1EFF.
+     */
+    public static final UnicodeBlock LATIN_EXTENDED_ADDITIONAL
+      = new UnicodeBlock(0x1E00, 0x1EFF,
+                         "LATIN_EXTENDED_ADDITIONAL", 
+                         "Latin Extended Additional");
+
+    /**
+     * Greek Extended.
+     * 0x1F00 - 0x1FFF.
+     */
+    public static final UnicodeBlock GREEK_EXTENDED
+      = new UnicodeBlock(0x1F00, 0x1FFF,
+                         "GREEK_EXTENDED", 
+                         "Greek Extended");
+
+    /**
+     * General Punctuation.
+     * 0x2000 - 0x206F.
+     */
+    public static final UnicodeBlock GENERAL_PUNCTUATION
+      = new UnicodeBlock(0x2000, 0x206F,
+                         "GENERAL_PUNCTUATION", 
+                         "General Punctuation");
+
+    /**
+     * Superscripts and Subscripts.
+     * 0x2070 - 0x209F.
+     */
+    public static final UnicodeBlock SUPERSCRIPTS_AND_SUBSCRIPTS
+      = new UnicodeBlock(0x2070, 0x209F,
+                         "SUPERSCRIPTS_AND_SUBSCRIPTS", 
+                         "Superscripts and Subscripts");
+
+    /**
+     * Currency Symbols.
+     * 0x20A0 - 0x20CF.
+     */
+    public static final UnicodeBlock CURRENCY_SYMBOLS
+      = new UnicodeBlock(0x20A0, 0x20CF,
+                         "CURRENCY_SYMBOLS", 
+                         "Currency Symbols");
+
+    /**
+     * Combining Marks for Symbols.
+     * 0x20D0 - 0x20FF.
+     */
+    public static final UnicodeBlock COMBINING_MARKS_FOR_SYMBOLS
+      = new UnicodeBlock(0x20D0, 0x20FF,
+                         "COMBINING_MARKS_FOR_SYMBOLS", 
+                         "Combining Marks for Symbols");
+
+    /**
+     * Letterlike Symbols.
+     * 0x2100 - 0x214F.
+     */
+    public static final UnicodeBlock LETTERLIKE_SYMBOLS
+      = new UnicodeBlock(0x2100, 0x214F,
+                         "LETTERLIKE_SYMBOLS", 
+                         "Letterlike Symbols");
+
+    /**
+     * Number Forms.
+     * 0x2150 - 0x218F.
+     */
+    public static final UnicodeBlock NUMBER_FORMS
+      = new UnicodeBlock(0x2150, 0x218F,
+                         "NUMBER_FORMS", 
+                         "Number Forms");
+
+    /**
+     * Arrows.
+     * 0x2190 - 0x21FF.
+     */
+    public static final UnicodeBlock ARROWS
+      = new UnicodeBlock(0x2190, 0x21FF,
+                         "ARROWS", 
+                         "Arrows");
+
+    /**
+     * Mathematical Operators.
+     * 0x2200 - 0x22FF.
+     */
+    public static final UnicodeBlock MATHEMATICAL_OPERATORS
+      = new UnicodeBlock(0x2200, 0x22FF,
+                         "MATHEMATICAL_OPERATORS", 
+                         "Mathematical Operators");
+
+    /**
+     * Miscellaneous Technical.
+     * 0x2300 - 0x23FF.
+     */
+    public static final UnicodeBlock MISCELLANEOUS_TECHNICAL
+      = new UnicodeBlock(0x2300, 0x23FF,
+                         "MISCELLANEOUS_TECHNICAL", 
+                         "Miscellaneous Technical");
+
+    /**
+     * Control Pictures.
+     * 0x2400 - 0x243F.
+     */
+    public static final UnicodeBlock CONTROL_PICTURES
+      = new UnicodeBlock(0x2400, 0x243F,
+                         "CONTROL_PICTURES", 
+                         "Control Pictures");
+
+    /**
+     * Optical Character Recognition.
+     * 0x2440 - 0x245F.
+     */
+    public static final UnicodeBlock OPTICAL_CHARACTER_RECOGNITION
+      = new UnicodeBlock(0x2440, 0x245F,
+                         "OPTICAL_CHARACTER_RECOGNITION", 
+                         "Optical Character Recognition");
+
+    /**
+     * Enclosed Alphanumerics.
+     * 0x2460 - 0x24FF.
+     */
+    public static final UnicodeBlock ENCLOSED_ALPHANUMERICS
+      = new UnicodeBlock(0x2460, 0x24FF,
+                         "ENCLOSED_ALPHANUMERICS", 
+                         "Enclosed Alphanumerics");
+
+    /**
+     * Box Drawing.
+     * 0x2500 - 0x257F.
+     */
+    public static final UnicodeBlock BOX_DRAWING
+      = new UnicodeBlock(0x2500, 0x257F,
+                         "BOX_DRAWING", 
+                         "Box Drawing");
+
+    /**
+     * Block Elements.
+     * 0x2580 - 0x259F.
+     */
+    public static final UnicodeBlock BLOCK_ELEMENTS
+      = new UnicodeBlock(0x2580, 0x259F,
+                         "BLOCK_ELEMENTS", 
+                         "Block Elements");
+
+    /**
+     * Geometric Shapes.
+     * 0x25A0 - 0x25FF.
+     */
+    public static final UnicodeBlock GEOMETRIC_SHAPES
+      = new UnicodeBlock(0x25A0, 0x25FF,
+                         "GEOMETRIC_SHAPES", 
+                         "Geometric Shapes");
+
+    /**
+     * Miscellaneous Symbols.
+     * 0x2600 - 0x26FF.
+     */
+    public static final UnicodeBlock MISCELLANEOUS_SYMBOLS
+      = new UnicodeBlock(0x2600, 0x26FF,
+                         "MISCELLANEOUS_SYMBOLS", 
+                         "Miscellaneous Symbols");
+
+    /**
+     * Dingbats.
+     * 0x2700 - 0x27BF.
+     */
+    public static final UnicodeBlock DINGBATS
+      = new UnicodeBlock(0x2700, 0x27BF,
+                         "DINGBATS", 
+                         "Dingbats");
+
+    /**
+     * Miscellaneous Mathematical Symbols-A.
+     * 0x27C0 - 0x27EF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A
+      = new UnicodeBlock(0x27C0, 0x27EF,
+                         "MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A", 
+                         "Miscellaneous Mathematical Symbols-A");
+
+    /**
+     * Supplemental Arrows-A.
+     * 0x27F0 - 0x27FF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock SUPPLEMENTAL_ARROWS_A
+      = new UnicodeBlock(0x27F0, 0x27FF,
+                         "SUPPLEMENTAL_ARROWS_A", 
+                         "Supplemental Arrows-A");
+
+    /**
+     * Braille Patterns.
+     * 0x2800 - 0x28FF.
+     * @since 1.4
+     */
+    public static final UnicodeBlock BRAILLE_PATTERNS
+      = new UnicodeBlock(0x2800, 0x28FF,
+                         "BRAILLE_PATTERNS", 
+                         "Braille Patterns");
+
+    /**
+     * Supplemental Arrows-B.
+     * 0x2900 - 0x297F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock SUPPLEMENTAL_ARROWS_B
+      = new UnicodeBlock(0x2900, 0x297F,
+                         "SUPPLEMENTAL_ARROWS_B", 
+                         "Supplemental Arrows-B");
+
+    /**
+     * Miscellaneous Mathematical Symbols-B.
+     * 0x2980 - 0x29FF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B
+      = new UnicodeBlock(0x2980, 0x29FF,
+                         "MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B", 
+                         "Miscellaneous Mathematical Symbols-B");
+
+    /**
+     * Supplemental Mathematical Operators.
+     * 0x2A00 - 0x2AFF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock SUPPLEMENTAL_MATHEMATICAL_OPERATORS
+      = new UnicodeBlock(0x2A00, 0x2AFF,
+                         "SUPPLEMENTAL_MATHEMATICAL_OPERATORS", 
+                         "Supplemental Mathematical Operators");
+
+    /**
+     * Miscellaneous Symbols and Arrows.
+     * 0x2B00 - 0x2BFF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock MISCELLANEOUS_SYMBOLS_AND_ARROWS
+      = new UnicodeBlock(0x2B00, 0x2BFF,
+                         "MISCELLANEOUS_SYMBOLS_AND_ARROWS", 
+                         "Miscellaneous Symbols and Arrows");
+
+    /**
+     * CJK Radicals Supplement.
+     * 0x2E80 - 0x2EFF.
+     * @since 1.4
+     */
+    public static final UnicodeBlock CJK_RADICALS_SUPPLEMENT
+      = new UnicodeBlock(0x2E80, 0x2EFF,
+                         "CJK_RADICALS_SUPPLEMENT", 
+                         "CJK Radicals Supplement");
+
+    /**
+     * Kangxi Radicals.
+     * 0x2F00 - 0x2FDF.
+     * @since 1.4
+     */
+    public static final UnicodeBlock KANGXI_RADICALS
+      = new UnicodeBlock(0x2F00, 0x2FDF,
+                         "KANGXI_RADICALS", 
+                         "Kangxi Radicals");
+
+    /**
+     * Ideographic Description Characters.
+     * 0x2FF0 - 0x2FFF.
+     * @since 1.4
+     */
+    public static final UnicodeBlock IDEOGRAPHIC_DESCRIPTION_CHARACTERS
+      = new UnicodeBlock(0x2FF0, 0x2FFF,
+                         "IDEOGRAPHIC_DESCRIPTION_CHARACTERS", 
+                         "Ideographic Description Characters");
+
+    /**
+     * CJK Symbols and Punctuation.
+     * 0x3000 - 0x303F.
+     */
+    public static final UnicodeBlock CJK_SYMBOLS_AND_PUNCTUATION
+      = new UnicodeBlock(0x3000, 0x303F,
+                         "CJK_SYMBOLS_AND_PUNCTUATION", 
+                         "CJK Symbols and Punctuation");
+
+    /**
+     * Hiragana.
+     * 0x3040 - 0x309F.
+     */
+    public static final UnicodeBlock HIRAGANA
+      = new UnicodeBlock(0x3040, 0x309F,
+                         "HIRAGANA", 
+                         "Hiragana");
+
+    /**
+     * Katakana.
+     * 0x30A0 - 0x30FF.
+     */
+    public static final UnicodeBlock KATAKANA
+      = new UnicodeBlock(0x30A0, 0x30FF,
+                         "KATAKANA", 
+                         "Katakana");
+
+    /**
+     * Bopomofo.
+     * 0x3100 - 0x312F.
+     */
+    public static final UnicodeBlock BOPOMOFO
+      = new UnicodeBlock(0x3100, 0x312F,
+                         "BOPOMOFO", 
+                         "Bopomofo");
+
+    /**
+     * Hangul Compatibility Jamo.
+     * 0x3130 - 0x318F.
+     */
+    public static final UnicodeBlock HANGUL_COMPATIBILITY_JAMO
+      = new UnicodeBlock(0x3130, 0x318F,
+                         "HANGUL_COMPATIBILITY_JAMO", 
+                         "Hangul Compatibility Jamo");
+
+    /**
+     * Kanbun.
+     * 0x3190 - 0x319F.
+     */
+    public static final UnicodeBlock KANBUN
+      = new UnicodeBlock(0x3190, 0x319F,
+                         "KANBUN", 
+                         "Kanbun");
+
+    /**
+     * Bopomofo Extended.
+     * 0x31A0 - 0x31BF.
+     * @since 1.4
+     */
+    public static final UnicodeBlock BOPOMOFO_EXTENDED
+      = new UnicodeBlock(0x31A0, 0x31BF,
+                         "BOPOMOFO_EXTENDED", 
+                         "Bopomofo Extended");
+
+    /**
+     * Katakana Phonetic Extensions.
+     * 0x31F0 - 0x31FF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock KATAKANA_PHONETIC_EXTENSIONS
+      = new UnicodeBlock(0x31F0, 0x31FF,
+                         "KATAKANA_PHONETIC_EXTENSIONS", 
+                         "Katakana Phonetic Extensions");
+
+    /**
+     * Enclosed CJK Letters and Months.
+     * 0x3200 - 0x32FF.
+     */
+    public static final UnicodeBlock ENCLOSED_CJK_LETTERS_AND_MONTHS
+      = new UnicodeBlock(0x3200, 0x32FF,
+                         "ENCLOSED_CJK_LETTERS_AND_MONTHS", 
+                         "Enclosed CJK Letters and Months");
+
+    /**
+     * CJK Compatibility.
+     * 0x3300 - 0x33FF.
+     */
+    public static final UnicodeBlock CJK_COMPATIBILITY
+      = new UnicodeBlock(0x3300, 0x33FF,
+                         "CJK_COMPATIBILITY", 
+                         "CJK Compatibility");
+
+    /**
+     * CJK Unified Ideographs Extension A.
+     * 0x3400 - 0x4DBF.
+     * @since 1.4
+     */
+    public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
+      = new UnicodeBlock(0x3400, 0x4DBF,
+                         "CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A", 
+                         "CJK Unified Ideographs Extension A");
+
+    /**
+     * Yijing Hexagram Symbols.
+     * 0x4DC0 - 0x4DFF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock YIJING_HEXAGRAM_SYMBOLS
+      = new UnicodeBlock(0x4DC0, 0x4DFF,
+                         "YIJING_HEXAGRAM_SYMBOLS", 
+                         "Yijing Hexagram Symbols");
+
+    /**
+     * CJK Unified Ideographs.
+     * 0x4E00 - 0x9FFF.
+     */
+    public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS
+      = new UnicodeBlock(0x4E00, 0x9FFF,
+                         "CJK_UNIFIED_IDEOGRAPHS", 
+                         "CJK Unified Ideographs");
+
+    /**
+     * Yi Syllables.
+     * 0xA000 - 0xA48F.
+     * @since 1.4
+     */
+    public static final UnicodeBlock YI_SYLLABLES
+      = new UnicodeBlock(0xA000, 0xA48F,
+                         "YI_SYLLABLES", 
+                         "Yi Syllables");
+
+    /**
+     * Yi Radicals.
+     * 0xA490 - 0xA4CF.
+     * @since 1.4
+     */
+    public static final UnicodeBlock YI_RADICALS
+      = new UnicodeBlock(0xA490, 0xA4CF,
+                         "YI_RADICALS", 
+                         "Yi Radicals");
+
+    /**
+     * Hangul Syllables.
+     * 0xAC00 - 0xD7AF.
+     */
+    public static final UnicodeBlock HANGUL_SYLLABLES
+      = new UnicodeBlock(0xAC00, 0xD7AF,
+                         "HANGUL_SYLLABLES", 
+                         "Hangul Syllables");
+
+    /**
+     * High Surrogates.
+     * 0xD800 - 0xDB7F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock HIGH_SURROGATES
+      = new UnicodeBlock(0xD800, 0xDB7F,
+                         "HIGH_SURROGATES", 
+                         "High Surrogates");
+
+    /**
+     * High Private Use Surrogates.
+     * 0xDB80 - 0xDBFF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock HIGH_PRIVATE_USE_SURROGATES
+      = new UnicodeBlock(0xDB80, 0xDBFF,
+                         "HIGH_PRIVATE_USE_SURROGATES", 
+                         "High Private Use Surrogates");
+
+    /**
+     * Low Surrogates.
+     * 0xDC00 - 0xDFFF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock LOW_SURROGATES
+      = new UnicodeBlock(0xDC00, 0xDFFF,
+                         "LOW_SURROGATES", 
+                         "Low Surrogates");
+
+    /**
+     * Private Use Area.
+     * 0xE000 - 0xF8FF.
+     */
+    public static final UnicodeBlock PRIVATE_USE_AREA
+      = new UnicodeBlock(0xE000, 0xF8FF,
+                         "PRIVATE_USE_AREA", 
+                         "Private Use Area");
+
+    /**
+     * CJK Compatibility Ideographs.
+     * 0xF900 - 0xFAFF.
+     */
+    public static final UnicodeBlock CJK_COMPATIBILITY_IDEOGRAPHS
+      = new UnicodeBlock(0xF900, 0xFAFF,
+                         "CJK_COMPATIBILITY_IDEOGRAPHS", 
+                         "CJK Compatibility Ideographs");
+
+    /**
+     * Alphabetic Presentation Forms.
+     * 0xFB00 - 0xFB4F.
+     */
+    public static final UnicodeBlock ALPHABETIC_PRESENTATION_FORMS
+      = new UnicodeBlock(0xFB00, 0xFB4F,
+                         "ALPHABETIC_PRESENTATION_FORMS", 
+                         "Alphabetic Presentation Forms");
+
+    /**
+     * Arabic Presentation Forms-A.
+     * 0xFB50 - 0xFDFF.
+     */
+    public static final UnicodeBlock ARABIC_PRESENTATION_FORMS_A
+      = new UnicodeBlock(0xFB50, 0xFDFF,
+                         "ARABIC_PRESENTATION_FORMS_A", 
+                         "Arabic Presentation Forms-A");
+
+    /**
+     * Variation Selectors.
+     * 0xFE00 - 0xFE0F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock VARIATION_SELECTORS
+      = new UnicodeBlock(0xFE00, 0xFE0F,
+                         "VARIATION_SELECTORS", 
+                         "Variation Selectors");
+
+    /**
+     * Combining Half Marks.
+     * 0xFE20 - 0xFE2F.
+     */
+    public static final UnicodeBlock COMBINING_HALF_MARKS
+      = new UnicodeBlock(0xFE20, 0xFE2F,
+                         "COMBINING_HALF_MARKS", 
+                         "Combining Half Marks");
+
+    /**
+     * CJK Compatibility Forms.
+     * 0xFE30 - 0xFE4F.
+     */
+    public static final UnicodeBlock CJK_COMPATIBILITY_FORMS
+      = new UnicodeBlock(0xFE30, 0xFE4F,
+                         "CJK_COMPATIBILITY_FORMS", 
+                         "CJK Compatibility Forms");
+
+    /**
+     * Small Form Variants.
+     * 0xFE50 - 0xFE6F.
+     */
+    public static final UnicodeBlock SMALL_FORM_VARIANTS
+      = new UnicodeBlock(0xFE50, 0xFE6F,
+                         "SMALL_FORM_VARIANTS", 
+                         "Small Form Variants");
+
+    /**
+     * Arabic Presentation Forms-B.
+     * 0xFE70 - 0xFEFF.
+     */
+    public static final UnicodeBlock ARABIC_PRESENTATION_FORMS_B
+      = new UnicodeBlock(0xFE70, 0xFEFF,
+                         "ARABIC_PRESENTATION_FORMS_B", 
+                         "Arabic Presentation Forms-B");
+
+    /**
+     * Halfwidth and Fullwidth Forms.
+     * 0xFF00 - 0xFFEF.
+     */
+    public static final UnicodeBlock HALFWIDTH_AND_FULLWIDTH_FORMS
+      = new UnicodeBlock(0xFF00, 0xFFEF,
+                         "HALFWIDTH_AND_FULLWIDTH_FORMS", 
+                         "Halfwidth and Fullwidth Forms");
+
+    /**
+     * Specials.
+     * 0xFFF0 - 0xFFFF.
+     */
+    public static final UnicodeBlock SPECIALS
+      = new UnicodeBlock(0xFFF0, 0xFFFF,
+                         "SPECIALS", 
+                         "Specials");
+
+    /**
+     * Linear B Syllabary.
+     * 0x10000 - 0x1007F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock LINEAR_B_SYLLABARY
+      = new UnicodeBlock(0x10000, 0x1007F,
+                         "LINEAR_B_SYLLABARY", 
+                         "Linear B Syllabary");
+
+    /**
+     * Linear B Ideograms.
+     * 0x10080 - 0x100FF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock LINEAR_B_IDEOGRAMS
+      = new UnicodeBlock(0x10080, 0x100FF,
+                         "LINEAR_B_IDEOGRAMS", 
+                         "Linear B Ideograms");
+
+    /**
+     * Aegean Numbers.
+     * 0x10100 - 0x1013F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock AEGEAN_NUMBERS
+      = new UnicodeBlock(0x10100, 0x1013F,
+                         "AEGEAN_NUMBERS", 
+                         "Aegean Numbers");
+
+    /**
+     * Old Italic.
+     * 0x10300 - 0x1032F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock OLD_ITALIC
+      = new UnicodeBlock(0x10300, 0x1032F,
+                         "OLD_ITALIC", 
+                         "Old Italic");
+
+    /**
+     * Gothic.
+     * 0x10330 - 0x1034F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock GOTHIC
+      = new UnicodeBlock(0x10330, 0x1034F,
+                         "GOTHIC", 
+                         "Gothic");
+
+    /**
+     * Ugaritic.
+     * 0x10380 - 0x1039F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock UGARITIC
+      = new UnicodeBlock(0x10380, 0x1039F,
+                         "UGARITIC", 
+                         "Ugaritic");
+
+    /**
+     * Deseret.
+     * 0x10400 - 0x1044F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock DESERET
+      = new UnicodeBlock(0x10400, 0x1044F,
+                         "DESERET", 
+                         "Deseret");
+
+    /**
+     * Shavian.
+     * 0x10450 - 0x1047F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock SHAVIAN
+      = new UnicodeBlock(0x10450, 0x1047F,
+                         "SHAVIAN", 
+                         "Shavian");
+
+    /**
+     * Osmanya.
+     * 0x10480 - 0x104AF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock OSMANYA
+      = new UnicodeBlock(0x10480, 0x104AF,
+                         "OSMANYA", 
+                         "Osmanya");
+
+    /**
+     * Cypriot Syllabary.
+     * 0x10800 - 0x1083F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock CYPRIOT_SYLLABARY
+      = new UnicodeBlock(0x10800, 0x1083F,
+                         "CYPRIOT_SYLLABARY", 
+                         "Cypriot Syllabary");
+
+    /**
+     * Byzantine Musical Symbols.
+     * 0x1D000 - 0x1D0FF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock BYZANTINE_MUSICAL_SYMBOLS
+      = new UnicodeBlock(0x1D000, 0x1D0FF,
+                         "BYZANTINE_MUSICAL_SYMBOLS", 
+                         "Byzantine Musical Symbols");
+
+    /**
+     * Musical Symbols.
+     * 0x1D100 - 0x1D1FF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock MUSICAL_SYMBOLS
+      = new UnicodeBlock(0x1D100, 0x1D1FF,
+                         "MUSICAL_SYMBOLS", 
+                         "Musical Symbols");
+
+    /**
+     * Tai Xuan Jing Symbols.
+     * 0x1D300 - 0x1D35F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock TAI_XUAN_JING_SYMBOLS
+      = new UnicodeBlock(0x1D300, 0x1D35F,
+                         "TAI_XUAN_JING_SYMBOLS", 
+                         "Tai Xuan Jing Symbols");
+
+    /**
+     * Mathematical Alphanumeric Symbols.
+     * 0x1D400 - 0x1D7FF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock MATHEMATICAL_ALPHANUMERIC_SYMBOLS
+      = new UnicodeBlock(0x1D400, 0x1D7FF,
+                         "MATHEMATICAL_ALPHANUMERIC_SYMBOLS", 
+                         "Mathematical Alphanumeric Symbols");
+
+    /**
+     * CJK Unified Ideographs Extension B.
+     * 0x20000 - 0x2A6DF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
+      = new UnicodeBlock(0x20000, 0x2A6DF,
+                         "CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B", 
+                         "CJK Unified Ideographs Extension B");
+
+    /**
+     * CJK Compatibility Ideographs Supplement.
+     * 0x2F800 - 0x2FA1F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT
+      = new UnicodeBlock(0x2F800, 0x2FA1F,
+                         "CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT", 
+                         "CJK Compatibility Ideographs Supplement");
+
+    /**
+     * Tags.
+     * 0xE0000 - 0xE007F.
+     * @since 1.5
+     */
+    public static final UnicodeBlock TAGS
+      = new UnicodeBlock(0xE0000, 0xE007F,
+                         "TAGS", 
+                         "Tags");
+
+    /**
+     * Variation Selectors Supplement.
+     * 0xE0100 - 0xE01EF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock VARIATION_SELECTORS_SUPPLEMENT
+      = new UnicodeBlock(0xE0100, 0xE01EF,
+                         "VARIATION_SELECTORS_SUPPLEMENT", 
+                         "Variation Selectors Supplement");
+
+    /**
+     * Supplementary Private Use Area-A.
+     * 0xF0000 - 0xFFFFF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock SUPPLEMENTARY_PRIVATE_USE_AREA_A
+      = new UnicodeBlock(0xF0000, 0xFFFFF,
+                         "SUPPLEMENTARY_PRIVATE_USE_AREA_A", 
+                         "Supplementary Private Use Area-A");
+
+    /**
+     * Supplementary Private Use Area-B.
+     * 0x100000 - 0x10FFFF.
+     * @since 1.5
+     */
+    public static final UnicodeBlock SUPPLEMENTARY_PRIVATE_USE_AREA_B
+      = new UnicodeBlock(0x100000, 0x10FFFF,
+                         "SUPPLEMENTARY_PRIVATE_USE_AREA_B", 
+                         "Supplementary Private Use Area-B");
+
+    /**
+     * Surrogates Area.
+     * 'D800' - 'DFFF'.
+     * @deprecated As of 1.5, the three areas, 
+     * <a href="#HIGH_SURROGATES">HIGH_SURROGATES</a>,
+     * <a href="#HIGH_PRIVATE_USE_SURROGATES">HIGH_PRIVATE_USE_SURROGATES</a>
+     * and <a href="#LOW_SURROGATES">LOW_SURROGATES</a>, as defined
+     * by the Unicode standard, should be used in preference to
+     * this.  These are also returned from calls to <code>of(int)</code>
+     * and <code>of(char)</code>.
+     */
+    public static final UnicodeBlock SURROGATES_AREA
+      = new UnicodeBlock(0xD800, 0xDFFF,
+                         "SURROGATES_AREA",
+             "Surrogates Area");
+
+    /**
+     * The defined subsets.
+     */
+    private static final UnicodeBlock sets[] = {
+      BASIC_LATIN,
+      LATIN_1_SUPPLEMENT,
+      LATIN_EXTENDED_A,
+      LATIN_EXTENDED_B,
+      IPA_EXTENSIONS,
+      SPACING_MODIFIER_LETTERS,
+      COMBINING_DIACRITICAL_MARKS,
+      GREEK,
+      CYRILLIC,
+      CYRILLIC_SUPPLEMENTARY,
+      ARMENIAN,
+      HEBREW,
+      ARABIC,
+      SYRIAC,
+      THAANA,
+      DEVANAGARI,
+      BENGALI,
+      GURMUKHI,
+      GUJARATI,
+      ORIYA,
+      TAMIL,
+      TELUGU,
+      KANNADA,
+      MALAYALAM,
+      SINHALA,
+      THAI,
+      LAO,
+      TIBETAN,
+      MYANMAR,
+      GEORGIAN,
+      HANGUL_JAMO,
+      ETHIOPIC,
+      CHEROKEE,
+      UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS,
+      OGHAM,
+      RUNIC,
+      TAGALOG,
+      HANUNOO,
+      BUHID,
+      TAGBANWA,
+      KHMER,
+      MONGOLIAN,
+      LIMBU,
+      TAI_LE,
+      KHMER_SYMBOLS,
+      PHONETIC_EXTENSIONS,
+      LATIN_EXTENDED_ADDITIONAL,
+      GREEK_EXTENDED,
+      GENERAL_PUNCTUATION,
+      SUPERSCRIPTS_AND_SUBSCRIPTS,
+      CURRENCY_SYMBOLS,
+      COMBINING_MARKS_FOR_SYMBOLS,
+      LETTERLIKE_SYMBOLS,
+      NUMBER_FORMS,
+      ARROWS,
+      MATHEMATICAL_OPERATORS,
+      MISCELLANEOUS_TECHNICAL,
+      CONTROL_PICTURES,
+      OPTICAL_CHARACTER_RECOGNITION,
+      ENCLOSED_ALPHANUMERICS,
+      BOX_DRAWING,
+      BLOCK_ELEMENTS,
+      GEOMETRIC_SHAPES,
+      MISCELLANEOUS_SYMBOLS,
+      DINGBATS,
+      MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A,
+      SUPPLEMENTAL_ARROWS_A,
+      BRAILLE_PATTERNS,
+      SUPPLEMENTAL_ARROWS_B,
+      MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B,
+      SUPPLEMENTAL_MATHEMATICAL_OPERATORS,
+      MISCELLANEOUS_SYMBOLS_AND_ARROWS,
+      CJK_RADICALS_SUPPLEMENT,
+      KANGXI_RADICALS,
+      IDEOGRAPHIC_DESCRIPTION_CHARACTERS,
+      CJK_SYMBOLS_AND_PUNCTUATION,
+      HIRAGANA,
+      KATAKANA,
+      BOPOMOFO,
+      HANGUL_COMPATIBILITY_JAMO,
+      KANBUN,
+      BOPOMOFO_EXTENDED,
+      KATAKANA_PHONETIC_EXTENSIONS,
+      ENCLOSED_CJK_LETTERS_AND_MONTHS,
+      CJK_COMPATIBILITY,
+      CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A,
+      YIJING_HEXAGRAM_SYMBOLS,
+      CJK_UNIFIED_IDEOGRAPHS,
+      YI_SYLLABLES,
+      YI_RADICALS,
+      HANGUL_SYLLABLES,
+      HIGH_SURROGATES,
+      HIGH_PRIVATE_USE_SURROGATES,
+      LOW_SURROGATES,
+      PRIVATE_USE_AREA,
+      CJK_COMPATIBILITY_IDEOGRAPHS,
+      ALPHABETIC_PRESENTATION_FORMS,
+      ARABIC_PRESENTATION_FORMS_A,
+      VARIATION_SELECTORS,
+      COMBINING_HALF_MARKS,
+      CJK_COMPATIBILITY_FORMS,
+      SMALL_FORM_VARIANTS,
+      ARABIC_PRESENTATION_FORMS_B,
+      HALFWIDTH_AND_FULLWIDTH_FORMS,
+      SPECIALS,
+      LINEAR_B_SYLLABARY,
+      LINEAR_B_IDEOGRAMS,
+      AEGEAN_NUMBERS,
+      OLD_ITALIC,
+      GOTHIC,
+      UGARITIC,
+      DESERET,
+      SHAVIAN,
+      OSMANYA,
+      CYPRIOT_SYLLABARY,
+      BYZANTINE_MUSICAL_SYMBOLS,
+      MUSICAL_SYMBOLS,
+      TAI_XUAN_JING_SYMBOLS,
+      MATHEMATICAL_ALPHANUMERIC_SYMBOLS,
+      CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B,
+      CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT,
+      TAGS,
+      VARIATION_SELECTORS_SUPPLEMENT,
+      SUPPLEMENTARY_PRIVATE_USE_AREA_A,
+      SUPPLEMENTARY_PRIVATE_USE_AREA_B,
+    };
+  } // class UnicodeBlock
+
+  /**
+   * A class to encompass all the properties of characters in the 
+   * private use blocks in the Unicode standard.  This class extends
+   * UnassignedCharacters because the return type from getType() is 
+   * different.
+   * @author Anthony Balkissoon abalkiss at redhat dot com
+   *
+   */
+  private static class PrivateUseCharacters extends UnassignedCharacters
+  {
+    /**
+     * Returns the type of the character cp.
+     */
+    static int getType(int cp)
+    {
+      // The upper 2 code points in any plane are considered unassigned, 
+      // even in the private-use planes.
+      if ((cp & 0xffff) >= 0xfffe)
+        return UnassignedCharacters.getType(cp);
+      return PRIVATE_USE;
+    }
+    
+    /**
+     * Returns true if the character cp is defined.
+     */
+    static boolean isDefined(int cp)
+    {
+      // The upper 2 code points in any plane are considered unassigned, 
+      // even in the private-use planes.
+      if ((cp & 0xffff) >= 0xfffe)
+        return UnassignedCharacters.isDefined(cp);
+      return true;
+    }
+    
+    /**
+     * Gets the directionality for the character cp.
+     */
+    static byte getDirectionality(int cp)
+    {
+      if ((cp & 0xffff) >= 0xfffe)
+        return UnassignedCharacters.getDirectionality(cp);
+      return DIRECTIONALITY_LEFT_TO_RIGHT;
+    }
+  }
+  
+  /**
+   * A class to encompass all the properties of code points that are 
+   * currently undefined in the Unicode standard.
+   * @author Anthony Balkissoon abalkiss at redhat dot com
+   *
+   */
+  private static class UnassignedCharacters
+  {
+    /**
+     * Returns the numeric value for the unassigned characters.
+     * @param cp the character
+     * @param radix the radix (not used)
+     * @return the numeric value of this character in this radix
+     */
+    static int digit(int cp, int radix)
+    {
+      return -1;
+    }
+
+    /**
+     * Returns the Unicode directionality property for unassigned 
+     * characters.
+     * @param cp the character
+     * @return DIRECTIONALITY_UNDEFINED
+     */
+    static byte getDirectionality(int cp)
+    {
+      return DIRECTIONALITY_UNDEFINED;
+    }
+
+    /**
+     * Returns -1, the numeric value for unassigned Unicode characters.
+     * @param cp the character
+     * @return -1
+     */
+    static int getNumericValue(int cp)
+    {
+      return -1;
+    }
+
+    /**
+     * Returns UNASSIGNED, the type of unassigned Unicode characters.
+     * @param cp the character
+     * @return UNASSIGNED
+     */
+    static int getType(int cp)
+    {
+      return UNASSIGNED;
+    }
+    
+    /**
+     * Returns false to indiciate that the character is not defined in the 
+     * Unicode standard.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isDefined(int cp)
+    {
+      return false;
+    }
+
+    /**
+     * Returns false to indicate that the character is not a digit.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isDigit(int cp)
+    {
+      return false;
+    }
+
+    /**
+     * Returns false to indicate that the character cannot be ignored 
+     * within an identifier
+     * @param cp the character
+     * @return false
+     */
+    static boolean isIdentifierIgnorable(int cp)
+    {
+      return false;
+    }
+
+    /**
+     * Returns false to indicate that the character cannot be part of a 
+     * Java identifier.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isJavaIdentifierPart(int cp)
+    {
+      return false;
+    }
+
+    /**
+     * Returns false to indicate that the character cannot be start a 
+     * Java identifier.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isJavaIdentiferStart(int cp)
+    {
+      return false;
+    }
+
+    /**
+     * Returns false to indicate that the character is not a letter.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isLetter(int cp)
+    {
+      return false;
+    }
+
+    /**
+     * Returns false to indicate that the character cannot is neither a letter
+     * nor a digit.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isLetterOrDigit(int cp)
+    {
+      return false;
+    }
+
+    /**
+     * Returns false to indicate that the character is not a lowercase letter.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isLowerCase(int cp)
+    {
+      return false;
+    }
+    
+    /**
+     * Returns false to indicate that the character cannot is not mirrored.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isMirrored(int cp)
+    {
+      return false;
+    }
+
+    /**
+     * Returns false to indicate that the character is not a space character.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isSpaceChar(int cp)
+    {
+      return false;
+    }
+    
+    /**
+     * Returns false to indicate that the character it not a titlecase letter.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isTitleCase(int cp)
+    {
+      return false;
+    }
+    
+    /**
+     * Returns false to indicate that the character cannot be part of a 
+     * Unicode identifier.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isUnicodeIdentifierPart(int cp)
+    {
+      return false;
+    }
+
+    /**
+     * Returns false to indicate that the character cannot start a 
+     * Unicode identifier.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isUnicodeIdentifierStart(int cp)
+    {
+      return false;
+    }
+
+    /**
+     * Returns false to indicate that the character is not an uppercase letter.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isUpperCase(int cp)
+    {
+      return false;
+    }
+
+    /**
+     * Returns false to indicate that the character is not a whitespace
+     * character.
+     * @param cp the character
+     * @return false
+     */
+    static boolean isWhiteSpace(int cp)
+    {
+      return false;
+    }
+
+    /**
+     * Returns cp to indicate this character has no lowercase conversion.
+     * @param cp the character
+     * @return cp
+     */
+    static int toLowerCase(int cp)
+    {
+      return cp;
+    }
+    
+    /**
+     * Returns cp to indicate this character has no titlecase conversion.
+     * @param cp the character
+     * @return cp
+     */
+    static int toTitleCase(int cp)
+    {
+      return cp;
+    }
+
+    /**
+     * Returns cp to indicate this character has no uppercase conversion.
+     * @param cp the character
+     * @return cp
+     */
+    static int toUpperCase(int cp)
+    {
+      return cp;
+    }    
+  }
+
+  /**
+   * The immutable value of this Character.
+   *
+   * @serial the value of this Character
+   */
+  private final char value;
+
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 3786198910865385080L;
+
+  /**
+   * Smallest value allowed for radix arguments in Java. This value is 2.
+   *
+   * @see #digit(char, int)
+   * @see #forDigit(int, int)
+   * @see Integer#toString(int, int)
+   * @see Integer#valueOf(String)
+   */
+  public static final int MIN_RADIX = 2;
+
+  /**
+   * Largest value allowed for radix arguments in Java. This value is 36.
+   *
+   * @see #digit(char, int)
+   * @see #forDigit(int, int)
+   * @see Integer#toString(int, int)
+   * @see Integer#valueOf(String)
+   */
+  public static final int MAX_RADIX = 36;
+
+  /**
+   * The minimum value the char data type can hold.
+   * This value is <code>'\\u0000'</code>.
+   */
+  public static final char MIN_VALUE = '\u0000';
+
+  /**
+   * The maximum value the char data type can hold.
+   * This value is <code>'\\uFFFF'</code>.
+   */
+  public static final char MAX_VALUE = '\uFFFF';
+
+  /**
+   * Class object representing the primitive char data type.
+   *
+   * @since 1.1
+   */
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('C');
+
+  /**
+   * The number of bits needed to represent a <code>char</code>.
+   * @since 1.5
+   */
+  public static final int SIZE = 16;
+
+  // This caches some Character values, and is used by boxing
+  // conversions via valueOf().  We must cache at least 0..127;
+  // this constant controls how much we actually cache.
+  private static final int MAX_CACHE = 127;
+  private static Character[] charCache = new Character[MAX_CACHE + 1];
+
+  /**
+   * Lu = Letter, Uppercase (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte UPPERCASE_LETTER = 1;
+
+  /**
+   * Ll = Letter, Lowercase (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte LOWERCASE_LETTER = 2;
+
+  /**
+   * Lt = Letter, Titlecase (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte TITLECASE_LETTER = 3;
+
+  /**
+   * Mn = Mark, Non-Spacing (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte NON_SPACING_MARK = 6;
+
+  /**
+   * Mc = Mark, Spacing Combining (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte COMBINING_SPACING_MARK = 8;
+
+  /**
+   * Me = Mark, Enclosing (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte ENCLOSING_MARK = 7;
+
+  /**
+   * Nd = Number, Decimal Digit (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte DECIMAL_DIGIT_NUMBER = 9;
+
+  /**
+   * Nl = Number, Letter (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte LETTER_NUMBER = 10;
+
+  /**
+   * No = Number, Other (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte OTHER_NUMBER = 11;
+
+  /**
+   * Zs = Separator, Space (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte SPACE_SEPARATOR = 12;
+
+  /**
+   * Zl = Separator, Line (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte LINE_SEPARATOR = 13;
+
+  /**
+   * Zp = Separator, Paragraph (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte PARAGRAPH_SEPARATOR = 14;
+
+  /**
+   * Cc = Other, Control (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte CONTROL = 15;
+
+  /**
+   * Cf = Other, Format (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte FORMAT = 16;
+
+  /**
+   * Cs = Other, Surrogate (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte SURROGATE = 19;
+
+  /**
+   * Co = Other, Private Use (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte PRIVATE_USE = 18;
+
+  /**
+   * Cn = Other, Not Assigned (Normative).
+   *
+   * @since 1.1
+   */
+  public static final byte UNASSIGNED = 0;
+
+  /**
+   * Lm = Letter, Modifier (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte MODIFIER_LETTER = 4;
+
+  /**
+   * Lo = Letter, Other (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte OTHER_LETTER = 5;
+
+  /**
+   * Pc = Punctuation, Connector (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte CONNECTOR_PUNCTUATION = 23;
+
+  /**
+   * Pd = Punctuation, Dash (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte DASH_PUNCTUATION = 20;
+
+  /**
+   * Ps = Punctuation, Open (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte START_PUNCTUATION = 21;
+
+  /**
+   * Pe = Punctuation, Close (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte END_PUNCTUATION = 22;
+
+  /**
+   * Pi = Punctuation, Initial Quote (Informative).
+   *
+   * @since 1.4
+   */
+  public static final byte INITIAL_QUOTE_PUNCTUATION = 29;
+
+  /**
+   * Pf = Punctuation, Final Quote (Informative).
+   *
+   * @since 1.4
+   */
+  public static final byte FINAL_QUOTE_PUNCTUATION = 30;
+
+  /**
+   * Po = Punctuation, Other (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte OTHER_PUNCTUATION = 24;
+
+  /**
+   * Sm = Symbol, Math (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte MATH_SYMBOL = 25;
+
+  /**
+   * Sc = Symbol, Currency (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte CURRENCY_SYMBOL = 26;
+
+  /**
+   * Sk = Symbol, Modifier (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte MODIFIER_SYMBOL = 27;
+
+  /**
+   * So = Symbol, Other (Informative).
+   *
+   * @since 1.1
+   */
+  public static final byte OTHER_SYMBOL = 28;
+
+  /**
+   * Undefined bidirectional character type. Undefined char values have
+   * undefined directionality in the Unicode specification.
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_UNDEFINED = -1;
+
+  /**
+   * Strong bidirectional character type "L".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = 0;
+
+  /**
+   * Strong bidirectional character type "R".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = 1;
+
+  /**
+   * Strong bidirectional character type "AL".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = 2;
+
+  /**
+   * Weak bidirectional character type "EN".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = 3;
+
+  /**
+   * Weak bidirectional character type "ES".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = 4;
+
+  /**
+   * Weak bidirectional character type "ET".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = 5;
+
+  /**
+   * Weak bidirectional character type "AN".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_ARABIC_NUMBER = 6;
+
+  /**
+   * Weak bidirectional character type "CS".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = 7;
+
+  /**
+   * Weak bidirectional character type "NSM".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_NONSPACING_MARK = 8;
+
+  /**
+   * Weak bidirectional character type "BN".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL = 9;
+
+  /**
+   * Neutral bidirectional character type "B".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR = 10;
+
+  /**
+   * Neutral bidirectional character type "S".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR = 11;
+
+  /**
+   * Strong bidirectional character type "WS".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_WHITESPACE = 12;
+
+  /**
+   * Neutral bidirectional character type "ON".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_OTHER_NEUTRALS = 13;
+
+  /**
+   * Strong bidirectional character type "LRE".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = 14;
+
+  /**
+   * Strong bidirectional character type "LRO".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = 15;
+
+  /**
+   * Strong bidirectional character type "RLE".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = 16;
+
+  /**
+   * Strong bidirectional character type "RLO".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = 17;
+
+  /**
+   * Weak bidirectional character type "PDF".
+   *
+   * @since 1.4
+   */
+  public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = 18;
+
+  /**
+   * Stores unicode block offset lookup table. Exploit package visibility of
+   * String.value to avoid copying the array.
+   * @see #readCodePoint(int)
+   * @see CharData#BLOCKS
+   */
+  private static final char[][] blocks = 
+    new char[][]{
+                 String.zeroBasedStringValue(CharData.BLOCKS[0]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[1]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[2]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[3]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[4]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[5]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[6]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[7]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[8]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[9]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[10]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[11]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[12]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[13]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[14]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[15]),
+                 String.zeroBasedStringValue(CharData.BLOCKS[16])};
+
+  /**
+   * Stores unicode attribute offset lookup table. Exploit package visibility
+   * of String.value to avoid copying the array.
+   * @see CharData#DATA
+   */  
+  private static final char[][] data = 
+    new char[][]{
+                 String.zeroBasedStringValue(CharData.DATA[0]),
+                 String.zeroBasedStringValue(CharData.DATA[1]),
+                 String.zeroBasedStringValue(CharData.DATA[2]),
+                 String.zeroBasedStringValue(CharData.DATA[3]),
+                 String.zeroBasedStringValue(CharData.DATA[4]),
+                 String.zeroBasedStringValue(CharData.DATA[5]),
+                 String.zeroBasedStringValue(CharData.DATA[6]),
+                 String.zeroBasedStringValue(CharData.DATA[7]),
+                 String.zeroBasedStringValue(CharData.DATA[8]),
+                 String.zeroBasedStringValue(CharData.DATA[9]),
+                 String.zeroBasedStringValue(CharData.DATA[10]),
+                 String.zeroBasedStringValue(CharData.DATA[11]),
+                 String.zeroBasedStringValue(CharData.DATA[12]),
+                 String.zeroBasedStringValue(CharData.DATA[13]),
+                 String.zeroBasedStringValue(CharData.DATA[14]),
+                 String.zeroBasedStringValue(CharData.DATA[15]),
+                 String.zeroBasedStringValue(CharData.DATA[16])};
+
+  /**
+   * Stores unicode numeric value attribute table. Exploit package visibility
+   * of String.value to avoid copying the array.
+   * @see CharData#NUM_VALUE
+   */
+  private static final char[][] numValue = 
+    new char[][]{
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[0]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[1]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[2]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[3]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[4]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[5]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[6]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[7]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[8]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[9]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[10]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[11]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[12]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[13]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[14]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[15]),
+                 String.zeroBasedStringValue(CharData.NUM_VALUE[16])};
+
+  /**
+   * Stores unicode uppercase attribute table. Exploit package visibility
+   * of String.value to avoid copying the array.
+   * @see CharData#UPPER
+   */  
+  private static final char[][] upper = 
+    new char[][]{
+                 String.zeroBasedStringValue(CharData.UPPER[0]),
+                 String.zeroBasedStringValue(CharData.UPPER[1]),
+                 String.zeroBasedStringValue(CharData.UPPER[2]),
+                 String.zeroBasedStringValue(CharData.UPPER[3]),
+                 String.zeroBasedStringValue(CharData.UPPER[4]),
+                 String.zeroBasedStringValue(CharData.UPPER[5]),
+                 String.zeroBasedStringValue(CharData.UPPER[6]),
+                 String.zeroBasedStringValue(CharData.UPPER[7]),
+                 String.zeroBasedStringValue(CharData.UPPER[8]),
+                 String.zeroBasedStringValue(CharData.UPPER[9]),
+                 String.zeroBasedStringValue(CharData.UPPER[10]),
+                 String.zeroBasedStringValue(CharData.UPPER[11]),
+                 String.zeroBasedStringValue(CharData.UPPER[12]),
+                 String.zeroBasedStringValue(CharData.UPPER[13]),
+                 String.zeroBasedStringValue(CharData.UPPER[14]),
+                 String.zeroBasedStringValue(CharData.UPPER[15]),
+                 String.zeroBasedStringValue(CharData.UPPER[16])};
+
+  /**
+   * Stores unicode lowercase attribute table. Exploit package visibility
+   * of String.value to avoid copying the array.
+   * @see CharData#LOWER
+   */
+  private static final char[][] lower = 
+    new char[][]{
+                 String.zeroBasedStringValue(CharData.LOWER[0]),
+                 String.zeroBasedStringValue(CharData.LOWER[1]),
+                 String.zeroBasedStringValue(CharData.LOWER[2]),
+                 String.zeroBasedStringValue(CharData.LOWER[3]),
+                 String.zeroBasedStringValue(CharData.LOWER[4]),
+                 String.zeroBasedStringValue(CharData.LOWER[5]),
+                 String.zeroBasedStringValue(CharData.LOWER[6]),
+                 String.zeroBasedStringValue(CharData.LOWER[7]),
+                 String.zeroBasedStringValue(CharData.LOWER[8]),
+                 String.zeroBasedStringValue(CharData.LOWER[9]),
+                 String.zeroBasedStringValue(CharData.LOWER[10]),
+                 String.zeroBasedStringValue(CharData.LOWER[11]),
+                 String.zeroBasedStringValue(CharData.LOWER[12]),
+                 String.zeroBasedStringValue(CharData.LOWER[13]),
+                 String.zeroBasedStringValue(CharData.LOWER[14]),
+                 String.zeroBasedStringValue(CharData.LOWER[15]),
+                 String.zeroBasedStringValue(CharData.LOWER[16])};
+
+  /**
+   * Stores unicode direction attribute table. Exploit package visibility
+   * of String.value to avoid copying the array.
+   * @see CharData#DIRECTION
+   */
+  // Package visible for use by String.
+  static final char[][] direction = 
+    new char[][]{
+                 String.zeroBasedStringValue(CharData.DIRECTION[0]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[1]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[2]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[3]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[4]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[5]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[6]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[7]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[8]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[9]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[10]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[11]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[12]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[13]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[14]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[15]),
+                 String.zeroBasedStringValue(CharData.DIRECTION[16])};
+
+  /**
+   * Stores unicode titlecase table. Exploit package visibility of
+   * String.value to avoid copying the array.
+   * @see CharData#TITLE
+   */
+  private static final char[] title = String.zeroBasedStringValue(CharData.TITLE);  
+
+  /**
+   * Mask for grabbing the type out of the contents of data.
+   * @see CharData#DATA
+   */
+  private static final int TYPE_MASK = 0x1F;
+
+  /**
+   * Mask for grabbing the non-breaking space flag out of the contents of
+   * data.
+   * @see CharData#DATA
+   */
+  private static final int NO_BREAK_MASK = 0x20;
+
+  /**
+   * Mask for grabbing the mirrored directionality flag out of the contents
+   * of data.
+   * @see CharData#DATA
+   */
+  private static final int MIRROR_MASK = 0x40;
+
+  /**
+   * Min value for supplementary code point.
+   *
+   * @since 1.5
+   */
+  public static final int MIN_SUPPLEMENTARY_CODE_POINT = 0x10000;
+
+  /**
+   * Min value for code point.
+   *
+   * @since 1.5
+   */
+  public static final int MIN_CODE_POINT = 0; 
+ 
+ 
+  /**
+   * Max value for code point.
+   *
+   * @since 1.5
+   */
+  public static final int MAX_CODE_POINT = 0x010ffff;
+
+
+  /**
+   * Minimum high surrogate code in UTF-16 encoding.
+   *
+   * @since 1.5
+   */
+  public static final char MIN_HIGH_SURROGATE = '\ud800';
+
+  /**
+   * Maximum high surrogate code in UTF-16 encoding.
+   *
+   * @since 1.5
+   */
+  public static final char MAX_HIGH_SURROGATE = '\udbff';
+ 
+  /**
+   * Minimum low surrogate code in UTF-16 encoding.
+   *
+   * @since 1.5
+   */
+  public static final char MIN_LOW_SURROGATE = '\udc00';
+
+  /**
+   * Maximum low surrogate code in UTF-16 encoding.
+   *
+   * @since 1.5
+   */
+  public static final char MAX_LOW_SURROGATE = '\udfff';
+
+  /**
+   * Minimum surrogate code in UTF-16 encoding.
+   *
+   * @since 1.5
+   */
+  public static final char MIN_SURROGATE = MIN_HIGH_SURROGATE;
+
+  /**
+   * Maximum low surrogate code in UTF-16 encoding.
+   *
+   * @since 1.5
+   */
+  public static final char MAX_SURROGATE = MAX_LOW_SURROGATE;
+
+  /**
+   * Grabs an attribute offset from the Unicode attribute database. The lower
+   * 5 bits are the character type, the next 2 bits are flags, and the top
+   * 9 bits are the offset into the attribute tables.
+   *
+   * @param codePoint the character to look up
+   * @return the character's attribute offset and type
+   * @see #TYPE_MASK
+   * @see #NO_BREAK_MASK
+   * @see #MIRROR_MASK
+   * @see CharData#DATA
+   * @see CharData#SHIFT
+   */
+  static char readCodePoint(int codePoint)
+  {
+    int plane = codePoint >>> 16;
+    char offset = (char) (codePoint & 0xffff);
+    return data[plane][(char) (blocks[plane][offset >> CharData.SHIFT[plane]] + offset)];
+  }
+
+  /**
+   * Wraps up a character.
+   *
+   * @param value the character to wrap
+   */
+  public Character(char value)
+  {
+    this.value = value;
+  }
+
+  /**
+   * Returns the character which has been wrapped by this class.
+   *
+   * @return the character wrapped
+   */
+  public char charValue()
+  {
+    return value;
+  }
+
+  /**
+   * Returns the numerical value (unsigned) of the wrapped character.
+   * Range of returned values: 0x0000-0xFFFF.
+   *
+   * @return the value of the wrapped character
+   */
+  public int hashCode()
+  {
+    return value;
+  }
+
+  /**
+   * Determines if an object is equal to this object. This is only true for
+   * another Character object wrapping the same value.
+   *
+   * @param o object to compare
+   * @return true if o is a Character with the same value
+   */
+  public boolean equals(Object o)
+  {
+    return o instanceof Character && value == ((Character) o).value;
+  }
+
+  /**
+   * Converts the wrapped character into a String.
+   *
+   * @return a String containing one character -- the wrapped character
+   *         of this instance
+   */
+  public String toString()
+  {
+    // Package constructor avoids an array copy.
+    return new String(new char[] { value }, 0, 1, true);
+  }
+
+  /**
+   * Returns a String of length 1 representing the specified character.
+   *
+   * @param ch the character to convert
+   * @return a String containing the character
+   * @since 1.4
+   */
+  public static String toString(char ch)
+  {
+    // Package constructor avoids an array copy.
+    return new String(new char[] { ch }, 0, 1, true);
+  }
+
+  /**
+   * Determines if a character is a Unicode lowercase letter. For example,
+   * <code>'a'</code> is lowercase.  Returns true if getType() returns
+   * LOWERCASE_LETTER.
+   * <br>
+   * lowercase = [Ll]
+   *
+   * @param ch character to test
+   * @return true if ch is a Unicode lowercase letter, else false
+   * @see #isUpperCase(char)
+   * @see #isTitleCase(char)
+   * @see #toLowerCase(char)
+   * @see #getType(char)
+   */
+  public static boolean isLowerCase(char ch)
+  {
+    return isLowerCase((int)ch);
+  }
+  
+  /**
+   * Determines if a character is a Unicode lowercase letter. For example,
+   * <code>'a'</code> is lowercase.  Returns true if getType() returns
+   * LOWERCASE_LETTER.
+   * <br>
+   * lowercase = [Ll]
+   *
+   * @param codePoint character to test
+   * @return true if ch is a Unicode lowercase letter, else false
+   * @see #isUpperCase(char)
+   * @see #isTitleCase(char)
+   * @see #toLowerCase(char)
+   * @see #getType(char)
+   * 
+   * @since 1.5
+   */
+  public static boolean isLowerCase(int codePoint)
+  {
+    return getType(codePoint) == LOWERCASE_LETTER;
+  }
+
+  /**
+   * Determines if a character is a Unicode uppercase letter. For example,
+   * <code>'A'</code> is uppercase.  Returns true if getType() returns
+   * UPPERCASE_LETTER.
+   * <br>
+   * uppercase = [Lu]
+   *
+   * @param ch character to test
+   * @return true if ch is a Unicode uppercase letter, else false
+   * @see #isLowerCase(char)
+   * @see #isTitleCase(char)
+   * @see #toUpperCase(char)
+   * @see #getType(char)
+   */
+  public static boolean isUpperCase(char ch)
+  {
+    return isUpperCase((int)ch);
+  }
+  
+  /**
+   * Determines if a character is a Unicode uppercase letter. For example,
+   * <code>'A'</code> is uppercase.  Returns true if getType() returns
+   * UPPERCASE_LETTER.
+   * <br>
+   * uppercase = [Lu]
+   *
+   * @param codePoint character to test
+   * @return true if ch is a Unicode uppercase letter, else false
+   * @see #isLowerCase(char)
+   * @see #isTitleCase(char)
+   * @see #toUpperCase(char)
+   * @see #getType(char)
+   * 
+   * @since 1.5
+   */
+  public static boolean isUpperCase(int codePoint)
+  {
+    return getType(codePoint) == UPPERCASE_LETTER;
+  }
+
+  /**
+   * Determines if a character is a Unicode titlecase letter. For example,
+   * the character "Lj" (Latin capital L with small letter j) is titlecase.
+   * True if getType() returns TITLECASE_LETTER.
+   * <br>
+   * titlecase = [Lt]
+   *
+   * @param ch character to test
+   * @return true if ch is a Unicode titlecase letter, else false
+   * @see #isLowerCase(char)
+   * @see #isUpperCase(char)
+   * @see #toTitleCase(char)
+   * @see #getType(char)
+   */
+  public static boolean isTitleCase(char ch)
+  {
+    return isTitleCase((int)ch);
+  }
+  
+  /**
+   * Determines if a character is a Unicode titlecase letter. For example,
+   * the character "Lj" (Latin capital L with small letter j) is titlecase.
+   * True if getType() returns TITLECASE_LETTER.
+   * <br>
+   * titlecase = [Lt]
+   *
+   * @param codePoint character to test
+   * @return true if ch is a Unicode titlecase letter, else false
+   * @see #isLowerCase(char)
+   * @see #isUpperCase(char)
+   * @see #toTitleCase(char)
+   * @see #getType(char)
+   * 
+   * @since 1.5
+   */
+  public static boolean isTitleCase(int codePoint)
+  {
+    return getType(codePoint) == TITLECASE_LETTER;
+  }
+  
+
+  /**
+   * Determines if a character is a Unicode decimal digit. For example,
+   * <code>'0'</code> is a digit.  A character is a Unicode digit if
+   * getType() returns DECIMAL_DIGIT_NUMBER.
+   * <br>
+   * Unicode decimal digit = [Nd]
+   *
+   * @param ch character to test
+   * @return true if ch is a Unicode decimal digit, else false
+   * @see #digit(char, int)
+   * @see #forDigit(int, int)
+   * @see #getType(char)
+   */
+  public static boolean isDigit(char ch)
+  {
+    return isDigit((int)ch);
+  }
+  
+  /**
+   * Determines if a character is a Unicode decimal digit. For example,
+   * <code>'0'</code> is a digit. A character is a Unicode digit if
+   * getType() returns DECIMAL_DIGIT_NUMBER.
+   * <br>
+   * Unicode decimal digit = [Nd]
+   *
+   * @param codePoint character to test
+   * @return true if ch is a Unicode decimal digit, else false
+   * @see #digit(char, int)
+   * @see #forDigit(int, int)
+   * @see #getType(char)
+   * 
+   * @since 1.5
+   */
+
+  public static boolean isDigit(int codePoint)
+  {
+    return getType(codePoint) == DECIMAL_DIGIT_NUMBER;
+  }
+
+  /**
+   * Determines if a character is part of the Unicode Standard. This is an
+   * evolving standard, but covers every character in the data file.
+   * <br>
+   * defined = not [Cn]
+   *
+   * @param ch character to test
+   * @return true if ch is a Unicode character, else false
+   * @see #isDigit(char)
+   * @see #isLetter(char)
+   * @see #isLetterOrDigit(char)
+   * @see #isLowerCase(char)
+   * @see #isTitleCase(char)
+   * @see #isUpperCase(char)
+   */
+  public static boolean isDefined(char ch)
+  {
+    return isDefined((int)ch);
+  }
+  
+  /**
+   * Determines if a character is part of the Unicode Standard. This is an
+   * evolving standard, but covers every character in the data file.
+   * <br>
+   * defined = not [Cn]
+   *
+   * @param codePoint character to test
+   * @return true if ch is a Unicode character, else false
+   * @see #isDigit(char)
+   * @see #isLetter(char)
+   * @see #isLetterOrDigit(char)
+   * @see #isLowerCase(char)
+   * @see #isTitleCase(char)
+   * @see #isUpperCase(char)
+   * 
+   * @since 1.5
+   */
+  public static boolean isDefined(int codePoint)
+  {
+    return getType(codePoint) != UNASSIGNED;
+  }
+
+  /**
+   * Determines if a character is a Unicode letter. Not all letters have case,
+   * so this may return true when isLowerCase and isUpperCase return false.
+   * A character is a Unicode letter if getType() returns one of 
+   * UPPERCASE_LETTER, LOWERCASE_LETTER, TITLECASE_LETTER, MODIFIER_LETTER,
+   * or OTHER_LETTER.
+   * <br>
+   * letter = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]
+   *
+   * @param ch character to test
+   * @return true if ch is a Unicode letter, else false
+   * @see #isDigit(char)
+   * @see #isJavaIdentifierStart(char)
+   * @see #isJavaLetter(char)
+   * @see #isJavaLetterOrDigit(char)
+   * @see #isLetterOrDigit(char)
+   * @see #isLowerCase(char)
+   * @see #isTitleCase(char)
+   * @see #isUnicodeIdentifierStart(char)
+   * @see #isUpperCase(char)
+   */
+  public static boolean isLetter(char ch)
+  {
+    return isLetter((int)ch);
+  }
+  
+  /**
+   * Determines if a character is a Unicode letter. Not all letters have case,
+   * so this may return true when isLowerCase and isUpperCase return false.
+   * A character is a Unicode letter if getType() returns one of 
+   * UPPERCASE_LETTER, LOWERCASE_LETTER, TITLECASE_LETTER, MODIFIER_LETTER,
+   * or OTHER_LETTER.
+   * <br>
+   * letter = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]
+   *
+   * @param codePoint character to test
+   * @return true if ch is a Unicode letter, else false
+   * @see #isDigit(char)
+   * @see #isJavaIdentifierStart(char)
+   * @see #isJavaLetter(char)
+   * @see #isJavaLetterOrDigit(char)
+   * @see #isLetterOrDigit(char)
+   * @see #isLowerCase(char)
+   * @see #isTitleCase(char)
+   * @see #isUnicodeIdentifierStart(char)
+   * @see #isUpperCase(char)
+   * 
+   * @since 1.5
+   */
+  public static boolean isLetter(int codePoint)
+  {
+    return ((1 << getType(codePoint))
+        & ((1 << UPPERCASE_LETTER)
+            | (1 << LOWERCASE_LETTER)
+            | (1 << TITLECASE_LETTER)
+            | (1 << MODIFIER_LETTER)
+            | (1 << OTHER_LETTER))) != 0;
+  }
+  /**
+   * Returns the index into the given CharSequence that is offset
+   * <code>codePointOffset</code> code points from <code>index</code>.
+   * @param seq the CharSequence
+   * @param index the start position in the CharSequence
+   * @param codePointOffset the number of code points offset from the start
+   * position
+   * @return the index into the CharSequence that is codePointOffset code 
+   * points offset from index
+   * 
+   * @throws NullPointerException if seq is null
+   * @throws IndexOutOfBoundsException if index is negative or greater than the
+   * length of the sequence.
+   * @throws IndexOutOfBoundsException if codePointOffset is positive and the 
+   * subsequence from index to the end of seq has fewer than codePointOffset
+   * code points
+   * @throws IndexOutOfBoundsException if codePointOffset is negative and the
+   * subsequence from the start of seq to index has fewer than 
+   * (-codePointOffset) code points
+   * @since 1.5
+   */
+  public static int offsetByCodePoints(CharSequence seq,
+                                       int index,
+                                       int codePointOffset)
+  {
+    int len = seq.length();
+    if (index < 0 || index > len)
+      throw new IndexOutOfBoundsException();
+    
+    int numToGo = codePointOffset;
+    int offset = index;
+    int adjust = 1;
+    if (numToGo >= 0)
+      {
+        for (; numToGo > 0; offset++)
+          {
+            numToGo--;
+            if (Character.isHighSurrogate(seq.charAt(offset))
+                && (offset + 1) < len
+                && Character.isLowSurrogate(seq.charAt(offset + 1)))
+              offset++;
+          }
+        return offset;
+      }
+    else
+      {
+        numToGo *= -1;
+        for (; numToGo > 0;)
+          {
+            numToGo--;
+            offset--;
+            if (Character.isLowSurrogate(seq.charAt(offset))
+                && (offset - 1) >= 0
+                && Character.isHighSurrogate(seq.charAt(offset - 1)))
+              offset--;
+          }
+        return offset;
+      }
+  }
+  
+  /**
+   * Returns the index into the given char subarray that is offset
+   * <code>codePointOffset</code> code points from <code>index</code>.
+   * @param a the char array
+   * @param start the start index of the subarray
+   * @param count the length of the subarray
+   * @param index the index to be offset
+   * @param codePointOffset the number of code points offset from <code>index
+   * </code>
+   * @return the index into the char array
+   * 
+   * @throws NullPointerException if a is null
+   * @throws IndexOutOfBoundsException if start or count is negative or if
+   * start + count is greater than the length of the array
+   * @throws IndexOutOfBoundsException if index is less than start or larger 
+   * than start + count
+   * @throws IndexOutOfBoundsException if codePointOffset is positive and the
+   * subarray from index to start + count - 1 has fewer than codePointOffset
+   * code points.
+   * @throws IndexOutOfBoundsException if codePointOffset is negative and the
+   * subarray from start to index - 1 has fewer than (-codePointOffset) code
+   * points
+   * 
+   * @since 1.5
+   */
+  public static int offsetByCodePoints(char[] a,
+                                       int start,
+                                       int count,
+                                       int index,
+                                       int codePointOffset)
+  {
+    int len = a.length;
+    int end = start + count;
+    if (start < 0 || count < 0 || end > len || index < start || index > end)
+      throw new IndexOutOfBoundsException();
+    
+    int numToGo = codePointOffset;
+    int offset = index;
+    int adjust = 1;
+    if (numToGo >= 0)
+      {
+        for (; numToGo > 0; offset++)
+          {
+            numToGo--;
+            if (Character.isHighSurrogate(a[offset])
+                && (offset + 1) < len
+                && Character.isLowSurrogate(a[offset + 1]))
+              offset++;
+          }
+        return offset;
+      }
+    else
+      {
+        numToGo *= -1;
+        for (; numToGo > 0;)
+          {
+            numToGo--;
+            offset--;
+            if (Character.isLowSurrogate(a[offset])
+                && (offset - 1) >= 0
+                && Character.isHighSurrogate(a[offset - 1]))
+              offset--;
+            if (offset < start)
+              throw new IndexOutOfBoundsException();
+          }
+        return offset;
+      }
+
+  }
+  
+  /**
+   * Returns the number of Unicode code points in the specified range of the
+   * given CharSequence.  The first char in the range is at position
+   * beginIndex and the last one is at position endIndex - 1.  Paired 
+   * surrogates (supplementary characters are represented by a pair of chars - 
+   * one from the high surrogates and one from the low surrogates) 
+   * count as just one code point.
+   * @param seq the CharSequence to inspect
+   * @param beginIndex the beginning of the range
+   * @param endIndex the end of the range
+   * @return the number of Unicode code points in the given range of the 
+   * sequence
+   * @throws NullPointerException if seq is null
+   * @throws IndexOutOfBoundsException if beginIndex is negative, endIndex is
+   * larger than the length of seq, or if beginIndex is greater than endIndex.
+   * @since 1.5
+   */
+  public static int codePointCount(CharSequence seq, int beginIndex,
+                                   int endIndex)
+  {
+    int len = seq.length();
+    if (beginIndex < 0 || endIndex > len || beginIndex > endIndex)
+      throw new IndexOutOfBoundsException();
+        
+    int count = 0;
+    for (int i = beginIndex; i < endIndex; i++)
+      {
+        count++;
+        // If there is a pairing, count it only once.
+        if (isHighSurrogate(seq.charAt(i)) && (i + 1) < endIndex
+            && isLowSurrogate(seq.charAt(i + 1)))
+          i ++;
+      }    
+    return count;
+  }
+  
+  /**
+   * Returns the number of Unicode code points in the specified range of the
+   * given char array.  The first char in the range is at position
+   * offset and the length of the range is count.  Paired surrogates
+   * (supplementary characters are represented by a pair of chars - 
+   * one from the high surrogates and one from the low surrogates) 
+   * count as just one code point.
+   * @param a the char array to inspect
+   * @param offset the beginning of the range
+   * @param count the length of the range
+   * @return the number of Unicode code points in the given range of the 
+   * array
+   * @throws NullPointerException if a is null
+   * @throws IndexOutOfBoundsException if offset or count is negative or if 
+   * offset + countendIndex is larger than the length of a.
+   * @since 1.5
+   */
+  public static int codePointCount(char[] a, int offset,
+                                   int count)
+  {
+    int len = a.length;
+    int end = offset + count;
+    if (offset < 0 || count < 0 || end > len)
+      throw new IndexOutOfBoundsException();
+        
+    int counter = 0;
+    for (int i = offset; i < end; i++)
+      {
+        counter++;
+        // If there is a pairing, count it only once.
+        if (isHighSurrogate(a[i]) && (i + 1) < end
+            && isLowSurrogate(a[i + 1]))
+          i ++;
+      }    
+    return counter;
+  }
+
+  /**
+   * Determines if a character is a Unicode letter or a Unicode digit. This
+   * is the combination of isLetter and isDigit.
+   * <br>
+   * letter or digit = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nd]
+   *
+   * @param ch character to test
+   * @return true if ch is a Unicode letter or a Unicode digit, else false
+   * @see #isDigit(char)
+   * @see #isJavaIdentifierPart(char)
+   * @see #isJavaLetter(char)
+   * @see #isJavaLetterOrDigit(char)
+   * @see #isLetter(char)
+   * @see #isUnicodeIdentifierPart(char)
+   */
+  public static boolean isLetterOrDigit(char ch)
+  {
+    return isLetterOrDigit((int)ch);
+  }
+
+  /**
+   * Determines if a character is a Unicode letter or a Unicode digit. This
+   * is the combination of isLetter and isDigit.
+   * <br>
+   * letter or digit = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nd]
+   *
+   * @param codePoint character to test
+   * @return true if ch is a Unicode letter or a Unicode digit, else false
+   * @see #isDigit(char)
+   * @see #isJavaIdentifierPart(char)
+   * @see #isJavaLetter(char)
+   * @see #isJavaLetterOrDigit(char)
+   * @see #isLetter(char)
+   * @see #isUnicodeIdentifierPart(char)
+   * 
+   * @since 1.5
+   */
+  public static boolean isLetterOrDigit(int codePoint)
+  {
+    return ((1 << getType(codePoint))
+        & ((1 << UPPERCASE_LETTER)
+           | (1 << LOWERCASE_LETTER)
+           | (1 << TITLECASE_LETTER)
+           | (1 << MODIFIER_LETTER)
+           | (1 << OTHER_LETTER)
+           | (1 << DECIMAL_DIGIT_NUMBER))) != 0;
+  }
+  
+  /**
+   * Determines if a character can start a Java identifier. This is the
+   * combination of isLetter, any character where getType returns
+   * LETTER_NUMBER, currency symbols (like '$'), and connecting punctuation
+   * (like '_').
+   *
+   * @param ch character to test
+   * @return true if ch can start a Java identifier, else false
+   * @deprecated Replaced by {@link #isJavaIdentifierStart(char)}
+   * @see #isJavaLetterOrDigit(char)
+   * @see #isJavaIdentifierStart(char)
+   * @see #isJavaIdentifierPart(char)
+   * @see #isLetter(char)
+   * @see #isLetterOrDigit(char)
+   * @see #isUnicodeIdentifierStart(char)
+   */
+  public static boolean isJavaLetter(char ch)
+  {
+    return isJavaIdentifierStart(ch);
+  }
+
+  /**
+   * Determines if a character can follow the first letter in
+   * a Java identifier.  This is the combination of isJavaLetter (isLetter,
+   * type of LETTER_NUMBER, currency, connecting punctuation) and digit,
+   * numeric letter (like Roman numerals), combining marks, non-spacing marks,
+   * or isIdentifierIgnorable.
+   *
+   * @param ch character to test
+   * @return true if ch can follow the first letter in a Java identifier
+   * @deprecated Replaced by {@link #isJavaIdentifierPart(char)}
+   * @see #isJavaLetter(char)
+   * @see #isJavaIdentifierStart(char)
+   * @see #isJavaIdentifierPart(char)
+   * @see #isLetter(char)
+   * @see #isLetterOrDigit(char)
+   * @see #isUnicodeIdentifierPart(char)
+   * @see #isIdentifierIgnorable(char)
+   */
+  public static boolean isJavaLetterOrDigit(char ch)
+  {
+    return isJavaIdentifierPart(ch);
+  }
+
+  /**
+   * Determines if a character can start a Java identifier. This is the
+   * combination of isLetter, any character where getType returns
+   * LETTER_NUMBER, currency symbols (like '$'), and connecting punctuation
+   * (like '_').
+   * <br>
+   * Java identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc]
+   *
+   * @param ch character to test
+   * @return true if ch can start a Java identifier, else false
+   * @see #isJavaIdentifierPart(char)
+   * @see #isLetter(char)
+   * @see #isUnicodeIdentifierStart(char)
+   * @since 1.1
+   */
+  public static boolean isJavaIdentifierStart(char ch)
+  {
+    return isJavaIdentifierStart((int)ch);
+  }
+
+  /**
+   * Determines if a character can start a Java identifier. This is the
+   * combination of isLetter, any character where getType returns
+   * LETTER_NUMBER, currency symbols (like '$'), and connecting punctuation
+   * (like '_').
+   * <br>
+   * Java identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc]
+   *
+   * @param codePoint character to test
+   * @return true if ch can start a Java identifier, else false
+   * @see #isJavaIdentifierPart(char)
+   * @see #isLetter(char)
+   * @see #isUnicodeIdentifierStart(char)
+   * @since 1.5
+   */
+  public static boolean isJavaIdentifierStart(int codePoint)
+  {
+    return ((1 << getType(codePoint))
+            & ((1 << UPPERCASE_LETTER)
+               | (1 << LOWERCASE_LETTER)
+               | (1 << TITLECASE_LETTER)
+               | (1 << MODIFIER_LETTER)
+               | (1 << OTHER_LETTER)
+               | (1 << LETTER_NUMBER)
+               | (1 << CURRENCY_SYMBOL)
+               | (1 << CONNECTOR_PUNCTUATION))) != 0;
+  }
+  
+  /**
+   * Determines if a character can follow the first letter in
+   * a Java identifier.  This is the combination of isJavaLetter (isLetter,
+   * type of LETTER_NUMBER, currency, connecting punctuation) and digit,
+   * numeric letter (like Roman numerals), combining marks, non-spacing marks,
+   * or isIdentifierIgnorable.
+   * <br>
+   * Java identifier extender =
+   *   [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc]|[Mn]|[Mc]|[Nd]|[Cf]
+   *   |U+0000-U+0008|U+000E-U+001B|U+007F-U+009F
+   *
+   * @param ch character to test
+   * @return true if ch can follow the first letter in a Java identifier
+   * @see #isIdentifierIgnorable(char)
+   * @see #isJavaIdentifierStart(char)
+   * @see #isLetterOrDigit(char)
+   * @see #isUnicodeIdentifierPart(char)
+   * @since 1.1
+   */
+  public static boolean isJavaIdentifierPart(char ch)
+  {
+    return isJavaIdentifierPart((int)ch);
+  }
+  
+  /**
+   * Determines if a character can follow the first letter in
+   * a Java identifier.  This is the combination of isJavaLetter (isLetter,
+   * type of LETTER_NUMBER, currency, connecting punctuation) and digit,
+   * numeric letter (like Roman numerals), combining marks, non-spacing marks,
+   * or isIdentifierIgnorable.
+   * <br>
+   * Java identifier extender =
+   *   [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Sc]|[Pc]|[Mn]|[Mc]|[Nd]|[Cf]
+   *   |U+0000-U+0008|U+000E-U+001B|U+007F-U+009F
+   *
+   * @param codePoint character to test
+   * @return true if ch can follow the first letter in a Java identifier
+   * @see #isIdentifierIgnorable(char)
+   * @see #isJavaIdentifierStart(char)
+   * @see #isLetterOrDigit(char)
+   * @see #isUnicodeIdentifierPart(char)
+   * @since 1.5
+   */
+  public static boolean isJavaIdentifierPart(int codePoint)
+  {
+    int category = getType(codePoint);
+    return ((1 << category)
+            & ((1 << UPPERCASE_LETTER)
+               | (1 << LOWERCASE_LETTER)
+               | (1 << TITLECASE_LETTER)
+               | (1 << MODIFIER_LETTER)
+               | (1 << OTHER_LETTER)
+               | (1 << NON_SPACING_MARK)
+               | (1 << COMBINING_SPACING_MARK)
+               | (1 << DECIMAL_DIGIT_NUMBER)
+               | (1 << LETTER_NUMBER)
+               | (1 << CURRENCY_SYMBOL)
+               | (1 << CONNECTOR_PUNCTUATION)
+               | (1 << FORMAT))) != 0
+      || (category == CONTROL && isIdentifierIgnorable(codePoint));
+  }
+
+  /**
+   * Determines if a character can start a Unicode identifier.  Only
+   * letters can start a Unicode identifier, but this includes characters
+   * in LETTER_NUMBER.
+   * <br>
+   * Unicode identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]
+   *
+   * @param ch character to test
+   * @return true if ch can start a Unicode identifier, else false
+   * @see #isJavaIdentifierStart(char)
+   * @see #isLetter(char)
+   * @see #isUnicodeIdentifierPart(char)
+   * @since 1.1
+   */
+  public static boolean isUnicodeIdentifierStart(char ch)
+  {
+    return isUnicodeIdentifierStart((int)ch);
+  }
+
+  /**
+   * Determines if a character can start a Unicode identifier.  Only
+   * letters can start a Unicode identifier, but this includes characters
+   * in LETTER_NUMBER.
+   * <br>
+   * Unicode identifier start = [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]
+   *
+   * @param codePoint character to test
+   * @return true if ch can start a Unicode identifier, else false
+   * @see #isJavaIdentifierStart(char)
+   * @see #isLetter(char)
+   * @see #isUnicodeIdentifierPart(char)
+   * @since 1.5
+   */
+  public static boolean isUnicodeIdentifierStart(int codePoint)
+  {
+    return ((1 << getType(codePoint))
+            & ((1 << UPPERCASE_LETTER)
+               | (1 << LOWERCASE_LETTER)
+               | (1 << TITLECASE_LETTER)
+               | (1 << MODIFIER_LETTER)
+               | (1 << OTHER_LETTER)
+               | (1 << LETTER_NUMBER))) != 0;
+  }
+
+  /**
+   * Determines if a character can follow the first letter in
+   * a Unicode identifier. This includes letters, connecting punctuation,
+   * digits, numeric letters, combining marks, non-spacing marks, and
+   * isIdentifierIgnorable.
+   * <br>
+   * Unicode identifier extender =
+   *   [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Mn]|[Mc]|[Nd]|[Pc]|[Cf]|
+   *   |U+0000-U+0008|U+000E-U+001B|U+007F-U+009F
+   *
+   * @param ch character to test
+   * @return true if ch can follow the first letter in a Unicode identifier
+   * @see #isIdentifierIgnorable(char)
+   * @see #isJavaIdentifierPart(char)
+   * @see #isLetterOrDigit(char)
+   * @see #isUnicodeIdentifierStart(char)
+   * @since 1.1
+   */
+  public static boolean isUnicodeIdentifierPart(char ch)
+  {
+    return isUnicodeIdentifierPart((int)ch);
+  }
+  
+  /**
+   * Determines if a character can follow the first letter in
+   * a Unicode identifier. This includes letters, connecting punctuation,
+   * digits, numeric letters, combining marks, non-spacing marks, and
+   * isIdentifierIgnorable.
+   * <br>
+   * Unicode identifier extender =
+   *   [Lu]|[Ll]|[Lt]|[Lm]|[Lo]|[Nl]|[Mn]|[Mc]|[Nd]|[Pc]|[Cf]|
+   *   |U+0000-U+0008|U+000E-U+001B|U+007F-U+009F
+   *
+   * @param codePoint character to test
+   * @return true if ch can follow the first letter in a Unicode identifier
+   * @see #isIdentifierIgnorable(char)
+   * @see #isJavaIdentifierPart(char)
+   * @see #isLetterOrDigit(char)
+   * @see #isUnicodeIdentifierStart(char)
+   * @since 1.5
+   */
+  public static boolean isUnicodeIdentifierPart(int codePoint)
+  {
+    int category = getType(codePoint);
+    return ((1 << category)
+            & ((1 << UPPERCASE_LETTER)
+               | (1 << LOWERCASE_LETTER)
+               | (1 << TITLECASE_LETTER)
+               | (1 << MODIFIER_LETTER)
+               | (1 << OTHER_LETTER)
+               | (1 << NON_SPACING_MARK)
+               | (1 << COMBINING_SPACING_MARK)
+               | (1 << DECIMAL_DIGIT_NUMBER)
+               | (1 << LETTER_NUMBER)
+               | (1 << CONNECTOR_PUNCTUATION)
+               | (1 << FORMAT))) != 0
+      || (category == CONTROL && isIdentifierIgnorable(codePoint));
+  }
+
+  /**
+   * Determines if a character is ignorable in a Unicode identifier. This
+   * includes the non-whitespace ISO control characters (<code>'\u0000'</code>
+   * through <code>'\u0008'</code>, <code>'\u000E'</code> through
+   * <code>'\u001B'</code>, and <code>'\u007F'</code> through
+   * <code>'\u009F'</code>), and FORMAT characters.
+   * <br>
+   * Unicode identifier ignorable = [Cf]|U+0000-U+0008|U+000E-U+001B
+   *    |U+007F-U+009F
+   *
+   * @param ch character to test
+   * @return true if ch is ignorable in a Unicode or Java identifier
+   * @see #isJavaIdentifierPart(char)
+   * @see #isUnicodeIdentifierPart(char)
+   * @since 1.1
+   */
+  public static boolean isIdentifierIgnorable(char ch)
+  {
+    return isIdentifierIgnorable((int)ch);
+  }
+  /**
+   * Determines if a character is ignorable in a Unicode identifier. This
+   * includes the non-whitespace ISO control characters (<code>'\u0000'</code>
+   * through <code>'\u0008'</code>, <code>'\u000E'</code> through
+   * <code>'\u001B'</code>, and <code>'\u007F'</code> through
+   * <code>'\u009F'</code>), and FORMAT characters.
+   * <br>
+   * Unicode identifier ignorable = [Cf]|U+0000-U+0008|U+000E-U+001B
+   *    |U+007F-U+009F
+   *
+   * @param codePoint character to test
+   * @return true if ch is ignorable in a Unicode or Java identifier
+   * @see #isJavaIdentifierPart(char)
+   * @see #isUnicodeIdentifierPart(char)
+   * @since 1.5
+   */
+  public static boolean isIdentifierIgnorable(int codePoint)
+  {
+    if ((codePoint >= 0 && codePoint <= 0x0008)
+        || (codePoint >= 0x000E && codePoint <= 0x001B)
+        || (codePoint >= 0x007F && codePoint <= 0x009F)
+        || getType(codePoint) == FORMAT)
+      return true;
+    return false;
+  }
+
+  /**
+   * Converts a Unicode character into its lowercase equivalent mapping.
+   * If a mapping does not exist, then the character passed is returned.
+   * Note that isLowerCase(toLowerCase(ch)) does not always return true.
+   *
+   * @param ch character to convert to lowercase
+   * @return lowercase mapping of ch, or ch if lowercase mapping does
+   *         not exist
+   * @see #isLowerCase(char)
+   * @see #isUpperCase(char)
+   * @see #toTitleCase(char)
+   * @see #toUpperCase(char)
+   */
+  public static char toLowerCase(char ch)
+  {
+    return (char) (lower[0][readCodePoint((int)ch) >>> 7] + ch);
+  }
+  
+  /**
+   * Converts a Unicode character into its lowercase equivalent mapping.
+   * If a mapping does not exist, then the character passed is returned.
+   * Note that isLowerCase(toLowerCase(ch)) does not always return true.
+   *
+   * @param codePoint character to convert to lowercase
+   * @return lowercase mapping of ch, or ch if lowercase mapping does
+   *         not exist
+   * @see #isLowerCase(char)
+   * @see #isUpperCase(char)
+   * @see #toTitleCase(char)
+   * @see #toUpperCase(char)
+   * 
+   * @since 1.5
+   */
+  public static int toLowerCase(int codePoint)
+  {
+    // If the code point is unassigned or in one of the private use areas
+    // then we delegate the call to the appropriate private static inner class.
+    int plane = codePoint >>> 16;
+    if (plane > 2 && plane < 14)
+      return UnassignedCharacters.toLowerCase(codePoint);
+    if (plane > 14)
+      return PrivateUseCharacters.toLowerCase(codePoint);
+    
+    // The short value stored in lower[plane] is the signed difference between
+    // codePoint and its lowercase conversion.
+    return ((short)lower[plane][readCodePoint(codePoint) >>> 7]) + codePoint;
+  }
+
+  /**
+   * Converts a Unicode character into its uppercase equivalent mapping.
+   * If a mapping does not exist, then the character passed is returned.
+   * Note that isUpperCase(toUpperCase(ch)) does not always return true.
+   *
+   * @param ch character to convert to uppercase
+   * @return uppercase mapping of ch, or ch if uppercase mapping does
+   *         not exist
+   * @see #isLowerCase(char)
+   * @see #isUpperCase(char)
+   * @see #toLowerCase(char)
+   * @see #toTitleCase(char)
+   */
+  public static char toUpperCase(char ch)
+  {
+    return (char) (upper[0][readCodePoint((int)ch) >>> 7] + ch);
+  }
+  
+  /**
+   * Converts a Unicode character into its uppercase equivalent mapping.
+   * If a mapping does not exist, then the character passed is returned.
+   * Note that isUpperCase(toUpperCase(ch)) does not always return true.
+   *
+   * @param codePoint character to convert to uppercase
+   * @return uppercase mapping of ch, or ch if uppercase mapping does
+   *         not exist
+   * @see #isLowerCase(char)
+   * @see #isUpperCase(char)
+   * @see #toLowerCase(char)
+   * @see #toTitleCase(char)
+   * 
+   * @since 1.5
+   */
+  public static int toUpperCase(int codePoint)
+  {
+    // If the code point is unassigned or in one of the private use areas
+    // then we delegate the call to the appropriate private static inner class.
+    int plane = codePoint >>> 16;
+    if (plane > 2 && plane < 14)
+      return UnassignedCharacters.toUpperCase(codePoint);
+    if (plane > 14)
+      return PrivateUseCharacters.toUpperCase(codePoint);
+        
+    // The short value stored in upper[plane] is the signed difference between
+    // codePoint and its uppercase conversion.
+    return ((short)upper[plane][readCodePoint(codePoint) >>> 7]) + codePoint;
+  }
+
+  /**
+   * Converts a Unicode character into its titlecase equivalent mapping.
+   * If a mapping does not exist, then the character passed is returned.
+   * Note that isTitleCase(toTitleCase(ch)) does not always return true.
+   *
+   * @param ch character to convert to titlecase
+   * @return titlecase mapping of ch, or ch if titlecase mapping does
+   *         not exist
+   * @see #isTitleCase(char)
+   * @see #toLowerCase(char)
+   * @see #toUpperCase(char)
+   */
+  public static char toTitleCase(char ch)
+  {
+    // As title is short, it doesn't hurt to exhaustively iterate over it.
+    for (int i = title.length - 2; i >= 0; i -= 2)
+      if (title[i] == ch)
+        return title[i + 1];
+    return toUpperCase(ch);
+  }
+  
+  /**
+   * Converts a Unicode character into its titlecase equivalent mapping.
+   * If a mapping does not exist, then the character passed is returned.
+   * Note that isTitleCase(toTitleCase(ch)) does not always return true.
+   *
+   * @param codePoint character to convert to titlecase
+   * @return titlecase mapping of ch, or ch if titlecase mapping does
+   *         not exist
+   * @see #isTitleCase(char)
+   * @see #toLowerCase(char)
+   * @see #toUpperCase(char)
+   * 
+   * @since 1.5
+   */
+  public static int toTitleCase(int codePoint)
+  {
+    // As of Unicode 4.0.0 no characters outside of plane 0 have
+    // titlecase mappings that are different from their uppercase
+    // mapping.
+    if (codePoint < 0x10000)
+      return (int) toTitleCase((char)codePoint);
+    return toUpperCase(codePoint);
+  }
+
+  /**
+   * Converts a character into a digit of the specified radix. If the radix
+   * exceeds MIN_RADIX or MAX_RADIX, or if the result of getNumericValue(ch)
+   * exceeds the radix, or if ch is not a decimal digit or in the case
+   * insensitive set of 'a'-'z', the result is -1.
+   * <br>
+   * character argument boundary = [Nd]|U+0041-U+005A|U+0061-U+007A
+   *    |U+FF21-U+FF3A|U+FF41-U+FF5A
+   *
+   * @param ch character to convert into a digit
+   * @param radix radix in which ch is a digit
+   * @return digit which ch represents in radix, or -1 not a valid digit
+   * @see #MIN_RADIX
+   * @see #MAX_RADIX
+   * @see #forDigit(int, int)
+   * @see #isDigit(char)
+   * @see #getNumericValue(char)
+   */
+  public static int digit(char ch, int radix)
+  {
+    if (radix < MIN_RADIX || radix > MAX_RADIX)
+      return -1;
+    char attr = readCodePoint((int)ch);
+    if (((1 << (attr & TYPE_MASK))
+         & ((1 << UPPERCASE_LETTER)
+            | (1 << LOWERCASE_LETTER)
+            | (1 << DECIMAL_DIGIT_NUMBER))) != 0)
+      {
+        // Signedness doesn't matter; 0xffff vs. -1 are both rejected.
+        int digit = numValue[0][attr >> 7];
+        return (digit < radix) ? digit : -1;
+      }
+    return -1;
+  }
+
+  /**
+   * Converts a character into a digit of the specified radix. If the radix
+   * exceeds MIN_RADIX or MAX_RADIX, or if the result of getNumericValue(ch)
+   * exceeds the radix, or if ch is not a decimal digit or in the case
+   * insensitive set of 'a'-'z', the result is -1.
+   * <br>
+   * character argument boundary = [Nd]|U+0041-U+005A|U+0061-U+007A
+   *    |U+FF21-U+FF3A|U+FF41-U+FF5A
+   *
+   * @param codePoint character to convert into a digit
+   * @param radix radix in which ch is a digit
+   * @return digit which ch represents in radix, or -1 not a valid digit
+   * @see #MIN_RADIX
+   * @see #MAX_RADIX
+   * @see #forDigit(int, int)
+   * @see #isDigit(char)
+   * @see #getNumericValue(char)
+   */
+  public static int digit(int codePoint, int radix)
+  {
+    if (radix < MIN_RADIX || radix > MAX_RADIX)
+      return -1;
+    
+    // If the code point is unassigned or in one of the private use areas
+    // then we delegate the call to the appropriate private static inner class.
+    int plane = codePoint >>> 16;
+    if (plane > 2 && plane < 14)
+      return UnassignedCharacters.digit(codePoint, radix);
+    if (plane > 14)
+      return PrivateUseCharacters.digit(codePoint, radix);
+    char attr = readCodePoint(codePoint);
+    if (((1 << (attr & TYPE_MASK))
+         & ((1 << UPPERCASE_LETTER)
+            | (1 << LOWERCASE_LETTER)
+            | (1 << DECIMAL_DIGIT_NUMBER))) != 0)
+      {
+        // Signedness doesn't matter; 0xffff vs. -1 are both rejected.
+        int digit = numValue[plane][attr >> 7];
+        
+        // If digit is less than or equal to -3 then the numerical value was 
+        // too large to fit into numValue and is stored in CharData.LARGENUMS.
+        if (digit <= -3)
+          digit = CharData.LARGENUMS[-digit - 3];
+        return (digit < radix) ? digit : -1;
+      }
+    return -1;
+  }
+  
+  /**
+   * Returns the Unicode numeric value property of a character. For example,
+   * <code>'\\u216C'</code> (the Roman numeral fifty) returns 50.
+   *
+   * <p>This method also returns values for the letters A through Z, (not
+   * specified by Unicode), in these ranges: <code>'\u0041'</code>
+   * through <code>'\u005A'</code> (uppercase); <code>'\u0061'</code>
+   * through <code>'\u007A'</code> (lowercase); and <code>'\uFF21'</code>
+   * through <code>'\uFF3A'</code>, <code>'\uFF41'</code> through
+   * <code>'\uFF5A'</code> (full width variants).
+   *
+   * <p>If the character lacks a numeric value property, -1 is returned.
+   * If the character has a numeric value property which is not representable
+   * as a nonnegative integer, such as a fraction, -2 is returned.
+   *
+   * character argument boundary = [Nd]|[Nl]|[No]|U+0041-U+005A|U+0061-U+007A
+   *    |U+FF21-U+FF3A|U+FF41-U+FF5A
+   *
+   * @param ch character from which the numeric value property will
+   *        be retrieved
+   * @return the numeric value property of ch, or -1 if it does not exist, or
+   *         -2 if it is not representable as a nonnegative integer
+   * @see #forDigit(int, int)
+   * @see #digit(char, int)
+   * @see #isDigit(char)
+   * @since 1.1
+   */
+  public static int getNumericValue(char ch)
+  {
+    // Treat numValue as signed.
+    return (short) numValue[0][readCodePoint((int)ch) >> 7];
+  }
+  
+  /**
+   * Returns the Unicode numeric value property of a character. For example,
+   * <code>'\\u216C'</code> (the Roman numeral fifty) returns 50.
+   *
+   * <p>This method also returns values for the letters A through Z, (not
+   * specified by Unicode), in these ranges: <code>'\u0041'</code>
+   * through <code>'\u005A'</code> (uppercase); <code>'\u0061'</code>
+   * through <code>'\u007A'</code> (lowercase); and <code>'\uFF21'</code>
+   * through <code>'\uFF3A'</code>, <code>'\uFF41'</code> through
+   * <code>'\uFF5A'</code> (full width variants).
+   *
+   * <p>If the character lacks a numeric value property, -1 is returned.
+   * If the character has a numeric value property which is not representable
+   * as a nonnegative integer, such as a fraction, -2 is returned.
+   *
+   * character argument boundary = [Nd]|[Nl]|[No]|U+0041-U+005A|U+0061-U+007A
+   *    |U+FF21-U+FF3A|U+FF41-U+FF5A
+   *
+   * @param codePoint character from which the numeric value property will
+   *        be retrieved
+   * @return the numeric value property of ch, or -1 if it does not exist, or
+   *         -2 if it is not representable as a nonnegative integer
+   * @see #forDigit(int, int)
+   * @see #digit(char, int)
+   * @see #isDigit(char)
+   * @since 1.5
+   */
+  public static int getNumericValue(int codePoint)
+  {
+    // If the code point is unassigned or in one of the private use areas
+    // then we delegate the call to the appropriate private static inner class.
+    int plane = codePoint >>> 16;
+    if (plane > 2 && plane < 14)
+      return UnassignedCharacters.getNumericValue(codePoint);
+    if (plane > 14)
+      return PrivateUseCharacters.getNumericValue(codePoint);
+    
+    // If the value N found in numValue[plane] is less than or equal to -3
+    // then the numeric value was too big to fit into 16 bits and is 
+    // stored in CharData.LARGENUMS at offset (-N - 3).
+    short num = (short)numValue[plane][readCodePoint(codePoint) >> 7];
+    if (num <= -3)
+      return CharData.LARGENUMS[-num - 3];
+    return num;
+  }
+
+  /**
+   * Determines if a character is a ISO-LATIN-1 space. This is only the five
+   * characters <code>'\t'</code>, <code>'\n'</code>, <code>'\f'</code>,
+   * <code>'\r'</code>, and <code>' '</code>.
+   * <br>
+   * Java space = U+0020|U+0009|U+000A|U+000C|U+000D
+   *
+   * @param ch character to test
+   * @return true if ch is a space, else false
+   * @deprecated Replaced by {@link #isWhitespace(char)}
+   * @see #isSpaceChar(char)
+   * @see #isWhitespace(char)
+   */
+  public static boolean isSpace(char ch)
+  {
+    // Performing the subtraction up front alleviates need to compare longs.
+    return ch-- <= ' ' && ((1 << ch)
+                           & ((1 << (' ' - 1))
+                              | (1 << ('\t' - 1))
+                              | (1 << ('\n' - 1))
+                              | (1 << ('\r' - 1))
+                              | (1 << ('\f' - 1)))) != 0;
+  }
+
+  /**
+   * Determines if a character is a Unicode space character. This includes
+   * SPACE_SEPARATOR, LINE_SEPARATOR, and PARAGRAPH_SEPARATOR.
+   * <br>
+   * Unicode space = [Zs]|[Zp]|[Zl]
+   *
+   * @param ch character to test
+   * @return true if ch is a Unicode space, else false
+   * @see #isWhitespace(char)
+   * @since 1.1
+   */
+  public static boolean isSpaceChar(char ch)
+  {
+    return isSpaceChar((int)ch);
+  }
+  
+  /**
+   * Determines if a character is a Unicode space character. This includes
+   * SPACE_SEPARATOR, LINE_SEPARATOR, and PARAGRAPH_SEPARATOR.
+   * <br>
+   * Unicode space = [Zs]|[Zp]|[Zl]
+   *
+   * @param codePoint character to test
+   * @return true if ch is a Unicode space, else false
+   * @see #isWhitespace(char)
+   * @since 1.5
+   */
+  public static boolean isSpaceChar(int codePoint)
+  {
+    return ((1 << getType(codePoint))
+            & ((1 << SPACE_SEPARATOR)
+               | (1 << LINE_SEPARATOR)
+               | (1 << PARAGRAPH_SEPARATOR))) != 0;
+  }
+
+  /**
+   * Determines if a character is Java whitespace. This includes Unicode
+   * space characters (SPACE_SEPARATOR, LINE_SEPARATOR, and
+   * PARAGRAPH_SEPARATOR) except the non-breaking spaces
+   * (<code>'\u00A0'</code>, <code>'\u2007'</code>, and <code>'\u202F'</code>);
+   * and these characters: <code>'\u0009'</code>, <code>'\u000A'</code>,
+   * <code>'\u000B'</code>, <code>'\u000C'</code>, <code>'\u000D'</code>,
+   * <code>'\u001C'</code>, <code>'\u001D'</code>, <code>'\u001E'</code>,
+   * and <code>'\u001F'</code>.
+   * <br>
+   * Java whitespace = ([Zs] not Nb)|[Zl]|[Zp]|U+0009-U+000D|U+001C-U+001F
+   *
+   * @param ch character to test
+   * @return true if ch is Java whitespace, else false
+   * @see #isSpaceChar(char)
+   * @since 1.1
+   */
+  public static boolean isWhitespace(char ch)
+  {
+    return isWhitespace((int) ch);
+  }
+  
+  /**
+   * Determines if a character is Java whitespace. This includes Unicode
+   * space characters (SPACE_SEPARATOR, LINE_SEPARATOR, and
+   * PARAGRAPH_SEPARATOR) except the non-breaking spaces
+   * (<code>'\u00A0'</code>, <code>'\u2007'</code>, and <code>'\u202F'</code>);
+   * and these characters: <code>'\u0009'</code>, <code>'\u000A'</code>,
+   * <code>'\u000B'</code>, <code>'\u000C'</code>, <code>'\u000D'</code>,
+   * <code>'\u001C'</code>, <code>'\u001D'</code>, <code>'\u001E'</code>,
+   * and <code>'\u001F'</code>.
+   * <br>
+   * Java whitespace = ([Zs] not Nb)|[Zl]|[Zp]|U+0009-U+000D|U+001C-U+001F
+   *
+   * @param codePoint character to test
+   * @return true if ch is Java whitespace, else false
+   * @see #isSpaceChar(char)
+   * @since 1.5
+   */
+  public static boolean isWhitespace(int codePoint)
+  {
+    int plane = codePoint >>> 16;
+    if (plane > 2 && plane < 14)
+      return UnassignedCharacters.isWhiteSpace(codePoint);
+    if (plane > 14)
+      return PrivateUseCharacters.isWhiteSpace(codePoint);
+    
+    int attr = readCodePoint(codePoint);
+    return ((((1 << (attr & TYPE_MASK))
+              & ((1 << SPACE_SEPARATOR)
+                 | (1 << LINE_SEPARATOR)
+                 | (1 << PARAGRAPH_SEPARATOR))) != 0)
+            && (attr & NO_BREAK_MASK) == 0)
+      || (codePoint <= '\u001F' && ((1 << codePoint)
+                             & ((1 << '\t')
+                                | (1 << '\n')
+                                | (1 << '\u000B')
+                                | (1 << '\u000C')
+                                | (1 << '\r')
+                                | (1 << '\u001C')
+                                | (1 << '\u001D')
+                                | (1 << '\u001E')
+                                | (1 << '\u001F'))) != 0);
+  }
+
+  /**
+   * Determines if a character has the ISO Control property.
+   * <br>
+   * ISO Control = [Cc]
+   *
+   * @param ch character to test
+   * @return true if ch is an ISO Control character, else false
+   * @see #isSpaceChar(char)
+   * @see #isWhitespace(char)
+   * @since 1.1
+   */
+  public static boolean isISOControl(char ch)
+  {
+    return isISOControl((int)ch);
+  }
+  
+  /**
+   * Determines if the character is an ISO Control character.  This is true
+   * if the code point is in the range [0, 0x001F] or if it is in the range
+   * [0x007F, 0x009F].
+   * @param codePoint the character to check
+   * @return true if the character is in one of the above ranges
+   * 
+   * @since 1.5
+   */
+  public static boolean isISOControl(int codePoint)
+  {
+    if ((codePoint >= 0 && codePoint <= 0x001F)
+        || (codePoint >= 0x007F && codePoint <= 0x009F))
+      return true;
+    return false;      
+  }
+
+  /**
+   * Returns the Unicode general category property of a character.
+   *
+   * @param ch character from which the general category property will
+   *        be retrieved
+   * @return the character category property of ch as an integer
+   * @see #UNASSIGNED
+   * @see #UPPERCASE_LETTER
+   * @see #LOWERCASE_LETTER
+   * @see #TITLECASE_LETTER
+   * @see #MODIFIER_LETTER
+   * @see #OTHER_LETTER
+   * @see #NON_SPACING_MARK
+   * @see #ENCLOSING_MARK
+   * @see #COMBINING_SPACING_MARK
+   * @see #DECIMAL_DIGIT_NUMBER
+   * @see #LETTER_NUMBER
+   * @see #OTHER_NUMBER
+   * @see #SPACE_SEPARATOR
+   * @see #LINE_SEPARATOR
+   * @see #PARAGRAPH_SEPARATOR
+   * @see #CONTROL
+   * @see #FORMAT
+   * @see #PRIVATE_USE
+   * @see #SURROGATE
+   * @see #DASH_PUNCTUATION
+   * @see #START_PUNCTUATION
+   * @see #END_PUNCTUATION
+   * @see #CONNECTOR_PUNCTUATION
+   * @see #OTHER_PUNCTUATION
+   * @see #MATH_SYMBOL
+   * @see #CURRENCY_SYMBOL
+   * @see #MODIFIER_SYMBOL
+   * @see #INITIAL_QUOTE_PUNCTUATION
+   * @see #FINAL_QUOTE_PUNCTUATION
+   * @since 1.1
+   */
+  public static int getType(char ch)
+  {
+    return getType((int)ch);
+  }
+  
+  /**
+   * Returns the Unicode general category property of a character.
+   *
+   * @param codePoint character from which the general category property will
+   *        be retrieved
+   * @return the character category property of ch as an integer
+   * @see #UNASSIGNED
+   * @see #UPPERCASE_LETTER
+   * @see #LOWERCASE_LETTER
+   * @see #TITLECASE_LETTER
+   * @see #MODIFIER_LETTER
+   * @see #OTHER_LETTER
+   * @see #NON_SPACING_MARK
+   * @see #ENCLOSING_MARK
+   * @see #COMBINING_SPACING_MARK
+   * @see #DECIMAL_DIGIT_NUMBER
+   * @see #LETTER_NUMBER
+   * @see #OTHER_NUMBER
+   * @see #SPACE_SEPARATOR
+   * @see #LINE_SEPARATOR
+   * @see #PARAGRAPH_SEPARATOR
+   * @see #CONTROL
+   * @see #FORMAT
+   * @see #PRIVATE_USE
+   * @see #SURROGATE
+   * @see #DASH_PUNCTUATION
+   * @see #START_PUNCTUATION
+   * @see #END_PUNCTUATION
+   * @see #CONNECTOR_PUNCTUATION
+   * @see #OTHER_PUNCTUATION
+   * @see #MATH_SYMBOL
+   * @see #CURRENCY_SYMBOL
+   * @see #MODIFIER_SYMBOL
+   * @see #INITIAL_QUOTE_PUNCTUATION
+   * @see #FINAL_QUOTE_PUNCTUATION
+   * 
+   * @since 1.5
+   */
+  public static int getType(int codePoint)
+  {
+    // If the codePoint is unassigned or in one of the private use areas
+    // then we delegate the call to the appropriate private static inner class.
+    int plane = codePoint >>> 16;
+    if (plane > 2 && plane < 14)
+      return UnassignedCharacters.getType(codePoint);
+    if (plane > 14)
+      return PrivateUseCharacters.getType(codePoint);
+    
+    return readCodePoint(codePoint) & TYPE_MASK;
+  }
+
+  /**
+   * Converts a digit into a character which represents that digit
+   * in a specified radix. If the radix exceeds MIN_RADIX or MAX_RADIX,
+   * or the digit exceeds the radix, then the null character <code>'\0'</code>
+   * is returned.  Otherwise the return value is in '0'-'9' and 'a'-'z'.
+   * <br>
+   * return value boundary = U+0030-U+0039|U+0061-U+007A
+   *
+   * @param digit digit to be converted into a character
+   * @param radix radix of digit
+   * @return character representing digit in radix, or '\0'
+   * @see #MIN_RADIX
+   * @see #MAX_RADIX
+   * @see #digit(char, int)
+   */
+  public static char forDigit(int digit, int radix)
+  {
+    if (radix < MIN_RADIX || radix > MAX_RADIX
+        || digit < 0 || digit >= radix)
+      return '\0';
+    return Number.digits[digit];
+  }
+
+  /**
+   * Returns the Unicode directionality property of the character. This
+   * is used in the visual ordering of text.
+   *
+   * @param ch the character to look up
+   * @return the directionality constant, or DIRECTIONALITY_UNDEFINED
+   * @see #DIRECTIONALITY_UNDEFINED
+   * @see #DIRECTIONALITY_LEFT_TO_RIGHT
+   * @see #DIRECTIONALITY_RIGHT_TO_LEFT
+   * @see #DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC
+   * @see #DIRECTIONALITY_EUROPEAN_NUMBER
+   * @see #DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
+   * @see #DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
+   * @see #DIRECTIONALITY_ARABIC_NUMBER
+   * @see #DIRECTIONALITY_COMMON_NUMBER_SEPARATOR
+   * @see #DIRECTIONALITY_NONSPACING_MARK
+   * @see #DIRECTIONALITY_BOUNDARY_NEUTRAL
+   * @see #DIRECTIONALITY_PARAGRAPH_SEPARATOR
+   * @see #DIRECTIONALITY_SEGMENT_SEPARATOR
+   * @see #DIRECTIONALITY_WHITESPACE
+   * @see #DIRECTIONALITY_OTHER_NEUTRALS
+   * @see #DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING
+   * @see #DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE
+   * @see #DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING
+   * @see #DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE
+   * @see #DIRECTIONALITY_POP_DIRECTIONAL_FORMAT
+   * @since 1.4
+   */
+  public static byte getDirectionality(char ch)
+  {
+    // The result will correctly be signed.
+    return getDirectionality((int)ch);
+  }
+  
+  /**
+   * Returns the Unicode directionality property of the character. This
+   * is used in the visual ordering of text.
+   *
+   * @param codePoint the character to look up
+   * @return the directionality constant, or DIRECTIONALITY_UNDEFINED
+   * @see #DIRECTIONALITY_UNDEFINED
+   * @see #DIRECTIONALITY_LEFT_TO_RIGHT
+   * @see #DIRECTIONALITY_RIGHT_TO_LEFT
+   * @see #DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC
+   * @see #DIRECTIONALITY_EUROPEAN_NUMBER
+   * @see #DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
+   * @see #DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
+   * @see #DIRECTIONALITY_ARABIC_NUMBER
+   * @see #DIRECTIONALITY_COMMON_NUMBER_SEPARATOR
+   * @see #DIRECTIONALITY_NONSPACING_MARK
+   * @see #DIRECTIONALITY_BOUNDARY_NEUTRAL
+   * @see #DIRECTIONALITY_PARAGRAPH_SEPARATOR
+   * @see #DIRECTIONALITY_SEGMENT_SEPARATOR
+   * @see #DIRECTIONALITY_WHITESPACE
+   * @see #DIRECTIONALITY_OTHER_NEUTRALS
+   * @see #DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING
+   * @see #DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE
+   * @see #DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING
+   * @see #DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE
+   * @see #DIRECTIONALITY_POP_DIRECTIONAL_FORMAT
+   * @since 1.5
+   */
+  public static byte getDirectionality(int codePoint)
+  {
+    // If the code point is unassigned or in one of the private use areas
+    // then we delegate the call to the appropriate private static inner class.
+    int plane = codePoint >>> 16;
+    if (plane > 2 && plane < 14)
+      return UnassignedCharacters.getDirectionality(codePoint);
+    if (plane > 14)
+      return PrivateUseCharacters.getDirectionality(codePoint);
+    
+    // The result will correctly be signed.
+    return (byte) (direction[plane][readCodePoint(codePoint) >> 7] >> 2);
+  }
+  
+  /**
+   * Determines whether the character is mirrored according to Unicode. For
+   * example, <code>\u0028</code> (LEFT PARENTHESIS) appears as '(' in
+   * left-to-right text, but ')' in right-to-left text.
+   *
+   * @param ch the character to look up
+   * @return true if the character is mirrored
+   * @since 1.4
+   */
+  public static boolean isMirrored(char ch)
+  {
+    return (readCodePoint((int)ch) & MIRROR_MASK) != 0;
+  }
+  
+  /**
+   * Determines whether the character is mirrored according to Unicode. For
+   * example, <code>\u0028</code> (LEFT PARENTHESIS) appears as '(' in
+   * left-to-right text, but ')' in right-to-left text.
+   *
+   * @param codePoint the character to look up
+   * @return true if the character is mirrored
+   * @since 1.5
+   */
+  public static boolean isMirrored(int codePoint)
+  {
+    // If the code point is unassigned or part of one of the private use areas
+    // then we delegate the call to the appropriate private static inner class.
+    int plane = codePoint >>> 16;
+    if (plane > 2 && plane < 14)
+      return UnassignedCharacters.isMirrored(codePoint);
+    if (plane > 14)
+      return PrivateUseCharacters.isMirrored(codePoint);
+    
+    return (readCodePoint(codePoint) & MIRROR_MASK) != 0;
+  }
+
+  /**
+   * Compares another Character to this Character, numerically.
+   *
+   * @param anotherCharacter Character to compare with this Character
+   * @return a negative integer if this Character is less than
+   *         anotherCharacter, zero if this Character is equal, and
+   *         a positive integer if this Character is greater
+   * @throws NullPointerException if anotherCharacter is null
+   * @since 1.2
+   */
+  public int compareTo(Character anotherCharacter)
+  {
+    return value - anotherCharacter.value;
+  }
+
+  /**
+   * Compares an object to this Character.  Assuming the object is a
+   * Character object, this method performs the same comparison as
+   * compareTo(Character).
+   *
+   * @param o object to compare
+   * @return the comparison value
+   * @throws ClassCastException if o is not a Character object
+   * @throws NullPointerException if o is null
+   * @see #compareTo(Character)
+   * @since 1.2
+   */
+  public int compareTo(Object o)
+  {
+    return compareTo((Character) o);
+  }
+
+  /**
+   * Returns an <code>Character</code> object wrapping the value.
+   * In contrast to the <code>Character</code> constructor, this method
+   * will cache some values.  It is used by boxing conversion.
+   *
+   * @param val the value to wrap
+   * @return the <code>Character</code>
+   * 
+   * @since 1.5
+   */
+  public static Character valueOf(char val)
+  {
+    if (val > MAX_CACHE)
+      return new Character(val);
+    synchronized (charCache)
+      {
+    if (charCache[val - MIN_VALUE] == null)
+      charCache[val - MIN_VALUE] = new Character(val);
+    return charCache[val - MIN_VALUE];
+      }
+  }
+
+  /**
+   * Reverse the bytes in val.
+   * @since 1.5
+   */
+  public static char reverseBytes(char val)
+  {
+    return (char) (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
+  }
+
+  /**
+   * Converts a unicode code point to a UTF-16 representation of that
+   * code point.
+   * 
+   * @param codePoint the unicode code point
+   *
+   * @return the UTF-16 representation of that code point
+   *
+   * @throws IllegalArgumentException if the code point is not a valid
+   *         unicode code point
+   *
+   * @since 1.5
+   */
+  public static char[] toChars(int codePoint)
+  {
+    if (!isValidCodePoint(codePoint))
+      throw new IllegalArgumentException("Illegal Unicode code point : "
+                                         + codePoint);
+    char[] result = new char[charCount(codePoint)];
+    int ignore = toChars(codePoint, result, 0);
+    return result;
+  }
+
+  /**
+   * Converts a unicode code point to its UTF-16 representation.
+   *
+   * @param codePoint the unicode code point
+   * @param dst the target char array
+   * @param dstIndex the start index for the target
+   *
+   * @return number of characters written to <code>dst</code>
+   *
+   * @throws IllegalArgumentException if <code>codePoint</code> is not a
+   *         valid unicode code point
+   * @throws NullPointerException if <code>dst</code> is <code>null</code>
+   * @throws IndexOutOfBoundsException if <code>dstIndex</code> is not valid
+   *         in <code>dst</code> or if the UTF-16 representation does not
+   *         fit into <code>dst</code>
+   *
+   * @since 1.5
+   */
+  public static int toChars(int codePoint, char[] dst, int dstIndex)
+  {
+    if (!isValidCodePoint(codePoint))
+      {
+        throw new IllegalArgumentException("not a valid code point: "
+                                           + codePoint);
+      }
+
+    int result;
+    if (isSupplementaryCodePoint(codePoint))
+      {
+        // Write second char first to cause IndexOutOfBoundsException
+        // immediately.
+        final int cp2 = codePoint - 0x10000;
+        dst[dstIndex + 1] = (char) ((cp2 % 0x400) + (int) MIN_LOW_SURROGATE);
+        dst[dstIndex] = (char) ((cp2 / 0x400) + (int) MIN_HIGH_SURROGATE);
+        result = 2;
+      }
+    else
+      {
+        dst[dstIndex] = (char) codePoint;
+        result = 1; 
+      }
+    return result;
+  }
+
+  /**
+   * Return number of 16-bit characters required to represent the given
+   * code point.
+   *
+   * @param codePoint a unicode code point
+   *
+   * @return 2 if codePoint >= 0x10000, 1 otherwise.
+   *
+   * @since 1.5
+   */
+  public static int charCount(int codePoint)
+  {
+    return 
+      (codePoint >= MIN_SUPPLEMENTARY_CODE_POINT) 
+      ? 2 
+      : 1;
+  }
+
+  /**
+   * Determines whether the specified code point is
+   * in the range 0x10000 .. 0x10FFFF, i.e. the character is within the Unicode
+   * supplementary character range.
+   *
+   * @param codePoint a Unicode code point
+   *
+   * @return <code>true</code> if code point is in supplementary range
+   *
+   * @since 1.5
+   */
+  public static boolean isSupplementaryCodePoint(int codePoint)
+  {
+    return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT
+      && codePoint <= MAX_CODE_POINT;
+  }
+
+  /**
+   * Determines whether the specified code point is
+   * in the range 0x0000 .. 0x10FFFF, i.e. it is a valid Unicode code point.
+   *
+   * @param codePoint a Unicode code point
+   *
+   * @return <code>true</code> if code point is valid
+   *
+   * @since 1.5
+   */
+  public static boolean isValidCodePoint(int codePoint)
+  {
+    return codePoint >= MIN_CODE_POINT && codePoint <= MAX_CODE_POINT;
+  }
+
+  /**
+   * Return true if the given character is a high surrogate.
+   * @param ch the character
+   * @return true if the character is a high surrogate character
+   *
+   * @since 1.5
+   */
+  public static boolean isHighSurrogate(char ch)
+  {
+    return ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE;
+  }
+
+  /**
+   * Return true if the given character is a low surrogate.
+   * @param ch the character
+   * @return true if the character is a low surrogate character
+   *
+   * @since 1.5
+   */
+  public static boolean isLowSurrogate(char ch)
+  {
+    return ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE;
+  }
+
+  /**
+   * Return true if the given characters compose a surrogate pair.
+   * This is true if the first character is a high surrogate and the
+   * second character is a low surrogate.
+   * @param ch1 the first character
+   * @param ch2 the first character
+   * @return true if the characters compose a surrogate pair
+   *
+   * @since 1.5
+   */
+  public static boolean isSurrogatePair(char ch1, char ch2)
+  {
+    return isHighSurrogate(ch1) && isLowSurrogate(ch2);
+  }
+
+  /**
+   * Given a valid surrogate pair, this returns the corresponding
+   * code point.
+   * @param high the high character of the pair
+   * @param low the low character of the pair
+   * @return the corresponding code point
+   *
+   * @since 1.5
+   */
+  public static int toCodePoint(char high, char low)
+  {
+    return ((high - MIN_HIGH_SURROGATE) * 0x400) +
+      (low - MIN_LOW_SURROGATE) + 0x10000;
+  }
+
+  /**
+   * Get the code point at the specified index in the CharSequence.
+   * This is like CharSequence#charAt(int), but if the character is
+   * the start of a surrogate pair, and there is a following
+   * character, and this character completes the pair, then the
+   * corresponding supplementary code point is returned.  Otherwise,
+   * the character at the index is returned.
+   *
+   * @param sequence the CharSequence
+   * @param index the index of the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   * @since 1.5
+   */
+  public static int codePointAt(CharSequence sequence, int index)
+  {
+    int len = sequence.length();
+    if (index < 0 || index >= len)
+      throw new IndexOutOfBoundsException();
+    char high = sequence.charAt(index);
+    if (! isHighSurrogate(high) || ++index >= len)
+      return high;
+    char low = sequence.charAt(index);
+    if (! isLowSurrogate(low))
+      return high;
+    return toCodePoint(high, low);
+  }
+
+  /**
+   * Get the code point at the specified index in the CharSequence.
+   * If the character is the start of a surrogate pair, and there is a
+   * following character, and this character completes the pair, then
+   * the corresponding supplementary code point is returned.
+   * Otherwise, the character at the index is returned.
+   *
+   * @param chars the character array in which to look
+   * @param index the index of the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   * @since 1.5
+   */
+  public static int codePointAt(char[] chars, int index)
+  {
+    return codePointAt(chars, index, chars.length);
+  }
+
+  /**
+   * Get the code point at the specified index in the CharSequence.
+   * If the character is the start of a surrogate pair, and there is a
+   * following character within the specified range, and this
+   * character completes the pair, then the corresponding
+   * supplementary code point is returned.  Otherwise, the character
+   * at the index is returned.
+   *
+   * @param chars the character array in which to look
+   * @param index the index of the codepoint to get, starting at 0
+   * @param limit the limit past which characters should not be examined
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or >=
+   * limit, or if limit is negative or >= the length of the array
+   * @since 1.5
+   */
+  public static int codePointAt(char[] chars, int index, int limit)
+  {
+    if (index < 0 || index >= limit || limit < 0 || limit > chars.length)
+      throw new IndexOutOfBoundsException();
+    char high = chars[index];
+    if (! isHighSurrogate(high) || ++index >= limit)
+      return high;
+    char low = chars[index];
+    if (! isLowSurrogate(low))
+      return high;
+    return toCodePoint(high, low);
+  }
+
+  /**
+   * Get the code point before the specified index.  This is like
+   * #codePointAt(char[], int), but checks the characters at
+   * <code>index-1</code> and <code>index-2</code> to see if they form
+   * a supplementary code point.  If they do not, the character at
+   * <code>index-1</code> is returned.
+   *
+   * @param chars the character array
+   * @param index the index just past the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   * @since 1.5
+   */
+  public static int codePointBefore(char[] chars, int index)
+  {
+    return codePointBefore(chars, index, 1);
+  }
+
+  /**
+   * Get the code point before the specified index.  This is like
+   * #codePointAt(char[], int), but checks the characters at
+   * <code>index-1</code> and <code>index-2</code> to see if they form
+   * a supplementary code point.  If they do not, the character at
+   * <code>index-1</code> is returned.  The start parameter is used to
+   * limit the range of the array which may be examined.
+   *
+   * @param chars the character array
+   * @param index the index just past the codepoint to get, starting at 0
+   * @param start the index before which characters should not be examined
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is > start or >
+   * the length of the array, or if limit is negative or >= the
+   * length of the array
+   * @since 1.5
+   */
+  public static int codePointBefore(char[] chars, int index, int start)
+  {
+    if (index < start || index > chars.length
+	|| start < 0 || start >= chars.length)
+      throw new IndexOutOfBoundsException();
+    --index;
+    char low = chars[index];
+    if (! isLowSurrogate(low) || --index < start)
+      return low;
+    char high = chars[index];
+    if (! isHighSurrogate(high))
+      return low;
+    return toCodePoint(high, low);
+  }
+
+  /**
+   * Get the code point before the specified index.  This is like
+   * #codePointAt(CharSequence, int), but checks the characters at
+   * <code>index-1</code> and <code>index-2</code> to see if they form
+   * a supplementary code point.  If they do not, the character at
+   * <code>index-1</code> is returned.
+   *
+   * @param sequence the CharSequence
+   * @param index the index just past the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   * @since 1.5
+   */
+  public static int codePointBefore(CharSequence sequence, int index)
+  {
+    int len = sequence.length();
+    if (index < 1 || index > len)
+      throw new IndexOutOfBoundsException();
+    --index;
+    char low = sequence.charAt(index);
+    if (! isLowSurrogate(low) || --index < 0)
+      return low;
+    char high = sequence.charAt(index);
+    if (! isHighSurrogate(high))
+      return low;
+    return toCodePoint(high, low);
+  }
+} // class Character

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Class.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Class.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1795 @@
+/* Class.java -- Representation of a Java class.
+   Copyright (C) 1998, 1999, 2000, 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.lang.reflect.ClassSignatureParser;
+
+import java.io.InputStream;
+import java.io.ObjectStreamClass;
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.GenericDeclaration;
+import java.lang.reflect.GenericSignatureFormatError;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.MalformedParameterizedTypeException;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.AllPermission;
+import java.security.Permissions;
+import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+
+
+/**
+ * A Class represents a Java type.  There will never be multiple Class
+ * objects with identical names and ClassLoaders. Primitive types, array
+ * types, and void also have a Class object.
+ *
+ * <p>Arrays with identical type and number of dimensions share the same class.
+ * The array class ClassLoader is the same as the ClassLoader of the element
+ * type of the array (which can be null to indicate the bootstrap classloader).
+ * The name of an array class is <code>[<signature format>;</code>.
+ * <p> For example,
+ * String[]'s class is <code>[Ljava.lang.String;</code>. boolean, byte,
+ * short, char, int, long, float and double have the "type name" of
+ * Z,B,S,C,I,J,F,D for the purposes of array classes.  If it's a
+ * multidimensioned array, the same principle applies:
+ * <code>int[][][]</code> == <code>[[[I</code>.
+ *
+ * <p>There is no public constructor - Class objects are obtained only through
+ * the virtual machine, as defined in ClassLoaders.
+ *
+ * @serialData Class objects serialize specially:
+ * <code>TC_CLASS ClassDescriptor</code>. For more serialization information,
+ * see {@link ObjectStreamClass}.
+ *
+ * @author John Keiser
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @since 1.0
+ * @see ClassLoader
+ */
+public final class Class 
+  implements Serializable, Type, AnnotatedElement, GenericDeclaration
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 3206093459760846163L;
+
+  /**
+   * Flag indicating a synthetic member.
+   * Note that this duplicates a constant in Modifier.
+   */
+  private static final int SYNTHETIC = 0x1000;
+
+  /**
+   * Flag indiciating an annotation class.
+   */
+  private static final int ANNOTATION = 0x2000;
+
+  /**
+   * Flag indicating an enum constant or an enum class.
+   * Note that this duplicates a constant in Modifier.
+   */
+  private static final int ENUM = 0x4000;
+
+  /** The class signers. */
+  private Object[] signers = null;
+  /** The class protection domain. */
+  private final transient ProtectionDomain pd;
+
+  /* We use an inner class, so that Class doesn't have a static initializer */
+  private static final class StaticData
+  {
+    static final ProtectionDomain unknownProtectionDomain;
+
+    static
+    {
+      Permissions permissions = new Permissions();
+      permissions.add(new AllPermission());
+      unknownProtectionDomain = new ProtectionDomain(null, permissions);
+    }
+  }
+
+  final transient Object vmdata;
+
+  /** newInstance() caches the default constructor */
+  private transient Constructor constructor;
+
+  /**
+   * Class is non-instantiable from Java code; only the VM can create
+   * instances of this class.
+   */
+  Class(Object vmdata)
+  {
+    this(vmdata, null);
+  }
+
+  Class(Object vmdata, ProtectionDomain pd)
+  {
+    this.vmdata = vmdata;
+    // If the VM didn't supply a protection domain and the class is an array,
+    // we "inherit" the protection domain from the component type class. This
+    // saves the VM from having to worry about protection domains for array
+    // classes.
+    if (pd == null && isArray())
+      this.pd = getComponentType().pd;
+    else
+      this.pd = pd;
+  }
+
+  /**
+   * Use the classloader of the current class to load, link, and initialize
+   * a class. This is equivalent to your code calling
+   * <code>Class.forName(name, true, getClass().getClassLoader())</code>.
+   *
+   * @param name the name of the class to find
+   * @return the Class object representing the class
+   * @throws ClassNotFoundException if the class was not found by the
+   *         classloader
+   * @throws LinkageError if linking the class fails
+   * @throws ExceptionInInitializerError if the class loads, but an exception
+   *         occurs during initialization
+   */
+  public static Class forName(String name) throws ClassNotFoundException
+  {
+    return VMClass.forName(name, true, VMStackWalker.getCallingClassLoader());
+  }
+
+  /**
+   * Use the specified classloader to load and link a class. If the loader
+   * is null, this uses the bootstrap class loader (provide the security
+   * check succeeds). Unfortunately, this method cannot be used to obtain
+   * the Class objects for primitive types or for void, you have to use
+   * the fields in the appropriate java.lang wrapper classes.
+   *
+   * <p>Calls <code>classloader.loadclass(name, initialize)</code>.
+   *
+   * @param name the name of the class to find
+   * @param initialize whether or not to initialize the class at this time
+   * @param classloader the classloader to use to find the class; null means
+   *        to use the bootstrap class loader
+   *
+   * @return the class object for the given class
+   *
+   * @throws ClassNotFoundException if the class was not found by the
+   *         classloader
+   * @throws LinkageError if linking the class fails
+   * @throws ExceptionInInitializerError if the class loads, but an exception
+   *         occurs during initialization
+   * @throws SecurityException if the <code>classloader</code> argument
+   *         is <code>null</code> and the caller does not have the
+   *         <code>RuntimePermission("getClassLoader")</code> permission
+   * @see ClassLoader
+   * @since 1.2
+   */
+  public static Class forName(String name, boolean initialize,
+                              ClassLoader classloader)
+    throws ClassNotFoundException
+  {
+    if (classloader == null)
+      {
+        // Check if we may access the bootstrap classloader
+        SecurityManager sm = SecurityManager.current;
+        if (sm != null)
+          {
+            // Get the calling classloader
+            ClassLoader cl = VMStackWalker.getCallingClassLoader();
+            if (cl != null)
+              sm.checkPermission(new RuntimePermission("getClassLoader"));
+          }
+      }
+    return VMClass.forName(name, initialize, classloader);
+  }
+  
+  /**
+   * Get all the public member classes and interfaces declared in this
+   * class or inherited from superclasses. This returns an array of length
+   * 0 if there are no member classes, including for primitive types. A
+   * security check may be performed, with
+   * <code>checkMemberAccess(this, Member.PUBLIC)</code> as well as
+   * <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @return all public member classes in this class
+   * @throws SecurityException if the security check fails
+   * @since 1.1
+   */
+  public Class[] getClasses()
+  {
+    memberAccessCheck(Member.PUBLIC);
+    return internalGetClasses();
+  }
+
+  /**
+   * Like <code>getClasses()</code> but without the security checks.
+   */
+  private Class[] internalGetClasses()
+  {
+    ArrayList list = new ArrayList();
+    list.addAll(Arrays.asList(getDeclaredClasses(true)));
+    Class superClass = getSuperclass();
+    if (superClass != null)
+      list.addAll(Arrays.asList(superClass.internalGetClasses()));
+    return (Class[])list.toArray(new Class[list.size()]);
+  }
+  
+  /**
+   * Get the ClassLoader that loaded this class.  If the class was loaded
+   * by the bootstrap classloader, this method will return null.
+   * If there is a security manager, and the caller's class loader is not
+   * an ancestor of the requested one, a security check of
+   * <code>RuntimePermission("getClassLoader")</code>
+   * must first succeed. Primitive types and void return null.
+   *
+   * @return the ClassLoader that loaded this class
+   * @throws SecurityException if the security check fails
+   * @see ClassLoader
+   * @see RuntimePermission
+   */
+  public ClassLoader getClassLoader()
+  {
+    if (isPrimitive())
+      return null;
+
+    ClassLoader loader = VMClass.getClassLoader(this);
+    // 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;
+  }
+
+  /**
+   * If this is an array, get the Class representing the type of array.
+   * Examples: "[[Ljava.lang.String;" would return "[Ljava.lang.String;", and
+   * calling getComponentType on that would give "java.lang.String".  If
+   * this is not an array, returns null.
+   *
+   * @return the array type of this class, or null
+   * @see Array
+   * @since 1.1
+   */
+  public Class getComponentType()
+  {
+    return VMClass.getComponentType (this);
+  }
+
+  /**
+   * Get a public constructor declared in this class. If the constructor takes
+   * no argument, an array of zero elements and null are equivalent for the
+   * types argument. A security check may be performed, with
+   * <code>checkMemberAccess(this, Member.PUBLIC)</code> as well as
+   * <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @param types the type of each parameter
+   * @return the constructor
+   * @throws NoSuchMethodException if the constructor does not exist
+   * @throws SecurityException if the security check fails
+   * @see #getConstructors()
+   * @since 1.1
+   */
+  public Constructor getConstructor(Class[] types) throws NoSuchMethodException
+  {
+    memberAccessCheck(Member.PUBLIC);
+    Constructor[] constructors = getDeclaredConstructors(true);
+    for (int i = 0; i < constructors.length; i++)
+      {
+	Constructor constructor = constructors[i];
+	if (matchParameters(types, constructor.getParameterTypes()))
+	  return constructor;
+      }
+    throw new NoSuchMethodException();
+  }
+
+  /**
+   * Get all the public constructors of this class. This returns an array of
+   * length 0 if there are no constructors, including for primitive types,
+   * arrays, and interfaces. It does, however, include the default
+   * constructor if one was supplied by the compiler. A security check may
+   * be performed, with <code>checkMemberAccess(this, Member.PUBLIC)</code>
+   * as well as <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @return all public constructors in this class
+   * @throws SecurityException if the security check fails
+   * @since 1.1
+   */
+  public Constructor[] getConstructors()
+  {
+    memberAccessCheck(Member.PUBLIC);
+    return getDeclaredConstructors(true);
+  }
+
+  /**
+   * Get a constructor declared in this class. If the constructor takes no
+   * argument, an array of zero elements and null are equivalent for the
+   * types argument. A security check may be performed, with
+   * <code>checkMemberAccess(this, Member.DECLARED)</code> as well as
+   * <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @param types the type of each parameter
+   * @return the constructor
+   * @throws NoSuchMethodException if the constructor does not exist
+   * @throws SecurityException if the security check fails
+   * @see #getDeclaredConstructors()
+   * @since 1.1
+   */
+  public Constructor getDeclaredConstructor(Class[] types)
+    throws NoSuchMethodException
+  {
+    memberAccessCheck(Member.DECLARED);
+    Constructor[] constructors = getDeclaredConstructors(false);
+    for (int i = 0; i < constructors.length; i++)
+      {
+	Constructor constructor = constructors[i];
+	if (matchParameters(types, constructor.getParameterTypes()))
+	  return constructor;
+      }
+    throw new NoSuchMethodException();
+  }
+
+  /**
+   * Get all the declared member classes and interfaces in this class, but
+   * not those inherited from superclasses. This returns an array of length
+   * 0 if there are no member classes, including for primitive types. A
+   * security check may be performed, with
+   * <code>checkMemberAccess(this, Member.DECLARED)</code> as well as
+   * <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @return all declared member classes in this class
+   * @throws SecurityException if the security check fails
+   * @since 1.1
+   */
+  public Class[] getDeclaredClasses()
+  {
+    memberAccessCheck(Member.DECLARED);
+    return getDeclaredClasses(false);
+  }
+
+  Class[] getDeclaredClasses (boolean publicOnly)
+  {
+    return VMClass.getDeclaredClasses (this, publicOnly);
+  }
+
+  /**
+   * Get all the declared constructors of this class. This returns an array of
+   * length 0 if there are no constructors, including for primitive types,
+   * arrays, and interfaces. It does, however, include the default
+   * constructor if one was supplied by the compiler. A security check may
+   * be performed, with <code>checkMemberAccess(this, Member.DECLARED)</code>
+   * as well as <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @return all constructors in this class
+   * @throws SecurityException if the security check fails
+   * @since 1.1
+   */
+  public Constructor[] getDeclaredConstructors()
+  {
+    memberAccessCheck(Member.DECLARED);
+    return getDeclaredConstructors(false);
+  }
+
+  Constructor[] getDeclaredConstructors (boolean publicOnly)
+  {
+    return VMClass.getDeclaredConstructors (this, publicOnly);
+  }
+  
+  /**
+   * Get a field declared in this class, where name is its simple name. The
+   * implicit length field of arrays is not available. A security check may
+   * be performed, with <code>checkMemberAccess(this, Member.DECLARED)</code>
+   * as well as <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @param name the name of the field
+   * @return the field
+   * @throws NoSuchFieldException if the field does not exist
+   * @throws SecurityException if the security check fails
+   * @see #getDeclaredFields()
+   * @since 1.1
+   */
+  public Field getDeclaredField(String name) throws NoSuchFieldException
+  {
+    memberAccessCheck(Member.DECLARED);
+    Field[] fields = getDeclaredFields(false);
+    for (int i = 0; i < fields.length; i++)
+      {
+	if (fields[i].getName().equals(name))
+	  return fields[i];
+      }
+    throw new NoSuchFieldException();
+  }
+
+  /**
+   * Get all the declared fields in this class, but not those inherited from
+   * superclasses. This returns an array of length 0 if there are no fields,
+   * including for primitive types. This does not return the implicit length
+   * field of arrays. A security check may be performed, with
+   * <code>checkMemberAccess(this, Member.DECLARED)</code> as well as
+   * <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @return all declared fields in this class
+   * @throws SecurityException if the security check fails
+   * @since 1.1
+   */
+  public Field[] getDeclaredFields()
+  {
+    memberAccessCheck(Member.DECLARED);
+    return getDeclaredFields(false);
+  }
+
+  Field[] getDeclaredFields (boolean publicOnly)
+  {
+    return VMClass.getDeclaredFields (this, publicOnly);
+  }
+
+  /**
+   * Get a method declared in this class, where name is its simple name. The
+   * implicit methods of Object are not available from arrays or interfaces.
+   * Constructors (named "<init>" in the class file) and class initializers
+   * (name "<clinit>") are not available.  The Virtual Machine allows
+   * multiple methods with the same signature but differing return types; in
+   * such a case the most specific return types are favored, then the final
+   * choice is arbitrary. If the method takes no argument, an array of zero
+   * elements and null are equivalent for the types argument. A security
+   * check may be performed, with
+   * <code>checkMemberAccess(this, Member.DECLARED)</code> as well as
+   * <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @param methodName the name of the method
+   * @param types the type of each parameter
+   * @return the method
+   * @throws NoSuchMethodException if the method does not exist
+   * @throws SecurityException if the security check fails
+   * @see #getDeclaredMethods()
+   * @since 1.1
+   */
+  public Method getDeclaredMethod(String methodName, Class[] types)
+    throws NoSuchMethodException
+  {
+    memberAccessCheck(Member.DECLARED);
+    Method match = matchMethod(getDeclaredMethods(false), methodName, types);
+    if (match == null)
+      throw new NoSuchMethodException(methodName);
+    return match;
+  }
+
+  /**
+   * Get all the declared methods in this class, but not those inherited from
+   * superclasses. This returns an array of length 0 if there are no methods,
+   * including for primitive types. This does include the implicit methods of
+   * arrays and interfaces which mirror methods of Object, nor does it
+   * include constructors or the class initialization methods. The Virtual
+   * Machine allows multiple methods with the same signature but differing
+   * return types; all such methods are in the returned array. A security
+   * check may be performed, with
+   * <code>checkMemberAccess(this, Member.DECLARED)</code> as well as
+   * <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @return all declared methods in this class
+   * @throws SecurityException if the security check fails
+   * @since 1.1
+   */
+  public Method[] getDeclaredMethods()
+  {
+    memberAccessCheck(Member.DECLARED);
+    return getDeclaredMethods(false);
+  }
+
+  Method[] getDeclaredMethods (boolean publicOnly)
+  {
+    return VMClass.getDeclaredMethods (this, publicOnly);
+  }
+ 
+  /**
+   * If this is a nested or inner class, return the class that declared it.
+   * If not, return null.
+   *
+   * @return the declaring class of this class
+   * @since 1.1
+   */
+  public Class getDeclaringClass()
+  {
+    return VMClass.getDeclaringClass (this);
+  }
+
+  /**
+   * Get a public field declared or inherited in this class, where name is
+   * its simple name. If the class contains multiple accessible fields by
+   * that name, an arbitrary one is returned. The implicit length field of
+   * arrays is not available. A security check may be performed, with
+   * <code>checkMemberAccess(this, Member.PUBLIC)</code> as well as
+   * <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @param fieldName the name of the field
+   * @return the field
+   * @throws NoSuchFieldException if the field does not exist
+   * @throws SecurityException if the security check fails
+   * @see #getFields()
+   * @since 1.1
+   */
+  public Field getField(String fieldName)
+    throws NoSuchFieldException
+  {
+    memberAccessCheck(Member.PUBLIC);
+    Field field = internalGetField(fieldName);
+    if (field == null)
+      throw new NoSuchFieldException(fieldName);
+    return field;
+  }
+
+  /**
+   * Get all the public fields declared in this class or inherited from
+   * superclasses. This returns an array of length 0 if there are no fields,
+   * including for primitive types. This does not return the implicit length
+   * field of arrays. A security check may be performed, with
+   * <code>checkMemberAccess(this, Member.PUBLIC)</code> as well as
+   * <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @return all public fields in this class
+   * @throws SecurityException if the security check fails
+   * @since 1.1
+   */
+  public Field[] getFields()
+  {
+    memberAccessCheck(Member.PUBLIC);
+    return internalGetFields();
+  }
+
+  /**
+   * Like <code>getFields()</code> but without the security checks.
+   */
+  private Field[] internalGetFields()
+  {
+    HashSet set = new HashSet();
+    set.addAll(Arrays.asList(getDeclaredFields(true)));
+    Class[] interfaces = getInterfaces();
+    for (int i = 0; i < interfaces.length; i++)
+      set.addAll(Arrays.asList(interfaces[i].internalGetFields()));
+    Class superClass = getSuperclass();
+    if (superClass != null)
+      set.addAll(Arrays.asList(superClass.internalGetFields()));
+    return (Field[])set.toArray(new Field[set.size()]);
+  }
+
+  /**
+   * Returns the <code>Package</code> in which this class is defined
+   * Returns null when this information is not available from the
+   * classloader of this class.
+   *
+   * @return the package for this class, if it is available
+   * @since 1.2
+   */
+  public Package getPackage()
+  {
+    ClassLoader cl = getClassLoader();
+    if (cl != null)
+      return cl.getPackage(getPackagePortion(getName()));
+    else
+      return VMClassLoader.getPackage(getPackagePortion(getName()));
+  }
+
+  /**
+   * Get the interfaces this class <em>directly</em> implements, in the
+   * order that they were declared. This returns an empty array, not null,
+   * for Object, primitives, void, and classes or interfaces with no direct
+   * superinterface. Array types return Cloneable and Serializable.
+   *
+   * @return the interfaces this class directly implements
+   */
+  public Class[] getInterfaces()
+  {
+    return VMClass.getInterfaces (this);
+  }
+
+  private static final class MethodKey
+  {
+    private String name;
+    private Class[] params;
+    private Class returnType;
+    private int hash;
+    
+    MethodKey(Method m)
+    {
+      name = m.getName();
+      params = m.getParameterTypes();
+      returnType = m.getReturnType();
+      hash = name.hashCode() ^ returnType.hashCode();
+      for(int i = 0; i < params.length; i++)
+	{
+	  hash ^= params[i].hashCode();
+	}
+    }
+    
+    public boolean equals(Object o)
+    {
+      if (o instanceof MethodKey)
+	{
+	  MethodKey m = (MethodKey) o;
+	  if (m.name.equals(name) && m.params.length == params.length
+              && m.returnType == returnType)
+	    {
+	      for (int i = 0; i < params.length; i++)
+		{
+		  if (m.params[i] != params[i])
+		    return false;
+		}
+	      return true;
+	    }
+	}
+      return false;
+    }
+    
+    public int hashCode()
+    {
+      return hash;
+    }
+  }
+  
+  /**
+   * Get a public method declared or inherited in this class, where name is
+   * its simple name. The implicit methods of Object are not available from
+   * interfaces.  Constructors (named "<init>" in the class file) and class
+   * initializers (name "<clinit>") are not available.  The Virtual
+   * Machine allows multiple methods with the same signature but differing
+   * return types, and the class can inherit multiple methods of the same
+   * return type; in such a case the most specific return types are favored,
+   * then the final choice is arbitrary. If the method takes no argument, an
+   * array of zero elements and null are equivalent for the types argument.
+   * A security check may be performed, with
+   * <code>checkMemberAccess(this, Member.PUBLIC)</code> as well as
+   * <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @param methodName the name of the method
+   * @param types the type of each parameter
+   * @return the method
+   * @throws NoSuchMethodException if the method does not exist
+   * @throws SecurityException if the security check fails
+   * @see #getMethods()
+   * @since 1.1
+   */
+  public Method getMethod(String methodName, Class[] types)
+    throws NoSuchMethodException
+  {
+    memberAccessCheck(Member.PUBLIC);
+    Method method = internalGetMethod(methodName, types);
+    if (method == null)
+      throw new NoSuchMethodException(methodName);
+    return method;
+  }
+
+  /**
+   * Like <code>getMethod(String,Class[])</code> but without the security
+   * checks and returns null instead of throwing NoSuchMethodException.
+   */
+  private Method internalGetMethod(String methodName, Class[] args)
+  {
+    Method match = matchMethod(getDeclaredMethods(true), methodName, args);
+    if (match != null)
+      return match;
+    Class superClass = getSuperclass();
+    if (superClass != null)
+      {
+	match = superClass.internalGetMethod(methodName, args);
+	if(match != null)
+	  return match;
+      }
+    Class[] interfaces = getInterfaces();
+    for (int i = 0; i < interfaces.length; i++)
+      {
+	match = interfaces[i].internalGetMethod(methodName, args);
+	if (match != null)
+	  return match;
+      }
+    return null;
+  }
+
+  /** 
+   * Find the best matching method in <code>list</code> according to
+   * the definition of ``best matching'' used by <code>getMethod()</code>
+   *
+   * <p>
+   * Returns the method if any, otherwise <code>null</code>.
+   *
+   * @param list List of methods to search
+   * @param name Name of method
+   * @param args Method parameter types
+   * @see #getMethod(String, Class[])
+   */
+  private static Method matchMethod(Method[] list, String name, Class[] args)
+  {
+    Method match = null;
+    for (int i = 0; i < list.length; i++)
+      {
+	Method method = list[i];
+	if (!method.getName().equals(name))
+	  continue;
+	if (!matchParameters(args, method.getParameterTypes()))
+	  continue;
+	if (match == null
+	    || match.getReturnType().isAssignableFrom(method.getReturnType()))
+	  match = method;
+      }
+    return match;
+  }
+
+  /**
+   * Check for an exact match between parameter type lists.
+   * Either list may be <code>null</code> to mean a list of
+   * length zero.
+   */
+  private static boolean matchParameters(Class[] types1, Class[] types2)
+  {
+    if (types1 == null)
+      return types2 == null || types2.length == 0;
+    if (types2 == null)
+      return types1 == null || types1.length == 0;
+    if (types1.length != types2.length)
+      return false;
+    for (int i = 0; i < types1.length; i++)
+      {
+	if (types1[i] != types2[i])
+	  return false;
+      }
+    return true;
+  }
+  
+  /**
+   * Get all the public methods declared in this class or inherited from
+   * superclasses. This returns an array of length 0 if there are no methods,
+   * including for primitive types. This does not include the implicit
+   * methods of interfaces which mirror methods of Object, nor does it
+   * include constructors or the class initialization methods. The Virtual
+   * Machine allows multiple methods with the same signature but differing
+   * return types; all such methods are in the returned array. A security
+   * check may be performed, with
+   * <code>checkMemberAccess(this, Member.PUBLIC)</code> as well as
+   * <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @return all public methods in this class
+   * @throws SecurityException if the security check fails
+   * @since 1.1
+   */
+  public Method[] getMethods()
+  {
+    memberAccessCheck(Member.PUBLIC);
+    // NOTE the API docs claim that no methods are returned for arrays,
+    // but Sun's implementation *does* return the public methods of Object
+    // (as would be expected), so we follow their implementation instead
+    // of their documentation.
+    return internalGetMethods();
+  }
+
+  /**
+   * Like <code>getMethods()</code> but without the security checks.
+   */
+  private Method[] internalGetMethods()
+  {
+    HashMap map = new HashMap();
+    Method[] methods;
+    Class[] interfaces = getInterfaces();
+    for(int i = 0; i < interfaces.length; i++)
+      {
+	methods = interfaces[i].internalGetMethods();
+	for(int j = 0; j < methods.length; j++)
+	  {
+	    map.put(new MethodKey(methods[j]), methods[j]);
+	  }
+      }
+    Class superClass = getSuperclass();
+    if(superClass != null)
+      {
+	methods = superClass.internalGetMethods();
+	for(int i = 0; i < methods.length; i++)
+	  {
+	    map.put(new MethodKey(methods[i]), methods[i]);
+	  }
+      }
+    methods = getDeclaredMethods(true);
+    for(int i = 0; i < methods.length; i++)
+      {
+	map.put(new MethodKey(methods[i]), methods[i]);
+      }
+    return (Method[])map.values().toArray(new Method[map.size()]);
+  }
+
+  /**
+   * Get the modifiers of this class.  These can be decoded using Modifier,
+   * and is limited to one of public, protected, or private, and any of
+   * final, static, abstract, or interface. An array class has the same
+   * public, protected, or private modifier as its component type, and is
+   * marked final but not an interface. Primitive types and void are marked
+   * public and final, but not an interface.
+   *
+   * @return the modifiers of this class
+   * @see Modifier
+   * @since 1.1
+   */
+  public int getModifiers()
+  {
+    int mod = VMClass.getModifiers (this, false);
+    return (mod & (Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
+          Modifier.FINAL | Modifier.STATIC | Modifier.ABSTRACT |
+          Modifier.INTERFACE));
+  }
+  
+  /**
+   * Get the name of this class, separated by dots for package separators.
+   * If the class represents a primitive type, or void, then the
+   * name of the type as it appears in the Java programming language
+   * is returned.  For instance, <code>Byte.TYPE.getName()</code>
+   * returns "byte".
+   *
+   * Arrays are specially encoded as shown on this table.
+   * <pre>
+   * array type          [<em>element type</em>
+   *                     (note that the element type is encoded per
+   *                      this table)
+   * boolean             Z
+   * byte                B
+   * char                C
+   * short               S
+   * int                 I
+   * long                J
+   * float               F
+   * double              D
+   * void                V
+   * class or interface, alone: <dotted name>
+   * class or interface, as element type: L<dotted name>;
+   * </pre>
+   *
+   * @return the name of this class
+   */
+  public String getName()
+  { 
+    return VMClass.getName (this);
+  }
+
+  /**
+   * Get a resource URL using this class's package using the
+   * getClassLoader().getResource() method.  If this class was loaded using
+   * the system classloader, ClassLoader.getSystemResource() is used instead.
+   *
+   * <p>If the name you supply is absolute (it starts with a <code>/</code>),
+   * then the leading <code>/</code> is removed and it is passed on to
+   * getResource(). If it is relative, the package name is prepended, and
+   * <code>.</code>'s are replaced with <code>/</code>.
+   *
+   * <p>The URL returned is system- and classloader-dependent, and could
+   * change across implementations.
+   *
+   * @param resourceName the name of the resource, generally a path
+   * @return the URL to the resource
+   * @throws NullPointerException if name is null
+   * @since 1.1
+   */
+  public URL getResource(String resourceName)
+  {
+    String name = resourcePath(resourceName);
+    ClassLoader loader = getClassLoader();
+    if (loader == null)
+      return ClassLoader.getSystemResource(name);
+    return loader.getResource(name);
+  }
+
+  /**
+   * Get a resource using this class's package using the
+   * getClassLoader().getResourceAsStream() method.  If this class was loaded
+   * using the system classloader, ClassLoader.getSystemResource() is used
+   * instead.
+   *
+   * <p>If the name you supply is absolute (it starts with a <code>/</code>),
+   * then the leading <code>/</code> is removed and it is passed on to
+   * getResource(). If it is relative, the package name is prepended, and
+   * <code>.</code>'s are replaced with <code>/</code>.
+   *
+   * <p>The URL returned is system- and classloader-dependent, and could
+   * change across implementations.
+   *
+   * @param resourceName the name of the resource, generally a path
+   * @return an InputStream with the contents of the resource in it, or null
+   * @throws NullPointerException if name is null
+   * @since 1.1
+   */
+  public InputStream getResourceAsStream(String resourceName)
+  {
+    String name = resourcePath(resourceName);
+    ClassLoader loader = getClassLoader();
+    if (loader == null)
+      return ClassLoader.getSystemResourceAsStream(name);
+    return loader.getResourceAsStream(name);
+  }
+
+  private String resourcePath(String resourceName)
+  {
+    if (resourceName.length() > 0)
+      {
+	if (resourceName.charAt(0) != '/')
+	  {
+	    String pkg = getPackagePortion(getName());
+	    if (pkg.length() > 0)
+	      resourceName = pkg.replace('.','/') + '/' + resourceName;
+	  }
+	else
+	  {
+	    resourceName = resourceName.substring(1);
+	  }
+      }
+    return resourceName;
+  }
+
+  /**
+   * Get the signers of this class. This returns null if there are no signers,
+   * such as for primitive types or void.
+   *
+   * @return the signers of this class
+   * @since 1.1
+   */
+  public Object[] getSigners()
+  {
+    return signers == null ? null : (Object[]) signers.clone ();
+  }
+  
+  /**
+   * Set the signers of this class.
+   *
+   * @param signers the signers of this class
+   */
+  void setSigners(Object[] signers)
+  {
+    this.signers = signers;
+  }
+
+  /**
+   * Get the direct superclass of this class.  If this is an interface,
+   * Object, a primitive type, or void, it will return null. If this is an
+   * array type, it will return Object.
+   *
+   * @return the direct superclass of this class
+   */
+  public Class getSuperclass()
+  {
+    return VMClass.getSuperclass (this);
+  }
+  
+  /**
+   * Return whether this class is an array type.
+   *
+   * @return whether this class is an array type
+   * @since 1.1
+   */
+  public boolean isArray()
+  {
+    return VMClass.isArray (this);
+  }
+  
+  /**
+   * Discover whether an instance of the Class parameter would be an
+   * instance of this Class as well.  Think of doing
+   * <code>isInstance(c.newInstance())</code> or even
+   * <code>c.newInstance() instanceof (this class)</code>. While this
+   * checks widening conversions for objects, it must be exact for primitive
+   * types.
+   *
+   * @param c the class to check
+   * @return whether an instance of c would be an instance of this class
+   *         as well
+   * @throws NullPointerException if c is null
+   * @since 1.1
+   */
+  public boolean isAssignableFrom(Class c)
+  {
+    return VMClass.isAssignableFrom (this, c);
+  }
+ 
+  /**
+   * Discover whether an Object is an instance of this Class.  Think of it
+   * as almost like <code>o instanceof (this class)</code>.
+   *
+   * @param o the Object to check
+   * @return whether o is an instance of this class
+   * @since 1.1
+   */
+  public boolean isInstance(Object o)
+  {
+    return VMClass.isInstance (this, o);
+  }
+  
+  /**
+   * Check whether this class is an interface or not.  Array types are not
+   * interfaces.
+   *
+   * @return whether this class is an interface or not
+   */
+  public boolean isInterface()
+  {
+    return VMClass.isInterface (this);
+  }
+  
+  /**
+   * Return whether this class is a primitive type.  A primitive type class
+   * is a class representing a kind of "placeholder" for the various
+   * primitive types, or void.  You can access the various primitive type
+   * classes through java.lang.Boolean.TYPE, java.lang.Integer.TYPE, etc.,
+   * or through boolean.class, int.class, etc.
+   *
+   * @return whether this class is a primitive type
+   * @see Boolean#TYPE
+   * @see Byte#TYPE
+   * @see Character#TYPE
+   * @see Short#TYPE
+   * @see Integer#TYPE
+   * @see Long#TYPE
+   * @see Float#TYPE
+   * @see Double#TYPE
+   * @see Void#TYPE
+   * @since 1.1
+   */
+  public boolean isPrimitive()
+  {
+    return VMClass.isPrimitive (this);
+  }
+  
+  /**
+   * Get a new instance of this class by calling the no-argument constructor.
+   * The class is initialized if it has not been already. A security check
+   * may be performed, with <code>checkMemberAccess(this, Member.PUBLIC)</code>
+   * as well as <code>checkPackageAccess</code> both having to succeed.
+   *
+   * @return a new instance of this class
+   * @throws InstantiationException if there is not a no-arg constructor
+   *         for this class, including interfaces, abstract classes, arrays,
+   *         primitive types, and void; or if an exception occurred during
+   *         the constructor
+   * @throws IllegalAccessException if you are not allowed to access the
+   *         no-arg constructor because of scoping reasons
+   * @throws SecurityException if the security check fails
+   * @throws ExceptionInInitializerError if class initialization caused by
+   *         this call fails with an exception
+   */
+  public Object newInstance()
+    throws InstantiationException, IllegalAccessException
+  {
+    memberAccessCheck(Member.PUBLIC);
+    Constructor constructor;
+    synchronized(this)
+      {
+	constructor = this.constructor;
+      }
+    if (constructor == null)
+      {
+	Constructor[] constructors = getDeclaredConstructors(false);
+	for (int i = 0; i < constructors.length; i++)
+	  {
+	    if (constructors[i].getParameterTypes().length == 0)
+	      {
+		constructor = constructors[i];
+		break;
+	      }
+	  }
+	if (constructor == null)
+	  throw new InstantiationException(getName());
+	if (!Modifier.isPublic(constructor.getModifiers())
+            || !Modifier.isPublic(VMClass.getModifiers(this, true)))
+	  {
+	    final Constructor finalConstructor = constructor;
+	    AccessController.doPrivileged(new PrivilegedAction()
+	      {
+		public Object run()
+	        {
+		  finalConstructor.setAccessible(true);
+		  return null;
+		}
+	      });
+	  }
+	synchronized(this)
+	  {
+	    if (this.constructor == null)
+	      this.constructor = constructor;
+	  }	    
+      }
+    int modifiers = constructor.getModifiers();
+    if (!Modifier.isPublic(modifiers)
+        || !Modifier.isPublic(VMClass.getModifiers(this, true)))
+      {
+	Class caller = VMStackWalker.getCallingClass();
+	if (caller != null &&
+	    caller != this &&
+	    (Modifier.isPrivate(modifiers)
+	     || getClassLoader() != caller.getClassLoader()
+	     || !getPackagePortion(getName())
+	     .equals(getPackagePortion(caller.getName()))))
+	  throw new IllegalAccessException(getName()
+					   + " has an inaccessible constructor");
+      }
+    try
+      {
+        return constructor.newInstance(null);
+      }
+    catch (InvocationTargetException e)
+      {
+	VMClass.throwException(e.getTargetException());
+	throw (InternalError) new InternalError
+	  ("VMClass.throwException returned").initCause(e);
+      }
+  }
+
+  /**
+   * Returns the protection domain of this class. If the classloader did not
+   * record the protection domain when creating this class the unknown
+   * protection domain is returned which has a <code>null</code> code source
+   * and all permissions. A security check may be performed, with
+   * <code>RuntimePermission("getProtectionDomain")</code>.
+   *
+   * @return the protection domain
+   * @throws SecurityException if the security manager exists and the caller
+   * does not have <code>RuntimePermission("getProtectionDomain")</code>.
+   * @see RuntimePermission
+   * @since 1.2
+   */
+  public ProtectionDomain getProtectionDomain()
+  {
+    SecurityManager sm = SecurityManager.current;
+    if (sm != null)
+      sm.checkPermission(new RuntimePermission("getProtectionDomain"));
+
+    return pd == null ? StaticData.unknownProtectionDomain : pd;
+  }
+
+  /**
+   * Return the human-readable form of this Object.  For an object, this
+   * is either "interface " or "class " followed by <code>getName()</code>,
+   * for primitive types and void it is just <code>getName()</code>.
+   *
+   * @return the human-readable form of this Object
+   */
+  public String toString()
+  {
+    if (isPrimitive())
+      return getName();
+    return (isInterface() ? "interface " : "class ") + getName();
+  }
+
+  /**
+   * Returns the desired assertion status of this class, if it were to be
+   * initialized at this moment. The class assertion status, if set, is
+   * returned; the backup is the default package status; then if there is
+   * a class loader, that default is returned; and finally the system default
+   * is returned. This method seldom needs calling in user code, but exists
+   * for compilers to implement the assert statement. Note that there is no
+   * guarantee that the result of this method matches the class's actual
+   * assertion status.
+   *
+   * @return the desired assertion status
+   * @see ClassLoader#setClassAssertionStatus(String, boolean)
+   * @see ClassLoader#setPackageAssertionStatus(String, boolean)
+   * @see ClassLoader#setDefaultAssertionStatus(boolean)
+   * @since 1.4
+   */
+  public boolean desiredAssertionStatus()
+  {
+    ClassLoader c = getClassLoader();
+    Object status;
+    if (c == null)
+      return VMClassLoader.defaultAssertionStatus();
+    if (c.classAssertionStatus != null)
+      synchronized (c)
+        {
+          status = c.classAssertionStatus.get(getName());
+          if (status != null)
+            return status.equals(Boolean.TRUE);
+        }
+    else
+      {
+        status = ClassLoader.StaticData.
+                    systemClassAssertionStatus.get(getName());
+        if (status != null)
+          return status.equals(Boolean.TRUE);
+      }
+    if (c.packageAssertionStatus != null)
+      synchronized (c)
+        {
+          String name = getPackagePortion(getName());
+          if ("".equals(name))
+            status = c.packageAssertionStatus.get(null);
+          else
+            do
+              {
+                status = c.packageAssertionStatus.get(name);
+                name = getPackagePortion(name);
+              }
+            while (! "".equals(name) && status == null);
+          if (status != null)
+            return status.equals(Boolean.TRUE);
+        }
+    else
+      {
+        String name = getPackagePortion(getName());
+        if ("".equals(name))
+          status = ClassLoader.StaticData.
+                    systemPackageAssertionStatus.get(null);
+        else
+          do
+            {
+              status = ClassLoader.StaticData.
+                        systemPackageAssertionStatus.get(name);
+              name = getPackagePortion(name);
+            }
+          while (! "".equals(name) && status == null);
+        if (status != null)
+          return status.equals(Boolean.TRUE);
+      }
+    return c.defaultAssertionStatus;
+  }
+
+  /**
+   * <p>
+   * Casts this class to represent a subclass of the specified class.
+   * This method is useful for `narrowing' the type of a class so that
+   * the class object, and instances of that class, can match the contract
+   * of a more restrictive method.  For example, if this class has the
+   * static type of <code>Class<Object></code>, and a dynamic type of
+   * <code>Class<Rectangle></code>, then, assuming <code>Shape</code> is
+   * a superclass of <code>Rectangle</code>, this method can be used on
+   * this class with the parameter, <code>Class<Shape></code>, to retain
+   * the same instance but with the type
+   * <code>Class<? extends Shape></code>.
+   * </p>
+   * <p>
+   * If this class can be converted to an instance which is parameterised
+   * over a subtype of the supplied type, <code>U</code>, then this method
+   * returns an appropriately cast reference to this object.  Otherwise,
+   * a <code>ClassCastException</code> is thrown.
+   * </p>
+   * 
+   * @param klass the class object, the parameterized type (<code>U</code>) of
+   *              which should be a superclass of the parameterized type of
+   *              this instance.
+   * @return a reference to this object, appropriately cast.
+   * @throws ClassCastException if this class can not be converted to one
+   *                            which represents a subclass of the specified
+   *                            type, <code>U</code>. 
+   * @since 1.5
+   */
+   /* FIXME[GENERICS]: Should be <U> Class<? extends U> asSubClass(Class<U> klass */
+  public Class asSubclass(Class klass)
+  {
+    if (! klass.isAssignableFrom(this))
+      throw new ClassCastException();
+    return this; /* FIXME[GENERICS]: Should cast to Class<? extends U> */ 
+  }
+
+  /**
+   * Returns the specified object, cast to this <code>Class</code>' type.
+   *
+   * @param obj the object to cast
+   * @throws ClassCastException  if obj is not an instance of this class
+   * @since 1.5
+   */
+  /* FIXME[GENERICS]: Should be T cast(Object obj) */
+  public Object cast(Object obj)
+  {
+    if (obj != null && ! isInstance(obj))
+      throw new ClassCastException();
+    return obj; /* FIXME[GENERICS]: Should be cast to T */
+  }
+
+  /**
+   * Like <code>getField(String)</code> but without the security checks and
+   * returns null instead of throwing NoSuchFieldException.
+   */
+  private Field internalGetField(String name)
+  {
+    Field[] fields = getDeclaredFields(true);
+    for (int i = 0; i < fields.length; i++)
+      {
+	Field field = fields[i];
+	if (field.getName().equals(name))
+	  return field;
+      }
+    Class[] interfaces = getInterfaces();
+    for (int i = 0; i < interfaces.length; i++)
+      {
+	Field field = interfaces[i].internalGetField(name);
+	if(field != null)
+	  return field;
+      }
+    Class superClass = getSuperclass();
+    if (superClass != null)
+      return superClass.internalGetField(name);
+    return null;
+  }
+
+  /**
+   * Strip the last portion of the name (after the last dot).
+   *
+   * @param name the name to get package of
+   * @return the package name, or "" if no package
+   */
+  private static String getPackagePortion(String name)
+  {
+    int lastInd = name.lastIndexOf('.');
+    if (lastInd == -1)
+      return "";
+    return name.substring(0, lastInd);
+  }
+
+  /**
+   * Perform security checks common to all of the methods that
+   * get members of this Class.
+   */
+  private void memberAccessCheck(int which)
+  {
+    SecurityManager sm = SecurityManager.current;
+    if (sm != null)
+      {
+	sm.checkMemberAccess(this, which);
+	Package pkg = getPackage();
+	if (pkg != null)
+	  sm.checkPackageAccess(pkg.getName());
+      }
+  }
+
+  /**
+   * Returns the enumeration constants of this class, or
+   * null if this class is not an <code>Enum</code>.
+   *
+   * @return an array of <code>Enum</code> constants
+   *         associated with this class, or null if this
+   *         class is not an <code>enum</code>.
+   * @since 1.5
+   */
+  /* FIXME[GENERICS]: T[] getEnumConstants() */
+  public Object[] getEnumConstants()
+  {
+    if (isEnum())
+      {
+	try
+	  {
+	    return (Object[])
+	      getMethod("values", new Class[0]).invoke(null, new Object[0]);
+	  }
+	catch (NoSuchMethodException exception)
+	  {
+	    throw new Error("Enum lacks values() method");
+	  }
+	catch (IllegalAccessException exception)
+	  {
+	    throw new Error("Unable to access Enum class");
+	  }
+	catch (InvocationTargetException exception)
+	  {
+	    throw new
+	      RuntimeException("The values method threw an exception",
+			       exception);
+	  }
+      }
+    else
+      {
+	return null;
+      }
+  }
+
+  /**
+   * Returns true if this class is an <code>Enum</code>.
+   *
+   * @return true if this is an enumeration class.
+   * @since 1.5
+   */
+  public boolean isEnum()
+  {
+    int mod = VMClass.getModifiers (this, true);
+    return (mod & ENUM) != 0;
+  }
+
+  /**
+   * Returns true if this class is a synthetic class, generated by
+   * the compiler.
+   *
+   * @return true if this is a synthetic class.
+   * @since 1.5
+   */
+  public boolean isSynthetic()
+  {
+    int mod = VMClass.getModifiers (this, true);
+    return (mod & SYNTHETIC) != 0;
+  }
+
+  /**
+   * Returns true if this class is an <code>Annotation</code>.
+   *
+   * @return true if this is an annotation class.
+   * @since 1.5
+   */
+  public boolean isAnnotation()
+  {
+    int mod = VMClass.getModifiers (this, true);
+    return (mod & ANNOTATION) != 0;
+  }
+
+  /**
+   * Returns the simple name for this class, as used in the source
+   * code.  For normal classes, this is the content returned by
+   * <code>getName()</code> which follows the last ".".  Anonymous
+   * classes have no name, and so the result of calling this method is
+   * "".  The simple name of an array consists of the simple name of
+   * its component type, followed by "[]".  Thus, an array with the 
+   * component type of an anonymous class has a simple name of simply
+   * "[]".
+   *
+   * @return the simple name for this class.
+   * @since 1.5
+   */
+  public String getSimpleName()
+  {
+    return VMClass.getSimpleName(this);
+  }
+
+  /**
+   * Returns this class' 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 class' annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @since 1.5
+   */
+  /* FIXME[GENERICS]: <T extends Annotation> T getAnnotation(Class <T>) */
+  public Annotation getAnnotation(Class annotationClass)
+  {
+    Annotation foundAnnotation = null;
+    Annotation[] annotations = getAnnotations();
+    for (int i = 0; i < annotations.length; i++)
+      if (annotations[i].annotationType() == annotationClass)
+	foundAnnotation = annotations[i];
+    return foundAnnotation;
+  }
+
+  /**
+   * Returns all annotations associated with this class.  If there are
+   * no annotations associated with this class, 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 this class' annotations.
+   * @since 1.5
+   */
+  public Annotation[] getAnnotations()
+  {
+    HashSet set = new HashSet();
+    set.addAll(Arrays.asList(getDeclaredAnnotations()));
+    Class[] interfaces = getInterfaces();
+    for (int i = 0; i < interfaces.length; i++)
+      set.addAll(Arrays.asList(interfaces[i].getAnnotations()));
+    Class superClass = getSuperclass();
+    if (superClass != null)
+      set.addAll(Arrays.asList(superClass.getAnnotations()));
+    return (Annotation[]) set.toArray(new Annotation[set.size()]);
+  }
+
+  /**
+   * <p>
+   * Returns the canonical name of this class, as defined by section
+   * 6.7 of the Java language specification.  Each package, top-level class,
+   * top-level interface and primitive type has a canonical name.  A member
+   * class has a canonical name, if its parent class has one.  Likewise,
+   * an array type has a canonical name, if its component type does.
+   * Local or anonymous classes do not have canonical names.
+   * </p>
+   * <p>
+   * The canonical name for top-level classes, top-level interfaces and
+   * primitive types is always the same as the fully-qualified name.
+   * For array types, the canonical name is the canonical name of its
+   * component type with `[]' appended.  
+   * </p>
+   * <p>
+   * The canonical name of a member class always refers to the place where
+   * the class was defined, and is composed of the canonical name of the
+   * defining class and the simple name of the member class, joined by `.'.
+   *  For example, if a <code>Person</code> class has an inner class,
+   * <code>M</code>, then both its fully-qualified name and canonical name
+   * is <code>Person.M</code>.  A subclass, <code>Staff</code>, of
+   * <code>Person</code> refers to the same inner class by the fully-qualified
+   * name of <code>Staff.M</code>, but its canonical name is still
+   * <code>Person.M</code>.
+   * </p>
+   * <p>
+   * Where no canonical name is present, <code>null</code> is returned.
+   * </p>
+   *
+   * @return the canonical name of the class, or <code>null</code> if the
+   *         class doesn't have a canonical name.
+   * @since 1.5
+   */
+  public String getCanonicalName()
+  {
+    return VMClass.getCanonicalName(this);
+  }
+
+  /**
+   * Returns all annotations directly defined by this class.  If there are
+   * no annotations associated with this class, 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 this class.
+   * @since 1.5
+   */
+  public Annotation[] getDeclaredAnnotations()
+  {
+    return VMClass.getDeclaredAnnotations(this);
+  }
+
+  /**
+   * Returns the class which immediately encloses this class.  If this class
+   * is a top-level class, this method returns <code>null</code>.
+   *
+   * @return the immediate enclosing class, or <code>null</code> if this is
+   *         a top-level class.
+   * @since 1.5
+   */
+   /* FIXME[GENERICS]: Should return Class<?> */
+  public Class getEnclosingClass()
+  {
+    return VMClass.getEnclosingClass(this);
+  }
+
+  /**
+   * Returns the constructor which immediately encloses this class.  If
+   * this class is a top-level class, or a local or anonymous class 
+   * immediately enclosed by a type definition, instance initializer
+   * or static initializer, then <code>null</code> is returned.
+   *
+   * @return the immediate enclosing constructor if this class is
+   *         declared within a constructor.  Otherwise, <code>null</code>
+   *         is returned.
+   * @since 1.5
+   */
+   /* FIXME[GENERICS]: Should return Constructor<?> */
+  public Constructor getEnclosingConstructor()
+  {
+    return VMClass.getEnclosingConstructor(this);
+  }
+
+  /**
+   * Returns the method which immediately encloses this class.  If
+   * this class is a top-level class, or a local or anonymous class 
+   * immediately enclosed by a type definition, instance initializer
+   * or static initializer, then <code>null</code> is returned.
+   *
+   * @return the immediate enclosing method if this class is
+   *         declared within a method.  Otherwise, <code>null</code>
+   *         is returned.
+   * @since 1.5
+   */
+  public Method getEnclosingMethod()
+  {
+    return VMClass.getEnclosingMethod(this);
+  }
+
+  /**
+   * <p>
+   * Returns an array of <code>Type</code> objects which represent the
+   * interfaces directly implemented by this class or extended by this
+   * interface.
+   * </p>
+   * <p>
+   * If one of the superinterfaces is a parameterized type, then the
+   * object returned for this interface reflects the actual type
+   * parameters used in the source code.  Type parameters are created
+   * using the semantics specified by the <code>ParameterizedType</code>
+   * interface, and only if an instance has not already been created.
+   * </p>
+   * <p>
+   * The order of the interfaces in the array matches the order in which
+   * the interfaces are declared.  For classes which represent an array,
+   * an array of two interfaces, <code>Cloneable</code> and
+   * <code>Serializable</code>, is always returned, with the objects in
+   * that order.  A class representing a primitive type or void always
+   * returns an array of zero size.
+   * </p>
+   *
+   * @return an array of interfaces implemented or extended by this class.
+   * @throws GenericSignatureFormatError if the generic signature of one
+   *         of the interfaces does not comply with that specified by the Java
+   *         Virtual Machine specification, 3rd edition.
+   * @throws TypeNotPresentException if any of the superinterfaces refers
+   *         to a non-existant type.
+   * @throws MalformedParameterizedTypeException if any of the interfaces
+   *         refer to a parameterized type that can not be instantiated for
+   *         some reason.
+   * @since 1.5
+   * @see java.lang.reflect.ParameterizedType
+   */
+  public Type[] getGenericInterfaces()
+  {
+    if (isPrimitive())
+      return new Type[0];
+
+    String sig = VMClass.getClassSignature(this);
+    if (sig == null)
+      return getInterfaces();
+
+    ClassSignatureParser p = new ClassSignatureParser(this, sig);
+    return p.getInterfaceTypes();
+  }
+
+  /**
+   * <p>
+   * Returns a <code>Type</code> object representing the direct superclass,
+   * whether class, interface, primitive type or void, of this class.
+   * If this class is an array class, then a class instance representing
+   * the <code>Object</code> class is returned.  If this class is primitive,
+   * an interface, or a representation of either the <code>Object</code>
+   * class or void, then <code>null</code> is returned.
+   * </p>
+   * <p>
+   * If the superclass is a parameterized type, then the
+   * object returned for this interface reflects the actual type
+   * parameters used in the source code.  Type parameters are created
+   * using the semantics specified by the <code>ParameterizedType</code>
+   * interface, and only if an instance has not already been created.
+   * </p>
+   *
+   * @return the superclass of this class.
+   * @throws GenericSignatureFormatError if the generic signature of the
+   *         class does not comply with that specified by the Java
+   *         Virtual Machine specification, 3rd edition.
+   * @throws TypeNotPresentException if the superclass refers
+   *         to a non-existant type.
+   * @throws MalformedParameterizedTypeException if the superclass
+   *         refers to a parameterized type that can not be instantiated for
+   *         some reason.
+   * @since 1.5
+   * @see java.lang.reflect.ParameterizedType
+   */
+  public Type getGenericSuperclass()
+  {
+    if (isArray())
+      return Object.class;
+
+    if (isPrimitive() || isInterface() || this == Object.class)
+      return null;
+
+    String sig = VMClass.getClassSignature(this);
+    if (sig == null)
+      return getSuperclass();
+
+    ClassSignatureParser p = new ClassSignatureParser(this, sig);
+    return p.getSuperclassType();
+  }
+
+  /**
+   * Returns an array of <code>TypeVariable</code> objects that represents
+   * the type variables declared by this class, in declaration order.
+   * An array of size zero is returned if this class has no type
+   * variables.
+   *
+   * @return the type variables associated with this class. 
+   * @throws GenericSignatureFormatError if the generic signature does
+   *         not conform to the format specified in the Virtual Machine
+   *         specification, version 3.
+   * @since 1.5
+   */
+   /* FIXME[GENERICS]: Should return TypeVariable<Class<T>> */
+  public TypeVariable[] getTypeParameters()
+  {
+    String sig = VMClass.getClassSignature(this);
+    if (sig == null)
+      return new TypeVariable[0];
+
+    ClassSignatureParser p = new ClassSignatureParser(this, sig);
+    return p.getTypeParameters();
+  }
+
+  /**
+   * Returns true if an annotation for the specified type is associated
+   * with this class.  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]: Should be Class<? extends Annotation> */
+  public boolean isAnnotationPresent(Class
+				     annotationClass)
+  {
+    return getAnnotation(annotationClass) != null;
+  }
+
+  /**
+   * Returns true if this object represents an anonymous class.
+   *
+   * @return true if this object represents an anonymous class.
+   * @since 1.5
+   */
+  public boolean isAnonymousClass()
+  {
+    return VMClass.isAnonymousClass(this);
+  }
+
+  /**
+   * Returns true if this object represents an local class.
+   *
+   * @return true if this object represents an local class.
+   * @since 1.5
+   */
+  public boolean isLocalClass()
+  {
+    return VMClass.isLocalClass(this);
+  }
+
+  /**
+   * Returns true if this object represents an member class.
+   *
+   * @return true if this object represents an member class.
+   * @since 1.5
+   */
+  public boolean isMemberClass()
+  {
+    return VMClass.isMemberClass(this);
+  }
+
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ClassCastException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ClassCastException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* ClassCastException.java -- exception thrown on bad cast
+   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;
+
+/**
+ * Thrown when an attempt is made to cast an object which is not of the
+ * appropriate runtime type. For example:<br>
+ * <pre>
+ * Object o = new Vector();
+ * String s = (String) o;
+ * </pre>
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class ClassCastException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -9223365651070458532L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public ClassCastException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public ClassCastException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ClassCircularityError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ClassCircularityError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* ClassCircularityError.java -- thrown when linking circular classes
+   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>ClassCircularityError</code> is thrown when a circular dependency
+ * has been detected while initializing a class. This signals binary
+ * incompatible versions of class files, as the compiler normally catches this.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public class ClassCircularityError extends LinkageError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 1054362542914539689L;
+
+  /**
+   * Create an error without a message.
+   */
+  public ClassCircularityError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public ClassCircularityError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ClassFormatError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ClassFormatError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* ClassFormatError.java -- thrown if a class file is invalid
+   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;
+
+/**
+ * A <code>ClassFormatError</code> is thrown when a Java Virtual Machine
+ * unable to read a class file because the file is corrupted or cannot be
+ * interpreted as a class file.
+ *
+ * @author Brian Jones
+ * @status updated to 1.4
+ */
+public class ClassFormatError extends LinkageError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -8420114879011949195L;
+
+  /**
+   * Create an error without a message.
+   */
+  public ClassFormatError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public ClassFormatError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ClassLoader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ClassLoader.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1150 @@
+/* ClassLoader.java -- responsible for loading classes into the VM
+   Copyright (C) 1998, 1999, 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 gnu.java.util.DoubleEnumeration;
+import gnu.java.util.EmptyEnumeration;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.ByteBuffer;
+import java.security.CodeSource;
+import java.security.PermissionCollection;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+/**
+ * The ClassLoader is a way of customizing the way Java gets its classes
+ * and loads them into memory.  The verifier and other standard Java things
+ * still run, but the ClassLoader is allowed great flexibility in determining
+ * where to get the classfiles and when to load and resolve them. For that
+ * matter, a custom ClassLoader can perform on-the-fly code generation or
+ * modification!
+ *
+ * <p>Every classloader has a parent classloader that is consulted before
+ * the 'child' classloader when classes or resources should be loaded.
+ * This is done to make sure that classes can be loaded from an hierarchy of
+ * multiple classloaders and classloaders do not accidentially redefine
+ * already loaded classes by classloaders higher in the hierarchy.
+ *
+ * <p>The grandparent of all classloaders is the bootstrap classloader, which
+ * loads all the standard system classes as implemented by GNU Classpath. The
+ * other special classloader is the system classloader (also called
+ * application classloader) that loads all classes from the CLASSPATH
+ * (<code>java.class.path</code> system property). The system classloader
+ * is responsible for finding the application classes from the classpath,
+ * and delegates all requests for the standard library classes to its parent
+ * the bootstrap classloader. Most programs will load all their classes
+ * through the system classloaders.
+ *
+ * <p>The bootstrap classloader in GNU Classpath is implemented as a couple of
+ * static (native) methods on the package private class
+ * <code>java.lang.VMClassLoader</code>, the system classloader is an
+ * anonymous inner class of ClassLoader and a subclass of
+ * <code>java.net.URLClassLoader</code>.
+ *
+ * <p>Users of a <code>ClassLoader</code> will normally just use the methods
+ * <ul>
+ *  <li> <code>loadClass()</code> to load a class.</li>
+ *  <li> <code>getResource()</code> or <code>getResourceAsStream()</code>
+ *       to access a resource.</li>
+ *  <li> <code>getResources()</code> to get an Enumeration of URLs to all
+ *       the resources provided by the classloader and its parents with the
+ *       same name.</li>
+ * </ul>
+ *
+ * <p>Subclasses should implement the methods
+ * <ul>
+ *  <li> <code>findClass()</code> which is called by <code>loadClass()</code>
+ *       when the parent classloader cannot provide a named class.</li>
+ *  <li> <code>findResource()</code> which is called by
+ *       <code>getResource()</code> when the parent classloader cannot provide
+ *       a named resource.</li>
+ *  <li> <code>findResources()</code> which is called by
+ *       <code>getResource()</code> to combine all the resources with the
+ *       same name from the classloader and its parents.</li>
+ *  <li> <code>findLibrary()</code> which is called by
+ *       <code>Runtime.loadLibrary()</code> when a class defined by the
+ *       classloader wants to load a native library.</li>
+ * </ul>
+ *
+ * @author John Keiser
+ * @author Mark Wielaard
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Class
+ * @since 1.0
+ * @status still missing 1.4 functionality
+ */
+public abstract class ClassLoader
+{
+  /**
+   * All packages defined by this classloader. It is not private in order to
+   * allow native code (and trusted subclasses) access to this field.
+   */
+  final HashMap definedPackages = new HashMap();
+
+  /**
+   * The classloader that is consulted before this classloader.
+   * If null then the parent is the bootstrap classloader.
+   */
+  private final ClassLoader parent;
+
+  /**
+   * This is true if this classloader was successfully initialized.
+   * This flag is needed to avoid a class loader attack: even if the
+   * security manager rejects an attempt to create a class loader, the
+   * malicious class could have a finalize method which proceeds to
+   * define classes.
+   */
+  private final boolean initialized;
+
+  static class StaticData
+  {
+    /**
+     * The System Class Loader (a.k.a. Application Class Loader). The one
+     * returned by ClassLoader.getSystemClassLoader.
+     */
+    static final ClassLoader systemClassLoader =
+                              VMClassLoader.getSystemClassLoader();
+    static
+    {
+      // Find out if we have to install a default security manager. Note that
+      // this is done here because we potentially need the system class loader
+      // to load the security manager and note also that we don't need the
+      // security manager until the system class loader is created.
+      // If the runtime chooses to use a class loader that doesn't have the
+      // system class loader as its parent, it is responsible for setting
+      // up a security manager before doing so.
+      String secman = SystemProperties.getProperty("java.security.manager");
+      if (secman != null && SecurityManager.current == null)
+        {
+          if (secman.equals("") || secman.equals("default"))
+	    {
+	      SecurityManager.current = new SecurityManager();
+	    }
+	  else
+	    {
+	      try
+	        {
+	  	  Class cl = Class.forName(secman, false, StaticData.systemClassLoader);
+		  SecurityManager.current = (SecurityManager)cl.newInstance();
+	        }
+	      catch (Exception x)
+	        {
+		  throw (InternalError)
+		      new InternalError("Unable to create SecurityManager")
+		  	  .initCause(x);
+	        }
+	    }
+        }
+    }
+
+    /**
+     * The default protection domain, used when defining a class with a null
+     * parameter for the domain.
+     */
+    static final ProtectionDomain defaultProtectionDomain;
+    static
+    {
+        CodeSource cs = new CodeSource(null, null);
+        PermissionCollection perm = Policy.getPolicy().getPermissions(cs);
+        defaultProtectionDomain = new ProtectionDomain(cs, perm);
+    }
+    /**
+     * The command-line state of the package assertion status overrides. This
+     * map is never modified, so it does not need to be synchronized.
+     */
+    // Package visible for use by Class.
+    static final Map systemPackageAssertionStatus
+      = VMClassLoader.packageAssertionStatus();
+    /**
+     * The command-line state of the class assertion status overrides. This
+     * map is never modified, so it does not need to be synchronized.
+     */
+    // Package visible for use by Class.
+    static final Map systemClassAssertionStatus
+      = VMClassLoader.classAssertionStatus();
+  }
+
+  /**
+   * The desired assertion status of classes loaded by this loader, if not
+   * overridden by package or class instructions.
+   */
+  // Package visible for use by Class.
+  boolean defaultAssertionStatus = VMClassLoader.defaultAssertionStatus();
+
+  /**
+   * The map of package assertion status overrides, or null if no package
+   * overrides have been specified yet. The values of the map should be
+   * Boolean.TRUE or Boolean.FALSE, and the unnamed package is represented
+   * by the null key. This map must be synchronized on this instance.
+   */
+  // Package visible for use by Class.
+  Map packageAssertionStatus;
+
+  /**
+   * The map of class assertion status overrides, or null if no class
+   * overrides have been specified yet. The values of the map should be
+   * Boolean.TRUE or Boolean.FALSE. This map must be synchronized on this
+   * instance.
+   */
+  // Package visible for use by Class.
+  Map classAssertionStatus;
+
+  /**
+   * VM private data.
+   */
+  transient Object vmdata;
+
+  /**
+   * Create a new ClassLoader with as parent the system classloader. There
+   * may be a security check for <code>checkCreateClassLoader</code>.
+   *
+   * @throws SecurityException if the security check fails
+   */
+  protected ClassLoader() throws SecurityException
+  {
+    this(StaticData.systemClassLoader);
+  }
+
+  /**
+   * Create a new ClassLoader with the specified parent. The parent will
+   * be consulted when a class or resource is requested through
+   * <code>loadClass()</code> or <code>getResource()</code>. Only when the
+   * parent classloader cannot provide the requested class or resource the
+   * <code>findClass()</code> or <code>findResource()</code> method
+   * of this classloader will be called. There may be a security check for
+   * <code>checkCreateClassLoader</code>.
+   *
+   * @param parent the classloader's parent, or null for the bootstrap
+   *        classloader
+   * @throws SecurityException if the security check fails
+   * @since 1.2
+   */
+  protected ClassLoader(ClassLoader parent)
+  {
+    // May we create a new classloader?
+    SecurityManager sm = SecurityManager.current;
+    if (sm != null)
+      sm.checkCreateClassLoader();
+    this.parent = parent;
+    this.initialized = true;
+  }
+
+  /**
+   * Load a class using this ClassLoader or its parent, without resolving
+   * it. Calls <code>loadClass(name, false)</code>.
+   *
+   * <p>Subclasses should not override this method but should override
+   * <code>findClass()</code> which is called by this method.</p>
+   *
+   * @param name the name of the class relative to this ClassLoader
+   * @return the loaded class
+   * @throws ClassNotFoundException if the class cannot be found
+   */
+  public Class loadClass(String name) throws ClassNotFoundException
+  {
+    return loadClass(name, false);
+  }
+
+  /**
+   * Load a class using this ClassLoader or its parent, possibly resolving
+   * it as well using <code>resolveClass()</code>. It first tries to find
+   * out if the class has already been loaded through this classloader by
+   * calling <code>findLoadedClass()</code>. Then it calls
+   * <code>loadClass()</code> on the parent classloader (or when there is
+   * no parent it uses the VM bootclassloader). If the class is still
+   * not loaded it tries to create a new class by calling
+   * <code>findClass()</code>. Finally when <code>resolve</code> is
+   * <code>true</code> it also calls <code>resolveClass()</code> on the
+   * newly loaded class.
+   *
+   * <p>Subclasses should not override this method but should override
+   * <code>findClass()</code> which is called by this method.</p>
+   *
+   * @param name the fully qualified name of the class to load
+   * @param resolve whether or not to resolve the class
+   * @return the loaded class
+   * @throws ClassNotFoundException if the class cannot be found
+   */
+  protected synchronized Class loadClass(String name, boolean resolve)
+    throws ClassNotFoundException
+  {
+    // Have we already loaded this class?
+    Class c = findLoadedClass(name);
+    if (c == null)
+      {
+	// Can the class be loaded by a parent?
+	try
+	  {
+	    if (parent == null)
+	      {
+		c = VMClassLoader.loadClass(name, resolve);
+		if (c != null)
+		  return c;
+	      }
+	    else
+	      {
+		return parent.loadClass(name, resolve);
+	      }
+	  }
+	catch (ClassNotFoundException e)
+	  {
+	  }
+	// Still not found, we have to do it ourself.
+	c = findClass(name);
+      }
+    if (resolve)
+      resolveClass(c);
+    return c;
+  }
+
+  /**
+   * Called for every class name that is needed but has not yet been
+   * defined by this classloader or one of its parents. It is called by
+   * <code>loadClass()</code> after both <code>findLoadedClass()</code> and
+   * <code>parent.loadClass()</code> couldn't provide the requested class.
+   *
+   * <p>The default implementation throws a
+   * <code>ClassNotFoundException</code>. Subclasses should override this
+   * method. An implementation of this method in a subclass should get the
+   * class bytes of the class (if it can find them), if the package of the
+   * requested class doesn't exist it should define the package and finally
+   * it should call define the actual class. It does not have to resolve the
+   * class. It should look something like the following:<br>
+   *
+   * <pre>
+   * // Get the bytes that describe the requested class
+   * byte[] classBytes = classLoaderSpecificWayToFindClassBytes(name);
+   * // Get the package name
+   * int lastDot = name.lastIndexOf('.');
+   * if (lastDot != -1)
+   *   {
+   *     String packageName = name.substring(0, lastDot);
+   *     // Look if the package already exists
+   *     if (getPackage(packageName) == null)
+   *       {
+   *         // define the package
+   *         definePackage(packageName, ...);
+   *       }
+   *   }
+   * // Define and return the class
+   *  return defineClass(name, classBytes, 0, classBytes.length);
+   * </pre>
+   *
+   * <p><code>loadClass()</code> makes sure that the <code>Class</code>
+   * returned by <code>findClass()</code> will later be returned by
+   * <code>findLoadedClass()</code> when the same class name is requested.
+   *
+   * @param name class name to find (including the package name)
+   * @return the requested Class
+   * @throws ClassNotFoundException when the class can not be found
+   * @since 1.2
+   */
+  protected Class findClass(String name) throws ClassNotFoundException
+  {
+    throw new ClassNotFoundException(name);
+  }
+
+  /**
+   * Helper to define a class using a string of bytes. This version is not
+   * secure.
+   *
+   * @param data the data representing the classfile, in classfile format
+   * @param offset the offset into the data where the classfile starts
+   * @param len the length of the classfile data in the array
+   * @return the class that was defined
+   * @throws ClassFormatError if data is not in proper classfile format
+   * @throws IndexOutOfBoundsException if offset or len is negative, or
+   *         offset + len exceeds data
+   * @deprecated use {@link #defineClass(String, byte[], int, int)} instead
+   */
+  protected final Class defineClass(byte[] data, int offset, int len)
+    throws ClassFormatError
+  {
+    return defineClass(null, data, offset, len);
+  }
+
+  /**
+   * Helper to define a class using a string of bytes without a
+   * ProtectionDomain. Subclasses should call this method from their
+   * <code>findClass()</code> implementation. The name should use '.'
+   * separators, and discard the trailing ".class".  The default protection
+   * domain has the permissions of
+   * <code>Policy.getPolicy().getPermissions(new CodeSource(null, null))</code>.
+   *
+   * @param name the name to give the class, or null if unknown
+   * @param data the data representing the classfile, in classfile format
+   * @param offset the offset into the data where the classfile starts
+   * @param len the length of the classfile data in the array
+   * @return the class that was defined
+   * @throws ClassFormatError if data is not in proper classfile format
+   * @throws IndexOutOfBoundsException if offset or len is negative, or
+   *         offset + len exceeds data
+   * @throws SecurityException if name starts with "java."
+   * @since 1.1
+   */
+  protected final Class defineClass(String name, byte[] data, int offset,
+                                    int len) throws ClassFormatError
+  {
+    return defineClass(name, data, offset, len, null);
+  }
+
+  /**
+   * Helper to define a class using a string of bytes. Subclasses should call
+   * this method from their <code>findClass()</code> implementation. If the
+   * domain is null, the default of
+   * <code>Policy.getPolicy().getPermissions(new CodeSource(null, null))</code>
+   * is used. Once a class has been defined in a package, all further classes
+   * in that package must have the same set of certificates or a
+   * SecurityException is thrown.
+   *
+   * @param name the name to give the class.  null if unknown
+   * @param data the data representing the classfile, in classfile format
+   * @param offset the offset into the data where the classfile starts
+   * @param len the length of the classfile data in the array
+   * @param domain the ProtectionDomain to give to the class, null for the
+   *        default protection domain
+   * @return the class that was defined
+   * @throws ClassFormatError if data is not in proper classfile format
+   * @throws IndexOutOfBoundsException if offset or len is negative, or
+   *         offset + len exceeds data
+   * @throws SecurityException if name starts with "java.", or if certificates
+   *         do not match up
+   * @since 1.2
+   */
+  protected final synchronized Class defineClass(String name, byte[] data,
+						 int offset, int len,
+						 ProtectionDomain domain)
+    throws ClassFormatError
+  {
+    checkInitialized();
+    if (domain == null)
+      domain = StaticData.defaultProtectionDomain;
+    
+    return VMClassLoader.defineClassWithTransformers(this, name, data, offset,
+						     len, domain);
+  }
+
+  /**
+   * Helper to define a class using the contents of a byte buffer. If
+   * the domain is null, the default of
+   * <code>Policy.getPolicy().getPermissions(new CodeSource(null,
+   * null))</code> is used. Once a class has been defined in a
+   * package, all further classes in that package must have the same
+   * set of certificates or a SecurityException is thrown.
+   *
+   * @param name the name to give the class.  null if unknown
+   * @param buf a byte buffer containing bytes that form a class.
+   * @param domain the ProtectionDomain to give to the class, null for the
+   *        default protection domain
+   * @return the class that was defined
+   * @throws ClassFormatError if data is not in proper classfile format
+   * @throws NoClassDefFoundError if the supplied name is not the same as
+   *                              the one specified by the byte buffer.
+   * @throws SecurityException if name starts with "java.", or if certificates
+   *         do not match up
+   * @since 1.5
+   */
+  protected final Class defineClass(String name, ByteBuffer buf,
+				    ProtectionDomain domain)
+    throws ClassFormatError
+  {
+    byte[] data = new byte[buf.remaining()];
+    buf.get(data);
+    return defineClass(name, data, 0, data.length, domain);
+  }
+
+  /**
+   * Links the class, if that has not already been done. Linking basically
+   * resolves all references to other classes made by this class.
+   *
+   * @param c the class to resolve
+   * @throws NullPointerException if c is null
+   * @throws LinkageError if linking fails
+   */
+  protected final void resolveClass(Class c)
+  {
+    checkInitialized();
+    VMClassLoader.resolveClass(c);
+  }
+
+  /**
+   * Helper to find a Class using the system classloader, possibly loading it.
+   * A subclass usually does not need to call this, if it correctly
+   * overrides <code>findClass(String)</code>.
+   *
+   * @param name the name of the class to find
+   * @return the found class
+   * @throws ClassNotFoundException if the class cannot be found
+   */
+  protected final Class findSystemClass(String name)
+    throws ClassNotFoundException
+  {
+    checkInitialized();
+    return Class.forName(name, false, StaticData.systemClassLoader);
+  }
+
+  /**
+   * Returns the parent of this classloader. If the parent of this
+   * classloader is the bootstrap classloader then this method returns
+   * <code>null</code>. A security check may be performed on
+   * <code>RuntimePermission("getClassLoader")</code>.
+   *
+   * @return the parent <code>ClassLoader</code>
+   * @throws SecurityException if the security check fails
+   * @since 1.2
+   */
+  public final ClassLoader getParent()
+  {
+    // Check if we may return the parent classloader.
+    SecurityManager sm = SecurityManager.current;
+    if (sm != null)
+      {
+	ClassLoader cl = VMStackWalker.getCallingClassLoader();
+	if (cl != null && ! cl.isAncestorOf(this))
+          sm.checkPermission(new RuntimePermission("getClassLoader"));
+      }
+    return parent;
+  }
+
+  /**
+   * Helper to set the signers of a class. This should be called after
+   * defining the class.
+   *
+   * @param c the Class to set signers of
+   * @param signers the signers to set
+   * @since 1.1
+   */
+  protected final void setSigners(Class c, Object[] signers)
+  {
+    checkInitialized();
+    c.setSigners(signers);
+  }
+
+  /**
+   * Helper to find an already-loaded class in this ClassLoader.
+   *
+   * @param name the name of the class to find
+   * @return the found Class, or null if it is not found
+   * @since 1.1
+   */
+  protected final synchronized Class findLoadedClass(String name)
+  {
+    checkInitialized();
+    return VMClassLoader.findLoadedClass(this, name);
+  }
+
+  /**
+   * Get the URL to a resource using this classloader or one of its parents.
+   * First tries to get the resource by calling <code>getResource()</code>
+   * on the parent classloader. If the parent classloader returns null then
+   * it tries finding the resource by calling <code>findResource()</code> on
+   * this classloader. The resource name should be separated by '/' for path
+   * elements.
+   *
+   * <p>Subclasses should not override this method but should override
+   * <code>findResource()</code> which is called by this method.
+   *
+   * @param name the name of the resource relative to this classloader
+   * @return the URL to the resource or null when not found
+   */
+  public URL getResource(String name)
+  {
+    URL result;
+
+    if (parent == null)
+      result = VMClassLoader.getResource(name);
+    else
+      result = parent.getResource(name);
+
+    if (result == null)
+      result = findResource(name);
+    return result;
+  }
+
+  /**
+   * Returns an Enumeration of all resources with a given name that can
+   * be found by this classloader and its parents. Certain classloaders
+   * (such as the URLClassLoader when given multiple jar files) can have
+   * multiple resources with the same name that come from multiple locations.
+   * It can also occur that a parent classloader offers a resource with a
+   * certain name and the child classloader also offers a resource with that
+   * same name. <code>getResource()</code> only offers the first resource (of the
+   * parent) with a given name. This method lists all resources with the
+   * same name. The name should use '/' as path separators.
+   *
+   * <p>The Enumeration is created by first calling <code>getResources()</code>
+   * on the parent classloader and then calling <code>findResources()</code>
+   * on this classloader.</p>
+   *
+   * @param name the resource name
+   * @return an enumaration of all resources found
+   * @throws IOException if I/O errors occur in the process
+   * @since 1.2
+   * @specnote this was <code>final</code> prior to 1.5
+   */
+  public Enumeration getResources(String name) throws IOException
+  {
+    Enumeration parentResources;
+    if (parent == null)
+      parentResources = VMClassLoader.getResources(name);
+    else
+      parentResources = parent.getResources(name);
+    return new DoubleEnumeration(parentResources, findResources(name));
+  }
+
+  /**
+   * Called whenever all locations of a named resource are needed.
+   * It is called by <code>getResources()</code> after it has called
+   * <code>parent.getResources()</code>. The results are combined by
+   * the <code>getResources()</code> method.
+   *
+   * <p>The default implementation always returns an empty Enumeration.
+   * Subclasses should override it when they can provide an Enumeration of
+   * URLs (possibly just one element) to the named resource.
+   * The first URL of the Enumeration should be the same as the one
+   * returned by <code>findResource</code>.
+   *
+   * @param name the name of the resource to be found
+   * @return a possibly empty Enumeration of URLs to the named resource
+   * @throws IOException if I/O errors occur in the process
+   * @since 1.2
+   */
+  protected Enumeration findResources(String name) throws IOException
+  {
+    return EmptyEnumeration.getInstance();
+  }
+
+  /**
+   * Called whenever a resource is needed that could not be provided by
+   * one of the parents of this classloader. It is called by
+   * <code>getResource()</code> after <code>parent.getResource()</code>
+   * couldn't provide the requested resource.
+   *
+   * <p>The default implementation always returns null. Subclasses should
+   * override this method when they can provide a way to return a URL
+   * to a named resource.
+   *
+   * @param name the name of the resource to be found
+   * @return a URL to the named resource or null when not found
+   * @since 1.2
+   */
+  protected URL findResource(String name)
+  {
+    return null;
+  }
+
+  /**
+   * Get the URL to a resource using the system classloader.
+   *
+   * @param name the name of the resource relative to the system classloader
+   * @return the URL to the resource
+   * @since 1.1
+   */
+  public static final URL getSystemResource(String name)
+  {
+    return StaticData.systemClassLoader.getResource(name);
+  }
+
+  /**
+   * Get an Enumeration of URLs to resources with a given name using the
+   * the system classloader. The enumeration firsts lists the resources with
+   * the given name that can be found by the bootstrap classloader followed
+   * by the resources with the given name that can be found on the classpath.
+   *
+   * @param name the name of the resource relative to the system classloader
+   * @return an Enumeration of URLs to the resources
+   * @throws IOException if I/O errors occur in the process
+   * @since 1.2
+   */
+  public static Enumeration getSystemResources(String name) throws IOException
+  {
+    return StaticData.systemClassLoader.getResources(name);
+  }
+
+  /**
+   * Get a resource as stream using this classloader or one of its parents.
+   * First calls <code>getResource()</code> and if that returns a URL to
+   * the resource then it calls and returns the InputStream given by
+   * <code>URL.openStream()</code>.
+   *
+   * <p>Subclasses should not override this method but should override
+   * <code>findResource()</code> which is called by this method.
+   *
+   * @param name the name of the resource relative to this classloader
+   * @return an InputStream to the resource, or null
+   * @since 1.1
+   */
+  public InputStream getResourceAsStream(String name)
+  {
+    try
+      {
+        URL url = getResource(name);
+        if (url == null)
+          return null;
+        return url.openStream();
+      }
+    catch (IOException e)
+      {
+        return null;
+      }
+  }
+
+  /**
+   * Get a resource using the system classloader.
+   *
+   * @param name the name of the resource relative to the system classloader
+   * @return an input stream for the resource, or null
+   * @since 1.1
+   */
+  public static final InputStream getSystemResourceAsStream(String name)
+  {
+    try
+      {
+        URL url = getSystemResource(name);
+        if (url == null)
+          return null;
+        return url.openStream();
+      }
+    catch (IOException e)
+      {
+        return null;
+      }
+  }
+
+  /**
+   * Returns the system classloader. The system classloader (also called
+   * the application classloader) is the classloader that is used to
+   * load the application classes on the classpath (given by the system
+   * property <code>java.class.path</code>. This is set as the context
+   * class loader for a thread. The system property
+   * <code>java.system.class.loader</code>, if defined, is taken to be the
+   * name of the class to use as the system class loader, which must have
+   * a public constructor which takes a ClassLoader as a parent. The parent
+   * class loader passed in the constructor is the default system class
+   * loader.
+   *
+   * <p>Note that this is different from the bootstrap classloader that
+   * actually loads all the real "system" classes.
+   *
+   * <p>A security check will be performed for
+   * <code>RuntimePermission("getClassLoader")</code> if the calling class
+   * is not a parent of the system class loader.
+   *
+   * @return the system class loader
+   * @throws SecurityException if the security check fails
+   * @throws IllegalStateException if this is called recursively
+   * @throws Error if <code>java.system.class.loader</code> fails to load
+   * @since 1.2
+   */
+  public static ClassLoader getSystemClassLoader()
+  {
+    // Check if we may return the system classloader
+    SecurityManager sm = SecurityManager.current;
+    if (sm != null)
+      {
+	ClassLoader cl = VMStackWalker.getCallingClassLoader();
+	if (cl != null && cl != StaticData.systemClassLoader)
+	  sm.checkPermission(new RuntimePermission("getClassLoader"));
+      }
+
+    return StaticData.systemClassLoader;
+  }
+
+  /**
+   * Defines a new package and creates a Package object. The package should
+   * be defined before any class in the package is defined with
+   * <code>defineClass()</code>. The package should not yet be defined
+   * before in this classloader or in one of its parents (which means that
+   * <code>getPackage()</code> should return <code>null</code>). All
+   * parameters except the <code>name</code> of the package may be
+   * <code>null</code>.
+   *
+   * <p>Subclasses should call this method from their <code>findClass()</code>
+   * implementation before calling <code>defineClass()</code> on a Class
+   * in a not yet defined Package (which can be checked by calling
+   * <code>getPackage()</code>).
+   *
+   * @param name the name of the Package
+   * @param specTitle the name of the specification
+   * @param specVendor the name of the specification designer
+   * @param specVersion the version of this specification
+   * @param implTitle the name of the implementation
+   * @param implVendor the vendor that wrote this implementation
+   * @param implVersion the version of this implementation
+   * @param sealed if sealed the origin of the package classes
+   * @return the Package object for the specified package
+   * @throws IllegalArgumentException if the package name is null or it
+   *         was already defined by this classloader or one of its parents
+   * @see Package
+   * @since 1.2
+   */
+  protected Package definePackage(String name, String specTitle,
+                                  String specVendor, String specVersion,
+                                  String implTitle, String implVendor,
+                                  String implVersion, URL sealed)
+  {
+    if (getPackage(name) != null)
+      throw new IllegalArgumentException("Package " + name
+                                         + " already defined");
+    Package p = new Package(name, specTitle, specVendor, specVersion,
+                            implTitle, implVendor, implVersion, sealed, this);
+    synchronized (definedPackages)
+      {
+        definedPackages.put(name, p);
+      }
+    return p;
+  }
+
+  /**
+   * Returns the Package object for the requested package name. It returns
+   * null when the package is not defined by this classloader or one of its
+   * parents.
+   *
+   * @param name the package name to find
+   * @return the package, if defined
+   * @since 1.2
+   */
+  protected Package getPackage(String name)
+  {
+    Package p;
+    if (parent == null)
+      p = VMClassLoader.getPackage(name);
+    else
+      p = parent.getPackage(name);
+
+    if (p == null)
+      {
+	synchronized (definedPackages)
+	  {
+	    p = (Package) definedPackages.get(name);
+	  }
+      }
+    return p;
+  }
+
+  /**
+   * Returns all Package objects defined by this classloader and its parents.
+   *
+   * @return an array of all defined packages
+   * @since 1.2
+   */
+  protected Package[] getPackages()
+  {
+    // Get all our packages.
+    Package[] packages;
+    synchronized(definedPackages)
+      {
+        packages = new Package[definedPackages.size()];
+        definedPackages.values().toArray(packages);
+      }
+
+    // If we have a parent get all packages defined by our parents.
+    Package[] parentPackages;
+    if (parent == null)
+      parentPackages = VMClassLoader.getPackages();
+    else
+      parentPackages = parent.getPackages();
+
+    Package[] allPackages = new Package[parentPackages.length
+					+ packages.length];
+    System.arraycopy(parentPackages, 0, allPackages, 0,
+                     parentPackages.length);
+    System.arraycopy(packages, 0, allPackages, parentPackages.length,
+                     packages.length);
+    return allPackages;
+  }
+
+  /**
+   * Called by <code>Runtime.loadLibrary()</code> to get an absolute path
+   * to a (system specific) library that was requested by a class loaded
+   * by this classloader. The default implementation returns
+   * <code>null</code>. It should be implemented by subclasses when they
+   * have a way to find the absolute path to a library. If this method
+   * returns null the library is searched for in the default locations
+   * (the directories listed in the <code>java.library.path</code> system
+   * property).
+   *
+   * @param name the (system specific) name of the requested library
+   * @return the full pathname to the requested library, or null
+   * @see Runtime#loadLibrary(String)
+   * @since 1.2
+   */
+  protected String findLibrary(String name)
+  {
+    return null;
+  }
+
+  /**
+   * Set the default assertion status for classes loaded by this classloader,
+   * used unless overridden by a package or class request.
+   *
+   * @param enabled true to set the default to enabled
+   * @see #setClassAssertionStatus(String, boolean)
+   * @see #setPackageAssertionStatus(String, boolean)
+   * @see #clearAssertionStatus()
+   * @since 1.4
+   */
+  public void setDefaultAssertionStatus(boolean enabled)
+  {
+    defaultAssertionStatus = enabled;
+  }
+  
+  /**
+   * Set the default assertion status for packages, used unless overridden
+   * by a class request. This default also covers subpackages, unless they
+   * are also specified. The unnamed package should use null for the name.
+   *
+   * @param name the package (and subpackages) to affect
+   * @param enabled true to set the default to enabled
+   * @see #setDefaultAssertionStatus(boolean)
+   * @see #setClassAssertionStatus(String, boolean)
+   * @see #clearAssertionStatus()
+   * @since 1.4
+   */
+  public synchronized void setPackageAssertionStatus(String name,
+                                                     boolean enabled)
+  {
+    if (packageAssertionStatus == null)
+      packageAssertionStatus
+        = new HashMap(StaticData.systemPackageAssertionStatus);
+    packageAssertionStatus.put(name, Boolean.valueOf(enabled));
+  }
+  
+  /**
+   * Set the default assertion status for a class. This only affects the
+   * status of top-level classes, any other string is harmless.
+   *
+   * @param name the class to affect
+   * @param enabled true to set the default to enabled
+   * @throws NullPointerException if name is null
+   * @see #setDefaultAssertionStatus(boolean)
+   * @see #setPackageAssertionStatus(String, boolean)
+   * @see #clearAssertionStatus()
+   * @since 1.4
+   */
+  public synchronized void setClassAssertionStatus(String name,
+                                                   boolean enabled)
+  {
+    if (classAssertionStatus == null)
+      classAssertionStatus = 
+        new HashMap(StaticData.systemClassAssertionStatus);
+    // The toString() hack catches null, as required.
+    classAssertionStatus.put(name.toString(), Boolean.valueOf(enabled));
+  }
+  
+  /**
+   * Resets the default assertion status of this classloader, its packages
+   * and classes, all to false. This allows overriding defaults inherited
+   * from the command line.
+   *
+   * @see #setDefaultAssertionStatus(boolean)
+   * @see #setClassAssertionStatus(String, boolean)
+   * @see #setPackageAssertionStatus(String, boolean)
+   * @since 1.4
+   */
+  public synchronized void clearAssertionStatus()
+  {
+    defaultAssertionStatus = false;
+    packageAssertionStatus = new HashMap();
+    classAssertionStatus = new HashMap();
+  }
+
+  /**
+   * Return true if this loader is either the specified class loader
+   * or an ancestor thereof.
+   * @param loader the class loader to check
+   */
+  final boolean isAncestorOf(ClassLoader loader)
+  {
+    while (loader != null)
+      {
+	if (this == loader)
+	  return true;
+	loader = loader.parent;
+      }
+    return false;
+  }
+
+  private static URL[] getExtClassLoaderUrls()
+  {
+    String classpath = SystemProperties.getProperty("java.ext.dirs", "");
+    StringTokenizer tok = new StringTokenizer(classpath, File.pathSeparator);
+    ArrayList list = new ArrayList();
+    while (tok.hasMoreTokens())
+      {
+	try
+	  {
+	    File f = new File(tok.nextToken());
+	    File[] files = f.listFiles();
+	    if (files != null)
+	      for (int i = 0; i < files.length; i++)
+		list.add(files[i].toURL());
+	  }
+	catch(Exception x)
+	  {
+	  }
+      }
+    URL[] urls = new URL[list.size()];
+    list.toArray(urls);
+    return urls;
+  }
+
+  private static void addFileURL(ArrayList list, String file)
+  {
+    try
+      {
+	list.add(new File(file).toURL());
+      }
+    catch(java.net.MalformedURLException x)
+      {
+      }
+  }
+
+  private static URL[] getSystemClassLoaderUrls()
+  {
+    String classpath = SystemProperties.getProperty("java.class.path", ".");
+    StringTokenizer tok = new StringTokenizer(classpath, File.pathSeparator, true);
+    ArrayList list = new ArrayList();
+    while (tok.hasMoreTokens())
+      {
+	String s = tok.nextToken();
+	if (s.equals(File.pathSeparator))
+	    addFileURL(list, ".");
+	else
+	  {
+	    addFileURL(list, s);
+	    if (tok.hasMoreTokens())
+	      {
+		// Skip the separator.
+		tok.nextToken();
+		// If the classpath ended with a separator,
+		// append the current directory.
+		if (!tok.hasMoreTokens())
+		    addFileURL(list, ".");
+	      }
+	  }
+      }
+    URL[] urls = new URL[list.size()];
+    list.toArray(urls);
+    return urls;
+  }
+
+  static ClassLoader defaultGetSystemClassLoader()
+  {
+    return createAuxiliarySystemClassLoader(
+        createSystemClassLoader(getSystemClassLoaderUrls(),
+            createExtClassLoader(getExtClassLoaderUrls(), null)));
+  }
+
+  static ClassLoader createExtClassLoader(URL[] urls, ClassLoader parent)
+  {
+    if (urls.length > 0)
+      return new URLClassLoader(urls, parent);
+    else
+      return parent;
+  }
+
+  static ClassLoader createSystemClassLoader(URL[] urls, ClassLoader parent)
+  {
+    return
+	new URLClassLoader(urls, parent)
+	{
+	    protected synchronized Class loadClass(String name,
+		boolean resolve)
+		throws ClassNotFoundException
+	    {
+		SecurityManager sm = SecurityManager.current;
+		if (sm != null)
+		{
+		    int lastDot = name.lastIndexOf('.');
+		    if (lastDot != -1)
+			sm.checkPackageAccess(name.substring(0, lastDot));
+		}
+		return super.loadClass(name, resolve);
+	    }
+	};
+  }
+
+  static ClassLoader createAuxiliarySystemClassLoader(ClassLoader parent)
+  {
+    String loader = SystemProperties.getProperty("java.system.class.loader", null);
+    if (loader == null)
+      {
+	return parent;
+      }
+    try
+      {
+	Constructor c = Class.forName(loader, false, parent)
+	    .getConstructor(new Class[] { ClassLoader.class });
+	return (ClassLoader)c.newInstance(new Object[] { parent });
+      }
+    catch (Exception e)
+      {
+	System.err.println("Requested system classloader " + loader + " failed.");
+	throw (Error)
+	    new Error("Requested system classloader " + loader + " failed.")
+		.initCause(e);
+      }
+  }
+
+  /**
+   * Before doing anything "dangerous" please call this method to make sure
+   * this class loader instance was properly constructed (and not obtained
+   * by exploiting the finalizer attack)
+   * @see #initialized
+   */
+  private void checkInitialized()
+  {
+    if (! initialized)
+      throw new SecurityException("attempt to use uninitialized class loader");
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ClassNotFoundException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ClassNotFoundException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,126 @@
+/* ClassNotFoundException.java -- thrown when class definition cannot be found
+   Copyright (C) 1998, 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;
+
+/**
+ * Thrown when a class is requested by reflection, but the class definition
+ * cannot be found. This exception is often chained from another Throwable.
+ *
+ * @author Brian Jones
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Class#forName(String)
+ * @see ClassLoader#findSystemClass(String)
+ * @see ClassLoader#loadClass(String, boolean)
+ * @status updated to 1.4
+ */
+public class ClassNotFoundException extends Exception
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 9176873029745254542L;
+
+  /**
+   * The cause of this exception (duplicates the one stored in Throwable).
+   *
+   * @serial the exception cause
+   * @since 1.2
+   */
+  private final Throwable ex;
+
+  /**
+   * Create an exception without a message. Note that this initializes the
+   * cause to null.
+   */
+  public ClassNotFoundException()
+  {
+    this(null);
+  }
+
+  /**
+   * Create an exception with a message. Note that this initializes the
+   * cause to null.
+   *
+   * @param s the message
+   */
+  public ClassNotFoundException(String s)
+  {
+    super(s);
+    ex = null;
+  }
+
+  /**
+   * Create an exception with a message and chain it to the exception
+   * which occurred while loading the class.
+   *
+   * @param s the message
+   * @param ex the chained exception
+   * @since 1.2
+   */
+  public ClassNotFoundException(String s, Throwable ex)
+  {
+    super(s, ex);
+    this.ex = ex;
+  }
+
+  /**
+   * Returns the exception which occurred while loading the class,
+   * otherwise returns null. This is a legacy method; the preferred choice
+   * now is {@link Throwable#getCause()}.
+   *
+   * @return the cause of this exception
+   * @since 1.2
+   */
+  public Throwable getException()
+  {
+    return ex;
+  }
+
+  /**
+   * Returns the exception which occurred while loading the class,
+   * otherwise returns null.
+   *
+   * @return the cause of this exception
+   * @since 1.4
+   */
+  public Throwable getCause()
+  {
+    return ex;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/CloneNotSupportedException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/CloneNotSupportedException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,92 @@
+/* CloneNotSupportedException.java -- thrown when an object cannot be cloned
+   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;
+
+/**
+ * Thrown to indicate an object should not or could not be cloned. This
+ * includes the case when {@link Object#clone()} is called on an object
+ * which does not implement the {@link Cloneable} interface. For example:<br>
+ * <pre>
+ * void m() throws CloneNotSupportedException
+ * {
+ *   clone();
+ * }
+ * </pre>
+ *
+ * <p>Notice that calling <code>clone()</code> on an array will never produce
+ * this exception, as the VM will always succeed in copying the array, or
+ * cause an OutOfMemoryError first. For example:<br>
+ * <pre>
+ * void m(int[] array)
+ * {
+ *   int[] copy = (int[]) array.clone();
+ * }
+ * </pre>
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Cloneable
+ * @see Object#clone()
+ * @status updated to 1.4
+ */
+public class CloneNotSupportedException extends Exception
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 5195511250079656443L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public CloneNotSupportedException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the error message
+   */
+  public CloneNotSupportedException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Cloneable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Cloneable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* Cloneable.java -- Interface for marking objects cloneable by Object.clone()
+   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 interface should be implemented by classes wishing to
+ * support of override <code>Object.clone()</code>.  The default
+ * behaviour of <code>clone()</code> performs a shallow copy, but
+ * subclasses often change this to perform a deep copy.  Therefore,
+ * it is a good idea to document how deep your clone will go.
+ * If <code>clone()</code> is called on an object which does not
+ * implement this interface, a <code>CloneNotSupportedException</code>
+ * will be thrown.
+ *
+ * <p>This interface is simply a tagging interface; it carries no
+ * requirements on methods to implement.  However, it is typical for
+ * a Cloneable class to implement at least <code>equals</code>,
+ * <code>hashCode</code>, and <code>clone</code>, sometimes
+ * increasing the accessibility of clone to be public. The typical
+ * implementation of <code>clone</code> invokes <code>super.clone()</code>
+ * rather than a constructor, but this is not a requirement.
+ *
+ * <p>If an object that implement Cloneable should not be cloned,
+ * simply override the <code>clone</code> method to throw a
+ * <code>CloneNotSupportedException</code>.
+ *
+ * <p>All array types implement Cloneable, and have a public
+ * <code>clone</code> method that will never fail with a
+ * <code>CloneNotSupportedException</code>.
+ *
+ * @author Paul Fisher
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @see Object#clone()
+ * @see CloneNotSupportedException
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface Cloneable
+{
+  // Tagging interface only.
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Comparable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Comparable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,98 @@
+/* Comparable.java -- Interface for comparaing objects to obtain an ordering
+   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;
+
+/**
+ * Interface for objects that can be ordering among other objects. The
+ * ordering can be <em>total</em>, such that two objects only compare equal
+ * if they are also equal by the equals method, or <em>partial</em> such
+ * that this is not necessarily true. For example, a case-sensitive
+ * dictionary order comparison of Strings is total, but if it is
+ * case-insensitive it is partial, because "abc" and "ABC" compare as
+ * equal even though "abc".equals("ABC") returns false. However, if you use
+ * a partial ordering, it is a good idea to document your class as
+ * "inconsistent with equals", because the behavior of your class in a
+ * SortedMap will be different than in a HashMap.
+ *
+ * <p>Lists, arrays, and sets of objects that implement this interface can
+ * be sorted automatically, without the need for an explicit
+ * {@link java.util.Comparator}. Note that <code>e1.compareTo(null)</code> 
+ * should throw an Exception; as should comparison between incompatible 
+ * classes.
+ *
+ * @author Geoff Berry
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @see java.util.Comparator
+ * @see java.util.Collections#sort(java.util.List)
+ * @see java.util.Arrays#sort(Object[])
+ * @see java.util.SortedSet
+ * @see java.util.SortedMap
+ * @see java.util.TreeSet
+ * @see java.util.TreeMap
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface Comparable
+{
+  /**
+   * Compares this object with another, and returns a numerical result based
+   * on the comparison.  If the result is negative, this object sorts less
+   * than the other; if 0, the two are equal, and if positive, this object
+   * sorts greater than the other.  To translate this into boolean, simply
+   * perform <code>o1.compareTo(o2) <em><op></em> 0</code>, where op
+   * is one of <, <=, =, !=, >, or >=.
+   *
+   * <p>You must make sure that the comparison is mutual, ie.
+   * <code>sgn(x.compareTo(y)) == -sgn(y.compareTo(x))</code> (where sgn() is
+   * defined as -1, 0, or 1 based on the sign).  This includes throwing an
+   * exception in either direction if the two are not comparable; hence,
+   * <code>compareTo(null)</code> should always throw an Exception.
+   *
+   * <p>You should also ensure transitivity, in two forms:
+   * <code>x.compareTo(y) > 0 && y.compareTo(z) > 0</code> implies
+   * <code>x.compareTo(z) > 0</code>; and <code>x.compareTo(y) == 0</code>
+   * implies <code>x.compareTo(z) == y.compareTo(z)</code>.
+   *
+   * @param o the object to be compared
+   * @return an integer describing the comparison
+   * @throws NullPointerException if o is null
+   * @throws ClassCastException if o cannot be compared
+   */
+  int compareTo(Object o);
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Compiler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Compiler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,127 @@
+/* Compiler.java -- placeholder for Java-to-native runtime compilers
+   Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang;
+
+/**
+ * The <code>Compiler</code> class is a placeholder for a JIT compiler
+ * implementation, and does nothing unless there is such a compiler.
+ *
+ * <p>The system property <code>java.compiler</code> may contain the name
+ * of a library to load with <code>System.loadLibrary</code> when the
+ * virtual machine first starts.  If so, and loading the library succeeds,
+ * then a function by the name of <code>java_lang_Compiler_start()</code>
+ * in that library is called.
+ *
+ * <p>Note that a VM might not have implemented any of this.
+ *
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @see System#getProperty(String)
+ * @see System#getProperty(String, String)
+ * @see System#loadLibrary(String)
+ * @since JDK 1.0
+ * @status updated to 1.4
+ */
+public final class Compiler
+{
+  /**
+   * Don't allow new `Compiler's to be made.
+   */
+  private Compiler()
+  {
+  }
+
+  /**
+   * Compile the class named by <code>oneClass</code>.
+   *
+   * @param oneClass the class to compile
+   * @return <code>false</code> if no compiler is available or
+   *         compilation failed, <code>true</code> if compilation succeeded
+   * @throws NullPointerException if oneClass is null
+   */
+  public static boolean compileClass(Class oneClass)
+  {
+    return VMCompiler.compileClass(oneClass);
+  }
+
+  /**
+   * Compile the classes whose name matches <code>classNames</code>.
+   *
+   * @param classNames the name of classes to compile
+   * @return <code>false</code> if no compiler is available or
+   *         compilation failed, <code>true</code> if compilation succeeded
+   * @throws NullPointerException if classNames is null
+   */
+  public static boolean compileClasses(String classNames)
+  {
+    return VMCompiler.compileClasses(classNames);
+  }
+
+  /**
+   * This method examines the argument and performs an operation
+   * according to the compilers documentation.  No specific operation
+   * is required.
+   *
+   * @param arg a compiler-specific argument
+   * @return a compiler-specific value, including null
+   * @throws NullPointerException if the compiler doesn't like a null arg
+   */
+  public static Object command(Object arg)
+  {
+    return VMCompiler.command(arg);
+  }
+
+  /**
+   * Calling <code>Compiler.enable()</code> will cause the compiler
+   * to resume operation if it was previously disabled; provided that a
+   * compiler even exists.
+   */
+  public static void enable()
+  {
+    VMCompiler.enable();
+  }
+
+  /**
+   * Calling <code>Compiler.disable()</code> will cause the compiler
+   * to be suspended; provided that a compiler even exists.
+   */
+  public static void disable()
+  {
+    VMCompiler.disable();
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Double.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Double.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,617 @@
+/* Double.java -- object wrapper for double
+   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.lang;
+
+
+/**
+ * Instances of class <code>Double</code> represent primitive
+ * <code>double</code> values.
+ *
+ * Additionally, this class provides various helper functions and variables
+ * related to doubles.
+ *
+ * @author Paul Fisher
+ * @author Andrew Haley (aph at cygnus.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public final class Double extends Number implements Comparable
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -9172774392245257468L;
+
+  /**
+   * The maximum positive value a <code>double</code> may represent
+   * is 1.7976931348623157e+308.
+   */
+  public static final double MAX_VALUE = 1.7976931348623157e+308;
+
+  /**
+   * The minimum positive value a <code>double</code> may represent
+   * is 5e-324.
+   */
+  public static final double MIN_VALUE = 5e-324;
+
+  /**
+   * The value of a double representation -1.0/0.0, negative
+   * infinity.
+   */
+  public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
+
+  /**
+   * The value of a double representing 1.0/0.0, positive infinity.
+   */
+  public static final double POSITIVE_INFINITY = 1.0 / 0.0;
+
+  /**
+   * All IEEE 754 values of NaN have the same value in Java.
+   */
+  public static final double NaN = 0.0 / 0.0;
+
+  /**
+   * The number of bits needed to represent a <code>double</code>.
+   * @since 1.5
+   */
+  public static final int SIZE = 64;
+
+ /**
+   * The primitive type <code>double</code> is represented by this
+   * <code>Class</code> object.
+   * @since 1.1
+   */
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('D');
+
+  /**
+   * The immutable value of this Double.
+   *
+   * @serial the wrapped double
+   */
+  private final double value;
+
+  /**
+   * Create a <code>Double</code> from the primitive <code>double</code>
+   * specified.
+   *
+   * @param value the <code>double</code> argument
+   */
+  public Double(double value)
+  {
+    this.value = value;
+  }
+
+  /**
+   * Create a <code>Double</code> from the specified <code>String</code>.
+   * This method calls <code>Double.parseDouble()</code>.
+   *
+   * @param s the <code>String</code> to convert
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>double</code>
+   * @throws NullPointerException if <code>s</code> is null
+   * @see #parseDouble(String)
+   */
+  public Double(String s)
+  {
+    value = parseDouble(s);
+  }
+
+  /**
+   * Convert the <code>double</code> to a <code>String</code>.
+   * Floating-point string representation is fairly complex: here is a
+   * rundown of the possible values.  "<code>[-]</code>" indicates that a
+   * negative sign will be printed if the value (or exponent) is negative.
+   * "<code><number></code>" means a string of digits ('0' to '9').
+   * "<code><digit></code>" means a single digit ('0' to '9').<br>
+   *
+   * <table border=1>
+   * <tr><th>Value of Double</th><th>String Representation</th></tr>
+   * <tr><td>[+-] 0</td> <td><code>[-]0.0</code></td></tr>
+   * <tr><td>Between [+-] 10<sup>-3</sup> and 10<sup>7</sup>, exclusive</td>
+   *     <td><code>[-]number.number</code></td></tr>
+   * <tr><td>Other numeric value</td>
+   *     <td><code>[-]<digit>.<number>
+   *          E[-]<number></code></td></tr>
+   * <tr><td>[+-] infinity</td> <td><code>[-]Infinity</code></td></tr>
+   * <tr><td>NaN</td> <td><code>NaN</code></td></tr>
+   * </table>
+   *
+   * Yes, negative zero <em>is</em> a possible value.  Note that there is
+   * <em>always</em> a <code>.</code> and at least one digit printed after
+   * it: even if the number is 3, it will be printed as <code>3.0</code>.
+   * After the ".", all digits will be printed except trailing zeros. The
+   * result is rounded to the shortest decimal number which will parse back
+   * to the same double.
+   *
+   * <p>To create other output formats, use {@link java.text.NumberFormat}.
+   *
+   * @XXX specify where we are not in accord with the spec.
+   *
+   * @param d the <code>double</code> to convert
+   * @return the <code>String</code> representing the <code>double</code>
+   */
+  public static String toString(double d)
+  {
+    return VMDouble.toString(d, false);
+  }
+
+  /**
+   * Convert a double value to a hexadecimal string.  This converts as
+   * follows:
+   * <ul>
+   * <li> A NaN value is converted to the string "NaN".
+   * <li> Positive infinity is converted to the string "Infinity".
+   * <li> Negative infinity is converted to the string "-Infinity".
+   * <li> For all other values, the first character of the result is '-'
+   * if the value is negative.  This is followed by '0x1.' if the
+   * value is normal, and '0x0.' if the value is denormal.  This is
+   * then followed by a (lower-case) hexadecimal representation of the
+   * mantissa, with leading zeros as required for denormal values.
+   * The next character is a 'p', and this is followed by a decimal
+   * representation of the unbiased exponent.
+   * </ul>
+   * @param d the double value
+   * @return the hexadecimal string representation
+   * @since 1.5
+   */
+  public static String toHexString(double d)
+  {
+    if (isNaN(d))
+      return "NaN";
+    if (isInfinite(d))
+      return d < 0 ? "-Infinity" : "Infinity";
+
+    long bits = doubleToLongBits(d);
+    StringBuilder result = new StringBuilder();
+    
+    if (bits < 0)
+      result.append('-');
+    result.append("0x");
+
+    final int mantissaBits = 52;
+    final int exponentBits = 11;
+    long mantMask = (1L << mantissaBits) - 1;
+    long mantissa = bits & mantMask;
+    long expMask = (1L << exponentBits) - 1;
+    long exponent = (bits >>> mantissaBits) & expMask;
+
+    result.append(exponent == 0 ? '0' : '1');
+    result.append('.');
+    result.append(Long.toHexString(mantissa));
+    if (exponent == 0 && mantissa != 0)
+      {
+        // Treat denormal specially by inserting '0's to make
+        // the length come out right.  The constants here are
+        // to account for things like the '0x'.
+        int offset = 4 + ((bits < 0) ? 1 : 0);
+        // The silly +3 is here to keep the code the same between
+        // the Float and Double cases.  In Float the value is
+        // not a multiple of 4.
+        int desiredLength = offset + (mantissaBits + 3) / 4;
+        while (result.length() < desiredLength)
+          result.insert(offset, '0');
+      }
+    result.append('p');
+    if (exponent == 0 && mantissa == 0)
+      {
+        // Zero, so do nothing special.
+      }
+    else
+      {
+        // Apply bias.
+        boolean denormal = exponent == 0;
+        exponent -= (1 << (exponentBits - 1)) - 1;
+        // Handle denormal.
+        if (denormal)
+          ++exponent;
+      }
+
+    result.append(Long.toString(exponent));
+    return result.toString();
+  }
+
+  /**
+   * Returns a <code>Double</code> object wrapping the value.
+   * In contrast to the <code>Double</code> constructor, this method
+   * may cache some values.  It is used by boxing conversion.
+   *
+   * @param val the value to wrap
+   * @return the <code>Double</code>
+   * 
+   * @since 1.5
+   */
+  public static Double valueOf(double val)
+  {
+    // We don't actually cache, but we could.
+    return new Double(val);
+  }
+
+ /**
+   * Create a new <code>Double</code> object using the <code>String</code>.
+   *
+   * @param s the <code>String</code> to convert
+   * @return the new <code>Double</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>double</code>
+   * @throws NullPointerException if <code>s</code> is null.
+   * @see #parseDouble(String)
+   */
+  public static Double valueOf(String s)
+  {
+    return new Double(parseDouble(s));
+  }
+
+  /**
+   * Parse the specified <code>String</code> as a <code>double</code>. The
+   * extended BNF grammar is as follows:<br>
+   * <pre>
+   * <em>DecodableString</em>:
+   *      ( [ <code>-</code> | <code>+</code> ] <code>NaN</code> )
+   *    | ( [ <code>-</code> | <code>+</code> ] <code>Infinity</code> )
+   *    | ( [ <code>-</code> | <code>+</code> ] <em>FloatingPoint</em>
+   *              [ <code>f</code> | <code>F</code> | <code>d</code>
+   *                | <code>D</code>] )
+   * <em>FloatingPoint</em>:
+   *      ( { <em>Digit</em> }+ [ <code>.</code> { <em>Digit</em> } ]
+   *              [ <em>Exponent</em> ] )
+   *    | ( <code>.</code> { <em>Digit</em> }+ [ <em>Exponent</em> ] )
+   * <em>Exponent</em>:
+   *      ( ( <code>e</code> | <code>E</code> )
+   *              [ <code>-</code> | <code>+</code> ] { <em>Digit</em> }+ )
+   * <em>Digit</em>: <em><code>'0'</code> through <code>'9'</code></em>
+   * </pre>
+   *
+   * <p>NaN and infinity are special cases, to allow parsing of the output
+   * of toString.  Otherwise, the result is determined by calculating
+   * <em>n * 10<sup>exponent</sup></em> to infinite precision, then rounding
+   * to the nearest double. Remember that many numbers cannot be precisely
+   * represented in floating point. In case of overflow, infinity is used,
+   * and in case of underflow, signed zero is used. Unlike Integer.parseInt,
+   * this does not accept Unicode digits outside the ASCII range.
+   *
+   * <p>If an unexpected character is found in the <code>String</code>, a
+   * <code>NumberFormatException</code> will be thrown.  Leading and trailing
+   * 'whitespace' is ignored via <code>String.trim()</code>, but spaces
+   * internal to the actual number are not allowed.
+   *
+   * <p>To parse numbers according to another format, consider using
+   * {@link java.text.NumberFormat}.
+   *
+   * @XXX specify where/how we are not in accord with the spec.
+   *
+   * @param str the <code>String</code> to convert
+   * @return the <code>double</code> value of <code>s</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>double</code>
+   * @throws NullPointerException if <code>s</code> is null
+   * @see #MIN_VALUE
+   * @see #MAX_VALUE
+   * @see #POSITIVE_INFINITY
+   * @see #NEGATIVE_INFINITY
+   * @since 1.2
+   */
+  public static double parseDouble(String str)
+  {
+    return VMDouble.parseDouble(str);
+  }
+
+  /**
+   * Return <code>true</code> if the <code>double</code> has the same
+   * value as <code>NaN</code>, otherwise return <code>false</code>.
+   *
+   * @param v the <code>double</code> to compare
+   * @return whether the argument is <code>NaN</code>.
+   */
+  public static boolean isNaN(double v)
+  {
+    // This works since NaN != NaN is the only reflexive inequality
+    // comparison which returns true.
+    return v != v;
+  }
+
+  /**
+   * Return <code>true</code> if the <code>double</code> has a value
+   * equal to either <code>NEGATIVE_INFINITY</code> or
+   * <code>POSITIVE_INFINITY</code>, otherwise return <code>false</code>.
+   *
+   * @param v the <code>double</code> to compare
+   * @return whether the argument is (-/+) infinity.
+   */
+  public static boolean isInfinite(double v)
+  {
+    return v == POSITIVE_INFINITY || v == NEGATIVE_INFINITY;
+  }
+
+  /**
+   * Return <code>true</code> if the value of this <code>Double</code>
+   * is the same as <code>NaN</code>, otherwise return <code>false</code>.
+   *
+   * @return whether this <code>Double</code> is <code>NaN</code>
+   */
+  public boolean isNaN()
+  {
+    return isNaN(value);
+  }
+
+  /**
+   * Return <code>true</code> if the value of this <code>Double</code>
+   * is the same as <code>NEGATIVE_INFINITY</code> or
+   * <code>POSITIVE_INFINITY</code>, otherwise return <code>false</code>.
+   *
+   * @return whether this <code>Double</code> is (-/+) infinity
+   */
+  public boolean isInfinite()
+  {
+    return isInfinite(value);
+  }
+
+  /**
+   * Convert the <code>double</code> value of this <code>Double</code>
+   * to a <code>String</code>.  This method calls
+   * <code>Double.toString(double)</code> to do its dirty work.
+   *
+   * @return the <code>String</code> representation
+   * @see #toString(double)
+   */
+  public String toString()
+  {
+    return toString(value);
+  }
+
+  /**
+   * Return the value of this <code>Double</code> as a <code>byte</code>.
+   *
+   * @return the byte value
+   * @since 1.1
+   */
+  public byte byteValue()
+  {
+    return (byte) value;
+  }
+
+  /**
+   * Return the value of this <code>Double</code> as a <code>short</code>.
+   *
+   * @return the short value
+   * @since 1.1
+   */
+  public short shortValue()
+  {
+    return (short) value;
+  }
+
+  /**
+   * Return the value of this <code>Double</code> as an <code>int</code>.
+   *
+   * @return the int value
+   */
+  public int intValue()
+  {
+    return (int) value;
+  }
+
+  /**
+   * Return the value of this <code>Double</code> as a <code>long</code>.
+   *
+   * @return the long value
+   */
+  public long longValue()
+  {
+    return (long) value;
+  }
+
+  /**
+   * Return the value of this <code>Double</code> as a <code>float</code>.
+   *
+   * @return the float value
+   */
+  public float floatValue()
+  {
+    return (float) value;
+  }
+
+  /**
+   * Return the value of this <code>Double</code>.
+   *
+   * @return the double value
+   */
+  public double doubleValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return a hashcode representing this Object. <code>Double</code>'s hash
+   * code is calculated by:<br>
+   * <code>long v = Double.doubleToLongBits(doubleValue());<br>
+   *    int hash = (int)(v^(v>>32))</code>.
+   *
+   * @return this Object's hash code
+   * @see #doubleToLongBits(double)
+   */
+  public int hashCode()
+  {
+    long v = doubleToLongBits(value);
+    return (int) (v ^ (v >>> 32));
+  }
+
+  /**
+   * Returns <code>true</code> if <code>obj</code> is an instance of
+   * <code>Double</code> and represents the same double value. Unlike comparing
+   * two doubles with <code>==</code>, this treats two instances of
+   * <code>Double.NaN</code> as equal, but treats <code>0.0</code> and
+   * <code>-0.0</code> as unequal.
+   *
+   * <p>Note that <code>d1.equals(d2)</code> is identical to
+   * <code>doubleToLongBits(d1.doubleValue()) ==
+   *    doubleToLongBits(d2.doubleValue())</code>.
+   *
+   * @param obj the object to compare
+   * @return whether the objects are semantically equal
+   */
+  public boolean equals(Object obj)
+  {
+    if (! (obj instanceof Double))
+      return false;
+
+    double d = ((Double) obj).value;
+
+    // Avoid call to native method. However, some implementations, like gcj,
+    // are better off using floatToIntBits(value) == floatToIntBits(f).
+    // Check common case first, then check NaN and 0.
+    if (value == d)
+      return (value != 0) || (1 / value == 1 / d);
+    return isNaN(value) && isNaN(d);
+  }
+
+  /**
+   * Convert the double to the IEEE 754 floating-point "double format" bit
+   * layout. Bit 63 (the most significant) is the sign bit, bits 62-52
+   * (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0
+   * (masked by 0x000fffffffffffffL) are the mantissa. This function
+   * collapses all versions of NaN to 0x7ff8000000000000L. The result of this
+   * function can be used as the argument to
+   * <code>Double.longBitsToDouble(long)</code> to obtain the original
+   * <code>double</code> value.
+   *
+   * @param value the <code>double</code> to convert
+   * @return the bits of the <code>double</code>
+   * @see #longBitsToDouble(long)
+   */
+  public static long doubleToLongBits(double value)
+  {
+    return VMDouble.doubleToLongBits(value);
+  }
+
+  /**
+   * Convert the double to the IEEE 754 floating-point "double format" bit
+   * layout. Bit 63 (the most significant) is the sign bit, bits 62-52
+   * (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0
+   * (masked by 0x000fffffffffffffL) are the mantissa. This function
+   * leaves NaN alone, rather than collapsing to a canonical value. The
+   * result of this function can be used as the argument to
+   * <code>Double.longBitsToDouble(long)</code> to obtain the original
+   * <code>double</code> value.
+   *
+   * @param value the <code>double</code> to convert
+   * @return the bits of the <code>double</code>
+   * @see #longBitsToDouble(long)
+   */
+  public static long doubleToRawLongBits(double value)
+  {
+    return VMDouble.doubleToRawLongBits(value);
+  }
+
+  /**
+   * Convert the argument in IEEE 754 floating-point "double format" bit
+   * layout to the corresponding float. Bit 63 (the most significant) is the
+   * sign bit, bits 62-52 (masked by 0x7ff0000000000000L) represent the
+   * exponent, and bits 51-0 (masked by 0x000fffffffffffffL) are the mantissa.
+   * This function leaves NaN alone, so that you can recover the bit pattern
+   * with <code>Double.doubleToRawLongBits(double)</code>.
+   *
+   * @param bits the bits to convert
+   * @return the <code>double</code> represented by the bits
+   * @see #doubleToLongBits(double)
+   * @see #doubleToRawLongBits(double)
+   */
+  public static double longBitsToDouble(long bits)
+  {
+    return VMDouble.longBitsToDouble(bits);
+  }
+
+  /**
+   * Compare two Doubles numerically by comparing their <code>double</code>
+   * values. The result is positive if the first is greater, negative if the
+   * second is greater, and 0 if the two are equal. However, this special
+   * cases NaN and signed zero as follows: NaN is considered greater than
+   * all other doubles, including <code>POSITIVE_INFINITY</code>, and positive
+   * zero is considered greater than negative zero.
+   *
+   * @param d the Double to compare
+   * @return the comparison
+   * @since 1.2
+   */
+  public int compareTo(Double d)
+  {
+    return compare(value, d.value);
+  }
+
+  /**
+   * Behaves like <code>compareTo(Double)</code> unless the Object
+   * is not an <code>Double</code>.
+   *
+   * @param o the object to compare
+   * @return the comparison
+   * @throws ClassCastException if the argument is not a <code>Double</code>
+   * @see #compareTo(Double)
+   * @see Comparable
+   * @since 1.2
+   */
+  public int compareTo(Object o)
+  {
+    return compare(value, ((Double) o).value);
+  }
+
+  /**
+   * Behaves like <code>new Double(x).compareTo(new Double(y))</code>; in
+   * other words this compares two doubles, special casing NaN and zero,
+   * without the overhead of objects.
+   *
+   * @param x the first double to compare
+   * @param y the second double to compare
+   * @return the comparison
+   * @since 1.4
+   */
+  public static int compare(double x, double y)
+  {
+    if (isNaN(x))
+      return isNaN(y) ? 0 : 1;
+    if (isNaN(y))
+      return -1;
+    // recall that 0.0 == -0.0, so we convert to infinites and try again
+    if (x == 0 && y == 0)
+      return (int) (1 / x - 1 / y);
+    if (x == y)
+      return 0;
+
+    return x > y ? 1 : -1;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Enum.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Enum.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,248 @@
+/* Enum.java - Base class for all enums
+   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;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+
+/**
+ * This class represents a Java enumeration.  All enumerations are
+ * subclasses of this class.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.5
+ */
+/* FIXME[GENERICS]: Should be Enum<T extends Enum<T>>
+   and Comparable<T> */
+public abstract class Enum
+  implements Comparable, Serializable
+{
+
+  /**
+   * For compatability with Sun's JDK
+   */
+  private static final long serialVersionUID = -4300926546619394005L;
+
+  /**
+   * The name of this enum constant.
+   */
+  String name;
+
+  /**
+   * The number of this enum constant.  Each constant is given a number
+   * which matches the order in which it was declared, starting with zero.
+   */
+  int ordinal;
+
+  /**
+   * This constructor is used by the compiler to create enumeration constants.
+   *
+   * @param name the name of the enumeration constant.
+   * @param ordinal the number of the enumeration constant, based on the
+   *                declaration order of the constants and starting from zero.
+   */
+  protected Enum(String name, int ordinal)
+  {
+    this.name = name;
+    this.ordinal = ordinal;
+  }
+
+  /**
+   * Returns an Enum for a enum class given a description string of
+   * the enum constant.
+   *
+   * @exception NullPointerException when etype or s are null.
+   * @exception IllegalArgumentException when there is no value s in
+   * the enum etype.
+   */
+  /* FIXME[GENERICS]: Should be <S extends Enum<S>> S valueOf(Class<S>) */
+  public static Enum valueOf(Class etype, String s)
+  {
+    if (etype == null || s == null)
+      throw new NullPointerException();
+
+    try
+      {
+        Field f = etype.getDeclaredField(s);
+        if (! f.isEnumConstant())
+          throw new IllegalArgumentException(s);
+	/* FIXME[GENERICS]: Should cast to S */
+        return (Enum) f.get(null); 
+      }
+    catch (NoSuchFieldException exception)
+      {
+	throw new IllegalArgumentException(s);
+      }
+    catch (IllegalAccessException exception)
+      {
+	throw new Error("Unable to access Enum class");
+      }
+  }
+
+  /**
+   * Returns true if this enumeration is equivalent to the supplied object,
+   * <code>o</code>.  Only one instance of an enumeration constant exists,
+   * so the comparison is simply done using <code>==</code>.
+   *
+   * @param o the object to compare to this.
+   * @return true if <code>this == o</code>.
+   */
+  public final boolean equals(Object o)
+  {
+    // Enum constants are singular, so we need only compare `=='.
+    return this == o;
+  }
+
+  /**
+   * Returns the hash code of this constant.  This is simply the ordinal.
+   *
+   * @return the hash code of this enumeration constant.
+   */
+  public final int hashCode()
+  {
+    return ordinal;
+  }
+
+  /**
+   * Returns a textual representation of this enumeration constant.
+   * By default, this is simply the declared name of the constant, but
+   * specific enumeration types may provide an implementation more suited
+   * to the data being stored.
+   *
+   * @return a textual representation of this constant.
+   */
+  public String toString()
+  {
+    return name;
+  }
+
+  /**
+   * Returns an integer which represents the relative ordering of this
+   * enumeration constant.  Enumeration constants are ordered by their
+   * ordinals, which represents their declaration order.  So, comparing
+   * two identical constants yields zero, while one declared prior to
+   * this returns a positive integer and one declared after yields a
+   * negative integer.
+   *
+   * @param e the enumeration constant to compare.
+   * @return a negative integer if <code>e.ordinal < this.ordinal</code>,
+   *         zero if <code>e.ordinal == this.ordinal</code> and a positive
+   *         integer if <code>e.ordinal > this.ordinal</code>.
+   * @throws ClassCastException if <code>e</code> is not an enumeration
+   *                            constant of the same class.
+   */ 
+  public final int compareTo(Enum e)
+  {
+    if (getDeclaringClass() != e.getDeclaringClass())
+      throw new ClassCastException();
+    return ordinal - e.ordinal;
+  }
+
+  /**
+   * Returns an integer which represents the relative ordering of this
+   * enumeration constant.  Enumeration constants are ordered by their
+   * ordinals, which represents their declaration order.  So, comparing
+   * two identical constants yields zero, while one declared prior to
+   * this returns a positive integer and one declared after yields a
+   * negative integer.
+   *
+   * @param o the enumeration constant to compare.
+   * @return a negative integer if <code>e.ordinal < this.ordinal</code>,
+   *         zero if <code>e.ordinal == this.ordinal</code> and a positive
+   *         integer if <code>e.ordinal > this.ordinal</code>.
+   * @throws ClassCastException if <code>e</code> is not an enumeration
+   *                            constant of the same class.
+   */ 
+  /* FIXME[GENERICS]: Remove this method */
+  public final int compareTo(Object o)
+  {
+    return compareTo((Enum)o);
+  }
+
+  /**
+   * Cloning of enumeration constants is prevented, to maintain their
+   * singleton status.
+   *
+   * @return the cloned object.
+   * @throws CloneNotSupportedException as enumeration constants can't be
+   *         cloned.
+   */
+  protected final Object clone() throws CloneNotSupportedException
+  {
+    throw new CloneNotSupportedException("can't clone an enum constant");
+  }
+
+  /**
+   * Returns the name of this enumeration constant.
+   *
+   * @return the name of the constant.
+   */
+  public final String name()
+  {
+    return name;
+  }
+
+  /**
+   * Returns the number of this enumeration constant, which represents
+   * the order in which it was originally declared, starting from zero.
+   * 
+   * @return the number of this constant.
+   */
+  public final int ordinal()
+  {
+    return ordinal;
+  }
+
+  /**
+   * Returns the type of this enumeration constant.  This is the class
+   * corresponding to the declaration of the enumeration.
+   *
+   * @return the type of this enumeration constant.
+   */
+  /* FIXME[GENERICS]: Should return Class<T> */
+  public final Class getDeclaringClass()
+  {
+    Class k = getClass();
+    // We might be in an anonymous subclass of the enum class, so go
+    // up one more level.
+    if (k.getSuperclass() != Enum.class)
+      k = k.getSuperclass();
+    return k;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/EnumConstantNotPresentException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/EnumConstantNotPresentException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,95 @@
+/* EnumConstantNotPresentException.java -- thrown when enum constant
+   not available
+   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;
+
+/**
+ * An exception of this type is thrown when a symbolic reference is
+ * made to an enum constant which does not exist.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @since 1.5
+ */
+public class EnumConstantNotPresentException extends RuntimeException
+{
+  private static final long serialVersionUID = -6046998521960521108L;
+
+  /**
+   * The enum's type.  Note that the name is fixed by the
+   * serialization spec.
+   */
+  private Class enumType;
+
+  /**
+   * The name of the missing enum constant.  Note that the name is
+   * fixed by the serialization spec.
+   */
+  private String constantName;
+
+  /**
+   * Create a new EnumConstantNotPresentException with the indicated
+   * enum type and enum constant name.
+   * @param theEnum the enum's class
+   * @param name the name of the missing enum constant
+   */
+  public EnumConstantNotPresentException(Class theEnum, String name)
+  {
+    super("enum " + theEnum + " is missing the constant " + name);
+    enumType = theEnum;
+    constantName = name;
+  }
+
+  /**
+   * Return the name of the missing constant.
+   * @return the name of the missing constant
+   */
+  public String constantName()
+  {
+    return constantName;
+  }
+
+  /**
+   * Return the enum type which is missing a constant.
+   * @return the enum type which is missing a constant
+   */
+  public Class enumType()
+  {
+    return enumType;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Error.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Error.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,107 @@
+/* Error.java -- Indication of fatal abnormal conditions
+   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;
+
+/**
+ * Applications should not try to catch errors since they indicate
+ * abnormal conditions.  An abnormal condition is something which should not
+ * occur, or which should not be recovered from.  This latter category
+ * includes <code>ThreadDeath</code> and <code>AssertionError</code>.
+ *
+ * <p>A method is not required to declare any subclass of <code>Error</code> in
+ * its <code>throws</code> clause which might be thrown but not caught while
+ * executing the method.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public class Error extends Throwable
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 4980196508277280342L;
+
+  /**
+   * Create an error without a message. The cause remains uninitialized.
+   *
+   * @see #initCause(Throwable)
+   */
+  public Error()
+  {
+  }
+
+  /**
+   * Create an error with a message. The cause remains uninitialized.
+   *
+   * @param s the message string
+   * @see #initCause(Throwable)
+   */
+  public Error(String s)
+  {
+    super(s);
+  }
+
+  /**
+   * Create an error with a message and a cause.
+   *
+   * @param s the message string
+   * @param cause the cause of this error
+   * @since 1.4
+   */
+  public Error(String s, Throwable cause)
+  {
+    super(s, cause);
+  }
+
+  /**
+   * Create an error with a given cause, and a message of
+   * <code>cause == null ? null : cause.toString()</code>.
+   *
+   * @param cause the cause of this error
+   * @since 1.4
+   */
+  public Error(Throwable cause)
+  {
+    super(cause);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Exception.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Exception.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,104 @@
+/* Exception.java -- generic exception thrown to indicate an exceptional
+   condition has occurred.
+   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;
+
+/**
+ * The root class of all exceptions worth catching in a program.  This
+ * includes the special category of <code>RuntimeException</code>, which
+ * does not need to be declared in a throws clause.  Exceptions can be used
+ * to represent almost any exceptional behavior, such as programming errors,
+ * mouse movements, keyboard clicking, etc.
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @status updated to 1.4
+ */
+public class Exception extends Throwable
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -3387516993124229948L;
+
+  /**
+   * Create an exception without a message. The cause remains uninitialized.
+   *
+   * @see #initCause(Throwable)
+   */
+  public Exception()
+  {
+  }
+
+  /**
+   * Create an exception with a message. The cause remains uninitialized.
+   *
+   * @param s the message
+   * @see #initCause(Throwable)
+   */
+  public Exception(String s)
+  {
+    super(s);
+  }
+
+  /**
+   * Create an exception with a message and a cause.
+   *
+   * @param s the message string
+   * @param cause the cause of this error
+   * @since 1.4
+   */
+  public Exception(String s, Throwable cause)
+  {
+    super(s, cause);
+  }
+
+  /**
+   * Create an exception with a given cause, and a message of
+   * <code>cause == null ? null : cause.toString()</code>.
+   *
+   * @param cause the cause of this exception
+   * @since 1.4
+   */
+  public Exception(Throwable cause)
+  {
+    super(cause);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ExceptionInInitializerError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/ExceptionInInitializerError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,123 @@
+/* ExceptionInInitializerError.java -- thrown when class initialization fails
+   with an uncaught exception
+   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;
+
+/**
+ * An <code>ExceptionInInitializerError</code> is thrown when an uncaught
+ * exception has occurred in a static initializer or the initializer for a
+ * static variable. In general, this wraps only RuntimeExceptions, since the
+ * compiler does not allow a checked exception to be uncaught in an
+ * initializer. This exception only occurs during reflection, when a class
+ * is initialized as part of another action.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ExceptionInInitializerError extends LinkageError
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  static final long serialVersionUID = 1521711792217232256L;
+
+  /**
+   * The cause of this exception (duplicates the one stored in Throwable).
+   *
+   * @serial the exception cause
+   */
+  private final Throwable exception;
+
+  /**
+   * Create an error without a message. The cause is initialized as null.
+   */
+  public ExceptionInInitializerError()
+  {
+    this((String) null);
+  }
+
+  /**
+   * Create an error with a message. The cause is initialized as null.
+   *
+   * @param s the message
+   */
+  public ExceptionInInitializerError(String s)
+  {
+    super(s);
+    exception = null;
+  }
+
+  /**
+   * Creates an error an saves a reference to the <code>Throwable</code>
+   * object. The message string is null.
+   *
+   * @param t the exception thrown
+   */
+  public ExceptionInInitializerError(Throwable t)
+  {
+    super(null);
+    initCause(t);
+    exception = t;
+  }
+
+  /**
+   * Return the exception that caused this error to be created. This is a
+   * legacy method; the preferred choice now is {@link Throwable#getCause()}.
+   *
+   * @return the cause, or null if unknown
+   */
+  public Throwable getException()
+  {
+    return exception;
+  }
+
+  /**
+   * Return the exception that cause this error to be created.
+   *
+   * @return the cause, or null if unknown
+   * @since 1.4
+   */
+  public Throwable getCause()
+  {
+    return exception;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Float.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Float.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,626 @@
+/* Float.java -- object wrapper for float
+   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.lang;
+
+/**
+ * Instances of class <code>Float</code> represent primitive
+ * <code>float</code> values.
+ *
+ * Additionally, this class provides various helper functions and variables
+ * related to floats.
+ *
+ * @author Paul Fisher
+ * @author Andrew Haley (aph at cygnus.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public final class Float extends Number implements Comparable
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -2671257302660747028L;
+
+  /**
+   * The maximum positive value a <code>double</code> may represent
+   * is 3.4028235e+38f.
+   */
+  public static final float MAX_VALUE = 3.4028235e+38f;
+
+  /**
+   * The minimum positive value a <code>float</code> may represent
+   * is 1.4e-45.
+   */
+  public static final float MIN_VALUE = 1.4e-45f;
+
+  /**
+   * The value of a float representation -1.0/0.0, negative infinity.
+   */
+  public static final float NEGATIVE_INFINITY = -1.0f / 0.0f;
+
+  /**
+   * The value of a float representation 1.0/0.0, positive infinity.
+   */
+  public static final float POSITIVE_INFINITY = 1.0f / 0.0f;
+
+  /**
+   * All IEEE 754 values of NaN have the same value in Java.
+   */
+  public static final float NaN = 0.0f / 0.0f;
+
+  /**
+   * The primitive type <code>float</code> is represented by this
+   * <code>Class</code> object.
+   * @since 1.1
+   */
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('F');
+
+  /**
+   * The number of bits needed to represent a <code>float</code>.
+   * @since 1.5
+   */
+  public static final int SIZE = 32;
+
+  /**
+   * The immutable value of this Float.
+   *
+   * @serial the wrapped float
+   */
+  private final float value;
+
+  /**
+   * Create a <code>Float</code> from the primitive <code>float</code>
+   * specified.
+   *
+   * @param value the <code>float</code> argument
+   */
+  public Float(float value)
+  {
+    this.value = value;
+  }
+
+  /**
+   * Create a <code>Float</code> from the primitive <code>double</code>
+   * specified.
+   *
+   * @param value the <code>double</code> argument
+   */
+  public Float(double value)
+  {
+    this.value = (float) value;
+  }
+
+  /**
+   * Create a <code>Float</code> from the specified <code>String</code>.
+   * This method calls <code>Float.parseFloat()</code>.
+   *
+   * @param s the <code>String</code> to convert
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>float</code>
+   * @throws NullPointerException if <code>s</code> is null
+   * @see #parseFloat(String)
+   */
+  public Float(String s)
+  {
+    value = parseFloat(s);
+  }
+
+  /**
+   * Convert the <code>float</code> to a <code>String</code>.
+   * Floating-point string representation is fairly complex: here is a
+   * rundown of the possible values.  "<code>[-]</code>" indicates that a
+   * negative sign will be printed if the value (or exponent) is negative.
+   * "<code><number></code>" means a string of digits ('0' to '9').
+   * "<code><digit></code>" means a single digit ('0' to '9').<br>
+   *
+   * <table border=1>
+   * <tr><th>Value of Float</th><th>String Representation</th></tr>
+   * <tr><td>[+-] 0</td> <td><code>[-]0.0</code></td></tr>
+   * <tr><td>Between [+-] 10<sup>-3</sup> and 10<sup>7</sup>, exclusive</td>
+   *     <td><code>[-]number.number</code></td></tr>
+   * <tr><td>Other numeric value</td>
+   *     <td><code>[-]<digit>.<number>
+   *          E[-]<number></code></td></tr>
+   * <tr><td>[+-] infinity</td> <td><code>[-]Infinity</code></td></tr>
+   * <tr><td>NaN</td> <td><code>NaN</code></td></tr>
+   * </table>
+   *
+   * Yes, negative zero <em>is</em> a possible value.  Note that there is
+   * <em>always</em> a <code>.</code> and at least one digit printed after
+   * it: even if the number is 3, it will be printed as <code>3.0</code>.
+   * After the ".", all digits will be printed except trailing zeros. The
+   * result is rounded to the shortest decimal number which will parse back
+   * to the same float.
+   *
+   * <p>To create other output formats, use {@link java.text.NumberFormat}.
+   *
+   * @XXX specify where we are not in accord with the spec.
+   *
+   * @param f the <code>float</code> to convert
+   * @return the <code>String</code> representing the <code>float</code>
+   */
+  public static String toString(float f)
+  {
+    return VMDouble.toString(f, true);
+  }
+
+  /**
+   * Convert a float value to a hexadecimal string.  This converts as
+   * follows:
+   * <ul>
+   * <li> A NaN value is converted to the string "NaN".
+   * <li> Positive infinity is converted to the string "Infinity".
+   * <li> Negative infinity is converted to the string "-Infinity".
+   * <li> For all other values, the first character of the result is '-'
+   * if the value is negative.  This is followed by '0x1.' if the
+   * value is normal, and '0x0.' if the value is denormal.  This is
+   * then followed by a (lower-case) hexadecimal representation of the
+   * mantissa, with leading zeros as required for denormal values.
+   * The next character is a 'p', and this is followed by a decimal
+   * representation of the unbiased exponent.
+   * </ul>
+   * @param f the float value
+   * @return the hexadecimal string representation
+   * @since 1.5
+   */
+  public static String toHexString(float f)
+  {
+    if (isNaN(f))
+      return "NaN";
+    if (isInfinite(f))
+      return f < 0 ? "-Infinity" : "Infinity";
+
+    int bits = floatToIntBits(f);
+    StringBuilder result = new StringBuilder();
+    
+    if (bits < 0)
+      result.append('-');
+    result.append("0x");
+
+    final int mantissaBits = 23;
+    final int exponentBits = 8;
+    int mantMask = (1 << mantissaBits) - 1;
+    int mantissa = bits & mantMask;
+    int expMask = (1 << exponentBits) - 1;
+    int exponent = (bits >>> mantissaBits) & expMask;
+
+    result.append(exponent == 0 ? '0' : '1');
+    result.append('.');
+    // For Float only, we have to adjust the mantissa.
+    mantissa <<= 1;
+    result.append(Integer.toHexString(mantissa));
+    if (exponent == 0 && mantissa != 0)
+      {
+        // Treat denormal specially by inserting '0's to make
+        // the length come out right.  The constants here are
+        // to account for things like the '0x'.
+        int offset = 4 + ((bits < 0) ? 1 : 0);
+        // The silly +3 is here to keep the code the same between
+        // the Float and Double cases.  In Float the value is
+        // not a multiple of 4.
+        int desiredLength = offset + (mantissaBits + 3) / 4;
+        while (result.length() < desiredLength)
+          result.insert(offset, '0');
+      }
+    result.append('p');
+    if (exponent == 0 && mantissa == 0)
+      {
+        // Zero, so do nothing special.
+      }
+    else
+      {
+        // Apply bias.
+        boolean denormal = exponent == 0;
+        exponent -= (1 << (exponentBits - 1)) - 1;
+        // Handle denormal.
+        if (denormal)
+          ++exponent;
+      }
+
+    result.append(Integer.toString(exponent));
+    return result.toString();
+  }
+
+  /**
+   * Creates a new <code>Float</code> object using the <code>String</code>.
+   *
+   * @param s the <code>String</code> to convert
+   * @return the new <code>Float</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>float</code>
+   * @throws NullPointerException if <code>s</code> is null
+   * @see #parseFloat(String)
+   */
+  public static Float valueOf(String s)
+  {
+    return new Float(parseFloat(s));
+  }
+
+  /**
+   * Returns a <code>Float</code> object wrapping the value.
+   * In contrast to the <code>Float</code> constructor, this method
+   * may cache some values.  It is used by boxing conversion.
+   *
+   * @param val the value to wrap
+   * @return the <code>Float</code>
+   * 
+   * @since 1.5
+   */
+  public static Float valueOf(float val)
+  {
+    // We don't actually cache, but we could.
+    return new Float(val);
+  }
+
+  /**
+   * Parse the specified <code>String</code> as a <code>float</code>. The
+   * extended BNF grammar is as follows:<br>
+   * <pre>
+   * <em>DecodableString</em>:
+   *      ( [ <code>-</code> | <code>+</code> ] <code>NaN</code> )
+   *    | ( [ <code>-</code> | <code>+</code> ] <code>Infinity</code> )
+   *    | ( [ <code>-</code> | <code>+</code> ] <em>FloatingPoint</em>
+   *              [ <code>f</code> | <code>F</code> | <code>d</code>
+   *                | <code>D</code>] )
+   * <em>FloatingPoint</em>:
+   *      ( { <em>Digit</em> }+ [ <code>.</code> { <em>Digit</em> } ]
+   *              [ <em>Exponent</em> ] )
+   *    | ( <code>.</code> { <em>Digit</em> }+ [ <em>Exponent</em> ] )
+   * <em>Exponent</em>:
+   *      ( ( <code>e</code> | <code>E</code> )
+   *              [ <code>-</code> | <code>+</code> ] { <em>Digit</em> }+ )
+   * <em>Digit</em>: <em><code>'0'</code> through <code>'9'</code></em>
+   * </pre>
+   *
+   * <p>NaN and infinity are special cases, to allow parsing of the output
+   * of toString.  Otherwise, the result is determined by calculating
+   * <em>n * 10<sup>exponent</sup></em> to infinite precision, then rounding
+   * to the nearest float. Remember that many numbers cannot be precisely
+   * represented in floating point. In case of overflow, infinity is used,
+   * and in case of underflow, signed zero is used. Unlike Integer.parseInt,
+   * this does not accept Unicode digits outside the ASCII range.
+   *
+   * <p>If an unexpected character is found in the <code>String</code>, a
+   * <code>NumberFormatException</code> will be thrown.  Leading and trailing
+   * 'whitespace' is ignored via <code>String.trim()</code>, but spaces
+   * internal to the actual number are not allowed.
+   *
+   * <p>To parse numbers according to another format, consider using
+   * {@link java.text.NumberFormat}.
+   *
+   * @XXX specify where/how we are not in accord with the spec.
+   *
+   * @param str the <code>String</code> to convert
+   * @return the <code>float</code> value of <code>s</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>float</code>
+   * @throws NullPointerException if <code>s</code> is null
+   * @see #MIN_VALUE
+   * @see #MAX_VALUE
+   * @see #POSITIVE_INFINITY
+   * @see #NEGATIVE_INFINITY
+   * @since 1.2
+   */
+  public static float parseFloat(String str)
+  {
+    // XXX Rounding parseDouble() causes some errors greater than 1 ulp from
+    // the infinitely precise decimal.
+    return (float) Double.parseDouble(str);
+  }
+
+  /**
+   * Return <code>true</code> if the <code>float</code> has the same
+   * value as <code>NaN</code>, otherwise return <code>false</code>.
+   *
+   * @param v the <code>float</code> to compare
+   * @return whether the argument is <code>NaN</code>
+   */
+  public static boolean isNaN(float v)
+  {
+    // This works since NaN != NaN is the only reflexive inequality
+    // comparison which returns true.
+    return v != v;
+  }
+
+  /**
+   * Return <code>true</code> if the <code>float</code> has a value
+   * equal to either <code>NEGATIVE_INFINITY</code> or
+   * <code>POSITIVE_INFINITY</code>, otherwise return <code>false</code>.
+   *
+   * @param v the <code>float</code> to compare
+   * @return whether the argument is (-/+) infinity
+   */
+  public static boolean isInfinite(float v)
+  {
+    return v == POSITIVE_INFINITY || v == NEGATIVE_INFINITY;
+  }
+
+  /**
+   * Return <code>true</code> if the value of this <code>Float</code>
+   * is the same as <code>NaN</code>, otherwise return <code>false</code>.
+   *
+   * @return whether this <code>Float</code> is <code>NaN</code>
+   */
+  public boolean isNaN()
+  {
+    return isNaN(value);
+  }
+
+  /**
+   * Return <code>true</code> if the value of this <code>Float</code>
+   * is the same as <code>NEGATIVE_INFINITY</code> or
+   * <code>POSITIVE_INFINITY</code>, otherwise return <code>false</code>.
+   *
+   * @return whether this <code>Float</code> is (-/+) infinity
+   */
+  public boolean isInfinite()
+  {
+    return isInfinite(value);
+  }
+
+  /**
+   * Convert the <code>float</code> value of this <code>Float</code>
+   * to a <code>String</code>.  This method calls
+   * <code>Float.toString(float)</code> to do its dirty work.
+   *
+   * @return the <code>String</code> representation
+   * @see #toString(float)
+   */
+  public String toString()
+  {
+    return toString(value);
+  }
+
+  /**
+   * Return the value of this <code>Float</code> as a <code>byte</code>.
+   *
+   * @return the byte value
+   * @since 1.1
+   */
+  public byte byteValue()
+  {
+    return (byte) value;
+  }
+
+  /**
+   * Return the value of this <code>Float</code> as a <code>short</code>.
+   *
+   * @return the short value
+   * @since 1.1
+   */
+  public short shortValue()
+  {
+    return (short) value;
+  }
+
+  /**
+   * Return the value of this <code>Integer</code> as an <code>int</code>.
+   *
+   * @return the int value
+   */
+  public int intValue()
+  {
+    return (int) value;
+  }
+
+  /**
+   * Return the value of this <code>Integer</code> as a <code>long</code>.
+   *
+   * @return the long value
+   */
+  public long longValue()
+  {
+    return (long) value;
+  }
+
+  /**
+   * Return the value of this <code>Float</code>.
+   *
+   * @return the float value
+   */
+  public float floatValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Float</code> as a <code>double</code>
+   *
+   * @return the double value
+   */
+  public double doubleValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return a hashcode representing this Object. <code>Float</code>'s hash
+   * code is calculated by calling <code>floatToIntBits(floatValue())</code>.
+   *
+   * @return this Object's hash code
+   * @see #floatToIntBits(float)
+   */
+  public int hashCode()
+  {
+    return floatToIntBits(value);
+  }
+
+  /**
+   * Returns <code>true</code> if <code>obj</code> is an instance of
+   * <code>Float</code> and represents the same float value. Unlike comparing
+   * two floats with <code>==</code>, this treats two instances of
+   * <code>Float.NaN</code> as equal, but treats <code>0.0</code> and
+   * <code>-0.0</code> as unequal.
+   *
+   * <p>Note that <code>f1.equals(f2)</code> is identical to
+   * <code>floatToIntBits(f1.floatValue()) ==
+   *    floatToIntBits(f2.floatValue())</code>.
+   *
+   * @param obj the object to compare
+   * @return whether the objects are semantically equal
+   */
+  public boolean equals(Object obj)
+  {
+    if (! (obj instanceof Float))
+      return false;
+
+    float f = ((Float) obj).value;
+
+    // Avoid call to native method. However, some implementations, like gcj,
+    // are better off using floatToIntBits(value) == floatToIntBits(f).
+    // Check common case first, then check NaN and 0.
+    if (value == f)
+      return (value != 0) || (1 / value == 1 / f);
+    return isNaN(value) && isNaN(f);
+  }
+
+  /**
+   * Convert the float to the IEEE 754 floating-point "single format" bit
+   * layout. Bit 31 (the most significant) is the sign bit, bits 30-23
+   * (masked by 0x7f800000) represent the exponent, and bits 22-0
+   * (masked by 0x007fffff) are the mantissa. This function collapses all
+   * versions of NaN to 0x7fc00000. The result of this function can be used
+   * as the argument to <code>Float.intBitsToFloat(int)</code> to obtain the
+   * original <code>float</code> value.
+   *
+   * @param value the <code>float</code> to convert
+   * @return the bits of the <code>float</code>
+   * @see #intBitsToFloat(int)
+   */
+  public static int floatToIntBits(float value)
+  {
+    return VMFloat.floatToIntBits(value);
+  }
+
+  /**
+   * Convert the float to the IEEE 754 floating-point "single format" bit
+   * layout. Bit 31 (the most significant) is the sign bit, bits 30-23
+   * (masked by 0x7f800000) represent the exponent, and bits 22-0
+   * (masked by 0x007fffff) are the mantissa. This function leaves NaN alone,
+   * rather than collapsing to a canonical value. The result of this function
+   * can be used as the argument to <code>Float.intBitsToFloat(int)</code> to
+   * obtain the original <code>float</code> value.
+   *
+   * @param value the <code>float</code> to convert
+   * @return the bits of the <code>float</code>
+   * @see #intBitsToFloat(int)
+   */
+  public static int floatToRawIntBits(float value)
+  {
+    return VMFloat.floatToRawIntBits(value);
+  }
+
+  /**
+   * Convert the argument in IEEE 754 floating-point "single format" bit
+   * layout to the corresponding float. Bit 31 (the most significant) is the
+   * sign bit, bits 30-23 (masked by 0x7f800000) represent the exponent, and
+   * bits 22-0 (masked by 0x007fffff) are the mantissa. This function leaves
+   * NaN alone, so that you can recover the bit pattern with
+   * <code>Float.floatToRawIntBits(float)</code>.
+   *
+   * @param bits the bits to convert
+   * @return the <code>float</code> represented by the bits
+   * @see #floatToIntBits(float)
+   * @see #floatToRawIntBits(float)
+   */
+  public static float intBitsToFloat(int bits)
+  {
+    return VMFloat.intBitsToFloat(bits);
+  }
+
+  /**
+   * Compare two Floats numerically by comparing their <code>float</code>
+   * values. The result is positive if the first is greater, negative if the
+   * second is greater, and 0 if the two are equal. However, this special
+   * cases NaN and signed zero as follows: NaN is considered greater than
+   * all other floats, including <code>POSITIVE_INFINITY</code>, and positive
+   * zero is considered greater than negative zero.
+   *
+   * @param f the Float to compare
+   * @return the comparison
+   * @since 1.2
+   */
+  public int compareTo(Float f)
+  {
+    return compare(value, f.value);
+  }
+
+  /**
+   * Behaves like <code>compareTo(Float)</code> unless the Object
+   * is not an <code>Float</code>.
+   *
+   * @param o the object to compare
+   * @return the comparison
+   * @throws ClassCastException if the argument is not a <code>Float</code>
+   * @see #compareTo(Float)
+   * @see Comparable
+   * @since 1.2
+   */
+  public int compareTo(Object o)
+  {
+    return compare(value, ((Float) o).value);
+  }
+
+  /**
+   * Behaves like <code>new Float(x).compareTo(new Float(y))</code>; in
+   * other words this compares two floats, special casing NaN and zero,
+   * without the overhead of objects.
+   *
+   * @param x the first float to compare
+   * @param y the second float to compare
+   * @return the comparison
+   * @since 1.4
+   */
+  public static int compare(float x, float y)
+  {
+    if (isNaN(x))
+      return isNaN(y) ? 0 : 1;
+    if (isNaN(y))
+      return -1;
+    // recall that 0.0 == -0.0, so we convert to infinities and try again
+    if (x == 0 && y == 0)
+      return (int) (1 / x - 1 / y);
+    if (x == y)
+      return 0;
+
+    return x > y ? 1 : -1;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IllegalAccessError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IllegalAccessError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* IllegalAccessError.java -- thrown when linking to an inaccessible member
+   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;
+
+/**
+ * An <code>IllegalAccessError</code> is thrown when an attempt is made to
+ * call a method, or access or modify a field that the application does not
+ * have access to.  Because this error is usually caught by a compiler,
+ * the error only occurs at runtime when the definition of a class has
+ * changed in a way that is incompatible with the previously compiled
+ * application.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public class IllegalAccessError extends IncompatibleClassChangeError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -8988904074992417891L;
+
+  /**
+   * Create an error without a message.
+   */
+  public IllegalAccessError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public IllegalAccessError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IllegalAccessException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IllegalAccessException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,99 @@
+/* IllegalAccessException.java -- thrown on attempt to reflect on
+   inaccessible data
+   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;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * Thrown whenever a reflective method tries to do something that the
+ * compiler would not allow.  For example, using reflection to set a private
+ * variable that belongs to a class in another package is bad.
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @see Class#newInstance()
+ * @see Field#set(Object, Object)
+ * @see Field#setBoolean(Object, boolean)
+ * @see Field#setByte(Object, byte)
+ * @see Field#setShort(Object, short)
+ * @see Field#setChar(Object, char)
+ * @see Field#setInt(Object, int)
+ * @see Field#setLong(Object, long)
+ * @see Field#setFloat(Object, float)
+ * @see Field#setDouble(Object, double)
+ * @see Field#get(Object)
+ * @see Field#getBoolean(Object)
+ * @see Field#getByte(Object)
+ * @see Field#getShort(Object)
+ * @see Field#getChar(Object)
+ * @see Field#getInt(Object)
+ * @see Field#getLong(Object)
+ * @see Field#getFloat(Object)
+ * @see Field#getDouble(Object)
+ * @see Method#invoke(Object, Object[])
+ * @see Constructor#newInstance(Object[])
+ * @status updated to 1.4
+ */
+public class IllegalAccessException extends Exception
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 6616958222490762034L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public IllegalAccessException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public IllegalAccessException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IllegalArgumentException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IllegalArgumentException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,129 @@
+/* IllegalArgumentException.java -- thrown when a method is passed an
+   illegal or inappropriate argument
+   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;
+
+/**
+ * Thrown when a method is passed an illegal or inappropriate argument. For
+ * example:<br>
+ * <pre>
+ * wait(-1);
+ * </pre>
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @status updated to 1.5
+ */
+public class IllegalArgumentException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -5365630128856068164L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public IllegalArgumentException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public IllegalArgumentException(String s)
+  {
+    super(s);
+  }
+
+  /**
+   * <p>
+   * Constructs a <code>IllegalArgumentException</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 IllegalArgumentException(String message, Throwable cause)
+  {
+    super(message, cause);
+  }
+
+  /**
+   * <p>
+   * Constructs a <code>IllegalArgumentException</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 IllegalArgumentException(Throwable cause)
+  {
+    super(cause);
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IllegalMonitorStateException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IllegalMonitorStateException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,78 @@
+/* IllegalMonitorStateException.java -- thrown when trying to wait or
+   notify a monitor that is not owned
+   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;
+
+/**
+ * Thrown when a thread attempts to wait or notify on a monitor that it
+ * does not own (ie. it has not synchronized on the object). For example:<br>
+ * <pre>
+ * void m() {
+ *   notify();
+ * }
+ * </pre>
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class IllegalMonitorStateException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 3713306369498869069L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public IllegalMonitorStateException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public IllegalMonitorStateException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IllegalStateException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IllegalStateException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,135 @@
+/* IllegalStateException.java -- thrown when invoking a method at
+   an illegal or inappropriate time
+   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;
+
+/**
+ * Thrown when a method is invoked at an illegal or inappropriate time. For
+ * example:<br>
+ * <pre>
+ * void m(Collecion c)
+ * {
+ *   c.iterator().remove();
+ * }
+ * </pre>
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.1
+ * @status updated to 1.5
+ */
+public class IllegalStateException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = -1848914673093119416L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public IllegalStateException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public IllegalStateException(String s)
+  {
+    super(s);
+  }
+
+  /**
+   * <p>
+   * Constructs a <code>IllegalStateException</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 IllegalStateException(String message, Throwable cause)
+  {
+    super(message, cause);
+  }
+
+  /**
+   * <p>
+   * Constructs a <code>IllegalStateException</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 IllegalStateException(Throwable cause)
+  {
+    super(cause);
+  }
+
+}
+

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IllegalThreadStateException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IllegalThreadStateException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* IllegalThreadStateException.java -- thrown when trying to manipulate a
+   Thread when it is not in an appropriate state
+   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;
+
+/**
+ * Thrown When trying to manipulate a Thread which is in an inappropriate
+ * state. Since the documentation suggests that this can happen with
+ * <code>Thread.suspend</code> or <code>Thread.resume</code>, but these
+ * two methods are deprecated, this exception is likely very rare.
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class IllegalThreadStateException extends IllegalArgumentException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -7626246362397460174L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public IllegalThreadStateException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public IllegalThreadStateException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IncompatibleClassChangeError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IncompatibleClassChangeError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* IncompatibleClassChangeError.java -- thrown for binary incompatible classes
+   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;
+
+/**
+ * An <code>IncompatibleClassChangeError</code> is thrown when the definition
+ * of a class used by the currently executing method has changed in an
+ * incompatible way.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public class IncompatibleClassChangeError extends LinkageError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -4914975503642802119L;
+
+  /**
+   * Create an error without a message.
+   */
+  public IncompatibleClassChangeError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public IncompatibleClassChangeError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IndexOutOfBoundsException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/IndexOutOfBoundsException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* IndexOutOfBoundsException.java -- thrown for an invalid index
+   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 on objects like String, Array, or Vector.
+ * Usually any negative integer less than or equal to -1 and positive 
+ * integer greater than or equal to the size of the object 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 IndexOutOfBoundsException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 234122996006267687L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public IndexOutOfBoundsException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public IndexOutOfBoundsException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/InheritableThreadLocal.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/InheritableThreadLocal.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,117 @@
+/* InheritableThreadLocal -- a ThreadLocal which inherits values across threads
+   Copyright (C) 2000, 2001, 2002, 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.lang;
+
+import gnu.java.util.WeakIdentityHashMap;
+
+import java.util.Iterator;
+
+/**
+ * A ThreadLocal whose value is inherited by child Threads. The value of the
+ * InheritableThreadLocal associated with the (parent) Thread is copied to
+ * the new (child) Thread at the moment of creation.
+ *
+ * <p>It is possible to make the value associated with the child Thread a
+ * function of the value that is associated with the parent Thread by
+ * overriding the <code>childValue()</code> method. The utility of this class
+ * is in transferring items like User ID or Transaction ID across threads
+ * automatically.
+ *
+ * @author Mark Wielaard (mark at klomp.org)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see ThreadLocal
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class InheritableThreadLocal extends ThreadLocal
+{
+  /**
+   * Creates a new InheritableThreadLocal that has no values associated
+   * with it yet.
+   */
+  public InheritableThreadLocal()
+  {
+  }
+
+  /**
+   * Determines the value associated with a newly created child Thread as a
+   * function of the value associated with the currently executing (parent)
+   * Thread. The default implementation just returns the parentValue.
+   *
+   * @param parentValue the value of this object in the parent thread at
+   *        the moment of creation of the child
+   * @return the initial value for the child thread
+   */
+  protected Object childValue(Object parentValue)
+  {
+    return parentValue;
+  }
+
+  /**
+   * Generates the childValues of all <code>InheritableThreadLocal</code>s
+   * that are in the heritage of the current Thread for the newly created
+   * childThread. Should be called from the contructor Thread.
+   *
+   * @param childThread the newly created thread, to inherit from this thread
+   * @see Thread#Thread(ThreadGroup, Runnable, String)
+   */
+  static void newChildThread(Thread childThread)
+  {
+    // The currentThread is the parent of the new thread.
+    Thread parentThread = Thread.currentThread();
+    if (parentThread.locals != null)
+      {
+        Iterator keys = parentThread.locals.keySet().iterator();
+        while (keys.hasNext())
+          {
+            Object key = keys.next();
+            if (key instanceof InheritableThreadLocal)
+              {
+                InheritableThreadLocal local = (InheritableThreadLocal)key;
+                Object parentValue = parentThread.locals.get(key);
+                Object childValue = local.childValue(parentValue == NULL
+                                                     ? null : parentValue);
+                if (childThread.locals == null)
+                    childThread.locals = new WeakIdentityHashMap();
+                childThread.locals.put(key, (childValue == null
+                                             ? NULL : childValue));
+              }
+          }
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/InstantiationError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/InstantiationError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* InstantiationError.java -- thrown when the linker cannot create an instance
+   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;
+
+/**
+ * An <code>InstantiationError</code> is thrown when an attempt is made to
+ * create an instance of an abstract class or an interface.  Because this
+ * error is usually caught by a compiler, the error only occurs at runtime
+ * when the definition of a class has changed in a way that is incompatible
+ * with the previously compiled application.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public class InstantiationError extends IncompatibleClassChangeError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -4885810657349421204L;
+
+  /**
+   * Create an error without a message.
+   */
+  public InstantiationError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public InstantiationError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/InstantiationException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/InstantiationException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* InstantiationException.java -- thrown when reflection cannot create an
+   instance
+   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;
+
+/**
+ * Thrown when an attempt is made to use reflection to build a
+ * non-instantiable class (an interface or abstract class).
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @see Class#newInstance()
+ * @status updated to 1.4
+ */
+public class InstantiationException extends Exception
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -8441929162975509110L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public InstantiationException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public InstantiationException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Integer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Integer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,772 @@
+/* Integer.java -- object wrapper for int
+   Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang;
+
+/**
+ * Instances of class <code>Integer</code> represent primitive
+ * <code>int</code> values.
+ *
+ * Additionally, this class provides various helper functions and variables
+ * related to ints.
+ *
+ * @author Paul Fisher
+ * @author John Keiser
+ * @author Warren Levy
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @author Tom Tromey (tromey at redhat.com)
+ * @since 1.0
+ * @status largely updated to 1.5
+ */
+public final class Integer extends Number implements Comparable
+{
+  /**
+   * Compatible with JDK 1.0.2+.
+   */
+  private static final long serialVersionUID = 1360826667806852920L;
+
+  /**
+   * The minimum value an <code>int</code> can represent is -2147483648 (or
+   * -2<sup>31</sup>).
+   */
+  public static final int MIN_VALUE = 0x80000000;
+
+  /**
+   * The maximum value an <code>int</code> can represent is 2147483647 (or
+   * 2<sup>31</sup> - 1).
+   */
+  public static final int MAX_VALUE = 0x7fffffff;
+
+  /**
+   * The primitive type <code>int</code> is represented by this
+   * <code>Class</code> object.
+   * @since 1.1
+   */
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('I');
+
+  /**
+   * The number of bits needed to represent an <code>int</code>.
+   * @since 1.5
+   */
+  public static final int SIZE = 32;
+
+  // This caches some Integer values, and is used by boxing
+  // conversions via valueOf().  We must cache at least -128..127;
+  // these constants control how much we actually cache.
+  private static final int MIN_CACHE = -128;
+  private static final int MAX_CACHE = 127;
+  private static Integer[] intCache = new Integer[MAX_CACHE - MIN_CACHE + 1];
+
+  /**
+   * The immutable value of this Integer.
+   *
+   * @serial the wrapped int
+   */
+  private final int value;
+
+  /**
+   * Create an <code>Integer</code> object representing the value of the
+   * <code>int</code> argument.
+   *
+   * @param value the value to use
+   */
+  public Integer(int value)
+  {
+    this.value = value;
+  }
+
+  /**
+   * Create an <code>Integer</code> object representing the value of the
+   * argument after conversion to an <code>int</code>.
+   *
+   * @param s the string to convert
+   * @throws NumberFormatException if the String does not contain an int
+   * @see #valueOf(String)
+   */
+  public Integer(String s)
+  {
+    value = parseInt(s, 10, false);
+  }
+
+  /**
+   * Converts the <code>int</code> to a <code>String</code> using
+   * the specified radix (base). If the radix exceeds
+   * <code>Character.MIN_RADIX</code> or <code>Character.MAX_RADIX</code>, 10
+   * is used instead. If the result is negative, the leading character is
+   * '-' ('\\u002D'). The remaining characters come from
+   * <code>Character.forDigit(digit, radix)</code> ('0'-'9','a'-'z').
+   *
+   * @param num the <code>int</code> to convert to <code>String</code>
+   * @param radix the radix (base) to use in the conversion
+   * @return the <code>String</code> representation of the argument
+   */
+  public static String toString(int num, int radix)
+  {
+    if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
+      radix = 10;
+
+    // For negative numbers, print out the absolute value w/ a leading '-'.
+    // Use an array large enough for a binary number.
+    char[] buffer = new char[33];
+    int i = 33;
+    boolean isNeg = false;
+    if (num < 0)
+      {
+        isNeg = true;
+        num = -num;
+
+        // When the value is MIN_VALUE, it overflows when made positive
+        if (num < 0)
+	  {
+	    buffer[--i] = digits[(int) (-(num + radix) % radix)];
+	    num = -(num / radix);
+	  }
+      }
+
+    do
+      {
+        buffer[--i] = digits[num % radix];
+        num /= radix;
+      }
+    while (num > 0);
+
+    if (isNeg)
+      buffer[--i] = '-';
+
+    // Package constructor avoids an array copy.
+    return new String(buffer, i, 33 - i, true);
+  }
+
+  /**
+   * Converts the <code>int</code> to a <code>String</code> assuming it is
+   * unsigned in base 16.
+   *
+   * @param i the <code>int</code> to convert to <code>String</code>
+   * @return the <code>String</code> representation of the argument
+   */
+  public static String toHexString(int i)
+  {
+    return toUnsignedString(i, 4);
+  }
+
+  /**
+   * Converts the <code>int</code> to a <code>String</code> assuming it is
+   * unsigned in base 8.
+   *
+   * @param i the <code>int</code> to convert to <code>String</code>
+   * @return the <code>String</code> representation of the argument
+   */
+  public static String toOctalString(int i)
+  {
+    return toUnsignedString(i, 3);
+  }
+
+  /**
+   * Converts the <code>int</code> to a <code>String</code> assuming it is
+   * unsigned in base 2.
+   *
+   * @param i the <code>int</code> to convert to <code>String</code>
+   * @return the <code>String</code> representation of the argument
+   */
+  public static String toBinaryString(int i)
+  {
+    return toUnsignedString(i, 1);
+  }
+
+  /**
+   * Converts the <code>int</code> to a <code>String</code> and assumes
+   * a radix of 10.
+   *
+   * @param i the <code>int</code> to convert to <code>String</code>
+   * @return the <code>String</code> representation of the argument
+   * @see #toString(int, int)
+   */
+  public static String toString(int i)
+  {
+    // This is tricky: in libgcj, String.valueOf(int) is a fast native
+    // implementation.  In Classpath it just calls back to
+    // Integer.toString(int, int).
+    return String.valueOf(i);
+  }
+
+  /**
+   * Converts the specified <code>String</code> into an <code>int</code>
+   * using the specified radix (base). The string must not be <code>null</code>
+   * or empty. It may begin with an optional '-', which will negate the answer,
+   * provided that there are also valid digits. Each digit is parsed as if by
+   * <code>Character.digit(d, radix)</code>, and must be in the range
+   * <code>0</code> to <code>radix - 1</code>. Finally, the result must be
+   * within <code>MIN_VALUE</code> to <code>MAX_VALUE</code>, inclusive.
+   * Unlike Double.parseDouble, you may not have a leading '+'.
+   *
+   * @param str the <code>String</code> to convert
+   * @param radix the radix (base) to use in the conversion
+   * @return the <code>String</code> argument converted to <code>int</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as an
+   *         <code>int</code>
+   */
+  public static int parseInt(String str, int radix)
+  {
+    return parseInt(str, radix, false);
+  }
+
+  /**
+   * Converts the specified <code>String</code> into an <code>int</code>.
+   * This function assumes a radix of 10.
+   *
+   * @param s the <code>String</code> to convert
+   * @return the <code>int</code> value of <code>s</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as an
+   *         <code>int</code>
+   * @see #parseInt(String, int)
+   */
+  public static int parseInt(String s)
+  {
+    return parseInt(s, 10, false);
+  }
+
+  /**
+   * Creates a new <code>Integer</code> object using the <code>String</code>
+   * and specified radix (base).
+   *
+   * @param s the <code>String</code> to convert
+   * @param radix the radix (base) to convert with
+   * @return the new <code>Integer</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as an
+   *         <code>int</code>
+   * @see #parseInt(String, int)
+   */
+  public static Integer valueOf(String s, int radix)
+  {
+    return new Integer(parseInt(s, radix, false));
+  }
+
+  /**
+   * Creates a new <code>Integer</code> object using the <code>String</code>,
+   * assuming a radix of 10.
+   *
+   * @param s the <code>String</code> to convert
+   * @return the new <code>Integer</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as an
+   *         <code>int</code>
+   * @see #Integer(String)
+   * @see #parseInt(String)
+   */
+  public static Integer valueOf(String s)
+  {
+    return new Integer(parseInt(s, 10, false));
+  }
+
+  /**
+   * Returns an <code>Integer</code> object wrapping the value.
+   * In contrast to the <code>Integer</code> constructor, this method
+   * will cache some values.  It is used by boxing conversion.
+   *
+   * @param val the value to wrap
+   * @return the <code>Integer</code>
+   */
+  public static Integer valueOf(int val)
+  {
+    if (val < MIN_CACHE || val > MAX_CACHE)
+      return new Integer(val);
+    synchronized (intCache)
+      {
+	if (intCache[val - MIN_CACHE] == null)
+	  intCache[val - MIN_CACHE] = new Integer(val);
+	return intCache[val - MIN_CACHE];
+      }
+  }
+
+  /**
+   * Return the value of this <code>Integer</code> as a <code>byte</code>.
+   *
+   * @return the byte value
+   */
+  public byte byteValue()
+  {
+    return (byte) value;
+  }
+
+  /**
+   * Return the value of this <code>Integer</code> as a <code>short</code>.
+   *
+   * @return the short value
+   */
+  public short shortValue()
+  {
+    return (short) value;
+  }
+
+  /**
+   * Return the value of this <code>Integer</code>.
+   * @return the int value
+   */
+  public int intValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Integer</code> as a <code>long</code>.
+   *
+   * @return the long value
+   */
+  public long longValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Integer</code> as a <code>float</code>.
+   *
+   * @return the float value
+   */
+  public float floatValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Integer</code> as a <code>double</code>.
+   *
+   * @return the double value
+   */
+  public double doubleValue()
+  {
+    return value;
+  }
+
+  /**
+   * Converts the <code>Integer</code> value to a <code>String</code> and
+   * assumes a radix of 10.
+   *
+   * @return the <code>String</code> representation
+   */
+  public String toString()
+  {
+    return String.valueOf(value);
+  }
+
+  /**
+   * Return a hashcode representing this Object. <code>Integer</code>'s hash
+   * code is simply its value.
+   *
+   * @return this Object's hash code
+   */
+  public int hashCode()
+  {
+    return value;
+  }
+
+  /**
+   * Returns <code>true</code> if <code>obj</code> is an instance of
+   * <code>Integer</code> and represents the same int value.
+   *
+   * @param obj the object to compare
+   * @return whether these Objects are semantically equal
+   */
+  public boolean equals(Object obj)
+  {
+    return obj instanceof Integer && value == ((Integer) obj).value;
+  }
+
+  /**
+   * Get the specified system property as an <code>Integer</code>. The
+   * <code>decode()</code> method will be used to interpret the value of
+   * the property.
+   *
+   * @param nm the name of the system property
+   * @return the system property as an <code>Integer</code>, or null if the
+   *         property is not found or cannot be decoded
+   * @throws SecurityException if accessing the system property is forbidden
+   * @see System#getProperty(String)
+   * @see #decode(String)
+   */
+  public static Integer getInteger(String nm)
+  {
+    return getInteger(nm, null);
+  }
+
+  /**
+   * Get the specified system property as an <code>Integer</code>, or use a
+   * default <code>int</code> value if the property is not found or is not
+   * decodable. The <code>decode()</code> method will be used to interpret
+   * the value of the property.
+   *
+   * @param nm the name of the system property
+   * @param val the default value
+   * @return the value of the system property, or the default
+   * @throws SecurityException if accessing the system property is forbidden
+   * @see System#getProperty(String)
+   * @see #decode(String)
+   */
+  public static Integer getInteger(String nm, int val)
+  {
+    Integer result = getInteger(nm, null);
+    return result == null ? new Integer(val) : result;
+  }
+
+  /**
+   * Get the specified system property as an <code>Integer</code>, or use a
+   * default <code>Integer</code> value if the property is not found or is
+   * not decodable. The <code>decode()</code> method will be used to
+   * interpret the value of the property.
+   *
+   * @param nm the name of the system property
+   * @param def the default value
+   * @return the value of the system property, or the default
+   * @throws SecurityException if accessing the system property is forbidden
+   * @see System#getProperty(String)
+   * @see #decode(String)
+   */
+  public static Integer getInteger(String nm, Integer def)
+  {
+    if (nm == null || "".equals(nm))
+      return def;
+    nm = System.getProperty(nm);
+    if (nm == null)
+      return def;
+    try
+      {
+        return decode(nm);
+      }
+    catch (NumberFormatException e)
+      {
+        return def;
+      }
+  }
+
+  /**
+   * Convert the specified <code>String</code> into an <code>Integer</code>.
+   * The <code>String</code> may represent decimal, hexadecimal, or
+   * octal numbers.
+   *
+   * <p>The extended BNF grammar is as follows:<br>
+   * <pre>
+   * <em>DecodableString</em>:
+   *      ( [ <code>-</code> ] <em>DecimalNumber</em> )
+   *    | ( [ <code>-</code> ] ( <code>0x</code> | <code>0X</code>
+   *              | <code>#</code> ) <em>HexDigit</em> { <em>HexDigit</em> } )
+   *    | ( [ <code>-</code> ] <code>0</code> { <em>OctalDigit</em> } )
+   * <em>DecimalNumber</em>:
+   *        <em>DecimalDigit except '0'</em> { <em>DecimalDigit</em> }
+   * <em>DecimalDigit</em>:
+   *        <em>Character.digit(d, 10) has value 0 to 9</em>
+   * <em>OctalDigit</em>:
+   *        <em>Character.digit(d, 8) has value 0 to 7</em>
+   * <em>DecimalDigit</em>:
+   *        <em>Character.digit(d, 16) has value 0 to 15</em>
+   * </pre>
+   * Finally, the value must be in the range <code>MIN_VALUE</code> to
+   * <code>MAX_VALUE</code>, or an exception is thrown.
+   *
+   * @param str the <code>String</code> to interpret
+   * @return the value of the String as an <code>Integer</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>int</code>
+   * @throws NullPointerException if <code>s</code> is null
+   * @since 1.2
+   */
+  public static Integer decode(String str)
+  {
+    return new Integer(parseInt(str, 10, true));
+  }
+
+  /**
+   * Compare two Integers numerically by comparing their <code>int</code>
+   * values. The result is positive if the first is greater, negative if the
+   * second is greater, and 0 if the two are equal.
+   *
+   * @param i the Integer to compare
+   * @return the comparison
+   * @since 1.2
+   */
+  public int compareTo(Integer i)
+  {
+    if (value == i.value)
+      return 0;
+    // Returns just -1 or 1 on inequality; doing math might overflow.
+    return value > i.value ? 1 : -1;
+  }
+
+  /**
+   * Behaves like <code>compareTo(Integer)</code> unless the Object
+   * is not an <code>Integer</code>.
+   *
+   * @param o the object to compare
+   * @return the comparison
+   * @throws ClassCastException if the argument is not an <code>Integer</code>
+   * @see #compareTo(Integer)
+   * @see Comparable
+   * @since 1.2
+   */
+  public int compareTo(Object o)
+  {
+    return compareTo((Integer) o);
+  }
+
+  /**
+   * Return the number of bits set in x.
+   * @param x value to examine
+   * @since 1.5
+   */
+  public static int bitCount(int x)
+  {
+    // Successively collapse alternating bit groups into a sum.
+    x = ((x >> 1) & 0x55555555) + (x & 0x55555555);
+    x = ((x >> 2) & 0x33333333) + (x & 0x33333333);
+    x = ((x >> 4) & 0x0f0f0f0f) + (x & 0x0f0f0f0f);
+    x = ((x >> 8) & 0x00ff00ff) + (x & 0x00ff00ff);
+    return ((x >> 16) & 0x0000ffff) + (x & 0x0000ffff);
+  }
+
+  /**
+   * Rotate x to the left by distance bits.
+   * @param x the value to rotate
+   * @param distance the number of bits by which to rotate
+   * @since 1.5
+   */
+  public static int rotateLeft(int x, int distance)
+  {
+    // This trick works because the shift operators implicitly mask
+    // the shift count.
+    return (x << distance) | (x >>> - distance);
+  }
+
+  /**
+   * Rotate x to the right by distance bits.
+   * @param x the value to rotate
+   * @param distance the number of bits by which to rotate
+   * @since 1.5
+   */
+  public static int rotateRight(int x, int distance)
+  {
+    // This trick works because the shift operators implicitly mask
+    // the shift count.
+    return (x << - distance) | (x >>> distance);
+  }
+
+  /**
+   * Find the highest set bit in value, and return a new value
+   * with only that bit set.
+   * @param value the value to examine
+   * @since 1.5
+   */
+  public static int highestOneBit(int value)
+  {
+    value |= value >>> 1;
+    value |= value >>> 2;
+    value |= value >>> 4;
+    value |= value >>> 8;
+    value |= value >>> 16;
+    return value ^ (value >>> 1);
+  }
+
+  /**
+   * Return the number of leading zeros in value.
+   * @param value the value to examine
+   * @since 1.5
+   */
+  public static int numberOfLeadingZeros(int value)
+  {
+    value |= value >>> 1;
+    value |= value >>> 2;
+    value |= value >>> 4;
+    value |= value >>> 8;
+    value |= value >>> 16;
+    return bitCount(~value);
+  }
+
+  /**
+   * Find the lowest set bit in value, and return a new value
+   * with only that bit set.
+   * @param value the value to examine
+   * @since 1.5
+   */
+  public static int lowestOneBit(int value)
+  {
+    // Classic assembly trick.
+    return value & - value;
+  }
+
+  /**
+   * Find the number of trailing zeros in value.
+   * @param value the value to examine
+   * @since 1.5
+   */
+  public static int numberOfTrailingZeros(int value)
+  {
+    return bitCount((value & -value) - 1);
+  }
+
+  /**
+   * Return 1 if x is positive, -1 if it is negative, and 0 if it is
+   * zero.
+   * @param x the value to examine
+   * @since 1.5
+   */
+  public static int signum(int x)
+  {
+    return x < 0 ? -1 : (x > 0 ? 1 : 0);
+  }
+
+  /**
+   * Reverse the bytes in val.
+   * @since 1.5
+   */
+  public static int reverseBytes(int val)
+  {
+    return (  ((val >> 24) & 0xff)
+	    | ((val >> 8) & 0xff00)
+	    | ((val << 8) & 0xff0000)
+	    | ((val << 24) & 0xff000000));
+  }
+
+  /**
+   * Reverse the bits in val.
+   * @since 1.5
+   */
+  public static int reverse(int val)
+  {
+    // Successively swap alternating bit groups.
+    val = ((val >> 1) & 0x55555555) + ((val << 1) & ~0x55555555);
+    val = ((val >> 2) & 0x33333333) + ((val << 2) & ~0x33333333);
+    val = ((val >> 4) & 0x0f0f0f0f) + ((val << 4) & ~0x0f0f0f0f);
+    val = ((val >> 8) & 0x00ff00ff) + ((val << 8) & ~0x00ff00ff);
+    return ((val >> 16) & 0x0000ffff) + ((val << 16) & ~0x0000ffff);
+  }
+
+  /**
+   * Helper for converting unsigned numbers to String.
+   *
+   * @param num the number
+   * @param exp log2(digit) (ie. 1, 3, or 4 for binary, oct, hex)
+   */
+  // Package visible for use by Long.
+  static String toUnsignedString(int num, int exp)
+  {
+    // Use an array large enough for a binary number.
+    int mask = (1 << exp) - 1;
+    char[] buffer = new char[32];
+    int i = 32;
+    do
+      {
+        buffer[--i] = digits[num & mask];
+        num >>>= exp;
+      }
+    while (num != 0);
+
+    // Package constructor avoids an array copy.
+    return new String(buffer, i, 32 - i, true);
+  }
+
+  /**
+   * Helper for parsing ints, used by Integer, Short, and Byte.
+   *
+   * @param str the string to parse
+   * @param radix the radix to use, must be 10 if decode is true
+   * @param decode if called from decode
+   * @return the parsed int value
+   * @throws NumberFormatException if there is an error
+   * @throws NullPointerException if decode is true and str if null
+   * @see #parseInt(String, int)
+   * @see #decode(String)
+   * @see Byte#parseByte(String, int)
+   * @see Short#parseShort(String, int)
+   */
+  static int parseInt(String str, int radix, boolean decode)
+  {
+    if (! decode && str == null)
+      throw new NumberFormatException();
+    int index = 0;
+    int len = str.length();
+    boolean isNeg = false;
+    if (len == 0)
+      throw new NumberFormatException("string length is null");
+    int ch = str.charAt(index);
+    if (ch == '-')
+      {
+        if (len == 1)
+          throw new NumberFormatException("pure '-'");
+        isNeg = true;
+        ch = str.charAt(++index);
+      }
+    if (decode)
+      {
+        if (ch == '0')
+          {
+            if (++index == len)
+              return 0;
+            if ((str.charAt(index) & ~('x' ^ 'X')) == 'X')
+              {
+                radix = 16;
+                index++;
+              }
+            else
+              radix = 8;
+          }
+        else if (ch == '#')
+          {
+            radix = 16;
+            index++;
+          }
+      }
+    if (index == len)
+      throw new NumberFormatException("non terminated number: " + str);
+
+    int max = MAX_VALUE / radix;
+    // We can't directly write `max = (MAX_VALUE + 1) / radix'.
+    // So instead we fake it.
+    if (isNeg && MAX_VALUE % radix == radix - 1)
+      ++max;
+
+    int val = 0;
+    while (index < len)
+      {
+	if (val < 0 || val > max)
+	  throw new NumberFormatException("number overflow (pos=" + index + ") : " + str);
+
+        ch = Character.digit(str.charAt(index++), radix);
+        val = val * radix + ch;
+        if (ch < 0 || (val < 0 && (! isNeg || val != MIN_VALUE)))
+          throw new NumberFormatException("invalid character at position " + index + " in " + str);
+      }
+    return isNeg ? -val : val;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/InternalError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/InternalError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* InternalError.java -- thrown when the VM encounters an internal error
+   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;
+
+/**
+ * An <code>InternalError</code> is thrown when a mystical error has
+ * occurred in the Java Virtual Machine.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public class InternalError extends VirtualMachineError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -9062593416125562365L;
+
+  /**
+   * Create an error without a message.
+   */
+  public InternalError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public InternalError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/InterruptedException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/InterruptedException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,80 @@
+/* InterruptedException.java -- thrown when a thread is interrupted
+   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;
+
+/**
+ * Thrown when a thread interrupts another thread which was previously
+ * sleeping, waiting, or paused in some other way.  See the
+ * <code>interrupt</code> method of class <code>Thread</code>.
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @see Object#wait()
+ * @see Object#wait(long)
+ * @see Object#wait(long, int)
+ * @see Thread#sleep(long)
+ * @see Thread#interrupt()
+ * @see Thread#interrupted()
+ * @status updated to 1.4
+ */
+public class InterruptedException extends Exception
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 6700697376100628473L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public InterruptedException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   *
+   * @param s the message
+   */
+  public InterruptedException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Iterable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Iterable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,60 @@
+/* Iterable.java -- Notes collection over which one may iterate
+   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;
+
+// We only need Iterator, but we import * to support lib/mkcollections.pl
+import java.util.*;
+
+/**
+ * This interface is used to indicate that a given class can be
+ * iterated over.  The compiler uses this interface to determine which
+ * classes are suitable targets of the <code>foreach</code> construct.
+ *
+ * @author Tom Tromey <tromey at redhat.com>
+ * @since 1.5
+ */
+public interface Iterable
+{
+  /**
+   * Returns an iterator for the collection.
+   *
+   * @return an iterator.
+   */
+  Iterator iterator ();
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/LinkageError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/LinkageError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* LinkageError.java -- thrown when classes valid at separate compile times
+   cannot be linked to each other
+   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;
+
+/**
+ * Subclasses of <code>LinkageError</code> are thrown to indicate that two
+ * classes which were compatible at separate compilation times cannot be
+ * linked to one another.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public class LinkageError extends Error
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 3579600108157160122L;
+
+  /**
+   * Create an error without a message.
+   */
+  public LinkageError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public LinkageError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Long.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Long.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,765 @@
+/* Long.java -- object wrapper for long
+   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;
+
+/**
+ * Instances of class <code>Long</code> represent primitive
+ * <code>long</code> values.
+ *
+ * Additionally, this class provides various helper functions and variables
+ * related to longs.
+ *
+ * @author Paul Fisher
+ * @author John Keiser
+ * @author Warren Levy
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status updated to 1.5
+ */
+public final class Long extends Number implements Comparable
+{
+  /**
+   * Compatible with JDK 1.0.2+.
+   */
+  private static final long serialVersionUID = 4290774380558885855L;
+
+  /**
+   * The minimum value a <code>long</code> can represent is
+   * -9223372036854775808L (or -2<sup>63</sup>).
+   */
+  public static final long MIN_VALUE = 0x8000000000000000L;
+
+  /**
+   * The maximum value a <code>long</code> can represent is
+   * 9223372036854775807 (or 2<sup>63</sup> - 1).
+   */
+  public static final long MAX_VALUE = 0x7fffffffffffffffL;
+
+  /**
+   * The primitive type <code>long</code> is represented by this
+   * <code>Class</code> object.
+   * @since 1.1
+   */
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass ('J');
+
+  /**
+   * The number of bits needed to represent a <code>long</code>.
+   * @since 1.5
+   */
+  public static final int SIZE = 64;
+
+  /**
+   * The immutable value of this Long.
+   *
+   * @serial the wrapped long
+   */
+  private final long value;
+
+  /**
+   * Create a <code>Long</code> object representing the value of the
+   * <code>long</code> argument.
+   *
+   * @param value the value to use
+   */
+  public Long(long value)
+  {
+    this.value = value;
+  }
+
+  /**
+   * Create a <code>Long</code> object representing the value of the
+   * argument after conversion to a <code>long</code>.
+   *
+   * @param s the string to convert
+   * @throws NumberFormatException if the String does not contain a long
+   * @see #valueOf(String)
+   */
+  public Long(String s)
+  {
+    value = parseLong(s, 10, false);
+  }
+
+  /**
+   * Converts the <code>long</code> to a <code>String</code> using
+   * the specified radix (base). If the radix exceeds
+   * <code>Character.MIN_RADIX</code> or <code>Character.MAX_RADIX</code>, 10
+   * is used instead. If the result is negative, the leading character is
+   * '-' ('\\u002D'). The remaining characters come from
+   * <code>Character.forDigit(digit, radix)</code> ('0'-'9','a'-'z').
+   *
+   * @param num the <code>long</code> to convert to <code>String</code>
+   * @param radix the radix (base) to use in the conversion
+   * @return the <code>String</code> representation of the argument
+   */
+  public static String toString(long num, int radix)
+  {
+    // Use the Integer toString for efficiency if possible.
+    if ((int) num == num)
+      return Integer.toString((int) num, radix);
+
+    if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
+      radix = 10;
+
+    // For negative numbers, print out the absolute value w/ a leading '-'.
+    // Use an array large enough for a binary number.
+    char[] buffer = new char[65];
+    int i = 65;
+    boolean isNeg = false;
+    if (num < 0)
+      {
+        isNeg = true;
+        num = -num;
+
+        // When the value is MIN_VALUE, it overflows when made positive
+        if (num < 0)
+	  {
+	    buffer[--i] = digits[(int) (-(num + radix) % radix)];
+	    num = -(num / radix);
+	  }
+      }
+
+    do
+      {
+        buffer[--i] = digits[(int) (num % radix)];
+        num /= radix;
+      }
+    while (num > 0);
+
+    if (isNeg)
+      buffer[--i] = '-';
+
+    // Package constructor avoids an array copy.
+    return new String(buffer, i, 65 - i, true);
+  }
+
+  /**
+   * Converts the <code>long</code> to a <code>String</code> assuming it is
+   * unsigned in base 16.
+   *
+   * @param l the <code>long</code> to convert to <code>String</code>
+   * @return the <code>String</code> representation of the argument
+   */
+  public static String toHexString(long l)
+  {
+    return toUnsignedString(l, 4);
+  }
+
+  /**
+   * Converts the <code>long</code> to a <code>String</code> assuming it is
+   * unsigned in base 8.
+   *
+   * @param l the <code>long</code> to convert to <code>String</code>
+   * @return the <code>String</code> representation of the argument
+   */
+  public static String toOctalString(long l)
+  {
+    return toUnsignedString(l, 3);
+  }
+
+  /**
+   * Converts the <code>long</code> to a <code>String</code> assuming it is
+   * unsigned in base 2.
+   *
+   * @param l the <code>long</code> to convert to <code>String</code>
+   * @return the <code>String</code> representation of the argument
+   */
+  public static String toBinaryString(long l)
+  {
+    return toUnsignedString(l, 1);
+  }
+
+  /**
+   * Converts the <code>long</code> to a <code>String</code> and assumes
+   * a radix of 10.
+   *
+   * @param num the <code>long</code> to convert to <code>String</code>
+   * @return the <code>String</code> representation of the argument
+   * @see #toString(long, int)
+   */
+  public static String toString(long num)
+  {
+    return toString(num, 10);
+  }
+
+  /**
+   * Converts the specified <code>String</code> into an <code>int</code>
+   * using the specified radix (base). The string must not be <code>null</code>
+   * or empty. It may begin with an optional '-', which will negate the answer,
+   * provided that there are also valid digits. Each digit is parsed as if by
+   * <code>Character.digit(d, radix)</code>, and must be in the range
+   * <code>0</code> to <code>radix - 1</code>. Finally, the result must be
+   * within <code>MIN_VALUE</code> to <code>MAX_VALUE</code>, inclusive.
+   * Unlike Double.parseDouble, you may not have a leading '+'; and 'l' or
+   * 'L' as the last character is only valid in radices 22 or greater, where
+   * it is a digit and not a type indicator.
+   *
+   * @param str the <code>String</code> to convert
+   * @param radix the radix (base) to use in the conversion
+   * @return the <code>String</code> argument converted to <code>long</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>long</code>
+   */
+  public static long parseLong(String str, int radix)
+  {
+    return parseLong(str, radix, false);
+  }
+
+  /**
+   * Converts the specified <code>String</code> into a <code>long</code>.
+   * This function assumes a radix of 10.
+   *
+   * @param s the <code>String</code> to convert
+   * @return the <code>int</code> value of <code>s</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>long</code>
+   * @see #parseLong(String, int)
+   */
+  public static long parseLong(String s)
+  {
+    return parseLong(s, 10, false);
+  }
+
+  /**
+   * Creates a new <code>Long</code> object using the <code>String</code>
+   * and specified radix (base).
+   *
+   * @param s the <code>String</code> to convert
+   * @param radix the radix (base) to convert with
+   * @return the new <code>Long</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>long</code>
+   * @see #parseLong(String, int)
+   */
+  public static Long valueOf(String s, int radix)
+  {
+    return new Long(parseLong(s, radix, false));
+  }
+
+  /**
+   * Creates a new <code>Long</code> object using the <code>String</code>,
+   * assuming a radix of 10.
+   *
+   * @param s the <code>String</code> to convert
+   * @return the new <code>Long</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>long</code>
+   * @see #Long(String)
+   * @see #parseLong(String)
+   */
+  public static Long valueOf(String s)
+  {
+    return new Long(parseLong(s, 10, false));
+  }
+
+  /**
+   * Returns a <code>Long</code> object wrapping the value.
+   *
+   * @param val the value to wrap
+   * @return the <code>Long</code>
+   * 
+   * @since 1.5
+   */
+  public static synchronized Long valueOf(long val)
+  {
+    // We aren't required to cache here.  We could, though perhaps we
+    // ought to consider that as an empirical question.
+    return new Long(val);
+  }
+
+  /**
+   * Convert the specified <code>String</code> into a <code>Long</code>.
+   * The <code>String</code> may represent decimal, hexadecimal, or
+   * octal numbers.
+   *
+   * <p>The extended BNF grammar is as follows:<br>
+   * <pre>
+   * <em>DecodableString</em>:
+   *      ( [ <code>-</code> ] <em>DecimalNumber</em> )
+   *    | ( [ <code>-</code> ] ( <code>0x</code> | <code>0X</code>
+   *              | <code>#</code> ) <em>HexDigit</em> { <em>HexDigit</em> } )
+   *    | ( [ <code>-</code> ] <code>0</code> { <em>OctalDigit</em> } )
+   * <em>DecimalNumber</em>:
+   *        <em>DecimalDigit except '0'</em> { <em>DecimalDigit</em> }
+   * <em>DecimalDigit</em>:
+   *        <em>Character.digit(d, 10) has value 0 to 9</em>
+   * <em>OctalDigit</em>:
+   *        <em>Character.digit(d, 8) has value 0 to 7</em>
+   * <em>DecimalDigit</em>:
+   *        <em>Character.digit(d, 16) has value 0 to 15</em>
+   * </pre>
+   * Finally, the value must be in the range <code>MIN_VALUE</code> to
+   * <code>MAX_VALUE</code>, or an exception is thrown. Note that you cannot
+   * use a trailing 'l' or 'L', unlike in Java source code.
+   *
+   * @param str the <code>String</code> to interpret
+   * @return the value of the String as a <code>Long</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>long</code>
+   * @throws NullPointerException if <code>s</code> is null
+   * @since 1.2
+   */
+  public static Long decode(String str)
+  {
+    return new Long(parseLong(str, 10, true));
+  }
+
+  /**
+   * Return the value of this <code>Long</code> as a <code>byte</code>.
+   *
+   * @return the byte value
+   */
+  public byte byteValue()
+  {
+    return (byte) value;
+  }
+
+  /**
+   * Return the value of this <code>Long</code> as a <code>short</code>.
+   *
+   * @return the short value
+   */
+  public short shortValue()
+  {
+    return (short) value;
+  }
+
+  /**
+   * Return the value of this <code>Long</code> as an <code>int</code>.
+   *
+   * @return the int value
+   */
+  public int intValue()
+  {
+    return (int) value;
+  }
+
+  /**
+   * Return the value of this <code>Long</code>.
+   *
+   * @return the long value
+   */
+  public long longValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Long</code> as a <code>float</code>.
+   *
+   * @return the float value
+   */
+  public float floatValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Long</code> as a <code>double</code>.
+   *
+   * @return the double value
+   */
+  public double doubleValue()
+  {
+    return value;
+  }
+
+  /**
+   * Converts the <code>Long</code> value to a <code>String</code> and
+   * assumes a radix of 10.
+   *
+   * @return the <code>String</code> representation
+   */
+  public String toString()
+  {
+    return toString(value, 10);
+  }
+
+  /**
+   * Return a hashcode representing this Object. <code>Long</code>'s hash
+   * code is calculated by <code>(int) (value ^ (value >> 32))</code>.
+   *
+   * @return this Object's hash code
+   */
+  public int hashCode()
+  {
+    return (int) (value ^ (value >>> 32));
+  }
+
+  /**
+   * Returns <code>true</code> if <code>obj</code> is an instance of
+   * <code>Long</code> and represents the same long value.
+   *
+   * @param obj the object to compare
+   * @return whether these Objects are semantically equal
+   */
+  public boolean equals(Object obj)
+  {
+    return obj instanceof Long && value == ((Long) obj).value;
+  }
+
+  /**
+   * Get the specified system property as a <code>Long</code>. The
+   * <code>decode()</code> method will be used to interpret the value of
+   * the property.
+   *
+   * @param nm the name of the system property
+   * @return the system property as a <code>Long</code>, or null if the
+   *         property is not found or cannot be decoded
+   * @throws SecurityException if accessing the system property is forbidden
+   * @see System#getProperty(String)
+   * @see #decode(String)
+   */
+  public static Long getLong(String nm)
+  {
+    return getLong(nm, null);
+  }
+
+  /**
+   * Get the specified system property as a <code>Long</code>, or use a
+   * default <code>long</code> value if the property is not found or is not
+   * decodable. The <code>decode()</code> method will be used to interpret
+   * the value of the property.
+   *
+   * @param nm the name of the system property
+   * @param val the default value
+   * @return the value of the system property, or the default
+   * @throws SecurityException if accessing the system property is forbidden
+   * @see System#getProperty(String)
+   * @see #decode(String)
+   */
+  public static Long getLong(String nm, long val)
+  {
+    Long result = getLong(nm, null);
+    return result == null ? new Long(val) : result;
+  }
+
+  /**
+   * Get the specified system property as a <code>Long</code>, or use a
+   * default <code>Long</code> value if the property is not found or is
+   * not decodable. The <code>decode()</code> method will be used to
+   * interpret the value of the property.
+   *
+   * @param nm the name of the system property
+   * @param def the default value
+   * @return the value of the system property, or the default
+   * @throws SecurityException if accessing the system property is forbidden
+   * @see System#getProperty(String)
+   * @see #decode(String)
+   */
+  public static Long getLong(String nm, Long def)
+  {
+    if (nm == null || "".equals(nm))
+      return def;
+    nm = System.getProperty(nm);
+    if (nm == null)
+      return def;
+    try
+      {
+        return decode(nm);
+      }
+    catch (NumberFormatException e)
+      {
+        return def;
+      }
+  }
+
+  /**
+   * Compare two Longs numerically by comparing their <code>long</code>
+   * values. The result is positive if the first is greater, negative if the
+   * second is greater, and 0 if the two are equal.
+   *
+   * @param l the Long to compare
+   * @return the comparison
+   * @since 1.2
+   */
+  public int compareTo(Long l)
+  {
+    if (value == l.value)
+      return 0;
+    // Returns just -1 or 1 on inequality; doing math might overflow the long.
+    return value > l.value ? 1 : -1;
+  }
+
+  /**
+   * Behaves like <code>compareTo(Long)</code> unless the Object
+   * is not a <code>Long</code>.
+   *
+   * @param o the object to compare
+   * @return the comparison
+   * @throws ClassCastException if the argument is not a <code>Long</code>
+   * @see #compareTo(Long)
+   * @see Comparable
+   * @since 1.2
+   */
+  public int compareTo(Object o)
+  {
+    return compareTo((Long) o);
+  }
+
+  /**
+   * Return the number of bits set in x.
+   * @param x value to examine
+   * @since 1.5
+   */
+  public static int bitCount(long x)
+  {
+    // Successively collapse alternating bit groups into a sum.
+    x = ((x >> 1) & 0x5555555555555555L) + (x & 0x5555555555555555L);
+    x = ((x >> 2) & 0x3333333333333333L) + (x & 0x3333333333333333L);
+    int v = (int) ((x >>> 32) + x);
+    v = ((v >> 4) & 0x0f0f0f0f) + (v & 0x0f0f0f0f);
+    v = ((v >> 8) & 0x00ff00ff) + (v & 0x00ff00ff);
+    return ((v >> 16) & 0x0000ffff) + (v & 0x0000ffff);
+  }
+
+  /**
+   * Rotate x to the left by distance bits.
+   * @param x the value to rotate
+   * @param distance the number of bits by which to rotate
+   * @since 1.5
+   */
+  public static long rotateLeft(long x, int distance)
+  {
+    // This trick works because the shift operators implicitly mask
+    // the shift count.
+    return (x << distance) | (x >>> - distance);
+  }
+
+  /**
+   * Rotate x to the right by distance bits.
+   * @param x the value to rotate
+   * @param distance the number of bits by which to rotate
+   * @since 1.5
+   */
+  public static long rotateRight(long x, int distance)
+  {
+    // This trick works because the shift operators implicitly mask
+    // the shift count.
+    return (x << - distance) | (x >>> distance);
+  }
+
+  /**
+   * Find the highest set bit in value, and return a new value
+   * with only that bit set.
+   * @param value the value to examine
+   * @since 1.5
+   */
+  public static long highestOneBit(long value)
+  {
+    value |= value >>> 1;
+    value |= value >>> 2;
+    value |= value >>> 4;
+    value |= value >>> 8;
+    value |= value >>> 16;
+    value |= value >>> 32;
+    return value ^ (value >>> 1);
+  }
+
+  /**
+   * Return the number of leading zeros in value.
+   * @param value the value to examine
+   * @since 1.5
+   */
+  public static int numberOfLeadingZeros(long value)
+  {
+    value |= value >>> 1;
+    value |= value >>> 2;
+    value |= value >>> 4;
+    value |= value >>> 8;
+    value |= value >>> 16;
+    value |= value >>> 32;
+    return bitCount(~value);
+  }
+
+  /**
+   * Find the lowest set bit in value, and return a new value
+   * with only that bit set.
+   * @param value the value to examine
+   * @since 1.5
+   */
+  public static long lowestOneBit(long value)
+  {
+    // Classic assembly trick.
+    return value & - value;
+  }
+
+  /**
+   * Find the number of trailing zeros in value.
+   * @param value the value to examine
+   * @since 1.5
+   */
+  public static int numberOfTrailingZeros(long value)
+  {
+    return bitCount((value & -value) - 1);
+  }
+
+  /**
+   * Return 1 if x is positive, -1 if it is negative, and 0 if it is
+   * zero.
+   * @param x the value to examine
+   * @since 1.5
+   */
+  public static int signum(long x)
+  {
+    return x < 0 ? -1 : (x > 0 ? 1 : 0);
+  }
+
+  /**
+   * Reverse the bytes in val.
+   * @since 1.5
+   */
+  public static long reverseBytes(long val)
+  {
+    int hi = Integer.reverseBytes((int) val);
+    int lo = Integer.reverseBytes((int) (val >>> 32));
+    return (((long) hi) << 32) | lo;
+  }
+
+  /**
+   * Reverse the bits in val.
+   * @since 1.5
+   */
+  public static long reverse(long val)
+  {
+    long hi = Integer.reverse((int) val) & 0xffffffffL;
+    long lo = Integer.reverse((int) (val >>> 32)) & 0xffffffffL;
+    return (hi << 32) | lo;
+  }
+
+  /**
+   * Helper for converting unsigned numbers to String.
+   *
+   * @param num the number
+   * @param exp log2(digit) (ie. 1, 3, or 4 for binary, oct, hex)
+   */
+  private static String toUnsignedString(long num, int exp)
+  {
+    // Use the Integer toUnsignedString for efficiency if possible.
+    // If NUM<0 then this particular optimization doesn't work
+    // properly.
+    if (num >= 0 && (int) num == num)
+      return Integer.toUnsignedString((int) num, exp);
+
+    // Use an array large enough for a binary number.
+    int mask = (1 << exp) - 1;
+    char[] buffer = new char[64];
+    int i = 64;
+    do
+      {
+        buffer[--i] = digits[(int) num & mask];
+        num >>>= exp;
+      }
+    while (num != 0);
+
+    // Package constructor avoids an array copy.
+    return new String(buffer, i, 64 - i, true);
+  }
+
+  /**
+   * Helper for parsing longs.
+   *
+   * @param str the string to parse
+   * @param radix the radix to use, must be 10 if decode is true
+   * @param decode if called from decode
+   * @return the parsed long value
+   * @throws NumberFormatException if there is an error
+   * @throws NullPointerException if decode is true and str is null
+   * @see #parseLong(String, int)
+   * @see #decode(String)
+   */
+  private static long parseLong(String str, int radix, boolean decode)
+  {
+    if (! decode && str == null)
+      throw new NumberFormatException();
+    int index = 0;
+    int len = str.length();
+    boolean isNeg = false;
+    if (len == 0)
+      throw new NumberFormatException();
+    int ch = str.charAt(index);
+    if (ch == '-')
+      {
+        if (len == 1)
+          throw new NumberFormatException();
+        isNeg = true;
+        ch = str.charAt(++index);
+      }
+    if (decode)
+      {
+        if (ch == '0')
+          {
+            if (++index == len)
+              return 0;
+            if ((str.charAt(index) & ~('x' ^ 'X')) == 'X')
+              {
+                radix = 16;
+                index++;
+              }
+            else
+              radix = 8;
+          }
+        else if (ch == '#')
+          {
+            radix = 16;
+            index++;
+          }
+      }
+    if (index == len)
+      throw new NumberFormatException();
+
+    long max = MAX_VALUE / radix;
+    // We can't directly write `max = (MAX_VALUE + 1) / radix'.
+    // So instead we fake it.
+    if (isNeg && MAX_VALUE % radix == radix - 1)
+      ++max;
+
+    long val = 0;
+    while (index < len)
+      {
+	if (val < 0 || val > max)
+	  throw new NumberFormatException();
+
+        ch = Character.digit(str.charAt(index++), radix);
+        val = val * radix + ch;
+        if (ch < 0 || (val < 0 && (! isNeg || val != MIN_VALUE)))
+          throw new NumberFormatException();
+      }
+    return isNeg ? -val : val;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Math.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Math.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1052 @@
+/* java.lang.Math -- common mathematical functions, native allowed (VMMath)
+   Copyright (C) 1998, 2001, 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 gnu.classpath.Configuration;
+
+import java.util.Random;
+
+/**
+ * Helper class containing useful mathematical functions and constants.
+ * <P>
+ *
+ * Note that angles are specified in radians.  Conversion functions are
+ * provided for your convenience.
+ *
+ * @author Paul Fisher
+ * @author John Keiser
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.0
+ */
+public final class Math
+{
+
+  // FIXME - This is here because we need to load the "javalang" system
+  // library somewhere late in the bootstrap cycle. We cannot do this
+  // from VMSystem or VMRuntime since those are used to actually load
+  // the library. This is mainly here because historically Math was
+  // late enough in the bootstrap cycle to start using System after it
+  // was initialized (called from the java.util classes).
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+        System.loadLibrary("javalang");
+      }
+  }
+
+  /**
+   * Math is non-instantiable
+   */
+  private Math()
+  {
+  }
+
+  /**
+   * A random number generator, initialized on first use.
+   */
+  private static Random rand;
+
+  /**
+   * The most accurate approximation to the mathematical constant <em>e</em>:
+   * <code>2.718281828459045</code>. Used in natural log and exp.
+   *
+   * @see #log(double)
+   * @see #exp(double)
+   */
+  public static final double E = 2.718281828459045;
+
+  /**
+   * The most accurate approximation to the mathematical constant <em>pi</em>:
+   * <code>3.141592653589793</code>. This is the ratio of a circle's diameter
+   * to its circumference.
+   */
+  public static final double PI = 3.141592653589793;
+
+  /**
+   * Take the absolute value of the argument.
+   * (Absolute value means make it positive.)
+   * <P>
+   *
+   * Note that the the largest negative value (Integer.MIN_VALUE) cannot
+   * be made positive.  In this case, because of the rules of negation in
+   * a computer, MIN_VALUE is what will be returned.
+   * This is a <em>negative</em> value.  You have been warned.
+   *
+   * @param i the number to take the absolute value of
+   * @return the absolute value
+   * @see Integer#MIN_VALUE
+   */
+  public static int abs(int i)
+  {
+    return (i < 0) ? -i : i;
+  }
+
+  /**
+   * Take the absolute value of the argument.
+   * (Absolute value means make it positive.)
+   * <P>
+   *
+   * Note that the the largest negative value (Long.MIN_VALUE) cannot
+   * be made positive.  In this case, because of the rules of negation in
+   * a computer, MIN_VALUE is what will be returned.
+   * This is a <em>negative</em> value.  You have been warned.
+   *
+   * @param l the number to take the absolute value of
+   * @return the absolute value
+   * @see Long#MIN_VALUE
+   */
+  public static long abs(long l)
+  {
+    return (l < 0) ? -l : l;
+  }
+
+  /**
+   * Take the absolute value of the argument.
+   * (Absolute value means make it positive.)
+   * <P>
+   *
+   * This is equivalent, but faster than, calling
+   * <code>Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))</code>.
+   *
+   * @param f the number to take the absolute value of
+   * @return the absolute value
+   */
+  public static float abs(float f)
+  {
+    return (f <= 0) ? 0 - f : f;
+  }
+
+  /**
+   * Take the absolute value of the argument.
+   * (Absolute value means make it positive.)
+   *
+   * This is equivalent, but faster than, calling
+   * <code>Double.longBitsToDouble(Double.doubleToLongBits(a)
+   *       << 1) >>> 1);</code>.
+   *
+   * @param d the number to take the absolute value of
+   * @return the absolute value
+   */
+  public static double abs(double d)
+  {
+    return (d <= 0) ? 0 - d : d;
+  }
+
+  /**
+   * Return whichever argument is smaller.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the smaller of the two numbers
+   */
+  public static int min(int a, int b)
+  {
+    return (a < b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is smaller.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the smaller of the two numbers
+   */
+  public static long min(long a, long b)
+  {
+    return (a < b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is smaller. If either argument is NaN, the
+   * result is NaN, and when comparing 0 and -0, -0 is always smaller.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the smaller of the two numbers
+   */
+  public static float min(float a, float b)
+  {
+    // this check for NaN, from JLS 15.21.1, saves a method call
+    if (a != a)
+      return a;
+    // no need to check if b is NaN; < will work correctly
+    // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special
+    if (a == 0 && b == 0)
+      return -(-a - b);
+    return (a < b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is smaller. If either argument is NaN, the
+   * result is NaN, and when comparing 0 and -0, -0 is always smaller.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the smaller of the two numbers
+   */
+  public static double min(double a, double b)
+  {
+    // this check for NaN, from JLS 15.21.1, saves a method call
+    if (a != a)
+      return a;
+    // no need to check if b is NaN; < will work correctly
+    // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special
+    if (a == 0 && b == 0)
+      return -(-a - b);
+    return (a < b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is larger.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the larger of the two numbers
+   */
+  public static int max(int a, int b)
+  {
+    return (a > b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is larger.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the larger of the two numbers
+   */
+  public static long max(long a, long b)
+  {
+    return (a > b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is larger. If either argument is NaN, the
+   * result is NaN, and when comparing 0 and -0, 0 is always larger.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the larger of the two numbers
+   */
+  public static float max(float a, float b)
+  {
+    // this check for NaN, from JLS 15.21.1, saves a method call
+    if (a != a)
+      return a;
+    // no need to check if b is NaN; > will work correctly
+    // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special
+    if (a == 0 && b == 0)
+      return a - -b;
+    return (a > b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is larger. If either argument is NaN, the
+   * result is NaN, and when comparing 0 and -0, 0 is always larger.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the larger of the two numbers
+   */
+  public static double max(double a, double b)
+  {
+    // this check for NaN, from JLS 15.21.1, saves a method call
+    if (a != a)
+      return a;
+    // no need to check if b is NaN; > will work correctly
+    // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special
+    if (a == 0 && b == 0)
+      return a - -b;
+    return (a > b) ? a : b;
+  }
+
+  /**
+   * The trigonometric function <em>sin</em>. The sine of NaN or infinity is
+   * NaN, and the sine of 0 retains its sign. This is accurate within 1 ulp,
+   * and is semi-monotonic.
+   *
+   * @param a the angle (in radians)
+   * @return sin(a)
+   */
+  public static double sin(double a)
+  {
+    return VMMath.sin(a);
+  }
+
+  /**
+   * The trigonometric function <em>cos</em>. The cosine of NaN or infinity is
+   * NaN. This is accurate within 1 ulp, and is semi-monotonic.
+   *
+   * @param a the angle (in radians)
+   * @return cos(a)
+   */
+  public static double cos(double a)
+  {
+    return VMMath.cos(a);
+  }
+
+  /**
+   * The trigonometric function <em>tan</em>. The tangent of NaN or infinity
+   * is NaN, and the tangent of 0 retains its sign. This is accurate within 1
+   * ulp, and is semi-monotonic.
+   *
+   * @param a the angle (in radians)
+   * @return tan(a)
+   */
+  public static double tan(double a)
+  {
+    return VMMath.tan(a);
+  }
+
+  /**
+   * The trigonometric function <em>arcsin</em>. The range of angles returned
+   * is -pi/2 to pi/2 radians (-90 to 90 degrees). If the argument is NaN or
+   * its absolute value is beyond 1, the result is NaN; and the arcsine of
+   * 0 retains its sign. This is accurate within 1 ulp, and is semi-monotonic.
+   *
+   * @param a the sin to turn back into an angle
+   * @return arcsin(a)
+   */
+  public static double asin(double a)
+  {
+    return VMMath.asin(a);
+  }
+
+  /**
+   * The trigonometric function <em>arccos</em>. The range of angles returned
+   * is 0 to pi radians (0 to 180 degrees). If the argument is NaN or
+   * its absolute value is beyond 1, the result is NaN. This is accurate
+   * within 1 ulp, and is semi-monotonic.
+   *
+   * @param a the cos to turn back into an angle
+   * @return arccos(a)
+   */
+  public static double acos(double a)
+  {
+    return VMMath.acos(a);
+  }
+
+  /**
+   * The trigonometric function <em>arcsin</em>. The range of angles returned
+   * is -pi/2 to pi/2 radians (-90 to 90 degrees). If the argument is NaN, the
+   * result is NaN; and the arctangent of 0 retains its sign. This is accurate
+   * within 1 ulp, and is semi-monotonic.
+   *
+   * @param a the tan to turn back into an angle
+   * @return arcsin(a)
+   * @see #atan2(double, double)
+   */
+  public static double atan(double a)
+  {
+    return VMMath.atan(a);
+  }
+
+  /**
+   * A special version of the trigonometric function <em>arctan</em>, for
+   * converting rectangular coordinates <em>(x, y)</em> to polar
+   * <em>(r, theta)</em>. This computes the arctangent of x/y in the range
+   * of -pi to pi radians (-180 to 180 degrees). Special cases:<ul>
+   * <li>If either argument is NaN, the result is NaN.</li>
+   * <li>If the first argument is positive zero and the second argument is
+   * positive, or the first argument is positive and finite and the second
+   * argument is positive infinity, then the result is positive zero.</li>
+   * <li>If the first argument is negative zero and the second argument is
+   * positive, or the first argument is negative and finite and the second
+   * argument is positive infinity, then the result is negative zero.</li>
+   * <li>If the first argument is positive zero and the second argument is
+   * negative, or the first argument is positive and finite and the second
+   * argument is negative infinity, then the result is the double value
+   * closest to pi.</li>
+   * <li>If the first argument is negative zero and the second argument is
+   * negative, or the first argument is negative and finite and the second
+   * argument is negative infinity, then the result is the double value
+   * closest to -pi.</li>
+   * <li>If the first argument is positive and the second argument is
+   * positive zero or negative zero, or the first argument is positive
+   * infinity and the second argument is finite, then the result is the
+   * double value closest to pi/2.</li>
+   * <li>If the first argument is negative and the second argument is
+   * positive zero or negative zero, or the first argument is negative
+   * infinity and the second argument is finite, then the result is the
+   * double value closest to -pi/2.</li>
+   * <li>If both arguments are positive infinity, then the result is the
+   * double value closest to pi/4.</li>
+   * <li>If the first argument is positive infinity and the second argument
+   * is negative infinity, then the result is the double value closest to
+   * 3*pi/4.</li>
+   * <li>If the first argument is negative infinity and the second argument
+   * is positive infinity, then the result is the double value closest to
+   * -pi/4.</li>
+   * <li>If both arguments are negative infinity, then the result is the
+   * double value closest to -3*pi/4.</li>
+   *
+   * </ul><p>This is accurate within 2 ulps, and is semi-monotonic. To get r,
+   * use sqrt(x*x+y*y).
+   *
+   * @param y the y position
+   * @param x the x position
+   * @return <em>theta</em> in the conversion of (x, y) to (r, theta)
+   * @see #atan(double)
+   */
+  public static double atan2(double y, double x)
+  {
+    return VMMath.atan2(y,x);
+  }
+
+  /**
+   * Take <em>e</em><sup>a</sup>.  The opposite of <code>log()</code>. If the
+   * argument is NaN, the result is NaN; if the argument is positive infinity,
+   * the result is positive infinity; and if the argument is negative
+   * infinity, the result is positive zero. This is accurate within 1 ulp,
+   * and is semi-monotonic.
+   *
+   * @param a the number to raise to the power
+   * @return the number raised to the power of <em>e</em>
+   * @see #log(double)
+   * @see #pow(double, double)
+   */
+  public static double exp(double a)
+  {
+    return VMMath.exp(a);
+  }
+
+  /**
+   * Take ln(a) (the natural log).  The opposite of <code>exp()</code>. If the
+   * argument is NaN or negative, the result is NaN; if the argument is
+   * positive infinity, the result is positive infinity; and if the argument
+   * is either zero, the result is negative infinity. This is accurate within
+   * 1 ulp, and is semi-monotonic.
+   *
+   * <p>Note that the way to get log<sub>b</sub>(a) is to do this:
+   * <code>ln(a) / ln(b)</code>.
+   *
+   * @param a the number to take the natural log of
+   * @return the natural log of <code>a</code>
+   * @see #exp(double)
+   */
+  public static double log(double a)
+  {
+    return VMMath.log(a);
+  }
+
+  /**
+   * Take a square root. If the argument is NaN or negative, the result is
+   * NaN; if the argument is positive infinity, the result is positive
+   * infinity; and if the result is either zero, the result is the same.
+   * This is accurate within the limits of doubles.
+   *
+   * <p>For a cube root, use <code>cbrt</code>.  For other roots, use
+   * <code>pow(a, 1 / rootNumber)</code>.</p>
+   *
+   * @param a the numeric argument
+   * @return the square root of the argument
+   * @see #cbrt(double)
+   * @see #pow(double, double)
+   */
+  public static double sqrt(double a)
+  {
+    return VMMath.sqrt(a);
+  }
+
+  /**
+   * Raise a number to a power. Special cases:<ul>
+   * <li>If the second argument is positive or negative zero, then the result
+   * is 1.0.</li>
+   * <li>If the second argument is 1.0, then the result is the same as the
+   * first argument.</li>
+   * <li>If the second argument is NaN, then the result is NaN.</li>
+   * <li>If the first argument is NaN and the second argument is nonzero,
+   * then the result is NaN.</li>
+   * <li>If the absolute value of the first argument is greater than 1 and
+   * the second argument is positive infinity, or the absolute value of the
+   * first argument is less than 1 and the second argument is negative
+   * infinity, then the result is positive infinity.</li>
+   * <li>If the absolute value of the first argument is greater than 1 and
+   * the second argument is negative infinity, or the absolute value of the
+   * first argument is less than 1 and the second argument is positive
+   * infinity, then the result is positive zero.</li>
+   * <li>If the absolute value of the first argument equals 1 and the second
+   * argument is infinite, then the result is NaN.</li>
+   * <li>If the first argument is positive zero and the second argument is
+   * greater than zero, or the first argument is positive infinity and the
+   * second argument is less than zero, then the result is positive zero.</li>
+   * <li>If the first argument is positive zero and the second argument is
+   * less than zero, or the first argument is positive infinity and the
+   * second argument is greater than zero, then the result is positive
+   * infinity.</li>
+   * <li>If the first argument is negative zero and the second argument is
+   * greater than zero but not a finite odd integer, or the first argument is
+   * negative infinity and the second argument is less than zero but not a
+   * finite odd integer, then the result is positive zero.</li>
+   * <li>If the first argument is negative zero and the second argument is a
+   * positive finite odd integer, or the first argument is negative infinity
+   * and the second argument is a negative finite odd integer, then the result
+   * is negative zero.</li>
+   * <li>If the first argument is negative zero and the second argument is
+   * less than zero but not a finite odd integer, or the first argument is
+   * negative infinity and the second argument is greater than zero but not a
+   * finite odd integer, then the result is positive infinity.</li>
+   * <li>If the first argument is negative zero and the second argument is a
+   * negative finite odd integer, or the first argument is negative infinity
+   * and the second argument is a positive finite odd integer, then the result
+   * is negative infinity.</li>
+   * <li>If the first argument is less than zero and the second argument is a
+   * finite even integer, then the result is equal to the result of raising
+   * the absolute value of the first argument to the power of the second
+   * argument.</li>
+   * <li>If the first argument is less than zero and the second argument is a
+   * finite odd integer, then the result is equal to the negative of the
+   * result of raising the absolute value of the first argument to the power
+   * of the second argument.</li>
+   * <li>If the first argument is finite and less than zero and the second
+   * argument is finite and not an integer, then the result is NaN.</li>
+   * <li>If both arguments are integers, then the result is exactly equal to
+   * the mathematical result of raising the first argument to the power of
+   * the second argument if that result can in fact be represented exactly as
+   * a double value.</li>
+   *
+   * </ul><p>(In the foregoing descriptions, a floating-point value is
+   * considered to be an integer if and only if it is a fixed point of the
+   * method {@link #ceil(double)} or, equivalently, a fixed point of the
+   * method {@link #floor(double)}. A value is a fixed point of a one-argument
+   * method if and only if the result of applying the method to the value is
+   * equal to the value.) This is accurate within 1 ulp, and is semi-monotonic.
+   *
+   * @param a the number to raise
+   * @param b the power to raise it to
+   * @return a<sup>b</sup>
+   */
+  public static double pow(double a, double b)
+  {
+    return VMMath.pow(a,b);
+  }
+
+  /**
+   * Get the IEEE 754 floating point remainder on two numbers. This is the
+   * value of <code>x - y * <em>n</em></code>, where <em>n</em> is the closest
+   * double to <code>x / y</code> (ties go to the even n); for a zero
+   * remainder, the sign is that of <code>x</code>. If either argument is NaN,
+   * the first argument is infinite, or the second argument is zero, the result
+   * is NaN; if x is finite but y is infinite, the result is x. This is
+   * accurate within the limits of doubles.
+   *
+   * @param x the dividend (the top half)
+   * @param y the divisor (the bottom half)
+   * @return the IEEE 754-defined floating point remainder of x/y
+   * @see #rint(double)
+   */
+  public static double IEEEremainder(double x, double y)
+  {
+    return VMMath.IEEEremainder(x,y);
+  }
+
+  /**
+   * Take the nearest integer that is that is greater than or equal to the
+   * argument. If the argument is NaN, infinite, or zero, the result is the
+   * same; if the argument is between -1 and 0, the result is negative zero.
+   * Note that <code>Math.ceil(x) == -Math.floor(-x)</code>.
+   *
+   * @param a the value to act upon
+   * @return the nearest integer >= <code>a</code>
+   */
+  public static double ceil(double a)
+  {
+    return VMMath.ceil(a);
+  }
+
+  /**
+   * Take the nearest integer that is that is less than or equal to the
+   * argument. If the argument is NaN, infinite, or zero, the result is the
+   * same. Note that <code>Math.ceil(x) == -Math.floor(-x)</code>.
+   *
+   * @param a the value to act upon
+   * @return the nearest integer <= <code>a</code>
+   */
+  public static double floor(double a)
+  {
+    return VMMath.floor(a);
+  }
+
+  /**
+   * Take the nearest integer to the argument.  If it is exactly between
+   * two integers, the even integer is taken. If the argument is NaN,
+   * infinite, or zero, the result is the same.
+   *
+   * @param a the value to act upon
+   * @return the nearest integer to <code>a</code>
+   */
+  public static double rint(double a)
+  {
+    return VMMath.rint(a);
+  }
+
+  /**
+   * Take the nearest integer to the argument.  This is equivalent to
+   * <code>(int) Math.floor(a + 0.5f)</code>. If the argument is NaN, the result
+   * is 0; otherwise if the argument is outside the range of int, the result
+   * will be Integer.MIN_VALUE or Integer.MAX_VALUE, as appropriate.
+   *
+   * @param a the argument to round
+   * @return the nearest integer to the argument
+   * @see Integer#MIN_VALUE
+   * @see Integer#MAX_VALUE
+   */
+  public static int round(float a)
+  {
+    // this check for NaN, from JLS 15.21.1, saves a method call
+    if (a != a)
+      return 0;
+    return (int) floor(a + 0.5f);
+  }
+
+  /**
+   * Take the nearest long to the argument.  This is equivalent to
+   * <code>(long) Math.floor(a + 0.5)</code>. If the argument is NaN, the
+   * result is 0; otherwise if the argument is outside the range of long, the
+   * result will be Long.MIN_VALUE or Long.MAX_VALUE, as appropriate.
+   *
+   * @param a the argument to round
+   * @return the nearest long to the argument
+   * @see Long#MIN_VALUE
+   * @see Long#MAX_VALUE
+   */
+  public static long round(double a)
+  {
+    // this check for NaN, from JLS 15.21.1, saves a method call
+    if (a != a)
+      return 0;
+    return (long) floor(a + 0.5d);
+  }
+
+  /**
+   * Get a random number.  This behaves like Random.nextDouble(), seeded by
+   * System.currentTimeMillis() when first called. In other words, the number
+   * is from a pseudorandom sequence, and lies in the range [+0.0, 1.0).
+   * This random sequence is only used by this method, and is threadsafe,
+   * although you may want your own random number generator if it is shared
+   * among threads.
+   *
+   * @return a random number
+   * @see Random#nextDouble()
+   * @see System#currentTimeMillis()
+   */
+  public static synchronized double random()
+  {
+    if (rand == null)
+      rand = new Random();
+    return rand.nextDouble();
+  }
+
+  /**
+   * Convert from degrees to radians. The formula for this is
+   * radians = degrees * (pi/180); however it is not always exact given the
+   * limitations of floating point numbers.
+   *
+   * @param degrees an angle in degrees
+   * @return the angle in radians
+   * @since 1.2
+   */
+  public static double toRadians(double degrees)
+  {
+    return (degrees * PI) / 180;
+  }
+
+  /**
+   * Convert from radians to degrees. The formula for this is
+   * degrees = radians * (180/pi); however it is not always exact given the
+   * limitations of floating point numbers.
+   *
+   * @param rads an angle in radians
+   * @return the angle in degrees
+   * @since 1.2
+   */
+  public static double toDegrees(double rads)
+  {
+    return (rads * 180) / PI;
+  }
+
+  /**
+   * <p>
+   * Take a cube root. If the argument is <code>NaN</code>, an infinity or
+   * zero, then the original value is returned.  The returned result is
+   * within 1 ulp of the exact result.  For a finite value, <code>x</code>,
+   * the cube root of <code>-x</code> is equal to the negation of the cube root
+   * of <code>x</code>. 
+   * </p>
+   * <p>
+   * For a square root, use <code>sqrt</code>.  For other roots, use
+   * <code>pow(a, 1 / rootNumber)</code>.
+   * </p>
+   *
+   * @param a the numeric argument
+   * @return the cube root of the argument
+   * @see #sqrt(double)
+   * @see #pow(double, double)
+   * @since 1.5
+   */
+  public static double cbrt(double a)
+  {
+    return VMMath.cbrt(a);
+  }
+
+  /**
+   * <p>
+   * Returns the hyperbolic cosine of the given value.  For a value,
+   * <code>x</code>, the hyperbolic cosine is <code>(e<sup>x</sup> + 
+   * e<sup>-x</sup>)/2</code>
+   * with <code>e</code> being <a href="#E">Euler's number</a>.  The returned
+   * result is within 2.5 ulps of the exact result.
+   * </p>
+   * <p>
+   * If the supplied value is <code>NaN</code>, then the original value is
+   * returned.  For either infinity, positive infinity is returned.
+   * The hyperbolic cosine of zero is 1.0.
+   * </p>
+   * 
+   * @param a the numeric argument
+   * @return the hyperbolic cosine of <code>a</code>.
+   * @since 1.5
+   */
+  public static double cosh(double a)
+  {
+    return VMMath.cosh(a);
+  }
+
+  /**
+   * <p>
+   * Returns <code>e<sup>a</sup> - 1.  For values close to 0, the
+   * result of <code>expm1(a) + 1</code> tend to be much closer to the
+   * exact result than simply <code>exp(x)</code>.  The result is within
+   * 1 ulp of the exact result, and results are semi-monotonic.  For finite
+   * inputs, the returned value is greater than or equal to -1.0.  Once
+   * a result enters within half a ulp of this limit, the limit is returned.
+   * </p>   
+   * <p>
+   * For <code>NaN</code>, positive infinity and zero, the original value
+   * is returned.  Negative infinity returns a result of -1.0 (the limit).
+   * </p>
+   * 
+   * @param a the numeric argument
+   * @return <code>e<sup>a</sup> - 1</code>
+   * @since 1.5
+   */
+  public static double expm1(double a)
+  {
+    return VMMath.expm1(a);
+  }
+
+  /**
+   * <p>
+   * Returns the hypotenuse, <code>a<sup>2</sup> + b<sup>2</sup></code>,
+   * without intermediate overflow or underflow.  The returned result is
+   * within 1 ulp of the exact result.  If one parameter is held constant,
+   * then the result in the other parameter is semi-monotonic.
+   * </p>
+   * <p>
+   * If either of the arguments is an infinity, then the returned result
+   * is positive infinity.  Otherwise, if either argument is <code>NaN</code>,
+   * then <code>NaN</code> is returned.
+   * </p>
+   * 
+   * @param a the first parameter.
+   * @param b the second parameter.
+   * @return the hypotenuse matching the supplied parameters.
+   * @since 1.5
+   */
+  public static double hypot(double a, double b)
+  {
+    return VMMath.hypot(a,b);
+  }
+
+  /**
+   * <p>
+   * Returns the base 10 logarithm of the supplied value.  The returned
+   * result is within 1 ulp of the exact result, and the results are
+   * semi-monotonic.
+   * </p>
+   * <p>
+   * Arguments of either <code>NaN</code> or less than zero return
+   * <code>NaN</code>.  An argument of positive infinity returns positive
+   * infinity.  Negative infinity is returned if either positive or negative
+   * zero is supplied.  Where the argument is the result of
+   * <code>10<sup>n</sup</code>, then <code>n</code> is returned.
+   * </p>
+   *
+   * @param a the numeric argument.
+   * @return the base 10 logarithm of <code>a</code>.
+   * @since 1.5
+   */
+  public static double log10(double a)
+  {
+    return VMMath.log10(a);
+  }
+
+  /**
+   * <p>
+   * Returns the natural logarithm resulting from the sum of the argument,
+   * <code>a</code> and 1.  For values close to 0, the
+   * result of <code>log1p(a)</code> tend to be much closer to the
+   * exact result than simply <code>log(1.0+a)</code>.  The returned
+   * result is within 1 ulp of the exact result, and the results are
+   * semi-monotonic.
+   * </p>
+   * <p>
+   * Arguments of either <code>NaN</code> or less than -1 return
+   * <code>NaN</code>.  An argument of positive infinity or zero
+   * returns the original argument.  Negative infinity is returned from an
+   * argument of -1.
+   * </p>
+   *
+   * @param a the numeric argument.
+   * @return the natural logarithm of <code>a</code> + 1.
+   * @since 1.5
+   */
+  public static double log1p(double a)
+  {
+    return VMMath.log1p(a);
+  }
+
+  /**
+   * <p>
+   * Returns the sign of the argument as follows:
+   * </p>
+   * <ul>
+   * <li>If <code>a</code> is greater than zero, the result is 1.0.</li>
+   * <li>If <code>a</code> is less than zero, the result is -1.0.</li>
+   * <li>If <code>a</code> is <code>NaN</code>, the result is <code>NaN</code>.
+   * <li>If <code>a</code> is positive or negative zero, the result is the
+   * same.</li>
+   * </ul>
+   * 
+   * @param a the numeric argument.
+   * @return the sign of the argument.
+   * @since 1.5.
+   */
+  public static double signum(double a)
+  {
+    if (Double.isNaN(a))
+      return Double.NaN;
+    if (a > 0)
+      return 1.0;
+    if (a < 0)
+      return -1.0;
+    return a;
+  }
+
+  /**
+   * <p>
+   * Returns the sign of the argument as follows:
+   * </p>
+   * <ul>
+   * <li>If <code>a</code> is greater than zero, the result is 1.0f.</li>
+   * <li>If <code>a</code> is less than zero, the result is -1.0f.</li>
+   * <li>If <code>a</code> is <code>NaN</code>, the result is <code>NaN</code>.
+   * <li>If <code>a</code> is positive or negative zero, the result is the
+   * same.</li>
+   * </ul>
+   * 
+   * @param a the numeric argument.
+   * @return the sign of the argument.
+   * @since 1.5.
+   */
+  public static float signum(float a)
+  {
+    if (Float.isNaN(a))
+      return Float.NaN;
+    if (a > 0)
+      return 1.0f;
+    if (a < 0)
+      return -1.0f;
+    return a;
+  }
+
+  /**
+   * <p>
+   * Returns the hyperbolic sine of the given value.  For a value,
+   * <code>x</code>, the hyperbolic sine is <code>(e<sup>x</sup> - 
+   * e<sup>-x</sup>)/2</code>
+   * with <code>e</code> being <a href="#E">Euler's number</a>.  The returned
+   * result is within 2.5 ulps of the exact result.
+   * </p>
+   * <p>
+   * If the supplied value is <code>NaN</code>, an infinity or a zero, then the
+   * original value is returned.
+   * </p>
+   * 
+   * @param a the numeric argument
+   * @return the hyperbolic sine of <code>a</code>.
+   * @since 1.5
+   */
+  public static double sinh(double a)
+  {
+    return VMMath.sinh(a);
+  }
+
+  /**
+   * <p>
+   * Returns the hyperbolic tangent of the given value.  For a value,
+   * <code>x</code>, the hyperbolic tangent is <code>(e<sup>x</sup> - 
+   * e<sup>-x</sup>)/(e<sup>x</sup> + e<sup>-x</sup>)</code>
+   * (i.e. <code>sinh(a)/cosh(a)</code>)
+   * with <code>e</code> being <a href="#E">Euler's number</a>.  The returned
+   * result is within 2.5 ulps of the exact result.  The absolute value
+   * of the exact result is always less than 1.  Computed results are thus
+   * less than or equal to 1 for finite arguments, with results within
+   * half a ulp of either positive or negative 1 returning the appropriate
+   * limit value (i.e. as if the argument was an infinity).
+   * </p>
+   * <p>
+   * If the supplied value is <code>NaN</code> or zero, then the original
+   * value is returned.  Positive infinity returns +1.0 and negative infinity
+   * returns -1.0.
+   * </p>
+   * 
+   * @param a the numeric argument
+   * @return the hyperbolic tangent of <code>a</code>.
+   * @since 1.5
+   */
+  public static double tanh(double a)
+  {
+    return VMMath.tanh(a);
+  }
+
+  /**
+   * Return the ulp for the given double argument.  The ulp is the
+   * difference between the argument and the next larger double.  Note
+   * that the sign of the double argument is ignored, that is,
+   * ulp(x) == ulp(-x).  If the argument is a NaN, then NaN is returned.
+   * If the argument is an infinity, then +Inf is returned.  If the
+   * argument is zero (either positive or negative), then
+   * {@link Double#MIN_VALUE} is returned.
+   * @param d the double whose ulp should be returned
+   * @return the difference between the argument and the next larger double
+   * @since 1.5
+   */
+  public static double ulp(double d)
+  {
+    if (Double.isNaN(d))
+      return d;
+    if (Double.isInfinite(d))
+      return Double.POSITIVE_INFINITY;
+    // This handles both +0.0 and -0.0.
+    if (d == 0.0)
+      return Double.MIN_VALUE;
+    long bits = Double.doubleToLongBits(d);
+    final int mantissaBits = 52;
+    final int exponentBits = 11;
+    final long mantMask = (1L << mantissaBits) - 1;
+    long mantissa = bits & mantMask;
+    final long expMask = (1L << exponentBits) - 1;
+    long exponent = (bits >>> mantissaBits) & expMask;
+
+    // Denormal number, so the answer is easy.
+    if (exponent == 0)
+      {
+        long result = (exponent << mantissaBits) | 1L;
+        return Double.longBitsToDouble(result);
+      }
+
+    // Conceptually we want to have '1' as the mantissa.  Then we would
+    // shift the mantissa over to make a normal number.  If this underflows
+    // the exponent, we will make a denormal result.
+    long newExponent = exponent - mantissaBits;
+    long newMantissa;
+    if (newExponent > 0)
+      newMantissa = 0;
+    else
+      {
+        newMantissa = 1L << -(newExponent - 1);
+        newExponent = 0;
+      }
+    return Double.longBitsToDouble((newExponent << mantissaBits) | newMantissa);
+  }
+
+  /**
+   * Return the ulp for the given float argument.  The ulp is the
+   * difference between the argument and the next larger float.  Note
+   * that the sign of the float argument is ignored, that is,
+   * ulp(x) == ulp(-x).  If the argument is a NaN, then NaN is returned.
+   * If the argument is an infinity, then +Inf is returned.  If the
+   * argument is zero (either positive or negative), then
+   * {@link Float#MIN_VALUE} is returned.
+   * @param f the float whose ulp should be returned
+   * @return the difference between the argument and the next larger float
+   * @since 1.5
+   */
+  public static float ulp(float f)
+  {
+    if (Float.isNaN(f))
+      return f;
+    if (Float.isInfinite(f))
+      return Float.POSITIVE_INFINITY;
+    // This handles both +0.0 and -0.0.
+    if (f == 0.0)
+      return Float.MIN_VALUE;
+    int bits = Float.floatToIntBits(f);
+    final int mantissaBits = 23;
+    final int exponentBits = 8;
+    final int mantMask = (1 << mantissaBits) - 1;
+    int mantissa = bits & mantMask;
+    final int expMask = (1 << exponentBits) - 1;
+    int exponent = (bits >>> mantissaBits) & expMask;
+
+    // Denormal number, so the answer is easy.
+    if (exponent == 0)
+      {
+        int result = (exponent << mantissaBits) | 1;
+        return Float.intBitsToFloat(result);
+      }
+
+    // Conceptually we want to have '1' as the mantissa.  Then we would
+    // shift the mantissa over to make a normal number.  If this underflows
+    // the exponent, we will make a denormal result.
+    int newExponent = exponent - mantissaBits;
+    int newMantissa;
+    if (newExponent > 0)
+      newMantissa = 0;
+    else
+      {
+        newMantissa = 1 << -(newExponent - 1);
+        newExponent = 0;
+      }
+    return Float.intBitsToFloat((newExponent << mantissaBits) | newMantissa);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NegativeArraySizeException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NegativeArraySizeException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,77 @@
+/* NegativeArraySizeException.java -- thrown on attempt to create array
+   with a negative size
+   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;
+
+/**
+ * Thrown when an attempt is made to create an array with a negative
+ * size. For example:<br>
+ * <pre>
+ * int i = -1;
+ * int[] array = new int[i];
+ * </pre>
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class NegativeArraySizeException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -8960118058596991861L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public NegativeArraySizeException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public NegativeArraySizeException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NoClassDefFoundError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NoClassDefFoundError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* NoClassDefFoundError.java -- thrown when a ClassLoader cannot find a class
+   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>NoClassDefFoundError</code> is thrown when a classloader or the
+ * Java Virtual Machine tries to load a class and no definition of the class
+ * can be found.  This could happen when using the <code>new</code> expression
+ * or during a normal method call.  The reason this would occur at runtime is
+ * because the missing class definition existed when the currently executing 
+ * class was compiled, but now that definition cannot be found.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public class NoClassDefFoundError extends LinkageError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 9095859863287012458L;
+
+  /**
+   * Create an error without a message.
+   */
+  public NoClassDefFoundError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public NoClassDefFoundError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NoSuchFieldError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NoSuchFieldError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* NoSuchFieldError.java -- thrown when the linker does not find a field
+   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>NoSuchFieldError</code> is thrown if an application attempts
+ * to access a field of a class, and that class no longer has that field.
+ * This is normally detected by the compiler, so it signals that you are
+ * using binary incompatible class versions.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public class NoSuchFieldError extends IncompatibleClassChangeError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -3456430195886129035L;
+
+  /**
+   * Create an error without a message.
+   */
+  public NoSuchFieldError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public NoSuchFieldError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NoSuchFieldException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NoSuchFieldException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* NoSuchFieldException.java -- thrown when reflecting a non-existant field
+   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;
+
+/**
+ * Thrown to indicate the class does not have the specified field. This is
+ * caused by a variety of reflection methods, when looking up a field by name.
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class NoSuchFieldException extends Exception
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = -6143714805279938260L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public NoSuchFieldException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public NoSuchFieldException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NoSuchMethodError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NoSuchMethodError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* NoSuchMethodError.java -- thrown when the linker does not find a method
+   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>NoSuchMethodError</code> is thrown if an application attempts
+ * to access a method of a class, and that class no longer has that method.
+ * This is normally detected by the compiler, so it signals that you are
+ * using binary incompatible class versions.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public class NoSuchMethodError extends IncompatibleClassChangeError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  static final long serialVersionUID = -3765521442372831335L;
+
+  /**
+   * Create an error without a message.
+   */
+  public NoSuchMethodError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public NoSuchMethodError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NoSuchMethodException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NoSuchMethodException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* NoSuchMethodException.java -- thrown when reflecting a non-existant method
+   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;
+
+/**
+ * Thrown to indicate the class does not have the specified method. This is
+ * caused by a variety of reflection methods, when looking up a method by name.
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class NoSuchMethodException extends Exception
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 5034388446362600923L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public NoSuchMethodException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public NoSuchMethodException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NullPointerException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NullPointerException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,82 @@
+/* NullPointerException.java -- thrown when using null instead of an object
+   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;
+
+/**
+ * Thrown when attempting to use <code>null</code> where an object
+ * is required. The Virtual Machine automatically throws this exception
+ * for the following:<br><ul>
+ * <li>Calling an instance method on a null object</li>
+ * <li>Accessing or modifying a field of a null object</li>
+ * <li>Taking the array length of a null array</li>
+ * <li>Accessing or modifying the slots of a null array</li>
+ * <li>Throwing a null Throwable</li>
+ * <li>Synchronizing on a null object</li>
+ * </ul>
+ * <p>Applications should also throw NullPointerExceptions whenever
+ * <code>null</code> is an inappropriate parameter to a method.
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class NullPointerException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 5162710183389028792L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public NullPointerException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public NullPointerException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Number.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Number.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,131 @@
+/* Number.java =- abstract superclass of numeric objects
+   Copyright (C) 1998, 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.io.Serializable;
+
+/**
+ * Number is a generic superclass of all the numeric classes, including
+ * the wrapper classes {@link Byte}, {@link Short}, {@link Integer},
+ * {@link Long}, {@link Float}, and {@link Double}.  Also worth mentioning
+ * are the classes in {@link java.math}.
+ *
+ * It provides ways to convert numeric objects to any primitive.
+ *
+ * @author Paul Fisher
+ * @author John Keiser
+ * @author Warren Levy
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public abstract class Number implements Serializable
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = -8742448824652078965L;
+
+  /**
+   * Table for calculating digits, used in Character, Long, and Integer.
+   */
+  static final char[] digits = {
+    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
+    'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
+    'u', 'v', 'w', 'x', 'y', 'z',
+  };
+
+  /**
+   * The basic constructor (often called implicitly).
+   */
+  public Number()
+  {
+  }
+
+  /**
+   * Return the value of this <code>Number</code> as an <code>int</code>.
+   *
+   * @return the int value
+   */
+  public abstract int intValue();
+
+  /**
+   * Return the value of this <code>Number</code> as a <code>long</code>.
+   *
+   * @return the long value
+   */
+  public abstract long longValue();
+
+  /**
+   * Return the value of this <code>Number</code> as a <code>float</code>.
+   *
+   * @return the float value
+   */
+  public abstract float floatValue();
+
+  /**
+   * Return the value of this <code>Number</code> as a <code>float</code>.
+   *
+   * @return the double value
+   */
+  public abstract double doubleValue();
+
+  /**
+   * Return the value of this <code>Number</code> as a <code>byte</code>.
+   *
+   * @return the byte value
+   * @since 1.1
+   */
+  public byte byteValue()
+  {
+    return (byte) intValue();
+  }
+
+  /**
+   * Return the value of this <code>Number</code> as a <code>short</code>.
+   *
+   * @return the short value
+   * @since 1.1
+   */
+  public short shortValue()
+  {
+    return (short) intValue();
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NumberFormatException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/NumberFormatException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* NumberFormatException.java -- thrown when parsing a bad string as a number
+   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;
+
+/**
+ * Can be thrown when attempting to convert a <code>String</code> to
+ * one of the numeric types, but the operation fails because the string
+ * has the wrong format.
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @status updated to 1.4
+ */
+public class NumberFormatException extends IllegalArgumentException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -2848938806368998894L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public NumberFormatException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public NumberFormatException(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Object.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Object.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,530 @@
+/* java.lang.Object - The universal superclass in Java
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang;
+
+
+/**
+ * Object is the ultimate superclass of every class
+ * (excepting interfaces).  When you define a class that
+ * does not extend any other class, it implicitly extends
+ * java.lang.Object.  Also, an anonymous class based on
+ * an interface will extend Object.
+ *
+ * <p>It provides general-purpose methods that every single
+ * Object, regardless of race, sex or creed, implements.
+ * All of the public methods may be invoked on arrays or
+ * interfaces.  The protected methods <code>clone</code>
+ * and <code>finalize</code> are not accessible on arrays
+ * or interfaces, but all array types have a public version
+ * of <code>clone</code> which is accessible.
+ *
+ * @author John Keiser
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @author Tom Tromey (tromey at cygnus.com)
+ */
+public class Object
+{
+  // WARNING: Object is a CORE class in the bootstrap cycle. See the comments
+  // in vm/reference/java/lang/Runtime for implications of this fact.
+
+  // Many JVMs do not allow for static initializers in this class,
+  // hence we do not use them in the default implementation.
+
+  // Some VM's rely on the order that these methods appear when laying
+  // out their internal structure.  Therefore, do not haphazardly
+  // rearrange these methods.
+
+  /**
+   * The basic constructor.  Object is special, because it has no
+   * superclass, so there is no call to super().
+   *
+   * @throws OutOfMemoryError Technically, this constructor never
+   *         throws an OutOfMemoryError, because the memory has
+   *         already been allocated by this point.  But as all
+   *         instance creation expressions eventually trace back
+   *         to this constructor, and creating an object allocates
+   *         memory, we list that possibility here.
+   */
+  // This could be implicit, but then javadoc would not document it!
+  public Object() {}
+
+  /**
+   * Determine whether this Object is semantically equal
+   * to another Object.
+   *
+   * <p>There are some fairly strict requirements on this
+   * method which subclasses must follow:<br>
+   * <ul>
+   * <li>It must be transitive.  If <code>a.equals(b)</code> and
+   *     <code>b.equals(c)</code>, then <code>a.equals(c)</code>
+   *     must be true as well.</li>
+   * <li>It must be symmetric.  <code>a.equals(b)</code> and
+   *     <code>b.equals(a)</code> must have the same value.</li>
+   * <li>It must be reflexive.  <code>a.equals(a)</code> must
+   *     always be true.</li>
+   * <li>It must be consistent.  Whichever value a.equals(b)
+   *     returns on the first invocation must be the value
+   *     returned on all later invocations.</li>
+   * <li><code>a.equals(null)</code> must be false.</li>
+   * <li>It must be consistent with hashCode().  That is,
+   *     <code>a.equals(b)</code> must imply
+   *     <code>a.hashCode() == b.hashCode()</code>.
+   *     The reverse is not true; two objects that are not
+   *     equal may have the same hashcode, but that has
+   *     the potential to harm hashing performance.</li>
+   * </ul>
+   *
+   * <p>This is typically overridden to throw a {@link ClassCastException}
+   * if the argument is not comparable to the class performing
+   * the comparison, but that is not a requirement.  It is legal
+   * for <code>a.equals(b)</code> to be true even though
+   * <code>a.getClass() != b.getClass()</code>.  Also, it
+   * is typical to never cause a {@link NullPointerException}.
+   *
+   * <p>In general, the Collections API ({@link java.util}) use the
+   * <code>equals</code> method rather than the <code>==</code>
+   * operator to compare objects.  However, {@link java.util.IdentityHashMap}
+   * is an exception to this rule, for its own good reasons.
+   *
+   * <p>The default implementation returns <code>this == o</code>.
+   *
+   * @param obj the Object to compare to
+   * @return whether this Object is semantically equal to another
+   * @see #hashCode()
+   */
+  public boolean equals(Object obj)
+  {
+    return this == obj;
+  }
+
+  /**
+   * Get a value that represents this Object, as uniquely as
+   * possible within the confines of an int.
+   *
+   * <p>There are some requirements on this method which
+   * subclasses must follow:<br>
+   *
+   * <ul>
+   * <li>Semantic equality implies identical hashcodes.  In other
+   *     words, if <code>a.equals(b)</code> is true, then
+   *     <code>a.hashCode() == b.hashCode()</code> must be as well.
+   *     However, the reverse is not necessarily true, and two
+   *     objects may have the same hashcode without being equal.</li>
+   * <li>It must be consistent.  Whichever value o.hashCode()
+   *     returns on the first invocation must be the value
+   *     returned on all later invocations as long as the object
+   *     exists.  Notice, however, that the result of hashCode may
+   *     change between separate executions of a Virtual Machine,
+   *     because it is not invoked on the same object.</li>
+   * </ul>
+   *
+   * <p>Notice that since <code>hashCode</code> is used in
+   * {@link java.util.Hashtable} and other hashing classes,
+   * a poor implementation will degrade the performance of hashing
+   * (so don't blindly implement it as returning a constant!). Also,
+   * if calculating the hash is time-consuming, a class may consider
+   * caching the results.
+   *
+   * <p>The default implementation returns
+   * <code>System.identityHashCode(this)</code>
+   *
+   * @return the hash code for this Object
+   * @see #equals(Object)
+   * @see System#identityHashCode(Object)
+   */
+  public int hashCode()
+  {
+    return System.identityHashCode(this);
+  }
+
+  /**
+   * Convert this Object to a human-readable String.
+   * There are no limits placed on how long this String
+   * should be or what it should contain.  We suggest you
+   * make it as intuitive as possible to be able to place
+   * it into {@link java.io.PrintStream#println() System.out.println()}
+   * and such.
+   *
+   * <p>It is typical, but not required, to ensure that this method
+   * never completes abruptly with a {@link RuntimeException}.
+   *
+   * <p>This method will be called when performing string
+   * concatenation with this object.  If the result is
+   * <code>null</code>, string concatenation will instead
+   * use <code>"null"</code>.
+   *
+   * <p>The default implementation returns
+   * <code>getClass().getName() + "@" +
+   *      Integer.toHexString(hashCode())</code>.
+   *
+   * @return the String representing this Object, which may be null
+   * @throws OutOfMemoryError The default implementation creates a new
+   *         String object, therefore it must allocate memory
+   * @see #getClass()
+   * @see #hashCode()
+   * @see Class#getName()
+   * @see Integer#toHexString(int)
+   */
+  public String toString()
+  {
+    return getClass().getName() + '@' + Integer.toHexString(hashCode());
+  }
+
+  /**
+   * Called on an object by the Virtual Machine at most once,
+   * at some point after the Object is determined unreachable
+   * but before it is destroyed. You would think that this
+   * means it eventually is called on every Object, but this is
+   * not necessarily the case.  If execution terminates
+   * abnormally, garbage collection does not always happen.
+   * Thus you cannot rely on this method to always work.
+   * For finer control over garbage collection, use references
+   * from the {@link java.lang.ref} package.
+   *
+   * <p>Virtual Machines are free to not call this method if
+   * they can determine that it does nothing important; for
+   * example, if your class extends Object and overrides
+   * finalize to do simply <code>super.finalize()</code>.
+   *
+   * <p>finalize() will be called by a {@link Thread} that has no
+   * locks on any Objects, and may be called concurrently.
+   * There are no guarantees on the order in which multiple
+   * objects are finalized.  This means that finalize() is
+   * usually unsuited for performing actions that must be
+   * thread-safe, and that your implementation must be
+   * use defensive programming if it is to always work.
+   *
+   * <p>If an Exception is thrown from finalize() during garbage
+   * collection, it will be patently ignored and the Object will
+   * still be destroyed.
+   *
+   * <p>It is allowed, although not typical, for user code to call
+   * finalize() directly.  User invocation does not affect whether
+   * automatic invocation will occur.  It is also permitted,
+   * although not recommended, for a finalize() method to "revive"
+   * an object by making it reachable from normal code again.
+   *
+   * <p>Unlike constructors, finalize() does not get called
+   * for an object's superclass unless the implementation
+   * specifically calls <code>super.finalize()</code>.
+   *
+   * <p>The default implementation does nothing.
+   *
+   * @throws Throwable permits a subclass to throw anything in an
+   *         overridden version; but the default throws nothing
+   * @see System#gc()
+   * @see System#runFinalizersOnExit(boolean)
+   * @see java.lang.ref
+   */
+  protected void finalize() throws Throwable
+  {
+  }
+
+  /**
+   * This method may be called to create a new copy of the
+   * Object.  The typical behavior is as follows:<br>
+   * <ul>
+   *  <li><code>o == o.clone()</code> is false</li>
+   *  <li><code>o.getClass() == o.clone().getClass()</code>
+   *      is true</li>
+   *  <li><code>o.equals(o)</code> is true</li>
+   * </ul>
+   *
+   * <p>However, these are not strict requirements, and may
+   * be violated if necessary.  Of the three requirements, the
+   * last is the most commonly violated, particularly if the
+   * subclass does not override {@link #equals(Object)}.
+   *
+   * <p>If the Object you call clone() on does not implement
+   * {@link Cloneable} (which is a placeholder interface), then
+   * a CloneNotSupportedException is thrown.  Notice that
+   * Object does not implement Cloneable; this method exists
+   * as a convenience for subclasses that do.
+   *
+   * <p>Object's implementation of clone allocates space for the
+   * new Object using the correct class, without calling any
+   * constructors, and then fills in all of the new field values
+   * with the old field values.  Thus, it is a shallow copy.
+   * However, subclasses are permitted to make a deep copy.
+   *
+   * <p>All array types implement Cloneable, and override
+   * this method as follows (it should never fail):<br>
+   * <pre>
+   * public Object clone()
+   * {
+   *   try
+   *     {
+   *       super.clone();
+   *     }
+   *   catch (CloneNotSupportedException e)
+   *     {
+   *       throw new InternalError(e.getMessage());
+   *     }
+   * }
+   * </pre>
+   *
+   * @return a copy of the Object
+   * @throws CloneNotSupportedException If this Object does not
+   *         implement Cloneable
+   * @throws OutOfMemoryError Since cloning involves memory allocation,
+   *         even though it may bypass constructors, you might run
+   *         out of memory
+   * @see Cloneable
+   */
+  protected Object clone() throws CloneNotSupportedException
+  {
+    if (this instanceof Cloneable)
+      return VMObject.clone((Cloneable) this);
+    throw new CloneNotSupportedException("Object not cloneable");
+  }
+
+  /**
+   * Returns the runtime {@link Class} of this Object.
+   *
+   * <p>The class object can also be obtained without a runtime
+   * instance by using the class literal, as in:
+   * <code>Foo.class</code>.  Notice that the class literal
+   * also works on primitive types, making it useful for
+   * reflection purposes.
+   *
+   * @return the class of this Object
+   */
+  public final Class getClass()
+  {
+    return VMObject.getClass(this);
+  }
+
+  /**
+   * Wakes up one of the {@link Thread}s that has called
+   * <code>wait</code> on this Object.  Only the owner
+   * of a lock on this Object may call this method.  This lock
+   * is obtained by a <code>synchronized</code> method or statement.
+   *
+   * <p>The Thread to wake up is chosen arbitrarily.  The
+   * awakened thread is not guaranteed to be the next thread
+   * to actually obtain the lock on this object.
+   *
+   * <p>This thread still holds a lock on the object, so it is
+   * typical to release the lock by exiting the synchronized
+   * code, calling wait(), or calling {@link Thread#sleep(long)}, so
+   * that the newly awakened thread can actually resume.  The
+   * awakened thread will most likely be awakened with an
+   * {@link InterruptedException}, but that is not guaranteed.
+   *
+   * @throws IllegalMonitorStateException if this Thread
+   *         does not own the lock on the Object
+   * @see #notifyAll()
+   * @see #wait()
+   * @see #wait(long)
+   * @see #wait(long, int)
+   * @see Thread
+   */
+  public final void notify() throws IllegalMonitorStateException
+  {
+    VMObject.notify(this);
+  }
+
+  /**
+   * Wakes up all of the {@link Thread}s that have called
+   * <code>wait</code> on this Object.  Only the owner
+   * of a lock on this Object may call this method.  This lock
+   * is obtained by a <code>synchronized</code> method or statement.
+   *
+   * <p>There are no guarantees as to which thread will next
+   * obtain the lock on the object.
+   *
+   * <p>This thread still holds a lock on the object, so it is
+   * typical to release the lock by exiting the synchronized
+   * code, calling wait(), or calling {@link Thread#sleep(long)}, so
+   * that one of the newly awakened threads can actually resume.
+   * The resuming thread will most likely be awakened with an
+   * {@link InterruptedException}, but that is not guaranteed.
+   *
+   * @throws IllegalMonitorStateException if this Thread
+   *         does not own the lock on the Object
+   * @see #notify()
+   * @see #wait()
+   * @see #wait(long)
+   * @see #wait(long, int)
+   * @see Thread
+   */
+  public final void notifyAll() throws IllegalMonitorStateException
+  {
+    VMObject.notifyAll(this);
+  }
+
+  /**
+   * Waits indefinitely for notify() or notifyAll() to be
+   * called on the Object in question.  Implementation is
+   * identical to wait(0).
+   *
+   * <p>The Thread that calls wait must have a lock on this Object,
+   * obtained by a <code>synchronized</code> method or statement.
+   * After calling wait, the thread loses the lock on this
+   * object until the method completes (abruptly or normally),
+   * at which time it regains the lock.  All locks held on
+   * other objects remain in force, even though the thread is
+   * inactive. Therefore, caution must be used to avoid deadlock.
+   *
+   * <p>While it is typical that this method will complete abruptly
+   * with an {@link InterruptedException}, it is not guaranteed.  So,
+   * it is typical to call wait inside an infinite loop:<br>
+   *
+   * <pre>
+   * try
+   *   {
+   *     while (true)
+   *       lock.wait();
+   *   }
+   * catch (InterruptedException e)
+   *   {
+   *   }
+   * </pre>
+   *
+   * @throws IllegalMonitorStateException if this Thread
+   *         does not own a lock on this Object
+   * @throws InterruptedException if some other Thread
+   *         interrupts this Thread
+   * @see #notify()
+   * @see #notifyAll()
+   * @see #wait(long)
+   * @see #wait(long, int)
+   * @see Thread
+   */
+  public final void wait()
+    throws IllegalMonitorStateException, InterruptedException
+  {
+    VMObject.wait(this, 0, 0);
+  }
+
+  /**
+   * Waits a specified amount of time (or indefinitely if
+   * the time specified is 0) for someone to call notify()
+   * or notifyAll() on this Object, waking up this Thread.
+   *
+   * <p>The Thread that calls wait must have a lock on this Object,
+   * obtained by a <code>synchronized</code> method or statement.
+   * After calling wait, the thread loses the lock on this
+   * object until the method completes (abruptly or normally),
+   * at which time it regains the lock.  All locks held on
+   * other objects remain in force, even though the thread is
+   * inactive. Therefore, caution must be used to avoid deadlock.
+   *
+   * <p>Usually, this call will complete normally if the time
+   * expires, or abruptly with {@link InterruptedException}
+   * if another thread called notify, but neither result
+   * is guaranteed.
+   *
+   * <p>The waiting period is only *roughly* the amount of time
+   * you requested.  It cannot be exact because of the overhead
+   * of the call itself.  Most Virtual Machiness treat the
+   * argument as a lower limit on the time spent waiting, but
+   * even that is not guaranteed.  Besides, some other thread
+   * may hold the lock on the object when the time expires, so
+   * the current thread may still have to wait to reobtain the
+   * lock.
+   *
+   * @param ms the minimum number of milliseconds to wait (1000
+   *        milliseconds = 1 second), or 0 for an indefinite wait
+   * @throws IllegalArgumentException if ms < 0
+   * @throws IllegalMonitorStateException if this Thread
+   *         does not own a lock on this Object
+   * @throws InterruptedException if some other Thread
+   *         interrupts this Thread
+   * @see #notify()
+   * @see #notifyAll()
+   * @see #wait()
+   * @see #wait(long, int)
+   * @see Thread
+   */
+  public final void wait(long ms)
+    throws IllegalMonitorStateException, InterruptedException
+  {
+    wait(ms, 0);
+  }
+
+  /**
+   * Waits a specified amount of time (or indefinitely if
+   * the time specified is 0) for someone to call notify()
+   * or notifyAll() on this Object, waking up this Thread.
+   *
+   * <p>The Thread that calls wait must have a lock on this Object,
+   * obtained by a <code>synchronized</code> method or statement.
+   * After calling wait, the thread loses the lock on this
+   * object until the method completes (abruptly or normally),
+   * at which time it regains the lock.  All locks held on
+   * other objects remain in force, even though the thread is
+   * inactive. Therefore, caution must be used to avoid deadlock.
+   *
+   * <p>Usually, this call will complete normally if the time
+   * expires, or abruptly with {@link InterruptedException}
+   * if another thread called notify, but neither result
+   * is guaranteed.
+   *
+   * <p>The waiting period is nowhere near as precise as
+   * nanoseconds; considering that even wait(int) is inaccurate,
+   * how much can you expect?  But on supporting
+   * implementations, this offers somewhat more granularity
+   * than milliseconds.
+   *
+   * @param ms the number of milliseconds to wait (1,000
+   *        milliseconds = 1 second)
+   * @param ns the number of nanoseconds to wait over and
+   *        above ms (1,000,000 nanoseconds = 1 millisecond)
+   * @throws IllegalArgumentException if ms < 0 or ns is not
+   *         in the range 0 to 999,999
+   * @throws IllegalMonitorStateException if this Thread
+   *         does not own a lock on this Object
+   * @throws InterruptedException if some other Thread
+   *         interrupts this Thread
+   * @see #notify()
+   * @see #notifyAll()
+   * @see #wait()
+   * @see #wait(long)
+   * @see Thread
+   */
+  public final void wait(long ms, int ns)
+    throws IllegalMonitorStateException, InterruptedException
+  {
+    if (ms < 0 || ns < 0 || ns > 999999)
+      throw new IllegalArgumentException("argument out of range");
+    VMObject.wait(this, ms, ns);
+  }
+} // class Object

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/OutOfMemoryError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/OutOfMemoryError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* OutOfMemoryError.java -- thrown when a memory allocation fails
+   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;
+
+/**
+ * Thrown when the Java Virtual Machine is unable to allocate an object
+ * because it is out of memory and no more memory could be made available
+ * by the garbage collector.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public class OutOfMemoryError extends VirtualMachineError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 8228564086184010517L;
+
+  /**
+   * Create an error without a message.
+   */
+  public OutOfMemoryError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public OutOfMemoryError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Package.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Package.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,416 @@
+/* Package.java -- information about a package
+   Copyright (C) 2000, 2001, 2002, 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.lang;
+
+import gnu.classpath.VMStackWalker;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.net.URL;
+import java.util.NoSuchElementException;
+import java.util.StringTokenizer;
+
+
+/**
+ * Everything you ever wanted to know about a package. This class makes it
+ * possible to attach specification and implementation information to a
+ * package as explained in the
+ * <a href="http://java.sun.com/products/jdk/1.3/docs/guide/versioning/spec/VersioningSpecification.html#PackageVersionSpecification">Package Versioning Specification</a>
+ * section of the
+ * <a href="http://java.sun.com/products/jdk/1.3/docs/guide/versioning/spec/VersioningSpecification.html">Product Versioning Specification</a>.
+ * It also allows packages to be sealed with respect to the originating URL.
+ *
+ * <p>The most useful method is the <code>isCompatibleWith()</code> method that
+ * compares a desired version of a specification with the version of the
+ * specification as implemented by a package. A package is considered
+ * compatible with another version if the version of the specification is
+ * equal or higher then the requested version. Version numbers are represented
+ * as strings of positive numbers separated by dots (e.g. "1.2.0").
+ * The first number is called the major number, the second the minor,
+ * the third the micro, etc. A version is considered higher then another
+ * version if it has a bigger major number then the another version or when
+ * the major numbers of the versions are equal if it has a bigger minor number
+ * then the other version, etc. (If a version has no minor, micro, etc numbers
+ * then they are considered the be 0.)
+ *
+ * @author Mark Wielaard (mark at klomp.org)
+ * @see ClassLoader#definePackage(String, String, String, String, String,
+ *      String, String, URL)
+ * @since 1.2
+ * @status updated to 1.5
+ */
+public class Package
+  implements AnnotatedElement
+{
+  /** The name of the Package */
+  private final String name;
+
+  /** The name if the implementation */
+  private final String implTitle;
+
+  /** The vendor that wrote this implementation */
+  private final String implVendor;
+
+  /** The version of this implementation */
+  private final String implVersion;
+
+  /** The name of the specification */
+  private final String specTitle;
+
+  /** The name of the specification designer */
+  private final String specVendor;
+
+  /** The version of this specification */
+  private final String specVersion;
+
+  /** If sealed the origin of the package classes, otherwise null */
+  private final URL sealed;
+
+  /** The class loader that defined this package */
+  private ClassLoader loader;
+
+  /** @deprecated Please use the other constructor that takes the class loader
+   *              that defines the Package.
+   */
+  Package(String name,
+	  String specTitle, String specVendor, String specVersion,
+	  String implTitle, String implVendor, String implVersion, URL sealed)
+  {
+    this(name, specTitle, specVendor, specVersion, implTitle, implVendor,
+         implVersion, sealed, null);
+  }
+
+  /**
+   * A package local constructor for the Package class. All parameters except
+   * the <code>name</code> of the package may be <code>null</code>.
+   * There are no public constructors defined for Package; this is a package
+   * local constructor that is used by java.lang.Classloader.definePackage().
+   * 
+   * @param name The name of the Package
+   * @param specTitle The name of the specification
+   * @param specVendor The name of the specification designer
+   * @param specVersion The version of this specification
+   * @param implTitle The name of the implementation
+   * @param implVendor The vendor that wrote this implementation
+   * @param implVersion The version of this implementation
+   * @param sealed If sealed the origin of the package classes
+   */
+  Package(String name,
+	  String specTitle, String specVendor, String specVersion,
+	  String implTitle, String implVendor, String implVersion, URL sealed,
+          ClassLoader loader)
+  {
+    if (name == null)
+      throw new IllegalArgumentException("null Package name");
+
+    this.name = name;
+    this.implTitle = implTitle;
+    this.implVendor = implVendor;
+    this.implVersion = implVersion;
+    this.specTitle = specTitle;
+    this.specVendor = specVendor;
+    this.specVersion = specVersion;
+    this.sealed = sealed;
+    this.loader = loader;
+  }
+
+  /**
+   * Returns the Package name in dot-notation.
+   *
+   * @return the non-null package name
+   */
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Returns the name of the specification, or null if unknown.
+   *
+   * @return the specification title
+   */
+  public String getSpecificationTitle()
+  {
+    return specTitle;
+  }
+
+  /**
+   * Returns the version of the specification, or null if unknown.
+   *
+   * @return the specification version
+   */
+  public String getSpecificationVersion()
+  {
+    return specVersion;
+  }
+
+  /**
+   * Returns the name of the specification designer, or null if unknown.
+   *
+   * @return the specification vendor
+   */
+  public String getSpecificationVendor()
+  {
+    return specVendor;
+  }
+
+  /**
+   * Returns the name of the implementation, or null if unknown.
+   *
+   * @return the implementation title
+   */
+  public String getImplementationTitle()
+  {
+    return implTitle;
+  }
+
+  /**
+   * Returns the version of this implementation, or null if unknown.
+   *
+   * @return the implementation version
+   */
+  public String getImplementationVersion()
+  {
+    return implVersion;
+  }
+
+  /**
+   * Returns the vendor that wrote this implementation, or null if unknown.
+   *
+   * @return the implementation vendor
+   */
+  public String getImplementationVendor()
+  {
+    return implVendor;
+  }
+
+  /**
+   * Returns true if this Package is sealed.
+   *
+   * @return true if the package is sealed
+   */
+  public boolean isSealed()
+  {
+    return sealed != null;
+  }
+
+  /**
+   * Returns true if this Package is sealed and the origin of the classes is
+   * the given URL.
+   *
+   * @param url the URL to test
+   * @return true if the package is sealed by this URL
+   * @throws NullPointerException if url is null
+   */
+  public boolean isSealed(URL url)
+  {
+    return url.equals(sealed);
+  }
+
+  /**
+   * Checks if the version of the specification is higher or at least as high
+   * as the desired version. Comparison is done by sequentially comparing
+   * dotted decimal numbers from the parameter and from
+   * <code>getSpecificationVersion</code>.
+   *
+   * @param version the (minimal) desired version of the specification
+   *
+   * @return true if the version is compatible, false otherwise
+   *
+   * @throws NumberFormatException if either version string is invalid
+   * @throws NullPointerException if either version string is null
+   */
+  public boolean isCompatibleWith(String version)
+  {
+    StringTokenizer versionTokens = new StringTokenizer(version, ".");
+    StringTokenizer specTokens = new StringTokenizer(specVersion, ".");
+    try
+      {
+        while (versionTokens.hasMoreElements())
+          {
+            int vers = Integer.parseInt(versionTokens.nextToken());
+            int spec = Integer.parseInt(specTokens.nextToken());
+            if (spec < vers)
+              return false;
+            else if (spec > vers)
+              return true;
+            // They must be equal, next Token please!
+          }
+      }
+    catch (NoSuchElementException e)
+      {
+        // This must have been thrown by spec.nextToken() so return false.
+        return false;
+      }
+    // They must have been exactly the same version.
+    // Or the specVersion has more subversions. That is also good.
+    return true;
+  }
+
+  /**
+   * Returns the named package if it is known by the callers class loader.
+   * It may return null if the package is unknown, when there is no
+   * information on that particular package available or when the callers
+   * classloader is null.
+   *
+   * @param name the name of the desired package
+   * @return the package by that name in the current ClassLoader
+   */
+  public static Package getPackage(String name)
+  {
+    // Get the caller's classloader
+    ClassLoader cl = VMStackWalker.getCallingClassLoader();
+    return cl != null ? cl.getPackage(name) : VMClassLoader.getPackage(name);
+  }
+
+  /**
+   * Returns all the packages that are known to the callers class loader.
+   * It may return an empty array if the classloader of the caller is null.
+   *
+   * @return an array of all known packages
+   */
+  public static Package[] getPackages()
+  {
+    // Get the caller's classloader
+    ClassLoader cl = VMStackWalker.getCallingClassLoader();
+    return cl != null ? cl.getPackages() : VMClassLoader.getPackages();
+  }
+
+  /**
+   * Returns the hashCode of the name of this package.
+   *
+   * @return the hash code
+   */
+  public int hashCode()
+  {
+    return name.hashCode();
+  }
+
+  /**
+   * Returns a string representation of this package. It is specified to
+   * be <code>"package " + getName() + (getSpecificationTitle() == null
+   * ? "" : ", " + getSpecificationTitle()) + (getSpecificationVersion()
+   * == null ? "" : ", version " + getSpecificationVersion())</code>.
+   *
+   * @return the string representation of the package
+   */
+  public String toString()
+  {
+    return ("package " + name + (specTitle == null ? "" : ", " + specTitle)
+	    + (specVersion == null ? "" : ", version " + specVersion));
+  }
+
+  /**
+   * Returns this package'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 package's annotation for the specified type, or
+   *         <code>null</code> if no such annotation exists.
+   * @since 1.5
+   */
+  /* FIXME[GENERICS]: <T extends Annotation> T getAnnotation(Class <T>) */
+  public Annotation getAnnotation(Class annotationClass)
+  {
+    Annotation foundAnnotation = null;
+    Annotation[] annotations = getAnnotations();
+    for (int i = 0; i < annotations.length; i++)
+      if (annotations[i].annotationType() == annotationClass)
+	foundAnnotation = annotations[i];
+    return foundAnnotation;
+  }
+
+  /**
+   * Returns all annotations associated with this package.  If there are
+   * no annotations associated with this package, 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
+   * package, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return this package' annotations.
+   * @since 1.5
+   */
+  public Annotation[] getAnnotations()
+  {
+    /** All a package's annotations are declared within it. */
+    return getDeclaredAnnotations();
+  }
+
+  /**
+   * Returns all annotations directly defined by this package.  If there are
+   * no annotations associated with this package, 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
+   * package, and hence no effect on the return value of this method for
+   * future callers.
+   *
+   * @return the annotations directly defined by this package.
+   * @since 1.5
+   */
+  public Annotation[] getDeclaredAnnotations()
+  {
+    try
+      {
+        Class pkgInfo = Class.forName(name + ".package-info", false, loader);
+        return pkgInfo.getDeclaredAnnotations();
+      }
+    catch (ClassNotFoundException _)
+      {
+        return new Annotation[0];
+      }
+  }
+
+  /**
+   * Returns true if an annotation for the specified type is associated
+   * with this package.  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> */
+  public boolean isAnnotationPresent(Class
+				     annotationClass)
+  {
+    return getAnnotation(annotationClass) != null;
+  }
+
+} // class Package

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Process.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Process.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,130 @@
+/* Process.java - Represent spawned system process
+   Copyright (C) 1998, 1999, 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 java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * An instance of a subclass of <code>Process</code> is created by the
+ * <code>Runtime.exec</code> methods.  Methods in <code>Process</code>
+ * provide a means to send input to a process, obtain the output from a
+ * subprocess, destroy a subprocess, obtain the exit value from a
+ * subprocess, and wait for a subprocess to complete.
+ *
+ * <p>This is dependent on the platform, and some processes (like native
+ * windowing processes, 16-bit processes in Windows, or shell scripts) may
+ * be limited in functionality. Because some platforms have limited buffers
+ * between processes, you may need to provide input and read output to prevent
+ * the process from blocking, or even deadlocking.
+ *
+ * <p>Even if all references to this object disapper, the process continues
+ * to execute to completion. There are no guarantees that the
+ * subprocess execute asynchronously or concurrently with the process which
+ * owns this object.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @see Runtime#exec(String[], String[], File)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public abstract class Process
+{
+  /**
+   * Empty constructor does nothing.
+   */
+  public Process()
+  {
+  }
+
+  /**
+   * Obtain the output stream that sends data to the subprocess. This is
+   * the STDIN of the subprocess. When implementing, you should probably
+   * use a buffered stream.
+   *
+   * @return the output stream that pipes to the process input
+   */
+  public abstract OutputStream getOutputStream();
+
+  /**
+   * Obtain the input stream that receives data from the subprocess. This is
+   * the STDOUT of the subprocess. When implementing, you should probably
+   * use a buffered stream.
+   *
+   * @return the input stream that pipes data from the process output
+   */
+  public abstract InputStream getInputStream();
+
+  /**
+   * Obtain the input stream that receives data from the subprocess. This is
+   * the STDERR of the subprocess. When implementing, you should probably
+   * use a buffered stream.
+   *
+   * @return the input stream that pipes data from the process error output
+   */
+  public abstract InputStream getErrorStream();
+
+  /**
+   * The thread calling <code>waitFor</code> will block until the subprocess
+   * has terminated. If the process has already terminated then the method
+   * immediately returns with the exit value of the subprocess.
+   *
+   * @return the subprocess exit value; 0 conventionally denotes success
+   * @throws InterruptedException if another thread interrupts the blocked one
+   */
+  public abstract int waitFor() throws InterruptedException;
+
+  /**
+   * When a process terminates there is associated with that termination
+   * an exit value for the process to indicate why it terminated. A return
+   * of <code>0</code> denotes normal process termination by convention.
+   *
+   * @return the exit value of the subprocess
+   * @throws IllegalThreadStateException if the subprocess has not terminated
+   */
+  public abstract int exitValue();
+
+  /**
+   * Kills the subprocess and all of its children forcibly.
+   */
+  public abstract void destroy();
+} // class Process

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Readable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Readable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* Readable.java -- A character source
+   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;
+
+import java.io.IOException;
+import java.nio.CharBuffer;
+import java.nio.ReadOnlyBufferException;
+
+/**
+ * A <code>Readable</code> object is simply a source for Unicode character
+ * data.  On request, a <code>Readable</code> will provide its data in
+ * a supplied <code>CharBuffer</code>.
+ *
+ * @author Tom Tromey <tromey at redhat.com>
+ * @author Andrew John Hughes <gnu_andrew at member.fsf.org>
+ * @since 1.5
+ */
+public interface Readable
+{
+
+  /**
+   * Adds the character data supplied by this <code>Readable</code>
+   * to the specified character buffer.  This method simply places
+   * each character into the buffer as supplied, using <code>put()</code>,
+   * without flipping or rewinding.
+   *
+   * @param buf the buffer to place the character data in.
+   * @return the number of <code>char</code> values placed in the buffer,
+   *         or -1 if no more characters are available.
+   * @throws IOException if an I/O error occurs.
+   * @throws NullPointerException if buf is null.
+   * @throws ReadOnlyBufferException if buf is read only.
+   */
+  int read(CharBuffer buf)
+    throws IOException;
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Runnable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Runnable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,62 @@
+/* Runnable -- interface for a method tied to an Object; often for Threads
+   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;
+
+/**
+ * Runnable is an interface you implement to indicate that your class can be
+ * executed as the main part of a Thread, among other places.  When you want
+ * an entry point to run a piece of code, implement this interface and
+ * override run.
+ *
+ * @author Paul Fisher
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @see Thread
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface Runnable
+{
+  /**
+   * This method will be called by whoever wishes to run your class
+   * implementing Runnable. Note that there are no restrictions on what
+   * you are allowed to do in the run method, except that you cannot
+   * throw a checked exception.
+   */
+  void run();
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Runtime.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Runtime.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,796 @@
+/* Runtime.java -- access to the VM process
+   Copyright (C) 1998, 2002, 2003, 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;
+
+import gnu.classpath.SystemProperties;
+import gnu.classpath.VMStackWalker;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Runtime represents the Virtual Machine.
+ *
+ * @author John Keiser
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @author Jeroen Frijters
+ */
+// No idea why this class isn't final, since you can't build a subclass!
+public class Runtime
+{
+  /**
+   * The library path, to search when loading libraries. We can also safely use
+   * this as a lock for synchronization.
+   */
+  private final String[] libpath;
+
+  /**
+   * The thread that started the exit sequence. Access to this field must
+   * be thread-safe; lock on libpath to avoid deadlock with user code.
+   * <code>runFinalization()</code> may want to look at this to see if ALL
+   * finalizers should be run, because the virtual machine is about to halt.
+   */
+  private Thread exitSequence;
+
+  /**
+   * All shutdown hooks. This is initialized lazily, and set to null once all
+   * shutdown hooks have run. Access to this field must be thread-safe; lock
+   * on libpath to avoid deadlock with user code.
+   */
+  private Set shutdownHooks;
+
+  /**
+   * The one and only runtime instance.
+   */
+  private static final Runtime current = new Runtime();
+
+  /**
+   * Not instantiable by a user, this should only create one instance.
+   */
+  private Runtime()
+  {
+    if (current != null)
+      throw new InternalError("Attempt to recreate Runtime");
+    
+    // If used by underlying VM this contains the directories where Classpath's own
+    // native libraries are located.
+    String bootPath = SystemProperties.getProperty("gnu.classpath.boot.library.path", "");
+    
+    // If properly set by the user this contains the directories where the application's
+    // native libraries are located. On operating systems where a LD_LIBRARY_PATH environment
+    // variable is available a VM should preset java.library.path with value of this
+    // variable.
+    String path = SystemProperties.getProperty("java.library.path", ".");
+    String pathSep = SystemProperties.getProperty("path.separator", ":");
+    String fileSep = SystemProperties.getProperty("file.separator", "/");
+
+    StringTokenizer t1 = new StringTokenizer(bootPath, pathSep);
+    StringTokenizer t2 = new StringTokenizer(path, pathSep);
+    libpath = new String[t1.countTokens() + t2.countTokens()];
+    
+    int i = 0;
+    while(t1.hasMoreTokens()) {
+      String prefix = t1.nextToken();
+      if (! prefix.endsWith(fileSep))
+        prefix += fileSep;
+      
+      libpath[i] = prefix;
+      i++;
+    }
+    
+    while(t2.hasMoreTokens()) {
+      String prefix = t2.nextToken();
+      if (! prefix.endsWith(fileSep))
+        prefix += fileSep;
+  
+      libpath[i] = prefix;
+      i++;
+    }
+  }
+
+  /**
+   * Get the current Runtime object for this JVM. This is necessary to access
+   * the many instance methods of this class.
+   *
+   * @return the current Runtime object
+   */
+  public static Runtime getRuntime()
+  {
+    return current;
+  }
+
+  /**
+   * Exit the Java runtime. This method will either throw a SecurityException
+   * or it will never return. The status code is returned to the system; often
+   * a non-zero status code indicates an abnormal exit. Of course, there is a
+   * security check, <code>checkExit(status)</code>.
+   *
+   * <p>First, all shutdown hooks are run, in unspecified order, and
+   * concurrently. Next, if finalization on exit has been enabled, all pending
+   * finalizers are run. Finally, the system calls <code>halt</code>.</p>
+   *
+   * <p>If this is run a second time after shutdown has already started, there
+   * are two actions. If shutdown hooks are still executing, it blocks
+   * indefinitely. Otherwise, if the status is nonzero it halts immediately;
+   * if it is zero, it blocks indefinitely. This is typically called by
+   * <code>System.exit</code>.</p>
+   *
+   * @param status the status to exit with
+   * @throws SecurityException if permission is denied
+   * @see #addShutdownHook(Thread)
+   * @see #runFinalizersOnExit(boolean)
+   * @see #runFinalization()
+   * @see #halt(int)
+   */
+  public void exit(int status)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe!
+    if (sm != null)
+      sm.checkExit(status);
+
+    if (runShutdownHooks())
+      halt(status);
+
+    // Someone else already called runShutdownHooks().
+    // Make sure we are not/no longer in the shutdownHooks set.
+    // And wait till the thread that is calling runShutdownHooks() finishes.
+    synchronized (libpath)
+      {
+        if (shutdownHooks != null)
+          {
+            shutdownHooks.remove(Thread.currentThread());
+            // Interrupt the exit sequence thread, in case it was waiting
+            // inside a join on our thread.
+            exitSequence.interrupt();
+            // Shutdown hooks are still running, so we clear status to
+	    // make sure we don't halt.
+	    status = 0;
+          }
+      }
+
+    // If exit() is called again after the shutdown hooks have run, but
+    // while finalization for exit is going on and the status is non-zero
+    // we halt immediately.
+    if (status != 0)
+      halt(status);
+
+    while (true)
+      try
+        {
+          exitSequence.join();
+        }
+      catch (InterruptedException e)
+        {
+          // Ignore, we've suspended indefinitely to let all shutdown
+          // hooks complete, and to let any non-zero exits through, because
+          // this is a duplicate call to exit(0).
+        }
+  }
+
+  /**
+   * On first invocation, run all the shutdown hooks and return true.
+   * Any subsequent invocations will simply return false.
+   * Note that it is package accessible so that VMRuntime can call it
+   * when VM exit is not triggered by a call to Runtime.exit().
+   * 
+   * @return was the current thread the first one to call this method?
+   */
+  boolean runShutdownHooks()
+  {
+    boolean first = false;
+    synchronized (libpath) // Synch on libpath, not this, to avoid deadlock.
+      {
+        if (exitSequence == null)
+          {
+            first = true;
+            exitSequence = Thread.currentThread();
+            if (shutdownHooks != null)
+              {
+                Iterator i = shutdownHooks.iterator();
+                while (i.hasNext()) // Start all shutdown hooks.
+                  try
+                    {
+                      ((Thread) i.next()).start();
+                    }
+                  catch (IllegalThreadStateException e)
+                    {
+                      i.remove();
+                    }
+              }
+          }
+      }
+    if (first)
+      {
+        if (shutdownHooks != null)
+          {
+            // Check progress of all shutdown hooks. As a hook completes,
+            // remove it from the set. If a hook calls exit, it removes
+            // itself from the set, then waits indefinitely on the
+            // exitSequence thread. Once the set is empty, set it to null to
+            // signal all finalizer threads that halt may be called.
+            while (true)
+              {
+                Thread[] hooks;
+                synchronized (libpath)
+                  {
+                    hooks = new Thread[shutdownHooks.size()];
+                    shutdownHooks.toArray(hooks);
+                  }
+                if (hooks.length == 0)
+                  break;
+                for (int i = 0; i < hooks.length; i++)
+                  {
+                    try
+                      {
+                        synchronized (libpath)
+                          {
+                            if (!shutdownHooks.contains(hooks[i]))
+                              continue;
+                          }
+                        hooks[i].join();
+                        synchronized (libpath)
+                          {
+                            shutdownHooks.remove(hooks[i]);
+                          }
+                      }
+                    catch (InterruptedException x)
+                      {
+                        // continue waiting on the next thread
+                      }
+                  }
+              }
+            synchronized (libpath)
+              {
+                shutdownHooks = null;
+              }
+          }
+	// Run finalization on all finalizable objects (even if they are
+	// still reachable).
+        VMRuntime.runFinalizationForExit();
+      }
+    return first;
+  }
+
+  /**
+   * Register a new shutdown hook. This is invoked when the program exits
+   * normally (because all non-daemon threads ended, or because
+   * <code>System.exit</code> was invoked), or when the user terminates
+   * the virtual machine (such as by typing ^C, or logging off). There is
+   * a security check to add hooks,
+   * <code>RuntimePermission("shutdownHooks")</code>.
+   *
+   * <p>The hook must be an initialized, but unstarted Thread. The threads
+   * are run concurrently, and started in an arbitrary order; and user
+   * threads or daemons may still be running. Once shutdown hooks have
+   * started, they must all complete, or else you must use <code>halt</code>,
+   * to actually finish the shutdown sequence. Attempts to modify hooks
+   * after shutdown has started result in IllegalStateExceptions.</p>
+   *
+   * <p>It is imperative that you code shutdown hooks defensively, as you
+   * do not want to deadlock, and have no idea what other hooks will be
+   * running concurrently. It is also a good idea to finish quickly, as the
+   * virtual machine really wants to shut down!</p>
+   *
+   * <p>There are no guarantees that such hooks will run, as there are ways
+   * to forcibly kill a process. But in such a drastic case, shutdown hooks
+   * would do little for you in the first place.</p>
+   *
+   * @param hook an initialized, unstarted Thread
+   * @throws IllegalArgumentException if the hook is already registered or run
+   * @throws IllegalStateException if the virtual machine is already in
+   *         the shutdown sequence
+   * @throws SecurityException if permission is denied
+   * @since 1.3
+   * @see #removeShutdownHook(Thread)
+   * @see #exit(int)
+   * @see #halt(int)
+   */
+  public void addShutdownHook(Thread hook)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe!
+    if (sm != null)
+      sm.checkPermission(new RuntimePermission("shutdownHooks"));
+    if (hook.isAlive() || hook.getThreadGroup() == null)
+      throw new IllegalArgumentException("The hook thread " + hook + " must not have been already run or started");
+    synchronized (libpath)
+      {
+        if (exitSequence != null)
+          throw new IllegalStateException("The Virtual Machine is exiting. It is not possible anymore to add any hooks");
+        if (shutdownHooks == null)
+          {
+            VMRuntime.enableShutdownHooks();
+            shutdownHooks = new HashSet(); // Lazy initialization.
+          }
+        if (! shutdownHooks.add(hook))
+          throw new IllegalArgumentException(hook.toString() + " had already been inserted");
+      }
+  }
+
+  /**
+   * De-register a shutdown hook. As when you registered it, there is a
+   * security check to remove hooks,
+   * <code>RuntimePermission("shutdownHooks")</code>.
+   *
+   * @param hook the hook to remove
+   * @return true if the hook was successfully removed, false if it was not
+   *         registered in the first place
+   * @throws IllegalStateException if the virtual machine is already in
+   *         the shutdown sequence
+   * @throws SecurityException if permission is denied
+   * @since 1.3
+   * @see #addShutdownHook(Thread)
+   * @see #exit(int)
+   * @see #halt(int)
+   */
+  public boolean removeShutdownHook(Thread hook)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe!
+    if (sm != null)
+      sm.checkPermission(new RuntimePermission("shutdownHooks"));
+    synchronized (libpath)
+      {
+        if (exitSequence != null)
+          throw new IllegalStateException();
+        if (shutdownHooks != null)
+          return shutdownHooks.remove(hook);
+      }
+    return false;
+  }
+
+  /**
+   * Forcibly terminate the virtual machine. This call never returns. It is
+   * much more severe than <code>exit</code>, as it bypasses all shutdown
+   * hooks and initializers. Use caution in calling this! Of course, there is
+   * a security check, <code>checkExit(status)</code>.
+   *
+   * @param status the status to exit with
+   * @throws SecurityException if permission is denied
+   * @since 1.3
+   * @see #exit(int)
+   * @see #addShutdownHook(Thread)
+   */
+  public void halt(int status)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe!
+    if (sm != null)
+      sm.checkExit(status);
+    VMRuntime.exit(status);
+  }
+
+  /**
+   * Tell the VM to run the finalize() method on every single Object before
+   * it exits.  Note that the JVM may still exit abnormally and not perform
+   * this, so you still don't have a guarantee. And besides that, this is
+   * inherently unsafe in multi-threaded code, as it may result in deadlock
+   * as multiple threads compete to manipulate objects. This value defaults to
+   * <code>false</code>. There is a security check, <code>checkExit(0)</code>.
+   *
+   * @param finalizeOnExit whether to finalize all Objects on exit
+   * @throws SecurityException if permission is denied
+   * @see #exit(int)
+   * @see #gc()
+   * @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)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe!
+    if (sm != null)
+      sm.checkExit(0);
+    VMRuntime.runFinalizersOnExit(finalizeOnExit);
+  }
+
+  /**
+   * Create a new subprocess with the specified command line. Calls
+   * <code>exec(cmdline, null, null)</code>. A security check is performed,
+   * <code>checkExec</code>.
+   *
+   * @param cmdline the command to call
+   * @return the Process object
+   * @throws SecurityException if permission is denied
+   * @throws IOException if an I/O error occurs
+   * @throws NullPointerException if cmdline is null
+   * @throws IndexOutOfBoundsException if cmdline is ""
+   */
+  public Process exec(String cmdline) throws IOException
+  {
+    return exec(cmdline, null, null);
+  }
+
+  /**
+   * Create a new subprocess with the specified command line and environment.
+   * If the environment is null, the process inherits the environment of
+   * this process. Calls <code>exec(cmdline, env, null)</code>. A security
+   * check is performed, <code>checkExec</code>.
+   *
+   * @param cmdline the command to call
+   * @param env the environment to use, in the format name=value
+   * @return the Process object
+   * @throws SecurityException if permission is denied
+   * @throws IOException if an I/O error occurs
+   * @throws NullPointerException if cmdline is null, or env has null entries
+   * @throws IndexOutOfBoundsException if cmdline is ""
+   */
+  public Process exec(String cmdline, String[] env) throws IOException
+  {
+    return exec(cmdline, env, null);
+  }
+
+  /**
+   * Create a new subprocess with the specified command line, environment, and
+   * working directory. If the environment is null, the process inherits the
+   * environment of this process. If the directory is null, the process uses
+   * the current working directory. This splits cmdline into an array, using
+   * the default StringTokenizer, then calls
+   * <code>exec(cmdArray, env, dir)</code>. A security check is performed,
+   * <code>checkExec</code>.
+   *
+   * @param cmdline the command to call
+   * @param env the environment to use, in the format name=value
+   * @param dir the working directory to use
+   * @return the Process object
+   * @throws SecurityException if permission is denied
+   * @throws IOException if an I/O error occurs
+   * @throws NullPointerException if cmdline is null, or env has null entries
+   * @throws IndexOutOfBoundsException if cmdline is ""
+   * @since 1.3
+   */
+  public Process exec(String cmdline, String[] env, File dir)
+    throws IOException
+  {
+    StringTokenizer t = new StringTokenizer(cmdline);
+    String[] cmd = new String[t.countTokens()];
+    for (int i = 0; i < cmd.length; i++)
+      cmd[i] = t.nextToken();
+    return exec(cmd, env, dir);
+  }
+
+  /**
+   * Create a new subprocess with the specified command line, already
+   * tokenized. Calls <code>exec(cmd, null, null)</code>. A security check
+   * is performed, <code>checkExec</code>.
+   *
+   * @param cmd the command to call
+   * @return the Process object
+   * @throws SecurityException if permission is denied
+   * @throws IOException if an I/O error occurs
+   * @throws NullPointerException if cmd is null, or has null entries
+   * @throws IndexOutOfBoundsException if cmd is length 0
+   */
+  public Process exec(String[] cmd) throws IOException
+  {
+    return exec(cmd, null, null);
+  }
+
+  /**
+   * Create a new subprocess with the specified command line, already
+   * tokenized, and specified environment. If the environment is null, the
+   * process inherits the environment of this process. Calls
+   * <code>exec(cmd, env, null)</code>. A security check is performed,
+   * <code>checkExec</code>.
+   *
+   * @param cmd the command to call
+   * @param env the environment to use, in the format name=value
+   * @return the Process object
+   * @throws SecurityException if permission is denied
+   * @throws IOException if an I/O error occurs
+   * @throws NullPointerException if cmd is null, or cmd or env has null
+   *         entries
+   * @throws IndexOutOfBoundsException if cmd is length 0
+   */
+  public Process exec(String[] cmd, String[] env) throws IOException
+  {
+    return exec(cmd, env, null);
+  }
+
+  /**
+   * Create a new subprocess with the specified command line, already
+   * tokenized, and the specified environment and working directory. If the
+   * environment is null, the process inherits the environment of this
+   * process. If the directory is null, the process uses the current working
+   * directory. A security check is performed, <code>checkExec</code>.
+   *
+   * @param cmd the command to call
+   * @param env the environment to use, in the format name=value
+   * @param dir the working directory to use
+   * @return the Process object
+   * @throws SecurityException if permission is denied
+   * @throws IOException if an I/O error occurs
+   * @throws NullPointerException if cmd is null, or cmd or env has null
+   *         entries
+   * @throws IndexOutOfBoundsException if cmd is length 0
+   * @since 1.3
+   */
+  public Process exec(String[] cmd, String[] env, File dir)
+    throws IOException
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe!
+    if (sm != null)
+      sm.checkExec(cmd[0]);
+    return VMRuntime.exec(cmd, env, dir);
+  }
+
+  /**
+   * Returns the number of available processors currently available to the
+   * virtual machine. This number may change over time; so a multi-processor
+   * program want to poll this to determine maximal resource usage.
+   *
+   * @return the number of processors available, at least 1
+   */
+  public int availableProcessors()
+  {
+    return VMRuntime.availableProcessors();
+  }
+
+  /**
+   * Find out how much memory is still free for allocating Objects on the heap.
+   *
+   * @return the number of bytes of free memory for more Objects
+   */
+  public long freeMemory()
+  {
+    return VMRuntime.freeMemory();
+  }
+
+  /**
+   * Find out how much memory total is available on the heap for allocating
+   * Objects.
+   *
+   * @return the total number of bytes of memory for Objects
+   */
+  public long totalMemory()
+  {
+    return VMRuntime.totalMemory();
+  }
+
+  /**
+   * Returns the maximum amount of memory the virtual machine can attempt to
+   * use. This may be <code>Long.MAX_VALUE</code> if there is no inherent
+   * limit (or if you really do have a 8 exabyte memory!).
+   *
+   * @return the maximum number of bytes the virtual machine will attempt
+   *         to allocate
+   */
+  public long maxMemory()
+  {
+    return VMRuntime.maxMemory();
+  }
+
+  /**
+   * Run the garbage collector. This method is more of a suggestion than
+   * anything. All this method guarantees is that the garbage collector will
+   * have "done its best" by the time it returns. Notice that garbage
+   * collection takes place even without calling this method.
+   */
+  public void gc()
+  {
+    VMRuntime.gc();
+  }
+
+  /**
+   * Run finalization on all Objects that are waiting to be finalized. Again,
+   * a suggestion, though a stronger one than {@link #gc()}. This calls the
+   * <code>finalize</code> method of all objects waiting to be collected.
+   *
+   * @see #finalize()
+   */
+  public void runFinalization()
+  {
+    VMRuntime.runFinalization();
+  }
+
+  /**
+   * Tell the VM to trace every bytecode instruction that executes (print out
+   * a trace of it).  No guarantees are made as to where it will be printed,
+   * and the VM is allowed to ignore this request.
+   *
+   * @param on whether to turn instruction tracing on
+   */
+  public void traceInstructions(boolean on)
+  {
+    VMRuntime.traceInstructions(on);
+  }
+
+  /**
+   * Tell the VM to trace every method call that executes (print out a trace
+   * of it).  No guarantees are made as to where it will be printed, and the
+   * VM is allowed to ignore this request.
+   *
+   * @param on whether to turn method tracing on
+   */
+  public void traceMethodCalls(boolean on)
+  {
+    VMRuntime.traceMethodCalls(on);
+  }
+
+  /**
+   * Load a native library using the system-dependent filename. This is similar
+   * to loadLibrary, except the only name mangling done is inserting "_g"
+   * before the final ".so" if the VM was invoked by the name "java_g". There
+   * may be a security check, of <code>checkLink</code>.
+   *
+   * <p>
+   * The library is loaded using the class loader associated with the
+   * class associated with the invoking method.
+   *
+   * @param filename the file to load
+   * @throws SecurityException if permission is denied
+   * @throws UnsatisfiedLinkError if the library is not found
+   */
+  public void load(String filename)
+  {
+    load(filename, VMStackWalker.getCallingClassLoader());
+  }
+
+  /**
+   * Same as <code>load(String)</code> but using the given loader.
+   *
+   * @param filename the file to load
+   * @param loader class loader, or <code>null</code> for the boot loader
+   * @throws SecurityException if permission is denied
+   * @throws UnsatisfiedLinkError if the library is not found
+   */
+  void load(String filename, ClassLoader loader)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe!
+    if (sm != null)
+      sm.checkLink(filename);
+    if (loadLib(filename, loader) == 0)
+      throw new UnsatisfiedLinkError("Could not load library " + filename);
+  }
+
+  /**
+   * Do a security check on the filename and then load the native library.
+   *
+   * @param filename the file to load
+   * @param loader class loader, or <code>null</code> for the boot loader
+   * @return 0 on failure, nonzero on success
+   * @throws SecurityException if file read permission is denied
+   */
+  private static int loadLib(String filename, ClassLoader loader)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe!
+    if (sm != null)
+      sm.checkRead(filename);
+    return VMRuntime.nativeLoad(filename, loader);
+  }
+
+  /**
+   * Load a native library using a system-independent "short name" for the
+   * library.  It will be transformed to a correct filename in a
+   * system-dependent manner (for example, in Windows, "mylib" will be turned
+   * into "mylib.dll").  This is done as follows: if the context that called
+   * load has a ClassLoader cl, then <code>cl.findLibrary(libpath)</code> is
+   * used to convert the name. If that result was null, or there was no class
+   * loader, this searches each directory of the system property
+   * <code>java.library.path</code> for a file named
+   * <code>System.mapLibraryName(libname)</code>. There may be a security
+   * check, of <code>checkLink</code>.
+   *
+   * <p>Note: Besides <code>java.library.path</code> a VM may chose to search
+   * for native libraries in a path that is specified by the
+   * <code>gnu.classpath.boot.library.path</code> system property. However
+   * this is for internal usage or development of GNU Classpath only.
+   * <b>A Java application must not load a non-system library by changing
+   * this property otherwise it will break compatibility.</b></p>
+   *
+   * <p>
+   * The library is loaded using the class loader associated with the
+   * class associated with the invoking method.
+   *
+   * @param libname the library to load
+   *
+   * @throws SecurityException if permission is denied
+   * @throws UnsatisfiedLinkError if the library is not found
+   *
+   * @see System#mapLibraryName(String)
+   * @see ClassLoader#findLibrary(String)
+   */
+  public void loadLibrary(String libname)
+  {
+    loadLibrary(libname, VMStackWalker.getCallingClassLoader());
+  }
+
+  /**
+   * Same as <code>loadLibrary(String)</code> but using the given loader.
+   *
+   * @param libname the library to load
+   * @param loader class loader, or <code>null</code> for the boot loader
+   * @throws SecurityException if permission is denied
+   * @throws UnsatisfiedLinkError if the library is not found
+   */
+  void loadLibrary(String libname, ClassLoader loader)
+  {
+    SecurityManager sm = SecurityManager.current; // Be thread-safe!
+    if (sm != null)
+      sm.checkLink(libname);
+    String filename;
+    if (loader != null && (filename = loader.findLibrary(libname)) != null)
+      {
+	if (loadLib(filename, loader) != 0)
+	  return;
+      }
+    else
+      {
+	filename = VMRuntime.mapLibraryName(libname);
+	for (int i = 0; i < libpath.length; i++)
+	  if (loadLib(libpath[i] + filename, loader) != 0)
+	    return;
+      }
+    throw new UnsatisfiedLinkError("Native library `" + libname
+      + "' not found (as file `" + filename + "') in gnu.classpath.boot.library.path and java.library.path");
+  }
+
+  /**
+   * Return a localized version of this InputStream, meaning all characters
+   * are localized before they come out the other end.
+   *
+   * @param in the stream to localize
+   * @return the localized stream
+   * @deprecated <code>InputStreamReader</code> is the preferred way to read
+   *             local encodings
+   * @XXX This implementation does not localize, yet.
+   */
+  public InputStream getLocalizedInputStream(InputStream in)
+  {
+    return in;
+  }
+
+  /**
+   * Return a localized version of this OutputStream, meaning all characters
+   * are localized before they are sent to the other end.
+   *
+   * @param out the stream to localize
+   * @return the localized stream
+   * @deprecated <code>OutputStreamWriter</code> is the preferred way to write
+   *             local encodings
+   * @XXX This implementation does not localize, yet.
+   */
+  public OutputStream getLocalizedOutputStream(OutputStream out)
+  {
+    return out;
+  }
+} // class Runtime

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/RuntimeException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/RuntimeException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,102 @@
+/* RuntimeException.java -- root of all unchecked exceptions
+   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;
+
+/**
+ * All exceptions which are subclasses of <code>RuntimeException</code>
+ * can be thrown at any time during the execution of a Java virtual machine.
+ * Methods which throw these exceptions are not required to declare them
+ * in their throws clause.
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @status updated to 1.4
+ */
+public class RuntimeException extends Exception
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -7034897190745766939L;
+
+  /**
+   * Create an exception without a message. The cause remains uninitialized.
+   *
+   * @see #initCause(Throwable)
+   */
+  public RuntimeException()
+  {
+  }
+
+  /**
+   * Create an exception with a message. The cause remains uninitialized.
+   *
+   * @param s the message string
+   * @see #initCause(Throwable)
+   */
+  public RuntimeException(String s)
+  {
+    super(s);
+  }
+
+  /**
+   * Create an exception with a message and a cause.
+   *
+   * @param s the message string
+   * @param cause the cause of this exception
+   * @since 1.4
+   */
+  public RuntimeException(String s, Throwable cause)
+  {
+    super(s, cause);
+  }
+
+  /**
+   * Create an exception with the given cause, and a message of
+   * <code>cause == null ? null : cause.toString()</code>.
+   *
+   * @param cause the cause of this exception
+   * @since 1.4
+   */
+  public RuntimeException(Throwable cause)
+  {
+    super(cause);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/RuntimePermission.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/RuntimePermission.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,209 @@
+/* RuntimePermission.java -- permission for a secure runtime action
+   Copyright (C) 1998, 2000, 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang;
+
+import java.security.BasicPermission;
+import java.security.Permission;
+
+/**
+ * A <code>RuntimePermission</code> contains a permission name, but no
+ * actions list.  This means you either have the permission or you don't.
+ *
+ * Permission names have the follow the hierarchial property naming
+ * convention.  In addition, an asterisk may appear at the end of a
+ * name if following a period or by itself.
+ *
+ * <table border=1>
+ * <tr><th>Valid names</th><th>Invalid names</th></tr>
+ * <tr><td>"accessClassInPackage.*","*"</td>
+ * <td>"**", "*x", "*.a"</td></tr>
+ * </table>
+ * <br>
+ *
+ * The following table provides a list of all the possible RuntimePermission
+ * permission names with a description of what that permission allows.<br>
+ * <table border=1>
+ * <tr><th>Permission Name</th><th>Permission Allows</th><th>Risks</th</tr>
+ * <tr>
+ *   <td><code>createClassLoader</code></td>
+ *   <td>creation of a class loader</td>
+ *   <td>a class loader can load rogue classes which bypass all security
+ *       permissions</td></tr>
+ * <tr>
+ *   <td><code>getClassLoader</code></td>
+ *   <td>retrieval of the class loader for the calling class</td>
+ *   <td>rogue code could load classes not otherwise available</td></tr>
+ * <tr>
+ *   <td><code>setContextClassLoader</code></td>
+ *   <td>allows the setting of the context class loader used by a thread</td>
+ *   <td>rogue code could change the context class loader needed by system
+ *       threads</td></tr>
+ * <tr>
+ *   <td><code>setSecurityManager</code></td>
+ *   <td>allows the application to replace the security manager</td>
+ *   <td>the new manager may be less restrictive, so that rogue code can
+ *       bypass existing security checks</td></tr>
+ * <tr>
+ *   <td><code>createSecurityManager</code></td>
+ *   <td>allows the application to create a new security manager</td>
+ *   <td>rogue code can use the new security manager to discover information
+ *       about the execution stack</td></tr>
+ * <tr>
+ *   <td><code>exitVM</code></td>
+ *   <td>allows the application to halt the virtual machine</td>
+ *   <td>rogue code can mount a denial-of-service attack by killing the
+ *       virtual machine</td></tr>
+ * <tr>
+ *   <td><code>shutdownHooks</code></td>
+ *   <td>allows registration and modification of shutdown hooks</td>
+ *   <td>rogue code can add a hook that interferes with clean
+ *       virtual machine shutdown</td></tr>
+ * <tr>
+ *   <td><code>setFactory</code></td>
+ *   <td>allows the application to set the socket factory for socket,
+ *       server socket, stream handler, or RMI socket factory.</td>
+ *   <td>rogue code can create a rogue network object which mangles or
+ *       intercepts data</td></tr>
+ * <tr>
+ *   <td><code>setIO</code></td>
+ *   <td>allows the application to set System.out, System.in, and
+ *       System.err</td>
+ *   <td>rogue code could sniff user input and intercept or mangle
+ *       output</td></tr>
+ * <tr>
+ *   <td><code>modifyThread</code></td>
+ *   <td>allows the application to modify any thread in the virtual machine
+ *       using any of the methods <code>stop</code>, <code>resume</code>,
+ *       <code>suspend</code>, <code>setPriority</code>, and
+ *       <code>setName</code> of classs <code>Thread</code></td>
+ *   <td>rogue code could adversely modify system or user threads</td></tr>
+ * <tr>
+ *   <td><code>stopThread</code></td>
+ *   <td>allows the application to <code>stop</code> any thread it has
+ *       access to in the system</td>
+ *   <td>rogue code can stop arbitrary threads</td></tr>
+ * <tr>
+ *   <td><code>modifyThreadGroup</code></td>
+ *   <td>allows the application to modify thread groups using any of the
+ *       methods <code>destroy</code>, <code>resume</code>,
+ *       <code>setDaemon</code>, <code>setMaxPriority</code>,
+ *       <code>stop</code>, and <code>suspend</code> of the class
+ *       <code>ThreadGroup</code></td>
+ *   <td>rogue code can mount a denial-of-service attack by changing run
+ *       priorities</td></tr>
+ * <tr>
+ *   <td><code>getProtectionDomain</code></td>
+ *   <td>retrieve a class's ProtectionDomain</td>
+ *   <td>rogue code can gain information about the security policy, to
+ *       prepare a better attack</td></tr>
+ * <tr>
+ *   <td><code>readFileDescriptor</code></td>
+ *   <td>read a file descriptor</td>
+ *   <td>rogue code can read sensitive information</td></tr>
+ * <tr>
+ *   <td><code>writeFileDescriptor</code></td>
+ *   <td>write a file descriptor</td>
+ *   <td>rogue code can write files, including viruses, and can modify the
+ *       virtual machine binary; if not just fill up the disk</td></tr>
+ * <tr>
+ *   <td><code>loadLibrary.</code><em>library name</em></td>
+ *   <td>dynamic linking of the named library</td>
+ *   <td>native code can bypass many security checks of pure Java</td></tr>
+ * <tr>
+ *   <td><code>accessClassInPackage.</code><em>package name</em></td>
+ *   <td>access to a package via a ClassLoader</td>
+ *   <td>rogue code can access classes not normally available</td></tr>
+ * <tr>
+ *   <td><code>defineClassInPackage.</code><em>package name</em></td>
+ *   <td>define a class inside a given package</td>
+ *   <td>rogue code can install rogue classes, including in trusted packages
+ *       like java.security or java.lang</td></tr>
+ * <tr>
+ *   <td><code>accessDeclaredMembers</code></td>
+ *   <td>access declared class members via reflection</td>
+ *   <td>rogue code can discover information, invoke methods, or modify fields
+ *       that are not otherwise available</td></tr>
+ * <tr>
+ *   <td><code>queuePrintJob</code></td>
+ *   <td>initiate a print job</td>
+ *   <td>rogue code could make a hard copy of sensitive information, or
+ *       simply waste paper</td></tr>
+ * </table>
+ *
+ * @author Brian Jones
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see BasicPermission
+ * @see Permission
+ * @see SecurityManager
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public final class RuntimePermission extends BasicPermission
+{
+  /**
+   * Compatible with JDK 1.2+.
+   */
+  private static final long serialVersionUID = 7399184964622342223L;
+
+  /**
+   * Create a new permission with the specified name.
+   *
+   * @param permissionName the name of the granted permission
+   * @throws NullPointerException if name is null
+   * @throws IllegalArgumentException thrown if name is empty or invalid
+   */
+  public RuntimePermission(String permissionName)
+    {
+      super(permissionName);
+    }
+
+  /**
+   * Create a new permission with the specified name. The actions argument
+   * is ignored, as runtime permissions have no actions.
+   *
+   * @param permissionName the name of the granted permission
+   * @param actions ignored
+   * @throws NullPointerException if name is null
+   * @throws IllegalArgumentException thrown if name is empty or invalid
+   */
+  public RuntimePermission(String permissionName, String actions)
+  {
+    super(permissionName);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/SecurityException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/SecurityException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,128 @@
+/* SecurityException.java -- thrown to indicate a security violation
+   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;
+
+/**
+ * The security manager will throw this exception to indicate a security
+ * violation.  This can occur any time an operation is attempted which is
+ * deemed unsafe by the current security policies.
+ *
+ * @author Brian Jones
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @see SecurityManager
+ * @status updated to 1.5
+ */
+public class SecurityException extends RuntimeException
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 6878364983674394167L;
+
+  /**
+   * Create an exception without a message.
+   */
+  public SecurityException()
+  {
+  }
+
+  /**
+   * Create an exception with a message.
+   *
+   * @param s the message
+   */
+  public SecurityException(String s)
+  {
+    super(s);
+  }
+
+  /**
+   * <p>
+   * Constructs a <code>SecurityException</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 SecurityException(String message, Throwable cause)
+  {
+    super(message, cause);
+  }
+
+  /**
+   * <p>
+   * Constructs a <code>SecurityException</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 SecurityException(Throwable cause)
+  {
+    super(cause);
+  }
+
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/SecurityManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/SecurityManager.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1075 @@
+/* SecurityManager.java -- security checks for privileged actions
+   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;
+
+import gnu.classpath.VMStackWalker;
+
+import java.awt.AWTPermission;
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FilePermission;
+import java.io.RandomAccessFile;
+import java.lang.reflect.Member;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketImplFactory;
+import java.net.SocketPermission;
+import java.net.URL;
+import java.net.URLStreamHandlerFactory;
+import java.security.AccessControlContext;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.AllPermission;
+import java.security.BasicPermission;
+import java.security.Permission;
+import java.security.Policy;
+import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
+import java.security.Security;
+import java.security.SecurityPermission;
+import java.util.Properties;
+import java.util.PropertyPermission;
+import java.util.StringTokenizer;
+
+/**
+ * SecurityManager is a class you can extend to create your own Java
+ * security policy.  By default, there is no SecurityManager installed in
+ * 1.1, which means that all things are permitted to all people. The security
+ * manager, if set, is consulted before doing anything with potentially
+ * dangerous results, and throws a <code>SecurityException</code> if the
+ * action is forbidden.
+ *
+ * <p>A typical check is as follows, just before the dangerous operation:<br>
+ * <pre>
+ * SecurityManager sm = System.getSecurityManager();
+ * if (sm != null)
+ *   sm.checkABC(<em>argument</em>, ...);
+ * </pre>
+ * Note that this is thread-safe, by caching the security manager in a local
+ * variable rather than risking a NullPointerException if the mangager is
+ * changed between the check for null and before the permission check.
+ *
+ * <p>The special method <code>checkPermission</code> is a catchall, and
+ * the default implementation calls
+ * <code>AccessController.checkPermission</code>. In fact, all the other
+ * methods default to calling checkPermission.
+ *
+ * <p>Sometimes, the security check needs to happen from a different context,
+ * such as when called from a worker thread. In such cases, use
+ * <code>getSecurityContext</code> to take a snapshot that can be passed
+ * to the worker thread:<br>
+ * <pre>
+ * Object context = null;
+ * SecurityManager sm = System.getSecurityManager();
+ * if (sm != null)
+ *   context = sm.getSecurityContext(); // defaults to an AccessControlContext
+ * // now, in worker thread
+ * if (sm != null)
+ *   sm.checkPermission(permission, context);
+ * </pre>
+ *
+ * <p>Permissions fall into these categories: File, Socket, Net, Security,
+ * Runtime, Property, AWT, Reflect, and Serializable. Each of these
+ * permissions have a property naming convention, that follows a hierarchical
+ * naming convention, to make it easy to grant or deny several permissions
+ * at once. Some permissions also take a list of permitted actions, such
+ * as "read" or "write", to fine-tune control even more. The permission
+ * <code>java.security.AllPermission</code> grants all permissions.
+ *
+ * <p>The default methods in this class deny all things to all people. You
+ * must explicitly grant permission for anything you want to be legal when
+ * subclassing this class.
+ *
+ * @author John Keiser
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see ClassLoader
+ * @see SecurityException
+ * @see #checkTopLevelWindow(Object)
+ * @see System#getSecurityManager()
+ * @see System#setSecurityManager(SecurityManager)
+ * @see AccessController
+ * @see AccessControlContext
+ * @see AccessControlException
+ * @see Permission
+ * @see BasicPermission
+ * @see java.io.FilePermission
+ * @see java.net.SocketPermission
+ * @see java.util.PropertyPermission
+ * @see RuntimePermission
+ * @see java.awt.AWTPermission
+ * @see Policy
+ * @see SecurityPermission
+ * @see ProtectionDomain
+ * @since 1.0
+ * @status still missing 1.4 functionality
+ */
+public class SecurityManager
+{
+  /**
+   * The current security manager. This is located here instead of in
+   * System, to avoid security problems, as well as bootstrap issues.
+   * Make sure to access it in a thread-safe manner; it is package visible
+   * to avoid overhead in java.lang.
+   */
+  static volatile SecurityManager current;
+
+  /**
+   * Tells whether or not the SecurityManager is currently performing a
+   * security check.
+   * @deprecated Use {@link #checkPermission(Permission)} instead.
+   */
+  protected boolean inCheck;
+
+  /**
+   * Construct a new security manager. There may be a security check, of
+   * <code>RuntimePermission("createSecurityManager")</code>.
+   *
+   * @throws SecurityException if permission is denied
+   */
+  public SecurityManager()
+  {
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkPermission(new RuntimePermission("createSecurityManager"));
+  }
+
+  /**
+   * Tells whether or not the SecurityManager is currently performing a
+   * security check.
+   *
+   * @return true if the SecurityManager is in a security check
+   * @see #inCheck
+   * @deprecated use {@link #checkPermission(Permission)} instead
+   */
+  public boolean getInCheck()
+  {
+    return inCheck;
+  }
+
+  /**
+   * Get a list of all the classes currently executing methods on the Java
+   * stack.  getClassContext()[0] is the currently executing method (ie. the
+   * class that CALLED getClassContext, not SecurityManager).
+   *
+   * @return an array of classes on the Java execution stack
+   */
+  protected Class[] getClassContext()
+  {
+    Class[] stack1 = VMStackWalker.getClassContext();
+    Class[] stack2 = new Class[stack1.length - 1];
+    System.arraycopy(stack1, 1, stack2, 0, stack1.length - 1);
+    return stack2;
+  }
+
+  /**
+   * Find the ClassLoader of the first non-system class on the execution
+   * stack. A non-system class is one whose ClassLoader is not equal to
+   * {@link ClassLoader#getSystemClassLoader()} or its ancestors. This
+   * will return null in three cases:
+   *
+   * <ul>
+   * <li>All methods on the stack are from system classes</li>
+   * <li>All methods on the stack up to the first "privileged" caller, as
+   *  created by {@link AccessController#doPrivileged(PrivilegedAction)},
+   *  are from system classes</li>
+   * <li>A check of <code>java.security.AllPermission</code> succeeds.</li>
+   * </ul>
+   * 
+   * @return the most recent non-system ClassLoader on the execution stack
+   * @deprecated use {@link #checkPermission(Permission)} instead
+   */
+  protected ClassLoader currentClassLoader()
+  {
+    Class cl = currentLoadedClass();
+    return cl != null ? cl.getClassLoader() : null;
+  }
+
+  /**
+   * Find the first non-system class on the execution stack. A non-system
+   * class is one whose ClassLoader is not equal to
+   * {@link ClassLoader#getSystemClassLoader()} or its ancestors. This
+   * will return null in three cases:
+   *
+   * <ul>
+   * <li>All methods on the stack are from system classes</li>
+   * <li>All methods on the stack up to the first "privileged" caller, as
+   *  created by {@link AccessController#doPrivileged(PrivilegedAction)},
+   *  are from system classes</li>
+   * <li>A check of <code>java.security.AllPermission</code> succeeds.</li>
+   * </ul>
+   * 
+   * @return the most recent non-system Class on the execution stack
+   * @deprecated use {@link #checkPermission(Permission)} instead
+   */
+  protected Class currentLoadedClass()
+  {
+    int i = classLoaderDepth();
+    return i >= 0 ? getClassContext()[i] : null;
+  }
+
+  /**
+   * Get the depth of a particular class on the execution stack.
+   *
+   * @param className the fully-qualified name to search for
+   * @return the index of the class on the stack, or -1
+   * @deprecated use {@link #checkPermission(Permission)} instead
+   */
+  protected int classDepth(String className)
+  {
+    Class[] c = getClassContext();
+    for (int i = 0; i < c.length; i++)
+      if (className.equals(c[i].getName()))
+        return i;
+    return -1;
+  }
+
+  /**
+   * Get the depth on the execution stack of the most recent non-system class.
+   * A non-system class is one whose ClassLoader is not equal to
+   * {@link ClassLoader#getSystemClassLoader()} or its ancestors. This
+   * will return -1 in three cases:
+   *
+   * <ul>
+   * <li>All methods on the stack are from system classes</li>
+   * <li>All methods on the stack up to the first "privileged" caller, as
+   *  created by {@link AccessController#doPrivileged(PrivilegedAction)},
+   *  are from system classes</li>
+   * <li>A check of <code>java.security.AllPermission</code> succeeds.</li>
+   * </ul>
+   * 
+   * @return the index of the most recent non-system Class on the stack
+   * @deprecated use {@link #checkPermission(Permission)} instead
+   */
+  protected int classLoaderDepth()
+  {
+    try
+      {
+        checkPermission(new AllPermission());
+      }
+    catch (SecurityException e)
+      {
+        Class[] c = getClassContext();
+        for (int i = 0; i < c.length; i++)
+          if (c[i].getClassLoader() != null)
+            // XXX Check if c[i] is AccessController, or a system class.
+            return i;
+      }
+    return -1;
+  }
+
+  /**
+   * Tell whether the specified class is on the execution stack.
+   *
+   * @param className the fully-qualified name of the class to find
+   * @return whether the specified class is on the execution stack
+   * @deprecated use {@link #checkPermission(Permission)} instead
+   */
+  protected boolean inClass(String className)
+  {
+    return classDepth(className) != -1;
+  }
+
+  /**
+   * Tell whether there is a class loaded with an explicit ClassLoader on
+   * the stack.
+   *
+   * @return whether a class with an explicit ClassLoader is on the stack
+   * @deprecated use {@link #checkPermission(Permission)} instead
+   */
+  protected boolean inClassLoader()
+  {
+    return classLoaderDepth() != -1;
+  }
+
+  /**
+   * Get an implementation-dependent Object that contains enough information
+   * about the current environment to be able to perform standard security
+   * checks later.  This is used by trusted methods that need to verify that
+   * their callers have sufficient access to perform certain operations.
+   *
+   * <p>Currently the only methods that use this are checkRead() and
+   * checkConnect(). The default implementation returns an
+   * <code>AccessControlContext</code>.
+   *
+   * @return a security context
+   * @see #checkConnect(String, int, Object)
+   * @see #checkRead(String, Object)
+   * @see AccessControlContext
+   * @see AccessController#getContext()
+   */
+  public Object getSecurityContext()
+  {
+    return AccessController.getContext();
+  }
+
+  /**
+   * Check if the current thread is allowed to perform an operation that
+   * requires the specified <code>Permission</code>. This defaults to
+   * <code>AccessController.checkPermission</code>.
+   *
+   * @param perm the <code>Permission</code> required
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if perm is null
+   * @since 1.2
+   */
+  public void checkPermission(Permission perm)
+  {
+    AccessController.checkPermission(perm);
+  }
+
+  /**
+   * Check if the current thread is allowed to perform an operation that
+   * requires the specified <code>Permission</code>. This is done in a
+   * context previously returned by <code>getSecurityContext()</code>. The
+   * default implementation expects context to be an AccessControlContext,
+   * and it calls <code>AccessControlContext.checkPermission(perm)</code>.
+   *
+   * @param perm the <code>Permission</code> required
+   * @param context a security context
+   * @throws SecurityException if permission is denied, or if context is
+   *         not an AccessControlContext
+   * @throws NullPointerException if perm is null
+   * @see #getSecurityContext()
+   * @see AccessControlContext#checkPermission(Permission)
+   * @since 1.2
+   */
+  public void checkPermission(Permission perm, Object context)
+  {
+    if (! (context instanceof AccessControlContext))
+      throw new SecurityException("Missing context");
+    ((AccessControlContext) context).checkPermission(perm);
+  }
+
+  /**
+   * Check if the current thread is allowed to create a ClassLoader. This
+   * method is called from ClassLoader.ClassLoader(), and checks
+   * <code>RuntimePermission("createClassLoader")</code>. If you override
+   * this, you should call <code>super.checkCreateClassLoader()</code> rather
+   * than throwing an exception.
+   *
+   * @throws SecurityException if permission is denied
+   * @see ClassLoader#ClassLoader()
+   */
+  public void checkCreateClassLoader()
+  {
+    checkPermission(new RuntimePermission("createClassLoader"));
+  }
+
+  /**
+   * Check if the current thread is allowed to modify another Thread. This is
+   * called by Thread.stop(), suspend(), resume(), interrupt(), destroy(),
+   * setPriority(), setName(), and setDaemon(). The default implementation
+   * checks <code>RuntimePermission("modifyThread")</code> on system threads
+   * (ie. threads in ThreadGroup with a null parent), and returns silently on
+   * other threads.
+   *
+   * <p>If you override this, you must do two things. First, call
+   * <code>super.checkAccess(t)</code>, to make sure you are not relaxing
+   * requirements. Second, if the calling thread has
+   * <code>RuntimePermission("modifyThread")</code>, return silently, so that
+   * core classes (the Classpath library!) can modify any thread.
+   *
+   * @param thread the other Thread to check
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if thread is null
+   * @see Thread#stop()
+   * @see Thread#suspend()
+   * @see Thread#resume()
+   * @see Thread#setPriority(int)
+   * @see Thread#setName(String)
+   * @see Thread#setDaemon(boolean)
+   */
+  public void checkAccess(Thread thread)
+  {
+    if (thread.getThreadGroup() != null 
+	&& thread.getThreadGroup().parent == null)
+      checkPermission(new RuntimePermission("modifyThread"));
+  }
+
+  /**
+   * Check if the current thread is allowed to modify a ThreadGroup. This is
+   * called by Thread.Thread() (to add a thread to the ThreadGroup),
+   * ThreadGroup.ThreadGroup() (to add this ThreadGroup to a parent),
+   * ThreadGroup.stop(), suspend(), resume(), interrupt(), destroy(),
+   * setDaemon(), and setMaxPriority(). The default implementation
+   * checks <code>RuntimePermission("modifyThread")</code> on the system group
+   * (ie. the one with a null parent), and returns silently on other groups.
+   *
+   * <p>If you override this, you must do two things. First, call
+   * <code>super.checkAccess(t)</code>, to make sure you are not relaxing
+   * requirements. Second, if the calling thread has
+   * <code>RuntimePermission("modifyThreadGroup")</code>, return silently,
+   * so that core classes (the Classpath library!) can modify any thread.
+   *
+   * @param g the ThreadGroup to check
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if g is null
+   * @see Thread#Thread()
+   * @see ThreadGroup#ThreadGroup(String)
+   * @see ThreadGroup#stop()
+   * @see ThreadGroup#suspend()
+   * @see ThreadGroup#resume()
+   * @see ThreadGroup#interrupt()
+   * @see ThreadGroup#setDaemon(boolean)
+   * @see ThreadGroup#setMaxPriority(int)
+   */
+  public void checkAccess(ThreadGroup g)
+  {
+    if (g.parent == null)
+      checkPermission(new RuntimePermission("modifyThreadGroup"));
+  }
+
+  /**
+   * Check if the current thread is allowed to exit the JVM with the given
+   * status. This method is called from Runtime.exit() and Runtime.halt().
+   * The default implementation checks
+   * <code>RuntimePermission("exitVM")</code>. If you override this, call
+   * <code>super.checkExit</code> rather than throwing an exception.
+   *
+   * @param status the status to exit with
+   * @throws SecurityException if permission is denied
+   * @see Runtime#exit(int)
+   * @see Runtime#halt(int)
+   */
+  public void checkExit(int status)
+  {
+    checkPermission(new RuntimePermission("exitVM"));
+  }
+
+  /**
+   * Check if the current thread is allowed to execute the given program. This
+   * method is called from Runtime.exec(). If the name is an absolute path,
+   * the default implementation checks
+   * <code>FilePermission(program, "execute")</code>, otherwise it checks
+   * <code>FilePermission("<<ALL FILES>>", "execute")</code>. If
+   * you override this, call <code>super.checkExec</code> rather than
+   * throwing an exception.
+   *
+   * @param program the name of the program to exec
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if program is null
+   * @see Runtime#exec(String[], String[], File)
+   */
+  public void checkExec(String program)
+  {
+    if (! program.equals(new File(program).getAbsolutePath()))
+      program = "<<ALL FILES>>";
+    checkPermission(new FilePermission(program, "execute"));
+  }
+
+  /**
+   * Check if the current thread is allowed to link in the given native
+   * library. This method is called from Runtime.load() (and hence, by
+   * loadLibrary() as well). The default implementation checks
+   * <code>RuntimePermission("loadLibrary." + filename)</code>. If you
+   * override this, call <code>super.checkLink</code> rather than throwing
+   * an exception.
+   *
+   * @param filename the full name of the library to load
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if filename is null
+   * @see Runtime#load(String)
+   */
+  public void checkLink(String filename)
+  {
+    // Use the toString() hack to do the null check.
+    checkPermission(new RuntimePermission("loadLibrary."
+                                          + filename.toString()));
+  }
+
+  /**
+   * Check if the current thread is allowed to read the given file using the
+   * FileDescriptor. This method is called from
+   * FileInputStream.FileInputStream(). The default implementation checks
+   * <code>RuntimePermission("readFileDescriptor")</code>. If you override
+   * this, call <code>super.checkRead</code> rather than throwing an
+   * exception.
+   *
+   * @param desc the FileDescriptor representing the file to access
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if desc is null
+   * @see FileInputStream#FileInputStream(FileDescriptor)
+   */
+  public void checkRead(FileDescriptor desc)
+  {
+    if (desc == null)
+      throw new NullPointerException();
+    checkPermission(new RuntimePermission("readFileDescriptor"));
+  }
+
+  /**
+   * Check if the current thread is allowed to read the given file. This
+   * method is called from FileInputStream.FileInputStream(),
+   * RandomAccessFile.RandomAccessFile(), File.exists(), canRead(), isFile(),
+   * isDirectory(), lastModified(), length() and list(). The default
+   * implementation checks <code>FilePermission(filename, "read")</code>. If
+   * you override this, call <code>super.checkRead</code> rather than
+   * throwing an exception.
+   *
+   * @param filename the full name of the file to access
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if filename is null
+   * @see File
+   * @see FileInputStream#FileInputStream(String)
+   * @see RandomAccessFile#RandomAccessFile(String, String)
+   */
+  public void checkRead(String filename)
+  {
+    checkPermission(new FilePermission(filename, "read"));
+  }
+
+  /**
+   * Check if the current thread is allowed to read the given file. using the
+   * given security context. The context must be a result of a previous call
+   * to <code>getSecurityContext()</code>. The default implementation checks
+   * <code>AccessControlContext.checkPermission(new FilePermission(filename,
+   * "read"))</code>. If you override this, call <code>super.checkRead</code>
+   * rather than throwing an exception.
+   *
+   * @param filename the full name of the file to access
+   * @param context the context to determine access for
+   * @throws SecurityException if permission is denied, or if context is
+   *         not an AccessControlContext
+   * @throws NullPointerException if filename is null
+   * @see #getSecurityContext()
+   * @see AccessControlContext#checkPermission(Permission)
+   */
+  public void checkRead(String filename, Object context)
+  {
+    if (! (context instanceof AccessControlContext))
+      throw new SecurityException("Missing context");
+    AccessControlContext ac = (AccessControlContext) context;
+    ac.checkPermission(new FilePermission(filename, "read"));
+  }
+
+  /**
+   * Check if the current thread is allowed to write the given file using the
+   * FileDescriptor. This method is called from
+   * FileOutputStream.FileOutputStream(). The default implementation checks
+   * <code>RuntimePermission("writeFileDescriptor")</code>. If you override
+   * this, call <code>super.checkWrite</code> rather than throwing an
+   * exception.
+   *
+   * @param desc the FileDescriptor representing the file to access
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if desc is null
+   * @see FileOutputStream#FileOutputStream(FileDescriptor)
+   */
+  public void checkWrite(FileDescriptor desc)
+  {
+    if (desc == null)
+      throw new NullPointerException();
+    checkPermission(new RuntimePermission("writeFileDescriptor"));
+  }
+
+  /**
+   * Check if the current thread is allowed to write the given file. This
+   * method is called from FileOutputStream.FileOutputStream(),
+   * RandomAccessFile.RandomAccessFile(), File.canWrite(), mkdir(), and
+   * renameTo(). The default implementation checks
+   * <code>FilePermission(filename, "write")</code>. If you override this,
+   * call <code>super.checkWrite</code> rather than throwing an exception.
+   *
+   * @param filename the full name of the file to access
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if filename is null
+   * @see File
+   * @see File#canWrite()
+   * @see File#mkdir()
+   * @see File#renameTo(File)
+   * @see FileOutputStream#FileOutputStream(String)
+   * @see RandomAccessFile#RandomAccessFile(String, String)
+   */
+  public void checkWrite(String filename)
+  {
+    checkPermission(new FilePermission(filename, "write"));
+  }
+
+  /**
+   * Check if the current thread is allowed to delete the given file. This
+   * method is called from File.delete(). The default implementation checks
+   * <code>FilePermission(filename, "delete")</code>. If you override this,
+   * call <code>super.checkDelete</code> rather than throwing an exception.
+   *
+   * @param filename the full name of the file to delete
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if filename is null
+   * @see File#delete()
+   */
+  public void checkDelete(String filename)
+  {
+    checkPermission(new FilePermission(filename, "delete"));
+  }
+
+  /**
+   * Check if the current thread is allowed to connect to a given host on a
+   * given port. This method is called from Socket.Socket(). A port number
+   * of -1 indicates the caller is attempting to determine an IP address, so
+   * the default implementation checks
+   * <code>SocketPermission(host, "resolve")</code>. Otherwise, the default
+   * implementation checks
+   * <code>SocketPermission(host + ":" + port, "connect")</code>. If you
+   * override this, call <code>super.checkConnect</code> rather than throwing
+   * an exception.
+   *
+   * @param host the host to connect to
+   * @param port the port to connect on
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if host is null
+   * @see Socket#Socket()
+   */
+  public void checkConnect(String host, int port)
+  {
+    if (port == -1)
+      checkPermission(new SocketPermission(host, "resolve"));
+    else
+      // Use the toString() hack to do the null check.
+      checkPermission(new SocketPermission(host.toString() + ":" + port,
+                                           "connect"));
+  }
+
+  /**
+   * Check if the current thread is allowed to connect to a given host on a
+   * given port, using the given security context. The context must be a
+   * result of a previous call to <code>getSecurityContext</code>. A port
+   * number of -1 indicates the caller is attempting to determine an IP
+   * address, so the default implementation checks
+   * <code>AccessControlContext.checkPermission(new SocketPermission(host,
+   * "resolve"))</code>. Otherwise, the default implementation checks
+   * <code>AccessControlContext.checkPermission(new SocketPermission(host
+   * + ":" + port, "connect"))</code>. If you override this, call
+   * <code>super.checkConnect</code> rather than throwing an exception.
+   *
+   * @param host the host to connect to
+   * @param port the port to connect on
+   * @param context the context to determine access for
+   *
+   * @throws SecurityException if permission is denied, or if context is
+   *         not an AccessControlContext
+   * @throws NullPointerException if host is null
+   *
+   * @see #getSecurityContext()
+   * @see AccessControlContext#checkPermission(Permission)
+   */
+  public void checkConnect(String host, int port, Object context)
+  {
+    if (! (context instanceof AccessControlContext))
+      throw new SecurityException("Missing context");
+    AccessControlContext ac = (AccessControlContext) context;
+    if (port == -1)
+      ac.checkPermission(new SocketPermission(host, "resolve"));
+    else
+      // Use the toString() hack to do the null check.
+      ac.checkPermission(new SocketPermission(host.toString() + ":" + port,
+                                              "connect"));
+  }
+
+  /**
+   * Check if the current thread is allowed to listen to a specific port for
+   * data. This method is called by ServerSocket.ServerSocket(). The default
+   * implementation checks
+   * <code>SocketPermission("localhost:" + (port == 0 ? "1024-" : "" + port),
+   * "listen")</code>. If you override this, call
+   * <code>super.checkListen</code> rather than throwing an exception.
+   *
+   * @param port the port to listen on
+   * @throws SecurityException if permission is denied
+   * @see ServerSocket#ServerSocket(int)
+   */
+  public void checkListen(int port)
+  {
+    checkPermission(new SocketPermission("localhost:"
+                                         + (port == 0 ? "1024-" : "" +port),
+                                         "listen"));
+  }
+
+  /**
+   * Check if the current thread is allowed to accept a connection from a
+   * particular host on a particular port. This method is called by
+   * ServerSocket.implAccept(). The default implementation checks
+   * <code>SocketPermission(host + ":" + port, "accept")</code>. If you
+   * override this, call <code>super.checkAccept</code> rather than throwing
+   * an exception.
+   *
+   * @param host the host which wishes to connect
+   * @param port the port the connection will be on
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if host is null
+   * @see ServerSocket#accept()
+   */
+  public void checkAccept(String host, int port)
+  {
+    // Use the toString() hack to do the null check.
+    checkPermission(new SocketPermission(host.toString() + ":" + port,
+                                         "accept"));
+  }
+
+  /**
+   * Check if the current thread is allowed to read and write multicast to
+   * a particular address. The default implementation checks
+   * <code>SocketPermission(addr.getHostAddress(), "accept,connect")</code>.
+   * If you override this, call <code>super.checkMulticast</code> rather than
+   * throwing an exception.
+   *
+   * @param addr the address to multicast to
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if host is null
+   * @since 1.1
+   */
+  public void checkMulticast(InetAddress addr)
+  {
+    checkPermission(new SocketPermission(addr.getHostAddress(),
+                                         "accept,connect"));
+  }
+
+  /**
+   *Check if the current thread is allowed to read and write multicast to
+   * a particular address with a particular ttl (time-to-live) value. The
+   * default implementation ignores ttl, and checks
+   * <code>SocketPermission(addr.getHostAddress(), "accept,connect")</code>.
+   * If you override this, call <code>super.checkMulticast</code> rather than
+   * throwing an exception.
+   *
+   * @param addr the address to multicast to
+   * @param ttl value in use for multicast send
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if host is null
+   * @since 1.1
+   * @deprecated use {@link #checkPermission(Permission)} instead
+   */
+  public void checkMulticast(InetAddress addr, byte ttl)
+  {
+    checkPermission(new SocketPermission(addr.getHostAddress(),
+                                         "accept,connect"));
+  }
+
+  /**
+   * Check if the current thread is allowed to read or write all the system
+   * properties at once. This method is called by System.getProperties()
+   * and setProperties(). The default implementation checks
+   * <code>PropertyPermission("*", "read,write")</code>. If you override
+   * this, call <code>super.checkPropertiesAccess</code> rather than
+   * throwing an exception.
+   *
+   * @throws SecurityException if permission is denied
+   * @see System#getProperties()
+   * @see System#setProperties(Properties)
+   */
+  public void checkPropertiesAccess()
+  {
+    checkPermission(new PropertyPermission("*", "read,write"));
+  }
+
+  /**
+   * Check if the current thread is allowed to read a particular system
+   * property (writes are checked directly via checkPermission). This method
+   * is called by System.getProperty() and setProperty(). The default
+   * implementation checks <code>PropertyPermission(key, "read")</code>. If
+   * you override this, call <code>super.checkPropertyAccess</code> rather
+   * than throwing an exception.
+   *
+   * @param key the key of the property to check
+   *
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if key is null
+   * @throws IllegalArgumentException if key is ""
+   *
+   * @see System#getProperty(String)
+   */
+  public void checkPropertyAccess(String key)
+  {
+    checkPermission(new PropertyPermission(key, "read"));
+  }
+
+  /**
+   * Check if the current thread is allowed to create a top-level window. If
+   * it is not, the operation should still go through, but some sort of
+   * nonremovable warning should be placed on the window to show that it
+   * is untrusted. This method is called by Window.Window(). The default
+   * implementation checks
+   * <code>AWTPermission("showWindowWithoutWarningBanner")</code>, and returns
+   * true if no exception was thrown. If you override this, use
+   * <code>return super.checkTopLevelWindow</code> rather than returning
+   * false.
+   *
+   * @param window the window to create
+   * @return true if there is permission to show the window without warning
+   * @throws NullPointerException if window is null
+   * @see java.awt.Window#Window(java.awt.Frame)
+   */
+  public boolean checkTopLevelWindow(Object window)
+  {
+    if (window == null)
+      throw new NullPointerException();
+    try
+      {
+        checkPermission(new AWTPermission("showWindowWithoutWarningBanner"));
+        return true;
+      }
+    catch (SecurityException e)
+      {
+        return false;
+      }
+  }
+
+  /**
+   * Check if the current thread is allowed to create a print job. This
+   * method is called by Toolkit.getPrintJob(). The default implementation
+   * checks <code>RuntimePermission("queuePrintJob")</code>. If you override
+   * this, call <code>super.checkPrintJobAccess</code> rather than throwing
+   * an exception.
+   *
+   * @throws SecurityException if permission is denied
+   * @see java.awt.Toolkit#getPrintJob(java.awt.Frame, String, Properties)
+   * @since 1.1
+   */
+  public void checkPrintJobAccess()
+  {
+    checkPermission(new RuntimePermission("queuePrintJob"));
+  }
+
+  /**
+   * Check if the current thread is allowed to use the system clipboard. This
+   * method is called by Toolkit.getSystemClipboard(). The default
+   * implementation checks <code>AWTPermission("accessClipboard")</code>. If
+   * you override this, call <code>super.checkSystemClipboardAccess</code>
+   * rather than throwing an exception.
+   *
+   * @throws SecurityException if permission is denied
+   * @see java.awt.Toolkit#getSystemClipboard()
+   * @since 1.1
+   */
+  public void checkSystemClipboardAccess()
+  {
+    checkPermission(new AWTPermission("accessClipboard"));
+  }
+
+  /**
+   * Check if the current thread is allowed to use the AWT event queue. This
+   * method is called by Toolkit.getSystemEventQueue(). The default
+   * implementation checks <code>AWTPermission("accessEventQueue")</code>.
+   * you override this, call <code>super.checkAwtEventQueueAccess</code>
+   * rather than throwing an exception.
+   *
+   * @throws SecurityException if permission is denied
+   * @see java.awt.Toolkit#getSystemEventQueue()
+   * @since 1.1
+   */
+  public void checkAwtEventQueueAccess()
+  {
+    checkPermission(new AWTPermission("accessEventQueue"));
+  }
+
+  /**
+   * Check if the current thread is allowed to access the specified package
+   * at all. This method is called by ClassLoader.loadClass() in user-created
+   * ClassLoaders. The default implementation gets a list of all restricted
+   * packages, via <code>Security.getProperty("package.access")</code>. Then,
+   * if packageName starts with or equals any restricted package, it checks
+   * <code>RuntimePermission("accessClassInPackage." + packageName)</code>.
+   * If you override this, you should call
+   * <code>super.checkPackageAccess</code> before doing anything else.
+   *
+   * @param packageName the package name to check access to
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if packageName is null
+   * @see ClassLoader#loadClass(String, boolean)
+   * @see Security#getProperty(String)
+   */
+  public void checkPackageAccess(String packageName)
+  {
+    checkPackageList(packageName, "package.access", "accessClassInPackage.");
+  }
+
+  /**
+   * Check if the current thread is allowed to define a class into the
+   * specified package. This method is called by ClassLoader.loadClass() in
+   * user-created ClassLoaders. The default implementation gets a list of all
+   * restricted packages, via
+   * <code>Security.getProperty("package.definition")</code>. Then, if
+   * packageName starts with or equals any restricted package, it checks
+   * <code>RuntimePermission("defineClassInPackage." + packageName)</code>.
+   * If you override this, you should call
+   * <code>super.checkPackageDefinition</code> before doing anything else.
+   *
+   * @param packageName the package name to check access to
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if packageName is null
+   * @see ClassLoader#loadClass(String, boolean)
+   * @see Security#getProperty(String)
+   */
+  public void checkPackageDefinition(String packageName)
+  {
+    checkPackageList(packageName, "package.definition", "defineClassInPackage.");
+  }
+
+  /**
+   * Check if the current thread is allowed to set the current socket factory.
+   * This method is called by Socket.setSocketImplFactory(),
+   * ServerSocket.setSocketFactory(), and URL.setURLStreamHandlerFactory().
+   * The default implementation checks
+   * <code>RuntimePermission("setFactory")</code>. If you override this, call
+   * <code>super.checkSetFactory</code> rather than throwing an exception.
+   *
+   * @throws SecurityException if permission is denied
+   * @see Socket#setSocketImplFactory(SocketImplFactory)
+   * @see ServerSocket#setSocketFactory(SocketImplFactory)
+   * @see URL#setURLStreamHandlerFactory(URLStreamHandlerFactory)
+   */
+  public void checkSetFactory()
+  {
+    checkPermission(new RuntimePermission("setFactory"));
+  }
+
+  /**
+   * Check if the current thread is allowed to get certain types of Methods,
+   * Fields and Constructors from a Class object. This method is called by
+   * Class.getMethod[s](), Class.getField[s](), Class.getConstructor[s],
+   * Class.getDeclaredMethod[s](), Class.getDeclaredField[s](), and
+   * Class.getDeclaredConstructor[s](). The default implementation allows
+   * PUBLIC access, and access to classes defined by the same classloader as
+   * the code performing the reflection. Otherwise, it checks
+   * <code>RuntimePermission("accessDeclaredMembers")</code>. If you override
+   * this, do not call <code>super.checkMemberAccess</code>, as this would
+   * mess up the stack depth check that determines the ClassLoader requesting
+   * the access.
+   *
+   * @param c the Class to check
+   * @param memberType either DECLARED or PUBLIC
+   * @throws SecurityException if permission is denied, including when
+   *         memberType is not DECLARED or PUBLIC
+   * @throws NullPointerException if c is null
+   * @see Class
+   * @see Member#DECLARED
+   * @see Member#PUBLIC
+   * @since 1.1
+   */
+  public void checkMemberAccess(Class c, int memberType)
+  {
+    if (c == null)
+      throw new NullPointerException();
+    if (memberType == Member.PUBLIC)
+      return;
+    // XXX Allow access to classes created by same classloader before next
+    // check.
+    checkPermission(new RuntimePermission("accessDeclaredMembers"));
+  }
+
+  /**
+   * Test whether a particular security action may be taken. The default
+   * implementation checks <code>SecurityPermission(action)</code>. If you
+   * override this, call <code>super.checkSecurityAccess</code> rather than
+   * throwing an exception.
+   *
+   * @param action the desired action to take
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if action is null
+   * @throws IllegalArgumentException if action is ""
+   * @since 1.1
+   */
+  public void checkSecurityAccess(String action)
+  {
+    checkPermission(new SecurityPermission(action));
+  }
+
+  /**
+   * Get the ThreadGroup that a new Thread should belong to by default. Called
+   * by Thread.Thread(). The default implementation returns the current
+   * ThreadGroup of the current Thread. <STRONG>Spec Note:</STRONG> it is not
+   * clear whether the new Thread is guaranteed to pass the
+   * checkAccessThreadGroup() test when using this ThreadGroup, but I presume
+   * so.
+   *
+   * @return the ThreadGroup to put the new Thread into
+   * @since 1.1
+   */
+  public ThreadGroup getThreadGroup()
+  {
+    return Thread.currentThread().getThreadGroup();
+  }
+
+  /**
+   * Helper that checks a comma-separated list of restricted packages, from
+   * <code>Security.getProperty("package.definition")</code>, for the given
+   * package access permission. If packageName starts with or equals any
+   * restricted package, it checks
+   * <code>RuntimePermission(permission + packageName)</code>.
+   *
+   * @param packageName the package name to check access to
+   * @param restriction "package.access" or "package.definition"
+   * @param permission the base permission, including the '.'
+   * @throws SecurityException if permission is denied
+   * @throws NullPointerException if packageName is null
+   * @see #checkPackageAccess(String)
+   * @see #checkPackageDefinition(String)
+   */
+  void checkPackageList(String packageName, final String restriction,
+                        String permission)
+  {
+    if (packageName == null)
+      throw new NullPointerException();
+
+    String list = (String)AccessController.doPrivileged(new PrivilegedAction()
+      {
+	public Object run()
+        {
+	  return Security.getProperty(restriction);
+	}
+      });
+
+    if (list == null || list.equals(""))
+      return;
+
+    String packageNamePlusDot = packageName + ".";
+
+    StringTokenizer st = new StringTokenizer(list, ",");
+    while (st.hasMoreTokens())
+      {
+	if (packageNamePlusDot.startsWith(st.nextToken()))
+	  {
+	    Permission p = new RuntimePermission(permission + packageName);
+	    checkPermission(p);
+	    return;
+	  }
+      }
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Short.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/Short.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,397 @@
+/* Short.java -- object wrapper for short
+   Copyright (C) 1998, 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;
+
+/**
+ * Instances of class <code>Short</code> represent primitive
+ * <code>short</code> values.
+ *
+ * Additionally, this class provides various helper functions and variables
+ * related to shorts.
+ *
+ * @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 Short extends Number implements Comparable
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = 7515723908773894738L;
+
+  /**
+   * The minimum value a <code>short</code> can represent is -32768 (or
+   * -2<sup>15</sup>).
+   */
+  public static final short MIN_VALUE = -32768;
+
+  /**
+   * The minimum value a <code>short</code> can represent is 32767 (or
+   * 2<sup>15</sup>).
+   */
+  public static final short MAX_VALUE = 32767;
+
+  /**
+   * The primitive type <code>short</code> is represented by this
+   * <code>Class</code> object.
+   */
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('S');
+
+  /**
+   * The number of bits needed to represent a <code>short</code>.
+   * @since 1.5
+   */
+  public static final int SIZE = 16;
+
+  // This caches some Short values, and is used by boxing conversions
+  // via valueOf().  We must cache at least -128..127; these constants
+  // control how much we actually cache.
+  private static final int MIN_CACHE = -128;
+  private static final int MAX_CACHE = 127;
+  private static Short[] shortCache = new Short[MAX_CACHE - MIN_CACHE + 1];
+
+  /**
+   * The immutable value of this Short.
+   *
+   * @serial the wrapped short
+   */
+  private final short value;
+
+  /**
+   * Create a <code>Short</code> object representing the value of the
+   * <code>short</code> argument.
+   *
+   * @param value the value to use
+   */
+  public Short(short value)
+  {
+    this.value = value;
+  }
+
+  /**
+   * Create a <code>Short</code> object representing the value of the
+   * argument after conversion to a <code>short</code>.
+   *
+   * @param s the string to convert
+   * @throws NumberFormatException if the String cannot be parsed
+   */
+  public Short(String s)
+  {
+    value = parseShort(s, 10);
+  }
+
+  /**
+   * Converts the <code>short</code> to a <code>String</code> and assumes
+   * a radix of 10.
+   *
+   * @param s the <code>short</code> to convert to <code>String</code>
+   * @return the <code>String</code> representation of the argument
+   */
+  public static String toString(short s)
+  {
+    return String.valueOf(s);
+  }
+
+  /**
+   * Converts the specified <code>String</code> into a <code>short</code>.
+   * This function assumes a radix of 10.
+   *
+   * @param s the <code>String</code> to convert
+   * @return the <code>short</code> value of <code>s</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>short</code>
+   */
+  public static short parseShort(String s)
+  {
+    return parseShort(s, 10);
+  }
+
+  /**
+   * Converts the specified <code>String</code> into a <code>short</code>
+   * using the specified radix (base). The string must not be <code>null</code>
+   * or empty. It may begin with an optional '-', which will negate the answer,
+   * provided that there are also valid digits. Each digit is parsed as if by
+   * <code>Character.digit(d, radix)</code>, and must be in the range
+   * <code>0</code> to <code>radix - 1</code>. Finally, the result must be
+   * within <code>MIN_VALUE</code> to <code>MAX_VALUE</code>, inclusive.
+   * Unlike Double.parseDouble, you may not have a leading '+'.
+   *
+   * @param s the <code>String</code> to convert
+   * @param radix the radix (base) to use in the conversion
+   * @return the <code>String</code> argument converted to <code>short</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>short</code>
+   */
+  public static short parseShort(String s, int radix)
+  {
+    int i = Integer.parseInt(s, radix, false);
+    if ((short) i != i)
+      throw new NumberFormatException();
+    return (short) i;
+  }
+
+  /**
+   * Creates a new <code>Short</code> object using the <code>String</code>
+   * and specified radix (base).
+   *
+   * @param s the <code>String</code> to convert
+   * @param radix the radix (base) to convert with
+   * @return the new <code>Short</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>short</code>
+   * @see #parseShort(String, int)
+   */
+  public static Short valueOf(String s, int radix)
+  {
+    return new Short(parseShort(s, radix));
+  }
+
+  /**
+   * Creates a new <code>Short</code> object using the <code>String</code>,
+   * assuming a radix of 10.
+   *
+   * @param s the <code>String</code> to convert
+   * @return the new <code>Short</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>short</code>
+   * @see #Short(String)
+   * @see #parseShort(String)
+   */
+  public static Short valueOf(String s)
+  {
+    return new Short(parseShort(s, 10));
+  }
+
+  /**
+   * Returns a <code>Short</code> object wrapping the value.
+   * In contrast to the <code>Short</code> constructor, this method
+   * will cache some values.  It is used by boxing conversion.
+   *
+   * @param val the value to wrap
+   * @return the <code>Short</code>
+   *
+   * @since 1.5
+   */
+  public static Short valueOf(short val)
+  {
+    if (val < MIN_CACHE || val > MAX_CACHE)
+      return new Short(val);
+    synchronized (shortCache)
+      {
+    if (shortCache[val - MIN_CACHE] == null)
+      shortCache[val - MIN_CACHE] = new Short(val);
+    return shortCache[val - MIN_CACHE];
+      }
+  }
+
+  /**
+   * Convert the specified <code>String</code> into a <code>Short</code>.
+   * The <code>String</code> may represent decimal, hexadecimal, or
+   * octal numbers.
+   *
+   * <p>The extended BNF grammar is as follows:<br>
+   * <pre>
+   * <em>DecodableString</em>:
+   *      ( [ <code>-</code> ] <em>DecimalNumber</em> )
+   *    | ( [ <code>-</code> ] ( <code>0x</code> | <code>0X</code>
+   *              | <code>#</code> ) <em>HexDigit</em> { <em>HexDigit</em> } )
+   *    | ( [ <code>-</code> ] <code>0</code> { <em>OctalDigit</em> } )
+   * <em>DecimalNumber</em>:
+   *        <em>DecimalDigit except '0'</em> { <em>DecimalDigit</em> }
+   * <em>DecimalDigit</em>:
+   *        <em>Character.digit(d, 10) has value 0 to 9</em>
+   * <em>OctalDigit</em>:
+   *        <em>Character.digit(d, 8) has value 0 to 7</em>
+   * <em>DecimalDigit</em>:
+   *        <em>Character.digit(d, 16) has value 0 to 15</em>
+   * </pre>
+   * Finally, the value must be in the range <code>MIN_VALUE</code> to
+   * <code>MAX_VALUE</code>, or an exception is thrown.
+   *
+   * @param s the <code>String</code> to interpret
+   * @return the value of the String as a <code>Short</code>
+   * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+   *         <code>short</code>
+   * @throws NullPointerException if <code>s</code> is null
+   * @see Integer#decode(String)
+   */
+  public static Short decode(String s)
+  {
+    int i = Integer.parseInt(s, 10, true);
+    if ((short) i != i)
+      throw new NumberFormatException();
+    return new Short((short) i);
+  }
+
+  /**
+   * Return the value of this <code>Short</code> as a <code>byte</code>.
+   *
+   * @return the byte value
+   */
+  public byte byteValue()
+  {
+    return (byte) value;
+  }
+
+  /**
+   * Return the value of this <code>Short</code>.
+   *
+   * @return the short value
+   */
+  public short shortValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Short</code> as an <code>int</code>.
+   *
+   * @return the int value
+   */
+  public int intValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Short</code> as a <code>long</code>.
+   *
+   * @return the long value
+   */
+  public long longValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Short</code> as a <code>float</code>.
+   *
+   * @return the float value
+   */
+  public float floatValue()
+  {
+    return value;
+  }
+
+  /**
+   * Return the value of this <code>Short</code> as a <code>double</code>.
+   *
+   * @return the double value
+   */
+  public double doubleValue()
+  {
+    return value;
+  }
+
+  /**
+   * Converts the <code>Short</code> value to a <code>String</code> and
+   * assumes a radix of 10.
+   *
+   * @return the <code>String</code> representation of this <code>Short</code>
+   */
+  public String toString()
+  {
+    return String.valueOf(value);
+  }
+
+  /**
+   * Return a hashcode representing this Object. <code>Short</code>'s hash
+   * code is simply its value.
+   *
+   * @return this Object's hash code
+   */
+  public int hashCode()
+  {
+    return value;
+  }
+
+  /**
+   * Returns <code>true</code> if <code>obj</code> is an instance of
+   * <code>Short</code> and represents the same short value.
+   *
+   * @param obj the object to compare
+   * @return whether these Objects are semantically equal
+   */
+  public boolean equals(Object obj)
+  {
+    return obj instanceof Short && value == ((Short) obj).value;
+  }
+
+  /**
+   * Compare two Shorts numerically by comparing their <code>short</code>
+   * values. The result is positive if the first is greater, negative if the
+   * second is greater, and 0 if the two are equal.
+   *
+   * @param s the Short to compare
+   * @return the comparison
+   * @since 1.2
+   */
+  public int compareTo(Short s)
+  {
+    return value - s.value;
+  }
+
+  /**
+   * Behaves like <code>compareTo(Short)</code> unless the Object
+   * is not a <code>Short</code>.
+   *
+   * @param o the object to compare
+   * @return the comparison
+   * @throws ClassCastException if the argument is not a <code>Short</code>
+   * @see #compareTo(Short)
+   * @see Comparable
+   * @since 1.2
+   */
+  public int compareTo(Object o)
+  {
+    return compareTo((Short)o);
+  }
+
+  /**
+   * Reverse the bytes in val.
+   * @since 1.5
+   */
+  public static short reverseBytes(short val)
+  {
+    return (short) (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/StackOverflowError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/StackOverflowError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* StackOverflowError.java -- thrown when the stack depth is exceeded
+   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>StackOverflowError</code> is thrown when the execution stack
+ * overflow occurs. This often occurs when a method enters infinit recursion.
+ *
+ * @author Brian Jones
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @status updated to 1.4
+ */
+public class StackOverflowError extends VirtualMachineError
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 8609175038441759607L;
+
+  /**
+   * Create an error without a message.
+   */
+  public StackOverflowError()
+  {
+  }
+
+  /**
+   * Create an error with a message.
+   *
+   * @param s the message
+   */
+  public StackOverflowError(String s)
+  {
+    super(s);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/StackTraceElement.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/StackTraceElement.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,279 @@
+/* StackTraceElement.java -- One function call or call stack element
+   Copyright (C) 2001, 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.lang;
+
+import java.io.Serializable;
+
+/**
+ * One function call or stack trace element. Gives information about
+ * the execution point such as the source file name, the line number,
+ * the fully qualified class name, the method name and whether this method
+ * is native, if this information is known.
+ *
+ * @author Mark Wielaard (mark at klomp.org)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.4
+ * @status updated to 1.5
+ */
+public final class StackTraceElement implements Serializable
+{
+  /**
+   * Compatible with JDK 1.4+.
+   */
+  private static final long serialVersionUID = 6992337162326171013L;
+
+  /**
+   * The name of the file, null if unknown.
+   *
+   * @serial the source code filename, if known
+   */
+  private final String fileName;
+
+  /**
+   * The line number in the file, negative if unknown.
+   *
+   * @serial the source code line number, if known
+   */
+  private final int lineNumber;
+
+  /**
+   * The fully qualified class name, null if unknown.
+   *
+   * @serial the enclosing class, if known
+   */
+  private final String declaringClass;
+
+  /**
+   * The method name in the class, null if unknown.
+   *
+   * @serial the enclosing method, if known
+   */
+  private final String methodName;
+
+  /** Whether the method is native. */
+  private final transient boolean isNative;
+
+  /**
+   * A package local constructor for the StackTraceElement class, to be
+   * called by the Virtual Machine as part of Throwable.fillInStackTrace.
+   * There are no public constructors defined for this class. Creation
+   * of new elements is implementation specific.
+   *
+   * @param fileName the name of the file, null if unknown
+   * @param lineNumber the line in the file, negative if unknown
+   * @param className the fully qualified name of the class, null if unknown
+   * @param methodName the name of the method, null if unknown
+   * @param isNative true if native, false otherwise
+   */
+  StackTraceElement(String fileName, int lineNumber, String className,
+                    String methodName, boolean isNative)
+  {
+    this.fileName = fileName;
+    this.lineNumber = lineNumber;
+    this.declaringClass = className;
+    this.methodName = methodName;
+    this.isNative = isNative;
+  }
+
+  /**
+   * Create a new StackTraceElement representing a given source location.
+   *
+   * @param className the fully qualified name of the class
+   * @param methodName the name of the method
+   * @param fileName the name of the file, null if unknown
+   * @param lineNumber the line in the file, negative if unknown, or -2
+   * if this method is native
+   * 
+   * @since 1.5
+   */
+  public StackTraceElement(String className, String methodName, String fileName,
+                           int lineNumber)
+  {
+    this(fileName, lineNumber, className, methodName, lineNumber == -2);
+    // The public constructor doesn't allow certain values to be null.
+    if (className == null || methodName == null)
+      throw new NullPointerException("invalid argument to constructor");
+  }
+
+  /**
+   * Returns the name of the file, or null if unknown. This is usually
+   * obtained from the <code>SourceFile</code> attribute of the class file
+   * format, if present.
+   *
+   * @return the file name
+   */
+  public String getFileName()
+  {
+    return fileName;
+  }
+
+  /**
+   * Returns the line number in the file, or a negative number if unknown.
+   * This is usually obtained from the <code>LineNumberTable</code> attribute
+   * of the method in the class file format, if present.
+   *
+   * @return the line number
+   */
+  public int getLineNumber()
+  {
+    return lineNumber;
+  }
+
+  /**
+   * Returns the fully qualified class name, or null if unknown.
+   *
+   * @return the class name
+   */
+  public String getClassName()
+  {
+    return declaringClass;
+  }
+
+  /**
+   * Returns the method name in the class, or null if unknown. If the
+   * execution point is in a constructor, the name is
+   * <code><init></code>; if the execution point is in the class
+   * initializer, the name is <code><clinit></code>.
+   *
+   * @return the method name
+   */
+  public String getMethodName()
+  {
+    return methodName;
+  }
+
+  /**
+   * Returns true if the method is native, or false if it is not or unknown.
+   *
+   * @return whether the method is native
+   */
+  public boolean isNativeMethod()
+  {
+    return isNative;
+  }
+
+  /**
+   * Returns a string representation of this stack trace element. The
+   * returned String is implementation specific. This implementation
+   * returns the following String: "[class][.][method]([file][:line])".
+   * If the fully qualified class name or the method is unknown it is
+   * omitted including the point seperator. If the source file name is
+   * unknown it is replaced by "Unknown Source" if the method is not native
+   * or by "Native Method" if the method is native. If the line number
+   * is unknown it and the colon are omitted.
+   *
+   * @return a string representation of this execution point
+   */
+  public String toString()
+  {
+    StringBuffer sb = new StringBuffer();
+    if (declaringClass != null)
+      {
+        sb.append(declaringClass);
+        if (methodName != null)
+          sb.append('.');
+      }
+    if (methodName != null)
+      sb.append(methodName);
+    sb.append("(");
+    if (fileName != null)
+      sb.append(fileName);
+    else
+      sb.append(isNative ? "Native Method" : "Unknown Source");
+    if (lineNumber >= 0)
+      sb.append(':').append(lineNumber);
+    sb.append(')');
+    return sb.toString();
+  }
+
+  /**
+   * Returns true if the given object is also a StackTraceElement and all
+   * attributes, except the native flag, are equal (either the same attribute
+   * between the two elments are null, or both satisfy Object.equals).
+   *
+   * @param o the object to compare
+   * @return true if the two are equal
+   */
+  public boolean equals(Object o)
+  {
+    if (! (o instanceof StackTraceElement))
+      return false;
+    StackTraceElement e = (StackTraceElement) o;
+    return equals(fileName, e.fileName)
+      && lineNumber == e.lineNumber
+      && equals(declaringClass, e.declaringClass)
+      && equals(methodName, e.methodName);
+  }
+
+  /**
+   * Returns the hashCode of this StackTraceElement. This implementation
+   * computes the hashcode by xor-ing the hashcode of all attributes except
+   * the native flag.
+   *
+   * @return the hashcode
+   */
+  public int hashCode()
+  {
+    return hashCode(fileName) ^ lineNumber ^ hashCode(declaringClass)
+      ^ hashCode(methodName);
+  }
+
+  /**
+   * Compare two objects according to Collection semantics.
+   *
+   * @param o1 the first object
+   * @param o2 the second object
+   * @return o1 == null ? o2 == null : o1.equals(o2)
+   */
+  private static boolean equals(Object o1, Object o2)
+  {
+    return o1 == null ? o2 == null : o1.equals(o2);
+  }
+
+  /**
+   * Hash an object according to Collection semantics.
+   *
+   * @param o the object to hash
+   * @return o1 == null ? 0 : o1.hashCode()
+   */
+  private static int hashCode(Object o)
+  {
+    return o == null ? 0 : o.hashCode();
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/StrictMath.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/StrictMath.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,2420 @@
+/* java.lang.StrictMath -- common mathematical functions, strict Java
+   Copyright (C) 1998, 2001, 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. */
+
+/*
+ * Some of the algorithms in this class are in the public domain, as part
+ * of fdlibm (freely-distributable math library), available at
+ * http://www.netlib.org/fdlibm/, and carry the following copyright:
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+package java.lang;
+
+import gnu.classpath.Configuration;
+
+import java.util.Random;
+
+/**
+ * Helper class containing useful mathematical functions and constants.
+ * This class mirrors {@link Math}, but is 100% portable, because it uses
+ * no native methods whatsoever.  Also, these algorithms are all accurate
+ * to less than 1 ulp, and execute in <code>strictfp</code> mode, while
+ * Math is allowed to vary in its results for some functions. Unfortunately,
+ * this usually means StrictMath has less efficiency and speed, as Math can
+ * use native methods.
+ *
+ * <p>The source of the various algorithms used is the fdlibm library, at:<br>
+ * <a href="http://www.netlib.org/fdlibm/">http://www.netlib.org/fdlibm/</a>
+ *
+ * Note that angles are specified in radians.  Conversion functions are
+ * provided for your convenience.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.3
+ */
+public final strictfp class StrictMath
+{
+  /**
+   * StrictMath is non-instantiable.
+   */
+  private StrictMath()
+  {
+  }
+
+  /**
+   * A random number generator, initialized on first use.
+   *
+   * @see #random()
+   */
+  private static Random rand;
+
+  /**
+   * The most accurate approximation to the mathematical constant <em>e</em>:
+   * <code>2.718281828459045</code>. Used in natural log and exp.
+   *
+   * @see #log(double)
+   * @see #exp(double)
+   */
+  public static final double E
+    = 2.718281828459045; // Long bits 0x4005bf0z8b145769L.
+
+  /**
+   * The most accurate approximation to the mathematical constant <em>pi</em>:
+   * <code>3.141592653589793</code>. This is the ratio of a circle's diameter
+   * to its circumference.
+   */
+  public static final double PI
+    = 3.141592653589793; // Long bits 0x400921fb54442d18L.
+
+  /**
+   * Take the absolute value of the argument. (Absolute value means make
+   * it positive.)
+   *
+   * <p>Note that the the largest negative value (Integer.MIN_VALUE) cannot
+   * be made positive.  In this case, because of the rules of negation in
+   * a computer, MIN_VALUE is what will be returned.
+   * This is a <em>negative</em> value.  You have been warned.
+   *
+   * @param i the number to take the absolute value of
+   * @return the absolute value
+   * @see Integer#MIN_VALUE
+   */
+  public static int abs(int i)
+  {
+    return (i < 0) ? -i : i;
+  }
+
+  /**
+   * Take the absolute value of the argument. (Absolute value means make
+   * it positive.)
+   *
+   * <p>Note that the the largest negative value (Long.MIN_VALUE) cannot
+   * be made positive.  In this case, because of the rules of negation in
+   * a computer, MIN_VALUE is what will be returned.
+   * This is a <em>negative</em> value.  You have been warned.
+   *
+   * @param l the number to take the absolute value of
+   * @return the absolute value
+   * @see Long#MIN_VALUE
+   */
+  public static long abs(long l)
+  {
+    return (l < 0) ? -l : l;
+  }
+
+  /**
+   * Take the absolute value of the argument. (Absolute value means make
+   * it positive.)
+   *
+   * @param f the number to take the absolute value of
+   * @return the absolute value
+   */
+  public static float abs(float f)
+  {
+    return (f <= 0) ? 0 - f : f;
+  }
+
+  /**
+   * Take the absolute value of the argument. (Absolute value means make
+   * it positive.)
+   *
+   * @param d the number to take the absolute value of
+   * @return the absolute value
+   */
+  public static double abs(double d)
+  {
+    return (d <= 0) ? 0 - d : d;
+  }
+
+  /**
+   * Return whichever argument is smaller.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the smaller of the two numbers
+   */
+  public static int min(int a, int b)
+  {
+    return (a < b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is smaller.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the smaller of the two numbers
+   */
+  public static long min(long a, long b)
+  {
+    return (a < b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is smaller. If either argument is NaN, the
+   * result is NaN, and when comparing 0 and -0, -0 is always smaller.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the smaller of the two numbers
+   */
+  public static float min(float a, float b)
+  {
+    // this check for NaN, from JLS 15.21.1, saves a method call
+    if (a != a)
+      return a;
+    // no need to check if b is NaN; < will work correctly
+    // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special
+    if (a == 0 && b == 0)
+      return -(-a - b);
+    return (a < b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is smaller. If either argument is NaN, the
+   * result is NaN, and when comparing 0 and -0, -0 is always smaller.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the smaller of the two numbers
+   */
+  public static double min(double a, double b)
+  {
+    // this check for NaN, from JLS 15.21.1, saves a method call
+    if (a != a)
+      return a;
+    // no need to check if b is NaN; < will work correctly
+    // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special
+    if (a == 0 && b == 0)
+      return -(-a - b);
+    return (a < b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is larger.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the larger of the two numbers
+   */
+  public static int max(int a, int b)
+  {
+    return (a > b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is larger.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the larger of the two numbers
+   */
+  public static long max(long a, long b)
+  {
+    return (a > b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is larger. If either argument is NaN, the
+   * result is NaN, and when comparing 0 and -0, 0 is always larger.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the larger of the two numbers
+   */
+  public static float max(float a, float b)
+  {
+    // this check for NaN, from JLS 15.21.1, saves a method call
+    if (a != a)
+      return a;
+    // no need to check if b is NaN; > will work correctly
+    // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special
+    if (a == 0 && b == 0)
+      return a - -b;
+    return (a > b) ? a : b;
+  }
+
+  /**
+   * Return whichever argument is larger. If either argument is NaN, the
+   * result is NaN, and when comparing 0 and -0, 0 is always larger.
+   *
+   * @param a the first number
+   * @param b a second number
+   * @return the larger of the two numbers
+   */
+  public static double max(double a, double b)
+  {
+    // this check for NaN, from JLS 15.21.1, saves a method call
+    if (a != a)
+      return a;
+    // no need to check if b is NaN; > will work correctly
+    // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special
+    if (a == 0 && b == 0)
+      return a - -b;
+    return (a > b) ? a : b;
+  }
+
+  /**
+   * The trigonometric function <em>sin</em>. The sine of NaN or infinity is
+   * NaN, and the sine of 0 retains its sign.
+   *
+   * @param a the angle (in radians)
+   * @return sin(a)
+   */
+  public static double sin(double a)
+  {
+    if (a == Double.NEGATIVE_INFINITY || ! (a < Double.POSITIVE_INFINITY))
+      return Double.NaN;
+
+    if (abs(a) <= PI / 4)
+      return sin(a, 0);
+
+    // Argument reduction needed.
+    double[] y = new double[2];
+    int n = remPiOver2(a, y);
+    switch (n & 3)
+      {
+      case 0:
+        return sin(y[0], y[1]);
+      case 1:
+        return cos(y[0], y[1]);
+      case 2:
+        return -sin(y[0], y[1]);
+      default:
+        return -cos(y[0], y[1]);
+      }
+  }
+
+  /**
+   * The trigonometric function <em>cos</em>. The cosine of NaN or infinity is
+   * NaN.
+   *
+   * @param a the angle (in radians).
+   * @return cos(a).
+   */
+  public static double cos(double a)
+  {
+    if (a == Double.NEGATIVE_INFINITY || ! (a < Double.POSITIVE_INFINITY))
+      return Double.NaN;
+
+    if (abs(a) <= PI / 4)
+      return cos(a, 0);
+
+    // Argument reduction needed.
+    double[] y = new double[2];
+    int n = remPiOver2(a, y);
+    switch (n & 3)
+      {
+      case 0:
+        return cos(y[0], y[1]);
+      case 1:
+        return -sin(y[0], y[1]);
+      case 2:
+        return -cos(y[0], y[1]);
+      default:
+        return sin(y[0], y[1]);
+      }
+  }
+
+  /**
+   * The trigonometric function <em>tan</em>. The tangent of NaN or infinity
+   * is NaN, and the tangent of 0 retains its sign.
+   *
+   * @param a the angle (in radians)
+   * @return tan(a)
+   */
+  public static double tan(double a)
+  {
+    if (a == Double.NEGATIVE_INFINITY || ! (a < Double.POSITIVE_INFINITY))
+      return Double.NaN;
+
+    if (abs(a) <= PI / 4)
+      return tan(a, 0, false);
+
+    // Argument reduction needed.
+    double[] y = new double[2];
+    int n = remPiOver2(a, y);
+    return tan(y[0], y[1], (n & 1) == 1);
+  }
+
+  /**
+   * The trigonometric function <em>arcsin</em>. The range of angles returned
+   * is -pi/2 to pi/2 radians (-90 to 90 degrees). If the argument is NaN or
+   * its absolute value is beyond 1, the result is NaN; and the arcsine of
+   * 0 retains its sign.
+   *
+   * @param x the sin to turn back into an angle
+   * @return arcsin(x)
+   */
+  public static double asin(double x)
+  {
+    boolean negative = x < 0;
+    if (negative)
+      x = -x;
+    if (! (x <= 1))
+      return Double.NaN;
+    if (x == 1)
+      return negative ? -PI / 2 : PI / 2;
+    if (x < 0.5)
+      {
+        if (x < 1 / TWO_27)
+          return negative ? -x : x;
+        double t = x * x;
+        double p = t * (PS0 + t * (PS1 + t * (PS2 + t * (PS3 + t
+                                                         * (PS4 + t * PS5)))));
+        double q = 1 + t * (QS1 + t * (QS2 + t * (QS3 + t * QS4)));
+        return negative ? -x - x * (p / q) : x + x * (p / q);
+      }
+    double w = 1 - x; // 1>|x|>=0.5.
+    double t = w * 0.5;
+    double p = t * (PS0 + t * (PS1 + t * (PS2 + t * (PS3 + t
+                                                     * (PS4 + t * PS5)))));
+    double q = 1 + t * (QS1 + t * (QS2 + t * (QS3 + t * QS4)));
+    double s = sqrt(t);
+    if (x >= 0.975)
+      {
+        w = p / q;
+        t = PI / 2 - (2 * (s + s * w) - PI_L / 2);
+      }
+    else
+      {
+        w = (float) s;
+        double c = (t - w * w) / (s + w);
+        p = 2 * s * (p / q) - (PI_L / 2 - 2 * c);
+        q = PI / 4 - 2 * w;
+        t = PI / 4 - (p - q);
+      }
+    return negative ? -t : t;
+  }
+
+  /**
+   * The trigonometric function <em>arccos</em>. The range of angles returned
+   * is 0 to pi radians (0 to 180 degrees). If the argument is NaN or
+   * its absolute value is beyond 1, the result is NaN.
+   *
+   * @param x the cos to turn back into an angle
+   * @return arccos(x)
+   */
+  public static double acos(double x)
+  {
+    boolean negative = x < 0;
+    if (negative)
+      x = -x;
+    if (! (x <= 1))
+      return Double.NaN;
+    if (x == 1)
+      return negative ? PI : 0;
+    if (x < 0.5)
+      {
+        if (x < 1 / TWO_57)
+          return PI / 2;
+        double z = x * x;
+        double p = z * (PS0 + z * (PS1 + z * (PS2 + z * (PS3 + z
+                                                         * (PS4 + z * PS5)))));
+        double q = 1 + z * (QS1 + z * (QS2 + z * (QS3 + z * QS4)));
+        double r = x - (PI_L / 2 - x * (p / q));
+        return negative ? PI / 2 + r : PI / 2 - r;
+      }
+    if (negative) // x<=-0.5.
+      {
+        double z = (1 + x) * 0.5;
+        double p = z * (PS0 + z * (PS1 + z * (PS2 + z * (PS3 + z
+                                                         * (PS4 + z * PS5)))));
+        double q = 1 + z * (QS1 + z * (QS2 + z * (QS3 + z * QS4)));
+        double s = sqrt(z);
+        double w = p / q * s - PI_L / 2;
+        return PI - 2 * (s + w);
+      }
+    double z = (1 - x) * 0.5; // x>0.5.
+    double s = sqrt(z);
+    double df = (float) s;
+    double c = (z - df * df) / (s + df);
+    double p = z * (PS0 + z * (PS1 + z * (PS2 + z * (PS3 + z
+                                                     * (PS4 + z * PS5)))));
+    double q = 1 + z * (QS1 + z * (QS2 + z * (QS3 + z * QS4)));
+    double w = p / q * s + c;
+    return 2 * (df + w);
+  }
+
+  /**
+   * The trigonometric function <em>arcsin</em>. The range of angles returned
+   * is -pi/2 to pi/2 radians (-90 to 90 degrees). If the argument is NaN, the
+   * result is NaN; and the arctangent of 0 retains its sign.
+   *
+   * @param x the tan to turn back into an angle
+   * @return arcsin(x)
+   * @see #atan2(double, double)
+   */
+  public static double atan(double x)
+  {
+    double lo;
+    double hi;
+    boolean negative = x < 0;
+    if (negative)
+      x = -x;
+    if (x >= TWO_66)
+      return negative ? -PI / 2 : PI / 2;
+    if (! (x >= 0.4375)) // |x|<7/16, or NaN.
+      {
+        if (! (x >= 1 / TWO_29)) // Small, or NaN.
+          return negative ? -x : x;
+        lo = hi = 0;
+      }
+    else if (x < 1.1875)
+      {
+        if (x < 0.6875) // 7/16<=|x|<11/16.
+          {
+            x = (2 * x - 1) / (2 + x);
+            hi = ATAN_0_5H;
+            lo = ATAN_0_5L;
+          }
+        else // 11/16<=|x|<19/16.
+          {
+            x = (x - 1) / (x + 1);
+            hi = PI / 4;
+            lo = PI_L / 4;
+          }
+      }
+    else if (x < 2.4375) // 19/16<=|x|<39/16.
+      {
+        x = (x - 1.5) / (1 + 1.5 * x);
+        hi = ATAN_1_5H;
+        lo = ATAN_1_5L;
+      }
+    else // 39/16<=|x|<2**66.
+      {
+        x = -1 / x;
+        hi = PI / 2;
+        lo = PI_L / 2;
+      }
+
+    // Break sum from i=0 to 10 ATi*z**(i+1) into odd and even poly.
+    double z = x * x;
+    double w = z * z;
+    double s1 = z * (AT0 + w * (AT2 + w * (AT4 + w * (AT6 + w
+                                                      * (AT8 + w * AT10)))));
+    double s2 = w * (AT1 + w * (AT3 + w * (AT5 + w * (AT7 + w * AT9))));
+    if (hi == 0)
+      return negative ? x * (s1 + s2) - x : x - x * (s1 + s2);
+    z = hi - ((x * (s1 + s2) - lo) - x);
+    return negative ? -z : z;
+  }
+
+  /**
+   * A special version of the trigonometric function <em>arctan</em>, for
+   * converting rectangular coordinates <em>(x, y)</em> to polar
+   * <em>(r, theta)</em>. This computes the arctangent of x/y in the range
+   * of -pi to pi radians (-180 to 180 degrees). Special cases:<ul>
+   * <li>If either argument is NaN, the result is NaN.</li>
+   * <li>If the first argument is positive zero and the second argument is
+   * positive, or the first argument is positive and finite and the second
+   * argument is positive infinity, then the result is positive zero.</li>
+   * <li>If the first argument is negative zero and the second argument is
+   * positive, or the first argument is negative and finite and the second
+   * argument is positive infinity, then the result is negative zero.</li>
+   * <li>If the first argument is positive zero and the second argument is
+   * negative, or the first argument is positive and finite and the second
+   * argument is negative infinity, then the result is the double value
+   * closest to pi.</li>
+   * <li>If the first argument is negative zero and the second argument is
+   * negative, or the first argument is negative and finite and the second
+   * argument is negative infinity, then the result is the double value
+   * closest to -pi.</li>
+   * <li>If the first argument is positive and the second argument is
+   * positive zero or negative zero, or the first argument is positive
+   * infinity and the second argument is finite, then the result is the
+   * double value closest to pi/2.</li>
+   * <li>If the first argument is negative and the second argument is
+   * positive zero or negative zero, or the first argument is negative
+   * infinity and the second argument is finite, then the result is the
+   * double value closest to -pi/2.</li>
+   * <li>If both arguments are positive infinity, then the result is the
+   * double value closest to pi/4.</li>
+   * <li>If the first argument is positive infinity and the second argument
+   * is negative infinity, then the result is the double value closest to
+   * 3*pi/4.</li>
+   * <li>If the first argument is negative infinity and the second argument
+   * is positive infinity, then the result is the double value closest to
+   * -pi/4.</li>
+   * <li>If both arguments are negative infinity, then the result is the
+   * double value closest to -3*pi/4.</li>
+   *
+   * </ul><p>This returns theta, the angle of the point. To get r, albeit
+   * slightly inaccurately, use sqrt(x*x+y*y).
+   *
+   * @param y the y position
+   * @param x the x position
+   * @return <em>theta</em> in the conversion of (x, y) to (r, theta)
+   * @see #atan(double)
+   */
+  public static double atan2(double y, double x)
+  {
+    if (x != x || y != y)
+      return Double.NaN;
+    if (x == 1)
+      return atan(y);
+    if (x == Double.POSITIVE_INFINITY)
+      {
+        if (y == Double.POSITIVE_INFINITY)
+          return PI / 4;
+        if (y == Double.NEGATIVE_INFINITY)
+          return -PI / 4;
+        return 0 * y;
+      }
+    if (x == Double.NEGATIVE_INFINITY)
+      {
+        if (y == Double.POSITIVE_INFINITY)
+          return 3 * PI / 4;
+        if (y == Double.NEGATIVE_INFINITY)
+          return -3 * PI / 4;
+        return (1 / (0 * y) == Double.POSITIVE_INFINITY) ? PI : -PI;
+      }
+    if (y == 0)
+      {
+        if (1 / (0 * x) == Double.POSITIVE_INFINITY)
+          return y;
+        return (1 / y == Double.POSITIVE_INFINITY) ? PI : -PI;
+      }
+    if (y == Double.POSITIVE_INFINITY || y == Double.NEGATIVE_INFINITY
+        || x == 0)
+      return y < 0 ? -PI / 2 : PI / 2;
+
+    double z = abs(y / x); // Safe to do y/x.
+    if (z > TWO_60)
+      z = PI / 2 + 0.5 * PI_L;
+    else if (x < 0 && z < 1 / TWO_60)
+      z = 0;
+    else
+      z = atan(z);
+    if (x > 0)
+      return y > 0 ? z : -z;
+    return y > 0 ? PI - (z - PI_L) : z - PI_L - PI;
+  }
+
+  /**
+   * Returns the hyperbolic cosine of <code>x</code>, which is defined as
+   * (exp(x) + exp(-x)) / 2.
+   *
+   * Special cases:
+   * <ul>
+   * <li>If the argument is NaN, the result is NaN</li>
+   * <li>If the argument is positive infinity, the result is positive
+   * infinity.</li>
+   * <li>If the argument is negative infinity, the result is positive
+   * infinity.</li>
+   * <li>If the argument is zero, the result is one.</li>
+   * </ul>
+   *
+   * @param x the argument to <em>cosh</em>
+   * @return the hyperbolic cosine of <code>x</code>
+   *
+   * @since 1.5
+   */
+  public static double cosh(double x)
+  {
+    // Method :
+    // mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2
+    // 1. Replace x by |x| (cosh(x) = cosh(-x)).
+    // 2.
+    //                                             [ exp(x) - 1 ]^2
+    //  0        <= x <= ln2/2  :  cosh(x) := 1 + -------------------
+    //                                                 2*exp(x)
+    //
+    //		                              exp(x) +  1/exp(x)
+    //  ln2/2    <= x <= 22     :  cosh(x) := ------------------
+    //		       			             2
+    //  22       <= x <= lnovft :  cosh(x) := exp(x)/2
+    //  lnovft   <= x <= ln2ovft:  cosh(x) := exp(x/2)/2 * exp(x/2)
+    //	ln2ovft  <  x	        :  cosh(x) := +inf  (overflow)
+
+    double t, w;
+    long bits;
+    int hx;
+    int lx;
+
+    // handle special cases
+    if (x != x)
+      return Double.NaN;
+    if (x == Double.POSITIVE_INFINITY)
+      return Double.POSITIVE_INFINITY;
+    if (x == Double.NEGATIVE_INFINITY)
+      return Double.POSITIVE_INFINITY;
+
+    bits = Double.doubleToLongBits(x);
+    hx = getHighDWord(bits) & 0x7fffffff;  // ignore sign
+    lx = getLowDWord(bits);
+
+    // |x| in [0, 0.5 * ln(2)], return 1 + expm1(|x|)^2 / (2 * exp(|x|))
+    if (hx < 0x3fd62e43)
+      {
+	t = expm1(abs(x));
+	w = 1.0 + t;
+
+	// for tiny arguments return 1.
+	if (hx < 0x3c800000)
+	  return w;
+
+	return 1.0 + (t * t) / (w + w);
+      }
+
+    // |x| in [0.5 * ln(2), 22], return exp(|x|)/2 + 1 / (2 * exp(|x|))
+    if (hx < 0x40360000)
+      {
+	t = exp(abs(x));
+
+	return 0.5 * t + 0.5 / t;
+      }
+
+    // |x| in [22, log(Double.MAX_VALUE)], return 0.5 * exp(|x|)
+    if (hx < 0x40862e42)
+      return 0.5 * exp(abs(x));
+
+    // |x| in [log(Double.MAX_VALUE), overflowthreshold],
+    // return exp(x/2)/2 * exp(x/2)
+
+    // we need to force an unsigned <= compare, thus can not use lx.
+    if ((hx < 0x408633ce)
+	|| ((hx == 0x408633ce)
+	    && ((bits & 0x00000000ffffffffL) <= 0x8fb9f87dL)))
+      {
+	w = exp(0.5 * abs(x));
+	t = 0.5 * w;
+
+	return t * w;
+      }
+
+    // |x| > overflowthreshold
+    return Double.POSITIVE_INFINITY;
+  }
+
+  /**
+   * Returns the lower two words of a long. This is intended to be
+   * used like this:
+   * <code>getLowDWord(Double.doubleToLongBits(x))</code>.
+   */
+  private static int getLowDWord(long x)
+  {
+    return (int) (x & 0x00000000ffffffffL);
+  }
+
+  /**
+   * Returns the higher two words of a long. This is intended to be
+   * used like this:
+   * <code>getHighDWord(Double.doubleToLongBits(x))</code>.
+   */
+  private static int getHighDWord(long x)
+  {
+    return (int) ((x & 0xffffffff00000000L) >> 32);
+  }
+
+  /**
+   * Returns a double with the IEEE754 bit pattern given in the lower
+   * and higher two words <code>lowDWord</code> and <code>highDWord</code>.
+   */
+  private static double buildDouble(int lowDWord, int highDWord)
+  {
+    return Double.longBitsToDouble((((long) highDWord & 0xffffffffL) << 32)
+				   | ((long) lowDWord & 0xffffffffL));
+  }
+
+  /**
+   * Returns the cube root of <code>x</code>. The sign of the cube root
+   * is equal to the sign of <code>x</code>.
+   *
+   * Special cases:
+   * <ul>
+   * <li>If the argument is NaN, the result is NaN</li>
+   * <li>If the argument is positive infinity, the result is positive
+   * infinity.</li>
+   * <li>If the argument is negative infinity, the result is negative
+   * infinity.</li>
+   * <li>If the argument is zero, the result is zero with the same
+   * sign as the argument.</li>
+   * </ul>
+   *
+   * @param x the number to take the cube root of
+   * @return the cube root of <code>x</code>
+   * @see #sqrt(double)
+   *
+   * @since 1.5
+   */
+  public static double cbrt(double x)
+  {
+    boolean negative = (x < 0);
+    double r;
+    double s;
+    double t;
+    double w;
+
+    long bits;
+    int l;
+    int h;
+
+    // handle the special cases
+    if (x != x)
+      return Double.NaN;
+    if (x == Double.POSITIVE_INFINITY)
+      return Double.POSITIVE_INFINITY;
+    if (x == Double.NEGATIVE_INFINITY)
+      return Double.NEGATIVE_INFINITY;
+    if (x == 0)
+      return x;
+
+    x = abs(x);
+    bits = Double.doubleToLongBits(x);
+
+    if (bits < 0x0010000000000000L)   // subnormal number
+      {
+	t = TWO_54;
+	t *= x;
+
+	// __HI(t)=__HI(t)/3+B2;
+	bits = Double.doubleToLongBits(t);
+	h = getHighDWord(bits);
+	l = getLowDWord(bits);
+
+	h = h / 3 + CBRT_B2;
+
+	t = buildDouble(l, h);
+      }
+    else
+      {
+	// __HI(t)=__HI(x)/3+B1;
+	h = getHighDWord(bits);
+	l = 0;
+
+	h = h / 3 + CBRT_B1;
+	t = buildDouble(l, h);
+      }
+
+    // new cbrt to 23 bits
+    r =  t * t / x;
+    s =  CBRT_C + r * t;
+    t *= CBRT_G + CBRT_F / (s + CBRT_E + CBRT_D / s);
+
+    // chopped to 20 bits and make it larger than cbrt(x)
+    bits = Double.doubleToLongBits(t);
+    h = getHighDWord(bits);
+
+    // __LO(t)=0;
+    // __HI(t)+=0x00000001;
+    l = 0;
+    h += 1;
+    t = buildDouble(l, h);
+
+    // one step newton iteration to 53 bits with error less than 0.667 ulps
+    s = t * t;		    // t * t is exact
+    r = x / s;
+    w = t + t;
+    r = (r - t) / (w + r);  // r - s is exact
+    t = t + t * r;
+
+    return negative ? -t : t;
+  }
+
+  /**
+   * Take <em>e</em><sup>a</sup>.  The opposite of <code>log()</code>. If the
+   * argument is NaN, the result is NaN; if the argument is positive infinity,
+   * the result is positive infinity; and if the argument is negative
+   * infinity, the result is positive zero.
+   *
+   * @param x the number to raise to the power
+   * @return the number raised to the power of <em>e</em>
+   * @see #log(double)
+   * @see #pow(double, double)
+   */
+  public static double exp(double x)
+  {
+    if (x != x)
+      return x;
+    if (x > EXP_LIMIT_H)
+      return Double.POSITIVE_INFINITY;
+    if (x < EXP_LIMIT_L)
+      return 0;
+
+    // Argument reduction.
+    double hi;
+    double lo;
+    int k;
+    double t = abs(x);
+    if (t > 0.5 * LN2)
+      {
+        if (t < 1.5 * LN2)
+          {
+            hi = t - LN2_H;
+            lo = LN2_L;
+            k = 1;
+          }
+        else
+          {
+            k = (int) (INV_LN2 * t + 0.5);
+            hi = t - k * LN2_H;
+            lo = k * LN2_L;
+          }
+        if (x < 0)
+          {
+            hi = -hi;
+            lo = -lo;
+            k = -k;
+          }
+        x = hi - lo;
+      }
+    else if (t < 1 / TWO_28)
+      return 1;
+    else
+      lo = hi = k = 0;
+
+    // Now x is in primary range.
+    t = x * x;
+    double c = x - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));
+    if (k == 0)
+      return 1 - (x * c / (c - 2) - x);
+    double y = 1 - (lo - x * c / (2 - c) - hi);
+    return scale(y, k);
+  }
+
+  /**
+   * Returns <em>e</em><sup>x</sup> - 1.
+   * Special cases:
+   * <ul>
+   * <li>If the argument is NaN, the result is NaN.</li>
+   * <li>If the argument is positive infinity, the result is positive
+   * infinity</li>
+   * <li>If the argument is negative infinity, the result is -1.</li>
+   * <li>If the argument is zero, the result is zero.</li>
+   * </ul>
+   *
+   * @param x the argument to <em>e</em><sup>x</sup> - 1.
+   * @return <em>e</em> raised to the power <code>x</code> minus one.
+   * @see #exp(double)
+   */
+  public static double expm1(double x)
+  {
+    // Method
+    //   1. Argument reduction:
+    //	Given x, find r and integer k such that
+    //
+    //            x = k * ln(2) + r,  |r| <= 0.5 * ln(2)
+    //
+    //  Here a correction term c will be computed to compensate
+    //	the error in r when rounded to a floating-point number.
+    //
+    //   2. Approximating expm1(r) by a special rational function on
+    //	the interval [0, 0.5 * ln(2)]:
+    //	Since
+    //	    r*(exp(r)+1)/(exp(r)-1) = 2 + r^2/6 - r^4/360 + ...
+    //	we define R1(r*r) by
+    //	    r*(exp(r)+1)/(exp(r)-1) = 2 + r^2/6 * R1(r*r)
+    //	That is,
+    //	    R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r)
+    //		     = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r))
+    //		     = 1 - r^2/60 + r^4/2520 - r^6/100800 + ...
+    //  We use a special Remes algorithm on [0, 0.347] to generate
+    // 	a polynomial of degree 5 in r*r to approximate R1. The
+    //	maximum error of this polynomial approximation is bounded
+    //	by 2**-61. In other words,
+    //	    R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5
+    //	where 	Q1  =  -1.6666666666666567384E-2,
+    // 		Q2  =   3.9682539681370365873E-4,
+    // 		Q3  =  -9.9206344733435987357E-6,
+    // 		Q4  =   2.5051361420808517002E-7,
+    // 		Q5  =  -6.2843505682382617102E-9;
+    //  	(where z=r*r, and Q1 to Q5 are called EXPM1_Qx in the source)
+    //	with error bounded by
+    //	    |                  5           |     -61
+    //	    | 1.0+Q1*z+...+Q5*z   -  R1(z) | <= 2
+    //	    |                              |
+    //
+    //	expm1(r) = exp(r)-1 is then computed by the following
+    // 	specific way which minimize the accumulation rounding error:
+    //			       2     3
+    //			      r     r    [ 3 - (R1 + R1*r/2)  ]
+    //	      expm1(r) = r + --- + --- * [--------------------]
+    //		              2     2    [ 6 - r*(3 - R1*r/2) ]
+    //
+    //	To compensate the error in the argument reduction, we use
+    //		expm1(r+c) = expm1(r) + c + expm1(r)*c
+    //			   ~ expm1(r) + c + r*c
+    //	Thus c+r*c will be added in as the correction terms for
+    //	expm1(r+c). Now rearrange the term to avoid optimization
+    // 	screw up:
+    //		        (      2                                    2 )
+    //		        ({  ( r    [ R1 -  (3 - R1*r/2) ]  )  }    r  )
+    //	 expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- )
+    //	                ({  ( 2    [ 6 - r*(3 - R1*r/2) ]  )  }    2  )
+    //                      (                                             )
+    //
+    //		   = r - E
+    //   3. Scale back to obtain expm1(x):
+    //	From step 1, we have
+    //	   expm1(x) = either 2^k*[expm1(r)+1] - 1
+    //		    = or     2^k*[expm1(r) + (1-2^-k)]
+    //   4. Implementation notes:
+    //	(A). To save one multiplication, we scale the coefficient Qi
+    //	     to Qi*2^i, and replace z by (x^2)/2.
+    //	(B). To achieve maximum accuracy, we compute expm1(x) by
+    //	  (i)   if x < -56*ln2, return -1.0, (raise inexact if x!=inf)
+    //	  (ii)  if k=0, return r-E
+    //	  (iii) if k=-1, return 0.5*(r-E)-0.5
+    //        (iv)	if k=1 if r < -0.25, return 2*((r+0.5)- E)
+    //	       	       else	     return  1.0+2.0*(r-E);
+    //	  (v)   if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1)
+    //	  (vi)  if k <= 20, return 2^k((1-2^-k)-(E-r)), else
+    //	  (vii) return 2^k(1-((E+2^-k)-r))
+
+    boolean negative = (x < 0);
+    double y, hi, lo, c, t, e, hxs, hfx, r1;
+    int k;
+
+    long bits;
+    int h_bits;
+    int l_bits;
+
+    c = 0.0;
+    y = abs(x);
+
+    bits = Double.doubleToLongBits(y);
+    h_bits = getHighDWord(bits);
+    l_bits = getLowDWord(bits);
+
+    // handle special cases and large arguments
+    if (h_bits >= 0x4043687a)        // if |x| >= 56 * ln(2)
+      {
+	if (h_bits >= 0x40862e42)    // if |x| >= EXP_LIMIT_H
+	  {
+	    if (h_bits >= 0x7ff00000)
+	      {
+		if (((h_bits & 0x000fffff) | (l_bits & 0xffffffff)) != 0)
+		  return Double.NaN;               // exp(NaN) = NaN
+		else
+		  return negative ? -1.0 : x;      // exp({+-inf}) = {+inf, -1}
+	      }
+
+	    if (x > EXP_LIMIT_H)
+	      return Double.POSITIVE_INFINITY;     // overflow
+	  }
+
+	if (negative)                // x <= -56 * ln(2)
+	  return -1.0;
+      }
+
+    // argument reduction
+    if (h_bits > 0x3fd62e42)         // |x| > 0.5 * ln(2)
+      {
+	if (h_bits < 0x3ff0a2b2)     // |x| < 1.5 * ln(2)
+	  {
+	    if (negative)
+	      {
+		hi = x + LN2_H;
+		lo = -LN2_L;
+		k = -1;
+	      }
+	    else
+	      {
+		hi = x - LN2_H;
+		lo = LN2_L;
+		k  = 1;
+	      }
+	  }
+	else
+	  {
+	    k = (int) (INV_LN2 * x + (negative ? - 0.5 : 0.5));
+	    t = k;
+	    hi = x - t * LN2_H;
+	    lo = t * LN2_L;
+	  }
+
+	x = hi - lo;
+	c = (hi - x) - lo;
+
+      }
+    else if (h_bits < 0x3c900000)    // |x| < 2^-54 return x
+      return x;
+    else
+      k = 0;
+
+    // x is now in primary range
+    hfx = 0.5 * x;
+    hxs = x * hfx;
+    r1 = 1.0 + hxs * (EXPM1_Q1
+	     + hxs * (EXPM1_Q2
+             + hxs * (EXPM1_Q3
+	     + hxs * (EXPM1_Q4
+	     + hxs *  EXPM1_Q5))));
+    t = 3.0 - r1 * hfx;
+    e = hxs * ((r1 - t) / (6.0 - x * t));
+
+    if (k == 0)
+      {
+	return x - (x * e - hxs);    // c == 0
+      }
+    else
+      {
+	e = x * (e - c) - c;
+	e -= hxs;
+
+	if (k == -1)
+	  return 0.5 * (x - e) - 0.5;
+
+	if (k == 1)
+	  {
+	    if (x < - 0.25)
+	      return -2.0 * (e - (x + 0.5));
+	    else
+	      return 1.0 + 2.0 * (x - e);
+	  }
+
+	if (k <= -2 || k > 56)       // sufficient to return exp(x) - 1
+	  {
+	    y = 1.0 - (e - x);
+
+	    bits = Double.doubleToLongBits(y);
+	    h_bits = getHighDWord(bits);
+	    l_bits = getLowDWord(bits);
+
+	    h_bits += (k << 20);     // add k to y's exponent
+
+	    y = buildDouble(l_bits, h_bits);
+
+	    return y - 1.0;
+	  }
+
+	t = 1.0;
+	if (k < 20)
+	  {
+	    bits = Double.doubleToLongBits(t);
+	    h_bits = 0x3ff00000 - (0x00200000 >> k);
+	    l_bits = getLowDWord(bits);
+
+	    t = buildDouble(l_bits, h_bits);      // t = 1 - 2^(-k)
+	    y = t - (e - x);
+
+	    bits = Double.doubleToLongBits(y);
+	    h_bits = getHighDWord(bits);
+	    l_bits = getLowDWord(bits);
+
+	    h_bits += (k << 20);     // add k to y's exponent
+
+	    y = buildDouble(l_bits, h_bits);
+	  }
+	else
+	  {
+	    bits = Double.doubleToLongBits(t);
+	    h_bits = (0x000003ff - k) << 20;
+	    l_bits = getLowDWord(bits);
+
+	    t = buildDouble(l_bits, h_bits);      // t = 2^(-k)
+
+	    y = x - (e + t);
+	    y += 1.0;
+
+	    bits = Double.doubleToLongBits(y);
+	    h_bits = getHighDWord(bits);
+	    l_bits = getLowDWord(bits);
+
+	    h_bits += (k << 20);     // add k to y's exponent
+
+	    y = buildDouble(l_bits, h_bits);
+	  }
+      }
+
+    return y;
+  }
+
+  /**
+   * Take ln(a) (the natural log).  The opposite of <code>exp()</code>. If the
+   * argument is NaN or negative, the result is NaN; if the argument is
+   * positive infinity, the result is positive infinity; and if the argument
+   * is either zero, the result is negative infinity.
+   *
+   * <p>Note that the way to get log<sub>b</sub>(a) is to do this:
+   * <code>ln(a) / ln(b)</code>.
+   *
+   * @param x the number to take the natural log of
+   * @return the natural log of <code>a</code>
+   * @see #exp(double)
+   */
+  public static double log(double x)
+  {
+    if (x == 0)
+      return Double.NEGATIVE_INFINITY;
+    if (x < 0)
+      return Double.NaN;
+    if (! (x < Double.POSITIVE_INFINITY))
+      return x;
+
+    // Normalize x.
+    long bits = Double.doubleToLongBits(x);
+    int exp = (int) (bits >> 52);
+    if (exp == 0) // Subnormal x.
+      {
+        x *= TWO_54;
+        bits = Double.doubleToLongBits(x);
+        exp = (int) (bits >> 52) - 54;
+      }
+    exp -= 1023; // Unbias exponent.
+    bits = (bits & 0x000fffffffffffffL) | 0x3ff0000000000000L;
+    x = Double.longBitsToDouble(bits);
+    if (x >= SQRT_2)
+      {
+        x *= 0.5;
+        exp++;
+      }
+    x--;
+    if (abs(x) < 1 / TWO_20)
+      {
+        if (x == 0)
+          return exp * LN2_H + exp * LN2_L;
+        double r = x * x * (0.5 - 1 / 3.0 * x);
+        if (exp == 0)
+          return x - r;
+        return exp * LN2_H - ((r - exp * LN2_L) - x);
+      }
+    double s = x / (2 + x);
+    double z = s * s;
+    double w = z * z;
+    double t1 = w * (LG2 + w * (LG4 + w * LG6));
+    double t2 = z * (LG1 + w * (LG3 + w * (LG5 + w * LG7)));
+    double r = t2 + t1;
+    if (bits >= 0x3ff6174a00000000L && bits < 0x3ff6b85200000000L)
+      {
+        double h = 0.5 * x * x; // Need more accuracy for x near sqrt(2).
+        if (exp == 0)
+          return x - (h - s * (h + r));
+        return exp * LN2_H - ((h - (s * (h + r) + exp * LN2_L)) - x);
+      }
+    if (exp == 0)
+      return x - s * (x - r);
+    return exp * LN2_H - ((s * (x - r) - exp * LN2_L) - x);
+  }
+
+  /**
+   * Take a square root. If the argument is NaN or negative, the result is
+   * NaN; if the argument is positive infinity, the result is positive
+   * infinity; and if the result is either zero, the result is the same.
+   *
+   * <p>For other roots, use pow(x, 1/rootNumber).
+   *
+   * @param x the numeric argument
+   * @return the square root of the argument
+   * @see #pow(double, double)
+   */
+  public static double sqrt(double x)
+  {
+    if (x < 0)
+      return Double.NaN;
+    if (x == 0 || ! (x < Double.POSITIVE_INFINITY))
+      return x;
+
+    // Normalize x.
+    long bits = Double.doubleToLongBits(x);
+    int exp = (int) (bits >> 52);
+    if (exp == 0) // Subnormal x.
+      {
+        x *= TWO_54;
+        bits = Double.doubleToLongBits(x);
+        exp = (int) (bits >> 52) - 54;
+      }
+    exp -= 1023; // Unbias exponent.
+    bits = (bits & 0x000fffffffffffffL) | 0x0010000000000000L;
+    if ((exp & 1) == 1) // Odd exp, double x to make it even.
+      bits <<= 1;
+    exp >>= 1;
+
+    // Generate sqrt(x) bit by bit.
+    bits <<= 1;
+    long q = 0;
+    long s = 0;
+    long r = 0x0020000000000000L; // Move r right to left.
+    while (r != 0)
+      {
+        long t = s + r;
+        if (t <= bits)
+          {
+            s = t + r;
+            bits -= t;
+            q += r;
+          }
+        bits <<= 1;
+        r >>= 1;
+      }
+
+    // Use floating add to round correctly.
+    if (bits != 0)
+      q += q & 1;
+    return Double.longBitsToDouble((q >> 1) + ((exp + 1022L) << 52));
+  }
+
+  /**
+   * Raise a number to a power. Special cases:<ul>
+   * <li>If the second argument is positive or negative zero, then the result
+   * is 1.0.</li>
+   * <li>If the second argument is 1.0, then the result is the same as the
+   * first argument.</li>
+   * <li>If the second argument is NaN, then the result is NaN.</li>
+   * <li>If the first argument is NaN and the second argument is nonzero,
+   * then the result is NaN.</li>
+   * <li>If the absolute value of the first argument is greater than 1 and
+   * the second argument is positive infinity, or the absolute value of the
+   * first argument is less than 1 and the second argument is negative
+   * infinity, then the result is positive infinity.</li>
+   * <li>If the absolute value of the first argument is greater than 1 and
+   * the second argument is negative infinity, or the absolute value of the
+   * first argument is less than 1 and the second argument is positive
+   * infinity, then the result is positive zero.</li>
+   * <li>If the absolute value of the first argument equals 1 and the second
+   * argument is infinite, then the result is NaN.</li>
+   * <li>If the first argument is positive zero and the second argument is
+   * greater than zero, or the first argument is positive infinity and the
+   * second argument is less than zero, then the result is positive zero.</li>
+   * <li>If the first argument is positive zero and the second argument is
+   * less than zero, or the first argument is positive infinity and the
+   * second argument is greater than zero, then the result is positive
+   * infinity.</li>
+   * <li>If the first argument is negative zero and the second argument is
+   * greater than zero but not a finite odd integer, or the first argument is
+   * negative infinity and the second argument is less than zero but not a
+   * finite odd integer, then the result is positive zero.</li>
+   * <li>If the first argument is negative zero and the second argument is a
+   * positive finite odd integer, or the first argument is negative infinity
+   * and the second argument is a negative finite odd integer, then the result
+   * is negative zero.</li>
+   * <li>If the first argument is negative zero and the second argument is
+   * less than zero but not a finite odd integer, or the first argument is
+   * negative infinity and the second argument is greater than zero but not a
+   * finite odd integer, then the result is positive infinity.</li>
+   * <li>If the first argument is negative zero and the second argument is a
+   * negative finite odd integer, or the first argument is negative infinity
+   * and the second argument is a positive finite odd integer, then the result
+   * is negative infinity.</li>
+   * <li>If the first argument is less than zero and the second argument is a
+   * finite even integer, then the result is equal to the result of raising
+   * the absolute value of the first argument to the power of the second
+   * argument.</li>
+   * <li>If the first argument is less than zero and the second argument is a
+   * finite odd integer, then the result is equal to the negative of the
+   * result of raising the absolute value of the first argument to the power
+   * of the second argument.</li>
+   * <li>If the first argument is finite and less than zero and the second
+   * argument is finite and not an integer, then the result is NaN.</li>
+   * <li>If both arguments are integers, then the result is exactly equal to
+   * the mathematical result of raising the first argument to the power of
+   * the second argument if that result can in fact be represented exactly as
+   * a double value.</li>
+   *
+   * </ul><p>(In the foregoing descriptions, a floating-point value is
+   * considered to be an integer if and only if it is a fixed point of the
+   * method {@link #ceil(double)} or, equivalently, a fixed point of the
+   * method {@link #floor(double)}. A value is a fixed point of a one-argument
+   * method if and only if the result of applying the method to the value is
+   * equal to the value.)
+   *
+   * @param x the number to raise
+   * @param y the power to raise it to
+   * @return x<sup>y</sup>
+   */
+  public static double pow(double x, double y)
+  {
+    // Special cases first.
+    if (y == 0)
+      return 1;
+    if (y == 1)
+      return x;
+    if (y == -1)
+      return 1 / x;
+    if (x != x || y != y)
+      return Double.NaN;
+
+    // When x < 0, yisint tells if y is not an integer (0), even(1),
+    // or odd (2).
+    int yisint = 0;
+    if (x < 0 && floor(y) == y)
+      yisint = (y % 2 == 0) ? 2 : 1;
+    double ax = abs(x);
+    double ay = abs(y);
+
+    // More special cases, of y.
+    if (ay == Double.POSITIVE_INFINITY)
+      {
+        if (ax == 1)
+          return Double.NaN;
+        if (ax > 1)
+          return y > 0 ? y : 0;
+        return y < 0 ? -y : 0;
+      }
+    if (y == 2)
+      return x * x;
+    if (y == 0.5)
+      return sqrt(x);
+
+    // More special cases, of x.
+    if (x == 0 || ax == Double.POSITIVE_INFINITY || ax == 1)
+      {
+        if (y < 0)
+          ax = 1 / ax;
+        if (x < 0)
+          {
+            if (x == -1 && yisint == 0)
+              ax = Double.NaN;
+            else if (yisint == 1)
+              ax = -ax;
+          }
+        return ax;
+      }
+    if (x < 0 && yisint == 0)
+      return Double.NaN;
+
+    // Now we can start!
+    double t;
+    double t1;
+    double t2;
+    double u;
+    double v;
+    double w;
+    if (ay > TWO_31)
+      {
+        if (ay > TWO_64) // Automatic over/underflow.
+          return ((ax < 1) ? y < 0 : y > 0) ? Double.POSITIVE_INFINITY : 0;
+        // Over/underflow if x is not close to one.
+        if (ax < 0.9999995231628418)
+          return y < 0 ? Double.POSITIVE_INFINITY : 0;
+        if (ax >= 1.0000009536743164)
+          return y > 0 ? Double.POSITIVE_INFINITY : 0;
+        // Now |1-x| is <= 2**-20, sufficient to compute
+        // log(x) by x-x^2/2+x^3/3-x^4/4.
+        t = x - 1;
+        w = t * t * (0.5 - t * (1 / 3.0 - t * 0.25));
+        u = INV_LN2_H * t;
+        v = t * INV_LN2_L - w * INV_LN2;
+        t1 = (float) (u + v);
+        t2 = v - (t1 - u);
+      }
+    else
+    {
+      long bits = Double.doubleToLongBits(ax);
+      int exp = (int) (bits >> 52);
+      if (exp == 0) // Subnormal x.
+        {
+          ax *= TWO_54;
+          bits = Double.doubleToLongBits(ax);
+          exp = (int) (bits >> 52) - 54;
+        }
+      exp -= 1023; // Unbias exponent.
+      ax = Double.longBitsToDouble((bits & 0x000fffffffffffffL)
+                                   | 0x3ff0000000000000L);
+      boolean k;
+      if (ax < SQRT_1_5)  // |x|<sqrt(3/2).
+        k = false;
+      else if (ax < SQRT_3) // |x|<sqrt(3).
+        k = true;
+      else
+        {
+          k = false;
+          ax *= 0.5;
+          exp++;
+        }
+
+      // Compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5).
+      u = ax - (k ? 1.5 : 1);
+      v = 1 / (ax + (k ? 1.5 : 1));
+      double s = u * v;
+      double s_h = (float) s;
+      double t_h = (float) (ax + (k ? 1.5 : 1));
+      double t_l = ax - (t_h - (k ? 1.5 : 1));
+      double s_l = v * ((u - s_h * t_h) - s_h * t_l);
+      // Compute log(ax).
+      double s2 = s * s;
+      double r = s_l * (s_h + s) + s2 * s2
+        * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6)))));
+      s2 = s_h * s_h;
+      t_h = (float) (3.0 + s2 + r);
+      t_l = r - (t_h - 3.0 - s2);
+      // u+v = s*(1+...).
+      u = s_h * t_h;
+      v = s_l * t_h + t_l * s;
+      // 2/(3log2)*(s+...).
+      double p_h = (float) (u + v);
+      double p_l = v - (p_h - u);
+      double z_h = CP_H * p_h;
+      double z_l = CP_L * p_h + p_l * CP + (k ? DP_L : 0);
+      // log2(ax) = (s+..)*2/(3*log2) = exp + dp_h + z_h + z_l.
+      t = exp;
+      t1 = (float) (z_h + z_l + (k ? DP_H : 0) + t);
+      t2 = z_l - (t1 - t - (k ? DP_H : 0) - z_h);
+    }
+
+    // Split up y into y1+y2 and compute (y1+y2)*(t1+t2).
+    boolean negative = x < 0 && yisint == 1;
+    double y1 = (float) y;
+    double p_l = (y - y1) * t1 + y * t2;
+    double p_h = y1 * t1;
+    double z = p_l + p_h;
+    if (z >= 1024) // Detect overflow.
+      {
+        if (z > 1024 || p_l + OVT > z - p_h)
+          return negative ? Double.NEGATIVE_INFINITY
+            : Double.POSITIVE_INFINITY;
+      }
+    else if (z <= -1075) // Detect underflow.
+      {
+        if (z < -1075 || p_l <= z - p_h)
+          return negative ? -0.0 : 0;
+      }
+
+    // Compute 2**(p_h+p_l).
+    int n = round((float) z);
+    p_h -= n;
+    t = (float) (p_l + p_h);
+    u = t * LN2_H;
+    v = (p_l - (t - p_h)) * LN2 + t * LN2_L;
+    z = u + v;
+    w = v - (z - u);
+    t = z * z;
+    t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));
+    double r = (z * t1) / (t1 - 2) - (w + z * w);
+    z = scale(1 - (r - z), n);
+    return negative ? -z : z;
+  }
+
+  /**
+   * Get the IEEE 754 floating point remainder on two numbers. This is the
+   * value of <code>x - y * <em>n</em></code>, where <em>n</em> is the closest
+   * double to <code>x / y</code> (ties go to the even n); for a zero
+   * remainder, the sign is that of <code>x</code>. If either argument is NaN,
+   * the first argument is infinite, or the second argument is zero, the result
+   * is NaN; if x is finite but y is infinite, the result is x.
+   *
+   * @param x the dividend (the top half)
+   * @param y the divisor (the bottom half)
+   * @return the IEEE 754-defined floating point remainder of x/y
+   * @see #rint(double)
+   */
+  public static double IEEEremainder(double x, double y)
+  {
+    // Purge off exception values.
+    if (x == Double.NEGATIVE_INFINITY || ! (x < Double.POSITIVE_INFINITY)
+        || y == 0 || y != y)
+      return Double.NaN;
+
+    boolean negative = x < 0;
+    x = abs(x);
+    y = abs(y);
+    if (x == y || x == 0)
+      return 0 * x; // Get correct sign.
+
+    // Achieve x < 2y, then take first shot at remainder.
+    if (y < TWO_1023)
+      x %= y + y;
+
+    // Now adjust x to get correct precision.
+    if (y < 4 / TWO_1023)
+      {
+        if (x + x > y)
+          {
+            x -= y;
+            if (x + x >= y)
+              x -= y;
+          }
+      }
+    else
+      {
+        y *= 0.5;
+        if (x > y)
+          {
+            x -= y;
+            if (x >= y)
+              x -= y;
+          }
+      }
+    return negative ? -x : x;
+  }
+
+  /**
+   * Take the nearest integer that is that is greater than or equal to the
+   * argument. If the argument is NaN, infinite, or zero, the result is the
+   * same; if the argument is between -1 and 0, the result is negative zero.
+   * Note that <code>Math.ceil(x) == -Math.floor(-x)</code>.
+   *
+   * @param a the value to act upon
+   * @return the nearest integer >= <code>a</code>
+   */
+  public static double ceil(double a)
+  {
+    return -floor(-a);
+  }
+
+  /**
+   * Take the nearest integer that is that is less than or equal to the
+   * argument. If the argument is NaN, infinite, or zero, the result is the
+   * same. Note that <code>Math.ceil(x) == -Math.floor(-x)</code>.
+   *
+   * @param a the value to act upon
+   * @return the nearest integer <= <code>a</code>
+   */
+  public static double floor(double a)
+  {
+    double x = abs(a);
+    if (! (x < TWO_52) || (long) a == a)
+      return a; // No fraction bits; includes NaN and infinity.
+    if (x < 1)
+      return a >= 0 ? 0 * a : -1; // Worry about signed zero.
+    return a < 0 ? (long) a - 1.0 : (long) a; // Cast to long truncates.
+  }
+
+  /**
+   * Take the nearest integer to the argument.  If it is exactly between
+   * two integers, the even integer is taken. If the argument is NaN,
+   * infinite, or zero, the result is the same.
+   *
+   * @param a the value to act upon
+   * @return the nearest integer to <code>a</code>
+   */
+  public static double rint(double a)
+  {
+    double x = abs(a);
+    if (! (x < TWO_52))
+      return a; // No fraction bits; includes NaN and infinity.
+    if (x <= 0.5)
+      return 0 * a; // Worry about signed zero.
+    if (x % 2 <= 0.5)
+      return (long) a; // Catch round down to even.
+    return (long) (a + (a < 0 ? -0.5 : 0.5)); // Cast to long truncates.
+  }
+
+  /**
+   * Take the nearest integer to the argument.  This is equivalent to
+   * <code>(int) Math.floor(f + 0.5f)</code>. If the argument is NaN, the
+   * result is 0; otherwise if the argument is outside the range of int, the
+   * result will be Integer.MIN_VALUE or Integer.MAX_VALUE, as appropriate.
+   *
+   * @param f the argument to round
+   * @return the nearest integer to the argument
+   * @see Integer#MIN_VALUE
+   * @see Integer#MAX_VALUE
+   */
+  public static int round(float f)
+  {
+    return (int) floor(f + 0.5f);
+  }
+
+  /**
+   * Take the nearest long to the argument.  This is equivalent to
+   * <code>(long) Math.floor(d + 0.5)</code>. If the argument is NaN, the
+   * result is 0; otherwise if the argument is outside the range of long, the
+   * result will be Long.MIN_VALUE or Long.MAX_VALUE, as appropriate.
+   *
+   * @param d the argument to round
+   * @return the nearest long to the argument
+   * @see Long#MIN_VALUE
+   * @see Long#MAX_VALUE
+   */
+  public static long round(double d)
+  {
+    return (long) floor(d + 0.5);
+  }
+
+  /**
+   * Get a random number.  This behaves like Random.nextDouble(), seeded by
+   * System.currentTimeMillis() when first called. In other words, the number
+   * is from a pseudorandom sequence, and lies in the range [+0.0, 1.0).
+   * This random sequence is only used by this method, and is threadsafe,
+   * although you may want your own random number generator if it is shared
+   * among threads.
+   *
+   * @return a random number
+   * @see Random#nextDouble()
+   * @see System#currentTimeMillis()
+   */
+  public static synchronized double random()
+  {
+    if (rand == null)
+      rand = new Random();
+    return rand.nextDouble();
+  }
+
+  /**
+   * Convert from degrees to radians. The formula for this is
+   * radians = degrees * (pi/180); however it is not always exact given the
+   * limitations of floating point numbers.
+   *
+   * @param degrees an angle in degrees
+   * @return the angle in radians
+   */
+  public static double toRadians(double degrees)
+  {
+    return (degrees * PI) / 180;
+  }
+
+  /**
+   * Convert from radians to degrees. The formula for this is
+   * degrees = radians * (180/pi); however it is not always exact given the
+   * limitations of floating point numbers.
+   *
+   * @param rads an angle in radians
+   * @return the angle in degrees
+   */
+  public static double toDegrees(double rads)
+  {
+    return (rads * 180) / PI;
+  }
+
+  /**
+   * Constants for scaling and comparing doubles by powers of 2. The compiler
+   * must automatically inline constructs like (1/TWO_54), so we don't list
+   * negative powers of two here.
+   */
+  private static final double
+    TWO_16 = 0x10000, // Long bits 0x40f0000000000000L.
+    TWO_20 = 0x100000, // Long bits 0x4130000000000000L.
+    TWO_24 = 0x1000000, // Long bits 0x4170000000000000L.
+    TWO_27 = 0x8000000, // Long bits 0x41a0000000000000L.
+    TWO_28 = 0x10000000, // Long bits 0x41b0000000000000L.
+    TWO_29 = 0x20000000, // Long bits 0x41c0000000000000L.
+    TWO_31 = 0x80000000L, // Long bits 0x41e0000000000000L.
+    TWO_49 = 0x2000000000000L, // Long bits 0x4300000000000000L.
+    TWO_52 = 0x10000000000000L, // Long bits 0x4330000000000000L.
+    TWO_54 = 0x40000000000000L, // Long bits 0x4350000000000000L.
+    TWO_57 = 0x200000000000000L, // Long bits 0x4380000000000000L.
+    TWO_60 = 0x1000000000000000L, // Long bits 0x43b0000000000000L.
+    TWO_64 = 1.8446744073709552e19, // Long bits 0x43f0000000000000L.
+    TWO_66 = 7.378697629483821e19, // Long bits 0x4410000000000000L.
+    TWO_1023 = 8.98846567431158e307; // Long bits 0x7fe0000000000000L.
+
+  /**
+   * Super precision for 2/pi in 24-bit chunks, for use in
+   * {@link #remPiOver2(double, double[])}.
+   */
+  private static final int TWO_OVER_PI[] = {
+    0xa2f983, 0x6e4e44, 0x1529fc, 0x2757d1, 0xf534dd, 0xc0db62,
+    0x95993c, 0x439041, 0xfe5163, 0xabdebb, 0xc561b7, 0x246e3a,
+    0x424dd2, 0xe00649, 0x2eea09, 0xd1921c, 0xfe1deb, 0x1cb129,
+    0xa73ee8, 0x8235f5, 0x2ebb44, 0x84e99c, 0x7026b4, 0x5f7e41,
+    0x3991d6, 0x398353, 0x39f49c, 0x845f8b, 0xbdf928, 0x3b1ff8,
+    0x97ffde, 0x05980f, 0xef2f11, 0x8b5a0a, 0x6d1f6d, 0x367ecf,
+    0x27cb09, 0xb74f46, 0x3f669e, 0x5fea2d, 0x7527ba, 0xc7ebe5,
+    0xf17b3d, 0x0739f7, 0x8a5292, 0xea6bfb, 0x5fb11f, 0x8d5d08,
+    0x560330, 0x46fc7b, 0x6babf0, 0xcfbc20, 0x9af436, 0x1da9e3,
+    0x91615e, 0xe61b08, 0x659985, 0x5f14a0, 0x68408d, 0xffd880,
+    0x4d7327, 0x310606, 0x1556ca, 0x73a8c9, 0x60e27b, 0xc08c6b,
+  };
+
+  /**
+   * Super precision for pi/2 in 24-bit chunks, for use in
+   * {@link #remPiOver2(double, double[])}.
+   */
+  private static final double PI_OVER_TWO[] = {
+    1.570796251296997, // Long bits 0x3ff921fb40000000L.
+    7.549789415861596e-8, // Long bits 0x3e74442d00000000L.
+    5.390302529957765e-15, // Long bits 0x3cf8469880000000L.
+    3.282003415807913e-22, // Long bits 0x3b78cc5160000000L.
+    1.270655753080676e-29, // Long bits 0x39f01b8380000000L.
+    1.2293330898111133e-36, // Long bits 0x387a252040000000L.
+    2.7337005381646456e-44, // Long bits 0x36e3822280000000L.
+    2.1674168387780482e-51, // Long bits 0x3569f31d00000000L.
+  };
+
+  /**
+   * More constants related to pi, used in
+   * {@link #remPiOver2(double, double[])} and elsewhere.
+   */
+  private static final double
+    PI_L = 1.2246467991473532e-16, // Long bits 0x3ca1a62633145c07L.
+    PIO2_1 = 1.5707963267341256, // Long bits 0x3ff921fb54400000L.
+    PIO2_1L = 6.077100506506192e-11, // Long bits 0x3dd0b4611a626331L.
+    PIO2_2 = 6.077100506303966e-11, // Long bits 0x3dd0b4611a600000L.
+    PIO2_2L = 2.0222662487959506e-21, // Long bits 0x3ba3198a2e037073L.
+    PIO2_3 = 2.0222662487111665e-21, // Long bits 0x3ba3198a2e000000L.
+    PIO2_3L = 8.4784276603689e-32; // Long bits 0x397b839a252049c1L.
+
+  /**
+   * Natural log and square root constants, for calculation of
+   * {@link #exp(double)}, {@link #log(double)} and
+   * {@link #pow(double, double)}. CP is 2/(3*ln(2)).
+   */
+  private static final double
+    SQRT_1_5 = 1.224744871391589, // Long bits 0x3ff3988e1409212eL.
+    SQRT_2 = 1.4142135623730951, // Long bits 0x3ff6a09e667f3bcdL.
+    SQRT_3 = 1.7320508075688772, // Long bits 0x3ffbb67ae8584caaL.
+    EXP_LIMIT_H = 709.782712893384, // Long bits 0x40862e42fefa39efL.
+    EXP_LIMIT_L = -745.1332191019411, // Long bits 0xc0874910d52d3051L.
+    CP = 0.9617966939259756, // Long bits 0x3feec709dc3a03fdL.
+    CP_H = 0.9617967009544373, // Long bits 0x3feec709e0000000L.
+    CP_L = -7.028461650952758e-9, // Long bits 0xbe3e2fe0145b01f5L.
+    LN2 = 0.6931471805599453, // Long bits 0x3fe62e42fefa39efL.
+    LN2_H = 0.6931471803691238, // Long bits 0x3fe62e42fee00000L.
+    LN2_L = 1.9082149292705877e-10, // Long bits 0x3dea39ef35793c76L.
+    INV_LN2 = 1.4426950408889634, // Long bits 0x3ff71547652b82feL.
+    INV_LN2_H = 1.4426950216293335, // Long bits 0x3ff7154760000000L.
+    INV_LN2_L = 1.9259629911266175e-8; // Long bits 0x3e54ae0bf85ddf44L.
+
+  /**
+   * Constants for computing {@link #log(double)}.
+   */
+  private static final double
+    LG1 = 0.6666666666666735, // Long bits 0x3fe5555555555593L.
+    LG2 = 0.3999999999940942, // Long bits 0x3fd999999997fa04L.
+    LG3 = 0.2857142874366239, // Long bits 0x3fd2492494229359L.
+    LG4 = 0.22222198432149784, // Long bits 0x3fcc71c51d8e78afL.
+    LG5 = 0.1818357216161805, // Long bits 0x3fc7466496cb03deL.
+    LG6 = 0.15313837699209373, // Long bits 0x3fc39a09d078c69fL.
+    LG7 = 0.14798198605116586; // Long bits 0x3fc2f112df3e5244L.
+
+  /**
+   * Constants for computing {@link #pow(double, double)}. L and P are
+   * coefficients for series; OVT is -(1024-log2(ovfl+.5ulp)); and DP is ???.
+   * The P coefficients also calculate {@link #exp(double)}.
+   */
+  private static final double
+    L1 = 0.5999999999999946, // Long bits 0x3fe3333333333303L.
+    L2 = 0.4285714285785502, // Long bits 0x3fdb6db6db6fabffL.
+    L3 = 0.33333332981837743, // Long bits 0x3fd55555518f264dL.
+    L4 = 0.272728123808534, // Long bits 0x3fd17460a91d4101L.
+    L5 = 0.23066074577556175, // Long bits 0x3fcd864a93c9db65L.
+    L6 = 0.20697501780033842, // Long bits 0x3fca7e284a454eefL.
+    P1 = 0.16666666666666602, // Long bits 0x3fc555555555553eL.
+    P2 = -2.7777777777015593e-3, // Long bits 0xbf66c16c16bebd93L.
+    P3 = 6.613756321437934e-5, // Long bits 0x3f11566aaf25de2cL.
+    P4 = -1.6533902205465252e-6, // Long bits 0xbebbbd41c5d26bf1L.
+    P5 = 4.1381367970572385e-8, // Long bits 0x3e66376972bea4d0L.
+    DP_H = 0.5849624872207642, // Long bits 0x3fe2b80340000000L.
+    DP_L = 1.350039202129749e-8, // Long bits 0x3e4cfdeb43cfd006L.
+    OVT = 8.008566259537294e-17; // Long bits 0x3c971547652b82feL.
+
+  /**
+   * Coefficients for computing {@link #sin(double)}.
+   */
+  private static final double
+    S1 = -0.16666666666666632, // Long bits 0xbfc5555555555549L.
+    S2 = 8.33333333332249e-3, // Long bits 0x3f8111111110f8a6L.
+    S3 = -1.984126982985795e-4, // Long bits 0xbf2a01a019c161d5L.
+    S4 = 2.7557313707070068e-6, // Long bits 0x3ec71de357b1fe7dL.
+    S5 = -2.5050760253406863e-8, // Long bits 0xbe5ae5e68a2b9cebL.
+    S6 = 1.58969099521155e-10; // Long bits 0x3de5d93a5acfd57cL.
+
+  /**
+   * Coefficients for computing {@link #cos(double)}.
+   */
+  private static final double
+    C1 = 0.0416666666666666, // Long bits 0x3fa555555555554cL.
+    C2 = -1.388888888887411e-3, // Long bits 0xbf56c16c16c15177L.
+    C3 = 2.480158728947673e-5, // Long bits 0x3efa01a019cb1590L.
+    C4 = -2.7557314351390663e-7, // Long bits 0xbe927e4f809c52adL.
+    C5 = 2.087572321298175e-9, // Long bits 0x3e21ee9ebdb4b1c4L.
+    C6 = -1.1359647557788195e-11; // Long bits 0xbda8fae9be8838d4L.
+
+  /**
+   * Coefficients for computing {@link #tan(double)}.
+   */
+  private static final double
+    T0 = 0.3333333333333341, // Long bits 0x3fd5555555555563L.
+    T1 = 0.13333333333320124, // Long bits 0x3fc111111110fe7aL.
+    T2 = 0.05396825397622605, // Long bits 0x3faba1ba1bb341feL.
+    T3 = 0.021869488294859542, // Long bits 0x3f9664f48406d637L.
+    T4 = 8.8632398235993e-3, // Long bits 0x3f8226e3e96e8493L.
+    T5 = 3.5920791075913124e-3, // Long bits 0x3f6d6d22c9560328L.
+    T6 = 1.4562094543252903e-3, // Long bits 0x3f57dbc8fee08315L.
+    T7 = 5.880412408202641e-4, // Long bits 0x3f4344d8f2f26501L.
+    T8 = 2.464631348184699e-4, // Long bits 0x3f3026f71a8d1068L.
+    T9 = 7.817944429395571e-5, // Long bits 0x3f147e88a03792a6L.
+    T10 = 7.140724913826082e-5, // Long bits 0x3f12b80f32f0a7e9L.
+    T11 = -1.8558637485527546e-5, // Long bits 0xbef375cbdb605373L.
+    T12 = 2.590730518636337e-5; // Long bits 0x3efb2a7074bf7ad4L.
+
+  /**
+   * Coefficients for computing {@link #asin(double)} and
+   * {@link #acos(double)}.
+   */
+  private static final double
+    PS0 = 0.16666666666666666, // Long bits 0x3fc5555555555555L.
+    PS1 = -0.3255658186224009, // Long bits 0xbfd4d61203eb6f7dL.
+    PS2 = 0.20121253213486293, // Long bits 0x3fc9c1550e884455L.
+    PS3 = -0.04005553450067941, // Long bits 0xbfa48228b5688f3bL.
+    PS4 = 7.915349942898145e-4, // Long bits 0x3f49efe07501b288L.
+    PS5 = 3.479331075960212e-5, // Long bits 0x3f023de10dfdf709L.
+    QS1 = -2.403394911734414, // Long bits 0xc0033a271c8a2d4bL.
+    QS2 = 2.0209457602335057, // Long bits 0x40002ae59c598ac8L.
+    QS3 = -0.6882839716054533, // Long bits 0xbfe6066c1b8d0159L.
+    QS4 = 0.07703815055590194; // Long bits 0x3fb3b8c5b12e9282L.
+
+  /**
+   * Coefficients for computing {@link #atan(double)}.
+   */
+  private static final double
+    ATAN_0_5H = 0.4636476090008061, // Long bits 0x3fddac670561bb4fL.
+    ATAN_0_5L = 2.2698777452961687e-17, // Long bits 0x3c7a2b7f222f65e2L.
+    ATAN_1_5H = 0.982793723247329, // Long bits 0x3fef730bd281f69bL.
+    ATAN_1_5L = 1.3903311031230998e-17, // Long bits 0x3c7007887af0cbbdL.
+    AT0 = 0.3333333333333293, // Long bits 0x3fd555555555550dL.
+    AT1 = -0.19999999999876483, // Long bits 0xbfc999999998ebc4L.
+    AT2 = 0.14285714272503466, // Long bits 0x3fc24924920083ffL.
+    AT3 = -0.11111110405462356, // Long bits 0xbfbc71c6fe231671L.
+    AT4 = 0.09090887133436507, // Long bits 0x3fb745cdc54c206eL.
+    AT5 = -0.0769187620504483, // Long bits 0xbfb3b0f2af749a6dL.
+    AT6 = 0.06661073137387531, // Long bits 0x3fb10d66a0d03d51L.
+    AT7 = -0.058335701337905735, // Long bits 0xbfadde2d52defd9aL.
+    AT8 = 0.049768779946159324, // Long bits 0x3fa97b4b24760debL.
+    AT9 = -0.036531572744216916, // Long bits 0xbfa2b4442c6a6c2fL.
+    AT10 = 0.016285820115365782; // Long bits 0x3f90ad3ae322da11L.
+
+  /**
+   * Constants for computing {@link #cbrt(double)}.
+   */
+  private static final int
+    CBRT_B1 = 715094163, // B1 = (682-0.03306235651)*2**20
+    CBRT_B2 = 696219795; // B2 = (664-0.03306235651)*2**20
+
+  /**
+   * Constants for computing {@link #cbrt(double)}.
+   */
+  private static final double
+    CBRT_C =  5.42857142857142815906e-01, // Long bits  0x3fe15f15f15f15f1L
+    CBRT_D = -7.05306122448979611050e-01, // Long bits  0xbfe691de2532c834L
+    CBRT_E =  1.41428571428571436819e+00, // Long bits  0x3ff6a0ea0ea0ea0fL
+    CBRT_F =  1.60714285714285720630e+00, // Long bits  0x3ff9b6db6db6db6eL
+    CBRT_G =  3.57142857142857150787e-01; // Long bits  0x3fd6db6db6db6db7L
+
+  /**
+   * Constants for computing {@link #expm1(double)}
+   */
+  private static final double
+    EXPM1_Q1 = -3.33333333333331316428e-02, // Long bits  0xbfa11111111110f4L
+    EXPM1_Q2 =  1.58730158725481460165e-03, // Long bits  0x3f5a01a019fe5585L
+    EXPM1_Q3 = -7.93650757867487942473e-05, // Long bits  0xbf14ce199eaadbb7L
+    EXPM1_Q4 =  4.00821782732936239552e-06, // Long bits  0x3ed0cfca86e65239L
+    EXPM1_Q5 = -2.01099218183624371326e-07; // Long bits  0xbe8afdb76e09c32dL
+
+  /**
+   * Helper function for reducing an angle to a multiple of pi/2 within
+   * [-pi/4, pi/4].
+   *
+   * @param x the angle; not infinity or NaN, and outside pi/4
+   * @param y an array of 2 doubles modified to hold the remander x % pi/2
+   * @return the quadrant of the result, mod 4: 0: [-pi/4, pi/4],
+   *         1: [pi/4, 3*pi/4], 2: [3*pi/4, 5*pi/4], 3: [-3*pi/4, -pi/4]
+   */
+  private static int remPiOver2(double x, double[] y)
+  {
+    boolean negative = x < 0;
+    x = abs(x);
+    double z;
+    int n;
+    if (Configuration.DEBUG && (x <= PI / 4 || x != x
+                                || x == Double.POSITIVE_INFINITY))
+      throw new InternalError("Assertion failure");
+    if (x < 3 * PI / 4) // If |x| is small.
+      {
+        z = x - PIO2_1;
+        if ((float) x != (float) (PI / 2)) // 33+53 bit pi is good enough.
+          {
+            y[0] = z - PIO2_1L;
+            y[1] = z - y[0] - PIO2_1L;
+          }
+        else // Near pi/2, use 33+33+53 bit pi.
+          {
+            z -= PIO2_2;
+            y[0] = z - PIO2_2L;
+            y[1] = z - y[0] - PIO2_2L;
+          }
+        n = 1;
+      }
+    else if (x <= TWO_20 * PI / 2) // Medium size.
+      {
+        n = (int) (2 / PI * x + 0.5);
+        z = x - n * PIO2_1;
+        double w = n * PIO2_1L; // First round good to 85 bits.
+        y[0] = z - w;
+        if (n >= 32 || (float) x == (float) (w))
+          {
+            if (x / y[0] >= TWO_16) // Second iteration, good to 118 bits.
+              {
+                double t = z;
+                w = n * PIO2_2;
+                z = t - w;
+                w = n * PIO2_2L - (t - z - w);
+                y[0] = z - w;
+                if (x / y[0] >= TWO_49) // Third iteration, 151 bits accuracy.
+                  {
+                    t = z;
+                    w = n * PIO2_3;
+                    z = t - w;
+                    w = n * PIO2_3L - (t - z - w);
+                    y[0] = z - w;
+                  }
+              }
+          }
+        y[1] = z - y[0] - w;
+      }
+    else
+      {
+        // All other (large) arguments.
+        int e0 = (int) (Double.doubleToLongBits(x) >> 52) - 1046;
+        z = scale(x, -e0); // e0 = ilogb(z) - 23.
+        double[] tx = new double[3];
+        for (int i = 0; i < 2; i++)
+          {
+            tx[i] = (int) z;
+            z = (z - tx[i]) * TWO_24;
+          }
+        tx[2] = z;
+        int nx = 2;
+        while (tx[nx] == 0)
+          nx--;
+        n = remPiOver2(tx, y, e0, nx);
+      }
+    if (negative)
+      {
+        y[0] = -y[0];
+        y[1] = -y[1];
+        return -n;
+      }
+    return n;
+  }
+
+  /**
+   * Helper function for reducing an angle to a multiple of pi/2 within
+   * [-pi/4, pi/4].
+   *
+   * @param x the positive angle, broken into 24-bit chunks
+   * @param y an array of 2 doubles modified to hold the remander x % pi/2
+   * @param e0 the exponent of x[0]
+   * @param nx the last index used in x
+   * @return the quadrant of the result, mod 4: 0: [-pi/4, pi/4],
+   *         1: [pi/4, 3*pi/4], 2: [3*pi/4, 5*pi/4], 3: [-3*pi/4, -pi/4]
+   */
+  private static int remPiOver2(double[] x, double[] y, int e0, int nx)
+  {
+    int i;
+    int ih;
+    int n;
+    double fw;
+    double z;
+    int[] iq = new int[20];
+    double[] f = new double[20];
+    double[] q = new double[20];
+    boolean recompute = false;
+
+    // Initialize jk, jz, jv, q0; note that 3>q0.
+    int jk = 4;
+    int jz = jk;
+    int jv = max((e0 - 3) / 24, 0);
+    int q0 = e0 - 24 * (jv + 1);
+
+    // Set up f[0] to f[nx+jk] where f[nx+jk] = TWO_OVER_PI[jv+jk].
+    int j = jv - nx;
+    int m = nx + jk;
+    for (i = 0; i <= m; i++, j++)
+      f[i] = (j < 0) ? 0 : TWO_OVER_PI[j];
+
+    // Compute q[0],q[1],...q[jk].
+    for (i = 0; i <= jk; i++)
+      {
+        for (j = 0, fw = 0; j <= nx; j++)
+          fw += x[j] * f[nx + i - j];
+        q[i] = fw;
+      }
+
+    do
+      {
+        // Distill q[] into iq[] reversingly.
+        for (i = 0, j = jz, z = q[jz]; j > 0; i++, j--)
+          {
+            fw = (int) (1 / TWO_24 * z);
+            iq[i] = (int) (z - TWO_24 * fw);
+            z = q[j - 1] + fw;
+          }
+
+        // Compute n.
+        z = scale(z, q0);
+        z -= 8 * floor(z * 0.125); // Trim off integer >= 8.
+        n = (int) z;
+        z -= n;
+        ih = 0;
+        if (q0 > 0) // Need iq[jz-1] to determine n.
+          {
+            i = iq[jz - 1] >> (24 - q0);
+            n += i;
+            iq[jz - 1] -= i << (24 - q0);
+            ih = iq[jz - 1] >> (23 - q0);
+          }
+        else if (q0 == 0)
+          ih = iq[jz - 1] >> 23;
+        else if (z >= 0.5)
+          ih = 2;
+
+        if (ih > 0) // If q > 0.5.
+          {
+            n += 1;
+            int carry = 0;
+            for (i = 0; i < jz; i++) // Compute 1-q.
+              {
+                j = iq[i];
+                if (carry == 0)
+                  {
+                    if (j != 0)
+                      {
+                        carry = 1;
+                        iq[i] = 0x1000000 - j;
+                      }
+                  }
+                else
+                  iq[i] = 0xffffff - j;
+              }
+            switch (q0)
+              {
+              case 1: // Rare case: chance is 1 in 12 for non-default.
+                iq[jz - 1] &= 0x7fffff;
+                break;
+              case 2:
+                iq[jz - 1] &= 0x3fffff;
+              }
+            if (ih == 2)
+              {
+                z = 1 - z;
+                if (carry != 0)
+                  z -= scale(1, q0);
+              }
+          }
+
+        // Check if recomputation is needed.
+        if (z == 0)
+          {
+            j = 0;
+            for (i = jz - 1; i >= jk; i--)
+              j |= iq[i];
+            if (j == 0) // Need recomputation.
+              {
+                int k;
+                for (k = 1; iq[jk - k] == 0; k++); // k = no. of terms needed.
+
+                for (i = jz + 1; i <= jz + k; i++) // Add q[jz+1] to q[jz+k].
+                  {
+                    f[nx + i] = TWO_OVER_PI[jv + i];
+                    for (j = 0, fw = 0; j <= nx; j++)
+                      fw += x[j] * f[nx + i - j];
+                    q[i] = fw;
+                  }
+                jz += k;
+                recompute = true;
+              }
+          }
+      }
+    while (recompute);
+
+    // Chop off zero terms.
+    if (z == 0)
+      {
+        jz--;
+        q0 -= 24;
+        while (iq[jz] == 0)
+          {
+            jz--;
+            q0 -= 24;
+          }
+      }
+    else // Break z into 24-bit if necessary.
+      {
+        z = scale(z, -q0);
+        if (z >= TWO_24)
+          {
+            fw = (int) (1 / TWO_24 * z);
+            iq[jz] = (int) (z - TWO_24 * fw);
+            jz++;
+            q0 += 24;
+            iq[jz] = (int) fw;
+          }
+        else
+          iq[jz] = (int) z;
+      }
+
+    // Convert integer "bit" chunk to floating-point value.
+    fw = scale(1, q0);
+    for (i = jz; i >= 0; i--)
+      {
+        q[i] = fw * iq[i];
+        fw *= 1 / TWO_24;
+      }
+
+    // Compute PI_OVER_TWO[0,...,jk]*q[jz,...,0].
+    double[] fq = new double[20];
+    for (i = jz; i >= 0; i--)
+      {
+        fw = 0;
+        for (int k = 0; k <= jk && k <= jz - i; k++)
+          fw += PI_OVER_TWO[k] * q[i + k];
+        fq[jz - i] = fw;
+      }
+
+    // Compress fq[] into y[].
+    fw = 0;
+    for (i = jz; i >= 0; i--)
+      fw += fq[i];
+    y[0] = (ih == 0) ? fw : -fw;
+    fw = fq[0] - fw;
+    for (i = 1; i <= jz; i++)
+      fw += fq[i];
+    y[1] = (ih == 0) ? fw : -fw;
+    return n;
+  }
+
+  /**
+   * Helper method for scaling a double by a power of 2.
+   *
+   * @param x the double
+   * @param n the scale; |n| < 2048
+   * @return x * 2**n
+   */
+  private static double scale(double x, int n)
+  {
+    if (Configuration.DEBUG && abs(n) >= 2048)
+      throw new InternalError("Assertion failure");
+    if (x == 0 || x == Double.NEGATIVE_INFINITY
+        || ! (x < Double.POSITIVE_INFINITY) || n == 0)
+      return x;
+    long bits = Double.doubleToLongBits(x);
+    int exp = (int) (bits >> 52) & 0x7ff;
+    if (exp == 0) // Subnormal x.
+      {
+        x *= TWO_54;
+        exp = ((int) (Double.doubleToLongBits(x) >> 52) & 0x7ff) - 54;
+      }
+    exp += n;
+    if (exp > 0x7fe) // Overflow.
+      return Double.POSITIVE_INFINITY * x;
+    if (exp > 0) // Normal.
+      return Double.longBitsToDouble((bits & 0x800fffffffffffffL)
+                                     | ((long) exp << 52));
+    if (exp <= -54)
+      return 0 * x; // Underflow.
+    exp += 54; // Subnormal result.
+    x = Double.longBitsToDouble((bits & 0x800fffffffffffffL)
+                                | ((long) exp << 52));
+    return x * (1 / TWO_54);
+  }
+
+  /**
+   * Helper trig function; computes sin in range [-pi/4, pi/4].
+   *
+   * @param x angle within about pi/4
+   * @param y tail of x, created by remPiOver2
+   * @return sin(x+y)
+   */
+  private static double sin(double x, double y)
+  {
+    if (Configuration.DEBUG && abs(x + y) > 0.7854)
+      throw new InternalError("Assertion failure");
+    if (abs(x) < 1 / TWO_27)
+      return x;  // If |x| ~< 2**-27, already know answer.
+
+    double z = x * x;
+    double v = z * x;
+    double r = S2 + z * (S3 + z * (S4 + z * (S5 + z * S6)));
+    if (y == 0)
+      return x + v * (S1 + z * r);
+    return x - ((z * (0.5 * y - v * r) - y) - v * S1);
+  }
+
+  /**
+   * Helper trig function; computes cos in range [-pi/4, pi/4].
+   *
+   * @param x angle within about pi/4
+   * @param y tail of x, created by remPiOver2
+   * @return cos(x+y)
+   */
+  private static double cos(double x, double y)
+  {
+    if (Configuration.DEBUG && abs(x + y) > 0.7854)
+      throw new InternalError("Assertion failure");
+    x = abs(x);
+    if (x < 1 / TWO_27)
+      return 1;  // If |x| ~< 2**-27, already know answer.
+
+    double z = x * x;
+    double r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * C6)))));
+
+    if (x < 0.3)
+      return 1 - (0.5 * z - (z * r - x * y));
+
+    double qx = (x > 0.78125) ? 0.28125 : (x * 0.25);
+    return 1 - qx - ((0.5 * z - qx) - (z * r - x * y));
+  }
+
+  /**
+   * Helper trig function; computes tan in range [-pi/4, pi/4].
+   *
+   * @param x angle within about pi/4
+   * @param y tail of x, created by remPiOver2
+   * @param invert true iff -1/tan should be returned instead
+   * @return tan(x+y)
+   */
+  private static double tan(double x, double y, boolean invert)
+  {
+    // PI/2 is irrational, so no double is a perfect multiple of it.
+    if (Configuration.DEBUG && (abs(x + y) > 0.7854 || (x == 0 && invert)))
+      throw new InternalError("Assertion failure");
+    boolean negative = x < 0;
+    if (negative)
+      {
+        x = -x;
+        y = -y;
+      }
+    if (x < 1 / TWO_28) // If |x| ~< 2**-28, already know answer.
+      return (negative ? -1 : 1) * (invert ? -1 / x : x);
+
+    double z;
+    double w;
+    boolean large = x >= 0.6744;
+    if (large)
+      {
+        z = PI / 4 - x;
+        w = PI_L / 4 - y;
+        x = z + w;
+        y = 0;
+      }
+    z = x * x;
+    w = z * z;
+    // Break x**5*(T1+x**2*T2+...) into
+    //   x**5(T1+x**4*T3+...+x**20*T11)
+    // + x**5(x**2*(T2+x**4*T4+...+x**22*T12)).
+    double r = T1 + w * (T3 + w * (T5 + w * (T7 + w * (T9 + w * T11))));
+    double v = z * (T2 + w * (T4 + w * (T6 + w * (T8 + w * (T10 + w * T12)))));
+    double s = z * x;
+    r = y + z * (s * (r + v) + y);
+    r += T0 * s;
+    w = x + r;
+    if (large)
+      {
+        v = invert ? -1 : 1;
+        return (negative ? -1 : 1) * (v - 2 * (x - (w * w / (w + v) - r)));
+      }
+    if (! invert)
+      return w;
+
+    // Compute -1.0/(x+r) accurately.
+    z = (float) w;
+    v = r - (z - x);
+    double a = -1 / w;
+    double t = (float) a;
+    return t + a * (1 + t * z + t * v);
+  }
+
+  /**
+   * <p>
+   * Returns the sign of the argument as follows:
+   * </p>
+   * <ul>
+   * <li>If <code>a</code> is greater than zero, the result is 1.0.</li>
+   * <li>If <code>a</code> is less than zero, the result is -1.0.</li>
+   * <li>If <code>a</code> is <code>NaN</code>, the result is <code>NaN</code>.
+   * <li>If <code>a</code> is positive or negative zero, the result is the
+   * same.</li>
+   * </ul>
+   * 
+   * @param a the numeric argument.
+   * @return the sign of the argument.
+   * @since 1.5.
+   */
+  public static double signum(double a)
+  {
+    // There's no difference.
+    return Math.signum(a);
+  }
+
+  /**
+   * <p>
+   * Returns the sign of the argument as follows:
+   * </p>
+   * <ul>
+   * <li>If <code>a</code> is greater than zero, the result is 1.0f.</li>
+   * <li>If <code>a</code> is less than zero, the result is -1.0f.</li>
+   * <li>If <code>a</code> is <code>NaN</code>, the result is <code>NaN</code>.
+   * <li>If <code>a</code> is positive or negative zero, the result is the
+   * same.</li>
+   * </ul>
+   * 
+   * @param a the numeric argument.
+   * @return the sign of the argument.
+   * @since 1.5.
+   */
+  public static float signum(float a)
+  {
+    // There's no difference.
+    return Math.signum(a);
+  }
+
+  /**
+   * Return the ulp for the given double argument.  The ulp is the
+   * difference between the argument and the next larger double.  Note
+   * that the sign of the double argument is ignored, that is,
+   * ulp(x) == ulp(-x).  If the argument is a NaN, then NaN is returned.
+   * If the argument is an infinity, then +Inf is returned.  If the
+   * argument is zero (either positive or negative), then
+   * {@link Double#MIN_VALUE} is returned.
+   * @param d the double whose ulp should be returned
+   * @return the difference between the argument and the next larger double
+   * @since 1.5
+   */
+  public static double ulp(double d)
+  {
+    // There's no difference.
+    return Math.ulp(d);
+  }
+
+  /**
+   * Return the ulp for the given float argument.  The ulp is the
+   * difference between the argument and the next larger float.  Note
+   * that the sign of the float argument is ignored, that is,
+   * ulp(x) == ulp(-x).  If the argument is a NaN, then NaN is returned.
+   * If the argument is an infinity, then +Inf is returned.  If the
+   * argument is zero (either positive or negative), then
+   * {@link Float#MIN_VALUE} is returned.
+   * @param f the float whose ulp should be returned
+   * @return the difference between the argument and the next larger float
+   * @since 1.5
+   */
+  public static float ulp(float f)
+  {
+    // There's no difference.
+    return Math.ulp(f);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/String.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/String.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1989 @@
+/* String.java -- immutable character sequences; the object of string literals
+   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.lang;
+
+import gnu.java.lang.CharData;
+
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CodingErrorAction;
+import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.UnsupportedCharsetException;
+import java.text.Collator;
+import java.util.Comparator;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+/**
+ * Strings represent an immutable set of characters.  All String literals
+ * are instances of this class, and two string literals with the same contents
+ * refer to the same String object.
+ *
+ * <p>This class also includes a number of methods for manipulating the
+ * contents of strings (of course, creating a new object if there are any
+ * changes, as String is immutable). Case mapping relies on Unicode 3.0.0
+ * standards, where some character sequences have a different number of
+ * characters in the uppercase version than the lower case.
+ *
+ * <p>Strings are special, in that they are the only object with an overloaded
+ * operator. When you use '+' with at least one String argument, both
+ * arguments have String conversion performed on them, and another String (not
+ * guaranteed to be unique) results.
+ *
+ * <p>String is special-cased when doing data serialization - rather than
+ * listing the fields of this class, a String object is converted to a string
+ * literal in the object stream.
+ *
+ * @author Paul N. Fisher
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @author Per Bothner (bothner at cygnus.com)
+ * @since 1.0
+ * @status updated to 1.4; but could use better data sharing via offset field
+ */
+public final class String implements Serializable, Comparable, CharSequence
+{
+  // WARNING: String is a CORE class in the bootstrap cycle. See the comments
+  // in vm/reference/java/lang/Runtime for implications of this fact.
+
+  /**
+   * This is probably not necessary because this class is special cased already
+   * but it will avoid showing up as a discrepancy when comparing SUIDs.
+   */
+  private static final long serialVersionUID = -6849794470754667710L;
+
+  /**
+   * Stores unicode multi-character uppercase expansion table.
+   * @see #toUpperCase(Locale)
+   * @see CharData#UPPER_EXPAND
+   */
+  private static final char[] upperExpand
+	= zeroBasedStringValue(CharData.UPPER_EXPAND);
+
+  /**
+   * Stores unicode multi-character uppercase special casing table.
+   * @see #upperCaseExpansion(char)
+   * @see CharData#UPPER_SPECIAL
+   */
+  private static final char[] upperSpecial
+	  = zeroBasedStringValue(CharData.UPPER_SPECIAL);
+  
+  /**
+   * Characters which make up the String.
+   * Package access is granted for use by StringBuffer.
+   */
+  final char[] value;
+
+  /**
+   * Holds the number of characters in value.  This number is generally
+   * the same as value.length, but can be smaller because substrings and
+   * StringBuffers can share arrays. Package visible for use by trusted code.
+   */
+  final int count;
+
+  /**
+   * Caches the result of hashCode().  If this value is zero, the hashcode
+   * is considered uncached (even if 0 is the correct hash value).
+   */
+  private int cachedHashCode;
+
+  /**
+   * Holds the starting position for characters in value[].  Since
+   * substring()'s are common, the use of offset allows the operation
+   * to perform in O(1). Package access is granted for use by StringBuffer.
+   */
+  final int offset;
+
+  /**
+   * An implementation for {@link #CASE_INSENSITIVE_ORDER}.
+   * This must be {@link Serializable}. The class name is dictated by
+   * compatibility with Sun's JDK.
+   */
+  private static final class CaseInsensitiveComparator
+    implements Comparator, Serializable
+  {
+    /**
+     * Compatible with JDK 1.2.
+     */
+    private static final long serialVersionUID = 8575799808933029326L;
+
+    /**
+     * The default private constructor generates unnecessary overhead.
+     */
+    CaseInsensitiveComparator() {}
+
+    /**
+     * Compares to Strings, using
+     * <code>String.compareToIgnoreCase(String)</code>.
+     *
+     * @param o1 the first string
+     * @param o2 the second string
+     * @return < 0, 0, or > 0 depending on the case-insensitive
+     *         comparison of the two strings.
+     * @throws NullPointerException if either argument is null
+     * @throws ClassCastException if either argument is not a String
+     * @see #compareToIgnoreCase(String)
+     */
+    public int compare(Object o1, Object o2)
+    {
+      return ((String) o1).compareToIgnoreCase((String) o2);
+    }
+  } // class CaseInsensitiveComparator
+
+  /**
+   * A Comparator that uses <code>String.compareToIgnoreCase(String)</code>.
+   * This comparator is {@link Serializable}. Note that it ignores Locale,
+   * for that, you want a Collator.
+   *
+   * @see Collator#compare(String, String)
+   * @since 1.2
+   */
+  public static final Comparator CASE_INSENSITIVE_ORDER
+    = new CaseInsensitiveComparator();
+
+  /**
+   * Creates an empty String (length 0). Unless you really need a new object,
+   * consider using <code>""</code> instead.
+   */
+  public String()
+  {
+    value = "".value;
+    offset = 0;
+    count = 0;
+  }
+
+  /**
+   * Copies the contents of a String to a new String. Since Strings are
+   * immutable, only a shallow copy is performed.
+   *
+   * @param str String to copy
+   * @throws NullPointerException if value is null
+   */
+  public String(String str)
+  {
+    value = str.value;
+    offset = str.offset;
+    count = str.count;
+    cachedHashCode = str.cachedHashCode;
+  }
+
+  /**
+   * Creates a new String using the character sequence of the char array.
+   * Subsequent changes to data do not affect the String.
+   *
+   * @param data char array to copy
+   * @throws NullPointerException if data is null
+   */
+  public String(char[] data)
+  {
+    this(data, 0, data.length, false);
+  }
+
+  /**
+   * Creates a new String using the character sequence of a subarray of
+   * characters. The string starts at offset, and copies count chars.
+   * Subsequent changes to data do not affect the String.
+   *
+   * @param data char array to copy
+   * @param offset position (base 0) to start copying out of data
+   * @param count the number of characters from data to copy
+   * @throws NullPointerException if data is null
+   * @throws IndexOutOfBoundsException if (offset < 0 || count < 0
+   *         || offset + count < 0 (overflow)
+   *         || offset + count > data.length)
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public String(char[] data, int offset, int count)
+  {
+    this(data, offset, count, false);
+  }
+
+  /**
+   * Creates a new String using an 8-bit array of integer values, starting at
+   * an offset, and copying up to the count. Each character c, using
+   * corresponding byte b, is created in the new String as if by performing:
+   *
+   * <pre>
+   * c = (char) (((hibyte & 0xff) << 8) | (b & 0xff))
+   * </pre>
+   *
+   * @param ascii array of integer values
+   * @param hibyte top byte of each Unicode character
+   * @param offset position (base 0) to start copying out of ascii
+   * @param count the number of characters from ascii to copy
+   * @throws NullPointerException if ascii is null
+   * @throws IndexOutOfBoundsException if (offset < 0 || count < 0
+   *         || offset + count < 0 (overflow)
+   *         || offset + count > ascii.length)
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   * @see #String(byte[])
+   * @see #String(byte[], String)
+   * @see #String(byte[], int, int)
+   * @see #String(byte[], int, int, String)
+   * @deprecated use {@link #String(byte[], int, int, String)} to perform
+   *             correct encoding
+   */
+  public String(byte[] ascii, int hibyte, int offset, int count)
+  {
+    if (offset < 0)
+      throw new StringIndexOutOfBoundsException("offset: " + offset);
+    if (count < 0)
+      throw new StringIndexOutOfBoundsException("count: " + count);
+    // equivalent to: offset + count < 0 || offset + count > ascii.length
+    if (ascii.length - offset < count)
+      throw new StringIndexOutOfBoundsException("offset + count: "
+						+ (offset + count));
+    value = new char[count];
+    this.offset = 0;
+    this.count = count;
+    hibyte <<= 8;
+    offset += count;
+    while (--count >= 0)
+      value[count] = (char) (hibyte | (ascii[--offset] & 0xff));
+  }
+
+  /**
+   * Creates a new String using an 8-bit array of integer values. Each
+   * character c, using corresponding byte b, is created in the new String
+   * as if by performing:
+   *
+   * <pre>
+   * c = (char) (((hibyte & 0xff) << 8) | (b & 0xff))
+   * </pre>
+   *
+   * @param ascii array of integer values
+   * @param hibyte top byte of each Unicode character
+   * @throws NullPointerException if ascii is null
+   * @see #String(byte[])
+   * @see #String(byte[], String)
+   * @see #String(byte[], int, int)
+   * @see #String(byte[], int, int, String)
+   * @see #String(byte[], int, int, int)
+   * @deprecated use {@link #String(byte[], String)} to perform
+   *             correct encoding
+   */
+  public String(byte[] ascii, int hibyte)
+  {
+    this(ascii, hibyte, 0, ascii.length);
+  }
+
+  /**
+   * Creates a new String using the portion of the byte array starting at the
+   * offset and ending at offset + count. Uses the specified encoding type
+   * to decode the byte array, so the resulting string may be longer or
+   * shorter than the byte array. For more decoding control, use
+   * {@link java.nio.charset.CharsetDecoder}, and for valid character sets,
+   * see {@link java.nio.charset.Charset}. The behavior is not specified if
+   * the decoder encounters invalid characters; this implementation throws
+   * an Error.
+   *
+   * @param data byte array to copy
+   * @param offset the offset to start at
+   * @param count the number of bytes in the array to use
+   * @param encoding the name of the encoding to use
+   * @throws NullPointerException if data or encoding is null
+   * @throws IndexOutOfBoundsException if offset or count is incorrect
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   * @throws UnsupportedEncodingException if encoding is not found
+   * @throws Error if the decoding fails
+   * @since 1.1
+   */
+  public String(byte[] data, int offset, int count, String encoding)
+    throws UnsupportedEncodingException
+  {
+    if (offset < 0)
+      throw new StringIndexOutOfBoundsException("offset: " + offset);
+    if (count < 0)
+      throw new StringIndexOutOfBoundsException("count: " + count);
+    // equivalent to: offset + count < 0 || offset + count > data.length
+    if (data.length - offset < count)
+      throw new StringIndexOutOfBoundsException("offset + count: "
+						+ (offset + count));
+    try 
+      {
+        CharsetDecoder csd = Charset.forName(encoding).newDecoder();
+	csd.onMalformedInput(CodingErrorAction.REPLACE);
+	csd.onUnmappableCharacter(CodingErrorAction.REPLACE);
+	CharBuffer cbuf = csd.decode(ByteBuffer.wrap(data, offset, count));
+ 	if(cbuf.hasArray())
+ 	  {
+ 	    value = cbuf.array();
+	    this.offset = cbuf.position();
+	    this.count = cbuf.remaining();
+ 	  } else {
+	    // Doubt this will happen. But just in case.
+	    value = new char[cbuf.remaining()];
+	    cbuf.get(value);
+	    this.offset = 0;
+	    this.count = value.length;
+	  }
+      } catch(CharacterCodingException e){
+	  throw new UnsupportedEncodingException("Encoding: "+encoding+
+						 " not found.");	  
+      } catch(IllegalCharsetNameException e){
+	  throw new UnsupportedEncodingException("Encoding: "+encoding+
+						 " not found.");
+      } catch(UnsupportedCharsetException e){
+	  throw new UnsupportedEncodingException("Encoding: "+encoding+
+						 " not found.");
+      }    
+  }
+
+  /**
+   * Creates a new String using the byte array. Uses the specified encoding
+   * type to decode the byte array, so the resulting string may be longer or
+   * shorter than the byte array. For more decoding control, use
+   * {@link java.nio.charset.CharsetDecoder}, and for valid character sets,
+   * see {@link java.nio.charset.Charset}. The behavior is not specified if
+   * the decoder encounters invalid characters; this implementation throws
+   * an Error.
+   *
+   * @param data byte array to copy
+   * @param encoding the name of the encoding to use
+   * @throws NullPointerException if data or encoding is null
+   * @throws UnsupportedEncodingException if encoding is not found
+   * @throws Error if the decoding fails
+   * @see #String(byte[], int, int, String)
+   * @since 1.1
+   */
+  public String(byte[] data, String encoding)
+    throws UnsupportedEncodingException
+  {
+    this(data, 0, data.length, encoding);
+  }
+
+  /**
+   * Creates a new String using the portion of the byte array starting at the
+   * offset and ending at offset + count. Uses the encoding of the platform's
+   * default charset, so the resulting string may be longer or shorter than
+   * the byte array. For more decoding control, use
+   * {@link java.nio.charset.CharsetDecoder}.  The behavior is not specified
+   * if the decoder encounters invalid characters; this implementation throws
+   * an Error.
+   *
+   * @param data byte array to copy
+   * @param offset the offset to start at
+   * @param count the number of bytes in the array to use
+   * @throws NullPointerException if data is null
+   * @throws IndexOutOfBoundsException if offset or count is incorrect
+   * @throws Error if the decoding fails
+   * @see #String(byte[], int, int, String)
+   * @since 1.1
+   */
+  public String(byte[] data, int offset, int count)
+  {
+    if (offset < 0)
+      throw new StringIndexOutOfBoundsException("offset: " + offset);
+    if (count < 0)
+      throw new StringIndexOutOfBoundsException("count: " + count);
+    // equivalent to: offset + count < 0 || offset + count > data.length
+    if (data.length - offset < count)
+      throw new StringIndexOutOfBoundsException("offset + count: "
+						+ (offset + count));
+    int o, c;
+    char[] v;
+    String encoding;
+    try 
+	{
+	  encoding = System.getProperty("file.encoding");
+	  CharsetDecoder csd = Charset.forName(encoding).newDecoder();
+	  csd.onMalformedInput(CodingErrorAction.REPLACE);
+	  csd.onUnmappableCharacter(CodingErrorAction.REPLACE);
+	  CharBuffer cbuf = csd.decode(ByteBuffer.wrap(data, offset, count));
+	  if(cbuf.hasArray())
+	    {
+              v = cbuf.array();
+	      o = cbuf.position();
+	      c = cbuf.remaining();
+	    } else {
+	      // Doubt this will happen. But just in case.
+	      v = new char[cbuf.remaining()];
+	      cbuf.get(v);
+	      o = 0;
+	      c = v.length;
+	    }
+	} catch(Exception ex){
+	    // If anything goes wrong (System property not set,
+	    // NIO provider not available, etc)
+	    // Default to the 'safe' encoding ISO8859_1
+	    v = new char[count];
+	    o = 0;
+	    c = count;
+	    for (int i=0;i<count;i++)
+	      v[i] = (char)data[offset+i];
+	}
+    this.value = v;
+    this.offset = o;
+    this.count = c;
+  }
+
+  /**
+   * Creates a new String using the byte array. Uses the encoding of the
+   * platform's default charset, so the resulting string may be longer or
+   * shorter than the byte array. For more decoding control, use
+   * {@link java.nio.charset.CharsetDecoder}.  The behavior is not specified
+   * if the decoder encounters invalid characters; this implementation throws
+   * an Error.
+   *
+   * @param data byte array to copy
+   * @throws NullPointerException if data is null
+   * @throws Error if the decoding fails
+   * @see #String(byte[], int, int)
+   * @see #String(byte[], int, int, String)
+   * @since 1.1
+   */
+  public String(byte[] data)
+  {
+    this(data, 0, data.length);
+  }
+
+  /**
+   * Creates a new String using the character sequence represented by
+   * the StringBuffer. Subsequent changes to buf do not affect the String.
+   *
+   * @param buffer StringBuffer to copy
+   * @throws NullPointerException if buffer is null
+   */
+  public String(StringBuffer buffer)
+  {
+    synchronized (buffer)
+      {
+        offset = 0;
+        count = buffer.count;
+        // Share unless buffer is 3/4 empty.
+        if ((count << 2) < buffer.value.length)
+          {
+            value = new char[count];
+            VMSystem.arraycopy(buffer.value, 0, value, 0, count);
+          }
+        else
+          {
+            buffer.shared = true;
+            value = buffer.value;
+          }
+      }
+  }
+
+  /**
+   * Creates a new String using the character sequence represented by
+   * the StringBuilder. Subsequent changes to buf do not affect the String.
+   *
+   * @param buffer StringBuilder to copy
+   * @throws NullPointerException if buffer is null
+   */
+  public String(StringBuilder buffer)
+  {
+    this(buffer.value, 0, buffer.count);
+  }
+
+  /**
+   * Special constructor which can share an array when safe to do so.
+   *
+   * @param data the characters to copy
+   * @param offset the location to start from
+   * @param count the number of characters to use
+   * @param dont_copy true if the array is trusted, and need not be copied
+   * @throws NullPointerException if chars is null
+   * @throws StringIndexOutOfBoundsException if bounds check fails
+   */
+  String(char[] data, int offset, int count, boolean dont_copy)
+  {
+    if (offset < 0)
+      throw new StringIndexOutOfBoundsException("offset: " + offset);
+    if (count < 0)
+      throw new StringIndexOutOfBoundsException("count: " + count);
+    // equivalent to: offset + count < 0 || offset + count > data.length
+    if (data.length - offset < count)
+      throw new StringIndexOutOfBoundsException("offset + count: "
+						+ (offset + count));
+    if (dont_copy)
+      {
+        value = data;
+        this.offset = offset;
+      }
+    else
+      {
+        value = new char[count];
+        VMSystem.arraycopy(data, offset, value, 0, count);
+        this.offset = 0;
+      }
+    this.count = count;
+  }
+
+  /**
+   * Creates a new String containing the characters represented in the
+   * given subarray of Unicode code points.
+   * @param codePoints the entire array of code points
+   * @param offset the start of the subarray
+   * @param count the length of the subarray
+   * 
+   * @throws IllegalArgumentException if an invalid code point is found
+   * in the codePoints array
+   * @throws IndexOutOfBoundsException if offset is negative or offset + count
+   * is greater than the length of the array.
+   */
+  public String(int[] codePoints, int offset, int count)
+  {
+    // FIXME: This implementation appears to give correct internal
+    // representation of the String because: 
+    //   - length() is correct
+    //   - getting a char[] from toCharArray() and testing 
+    //     Character.codePointAt() on all the characters in that array gives
+    //     the appropriate results
+    // however printing the String gives incorrect results.  This may be 
+    // due to printing method errors (such as incorrectly looping through
+    // the String one char at a time rather than one "character" at a time.
+    
+    if (offset < 0)
+      throw new IndexOutOfBoundsException();
+    int end = offset + count;
+    int pos = 0;
+    // This creates a char array that is long enough for all of the code
+    // points to represent supplementary characters.  This is more than likely
+    // a waste of storage, so we use it only temporarily and then copy the 
+    // used portion into the value array.
+    char[] temp = new char[2 * codePoints.length];
+    for (int i = offset; i < end; i++)
+      {
+        pos += Character.toChars(codePoints[i], temp, pos);        
+      }
+    this.count = pos;
+    this.value = new char[pos];
+    System.arraycopy(temp, 0, value, 0, pos);
+    this.offset = 0;
+  }
+  
+  /**
+   * Returns the number of characters contained in this String.
+   *
+   * @return the length of this String
+   */
+  public int length()
+  {
+    return count;
+  }
+
+  /**
+   * Returns the character located at the specified index within this String.
+   *
+   * @param index position of character to return (base 0)
+   * @return character located at position index
+   * @throws IndexOutOfBoundsException if index < 0 || index >= length()
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public char charAt(int index)
+  {
+    if (index < 0 || index >= count)
+      throw new StringIndexOutOfBoundsException(index);
+    return value[offset + index];
+  }
+
+  /**
+   * Get the code point at the specified index.  This is like #charAt(int),
+   * but if the character is the start of a surrogate pair, and the
+   * following character completes the pair, then the corresponding
+   * supplementary code point is returned.
+   * @param index the index of the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   * @since 1.5
+   */
+  public synchronized int codePointAt(int index)
+  {
+    // Use the CharSequence overload as we get better range checking
+    // this way.
+    return Character.codePointAt(this, index);
+  }
+
+  /**
+   * Get the code point before the specified index.  This is like
+   * #codePointAt(int), but checks the characters at <code>index-1</code> and
+   * <code>index-2</code> to see if they form a supplementary code point.
+   * @param index the index just past the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   * @since 1.5
+   */
+  public synchronized int codePointBefore(int index)
+  {
+    // Use the CharSequence overload as we get better range checking
+    // this way.
+    return Character.codePointBefore(this, index);
+  }
+
+  /**
+   * Copies characters from this String starting at a specified start index,
+   * ending at a specified stop index, to a character array starting at
+   * a specified destination begin index.
+   *
+   * @param srcBegin index to begin copying characters from this String
+   * @param srcEnd index after the last character to be copied from this String
+   * @param dst character array which this String is copied into
+   * @param dstBegin index to start writing characters into dst
+   * @throws NullPointerException if dst is null
+   * @throws IndexOutOfBoundsException if any indices are out of bounds
+   *         (while unspecified, source problems cause a
+   *         StringIndexOutOfBoundsException, and dst problems cause an
+   *         ArrayIndexOutOfBoundsException)
+   */
+  public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin)
+  {
+    if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count)
+      throw new StringIndexOutOfBoundsException();
+    VMSystem.arraycopy(value, srcBegin + offset,
+                     dst, dstBegin, srcEnd - srcBegin);
+  }
+
+  /**
+   * Copies the low byte of each character from this String starting at a
+   * specified start index, ending at a specified stop index, to a byte array
+   * starting at a specified destination begin index.
+   *
+   * @param srcBegin index to being copying characters from this String
+   * @param srcEnd index after the last character to be copied from this String
+   * @param dst byte array which each low byte of this String is copied into
+   * @param dstBegin index to start writing characters into dst
+   * @throws NullPointerException if dst is null and copy length is non-zero
+   * @throws IndexOutOfBoundsException if any indices are out of bounds
+   *         (while unspecified, source problems cause a
+   *         StringIndexOutOfBoundsException, and dst problems cause an
+   *         ArrayIndexOutOfBoundsException)
+   * @see #getBytes()
+   * @see #getBytes(String)
+   * @deprecated use {@link #getBytes()}, which uses a char to byte encoder
+   */
+  public void getBytes(int srcBegin, int srcEnd, byte dst[], int dstBegin)
+  {
+    if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count)
+      throw new StringIndexOutOfBoundsException();
+    int i = srcEnd - srcBegin;
+    srcBegin += offset;
+    while (--i >= 0)
+      dst[dstBegin++] = (byte) value[srcBegin++];
+  }
+
+  /**
+   * Converts the Unicode characters in this String to a byte array. Uses the
+   * specified encoding method, so the result may be longer or shorter than
+   * the String. For more encoding control, use
+   * {@link java.nio.charset.CharsetEncoder}, and for valid character sets,
+   * see {@link java.nio.charset.Charset}. Unsupported characters get
+   * replaced by an encoding specific byte.
+   *
+   * @param enc encoding name
+   * @return the resulting byte array
+   * @throws NullPointerException if enc is null
+   * @throws UnsupportedEncodingException if encoding is not supported
+   * @since 1.1
+   */
+  public byte[] getBytes(String enc) throws UnsupportedEncodingException
+  {
+    try 
+      {
+	CharsetEncoder cse = Charset.forName(enc).newEncoder();
+	cse.onMalformedInput(CodingErrorAction.REPLACE);
+	cse.onUnmappableCharacter(CodingErrorAction.REPLACE);
+	ByteBuffer bbuf = cse.encode(CharBuffer.wrap(value, offset, count));
+	if(bbuf.hasArray())
+	  return bbuf.array();
+	
+	// Doubt this will happen. But just in case.
+	byte[] bytes = new byte[bbuf.remaining()];
+	bbuf.get(bytes);
+	return bytes;
+      } 
+    catch(IllegalCharsetNameException e)
+      {
+	throw new UnsupportedEncodingException("Encoding: " + enc
+					       + " not found.");
+      } 
+    catch(UnsupportedCharsetException e)
+      {
+	throw new UnsupportedEncodingException("Encoding: " + enc
+					       + " not found.");
+      } 
+    catch(CharacterCodingException e)
+      {
+	// This shouldn't ever happen.
+	throw (InternalError) new InternalError().initCause(e);
+      }	  
+  }
+
+  /**
+   * Converts the Unicode characters in this String to a byte array. Uses the
+   * encoding of the platform's default charset, so the result may be longer
+   * or shorter than the String. For more encoding control, use
+   * {@link java.nio.charset.CharsetEncoder}. Unsupported characters get
+   * replaced by an encoding specific byte.
+   *
+   * @return the resulting byte array, or null on a problem
+   * @since 1.1
+   */
+  public byte[] getBytes()
+  { 
+      try 
+	  {
+	      return getBytes(System.getProperty("file.encoding"));
+	  } catch(Exception e) {
+	      // XXX - Throw an error here? 
+	      // For now, default to the 'safe' encoding.
+	      byte[] bytes = new byte[count];
+	      for(int i=0;i<count;i++)
+		  bytes[i] = (byte)((value[offset+i] <= 0xFF)?
+				    value[offset+i]:'?');
+	      return bytes;
+      }
+  }
+
+  /**
+   * Predicate which compares anObject to this. This is true only for Strings
+   * with the same character sequence.
+   *
+   * @param anObject the object to compare
+   * @return true if anObject is semantically equal to this
+   * @see #compareTo(String)
+   * @see #equalsIgnoreCase(String)
+   */
+  public boolean equals(Object anObject)
+  {
+    if (! (anObject instanceof String))
+      return false;
+    String str2 = (String) anObject;
+    if (count != str2.count)
+      return false;
+    if (value == str2.value && offset == str2.offset)
+      return true;
+    int i = count;
+    int x = offset;
+    int y = str2.offset;
+    while (--i >= 0)
+      if (value[x++] != str2.value[y++])
+        return false;
+    return true;
+  }
+
+  /**
+   * Compares the given StringBuffer to this String. This is true if the
+   * StringBuffer has the same content as this String at this moment.
+   *
+   * @param buffer the StringBuffer to compare to
+   * @return true if StringBuffer has the same character sequence
+   * @throws NullPointerException if the given StringBuffer is null
+   * @since 1.4
+   */
+  public boolean contentEquals(StringBuffer buffer)
+  {
+    synchronized (buffer)
+      {
+        if (count != buffer.count)
+          return false;
+        if (value == buffer.value)
+          return true; // Possible if shared.
+        int i = count;
+        int x = offset + count;
+        while (--i >= 0)
+          if (value[--x] != buffer.value[i])
+            return false;
+        return true;
+      }
+  }
+
+  /**
+   * Compares the given CharSequence to this String. This is true if
+   * the CharSequence has the same content as this String at this
+   * moment.
+   *
+   * @param seq the CharSequence to compare to
+   * @return true if CharSequence has the same character sequence
+   * @throws NullPointerException if the given CharSequence is null
+   * @since 1.5
+   */
+  public boolean contentEquals(CharSequence seq)
+  {
+    if (seq.length() != count)
+      return false;
+    for (int i = 0; i < count; ++i)
+      if (value[offset + i] != seq.charAt(i))
+	return false;
+    return true;
+  }
+
+  /**
+   * Compares a String to this String, ignoring case. This does not handle
+   * multi-character capitalization exceptions; instead the comparison is
+   * made on a character-by-character basis, and is true if:<br><ul>
+   * <li><code>c1 == c2</code></li>
+   * <li><code>Character.toUpperCase(c1)
+   *     == Character.toUpperCase(c2)</code></li>
+   * <li><code>Character.toLowerCase(c1)
+   *     == Character.toLowerCase(c2)</code></li>
+   * </ul>
+   *
+   * @param anotherString String to compare to this String
+   * @return true if anotherString is equal, ignoring case
+   * @see #equals(Object)
+   * @see Character#toUpperCase(char)
+   * @see Character#toLowerCase(char)
+   */
+  public boolean equalsIgnoreCase(String anotherString)
+  {
+    if (anotherString == null || count != anotherString.count)
+      return false;
+    int i = count;
+    int x = offset;
+    int y = anotherString.offset;
+    while (--i >= 0)
+      {
+        char c1 = value[x++];
+        char c2 = anotherString.value[y++];
+        // Note that checking c1 != c2 is redundant, but avoids method calls.
+        if (c1 != c2
+            && Character.toUpperCase(c1) != Character.toUpperCase(c2)
+            && Character.toLowerCase(c1) != Character.toLowerCase(c2))
+          return false;
+      }
+    return true;
+  }
+
+  /**
+   * Compares this String and another String (case sensitive,
+   * lexicographically). The result is less than 0 if this string sorts
+   * before the other, 0 if they are equal, and greater than 0 otherwise.
+   * After any common starting sequence is skipped, the result is
+   * <code>this.charAt(k) - anotherString.charAt(k)</code> if both strings
+   * have characters remaining, or
+   * <code>this.length() - anotherString.length()</code> if one string is
+   * a subsequence of the other.
+   *
+   * @param anotherString the String to compare against
+   * @return the comparison
+   * @throws NullPointerException if anotherString is null
+   */
+  public int compareTo(String anotherString)
+  {
+    int i = Math.min(count, anotherString.count);
+    int x = offset;
+    int y = anotherString.offset;
+    while (--i >= 0)
+      {
+        int result = value[x++] - anotherString.value[y++];
+        if (result != 0)
+          return result;
+      }
+    return count - anotherString.count;
+  }
+
+  /**
+   * Behaves like <code>compareTo(java.lang.String)</code> unless the Object
+   * is not a <code>String</code>.  Then it throws a
+   * <code>ClassCastException</code>.
+   *
+   * @param o the object to compare against
+   * @return the comparison
+   * @throws NullPointerException if o is null
+   * @throws ClassCastException if o is not a <code>String</code>
+   * @since 1.2
+   */
+  public int compareTo(Object o)
+  {
+    return compareTo((String) o);
+  }
+
+  /**
+   * Compares this String and another String (case insensitive). This
+   * comparison is <em>similar</em> to equalsIgnoreCase, in that it ignores
+   * locale and multi-characater capitalization, and compares characters
+   * after performing
+   * <code>Character.toLowerCase(Character.toUpperCase(c))</code> on each
+   * character of the string. This is unsatisfactory for locale-based
+   * comparison, in which case you should use {@link java.text.Collator}.
+   *
+   * @param str the string to compare against
+   * @return the comparison
+   * @see Collator#compare(String, String)
+   * @since 1.2
+   */
+  public int compareToIgnoreCase(String str)
+  {
+    int i = Math.min(count, str.count);
+    int x = offset;
+    int y = str.offset;
+    while (--i >= 0)
+      {
+        int result = Character.toLowerCase(Character.toUpperCase(value[x++]))
+          - Character.toLowerCase(Character.toUpperCase(str.value[y++]));
+        if (result != 0)
+          return result;
+      }
+    return count - str.count;
+  }  
+
+  /**
+   * Predicate which determines if this String matches another String
+   * starting at a specified offset for each String and continuing
+   * for a specified length. Indices out of bounds are harmless, and give
+   * a false result.
+   *
+   * @param toffset index to start comparison at for this String
+   * @param other String to compare region to this String
+   * @param ooffset index to start comparison at for other
+   * @param len number of characters to compare
+   * @return true if regions match (case sensitive)
+   * @throws NullPointerException if other is null
+   */
+  public boolean regionMatches(int toffset, String other, int ooffset, int len)
+  {
+    return regionMatches(false, toffset, other, ooffset, len);
+  }
+
+  /**
+   * Predicate which determines if this String matches another String
+   * starting at a specified offset for each String and continuing
+   * for a specified length, optionally ignoring case. Indices out of bounds
+   * are harmless, and give a false result. Case comparisons are based on
+   * <code>Character.toLowerCase()</code> and
+   * <code>Character.toUpperCase()</code>, not on multi-character
+   * capitalization expansions.
+   *
+   * @param ignoreCase true if case should be ignored in comparision
+   * @param toffset index to start comparison at for this String
+   * @param other String to compare region to this String
+   * @param ooffset index to start comparison at for other
+   * @param len number of characters to compare
+   * @return true if regions match, false otherwise
+   * @throws NullPointerException if other is null
+   */
+  public boolean regionMatches(boolean ignoreCase, int toffset,
+                               String other, int ooffset, int len)
+  {
+    if (toffset < 0 || ooffset < 0 || toffset + len > count
+        || ooffset + len > other.count)
+      return false;
+    toffset += offset;
+    ooffset += other.offset;
+    while (--len >= 0)
+      {
+        char c1 = value[toffset++];
+        char c2 = other.value[ooffset++];
+        // Note that checking c1 != c2 is redundant when ignoreCase is true,
+        // but it avoids method calls.
+        if (c1 != c2
+            && (! ignoreCase
+                || (Character.toLowerCase(c1) != Character.toLowerCase(c2)
+                    && (Character.toUpperCase(c1)
+                        != Character.toUpperCase(c2)))))
+          return false;
+      }
+    return true;
+  }
+
+  /**
+   * Predicate which determines if this String contains the given prefix,
+   * beginning comparison at toffset. The result is false if toffset is
+   * negative or greater than this.length(), otherwise it is the same as
+   * <code>this.substring(toffset).startsWith(prefix)</code>.
+   *
+   * @param prefix String to compare
+   * @param toffset offset for this String where comparison starts
+   * @return true if this String starts with prefix
+   * @throws NullPointerException if prefix is null
+   * @see #regionMatches(boolean, int, String, int, int)
+   */
+  public boolean startsWith(String prefix, int toffset)
+  {
+    return regionMatches(false, toffset, prefix, 0, prefix.count);
+  }
+
+  /**
+   * Predicate which determines if this String starts with a given prefix.
+   * If the prefix is an empty String, true is returned.
+   *
+   * @param prefix String to compare
+   * @return true if this String starts with the prefix
+   * @throws NullPointerException if prefix is null
+   * @see #startsWith(String, int)
+   */
+  public boolean startsWith(String prefix)
+  {
+    return regionMatches(false, 0, prefix, 0, prefix.count);
+  }
+
+  /**
+   * Predicate which determines if this String ends with a given suffix.
+   * If the suffix is an empty String, true is returned.
+   *
+   * @param suffix String to compare
+   * @return true if this String ends with the suffix
+   * @throws NullPointerException if suffix is null
+   * @see #regionMatches(boolean, int, String, int, int)
+   */
+  public boolean endsWith(String suffix)
+  {
+    return regionMatches(false, count - suffix.count, suffix, 0, suffix.count);
+  }
+
+  /**
+   * Computes the hashcode for this String. This is done with int arithmetic,
+   * where ** represents exponentiation, by this formula:<br>
+   * <code>s[0]*31**(n-1) + s[1]*31**(n-2) + ... + s[n-1]</code>.
+   *
+   * @return hashcode value of this String
+   */
+  public int hashCode()
+  {
+    if (cachedHashCode != 0)
+      return cachedHashCode;
+
+    // Compute the hash code using a local variable to be reentrant.
+    int hashCode = 0;
+    int limit = count + offset;
+    for (int i = offset; i < limit; i++)
+      hashCode = hashCode * 31 + value[i];
+    return cachedHashCode = hashCode;
+  }
+
+  /**
+   * Finds the first instance of a character in this String.
+   *
+   * @param ch character to find
+   * @return location (base 0) of the character, or -1 if not found
+   */
+  public int indexOf(int ch)
+  {
+    return indexOf(ch, 0);
+  }
+
+  /**
+   * Finds the first instance of a character in this String, starting at
+   * a given index.  If starting index is less than 0, the search
+   * starts at the beginning of this String.  If the starting index
+   * is greater than the length of this String, -1 is returned.
+   *
+   * @param ch character to find
+   * @param fromIndex index to start the search
+   * @return location (base 0) of the character, or -1 if not found
+   */
+  public int indexOf(int ch, int fromIndex)
+  {
+    if ((char) ch != ch)
+      return -1;
+    if (fromIndex < 0)
+      fromIndex = 0;
+    int i = fromIndex + offset;
+    for ( ; fromIndex < count; fromIndex++)
+      if (value[i++] == ch)
+        return fromIndex;
+    return -1;
+  }
+
+  /**
+   * Finds the last instance of a character in this String.
+   *
+   * @param ch character to find
+   * @return location (base 0) of the character, or -1 if not found
+   */
+  public int lastIndexOf(int ch)
+  {
+    return lastIndexOf(ch, count - 1);
+  }
+
+  /**
+   * Finds the last instance of a character in this String, starting at
+   * a given index.  If starting index is greater than the maximum valid
+   * index, then the search begins at the end of this String.  If the
+   * starting index is less than zero, -1 is returned.
+   *
+   * @param ch character to find
+   * @param fromIndex index to start the search
+   * @return location (base 0) of the character, or -1 if not found
+   */
+  public int lastIndexOf(int ch, int fromIndex)
+  {
+    if ((char) ch != ch)
+      return -1;
+    if (fromIndex >= count)
+      fromIndex = count - 1;
+    int i = fromIndex + offset;
+    for ( ; fromIndex >= 0; fromIndex--)
+      if (value[i--] == ch)
+        return fromIndex;
+    return -1;
+  }
+
+  /**
+   * Finds the first instance of a String in this String.
+   *
+   * @param str String to find
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   */
+  public int indexOf(String str)
+  {
+    return indexOf(str, 0);
+  }
+
+  /**
+   * Finds the first instance of a String in this String, starting at
+   * a given index.  If starting index is less than 0, the search
+   * starts at the beginning of this String.  If the starting index
+   * is greater than the length of this String, -1 is returned.
+   *
+   * @param str String to find
+   * @param fromIndex index to start the search
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   */
+  public int indexOf(String str, int fromIndex)
+  {
+    if (fromIndex < 0)
+      fromIndex = 0;
+    int limit = count - str.count;
+    for ( ; fromIndex <= limit; fromIndex++)
+      if (regionMatches(fromIndex, str, 0, str.count))
+        return fromIndex;
+    return -1;
+  }
+
+  /**
+   * Finds the last instance of a String in this String.
+   *
+   * @param str String to find
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   */
+  public int lastIndexOf(String str)
+  {
+    return lastIndexOf(str, count - str.count);
+  }
+
+  /**
+   * Finds the last instance of a String in this String, starting at
+   * a given index.  If starting index is greater than the maximum valid
+   * index, then the search begins at the end of this String.  If the
+   * starting index is less than zero, -1 is returned.
+   *
+   * @param str String to find
+   * @param fromIndex index to start the search
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   */
+  public int lastIndexOf(String str, int fromIndex)
+  {
+    fromIndex = Math.min(fromIndex, count - str.count);
+    for ( ; fromIndex >= 0; fromIndex--)
+      if (regionMatches(fromIndex, str, 0, str.count))
+        return fromIndex;
+    return -1;
+  }
+
+  /**
+   * Creates a substring of this String, starting at a specified index
+   * and ending at the end of this String.
+   *
+   * @param begin index to start substring (base 0)
+   * @return new String which is a substring of this String
+   * @throws IndexOutOfBoundsException if begin < 0 || begin > length()
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public String substring(int begin)
+  {
+    return substring(begin, count);
+  }
+
+  /**
+   * Creates a substring of this String, starting at a specified index
+   * and ending at one character before a specified index.
+   *
+   * @param beginIndex index to start substring (inclusive, base 0)
+   * @param endIndex index to end at (exclusive)
+   * @return new String which is a substring of this String
+   * @throws IndexOutOfBoundsException if begin < 0 || end > length()
+   *         || begin > end (while unspecified, this is a
+   *         StringIndexOutOfBoundsException)
+   */
+  public String substring(int beginIndex, int endIndex)
+  {
+    if (beginIndex < 0 || endIndex > count || beginIndex > endIndex)
+      throw new StringIndexOutOfBoundsException();
+    if (beginIndex == 0 && endIndex == count)
+      return this;
+    int len = endIndex - beginIndex;
+    // Package constructor avoids an array copy.
+    return new String(value, beginIndex + offset, len,
+                      (len << 2) >= value.length);
+  }
+
+  /**
+   * Creates a substring of this String, starting at a specified index
+   * and ending at one character before a specified index. This behaves like
+   * <code>substring(begin, end)</code>.
+   *
+   * @param begin index to start substring (inclusive, base 0)
+   * @param end index to end at (exclusive)
+   * @return new String which is a substring of this String
+   * @throws IndexOutOfBoundsException if begin < 0 || end > length()
+   *         || begin > end
+   * @since 1.4
+   */
+  public CharSequence subSequence(int begin, int end)
+  {
+    return substring(begin, end);
+  }
+
+  /**
+   * Concatenates a String to this String. This results in a new string unless
+   * one of the two originals is "".
+   *
+   * @param str String to append to this String
+   * @return newly concatenated String
+   * @throws NullPointerException if str is null
+   */
+  public String concat(String str)
+  {
+    if (str.count == 0)
+      return this;
+    if (count == 0)
+      return str;
+    char[] newStr = new char[count + str.count];
+    VMSystem.arraycopy(value, offset, newStr, 0, count);
+    VMSystem.arraycopy(str.value, str.offset, newStr, count, str.count);
+    // Package constructor avoids an array copy.
+    return new String(newStr, 0, newStr.length, true);
+  }
+
+  /**
+   * Replaces every instance of a character in this String with a new
+   * character. If no replacements occur, this is returned.
+   *
+   * @param oldChar the old character to replace
+   * @param newChar the new character
+   * @return new String with all instances of oldChar replaced with newChar
+   */
+  public String replace(char oldChar, char newChar)
+  {
+    if (oldChar == newChar)
+      return this;
+    int i = count;
+    int x = offset - 1;
+    while (--i >= 0)
+      if (value[++x] == oldChar)
+        break;
+    if (i < 0)
+      return this;
+    char[] newStr = (char[]) value.clone();
+    newStr[x] = newChar;
+    while (--i >= 0)
+      if (value[++x] == oldChar)
+        newStr[x] = newChar;
+    // Package constructor avoids an array copy.
+    return new String(newStr, offset, count, true);
+  }
+
+  /**
+   * Test if this String matches a regular expression. This is shorthand for
+   * <code>{@link Pattern}.matches(regex, this)</code>.
+   *
+   * @param regex the pattern to match
+   * @return true if the pattern matches
+   * @throws NullPointerException if regex is null
+   * @throws PatternSyntaxException if regex is invalid
+   * @see Pattern#matches(String, CharSequence)
+   * @since 1.4
+   */
+  public boolean matches(String regex)
+  {
+    return Pattern.matches(regex, this);
+  }
+
+  /**
+   * Replaces the first substring match of the regular expression with a
+   * given replacement. This is shorthand for <code>{@link Pattern}
+   *   .compile(regex).matcher(this).replaceFirst(replacement)</code>.
+   *
+   * @param regex the pattern to match
+   * @param replacement the replacement string
+   * @return the modified string
+   * @throws NullPointerException if regex or replacement is null
+   * @throws PatternSyntaxException if regex is invalid
+   * @see #replaceAll(String, String)
+   * @see Pattern#compile(String)
+   * @see Pattern#matcher(CharSequence)
+   * @see Matcher#replaceFirst(String)
+   * @since 1.4
+   */
+  public String replaceFirst(String regex, String replacement)
+  {
+    return Pattern.compile(regex).matcher(this).replaceFirst(replacement);
+  }
+
+  /**
+   * Replaces all matching substrings of the regular expression with a
+   * given replacement. This is shorthand for <code>{@link Pattern}
+   *   .compile(regex).matcher(this).replaceAll(replacement)</code>.
+   *
+   * @param regex the pattern to match
+   * @param replacement the replacement string
+   * @return the modified string
+   * @throws NullPointerException if regex or replacement is null
+   * @throws PatternSyntaxException if regex is invalid
+   * @see #replaceFirst(String, String)
+   * @see Pattern#compile(String)
+   * @see Pattern#matcher(CharSequence)
+   * @see Matcher#replaceAll(String)
+   * @since 1.4
+   */
+  public String replaceAll(String regex, String replacement)
+  {
+    return Pattern.compile(regex).matcher(this).replaceAll(replacement);
+  }
+
+  /**
+   * Split this string around the matches of a regular expression. Each
+   * element of the returned array is the largest block of characters not
+   * terminated by the regular expression, in the order the matches are found.
+   *
+   * <p>The limit affects the length of the array. If it is positive, the
+   * array will contain at most n elements (n - 1 pattern matches). If
+   * negative, the array length is unlimited, but there can be trailing empty
+   * entries. if 0, the array length is unlimited, and trailing empty entries
+   * are discarded.
+   *
+   * <p>For example, splitting "boo:and:foo" yields:<br>
+   * <table border=0>
+   * <th><td>Regex</td> <td>Limit</td> <td>Result</td></th>
+   * <tr><td>":"</td>   <td>2</td>  <td>{ "boo", "and:foo" }</td></tr>
+   * <tr><td>":"</td>   <td>t</td>  <td>{ "boo", "and", "foo" }</td></tr>
+   * <tr><td>":"</td>   <td>-2</td> <td>{ "boo", "and", "foo" }</td></tr>
+   * <tr><td>"o"</td>   <td>5</td>  <td>{ "b", "", ":and:f", "", "" }</td></tr>
+   * <tr><td>"o"</td>   <td>-2</td> <td>{ "b", "", ":and:f", "", "" }</td></tr>
+   * <tr><td>"o"</td>   <td>0</td>  <td>{ "b", "", ":and:f" }</td></tr>
+   * </table>
+   *
+   * <p>This is shorthand for
+   * <code>{@link Pattern}.compile(regex).split(this, limit)</code>.
+   *
+   * @param regex the pattern to match
+   * @param limit the limit threshold
+   * @return the array of split strings
+   * @throws NullPointerException if regex or replacement is null
+   * @throws PatternSyntaxException if regex is invalid
+   * @see Pattern#compile(String)
+   * @see Pattern#split(CharSequence, int)
+   * @since 1.4
+   */
+  public String[] split(String regex, int limit)
+  {
+    return Pattern.compile(regex).split(this, limit);
+  }
+
+  /**
+   * Split this string around the matches of a regular expression. Each
+   * element of the returned array is the largest block of characters not
+   * terminated by the regular expression, in the order the matches are found.
+   * The array length is unlimited, and trailing empty entries are discarded,
+   * as though calling <code>split(regex, 0)</code>.
+   *
+   * @param regex the pattern to match
+   * @return the array of split strings
+   * @throws NullPointerException if regex or replacement is null
+   * @throws PatternSyntaxException if regex is invalid
+   * @see #split(String, int)
+   * @see Pattern#compile(String)
+   * @see Pattern#split(CharSequence, int)
+   * @since 1.4
+   */
+  public String[] split(String regex)
+  {
+    return Pattern.compile(regex).split(this, 0);
+  }
+
+  /**
+   * Lowercases this String according to a particular locale. This uses
+   * Unicode's special case mappings, as applied to the given Locale, so the
+   * resulting string may be a different length.
+   *
+   * @param loc locale to use
+   * @return new lowercased String, or this if no characters were lowercased
+   * @throws NullPointerException if loc is null
+   * @see #toUpperCase(Locale)
+   * @since 1.1
+   */
+  public String toLowerCase(Locale loc)
+  {
+    // First, see if the current string is already lower case.
+    boolean turkish = "tr".equals(loc.getLanguage());
+    int i = count;
+    int x = offset - 1;
+    while (--i >= 0)
+      {
+        char ch = value[++x];
+        if ((turkish && ch == '\u0049')
+            || ch != Character.toLowerCase(ch))
+          break;
+      }
+    if (i < 0)
+      return this;
+
+    // Now we perform the conversion. Fortunately, there are no multi-character
+    // lowercase expansions in Unicode 3.0.0.
+    char[] newStr = (char[]) value.clone();
+    do
+      {
+        char ch = value[x];
+        // Hardcoded special case.
+        newStr[x++] = (turkish && ch == '\u0049') ? '\u0131'
+          : Character.toLowerCase(ch);
+      }
+    while (--i >= 0);
+    // Package constructor avoids an array copy.
+    return new String(newStr, offset, count, true);
+  }
+
+  /**
+   * Lowercases this String. This uses Unicode's special case mappings, as
+   * applied to the platform's default Locale, so the resulting string may
+   * be a different length.
+   *
+   * @return new lowercased String, or this if no characters were lowercased
+   * @see #toLowerCase(Locale)
+   * @see #toUpperCase()
+   */
+  public String toLowerCase()
+  {
+    return toLowerCase(Locale.getDefault());
+  }
+
+  /**
+   * Uppercases this String according to a particular locale. This uses
+   * Unicode's special case mappings, as applied to the given Locale, so the
+   * resulting string may be a different length.
+   *
+   * @param loc locale to use
+   * @return new uppercased String, or this if no characters were uppercased
+   * @throws NullPointerException if loc is null
+   * @see #toLowerCase(Locale)
+   * @since 1.1
+   */
+  public String toUpperCase(Locale loc)
+  {
+    // First, see how many characters we have to grow by, as well as if the
+    // current string is already upper case.
+    boolean turkish = "tr".equals(loc.getLanguage());
+    int expand = 0;
+    boolean unchanged = true;
+    int i = count;
+    int x = i + offset;
+    while (--i >= 0)
+      {
+        char ch = value[--x];
+        expand += upperCaseExpansion(ch);
+        unchanged = (unchanged && expand == 0
+                     && ! (turkish && ch == '\u0069')
+                     && ch == Character.toUpperCase(ch));
+      }
+    if (unchanged)
+      return this;
+
+    // Now we perform the conversion.
+    i = count;
+    if (expand == 0)
+      {
+        char[] newStr = (char[]) value.clone();
+        while (--i >= 0)
+          {
+            char ch = value[x];
+            // Hardcoded special case.
+            newStr[x++] = (turkish && ch == '\u0069') ? '\u0130'
+              : Character.toUpperCase(ch);
+          }
+        // Package constructor avoids an array copy.
+        return new String(newStr, offset, count, true);
+      }
+
+    // Expansion is necessary.
+    char[] newStr = new char[count + expand];
+    int j = 0;
+    while (--i >= 0)
+      {
+        char ch = value[x++];
+        // Hardcoded special case.
+        if (turkish && ch == '\u0069')
+          {
+            newStr[j++] = '\u0130';
+            continue;
+          }
+        expand = upperCaseExpansion(ch);
+        if (expand > 0)
+          {
+            int index = upperCaseIndex(ch);
+            while (expand-- >= 0)
+              newStr[j++] = upperExpand[index++];
+          }
+        else
+          newStr[j++] = Character.toUpperCase(ch);
+      }
+    // Package constructor avoids an array copy.
+    return new String(newStr, 0, newStr.length, true);
+  }
+
+  /**
+   * Uppercases this String. This uses Unicode's special case mappings, as
+   * applied to the platform's default Locale, so the resulting string may
+   * be a different length.
+   *
+   * @return new uppercased String, or this if no characters were uppercased
+   * @see #toUpperCase(Locale)
+   * @see #toLowerCase()
+   */
+  public String toUpperCase()
+  {
+    return toUpperCase(Locale.getDefault());
+  }
+
+  /**
+   * Trims all characters less than or equal to <code>'\u0020'</code>
+   * (<code>' '</code>) from the beginning and end of this String. This
+   * includes many, but not all, ASCII control characters, and all
+   * {@link Character#isWhitespace(char)}.
+   *
+   * @return new trimmed String, or this if nothing trimmed
+   */
+  public String trim()
+  {
+    int limit = count + offset;
+    if (count == 0 || (value[offset] > '\u0020'
+                       && value[limit - 1] > '\u0020'))
+      return this;
+    int begin = offset;
+    do
+      if (begin == limit)
+        return "";
+    while (value[begin++] <= '\u0020');
+    int end = limit;
+    while (value[--end] <= '\u0020');
+    return substring(begin - offset - 1, end - offset + 1);
+  }
+
+  /**
+   * Returns this, as it is already a String!
+   *
+   * @return this
+   */
+  public String toString()
+  {
+    return this;
+  }
+
+  /**
+   * Copies the contents of this String into a character array. Subsequent
+   * changes to the array do not affect the String.
+   *
+   * @return character array copying the String
+   */
+  public char[] toCharArray()
+  {
+    if (count == value.length)
+      return (char[]) value.clone();
+
+    char[] copy = new char[count];
+    VMSystem.arraycopy(value, offset, copy, 0, count);
+    return copy;
+  }
+
+  /**
+   * Returns a String representation of an Object. This is "null" if the
+   * object is null, otherwise it is <code>obj.toString()</code> (which
+   * can be null).
+   *
+   * @param obj the Object
+   * @return the string conversion of obj
+   */
+  public static String valueOf(Object obj)
+  {
+    return obj == null ? "null" : obj.toString();
+  }
+
+  /**
+   * Returns a String representation of a character array. Subsequent
+   * changes to the array do not affect the String.
+   *
+   * @param data the character array
+   * @return a String containing the same character sequence as data
+   * @throws NullPointerException if data is null
+   * @see #valueOf(char[], int, int)
+   * @see #String(char[])
+   */
+  public static String valueOf(char[] data)
+  {
+    return valueOf (data, 0, data.length);
+  }
+
+  /**
+   * Returns a String representing the character sequence of the char array,
+   * starting at the specified offset, and copying chars up to the specified
+   * count. Subsequent changes to the array do not affect the String.
+   *
+   * @param data character array
+   * @param offset position (base 0) to start copying out of data
+   * @param count the number of characters from data to copy
+   * @return String containing the chars from data[offset..offset+count]
+   * @throws NullPointerException if data is null
+   * @throws IndexOutOfBoundsException if (offset < 0 || count < 0
+   *         || offset + count < 0 (overflow)
+   *         || offset + count > data.length)
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   * @see #String(char[], int, int)
+   */
+  public static String valueOf(char[] data, int offset, int count)
+  {
+    return new String(data, offset, count, false);
+  }
+
+  /**
+   * Returns a String representing the character sequence of the char array,
+   * starting at the specified offset, and copying chars up to the specified
+   * count. Subsequent changes to the array do not affect the String.
+   *
+   * @param data character array
+   * @param offset position (base 0) to start copying out of data
+   * @param count the number of characters from data to copy
+   * @return String containing the chars from data[offset..offset+count]
+   * @throws NullPointerException if data is null
+   * @throws IndexOutOfBoundsException if (offset < 0 || count < 0
+   *         || offset + count < 0 (overflow)
+   *         || offset + count > data.length)
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   * @see #String(char[], int, int)
+   */
+  public static String copyValueOf(char[] data, int offset, int count)
+  {
+    return new String(data, offset, count, false);
+  }
+
+  /**
+   * Returns a String representation of a character array. Subsequent
+   * changes to the array do not affect the String.
+   *
+   * @param data the character array
+   * @return a String containing the same character sequence as data
+   * @throws NullPointerException if data is null
+   * @see #copyValueOf(char[], int, int)
+   * @see #String(char[])
+   */
+  public static String copyValueOf(char[] data)
+  {
+    return copyValueOf (data, 0, data.length);
+  }
+
+  /**
+   * Returns a String representing a boolean.
+   *
+   * @param b the boolean
+   * @return "true" if b is true, else "false"
+   */
+  public static String valueOf(boolean b)
+  {
+    return b ? "true" : "false";
+  }
+
+  /**
+   * Returns a String representing a character.
+   *
+   * @param c the character
+   * @return String containing the single character c
+   */
+  public static String valueOf(char c)
+  {
+    // Package constructor avoids an array copy.
+    return new String(new char[] { c }, 0, 1, true);
+  }
+
+  /**
+   * Returns a String representing an integer.
+   *
+   * @param i the integer
+   * @return String containing the integer in base 10
+   * @see Integer#toString(int)
+   */
+  public static String valueOf(int i)
+  {
+    // See Integer to understand why we call the two-arg variant.
+    return Integer.toString(i, 10);
+  }
+
+  /**
+   * Returns a String representing a long.
+   *
+   * @param l the long
+   * @return String containing the long in base 10
+   * @see Long#toString(long)
+   */
+  public static String valueOf(long l)
+  {
+    return Long.toString(l);
+  }
+
+  /**
+   * Returns a String representing a float.
+   *
+   * @param f the float
+   * @return String containing the float
+   * @see Float#toString(float)
+   */
+  public static String valueOf(float f)
+  {
+    return Float.toString(f);
+  }
+
+  /**
+   * Returns a String representing a double.
+   *
+   * @param d the double
+   * @return String containing the double
+   * @see Double#toString(double)
+   */
+  public static String valueOf(double d)
+  {
+    return Double.toString(d);
+  }
+
+  /**
+   * If two Strings are considered equal, by the equals() method, 
+   * then intern() will return the same String instance. ie. 
+   * if (s1.equals(s2)) then (s1.intern() == s2.intern()). 
+   * All string literals and string-valued constant expressions 
+   * are already interned.
+   *
+   * @return the interned String
+   */
+  public String intern()
+  {
+    return VMString.intern(this);
+  }
+
+  /**
+   * Return the number of code points between two indices in the
+   * <code>String</code>.  An unpaired surrogate counts as a
+   * code point for this purpose.  Characters outside the indicated
+   * range are not examined, even if the range ends in the middle of a
+   * surrogate pair.
+   *
+   * @param start the starting index
+   * @param end one past the ending index
+   * @return the number of code points
+   * @since 1.5
+   */
+  public synchronized int codePointCount(int start, int end)
+  {
+    if (start < 0 || end > count || start > end)
+      throw new StringIndexOutOfBoundsException();
+
+    start += offset;
+    end += offset;
+    int count = 0;
+    while (start < end)
+      {
+	char base = value[start];
+	if (base < Character.MIN_HIGH_SURROGATE
+	    || base > Character.MAX_HIGH_SURROGATE
+	    || start == end
+	    || start == count
+	    || value[start + 1] < Character.MIN_LOW_SURROGATE
+	    || value[start + 1] > Character.MAX_LOW_SURROGATE)
+	  {
+	    // Nothing.
+	  }
+	else
+	  {
+	    // Surrogate pair.
+	    ++start;
+	  }
+	++start;
+	++count;
+      }
+    return count;
+  }
+
+  /**
+   * Helper function used to detect which characters have a multi-character
+   * uppercase expansion. Note that this is only used in locations which
+   * track one-to-many capitalization (java.lang.Character does not do this).
+   * As of Unicode 3.0.0, the result is limited in the range 0 to 2, as the
+   * longest uppercase expansion is three characters (a growth of 2 from the
+   * lowercase character).
+   *
+   * @param ch the char to check
+   * @return the number of characters to add when converting to uppercase
+   * @see CharData#DIRECTION
+   * @see CharData#UPPER_SPECIAL
+   * @see #toUpperCase(Locale)
+   */
+  private static int upperCaseExpansion(char ch)
+  {
+    return Character.direction[0][Character.readCodePoint((int)ch) >> 7] & 3;
+  }
+
+  /**
+   * Helper function used to locate the offset in upperExpand given a
+   * character with a multi-character expansion. The binary search is
+   * optimized under the assumption that this method will only be called on
+   * characters which exist in upperSpecial.
+   *
+   * @param ch the char to check
+   * @return the index where its expansion begins
+   * @see CharData#UPPER_SPECIAL
+   * @see CharData#UPPER_EXPAND
+   * @see #toUpperCase(Locale)
+   */
+  private static int upperCaseIndex(char ch)
+  {
+    // Simple binary search for the correct character.
+    int low = 0;
+    int hi = upperSpecial.length - 2;
+    int mid = ((low + hi) >> 2) << 1;
+    char c = upperSpecial[mid];
+    while (ch != c)
+      {
+        if (ch < c)
+          hi = mid - 2;
+        else
+          low = mid + 2;
+        mid = ((low + hi) >> 2) << 1;
+        c = upperSpecial[mid];
+      }
+    return upperSpecial[mid + 1];
+  }
+
+  /**
+   * Returns the value array of the given string if it is zero based or a
+   * copy of it that is zero based (stripping offset and making length equal
+   * to count). Used for accessing the char[]s of gnu.java.lang.CharData.
+   * Package private for use in Character.
+   */
+  static char[] zeroBasedStringValue(String s)
+  {
+    char[] value;
+
+    if (s.offset == 0 && s.count == s.value.length)
+      value = s.value;
+    else
+      {
+	int count = s.count;
+	value = new char[count];
+	VMSystem.arraycopy(s.value, s.offset, value, 0, count);
+      }
+
+    return value;
+  }
+  
+  /**
+   * Returns true iff this String contains the sequence of Characters
+   * described in s.
+   * @param s the CharSequence
+   * @return true iff this String contains s
+   * 
+   * @since 1.5
+   */
+  public boolean contains (CharSequence s)
+  {
+    return this.indexOf(s.toString()) != -1;
+  }
+  
+  /**
+   * Returns a string that is this string with all instances of the sequence
+   * represented by <code>target</code> replaced by the sequence in 
+   * <code>replacement</code>.
+   * @param target the sequence to be replaced
+   * @param replacement the sequence used as the replacement
+   * @return the string constructed as above
+   */
+  public String replace (CharSequence target, CharSequence replacement)
+  {
+    String targetString = target.toString();
+    String replaceString = replacement.toString();
+    int targetLength = target.length();
+    int replaceLength = replacement.length();
+    
+    int startPos = this.indexOf(targetString);
+    StringBuilder result = new StringBuilder(this);    
+    while (startPos != -1)
+      {
+        // Replace the target with the replacement
+        result.replace(startPos, startPos + targetLength, replaceString);
+
+        // Search for a new occurrence of the target
+        startPos = result.indexOf(targetString, startPos + replaceLength);
+      }
+    return result.toString();
+  }
+  
+  /**
+   * Return the index into this String that is offset from the given index by 
+   * <code>codePointOffset</code> code points.
+   * @param index the index at which to start
+   * @param codePointOffset the number of code points to offset
+   * @return the index into this String that is <code>codePointOffset</code>
+   * code points offset from <code>index</code>.
+   * 
+   * @throws IndexOutOfBoundsException if index is negative or larger than the
+   * length of this string.
+   * @throws IndexOutOfBoundsException if codePointOffset is positive and the
+   * substring starting with index has fewer than codePointOffset code points.
+   * @throws IndexOutOfBoundsException if codePointOffset is negative and the
+   * substring ending with index has fewer than (-codePointOffset) code points.
+   * @since 1.5
+   */
+  public int offsetByCodePoints(int index, int codePointOffset)
+  {
+    if (index < 0 || index > count)
+      throw new IndexOutOfBoundsException();
+    
+    return Character.offsetByCodePoints(value, offset, count, offset + index,
+                                        codePointOffset);
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/StringBuffer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/StringBuffer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1188 @@
+/* StringBuffer.java -- Growable strings
+   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 java.io.Serializable;
+
+/**
+ * <code>StringBuffer</code> represents a changeable <code>String</code>.
+ * It provides the operations required to modify the
+ * <code>StringBuffer</code>, including insert, replace, delete, append,
+ * and reverse. It is thread-safe; meaning that all modifications to a buffer
+ * are in synchronized methods.
+ *
+ * <p><code>StringBuffer</code>s are variable-length in nature, so even if
+ * you initialize them to a certain size, they can still grow larger than
+ * that. <em>Capacity</em> indicates the number of characters the
+ * <code>StringBuffer</code> can have in it before it has to grow (growing
+ * the char array is an expensive operation involving <code>new</code>).
+ *
+ * <p>Incidentally, compilers often implement the String operator "+"
+ * by using a <code>StringBuffer</code> operation:<br>
+ * <code>a + b</code><br>
+ * is the same as<br>
+ * <code>new StringBuffer().append(a).append(b).toString()</code>.
+ *
+ * <p>Classpath's StringBuffer is capable of sharing memory with Strings for
+ * efficiency.  This will help when a StringBuffer is converted to a String
+ * and the StringBuffer is not changed after that (quite common when performing
+ * string concatenation).
+ *
+ * @author Paul Fisher
+ * @author John Keiser
+ * @author Tom Tromey
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see String
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public final class StringBuffer implements Serializable, CharSequence
+{
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = 3388685877147921107L;
+
+  /**
+   * Index of next available character (and thus the size of the current
+   * string contents).  Note that this has permissions set this way so that
+   * String can get the value.
+   *
+   * @serial the number of characters in the buffer
+   */
+  int count;
+
+  /**
+   * The buffer.  Note that this has permissions set this way so that String
+   * can get the value.
+   *
+   * @serial the buffer
+   */
+  char[] value;
+
+  /**
+   * True if the buffer is shared with another object (StringBuffer or
+   * String); this means the buffer must be copied before writing to it again.
+   * Note that this has permissions set this way so that String can get the
+   * value.
+   *
+   * @serial whether the buffer is shared
+   */
+  boolean shared;
+
+  /**
+   * The default capacity of a buffer.
+   */
+  private static final int DEFAULT_CAPACITY = 16;
+
+  /**
+   * Create a new StringBuffer with default capacity 16.
+   */
+  public StringBuffer()
+  {
+    this(DEFAULT_CAPACITY);
+  }
+
+  /**
+   * Create an empty <code>StringBuffer</code> with the specified initial
+   * capacity.
+   *
+   * @param capacity the initial capacity
+   * @throws NegativeArraySizeException if capacity is negative
+   */
+  public StringBuffer(int capacity)
+  {
+    value = new char[capacity];
+  }
+
+  /**
+   * Create a new <code>StringBuffer</code> with the characters in the
+   * specified <code>String</code>. Initial capacity will be the size of the
+   * String plus 16.
+   *
+   * @param str the <code>String</code> to convert
+   * @throws NullPointerException if str is null
+   */
+  public StringBuffer(String str)
+  {
+    // Unfortunately, because the size is 16 larger, we cannot share.
+    count = str.count;
+    value = new char[count + DEFAULT_CAPACITY];
+    str.getChars(0, count, value, 0);
+  }
+
+  /**
+   * Create a new <code>StringBuffer</code> with the characters from the
+   * specified <code>CharSequence</code>. Initial capacity will be the
+   * size of the CharSequence plus 16.
+   *
+   * @param sequence the <code>String</code> to convert
+   * @throws NullPointerException if str is null
+   *
+   * @since 1.5
+   */
+  public StringBuffer(CharSequence sequence)
+  {
+    count = Math.max(0, sequence.length());
+    value = new char[count + DEFAULT_CAPACITY];
+    for (int i = 0; i < count; ++i)
+      value[i] = sequence.charAt(i);
+  }
+
+  /**
+   * Get the length of the <code>String</code> this <code>StringBuffer</code>
+   * would create. Not to be confused with the <em>capacity</em> of the
+   * <code>StringBuffer</code>.
+   *
+   * @return the length of this <code>StringBuffer</code>
+   * @see #capacity()
+   * @see #setLength(int)
+   */
+  public synchronized int length()
+  {
+    return count;
+  }
+
+  /**
+   * Get the total number of characters this <code>StringBuffer</code> can
+   * support before it must be grown.  Not to be confused with <em>length</em>.
+   *
+   * @return the capacity of this <code>StringBuffer</code>
+   * @see #length()
+   * @see #ensureCapacity(int)
+   */
+  public synchronized int capacity()
+  {
+    return value.length;
+  }
+
+  /**
+   * Increase the capacity of this <code>StringBuffer</code>. This will
+   * ensure that an expensive growing operation will not occur until
+   * <code>minimumCapacity</code> is reached. The buffer is grown to the
+   * larger of <code>minimumCapacity</code> and
+   * <code>capacity() * 2 + 2</code>, if it is not already large enough.
+   *
+   * @param minimumCapacity the new capacity
+   * @see #capacity()
+   */
+  public synchronized void ensureCapacity(int minimumCapacity)
+  {
+    ensureCapacity_unsynchronized(minimumCapacity);
+  }
+
+  /**
+   * Set the length of this StringBuffer. If the new length is greater than
+   * the current length, all the new characters are set to '\0'. If the new
+   * length is less than the current length, the first <code>newLength</code>
+   * characters of the old array will be preserved, and the remaining
+   * characters are truncated.
+   *
+   * @param newLength the new length
+   * @throws IndexOutOfBoundsException if the new length is negative
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   * @see #length()
+   */
+  public synchronized void setLength(int newLength)
+  {
+    if (newLength < 0)
+      throw new StringIndexOutOfBoundsException(newLength);
+
+    int valueLength = value.length;
+
+    /* Always call ensureCapacity_unsynchronized in order to preserve
+       copy-on-write semantics.  */
+    ensureCapacity_unsynchronized(newLength);
+
+    if (newLength < valueLength)
+      {
+        /* If the StringBuffer's value just grew, then we know that
+           value is newly allocated and the region between count and
+           newLength is filled with '\0'.  */
+	count = newLength;
+      }
+    else
+      {
+	/* The StringBuffer's value doesn't need to grow.  However,
+	   we should clear out any cruft that may exist.  */
+	while (count < newLength)
+          value[count++] = '\0';
+      }
+  }
+
+  /**
+   * Get the character at the specified index.
+   *
+   * @param index the index of the character to get, starting at 0
+   * @return the character at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   */
+  public synchronized char charAt(int index)
+  {
+    if (index < 0 || index >= count)
+      throw new StringIndexOutOfBoundsException(index);
+    return value[index];
+  }
+
+  /**
+   * Get the code point at the specified index.  This is like #charAt(int),
+   * but if the character is the start of a surrogate pair, and the
+   * following character completes the pair, then the corresponding
+   * supplementary code point is returned.
+   * @param index the index of the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   * @since 1.5
+   */
+  public synchronized int codePointAt(int index)
+  {
+    return Character.codePointAt(value, index, count);
+  }
+
+  /**
+   * Get the code point before the specified index.  This is like
+   * #codePointAt(int), but checks the characters at <code>index-1</code> and
+   * <code>index-2</code> to see if they form a supplementary code point.
+   * @param index the index just past the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   * @since 1.5
+   */
+  public synchronized int codePointBefore(int index)
+  {
+    // Character.codePointBefore() doesn't perform this check.  We
+    // could use the CharSequence overload, but this is just as easy.
+    if (index >= count)
+      throw new IndexOutOfBoundsException();
+    return Character.codePointBefore(value, index, 1);
+  }
+
+  /**
+   * Get the specified array of characters. <code>srcOffset - srcEnd</code>
+   * characters will be copied into the array you pass in.
+   *
+   * @param srcOffset the index to start copying from (inclusive)
+   * @param srcEnd the index to stop copying from (exclusive)
+   * @param dst the array to copy into
+   * @param dstOffset the index to start copying into
+   * @throws NullPointerException if dst is null
+   * @throws IndexOutOfBoundsException if any source or target indices are
+   *         out of range (while unspecified, source problems cause a
+   *         StringIndexOutOfBoundsException, and dest problems cause an
+   *         ArrayIndexOutOfBoundsException)
+   * @see System#arraycopy(Object, int, Object, int, int)
+   */
+  public synchronized void getChars(int srcOffset, int srcEnd,
+                                    char[] dst, int dstOffset)
+  {
+    if (srcOffset < 0 || srcEnd > count || srcEnd < srcOffset)
+      throw new StringIndexOutOfBoundsException();
+    VMSystem.arraycopy(value, srcOffset, dst, dstOffset, srcEnd - srcOffset);
+  }
+
+  /**
+   * Set the character at the specified index.
+   *
+   * @param index the index of the character to set starting at 0
+   * @param ch the value to set that character to
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public synchronized void setCharAt(int index, char ch)
+  {
+    if (index < 0 || index >= count)
+      throw new StringIndexOutOfBoundsException(index);
+    // Call ensureCapacity to enforce copy-on-write.
+    ensureCapacity_unsynchronized(count);
+    value[index] = ch;
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param obj the <code>Object</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(Object)
+   * @see #append(String)
+   */
+  public StringBuffer append(Object obj)
+  {
+    return append(obj == null ? "null" : obj.toString());
+  }
+
+  /**
+   * Append the <code>String</code> to this <code>StringBuffer</code>. If
+   * str is null, the String "null" is appended.
+   *
+   * @param str the <code>String</code> to append
+   * @return this <code>StringBuffer</code>
+   */
+  public synchronized StringBuffer append(String str)
+  {
+    if (str == null)
+      str = "null";
+    int len = str.count;
+    ensureCapacity_unsynchronized(count + len);
+    str.getChars(0, len, value, count);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Append the <code>StringBuffer</code> value of the argument to this
+   * <code>StringBuffer</code>. This behaves the same as
+   * <code>append((Object) stringBuffer)</code>, except it is more efficient.
+   *
+   * @param stringBuffer the <code>StringBuffer</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see #append(Object)
+   * @since 1.4
+   */
+  public synchronized StringBuffer append(StringBuffer stringBuffer)
+  {
+    if (stringBuffer == null)
+      return append("null");
+    synchronized (stringBuffer)
+      {
+        int len = stringBuffer.count;
+        ensureCapacity_unsynchronized(count + len);
+        VMSystem.arraycopy(stringBuffer.value, 0, value, count, len);
+        count += len;
+      }
+    return this;
+  }
+
+  /**
+   * Append the <code>CharSequence</code> value of the argument to this
+   * <code>StringBuffer</code>.
+   *
+   * @param sequence the <code>CharSequence</code> to append
+   * @return this <code>StringBuffer</code>
+   * @see #append(Object)
+   * @since 1.5
+   */
+  public synchronized StringBuffer append(CharSequence sequence)
+  {
+    if (sequence == null)
+      sequence = "null";
+    return append(sequence, 0, sequence.length());
+  }
+
+  /**
+   * Append the specified subsequence of the <code>CharSequence</code>
+   * argument to this <code>StringBuffer</code>.
+   *
+   * @param sequence the <code>CharSequence</code> to append
+   * @param start the starting index
+   * @param end one past the ending index
+   * @return this <code>StringBuffer</code>
+   * @see #append(Object)
+   * @since 1.5
+   */
+  public synchronized StringBuffer append(CharSequence sequence,
+					  int start, int end)
+  {
+    if (sequence == null)
+      sequence = "null";
+    if (start < 0 || end < 0 || start > end || end > sequence.length())
+      throw new IndexOutOfBoundsException();
+    ensureCapacity_unsynchronized(this.count + end - start);
+    for (int i = start; i < end; ++i)
+      value[count++] = sequence.charAt(i);
+    return this;
+  }
+
+  /**
+   * Append the <code>char</code> array to this <code>StringBuffer</code>.
+   * This is similar (but more efficient) than
+   * <code>append(new String(data))</code>, except in the case of null.
+   *
+   * @param data the <code>char[]</code> to append
+   * @return this <code>StringBuffer</code>
+   * @throws NullPointerException if <code>str</code> is <code>null</code>
+   * @see #append(char[], int, int)
+   */
+  public StringBuffer append(char[] data)
+  {
+    return append(data, 0, data.length);
+  }
+
+  /**
+   * Append part of the <code>char</code> array to this
+   * <code>StringBuffer</code>. This is similar (but more efficient) than
+   * <code>append(new String(data, offset, count))</code>, except in the case
+   * of null.
+   *
+   * @param data the <code>char[]</code> to append
+   * @param offset the start location in <code>str</code>
+   * @param count the number of characters to get from <code>str</code>
+   * @return this <code>StringBuffer</code>
+   * @throws NullPointerException if <code>str</code> is <code>null</code>
+   * @throws IndexOutOfBoundsException if offset or count is out of range
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public synchronized StringBuffer append(char[] data, int offset, int count)
+  {
+    if (offset < 0 || count < 0 || offset > data.length - count)
+      throw new StringIndexOutOfBoundsException();
+    ensureCapacity_unsynchronized(this.count + count);
+    VMSystem.arraycopy(data, offset, value, this.count, count);
+    this.count += count;
+    return this;
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param bool the <code>boolean</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(boolean)
+   */
+  public StringBuffer append(boolean bool)
+  {
+    return append(bool ? "true" : "false");
+  }
+
+  /**
+   * Append the <code>char</code> to this <code>StringBuffer</code>.
+   *
+   * @param ch the <code>char</code> to append
+   * @return this <code>StringBuffer</code>
+   */
+  public synchronized StringBuffer append(char ch)
+  {
+    ensureCapacity_unsynchronized(count + 1);
+    value[count++] = ch;
+    return this;
+  }
+
+  /**
+   * Append the code point to this <code>StringBuffer</code>.
+   * This is like #append(char), but will append two characters
+   * if a supplementary code point is given.
+   *
+   * @param code the code point to append
+   * @return this <code>StringBuffer</code>
+   * @see Character#toChars(int, char[], int)
+   * @since 1.5
+   */
+  public synchronized StringBuffer appendCodePoint(int code)
+  {
+    int len = Character.charCount(code);
+    ensureCapacity_unsynchronized(count + len);
+    Character.toChars(code, value, count);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param inum the <code>int</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(int)
+   */
+  // This is native in libgcj, for efficiency.
+  public StringBuffer append(int inum)
+  {
+    return append(String.valueOf(inum));
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param lnum the <code>long</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(long)
+   */
+  public StringBuffer append(long lnum)
+  {
+    return append(Long.toString(lnum, 10));
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param fnum the <code>float</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(float)
+   */
+  public StringBuffer append(float fnum)
+  {
+    return append(Float.toString(fnum));
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param dnum the <code>double</code> to convert and append
+   * @return this <code>StringBuffer</code>
+   * @see String#valueOf(double)
+   */
+  public StringBuffer append(double dnum)
+  {
+    return append(Double.toString(dnum));
+  }
+
+  /**
+   * Delete characters from this <code>StringBuffer</code>.
+   * <code>delete(10, 12)</code> will delete 10 and 11, but not 12. It is
+   * harmless for end to be larger than length().
+   *
+   * @param start the first character to delete
+   * @param end the index after the last character to delete
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if start or end are out of bounds
+   * @since 1.2
+   */
+  public synchronized StringBuffer delete(int start, int end)
+  {
+    if (start < 0 || start > count || start > end)
+      throw new StringIndexOutOfBoundsException(start);
+    if (end > count)
+      end = count;
+    // This will unshare if required.
+    ensureCapacity_unsynchronized(count);
+    if (count - end != 0)
+      VMSystem.arraycopy(value, end, value, start, count - end);
+    count -= end - start;
+    return this;
+  }
+
+  /**
+   * Delete a character from this <code>StringBuffer</code>.
+   *
+   * @param index the index of the character to delete
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if index is out of bounds
+   * @since 1.2
+   */
+  public StringBuffer deleteCharAt(int index)
+  {
+    return delete(index, index + 1);
+  }
+
+  /**
+   * Replace characters between index <code>start</code> (inclusive) and
+   * <code>end</code> (exclusive) with <code>str</code>. If <code>end</code>
+   * is larger than the size of this StringBuffer, all characters after
+   * <code>start</code> are replaced.
+   *
+   * @param start the beginning index of characters to delete (inclusive)
+   * @param end the ending index of characters to delete (exclusive)
+   * @param str the new <code>String</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if start or end are out of bounds
+   * @throws NullPointerException if str is null
+   * @since 1.2
+   */
+  public synchronized StringBuffer replace(int start, int end, String str)
+  {
+    if (start < 0 || start > count || start > end)
+      throw new StringIndexOutOfBoundsException(start);
+
+    int len = str.count;
+    // Calculate the difference in 'count' after the replace.
+    int delta = len - (end > count ? count : end) + start;
+    ensureCapacity_unsynchronized(count + delta);
+
+    if (delta != 0 && end < count)
+      VMSystem.arraycopy(value, end, value, end + delta, count - end);
+
+    str.getChars(0, len, value, start);
+    count += delta;
+    return this;
+  }
+
+  /**
+   * Creates a substring of this StringBuffer, starting at a specified index
+   * and ending at the end of this StringBuffer.
+   *
+   * @param beginIndex index to start substring (base 0)
+   * @return new String which is a substring of this StringBuffer
+   * @throws StringIndexOutOfBoundsException if beginIndex is out of bounds
+   * @see #substring(int, int)
+   * @since 1.2
+   */
+  public String substring(int beginIndex)
+  {
+    return substring(beginIndex, count);
+  }
+
+  /**
+   * Creates a substring of this StringBuffer, starting at a specified index
+   * and ending at one character before a specified index. This is implemented
+   * the same as <code>substring(beginIndex, endIndex)</code>, to satisfy
+   * the CharSequence interface.
+   *
+   * @param beginIndex index to start at (inclusive, base 0)
+   * @param endIndex index to end at (exclusive)
+   * @return new String which is a substring of this StringBuffer
+   * @throws IndexOutOfBoundsException if beginIndex or endIndex is out of
+   *         bounds
+   * @see #substring(int, int)
+   * @since 1.4
+   */
+  public CharSequence subSequence(int beginIndex, int endIndex)
+  {
+    return substring(beginIndex, endIndex);
+  }
+
+  /**
+   * Creates a substring of this StringBuffer, starting at a specified index
+   * and ending at one character before a specified index.
+   *
+   * @param beginIndex index to start at (inclusive, base 0)
+   * @param endIndex index to end at (exclusive)
+   * @return new String which is a substring of this StringBuffer
+   * @throws StringIndexOutOfBoundsException if beginIndex or endIndex is out
+   *         of bounds
+   * @since 1.2
+   */
+  public synchronized String substring(int beginIndex, int endIndex)
+  {
+    int len = endIndex - beginIndex;
+    if (beginIndex < 0 || endIndex > count || endIndex < beginIndex)
+      throw new StringIndexOutOfBoundsException();
+    if (len == 0)
+      return "";
+    // Don't copy unless substring is smaller than 1/4 of the buffer.
+    boolean share_buffer = ((len << 2) >= value.length);
+    if (share_buffer)
+      this.shared = true;
+    // Package constructor avoids an array copy.
+    return new String(value, beginIndex, len, share_buffer);
+  }
+
+  /**
+   * Insert a subarray of the <code>char[]</code> argument into this
+   * <code>StringBuffer</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param str the <code>char[]</code> to insert
+   * @param str_offset the index in <code>str</code> to start inserting from
+   * @param len the number of characters to insert
+   * @return this <code>StringBuffer</code>
+   * @throws NullPointerException if <code>str</code> is <code>null</code>
+   * @throws StringIndexOutOfBoundsException if any index is out of bounds
+   * @since 1.2
+   */
+  public synchronized StringBuffer insert(int offset,
+                                          char[] str, int str_offset, int len)
+  {
+    if (offset < 0 || offset > count || len < 0
+        || str_offset < 0 || str_offset > str.length - len)
+      throw new StringIndexOutOfBoundsException();
+    ensureCapacity_unsynchronized(count + len);
+    VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
+    VMSystem.arraycopy(str, str_offset, value, offset, len);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param obj the <code>Object</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @exception StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(Object)
+   */
+  public StringBuffer insert(int offset, Object obj)
+  {
+    return insert(offset, obj == null ? "null" : obj.toString());
+  }
+
+  /**
+   * Insert the <code>String</code> argument into this
+   * <code>StringBuffer</code>. If str is null, the String "null" is used
+   * instead.
+   *
+   * @param offset the place to insert in this buffer
+   * @param str the <code>String</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   */
+  public synchronized StringBuffer insert(int offset, String str)
+  {
+    if (offset < 0 || offset > count)
+      throw new StringIndexOutOfBoundsException(offset);
+    if (str == null)
+      str = "null";
+    int len = str.count;
+    ensureCapacity_unsynchronized(count + len);
+    VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
+    str.getChars(0, len, value, offset);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Insert the <code>CharSequence</code> argument into this
+   * <code>StringBuffer</code>.  If the sequence is null, the String
+   * "null" is used instead.
+   *
+   * @param offset the place to insert in this buffer
+   * @param sequence the <code>CharSequence</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws IndexOutOfBoundsException if offset is out of bounds
+   * @since 1.5
+   */
+  public synchronized StringBuffer insert(int offset, CharSequence sequence)
+  {
+    if (sequence == null)
+      sequence = "null";
+    return insert(offset, sequence, 0, sequence.length());
+  }
+
+  /**
+   * Insert a subsequence of the <code>CharSequence</code> argument into this
+   * <code>StringBuffer</code>.  If the sequence is null, the String
+   * "null" is used instead.
+   *
+   * @param offset the place to insert in this buffer
+   * @param sequence the <code>CharSequence</code> to insert
+   * @param start the starting index of the subsequence
+   * @param end one past the ending index of the subsequence
+   * @return this <code>StringBuffer</code>
+   * @throws IndexOutOfBoundsException if offset, start,
+   * or end are out of bounds
+   * @since 1.5
+   */
+  public synchronized StringBuffer insert(int offset, CharSequence sequence,
+					  int start, int end)
+  {
+    if (sequence == null)
+      sequence = "null";
+    if (start < 0 || end < 0 || start > end || end > sequence.length())
+      throw new IndexOutOfBoundsException();
+    int len = end - start;
+    ensureCapacity_unsynchronized(count + len);
+    VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
+    for (int i = start; i < end; ++i)
+      value[offset++] = sequence.charAt(i);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Insert the <code>char[]</code> argument into this
+   * <code>StringBuffer</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param data the <code>char[]</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws NullPointerException if <code>data</code> is <code>null</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see #insert(int, char[], int, int)
+   */
+  public StringBuffer insert(int offset, char[] data)
+  {
+    return insert(offset, data, 0, data.length);
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param bool the <code>boolean</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(boolean)
+   */
+  public StringBuffer insert(int offset, boolean bool)
+  {
+    return insert(offset, bool ? "true" : "false");
+  }
+
+  /**
+   * Insert the <code>char</code> argument into this <code>StringBuffer</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param ch the <code>char</code> to insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   */
+  public synchronized StringBuffer insert(int offset, char ch)
+  {
+    if (offset < 0 || offset > count)
+      throw new StringIndexOutOfBoundsException(offset);
+    ensureCapacity_unsynchronized(count + 1);
+    VMSystem.arraycopy(value, offset, value, offset + 1, count - offset);
+    value[offset] = ch;
+    count++;
+    return this;
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param inum the <code>int</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(int)
+   */
+  public StringBuffer insert(int offset, int inum)
+  {
+    return insert(offset, String.valueOf(inum));
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param lnum the <code>long</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(long)
+   */
+  public StringBuffer insert(int offset, long lnum)
+  {
+    return insert(offset, Long.toString(lnum, 10));
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param fnum the <code>float</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(float)
+   */
+  public StringBuffer insert(int offset, float fnum)
+  {
+    return insert(offset, Float.toString(fnum));
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param dnum the <code>double</code> to convert and insert
+   * @return this <code>StringBuffer</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(double)
+   */
+  public StringBuffer insert(int offset, double dnum)
+  {
+    return insert(offset, Double.toString(dnum));
+  }
+
+  /**
+   * Finds the first instance of a substring in this StringBuffer.
+   *
+   * @param str String to find
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @see #indexOf(String, int)
+   * @since 1.4
+   */
+  public int indexOf(String str)
+  {
+    return indexOf(str, 0);
+  }
+
+  /**
+   * Finds the first instance of a String in this StringBuffer, starting at
+   * a given index.  If starting index is less than 0, the search starts at
+   * the beginning of this String.  If the starting index is greater than the
+   * length of this String, or the substring is not found, -1 is returned.
+   *
+   * @param str String to find
+   * @param fromIndex index to start the search
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @since 1.4
+   */
+  public synchronized int indexOf(String str, int fromIndex)
+  {
+    if (fromIndex < 0)
+      fromIndex = 0;
+    int limit = count - str.count;
+    for ( ; fromIndex <= limit; fromIndex++)
+      if (regionMatches(fromIndex, str))
+        return fromIndex;
+    return -1;
+  }
+
+  /**
+   * Finds the last instance of a substring in this StringBuffer.
+   *
+   * @param str String to find
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @see #lastIndexOf(String, int)
+   * @since 1.4
+   */
+  public int lastIndexOf(String str)
+  {
+    return lastIndexOf(str, count - str.count);
+  }
+
+  /**
+   * Finds the last instance of a String in this StringBuffer, starting at a
+   * given index.  If starting index is greater than the maximum valid index,
+   * then the search begins at the end of this String.  If the starting index
+   * is less than zero, or the substring is not found, -1 is returned.
+   *
+   * @param str String to find
+   * @param fromIndex index to start the search
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @since 1.4
+   */
+  public synchronized int lastIndexOf(String str, int fromIndex)
+  {
+    fromIndex = Math.min(fromIndex, count - str.count);
+    for ( ; fromIndex >= 0; fromIndex--)
+      if (regionMatches(fromIndex, str))
+        return fromIndex;
+    return -1;
+  }
+
+  /**
+   * Reverse the characters in this StringBuffer. The same sequence of
+   * characters exists, but in the reverse index ordering.
+   *
+   * @return this <code>StringBuffer</code>
+   */
+  public synchronized StringBuffer reverse()
+  {
+    // Call ensureCapacity to enforce copy-on-write.
+    ensureCapacity_unsynchronized(count);
+    for (int i = count >> 1, j = count - i; --i >= 0; ++j)
+      {
+        char c = value[i];
+        value[i] = value[j];
+        value[j] = c;
+      }
+    return this;
+  }
+
+  /**
+   * Convert this <code>StringBuffer</code> to a <code>String</code>. The
+   * String is composed of the characters currently in this StringBuffer. Note
+   * that the result is a copy, and that future modifications to this buffer
+   * do not affect the String.
+   *
+   * @return the characters in this StringBuffer
+   */
+  public String toString()
+  {
+    // The string will set this.shared = true.
+    return new String(this);
+  }
+
+  /**
+   * This may reduce the amount of memory used by the StringBuffer,
+   * by resizing the internal array to remove unused space.  However,
+   * this method is not required to resize, so this behavior cannot
+   * be relied upon.
+   * @since 1.5
+   */
+  public synchronized void trimToSize()
+  {
+    int wouldSave = value.length - count;
+    // Some random heuristics: if we save less than 20 characters, who
+    // cares.
+    if (wouldSave < 20)
+      return;
+    // If we save more than 200 characters, shrink.
+    // If we save more than 1/4 of the buffer, shrink.
+    if (wouldSave > 200 || wouldSave * 4 > value.length)
+      {
+	char[] newValue = new char[count];
+	VMSystem.arraycopy(value, 0, newValue, 0, count);
+	value = newValue;
+      }
+  }
+
+  /**
+   * Return the number of code points between two indices in the
+   * <code>StringBuffer</code>.  An unpaired surrogate counts as a
+   * code point for this purpose.  Characters outside the indicated
+   * range are not examined, even if the range ends in the middle of a
+   * surrogate pair.
+   *
+   * @param start the starting index
+   * @param end one past the ending index
+   * @return the number of code points
+   * @since 1.5
+   */
+  public synchronized int codePointCount(int start, int end)
+  {
+    if (start < 0 || end >= count || start > end)
+      throw new StringIndexOutOfBoundsException();
+
+    int count = 0;
+    while (start < end)
+      {
+	char base = value[start];
+	if (base < Character.MIN_HIGH_SURROGATE
+	    || base > Character.MAX_HIGH_SURROGATE
+	    || start == end
+	    || start == count
+	    || value[start + 1] < Character.MIN_LOW_SURROGATE
+	    || value[start + 1] > Character.MAX_LOW_SURROGATE)
+	  {
+	    // Nothing.
+	  }
+	else
+	  {
+	    // Surrogate pair.
+	    ++start;
+	  }
+	++start;
+	++count;
+      }
+    return count;
+  }
+
+  /**
+   * Starting at the given index, this counts forward by the indicated
+   * number of code points, and then returns the resulting index.  An
+   * unpaired surrogate counts as a single code point for this
+   * purpose.
+   *
+   * @param start the starting index
+   * @param codePoints the number of code points
+   * @return the resulting index
+   * @since 1.5
+   */
+  public synchronized int offsetByCodePoints(int start, int codePoints)
+  {
+    while (codePoints > 0)
+      {
+	char base = value[start];
+	if (base < Character.MIN_HIGH_SURROGATE
+	    || base > Character.MAX_HIGH_SURROGATE
+	    || start == count
+	    || value[start + 1] < Character.MIN_LOW_SURROGATE
+	    || value[start + 1] > Character.MAX_LOW_SURROGATE)
+	  {
+	    // Nothing.
+	  }
+	else
+	  {
+	    // Surrogate pair.
+	    ++start;
+	  }
+	++start;
+	--codePoints;
+      }
+    return start;
+  }
+
+  /**
+   * An unsynchronized version of ensureCapacity, used internally to avoid
+   * the cost of a second lock on the same object. This also has the side
+   * effect of duplicating the array, if it was shared (to form copy-on-write
+   * semantics).
+   *
+   * @param minimumCapacity the minimum capacity
+   * @see #ensureCapacity(int)
+   */
+  private void ensureCapacity_unsynchronized(int minimumCapacity)
+  {
+    if (shared || minimumCapacity > value.length)
+      {
+        // We don't want to make a larger vector when `shared' is
+        // set.  If we do, then setLength becomes very inefficient
+        // when repeatedly reusing a StringBuffer in a loop.
+        int max = (minimumCapacity > value.length
+                   ? value.length * 2 + 2
+                   : value.length);
+        minimumCapacity = (minimumCapacity < max ? max : minimumCapacity);
+        char[] nb = new char[minimumCapacity];
+        VMSystem.arraycopy(value, 0, nb, 0, count);
+        value = nb;
+        shared = false;
+      }
+  }
+
+  /**
+   * Predicate which determines if a substring of this matches another String
+   * starting at a specified offset for each String and continuing for a
+   * specified length. This is more efficient than creating a String to call
+   * indexOf on.
+   *
+   * @param toffset index to start comparison at for this String
+   * @param other non-null String to compare to region of this
+   * @return true if regions match, false otherwise
+   * @see #indexOf(String, int)
+   * @see #lastIndexOf(String, int)
+   * @see String#regionMatches(boolean, int, String, int, int)
+   */
+  private boolean regionMatches(int toffset, String other)
+  {
+    int len = other.count;
+    int index = other.offset;
+    while (--len >= 0)
+      if (value[toffset++] != other.value[index++])
+        return false;
+    return true;
+  }
+}

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

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/lang/StringBuilder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/lang/StringBuilder.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1070 @@
+/* StringBuilder.java -- Unsynchronized growable strings
+   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 java.io.Serializable;
+
+/**
+ * <code>StringBuilder</code> represents a changeable <code>String</code>.
+ * It provides the operations required to modify the
+ * <code>StringBuilder</code>, including insert, replace, delete, append,
+ * and reverse. It like <code>StringBuffer</code>, but is not
+ * synchronized.  It is ideal for use when it is known that the
+ * object will only be used from a single thread.
+ *
+ * <p><code>StringBuilder</code>s are variable-length in nature, so even if
+ * you initialize them to a certain size, they can still grow larger than
+ * that. <em>Capacity</em> indicates the number of characters the
+ * <code>StringBuilder</code> can have in it before it has to grow (growing
+ * the char array is an expensive operation involving <code>new</code>).
+ *
+ * <p>Incidentally, compilers often implement the String operator "+"
+ * by using a <code>StringBuilder</code> operation:<br>
+ * <code>a + b</code><br>
+ * is the same as<br>
+ * <code>new StringBuilder().append(a).append(b).toString()</code>.
+ *
+ * <p>Classpath's StringBuilder is capable of sharing memory with Strings for
+ * efficiency.  This will help when a StringBuilder is converted to a String
+ * and the StringBuilder is not changed after that (quite common when
+ * performing string concatenation).
+ *
+ * @author Paul Fisher
+ * @author John Keiser
+ * @author Tom Tromey
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see String
+ * @see StringBuffer
+ *
+ * @since 1.5
+ */
+// FIX15: Implement Appendable when co-variant methods are available
+public final class StringBuilder
+  implements Serializable, CharSequence
+{
+  // Implementation note: if you change this class, you usually will
+  // want to change StringBuffer as well.
+
+  /**
+   * For compatability with Sun's JDK
+   */
+  private static final long serialVersionUID = 4383685877147921099L;
+
+  /**
+   * Index of next available character (and thus the size of the current
+   * string contents).  Note that this has permissions set this way so that
+   * String can get the value.
+   *
+   * @serial the number of characters in the buffer
+   */
+  int count;
+
+  /**
+   * The buffer.  Note that this has permissions set this way so that String
+   * can get the value.
+   *
+   * @serial the buffer
+   */
+  char[] value;
+
+  /**
+   * The default capacity of a buffer.
+   */
+  private static final int DEFAULT_CAPACITY = 16;
+
+  /**
+   * Create a new StringBuilder with default capacity 16.
+   */
+  public StringBuilder()
+  {
+    this(DEFAULT_CAPACITY);
+  }
+
+  /**
+   * Create an empty <code>StringBuilder</code> with the specified initial
+   * capacity.
+   *
+   * @param capacity the initial capacity
+   * @throws NegativeArraySizeException if capacity is negative
+   */
+  public StringBuilder(int capacity)
+  {
+    value = new char[capacity];
+  }
+
+  /**
+   * Create a new <code>StringBuilder</code> with the characters in the
+   * specified <code>String</code>. Initial capacity will be the size of the
+   * String plus 16.
+   *
+   * @param str the <code>String</code> to convert
+   * @throws NullPointerException if str is null
+   */
+  public StringBuilder(String str)
+  {
+    // Unfortunately, because the size is 16 larger, we cannot share.
+    count = str.count;
+    value = new char[count + DEFAULT_CAPACITY];
+    str.getChars(0, count, value, 0);
+  }
+
+  /**
+   * Create a new <code>StringBuilder</code> with the characters in the
+   * specified <code>CharSequence</code>. Initial capacity will be the
+   * length of the sequence plus 16; if the sequence reports a length
+   * less than or equal to 0, then the initial capacity will be 16.
+   *
+   * @param seq the initializing <code>CharSequence</code>
+   * @throws NullPointerException if str is null
+   */
+  public StringBuilder(CharSequence seq)
+  {
+    int len = seq.length();
+    count = len <= 0 ? 0 : len;
+    value = new char[count + DEFAULT_CAPACITY];
+    for (int i = 0; i < len; ++i)
+      value[i] = seq.charAt(i);
+  }
+
+  /**
+   * Get the length of the <code>String</code> this <code>StringBuilder</code>
+   * would create. Not to be confused with the <em>capacity</em> of the
+   * <code>StringBuilder</code>.
+   *
+   * @return the length of this <code>StringBuilder</code>
+   * @see #capacity()
+   * @see #setLength(int)
+   */
+  public int length()
+  {
+    return count;
+  }
+
+  /**
+   * Get the total number of characters this <code>StringBuilder</code> can
+   * support before it must be grown.  Not to be confused with <em>length</em>.
+   *
+   * @return the capacity of this <code>StringBuilder</code>
+   * @see #length()
+   * @see #ensureCapacity(int)
+   */
+  public int capacity()
+  {
+    return value.length;
+  }
+
+  /**
+   * Increase the capacity of this <code>StringBuilder</code>. This will
+   * ensure that an expensive growing operation will not occur until
+   * <code>minimumCapacity</code> is reached. The buffer is grown to the
+   * larger of <code>minimumCapacity</code> and
+   * <code>capacity() * 2 + 2</code>, if it is not already large enough.
+   *
+   * @param minimumCapacity the new capacity
+   * @see #capacity()
+   */
+  public void ensureCapacity(int minimumCapacity)
+  {
+    if (minimumCapacity > value.length)
+      {
+        int max = value.length * 2 + 2;
+        minimumCapacity = (minimumCapacity < max ? max : minimumCapacity);
+        char[] nb = new char[minimumCapacity];
+        VMSystem.arraycopy(value, 0, nb, 0, count);
+        value = nb;
+      }
+  }
+
+  /**
+   * Set the length of this StringBuilder. If the new length is greater than
+   * the current length, all the new characters are set to '\0'. If the new
+   * length is less than the current length, the first <code>newLength</code>
+   * characters of the old array will be preserved, and the remaining
+   * characters are truncated.
+   *
+   * @param newLength the new length
+   * @throws IndexOutOfBoundsException if the new length is negative
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   * @see #length()
+   */
+  public void setLength(int newLength)
+  {
+    if (newLength < 0)
+      throw new StringIndexOutOfBoundsException(newLength);
+
+    int valueLength = value.length;
+
+    /* Always call ensureCapacity in order to preserve copy-on-write
+       semantics.  */
+    ensureCapacity(newLength);
+
+    if (newLength < valueLength)
+      {
+        /* If the StringBuilder's value just grew, then we know that
+           value is newly allocated and the region between count and
+           newLength is filled with '\0'.  */
+	count = newLength;
+      }
+    else
+      {
+	/* The StringBuilder's value doesn't need to grow.  However,
+	   we should clear out any cruft that may exist.  */
+	while (count < newLength)
+          value[count++] = '\0';
+      }
+  }
+
+  /**
+   * Get the character at the specified index.
+   *
+   * @param index the index of the character to get, starting at 0
+   * @return the character at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public char charAt(int index)
+  {
+    if (index < 0 || index >= count)
+      throw new StringIndexOutOfBoundsException(index);
+    return value[index];
+  }
+
+  /**
+   * Get the specified array of characters. <code>srcOffset - srcEnd</code>
+   * characters will be copied into the array you pass in.
+   *
+   * @param srcOffset the index to start copying from (inclusive)
+   * @param srcEnd the index to stop copying from (exclusive)
+   * @param dst the array to copy into
+   * @param dstOffset the index to start copying into
+   * @throws NullPointerException if dst is null
+   * @throws IndexOutOfBoundsException if any source or target indices are
+   *         out of range (while unspecified, source problems cause a
+   *         StringIndexOutOfBoundsException, and dest problems cause an
+   *         ArrayIndexOutOfBoundsException)
+   * @see System#arraycopy(Object, int, Object, int, int)
+   */
+  public void getChars(int srcOffset, int srcEnd,
+		       char[] dst, int dstOffset)
+  {
+    if (srcOffset < 0 || srcEnd > count || srcEnd < srcOffset)
+      throw new StringIndexOutOfBoundsException();
+    VMSystem.arraycopy(value, srcOffset, dst, dstOffset, srcEnd - srcOffset);
+  }
+
+  /**
+   * Set the character at the specified index.
+   *
+   * @param index the index of the character to set starting at 0
+   * @param ch the value to set that character to
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public void setCharAt(int index, char ch)
+  {
+    if (index < 0 || index >= count)
+      throw new StringIndexOutOfBoundsException(index);
+    // Call ensureCapacity to enforce copy-on-write.
+    ensureCapacity(count);
+    value[index] = ch;
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param obj the <code>Object</code> to convert and append
+   * @return this <code>StringBuilder</code>
+   * @see String#valueOf(Object)
+   * @see #append(String)
+   */
+  public StringBuilder append(Object obj)
+  {
+    return append(obj == null ? "null" : obj.toString());
+  }
+
+  /**
+   * Append the <code>String</code> to this <code>StringBuilder</code>. If
+   * str is null, the String "null" is appended.
+   *
+   * @param str the <code>String</code> to append
+   * @return this <code>StringBuilder</code>
+   */
+  public StringBuilder append(String str)
+  {
+    if (str == null)
+      str = "null";
+    int len = str.count;
+    ensureCapacity(count + len);
+    str.getChars(0, len, value, count);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Append the <code>StringBuilder</code> value of the argument to this
+   * <code>StringBuilder</code>. This behaves the same as
+   * <code>append((Object) stringBuffer)</code>, except it is more efficient.
+   *
+   * @param stringBuffer the <code>StringBuilder</code> to convert and append
+   * @return this <code>StringBuilder</code>
+   * @see #append(Object)
+   */
+  public StringBuilder append(StringBuffer stringBuffer)
+  {
+    if (stringBuffer == null)
+      return append("null");
+    synchronized (stringBuffer)
+      {
+	int len = stringBuffer.count;
+	ensureCapacity(count + len);
+	VMSystem.arraycopy(stringBuffer.value, 0, value, count, len);
+	count += len;
+      }
+    return this;
+  }
+
+  /**
+   * Append the <code>char</code> array to this <code>StringBuilder</code>.
+   * This is similar (but more efficient) than
+   * <code>append(new String(data))</code>, except in the case of null.
+   *
+   * @param data the <code>char[]</code> to append
+   * @return this <code>StringBuilder</code>
+   * @throws NullPointerException if <code>str</code> is <code>null</code>
+   * @see #append(char[], int, int)
+   */
+  public StringBuilder append(char[] data)
+  {
+    return append(data, 0, data.length);
+  }
+
+  /**
+   * Append part of the <code>char</code> array to this
+   * <code>StringBuilder</code>. This is similar (but more efficient) than
+   * <code>append(new String(data, offset, count))</code>, except in the case
+   * of null.
+   *
+   * @param data the <code>char[]</code> to append
+   * @param offset the start location in <code>str</code>
+   * @param count the number of characters to get from <code>str</code>
+   * @return this <code>StringBuilder</code>
+   * @throws NullPointerException if <code>str</code> is <code>null</code>
+   * @throws IndexOutOfBoundsException if offset or count is out of range
+   *         (while unspecified, this is a StringIndexOutOfBoundsException)
+   */
+  public StringBuilder append(char[] data, int offset, int count)
+  {
+    if (offset < 0 || count < 0 || offset > data.length - count)
+      throw new StringIndexOutOfBoundsException();
+    ensureCapacity(this.count + count);
+    VMSystem.arraycopy(data, offset, value, this.count, count);
+    this.count += count;
+    return this;
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param bool the <code>boolean</code> to convert and append
+   * @return this <code>StringBuilder</code>
+   * @see String#valueOf(boolean)
+   */
+  public StringBuilder append(boolean bool)
+  {
+    return append(bool ? "true" : "false");
+  }
+
+  /**
+   * Append the <code>char</code> to this <code>StringBuilder</code>.
+   *
+   * @param ch the <code>char</code> to append
+   * @return this <code>StringBuilder</code>
+   */
+  public StringBuilder append(char ch)
+  {
+    ensureCapacity(count + 1);
+    value[count++] = ch;
+    return this;
+  }
+
+  /**
+   * Append the characters in the <code>CharSequence</code> to this
+   * buffer.
+   *
+   * @param seq the <code>CharSequence</code> providing the characters
+   * @return this <code>StringBuilder</code>
+   */
+  public StringBuilder append(CharSequence seq)
+  {
+    return append(seq, 0, seq.length());
+  }
+
+  /**
+   * Append some characters from the <code>CharSequence</code> to this
+   * buffer.  If the argument is null, the four characters "null" are
+   * appended.
+   *
+   * @param seq the <code>CharSequence</code> providing the characters
+   * @param start the starting index
+   * @param end one past the final index
+   * @return this <code>StringBuilder</code>
+   */
+  public StringBuilder append(CharSequence seq, int start,
+			      int end)
+  {
+    if (seq == null)
+      return append("null");
+    if (end - start > 0)
+      {
+	ensureCapacity(count + end - start);
+	for (; start < end; ++start)
+	  value[count++] = seq.charAt(start);
+      }
+    return this;
+  }
+
+  /**
+   * Append the code point to this <code>StringBuilder</code>.
+   * This is like #append(char), but will append two characters
+   * if a supplementary code point is given.
+   *
+   * @param code the code point to append
+   * @return this <code>StringBuilder</code>
+   * @see Character#toChars(int, char[], int)
+   * @since 1.5
+   */
+  public synchronized StringBuilder appendCodePoint(int code)
+  {
+    int len = Character.charCount(code);
+    ensureCapacity(count + len);
+    Character.toChars(code, value, count);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param inum the <code>int</code> to convert and append
+   * @return this <code>StringBuilder</code>
+   * @see String#valueOf(int)
+   */
+  // This is native in libgcj, for efficiency.
+  public StringBuilder append(int inum)
+  {
+    return append(String.valueOf(inum));
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param lnum the <code>long</code> to convert and append
+   * @return this <code>StringBuilder</code>
+   * @see String#valueOf(long)
+   */
+  public StringBuilder append(long lnum)
+  {
+    return append(Long.toString(lnum, 10));
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param fnum the <code>float</code> to convert and append
+   * @return this <code>StringBuilder</code>
+   * @see String#valueOf(float)
+   */
+  public StringBuilder append(float fnum)
+  {
+    return append(Float.toString(fnum));
+  }
+
+  /**
+   * Append the <code>String</code> value of the argument to this
+   * <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param dnum the <code>double</code> to convert and append
+   * @return this <code>StringBuilder</code>
+   * @see String#valueOf(double)
+   */
+  public StringBuilder append(double dnum)
+  {
+    return append(Double.toString(dnum));
+  }
+
+  /**
+   * Delete characters from this <code>StringBuilder</code>.
+   * <code>delete(10, 12)</code> will delete 10 and 11, but not 12. It is
+   * harmless for end to be larger than length().
+   *
+   * @param start the first character to delete
+   * @param end the index after the last character to delete
+   * @return this <code>StringBuilder</code>
+   * @throws StringIndexOutOfBoundsException if start or end are out of bounds
+   */
+  public StringBuilder delete(int start, int end)
+  {
+    if (start < 0 || start > count || start > end)
+      throw new StringIndexOutOfBoundsException(start);
+    if (end > count)
+      end = count;
+    // This will unshare if required.
+    ensureCapacity(count);
+    if (count - end != 0)
+      VMSystem.arraycopy(value, end, value, start, count - end);
+    count -= end - start;
+    return this;
+  }
+
+  /**
+   * Delete a character from this <code>StringBuilder</code>.
+   *
+   * @param index the index of the character to delete
+   * @return this <code>StringBuilder</code>
+   * @throws StringIndexOutOfBoundsException if index is out of bounds
+   */
+  public StringBuilder deleteCharAt(int index)
+  {
+    return delete(index, index + 1);
+  }
+
+  /**
+   * Replace characters between index <code>start</code> (inclusive) and
+   * <code>end</code> (exclusive) with <code>str</code>. If <code>end</code>
+   * is larger than the size of this StringBuilder, all characters after
+   * <code>start</code> are replaced.
+   *
+   * @param start the beginning index of characters to delete (inclusive)
+   * @param end the ending index of characters to delete (exclusive)
+   * @param str the new <code>String</code> to insert
+   * @return this <code>StringBuilder</code>
+   * @throws StringIndexOutOfBoundsException if start or end are out of bounds
+   * @throws NullPointerException if str is null
+   */
+  public StringBuilder replace(int start, int end, String str)
+  {
+    if (start < 0 || start > count || start > end)
+      throw new StringIndexOutOfBoundsException(start);
+
+    int len = str.count;
+    // Calculate the difference in 'count' after the replace.
+    int delta = len - (end > count ? count : end) + start;
+    ensureCapacity(count + delta);
+
+    if (delta != 0 && end < count)
+      VMSystem.arraycopy(value, end, value, end + delta, count - end);
+
+    str.getChars(0, len, value, start);
+    count += delta;
+    return this;
+  }
+
+  /**
+   * Creates a substring of this StringBuilder, starting at a specified index
+   * and ending at the end of this StringBuilder.
+   *
+   * @param beginIndex index to start substring (base 0)
+   * @return new String which is a substring of this StringBuilder
+   * @throws StringIndexOutOfBoundsException if beginIndex is out of bounds
+   * @see #substring(int, int)
+   */
+  public String substring(int beginIndex)
+  {
+    return substring(beginIndex, count);
+  }
+
+  /**
+   * Creates a substring of this StringBuilder, starting at a specified index
+   * and ending at one character before a specified index. This is implemented
+   * the same as <code>substring(beginIndex, endIndex)</code>, to satisfy
+   * the CharSequence interface.
+   *
+   * @param beginIndex index to start at (inclusive, base 0)
+   * @param endIndex index to end at (exclusive)
+   * @return new String which is a substring of this StringBuilder
+   * @throws IndexOutOfBoundsException if beginIndex or endIndex is out of
+   *         bounds
+   * @see #substring(int, int)
+   */
+  public CharSequence subSequence(int beginIndex, int endIndex)
+  {
+    return substring(beginIndex, endIndex);
+  }
+
+  /**
+   * Creates a substring of this StringBuilder, starting at a specified index
+   * and ending at one character before a specified index.
+   *
+   * @param beginIndex index to start at (inclusive, base 0)
+   * @param endIndex index to end at (exclusive)
+   * @return new String which is a substring of this StringBuilder
+   * @throws StringIndexOutOfBoundsException if beginIndex or endIndex is out
+   *         of bounds
+   */
+  public String substring(int beginIndex, int endIndex)
+  {
+    int len = endIndex - beginIndex;
+    if (beginIndex < 0 || endIndex > count || endIndex < beginIndex)
+      throw new StringIndexOutOfBoundsException();
+    if (len == 0)
+      return "";
+    return new String(value, beginIndex, len);
+  }
+
+  /**
+   * Insert a subarray of the <code>char[]</code> argument into this
+   * <code>StringBuilder</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param str the <code>char[]</code> to insert
+   * @param str_offset the index in <code>str</code> to start inserting from
+   * @param len the number of characters to insert
+   * @return this <code>StringBuilder</code>
+   * @throws NullPointerException if <code>str</code> is <code>null</code>
+   * @throws StringIndexOutOfBoundsException if any index is out of bounds
+   */
+  public StringBuilder insert(int offset,
+			      char[] str, int str_offset, int len)
+  {
+    if (offset < 0 || offset > count || len < 0
+        || str_offset < 0 || str_offset > str.length - len)
+      throw new StringIndexOutOfBoundsException();
+    ensureCapacity(count + len);
+    VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
+    VMSystem.arraycopy(str, str_offset, value, offset, len);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param obj the <code>Object</code> to convert and insert
+   * @return this <code>StringBuilder</code>
+   * @exception StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(Object)
+   */
+  public StringBuilder insert(int offset, Object obj)
+  {
+    return insert(offset, obj == null ? "null" : obj.toString());
+  }
+
+  /**
+   * Insert the <code>String</code> argument into this
+   * <code>StringBuilder</code>. If str is null, the String "null" is used
+   * instead.
+   *
+   * @param offset the place to insert in this buffer
+   * @param str the <code>String</code> to insert
+   * @return this <code>StringBuilder</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   */
+  public StringBuilder insert(int offset, String str)
+  {
+    if (offset < 0 || offset > count)
+      throw new StringIndexOutOfBoundsException(offset);
+    if (str == null)
+      str = "null";
+    int len = str.count;
+    ensureCapacity(count + len);
+    VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
+    str.getChars(0, len, value, offset);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Insert the <code>CharSequence</code> argument into this
+   * <code>StringBuilder</code>.  If the sequence is null, the String
+   * "null" is used instead.
+   *
+   * @param offset the place to insert in this buffer
+   * @param sequence the <code>CharSequence</code> to insert
+   * @return this <code>StringBuilder</code>
+   * @throws IndexOutOfBoundsException if offset is out of bounds
+   */
+  public synchronized StringBuilder insert(int offset, CharSequence sequence)
+  {
+    if (sequence == null)
+      sequence = "null";
+    return insert(offset, sequence, 0, sequence.length());
+  }
+
+  /**
+   * Insert a subsequence of the <code>CharSequence</code> argument into this
+   * <code>StringBuilder</code>.  If the sequence is null, the String
+   * "null" is used instead.
+   *
+   * @param offset the place to insert in this buffer
+   * @param sequence the <code>CharSequence</code> to insert
+   * @param start the starting index of the subsequence
+   * @param end one past the ending index of the subsequence
+   * @return this <code>StringBuilder</code>
+   * @throws IndexOutOfBoundsException if offset, start,
+   * or end are out of bounds
+   */
+  public synchronized StringBuilder insert(int offset, CharSequence sequence,
+                      int start, int end)
+  {
+    if (sequence == null)
+      sequence = "null";
+    if (start < 0 || end < 0 || start > end || end > sequence.length())
+      throw new IndexOutOfBoundsException();
+    int len = end - start;
+    ensureCapacity(count + len);
+    VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
+    for (int i = start; i < end; ++i)
+      value[offset++] = sequence.charAt(i);
+    count += len;
+    return this;
+  }
+
+  /**
+   * Insert the <code>char[]</code> argument into this
+   * <code>StringBuilder</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param data the <code>char[]</code> to insert
+   * @return this <code>StringBuilder</code>
+   * @throws NullPointerException if <code>data</code> is <code>null</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see #insert(int, char[], int, int)
+   */
+  public StringBuilder insert(int offset, char[] data)
+  {
+    return insert(offset, data, 0, data.length);
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param bool the <code>boolean</code> to convert and insert
+   * @return this <code>StringBuilder</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(boolean)
+   */
+  public StringBuilder insert(int offset, boolean bool)
+  {
+    return insert(offset, bool ? "true" : "false");
+  }
+
+  /**
+   * Insert the <code>char</code> argument into this <code>StringBuilder</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param ch the <code>char</code> to insert
+   * @return this <code>StringBuilder</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   */
+  public StringBuilder insert(int offset, char ch)
+  {
+    if (offset < 0 || offset > count)
+      throw new StringIndexOutOfBoundsException(offset);
+    ensureCapacity(count + 1);
+    VMSystem.arraycopy(value, offset, value, offset + 1, count - offset);
+    value[offset] = ch;
+    count++;
+    return this;
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param inum the <code>int</code> to convert and insert
+   * @return this <code>StringBuilder</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(int)
+   */
+  public StringBuilder insert(int offset, int inum)
+  {
+    return insert(offset, String.valueOf(inum));
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param lnum the <code>long</code> to convert and insert
+   * @return this <code>StringBuilder</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(long)
+   */
+  public StringBuilder insert(int offset, long lnum)
+  {
+    return insert(offset, Long.toString(lnum, 10));
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param fnum the <code>float</code> to convert and insert
+   * @return this <code>StringBuilder</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(float)
+   */
+  public StringBuilder insert(int offset, float fnum)
+  {
+    return insert(offset, Float.toString(fnum));
+  }
+
+  /**
+   * Insert the <code>String</code> value of the argument into this
+   * <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
+   * to <code>String</code>.
+   *
+   * @param offset the place to insert in this buffer
+   * @param dnum the <code>double</code> to convert and insert
+   * @return this <code>StringBuilder</code>
+   * @throws StringIndexOutOfBoundsException if offset is out of bounds
+   * @see String#valueOf(double)
+   */
+  public StringBuilder insert(int offset, double dnum)
+  {
+    return insert(offset, Double.toString(dnum));
+  }
+
+  /**
+   * Finds the first instance of a substring in this StringBuilder.
+   *
+   * @param str String to find
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @see #indexOf(String, int)
+   */
+  public int indexOf(String str)
+  {
+    return indexOf(str, 0);
+  }
+
+  /**
+   * Finds the first instance of a String in this StringBuilder, starting at
+   * a given index.  If starting index is less than 0, the search starts at
+   * the beginning of this String.  If the starting index is greater than the
+   * length of this String, or the substring is not found, -1 is returned.
+   *
+   * @param str String to find
+   * @param fromIndex index to start the search
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   */
+  public int indexOf(String str, int fromIndex)
+  {
+    if (fromIndex < 0)
+      fromIndex = 0;
+    int limit = count - str.count;
+    for ( ; fromIndex <= limit; fromIndex++)
+      if (regionMatches(fromIndex, str))
+        return fromIndex;
+    return -1;
+  }
+
+  /**
+   * Finds the last instance of a substring in this StringBuilder.
+   *
+   * @param str String to find
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   * @see #lastIndexOf(String, int)
+   */
+  public int lastIndexOf(String str)
+  {
+    return lastIndexOf(str, count - str.count);
+  }
+
+  /**
+   * Finds the last instance of a String in this StringBuilder, starting at a
+   * given index.  If starting index is greater than the maximum valid index,
+   * then the search begins at the end of this String.  If the starting index
+   * is less than zero, or the substring is not found, -1 is returned.
+   *
+   * @param str String to find
+   * @param fromIndex index to start the search
+   * @return location (base 0) of the String, or -1 if not found
+   * @throws NullPointerException if str is null
+   */
+  public int lastIndexOf(String str, int fromIndex)
+  {
+    fromIndex = Math.min(fromIndex, count - str.count);
+    for ( ; fromIndex >= 0; fromIndex--)
+      if (regionMatches(fromIndex, str))
+        return fromIndex;
+    return -1;
+  }
+
+  /**
+   * Reverse the characters in this StringBuilder. The same sequence of
+   * characters exists, but in the reverse index ordering.
+   *
+   * @return this <code>StringBuilder</code>
+   */
+  public StringBuilder reverse()
+  {
+    // Call ensureCapacity to enforce copy-on-write.
+    ensureCapacity(count);
+    for (int i = count >> 1, j = count - i; --i >= 0; ++j)
+      {
+        char c = value[i];
+        value[i] = value[j];
+        value[j] = c;
+      }
+    return this;
+  }
+
+  /**
+   * Convert this <code>StringBuilder</code> to a <code>String</code>. The
+   * String is composed of the characters currently in this StringBuilder. Note
+   * that the result is a copy, and that future modifications to this buffer
+   * do not affect the String.
+   *
+   * @return the characters in this StringBuilder
+   */
+  public String toString()
+  {
+    return new String(this);
+  }
+
+  /**
+   * Predicate which determines if a substring of this matches another String
+   * starting at a specified offset for each String and continuing for a
+   * specified length. This is more efficient than creating a String to call
+   * indexOf on.
+   *
+   * @param toffset index to start comparison at for this String
+   * @param other non-null String to compare to region of this
+   * @return true if regions match, false otherwise
+   * @see #indexOf(String, int)
+   * @see #lastIndexOf(String, int)
+   * @see String#regionMatches(boolean, int, String, int, int)
+   */
+  private boolean regionMatches(int toffset, String other)
+  {
+    int len = other.count;
+    int index = other.offset;
+    while (--len >= 0)
+      if (value[toffset++] != other.value[index++])
+        return false;
+    return true;
+  }
+
+  /**
+   * Get the code point at the specified index.  This is like #charAt(int),
+   * but if the character is the start of a surrogate pair, and the
+   * following character completes the pair, then the corresponding
+   * supplementary code point is returned.
+   * @param index the index of the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   * @since 1.5
+   */
+  public int codePointAt(int index)
+  {
+    return Character.codePointAt(value, index, count);
+  }
+
+    /**
+   * Get the code point before the specified index.  This is like
+   * #codePointAt(int), but checks the characters at <code>index-1</code> and
+   * <code>index-2</code> to see if they form a supplementary code point.
+   * @param index the index just past the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or >= length()
+   * @since 1.5
+   */
+  public int codePointBefore(int index)
+  {
+    // Character.codePointBefore() doesn't perform this check.  We
+    // could use the CharSequence overload, but this is just as easy.
+    if (index >= count)
+      throw new IndexOutOfBoundsException();
+    return Character.codePointBefore(value, index, 1);
+  }
+
+  /**
+   * Returns the number of Unicode code points in the specified sub sequence.
+   * Surrogate pairs count as one code point.
+   * @param beginIndex the start of the subarray
+   * @param endIndex the index after the last char in the subarray
+   * @return the number of code points
+   * @throws IndexOutOfBoundsException if beginIndex is less than zero or 
+   * greater than endIndex or if endIndex is greater than the length of this 
+   * StringBuilder
+   */
+  public int codePointCount(int beginIndex,int endIndex)
+  {
+    if (beginIndex < 0 || beginIndex > endIndex || endIndex > count)
+      throw new IndexOutOfBoundsException("invalid indices: " + beginIndex
+                                          + ", " + endIndex);
+    return Character.codePointCount(value, beginIndex, endIndex - beginIndex);
+  }
+
+  public void trimToSize()
+  {
+    if (count < value.length)
+      {
+        char[] newValue = new char[count];
+        VMSystem.arraycopy(value, 0, newValue, 0, count);
+        value = newValue;
+      }
+  }
+}





More information about the llvm-commits mailing list