Merging second batch of JDK classes emul
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 29 Sep 2012 06:39:39 +0200
branchemul
changeset 53479af3c3f834
parent 51 506ef276a0db
parent 52 94c1a17117f3
child 54 e7160b348c34
Merging second batch of JDK classes
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/emul/src/main/java/java/lang/CharSequence.java	Sat Sep 29 06:39:39 2012 +0200
     1.3 @@ -0,0 +1,111 @@
     1.4 +/*
     1.5 + * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package java.lang;
    1.30 +
    1.31 +
    1.32 +/**
    1.33 + * A <tt>CharSequence</tt> is a readable sequence of <code>char</code> values. This
    1.34 + * interface provides uniform, read-only access to many different kinds of
    1.35 + * <code>char</code> sequences.
    1.36 + * A <code>char</code> value represents a character in the <i>Basic
    1.37 + * Multilingual Plane (BMP)</i> or a surrogate. Refer to <a
    1.38 + * href="Character.html#unicode">Unicode Character Representation</a> for details.
    1.39 + *
    1.40 + * <p> This interface does not refine the general contracts of the {@link
    1.41 + * java.lang.Object#equals(java.lang.Object) equals} and {@link
    1.42 + * java.lang.Object#hashCode() hashCode} methods.  The result of comparing two
    1.43 + * objects that implement <tt>CharSequence</tt> is therefore, in general,
    1.44 + * undefined.  Each object may be implemented by a different class, and there
    1.45 + * is no guarantee that each class will be capable of testing its instances
    1.46 + * for equality with those of the other.  It is therefore inappropriate to use
    1.47 + * arbitrary <tt>CharSequence</tt> instances as elements in a set or as keys in
    1.48 + * a map. </p>
    1.49 + *
    1.50 + * @author Mike McCloskey
    1.51 + * @since 1.4
    1.52 + * @spec JSR-51
    1.53 + */
    1.54 +
    1.55 +public interface CharSequence {
    1.56 +
    1.57 +    /**
    1.58 +     * Returns the length of this character sequence.  The length is the number
    1.59 +     * of 16-bit <code>char</code>s in the sequence.</p>
    1.60 +     *
    1.61 +     * @return  the number of <code>char</code>s in this sequence
    1.62 +     */
    1.63 +    int length();
    1.64 +
    1.65 +    /**
    1.66 +     * Returns the <code>char</code> value at the specified index.  An index ranges from zero
    1.67 +     * to <tt>length() - 1</tt>.  The first <code>char</code> value of the sequence is at
    1.68 +     * index zero, the next at index one, and so on, as for array
    1.69 +     * indexing. </p>
    1.70 +     *
    1.71 +     * <p>If the <code>char</code> value specified by the index is a
    1.72 +     * <a href="{@docRoot}/java/lang/Character.html#unicode">surrogate</a>, the surrogate
    1.73 +     * value is returned.
    1.74 +     *
    1.75 +     * @param   index   the index of the <code>char</code> value to be returned
    1.76 +     *
    1.77 +     * @return  the specified <code>char</code> value
    1.78 +     *
    1.79 +     * @throws  IndexOutOfBoundsException
    1.80 +     *          if the <tt>index</tt> argument is negative or not less than
    1.81 +     *          <tt>length()</tt>
    1.82 +     */
    1.83 +    char charAt(int index);
    1.84 +
    1.85 +    /**
    1.86 +     * Returns a new <code>CharSequence</code> that is a subsequence of this sequence.
    1.87 +     * The subsequence starts with the <code>char</code> value at the specified index and
    1.88 +     * ends with the <code>char</code> value at index <tt>end - 1</tt>.  The length
    1.89 +     * (in <code>char</code>s) of the
    1.90 +     * returned sequence is <tt>end - start</tt>, so if <tt>start == end</tt>
    1.91 +     * then an empty sequence is returned. </p>
    1.92 +     *
    1.93 +     * @param   start   the start index, inclusive
    1.94 +     * @param   end     the end index, exclusive
    1.95 +     *
    1.96 +     * @return  the specified subsequence
    1.97 +     *
    1.98 +     * @throws  IndexOutOfBoundsException
    1.99 +     *          if <tt>start</tt> or <tt>end</tt> are negative,
   1.100 +     *          if <tt>end</tt> is greater than <tt>length()</tt>,
   1.101 +     *          or if <tt>start</tt> is greater than <tt>end</tt>
   1.102 +     */
   1.103 +    CharSequence subSequence(int start, int end);
   1.104 +
   1.105 +    /**
   1.106 +     * Returns a string containing the characters in this sequence in the same
   1.107 +     * order as this sequence.  The length of the string will be the length of
   1.108 +     * this sequence. </p>
   1.109 +     *
   1.110 +     * @return  a string consisting of exactly this sequence of characters
   1.111 +     */
   1.112 +    public String toString();
   1.113 +
   1.114 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/emul/src/main/java/java/lang/Comparable.java	Sat Sep 29 06:39:39 2012 +0200
     2.3 @@ -0,0 +1,138 @@
     2.4 +/*
     2.5 + * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.  Oracle designates this
    2.11 + * particular file as subject to the "Classpath" exception as provided
    2.12 + * by Oracle in the LICENSE file that accompanied this code.
    2.13 + *
    2.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.17 + * version 2 for more details (a copy is included in the LICENSE file that
    2.18 + * accompanied this code).
    2.19 + *
    2.20 + * You should have received a copy of the GNU General Public License version
    2.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.23 + *
    2.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.25 + * or visit www.oracle.com if you need additional information or have any
    2.26 + * questions.
    2.27 + */
    2.28 +
    2.29 +package java.lang;
    2.30 +import java.util.*;
    2.31 +
    2.32 +/**
    2.33 + * This interface imposes a total ordering on the objects of each class that
    2.34 + * implements it.  This ordering is referred to as the class's <i>natural
    2.35 + * ordering</i>, and the class's <tt>compareTo</tt> method is referred to as
    2.36 + * its <i>natural comparison method</i>.<p>
    2.37 + *
    2.38 + * Lists (and arrays) of objects that implement this interface can be sorted
    2.39 + * automatically by {@link Collections#sort(List) Collections.sort} (and
    2.40 + * {@link Arrays#sort(Object[]) Arrays.sort}).  Objects that implement this
    2.41 + * interface can be used as keys in a {@linkplain SortedMap sorted map} or as
    2.42 + * elements in a {@linkplain SortedSet sorted set}, without the need to
    2.43 + * specify a {@linkplain Comparator comparator}.<p>
    2.44 + *
    2.45 + * The natural ordering for a class <tt>C</tt> is said to be <i>consistent
    2.46 + * with equals</i> if and only if <tt>e1.compareTo(e2) == 0</tt> has
    2.47 + * the same boolean value as <tt>e1.equals(e2)</tt> for every
    2.48 + * <tt>e1</tt> and <tt>e2</tt> of class <tt>C</tt>.  Note that <tt>null</tt>
    2.49 + * is not an instance of any class, and <tt>e.compareTo(null)</tt> should
    2.50 + * throw a <tt>NullPointerException</tt> even though <tt>e.equals(null)</tt>
    2.51 + * returns <tt>false</tt>.<p>
    2.52 + *
    2.53 + * It is strongly recommended (though not required) that natural orderings be
    2.54 + * consistent with equals.  This is so because sorted sets (and sorted maps)
    2.55 + * without explicit comparators behave "strangely" when they are used with
    2.56 + * elements (or keys) whose natural ordering is inconsistent with equals.  In
    2.57 + * particular, such a sorted set (or sorted map) violates the general contract
    2.58 + * for set (or map), which is defined in terms of the <tt>equals</tt>
    2.59 + * method.<p>
    2.60 + *
    2.61 + * For example, if one adds two keys <tt>a</tt> and <tt>b</tt> such that
    2.62 + * <tt>(!a.equals(b) && a.compareTo(b) == 0)</tt> to a sorted
    2.63 + * set that does not use an explicit comparator, the second <tt>add</tt>
    2.64 + * operation returns false (and the size of the sorted set does not increase)
    2.65 + * because <tt>a</tt> and <tt>b</tt> are equivalent from the sorted set's
    2.66 + * perspective.<p>
    2.67 + *
    2.68 + * Virtually all Java core classes that implement <tt>Comparable</tt> have natural
    2.69 + * orderings that are consistent with equals.  One exception is
    2.70 + * <tt>java.math.BigDecimal</tt>, whose natural ordering equates
    2.71 + * <tt>BigDecimal</tt> objects with equal values and different precisions
    2.72 + * (such as 4.0 and 4.00).<p>
    2.73 + *
    2.74 + * For the mathematically inclined, the <i>relation</i> that defines
    2.75 + * the natural ordering on a given class C is:<pre>
    2.76 + *       {(x, y) such that x.compareTo(y) &lt;= 0}.
    2.77 + * </pre> The <i>quotient</i> for this total order is: <pre>
    2.78 + *       {(x, y) such that x.compareTo(y) == 0}.
    2.79 + * </pre>
    2.80 + *
    2.81 + * It follows immediately from the contract for <tt>compareTo</tt> that the
    2.82 + * quotient is an <i>equivalence relation</i> on <tt>C</tt>, and that the
    2.83 + * natural ordering is a <i>total order</i> on <tt>C</tt>.  When we say that a
    2.84 + * class's natural ordering is <i>consistent with equals</i>, we mean that the
    2.85 + * quotient for the natural ordering is the equivalence relation defined by
    2.86 + * the class's {@link Object#equals(Object) equals(Object)} method:<pre>
    2.87 + *     {(x, y) such that x.equals(y)}. </pre><p>
    2.88 + *
    2.89 + * This interface is a member of the
    2.90 + * <a href="{@docRoot}/../technotes/guides/collections/index.html">
    2.91 + * Java Collections Framework</a>.
    2.92 + *
    2.93 + * @param <T> the type of objects that this object may be compared to
    2.94 + *
    2.95 + * @author  Josh Bloch
    2.96 + * @see java.util.Comparator
    2.97 + * @since 1.2
    2.98 + */
    2.99 +
   2.100 +public interface Comparable<T> {
   2.101 +    /**
   2.102 +     * Compares this object with the specified object for order.  Returns a
   2.103 +     * negative integer, zero, or a positive integer as this object is less
   2.104 +     * than, equal to, or greater than the specified object.
   2.105 +     *
   2.106 +     * <p>The implementor must ensure <tt>sgn(x.compareTo(y)) ==
   2.107 +     * -sgn(y.compareTo(x))</tt> for all <tt>x</tt> and <tt>y</tt>.  (This
   2.108 +     * implies that <tt>x.compareTo(y)</tt> must throw an exception iff
   2.109 +     * <tt>y.compareTo(x)</tt> throws an exception.)
   2.110 +     *
   2.111 +     * <p>The implementor must also ensure that the relation is transitive:
   2.112 +     * <tt>(x.compareTo(y)&gt;0 &amp;&amp; y.compareTo(z)&gt;0)</tt> implies
   2.113 +     * <tt>x.compareTo(z)&gt;0</tt>.
   2.114 +     *
   2.115 +     * <p>Finally, the implementor must ensure that <tt>x.compareTo(y)==0</tt>
   2.116 +     * implies that <tt>sgn(x.compareTo(z)) == sgn(y.compareTo(z))</tt>, for
   2.117 +     * all <tt>z</tt>.
   2.118 +     *
   2.119 +     * <p>It is strongly recommended, but <i>not</i> strictly required that
   2.120 +     * <tt>(x.compareTo(y)==0) == (x.equals(y))</tt>.  Generally speaking, any
   2.121 +     * class that implements the <tt>Comparable</tt> interface and violates
   2.122 +     * this condition should clearly indicate this fact.  The recommended
   2.123 +     * language is "Note: this class has a natural ordering that is
   2.124 +     * inconsistent with equals."
   2.125 +     *
   2.126 +     * <p>In the foregoing description, the notation
   2.127 +     * <tt>sgn(</tt><i>expression</i><tt>)</tt> designates the mathematical
   2.128 +     * <i>signum</i> function, which is defined to return one of <tt>-1</tt>,
   2.129 +     * <tt>0</tt>, or <tt>1</tt> according to whether the value of
   2.130 +     * <i>expression</i> is negative, zero or positive.
   2.131 +     *
   2.132 +     * @param   o the object to be compared.
   2.133 +     * @return  a negative integer, zero, or a positive integer as this object
   2.134 +     *          is less than, equal to, or greater than the specified object.
   2.135 +     *
   2.136 +     * @throws NullPointerException if the specified object is null
   2.137 +     * @throws ClassCastException if the specified object's type prevents it
   2.138 +     *         from being compared to this object.
   2.139 +     */
   2.140 +    public int compareTo(T o);
   2.141 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/emul/src/main/java/java/lang/Deprecated.java	Sat Sep 29 06:39:39 2012 +0200
     3.3 @@ -0,0 +1,44 @@
     3.4 +/*
     3.5 + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.  Oracle designates this
    3.11 + * particular file as subject to the "Classpath" exception as provided
    3.12 + * by Oracle in the LICENSE file that accompanied this code.
    3.13 + *
    3.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.17 + * version 2 for more details (a copy is included in the LICENSE file that
    3.18 + * accompanied this code).
    3.19 + *
    3.20 + * You should have received a copy of the GNU General Public License version
    3.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.23 + *
    3.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.25 + * or visit www.oracle.com if you need additional information or have any
    3.26 + * questions.
    3.27 + */
    3.28 +
    3.29 +package java.lang;
    3.30 +
    3.31 +import java.lang.annotation.*;
    3.32 +import static java.lang.annotation.ElementType.*;
    3.33 +
    3.34 +/**
    3.35 + * A program element annotated &#64;Deprecated is one that programmers
    3.36 + * are discouraged from using, typically because it is dangerous,
    3.37 + * or because a better alternative exists.  Compilers warn when a
    3.38 + * deprecated program element is used or overridden in non-deprecated code.
    3.39 + *
    3.40 + * @author  Neal Gafter
    3.41 + * @since 1.5
    3.42 + */
    3.43 +@Documented
    3.44 +@Retention(RetentionPolicy.RUNTIME)
    3.45 +@Target(value={CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE})
    3.46 +public @interface Deprecated {
    3.47 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/emul/src/main/java/java/lang/Exception.java	Sat Sep 29 06:39:39 2012 +0200
     4.3 @@ -0,0 +1,124 @@
     4.4 +/*
     4.5 + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
     4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.7 + *
     4.8 + * This code is free software; you can redistribute it and/or modify it
     4.9 + * under the terms of the GNU General Public License version 2 only, as
    4.10 + * published by the Free Software Foundation.  Oracle designates this
    4.11 + * particular file as subject to the "Classpath" exception as provided
    4.12 + * by Oracle in the LICENSE file that accompanied this code.
    4.13 + *
    4.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    4.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    4.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    4.17 + * version 2 for more details (a copy is included in the LICENSE file that
    4.18 + * accompanied this code).
    4.19 + *
    4.20 + * You should have received a copy of the GNU General Public License version
    4.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    4.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    4.23 + *
    4.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    4.25 + * or visit www.oracle.com if you need additional information or have any
    4.26 + * questions.
    4.27 + */
    4.28 +
    4.29 +package java.lang;
    4.30 +
    4.31 +/**
    4.32 + * The class {@code Exception} and its subclasses are a form of
    4.33 + * {@code Throwable} that indicates conditions that a reasonable
    4.34 + * application might want to catch.
    4.35 + *
    4.36 + * <p>The class {@code Exception} and any subclasses that are not also
    4.37 + * subclasses of {@link RuntimeException} are <em>checked
    4.38 + * exceptions</em>.  Checked exceptions need to be declared in a
    4.39 + * method or constructor's {@code throws} clause if they can be thrown
    4.40 + * by the execution of the method or constructor and propagate outside
    4.41 + * the method or constructor boundary.
    4.42 + *
    4.43 + * @author  Frank Yellin
    4.44 + * @see     java.lang.Error
    4.45 + * @jls 11.2 Compile-Time Checking of Exceptions
    4.46 + * @since   JDK1.0
    4.47 + */
    4.48 +public class Exception extends Throwable {
    4.49 +    static final long serialVersionUID = -3387516993124229948L;
    4.50 +
    4.51 +    /**
    4.52 +     * Constructs a new exception with {@code null} as its detail message.
    4.53 +     * The cause is not initialized, and may subsequently be initialized by a
    4.54 +     * call to {@link #initCause}.
    4.55 +     */
    4.56 +    public Exception() {
    4.57 +        super();
    4.58 +    }
    4.59 +
    4.60 +    /**
    4.61 +     * Constructs a new exception with the specified detail message.  The
    4.62 +     * cause is not initialized, and may subsequently be initialized by
    4.63 +     * a call to {@link #initCause}.
    4.64 +     *
    4.65 +     * @param   message   the detail message. The detail message is saved for
    4.66 +     *          later retrieval by the {@link #getMessage()} method.
    4.67 +     */
    4.68 +    public Exception(String message) {
    4.69 +        super(message);
    4.70 +    }
    4.71 +
    4.72 +    /**
    4.73 +     * Constructs a new exception with the specified detail message and
    4.74 +     * cause.  <p>Note that the detail message associated with
    4.75 +     * {@code cause} is <i>not</i> automatically incorporated in
    4.76 +     * this exception's detail message.
    4.77 +     *
    4.78 +     * @param  message the detail message (which is saved for later retrieval
    4.79 +     *         by the {@link #getMessage()} method).
    4.80 +     * @param  cause the cause (which is saved for later retrieval by the
    4.81 +     *         {@link #getCause()} method).  (A <tt>null</tt> value is
    4.82 +     *         permitted, and indicates that the cause is nonexistent or
    4.83 +     *         unknown.)
    4.84 +     * @since  1.4
    4.85 +     */
    4.86 +    public Exception(String message, Throwable cause) {
    4.87 +        super(message, cause);
    4.88 +    }
    4.89 +
    4.90 +    /**
    4.91 +     * Constructs a new exception with the specified cause and a detail
    4.92 +     * message of <tt>(cause==null ? null : cause.toString())</tt> (which
    4.93 +     * typically contains the class and detail message of <tt>cause</tt>).
    4.94 +     * This constructor is useful for exceptions that are little more than
    4.95 +     * wrappers for other throwables (for example, {@link
    4.96 +     * java.security.PrivilegedActionException}).
    4.97 +     *
    4.98 +     * @param  cause the cause (which is saved for later retrieval by the
    4.99 +     *         {@link #getCause()} method).  (A <tt>null</tt> value is
   4.100 +     *         permitted, and indicates that the cause is nonexistent or
   4.101 +     *         unknown.)
   4.102 +     * @since  1.4
   4.103 +     */
   4.104 +    public Exception(Throwable cause) {
   4.105 +        super(cause);
   4.106 +    }
   4.107 +
   4.108 +    /**
   4.109 +     * Constructs a new exception with the specified detail message,
   4.110 +     * cause, suppression enabled or disabled, and writable stack
   4.111 +     * trace enabled or disabled.
   4.112 +     *
   4.113 +     * @param  message the detail message.
   4.114 +     * @param cause the cause.  (A {@code null} value is permitted,
   4.115 +     * and indicates that the cause is nonexistent or unknown.)
   4.116 +     * @param enableSuppression whether or not suppression is enabled
   4.117 +     *                          or disabled
   4.118 +     * @param writableStackTrace whether or not the stack trace should
   4.119 +     *                           be writable
   4.120 +     * @since 1.7
   4.121 +     */
   4.122 +    protected Exception(String message, Throwable cause,
   4.123 +                        boolean enableSuppression,
   4.124 +                        boolean writableStackTrace) {
   4.125 +        super(message, cause, enableSuppression, writableStackTrace);
   4.126 +    }
   4.127 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/emul/src/main/java/java/lang/RuntimeException.java	Sat Sep 29 06:39:39 2012 +0200
     5.3 @@ -0,0 +1,119 @@
     5.4 +/*
     5.5 + * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
     5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.7 + *
     5.8 + * This code is free software; you can redistribute it and/or modify it
     5.9 + * under the terms of the GNU General Public License version 2 only, as
    5.10 + * published by the Free Software Foundation.  Oracle designates this
    5.11 + * particular file as subject to the "Classpath" exception as provided
    5.12 + * by Oracle in the LICENSE file that accompanied this code.
    5.13 + *
    5.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    5.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.17 + * version 2 for more details (a copy is included in the LICENSE file that
    5.18 + * accompanied this code).
    5.19 + *
    5.20 + * You should have received a copy of the GNU General Public License version
    5.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    5.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.23 + *
    5.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    5.25 + * or visit www.oracle.com if you need additional information or have any
    5.26 + * questions.
    5.27 + */
    5.28 +
    5.29 +package java.lang;
    5.30 +
    5.31 +/**
    5.32 + * {@code RuntimeException} is the superclass of those
    5.33 + * exceptions that can be thrown during the normal operation of the
    5.34 + * Java Virtual Machine.
    5.35 + *
    5.36 + * <p>{@code RuntimeException} and its subclasses are <em>unchecked
    5.37 + * exceptions</em>.  Unchecked exceptions do <em>not</em> need to be
    5.38 + * declared in a method or constructor's {@code throws} clause if they
    5.39 + * can be thrown by the execution of the method or constructor and
    5.40 + * propagate outside the method or constructor boundary.
    5.41 + *
    5.42 + * @author  Frank Yellin
    5.43 + * @jls 11.2 Compile-Time Checking of Exceptions
    5.44 + * @since   JDK1.0
    5.45 + */
    5.46 +public class RuntimeException extends Exception {
    5.47 +    static final long serialVersionUID = -7034897190745766939L;
    5.48 +
    5.49 +    /** Constructs a new runtime exception with {@code null} as its
    5.50 +     * detail message.  The cause is not initialized, and may subsequently be
    5.51 +     * initialized by a call to {@link #initCause}.
    5.52 +     */
    5.53 +    public RuntimeException() {
    5.54 +        super();
    5.55 +    }
    5.56 +
    5.57 +    /** Constructs a new runtime exception with the specified detail message.
    5.58 +     * The cause is not initialized, and may subsequently be initialized by a
    5.59 +     * call to {@link #initCause}.
    5.60 +     *
    5.61 +     * @param   message   the detail message. The detail message is saved for
    5.62 +     *          later retrieval by the {@link #getMessage()} method.
    5.63 +     */
    5.64 +    public RuntimeException(String message) {
    5.65 +        super(message);
    5.66 +    }
    5.67 +
    5.68 +    /**
    5.69 +     * Constructs a new runtime exception with the specified detail message and
    5.70 +     * cause.  <p>Note that the detail message associated with
    5.71 +     * {@code cause} is <i>not</i> automatically incorporated in
    5.72 +     * this runtime exception's detail message.
    5.73 +     *
    5.74 +     * @param  message the detail message (which is saved for later retrieval
    5.75 +     *         by the {@link #getMessage()} method).
    5.76 +     * @param  cause the cause (which is saved for later retrieval by the
    5.77 +     *         {@link #getCause()} method).  (A <tt>null</tt> value is
    5.78 +     *         permitted, and indicates that the cause is nonexistent or
    5.79 +     *         unknown.)
    5.80 +     * @since  1.4
    5.81 +     */
    5.82 +    public RuntimeException(String message, Throwable cause) {
    5.83 +        super(message, cause);
    5.84 +    }
    5.85 +
    5.86 +    /** Constructs a new runtime exception with the specified cause and a
    5.87 +     * detail message of <tt>(cause==null ? null : cause.toString())</tt>
    5.88 +     * (which typically contains the class and detail message of
    5.89 +     * <tt>cause</tt>).  This constructor is useful for runtime exceptions
    5.90 +     * that are little more than wrappers for other throwables.
    5.91 +     *
    5.92 +     * @param  cause the cause (which is saved for later retrieval by the
    5.93 +     *         {@link #getCause()} method).  (A <tt>null</tt> value is
    5.94 +     *         permitted, and indicates that the cause is nonexistent or
    5.95 +     *         unknown.)
    5.96 +     * @since  1.4
    5.97 +     */
    5.98 +    public RuntimeException(Throwable cause) {
    5.99 +        super(cause);
   5.100 +    }
   5.101 +
   5.102 +    /**
   5.103 +     * Constructs a new runtime exception with the specified detail
   5.104 +     * message, cause, suppression enabled or disabled, and writable
   5.105 +     * stack trace enabled or disabled.
   5.106 +     *
   5.107 +     * @param  message the detail message.
   5.108 +     * @param cause the cause.  (A {@code null} value is permitted,
   5.109 +     * and indicates that the cause is nonexistent or unknown.)
   5.110 +     * @param enableSuppression whether or not suppression is enabled
   5.111 +     *                          or disabled
   5.112 +     * @param writableStackTrace whether or not the stack trace should
   5.113 +     *                           be writable
   5.114 +     *
   5.115 +     * @since 1.7
   5.116 +     */
   5.117 +    protected RuntimeException(String message, Throwable cause,
   5.118 +                               boolean enableSuppression,
   5.119 +                               boolean writableStackTrace) {
   5.120 +        super(message, cause, enableSuppression, writableStackTrace);
   5.121 +    }
   5.122 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/emul/src/main/java/java/lang/StackTraceElement.java	Sat Sep 29 06:39:39 2012 +0200
     6.3 @@ -0,0 +1,221 @@
     6.4 +/*
     6.5 + * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
     6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 + *
     6.8 + * This code is free software; you can redistribute it and/or modify it
     6.9 + * under the terms of the GNU General Public License version 2 only, as
    6.10 + * published by the Free Software Foundation.  Oracle designates this
    6.11 + * particular file as subject to the "Classpath" exception as provided
    6.12 + * by Oracle in the LICENSE file that accompanied this code.
    6.13 + *
    6.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.17 + * version 2 for more details (a copy is included in the LICENSE file that
    6.18 + * accompanied this code).
    6.19 + *
    6.20 + * You should have received a copy of the GNU General Public License version
    6.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.23 + *
    6.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.25 + * or visit www.oracle.com if you need additional information or have any
    6.26 + * questions.
    6.27 + */
    6.28 +
    6.29 +package java.lang;
    6.30 +
    6.31 +import java.util.Objects;
    6.32 +
    6.33 +/**
    6.34 + * An element in a stack trace, as returned by {@link
    6.35 + * Throwable#getStackTrace()}.  Each element represents a single stack frame.
    6.36 + * All stack frames except for the one at the top of the stack represent
    6.37 + * a method invocation.  The frame at the top of the stack represents the
    6.38 + * execution point at which the stack trace was generated.  Typically,
    6.39 + * this is the point at which the throwable corresponding to the stack trace
    6.40 + * was created.
    6.41 + *
    6.42 + * @since  1.4
    6.43 + * @author Josh Bloch
    6.44 + */
    6.45 +public final class StackTraceElement implements java.io.Serializable {
    6.46 +    // Normally initialized by VM (public constructor added in 1.5)
    6.47 +    private String declaringClass;
    6.48 +    private String methodName;
    6.49 +    private String fileName;
    6.50 +    private int    lineNumber;
    6.51 +
    6.52 +    /**
    6.53 +     * Creates a stack trace element representing the specified execution
    6.54 +     * point.
    6.55 +     *
    6.56 +     * @param declaringClass the fully qualified name of the class containing
    6.57 +     *        the execution point represented by the stack trace element
    6.58 +     * @param methodName the name of the method containing the execution point
    6.59 +     *        represented by the stack trace element
    6.60 +     * @param fileName the name of the file containing the execution point
    6.61 +     *         represented by the stack trace element, or {@code null} if
    6.62 +     *         this information is unavailable
    6.63 +     * @param lineNumber the line number of the source line containing the
    6.64 +     *         execution point represented by this stack trace element, or
    6.65 +     *         a negative number if this information is unavailable. A value
    6.66 +     *         of -2 indicates that the method containing the execution point
    6.67 +     *         is a native method
    6.68 +     * @throws NullPointerException if {@code declaringClass} or
    6.69 +     *         {@code methodName} is null
    6.70 +     * @since 1.5
    6.71 +     */
    6.72 +    public StackTraceElement(String declaringClass, String methodName,
    6.73 +                             String fileName, int lineNumber) {
    6.74 +        this.declaringClass = Objects.requireNonNull(declaringClass, "Declaring class is null");
    6.75 +        this.methodName     = Objects.requireNonNull(methodName, "Method name is null");
    6.76 +        this.fileName       = fileName;
    6.77 +        this.lineNumber     = lineNumber;
    6.78 +    }
    6.79 +
    6.80 +    /**
    6.81 +     * Returns the name of the source file containing the execution point
    6.82 +     * represented by this stack trace element.  Generally, this corresponds
    6.83 +     * to the {@code SourceFile} attribute of the relevant {@code class}
    6.84 +     * file (as per <i>The Java Virtual Machine Specification</i>, Section
    6.85 +     * 4.7.7).  In some systems, the name may refer to some source code unit
    6.86 +     * other than a file, such as an entry in source repository.
    6.87 +     *
    6.88 +     * @return the name of the file containing the execution point
    6.89 +     *         represented by this stack trace element, or {@code null} if
    6.90 +     *         this information is unavailable.
    6.91 +     */
    6.92 +    public String getFileName() {
    6.93 +        return fileName;
    6.94 +    }
    6.95 +
    6.96 +    /**
    6.97 +     * Returns the line number of the source line containing the execution
    6.98 +     * point represented by this stack trace element.  Generally, this is
    6.99 +     * derived from the {@code LineNumberTable} attribute of the relevant
   6.100 +     * {@code class} file (as per <i>The Java Virtual Machine
   6.101 +     * Specification</i>, Section 4.7.8).
   6.102 +     *
   6.103 +     * @return the line number of the source line containing the execution
   6.104 +     *         point represented by this stack trace element, or a negative
   6.105 +     *         number if this information is unavailable.
   6.106 +     */
   6.107 +    public int getLineNumber() {
   6.108 +        return lineNumber;
   6.109 +    }
   6.110 +
   6.111 +    /**
   6.112 +     * Returns the fully qualified name of the class containing the
   6.113 +     * execution point represented by this stack trace element.
   6.114 +     *
   6.115 +     * @return the fully qualified name of the {@code Class} containing
   6.116 +     *         the execution point represented by this stack trace element.
   6.117 +     */
   6.118 +    public String getClassName() {
   6.119 +        return declaringClass;
   6.120 +    }
   6.121 +
   6.122 +    /**
   6.123 +     * Returns the name of the method containing the execution point
   6.124 +     * represented by this stack trace element.  If the execution point is
   6.125 +     * contained in an instance or class initializer, this method will return
   6.126 +     * the appropriate <i>special method name</i>, {@code <init>} or
   6.127 +     * {@code <clinit>}, as per Section 3.9 of <i>The Java Virtual
   6.128 +     * Machine Specification</i>.
   6.129 +     *
   6.130 +     * @return the name of the method containing the execution point
   6.131 +     *         represented by this stack trace element.
   6.132 +     */
   6.133 +    public String getMethodName() {
   6.134 +        return methodName;
   6.135 +    }
   6.136 +
   6.137 +    /**
   6.138 +     * Returns true if the method containing the execution point
   6.139 +     * represented by this stack trace element is a native method.
   6.140 +     *
   6.141 +     * @return {@code true} if the method containing the execution point
   6.142 +     *         represented by this stack trace element is a native method.
   6.143 +     */
   6.144 +    public boolean isNativeMethod() {
   6.145 +        return lineNumber == -2;
   6.146 +    }
   6.147 +
   6.148 +    /**
   6.149 +     * Returns a string representation of this stack trace element.  The
   6.150 +     * format of this string depends on the implementation, but the following
   6.151 +     * examples may be regarded as typical:
   6.152 +     * <ul>
   6.153 +     * <li>
   6.154 +     *   {@code "MyClass.mash(MyClass.java:9)"} - Here, {@code "MyClass"}
   6.155 +     *   is the <i>fully-qualified name</i> of the class containing the
   6.156 +     *   execution point represented by this stack trace element,
   6.157 +     *   {@code "mash"} is the name of the method containing the execution
   6.158 +     *   point, {@code "MyClass.java"} is the source file containing the
   6.159 +     *   execution point, and {@code "9"} is the line number of the source
   6.160 +     *   line containing the execution point.
   6.161 +     * <li>
   6.162 +     *   {@code "MyClass.mash(MyClass.java)"} - As above, but the line
   6.163 +     *   number is unavailable.
   6.164 +     * <li>
   6.165 +     *   {@code "MyClass.mash(Unknown Source)"} - As above, but neither
   6.166 +     *   the file name nor the line  number are available.
   6.167 +     * <li>
   6.168 +     *   {@code "MyClass.mash(Native Method)"} - As above, but neither
   6.169 +     *   the file name nor the line  number are available, and the method
   6.170 +     *   containing the execution point is known to be a native method.
   6.171 +     * </ul>
   6.172 +     * @see    Throwable#printStackTrace()
   6.173 +     */
   6.174 +    public String toString() {
   6.175 +        return getClassName() + "." + methodName +
   6.176 +            (isNativeMethod() ? "(Native Method)" :
   6.177 +             (fileName != null && lineNumber >= 0 ?
   6.178 +              "(" + fileName + ":" + lineNumber + ")" :
   6.179 +              (fileName != null ?  "("+fileName+")" : "(Unknown Source)")));
   6.180 +    }
   6.181 +
   6.182 +    /**
   6.183 +     * Returns true if the specified object is another
   6.184 +     * {@code StackTraceElement} instance representing the same execution
   6.185 +     * point as this instance.  Two stack trace elements {@code a} and
   6.186 +     * {@code b} are equal if and only if:
   6.187 +     * <pre>
   6.188 +     *     equals(a.getFileName(), b.getFileName()) &&
   6.189 +     *     a.getLineNumber() == b.getLineNumber()) &&
   6.190 +     *     equals(a.getClassName(), b.getClassName()) &&
   6.191 +     *     equals(a.getMethodName(), b.getMethodName())
   6.192 +     * </pre>
   6.193 +     * where {@code equals} has the semantics of {@link
   6.194 +     * java.util.Objects#equals(Object, Object) Objects.equals}.
   6.195 +     *
   6.196 +     * @param  obj the object to be compared with this stack trace element.
   6.197 +     * @return true if the specified object is another
   6.198 +     *         {@code StackTraceElement} instance representing the same
   6.199 +     *         execution point as this instance.
   6.200 +     */
   6.201 +    public boolean equals(Object obj) {
   6.202 +        if (obj==this)
   6.203 +            return true;
   6.204 +        if (!(obj instanceof StackTraceElement))
   6.205 +            return false;
   6.206 +        StackTraceElement e = (StackTraceElement)obj;
   6.207 +        return e.declaringClass.equals(declaringClass) &&
   6.208 +            e.lineNumber == lineNumber &&
   6.209 +            Objects.equals(methodName, e.methodName) &&
   6.210 +            Objects.equals(fileName, e.fileName);
   6.211 +    }
   6.212 +
   6.213 +    /**
   6.214 +     * Returns a hash code value for this stack trace element.
   6.215 +     */
   6.216 +    public int hashCode() {
   6.217 +        int result = 31*declaringClass.hashCode() + methodName.hashCode();
   6.218 +        result = 31*result + Objects.hashCode(fileName);
   6.219 +        result = 31*result + lineNumber;
   6.220 +        return result;
   6.221 +    }
   6.222 +
   6.223 +    private static final long serialVersionUID = 6992337162326171013L;
   6.224 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/emul/src/main/java/java/lang/StringBuffer.java	Sat Sep 29 06:39:39 2012 +0200
     7.3 @@ -0,0 +1,605 @@
     7.4 +/*
     7.5 + * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved.
     7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.7 + *
     7.8 + * This code is free software; you can redistribute it and/or modify it
     7.9 + * under the terms of the GNU General Public License version 2 only, as
    7.10 + * published by the Free Software Foundation.  Oracle designates this
    7.11 + * particular file as subject to the "Classpath" exception as provided
    7.12 + * by Oracle in the LICENSE file that accompanied this code.
    7.13 + *
    7.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    7.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    7.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    7.17 + * version 2 for more details (a copy is included in the LICENSE file that
    7.18 + * accompanied this code).
    7.19 + *
    7.20 + * You should have received a copy of the GNU General Public License version
    7.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    7.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    7.23 + *
    7.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    7.25 + * or visit www.oracle.com if you need additional information or have any
    7.26 + * questions.
    7.27 + */
    7.28 +
    7.29 +package java.lang;
    7.30 +
    7.31 +
    7.32 +/**
    7.33 + * A thread-safe, mutable sequence of characters.
    7.34 + * A string buffer is like a {@link String}, but can be modified. At any
    7.35 + * point in time it contains some particular sequence of characters, but
    7.36 + * the length and content of the sequence can be changed through certain
    7.37 + * method calls.
    7.38 + * <p>
    7.39 + * String buffers are safe for use by multiple threads. The methods
    7.40 + * are synchronized where necessary so that all the operations on any
    7.41 + * particular instance behave as if they occur in some serial order
    7.42 + * that is consistent with the order of the method calls made by each of
    7.43 + * the individual threads involved.
    7.44 + * <p>
    7.45 + * The principal operations on a <code>StringBuffer</code> are the
    7.46 + * <code>append</code> and <code>insert</code> methods, which are
    7.47 + * overloaded so as to accept data of any type. Each effectively
    7.48 + * converts a given datum to a string and then appends or inserts the
    7.49 + * characters of that string to the string buffer. The
    7.50 + * <code>append</code> method always adds these characters at the end
    7.51 + * of the buffer; the <code>insert</code> method adds the characters at
    7.52 + * a specified point.
    7.53 + * <p>
    7.54 + * For example, if <code>z</code> refers to a string buffer object
    7.55 + * whose current contents are "<code>start</code>", then
    7.56 + * the method call <code>z.append("le")</code> would cause the string
    7.57 + * buffer to contain "<code>startle</code>", whereas
    7.58 + * <code>z.insert(4, "le")</code> would alter the string buffer to
    7.59 + * contain "<code>starlet</code>".
    7.60 + * <p>
    7.61 + * In general, if sb refers to an instance of a <code>StringBuffer</code>,
    7.62 + * then <code>sb.append(x)</code> has the same effect as
    7.63 + * <code>sb.insert(sb.length(),&nbsp;x)</code>.
    7.64 + * <p>
    7.65 + * Whenever an operation occurs involving a source sequence (such as
    7.66 + * appending or inserting from a source sequence) this class synchronizes
    7.67 + * only on the string buffer performing the operation, not on the source.
    7.68 + * <p>
    7.69 + * Every string buffer has a capacity. As long as the length of the
    7.70 + * character sequence contained in the string buffer does not exceed
    7.71 + * the capacity, it is not necessary to allocate a new internal
    7.72 + * buffer array. If the internal buffer overflows, it is
    7.73 + * automatically made larger.
    7.74 + *
    7.75 + * As of  release JDK 5, this class has been supplemented with an equivalent
    7.76 + * class designed for use by a single thread, {@link StringBuilder}.  The
    7.77 + * <tt>StringBuilder</tt> class should generally be used in preference to
    7.78 + * this one, as it supports all of the same operations but it is faster, as
    7.79 + * it performs no synchronization.
    7.80 + *
    7.81 + * @author      Arthur van Hoff
    7.82 + * @see     java.lang.StringBuilder
    7.83 + * @see     java.lang.String
    7.84 + * @since   JDK1.0
    7.85 + */
    7.86 + public final class StringBuffer
    7.87 +    extends AbstractStringBuilder
    7.88 +    implements java.io.Serializable, CharSequence
    7.89 +{
    7.90 +
    7.91 +    /** use serialVersionUID from JDK 1.0.2 for interoperability */
    7.92 +    static final long serialVersionUID = 3388685877147921107L;
    7.93 +
    7.94 +    /**
    7.95 +     * Constructs a string buffer with no characters in it and an
    7.96 +     * initial capacity of 16 characters.
    7.97 +     */
    7.98 +    public StringBuffer() {
    7.99 +        super(16);
   7.100 +    }
   7.101 +
   7.102 +    /**
   7.103 +     * Constructs a string buffer with no characters in it and
   7.104 +     * the specified initial capacity.
   7.105 +     *
   7.106 +     * @param      capacity  the initial capacity.
   7.107 +     * @exception  NegativeArraySizeException  if the <code>capacity</code>
   7.108 +     *               argument is less than <code>0</code>.
   7.109 +     */
   7.110 +    public StringBuffer(int capacity) {
   7.111 +        super(capacity);
   7.112 +    }
   7.113 +
   7.114 +    /**
   7.115 +     * Constructs a string buffer initialized to the contents of the
   7.116 +     * specified string. The initial capacity of the string buffer is
   7.117 +     * <code>16</code> plus the length of the string argument.
   7.118 +     *
   7.119 +     * @param   str   the initial contents of the buffer.
   7.120 +     * @exception NullPointerException if <code>str</code> is <code>null</code>
   7.121 +     */
   7.122 +    public StringBuffer(String str) {
   7.123 +        super(str.length() + 16);
   7.124 +        append(str);
   7.125 +    }
   7.126 +
   7.127 +    /**
   7.128 +     * Constructs a string buffer that contains the same characters
   7.129 +     * as the specified <code>CharSequence</code>. The initial capacity of
   7.130 +     * the string buffer is <code>16</code> plus the length of the
   7.131 +     * <code>CharSequence</code> argument.
   7.132 +     * <p>
   7.133 +     * If the length of the specified <code>CharSequence</code> is
   7.134 +     * less than or equal to zero, then an empty buffer of capacity
   7.135 +     * <code>16</code> is returned.
   7.136 +     *
   7.137 +     * @param      seq   the sequence to copy.
   7.138 +     * @exception NullPointerException if <code>seq</code> is <code>null</code>
   7.139 +     * @since 1.5
   7.140 +     */
   7.141 +    public StringBuffer(CharSequence seq) {
   7.142 +        this(seq.length() + 16);
   7.143 +        append(seq);
   7.144 +    }
   7.145 +
   7.146 +    public synchronized int length() {
   7.147 +        return count;
   7.148 +    }
   7.149 +
   7.150 +    public synchronized int capacity() {
   7.151 +        return value.length;
   7.152 +    }
   7.153 +
   7.154 +
   7.155 +    public synchronized void ensureCapacity(int minimumCapacity) {
   7.156 +        if (minimumCapacity > value.length) {
   7.157 +            expandCapacity(minimumCapacity);
   7.158 +        }
   7.159 +    }
   7.160 +
   7.161 +    /**
   7.162 +     * @since      1.5
   7.163 +     */
   7.164 +    public synchronized void trimToSize() {
   7.165 +        super.trimToSize();
   7.166 +    }
   7.167 +
   7.168 +    /**
   7.169 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   7.170 +     * @see        #length()
   7.171 +     */
   7.172 +    public synchronized void setLength(int newLength) {
   7.173 +        super.setLength(newLength);
   7.174 +    }
   7.175 +
   7.176 +    /**
   7.177 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   7.178 +     * @see        #length()
   7.179 +     */
   7.180 +    public synchronized char charAt(int index) {
   7.181 +        if ((index < 0) || (index >= count))
   7.182 +            throw new StringIndexOutOfBoundsException(index);
   7.183 +        return value[index];
   7.184 +    }
   7.185 +
   7.186 +    /**
   7.187 +     * @since      1.5
   7.188 +     */
   7.189 +    public synchronized int codePointAt(int index) {
   7.190 +        return super.codePointAt(index);
   7.191 +    }
   7.192 +
   7.193 +    /**
   7.194 +     * @since     1.5
   7.195 +     */
   7.196 +    public synchronized int codePointBefore(int index) {
   7.197 +        return super.codePointBefore(index);
   7.198 +    }
   7.199 +
   7.200 +    /**
   7.201 +     * @since     1.5
   7.202 +     */
   7.203 +    public synchronized int codePointCount(int beginIndex, int endIndex) {
   7.204 +        return super.codePointCount(beginIndex, endIndex);
   7.205 +    }
   7.206 +
   7.207 +    /**
   7.208 +     * @since     1.5
   7.209 +     */
   7.210 +    public synchronized int offsetByCodePoints(int index, int codePointOffset) {
   7.211 +        return super.offsetByCodePoints(index, codePointOffset);
   7.212 +    }
   7.213 +
   7.214 +    /**
   7.215 +     * @throws NullPointerException {@inheritDoc}
   7.216 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   7.217 +     */
   7.218 +    public synchronized void getChars(int srcBegin, int srcEnd, char[] dst,
   7.219 +                                      int dstBegin)
   7.220 +    {
   7.221 +        super.getChars(srcBegin, srcEnd, dst, dstBegin);
   7.222 +    }
   7.223 +
   7.224 +    /**
   7.225 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   7.226 +     * @see        #length()
   7.227 +     */
   7.228 +    public synchronized void setCharAt(int index, char ch) {
   7.229 +        if ((index < 0) || (index >= count))
   7.230 +            throw new StringIndexOutOfBoundsException(index);
   7.231 +        value[index] = ch;
   7.232 +    }
   7.233 +
   7.234 +    public synchronized StringBuffer append(Object obj) {
   7.235 +        super.append(String.valueOf(obj));
   7.236 +        return this;
   7.237 +    }
   7.238 +
   7.239 +    public synchronized StringBuffer append(String str) {
   7.240 +        super.append(str);
   7.241 +        return this;
   7.242 +    }
   7.243 +
   7.244 +    /**
   7.245 +     * Appends the specified <tt>StringBuffer</tt> to this sequence.
   7.246 +     * <p>
   7.247 +     * The characters of the <tt>StringBuffer</tt> argument are appended,
   7.248 +     * in order, to the contents of this <tt>StringBuffer</tt>, increasing the
   7.249 +     * length of this <tt>StringBuffer</tt> by the length of the argument.
   7.250 +     * If <tt>sb</tt> is <tt>null</tt>, then the four characters
   7.251 +     * <tt>"null"</tt> are appended to this <tt>StringBuffer</tt>.
   7.252 +     * <p>
   7.253 +     * Let <i>n</i> be the length of the old character sequence, the one
   7.254 +     * contained in the <tt>StringBuffer</tt> just prior to execution of the
   7.255 +     * <tt>append</tt> method. Then the character at index <i>k</i> in
   7.256 +     * the new character sequence is equal to the character at index <i>k</i>
   7.257 +     * in the old character sequence, if <i>k</i> is less than <i>n</i>;
   7.258 +     * otherwise, it is equal to the character at index <i>k-n</i> in the
   7.259 +     * argument <code>sb</code>.
   7.260 +     * <p>
   7.261 +     * This method synchronizes on <code>this</code> (the destination)
   7.262 +     * object but does not synchronize on the source (<code>sb</code>).
   7.263 +     *
   7.264 +     * @param   sb   the <tt>StringBuffer</tt> to append.
   7.265 +     * @return  a reference to this object.
   7.266 +     * @since 1.4
   7.267 +     */
   7.268 +    public synchronized StringBuffer append(StringBuffer sb) {
   7.269 +        super.append(sb);
   7.270 +        return this;
   7.271 +    }
   7.272 +
   7.273 +
   7.274 +    /**
   7.275 +     * Appends the specified <code>CharSequence</code> to this
   7.276 +     * sequence.
   7.277 +     * <p>
   7.278 +     * The characters of the <code>CharSequence</code> argument are appended,
   7.279 +     * in order, increasing the length of this sequence by the length of the
   7.280 +     * argument.
   7.281 +     *
   7.282 +     * <p>The result of this method is exactly the same as if it were an
   7.283 +     * invocation of this.append(s, 0, s.length());
   7.284 +     *
   7.285 +     * <p>This method synchronizes on this (the destination)
   7.286 +     * object but does not synchronize on the source (<code>s</code>).
   7.287 +     *
   7.288 +     * <p>If <code>s</code> is <code>null</code>, then the four characters
   7.289 +     * <code>"null"</code> are appended.
   7.290 +     *
   7.291 +     * @param   s the <code>CharSequence</code> to append.
   7.292 +     * @return  a reference to this object.
   7.293 +     * @since 1.5
   7.294 +     */
   7.295 +    public StringBuffer append(CharSequence s) {
   7.296 +        // Note, synchronization achieved via other invocations
   7.297 +        if (s == null)
   7.298 +            s = "null";
   7.299 +        if (s instanceof String)
   7.300 +            return this.append((String)s);
   7.301 +        if (s instanceof StringBuffer)
   7.302 +            return this.append((StringBuffer)s);
   7.303 +        return this.append(s, 0, s.length());
   7.304 +    }
   7.305 +
   7.306 +    /**
   7.307 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   7.308 +     * @since      1.5
   7.309 +     */
   7.310 +    public synchronized StringBuffer append(CharSequence s, int start, int end)
   7.311 +    {
   7.312 +        super.append(s, start, end);
   7.313 +        return this;
   7.314 +    }
   7.315 +
   7.316 +    public synchronized StringBuffer append(char[] str) {
   7.317 +        super.append(str);
   7.318 +        return this;
   7.319 +    }
   7.320 +
   7.321 +    /**
   7.322 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   7.323 +     */
   7.324 +    public synchronized StringBuffer append(char[] str, int offset, int len) {
   7.325 +        super.append(str, offset, len);
   7.326 +        return this;
   7.327 +    }
   7.328 +
   7.329 +    public synchronized StringBuffer append(boolean b) {
   7.330 +        super.append(b);
   7.331 +        return this;
   7.332 +    }
   7.333 +
   7.334 +    public synchronized StringBuffer append(char c) {
   7.335 +        super.append(c);
   7.336 +        return this;
   7.337 +    }
   7.338 +
   7.339 +    public synchronized StringBuffer append(int i) {
   7.340 +        super.append(i);
   7.341 +        return this;
   7.342 +    }
   7.343 +
   7.344 +    /**
   7.345 +     * @since 1.5
   7.346 +     */
   7.347 +    public synchronized StringBuffer appendCodePoint(int codePoint) {
   7.348 +        super.appendCodePoint(codePoint);
   7.349 +        return this;
   7.350 +    }
   7.351 +
   7.352 +    public synchronized StringBuffer append(long lng) {
   7.353 +        super.append(lng);
   7.354 +        return this;
   7.355 +    }
   7.356 +
   7.357 +    public synchronized StringBuffer append(float f) {
   7.358 +        super.append(f);
   7.359 +        return this;
   7.360 +    }
   7.361 +
   7.362 +    public synchronized StringBuffer append(double d) {
   7.363 +        super.append(d);
   7.364 +        return this;
   7.365 +    }
   7.366 +
   7.367 +    /**
   7.368 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.369 +     * @since      1.2
   7.370 +     */
   7.371 +    public synchronized StringBuffer delete(int start, int end) {
   7.372 +        super.delete(start, end);
   7.373 +        return this;
   7.374 +    }
   7.375 +
   7.376 +    /**
   7.377 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.378 +     * @since      1.2
   7.379 +     */
   7.380 +    public synchronized StringBuffer deleteCharAt(int index) {
   7.381 +        super.deleteCharAt(index);
   7.382 +        return this;
   7.383 +    }
   7.384 +
   7.385 +    /**
   7.386 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.387 +     * @since      1.2
   7.388 +     */
   7.389 +    public synchronized StringBuffer replace(int start, int end, String str) {
   7.390 +        super.replace(start, end, str);
   7.391 +        return this;
   7.392 +    }
   7.393 +
   7.394 +    /**
   7.395 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.396 +     * @since      1.2
   7.397 +     */
   7.398 +    public synchronized String substring(int start) {
   7.399 +        return substring(start, count);
   7.400 +    }
   7.401 +
   7.402 +    /**
   7.403 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   7.404 +     * @since      1.4
   7.405 +     */
   7.406 +    public synchronized CharSequence subSequence(int start, int end) {
   7.407 +        return super.substring(start, end);
   7.408 +    }
   7.409 +
   7.410 +    /**
   7.411 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.412 +     * @since      1.2
   7.413 +     */
   7.414 +    public synchronized String substring(int start, int end) {
   7.415 +        return super.substring(start, end);
   7.416 +    }
   7.417 +
   7.418 +    /**
   7.419 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.420 +     * @since      1.2
   7.421 +     */
   7.422 +    public synchronized StringBuffer insert(int index, char[] str, int offset,
   7.423 +                                            int len)
   7.424 +    {
   7.425 +        super.insert(index, str, offset, len);
   7.426 +        return this;
   7.427 +    }
   7.428 +
   7.429 +    /**
   7.430 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.431 +     */
   7.432 +    public synchronized StringBuffer insert(int offset, Object obj) {
   7.433 +        super.insert(offset, String.valueOf(obj));
   7.434 +        return this;
   7.435 +    }
   7.436 +
   7.437 +    /**
   7.438 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.439 +     */
   7.440 +    public synchronized StringBuffer insert(int offset, String str) {
   7.441 +        super.insert(offset, str);
   7.442 +        return this;
   7.443 +    }
   7.444 +
   7.445 +    /**
   7.446 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.447 +     */
   7.448 +    public synchronized StringBuffer insert(int offset, char[] str) {
   7.449 +        super.insert(offset, str);
   7.450 +        return this;
   7.451 +    }
   7.452 +
   7.453 +    /**
   7.454 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   7.455 +     * @since      1.5
   7.456 +     */
   7.457 +    public StringBuffer insert(int dstOffset, CharSequence s) {
   7.458 +        // Note, synchronization achieved via other invocations
   7.459 +        if (s == null)
   7.460 +            s = "null";
   7.461 +        if (s instanceof String)
   7.462 +            return this.insert(dstOffset, (String)s);
   7.463 +        return this.insert(dstOffset, s, 0, s.length());
   7.464 +    }
   7.465 +
   7.466 +    /**
   7.467 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   7.468 +     * @since      1.5
   7.469 +     */
   7.470 +    public synchronized StringBuffer insert(int dstOffset, CharSequence s,
   7.471 +                                            int start, int end)
   7.472 +    {
   7.473 +        super.insert(dstOffset, s, start, end);
   7.474 +        return this;
   7.475 +    }
   7.476 +
   7.477 +    /**
   7.478 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.479 +     */
   7.480 +    public StringBuffer insert(int offset, boolean b) {
   7.481 +        return insert(offset, String.valueOf(b));
   7.482 +    }
   7.483 +
   7.484 +    /**
   7.485 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   7.486 +     */
   7.487 +    public synchronized StringBuffer insert(int offset, char c) {
   7.488 +        super.insert(offset, c);
   7.489 +        return this;
   7.490 +    }
   7.491 +
   7.492 +    /**
   7.493 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.494 +     */
   7.495 +    public StringBuffer insert(int offset, int i) {
   7.496 +        return insert(offset, String.valueOf(i));
   7.497 +    }
   7.498 +
   7.499 +    /**
   7.500 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.501 +     */
   7.502 +    public StringBuffer insert(int offset, long l) {
   7.503 +        return insert(offset, String.valueOf(l));
   7.504 +    }
   7.505 +
   7.506 +    /**
   7.507 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.508 +     */
   7.509 +    public StringBuffer insert(int offset, float f) {
   7.510 +        return insert(offset, String.valueOf(f));
   7.511 +    }
   7.512 +
   7.513 +    /**
   7.514 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   7.515 +     */
   7.516 +    public StringBuffer insert(int offset, double d) {
   7.517 +        return insert(offset, String.valueOf(d));
   7.518 +    }
   7.519 +
   7.520 +    /**
   7.521 +     * @throws NullPointerException {@inheritDoc}
   7.522 +     * @since      1.4
   7.523 +     */
   7.524 +    public int indexOf(String str) {
   7.525 +        return indexOf(str, 0);
   7.526 +    }
   7.527 +
   7.528 +    /**
   7.529 +     * @throws NullPointerException {@inheritDoc}
   7.530 +     * @since      1.4
   7.531 +     */
   7.532 +    public synchronized int indexOf(String str, int fromIndex) {
   7.533 +        return String.indexOf(value, 0, count,
   7.534 +                              str.toCharArray(), 0, str.length(), fromIndex);
   7.535 +    }
   7.536 +
   7.537 +    /**
   7.538 +     * @throws NullPointerException {@inheritDoc}
   7.539 +     * @since      1.4
   7.540 +     */
   7.541 +    public int lastIndexOf(String str) {
   7.542 +        // Note, synchronization achieved via other invocations
   7.543 +        return lastIndexOf(str, count);
   7.544 +    }
   7.545 +
   7.546 +    /**
   7.547 +     * @throws NullPointerException {@inheritDoc}
   7.548 +     * @since      1.4
   7.549 +     */
   7.550 +    public synchronized int lastIndexOf(String str, int fromIndex) {
   7.551 +        return String.lastIndexOf(value, 0, count,
   7.552 +                              str.toCharArray(), 0, str.length(), fromIndex);
   7.553 +    }
   7.554 +
   7.555 +    /**
   7.556 +     * @since   JDK1.0.2
   7.557 +     */
   7.558 +    public synchronized StringBuffer reverse() {
   7.559 +        super.reverse();
   7.560 +        return this;
   7.561 +    }
   7.562 +
   7.563 +    public synchronized String toString() {
   7.564 +        return new String(value, 0, count);
   7.565 +    }
   7.566 +
   7.567 +    /**
   7.568 +     * Serializable fields for StringBuffer.
   7.569 +     *
   7.570 +     * @serialField value  char[]
   7.571 +     *              The backing character array of this StringBuffer.
   7.572 +     * @serialField count int
   7.573 +     *              The number of characters in this StringBuffer.
   7.574 +     * @serialField shared  boolean
   7.575 +     *              A flag indicating whether the backing array is shared.
   7.576 +     *              The value is ignored upon deserialization.
   7.577 +     */
   7.578 +    private static final java.io.ObjectStreamField[] serialPersistentFields =
   7.579 +    {
   7.580 +        new java.io.ObjectStreamField("value", char[].class),
   7.581 +        new java.io.ObjectStreamField("count", Integer.TYPE),
   7.582 +        new java.io.ObjectStreamField("shared", Boolean.TYPE),
   7.583 +    };
   7.584 +
   7.585 +    /**
   7.586 +     * readObject is called to restore the state of the StringBuffer from
   7.587 +     * a stream.
   7.588 +     */
   7.589 +    private synchronized void writeObject(java.io.ObjectOutputStream s)
   7.590 +        throws java.io.IOException {
   7.591 +        java.io.ObjectOutputStream.PutField fields = s.putFields();
   7.592 +        fields.put("value", value);
   7.593 +        fields.put("count", count);
   7.594 +        fields.put("shared", false);
   7.595 +        s.writeFields();
   7.596 +    }
   7.597 +
   7.598 +    /**
   7.599 +     * readObject is called to restore the state of the StringBuffer from
   7.600 +     * a stream.
   7.601 +     */
   7.602 +    private void readObject(java.io.ObjectInputStream s)
   7.603 +        throws java.io.IOException, ClassNotFoundException {
   7.604 +        java.io.ObjectInputStream.GetField fields = s.readFields();
   7.605 +        value = (char[])fields.get("value", null);
   7.606 +        count = fields.get("count", 0);
   7.607 +    }
   7.608 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/emul/src/main/java/java/lang/StringBuilder.java	Sat Sep 29 06:39:39 2012 +0200
     8.3 @@ -0,0 +1,437 @@
     8.4 +/*
     8.5 + * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
     8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.7 + *
     8.8 + * This code is free software; you can redistribute it and/or modify it
     8.9 + * under the terms of the GNU General Public License version 2 only, as
    8.10 + * published by the Free Software Foundation.  Oracle designates this
    8.11 + * particular file as subject to the "Classpath" exception as provided
    8.12 + * by Oracle in the LICENSE file that accompanied this code.
    8.13 + *
    8.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    8.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    8.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    8.17 + * version 2 for more details (a copy is included in the LICENSE file that
    8.18 + * accompanied this code).
    8.19 + *
    8.20 + * You should have received a copy of the GNU General Public License version
    8.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    8.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    8.23 + *
    8.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    8.25 + * or visit www.oracle.com if you need additional information or have any
    8.26 + * questions.
    8.27 + */
    8.28 +
    8.29 +package java.lang;
    8.30 +
    8.31 +
    8.32 +/**
    8.33 + * A mutable sequence of characters.  This class provides an API compatible
    8.34 + * with <code>StringBuffer</code>, but with no guarantee of synchronization.
    8.35 + * This class is designed for use as a drop-in replacement for
    8.36 + * <code>StringBuffer</code> in places where the string buffer was being
    8.37 + * used by a single thread (as is generally the case).   Where possible,
    8.38 + * it is recommended that this class be used in preference to
    8.39 + * <code>StringBuffer</code> as it will be faster under most implementations.
    8.40 + *
    8.41 + * <p>The principal operations on a <code>StringBuilder</code> are the
    8.42 + * <code>append</code> and <code>insert</code> methods, which are
    8.43 + * overloaded so as to accept data of any type. Each effectively
    8.44 + * converts a given datum to a string and then appends or inserts the
    8.45 + * characters of that string to the string builder. The
    8.46 + * <code>append</code> method always adds these characters at the end
    8.47 + * of the builder; the <code>insert</code> method adds the characters at
    8.48 + * a specified point.
    8.49 + * <p>
    8.50 + * For example, if <code>z</code> refers to a string builder object
    8.51 + * whose current contents are "<code>start</code>", then
    8.52 + * the method call <code>z.append("le")</code> would cause the string
    8.53 + * builder to contain "<code>startle</code>", whereas
    8.54 + * <code>z.insert(4, "le")</code> would alter the string builder to
    8.55 + * contain "<code>starlet</code>".
    8.56 + * <p>
    8.57 + * In general, if sb refers to an instance of a <code>StringBuilder</code>,
    8.58 + * then <code>sb.append(x)</code> has the same effect as
    8.59 + * <code>sb.insert(sb.length(),&nbsp;x)</code>.
    8.60 + *
    8.61 + * Every string builder has a capacity. As long as the length of the
    8.62 + * character sequence contained in the string builder does not exceed
    8.63 + * the capacity, it is not necessary to allocate a new internal
    8.64 + * buffer. If the internal buffer overflows, it is automatically made larger.
    8.65 + *
    8.66 + * <p>Instances of <code>StringBuilder</code> are not safe for
    8.67 + * use by multiple threads. If such synchronization is required then it is
    8.68 + * recommended that {@link java.lang.StringBuffer} be used.
    8.69 + *
    8.70 + * @author      Michael McCloskey
    8.71 + * @see         java.lang.StringBuffer
    8.72 + * @see         java.lang.String
    8.73 + * @since       1.5
    8.74 + */
    8.75 +public final class StringBuilder
    8.76 +    extends AbstractStringBuilder
    8.77 +    implements java.io.Serializable, CharSequence
    8.78 +{
    8.79 +
    8.80 +    /** use serialVersionUID for interoperability */
    8.81 +    static final long serialVersionUID = 4383685877147921099L;
    8.82 +
    8.83 +    /**
    8.84 +     * Constructs a string builder with no characters in it and an
    8.85 +     * initial capacity of 16 characters.
    8.86 +     */
    8.87 +    public StringBuilder() {
    8.88 +        super(16);
    8.89 +    }
    8.90 +
    8.91 +    /**
    8.92 +     * Constructs a string builder with no characters in it and an
    8.93 +     * initial capacity specified by the <code>capacity</code> argument.
    8.94 +     *
    8.95 +     * @param      capacity  the initial capacity.
    8.96 +     * @throws     NegativeArraySizeException  if the <code>capacity</code>
    8.97 +     *               argument is less than <code>0</code>.
    8.98 +     */
    8.99 +    public StringBuilder(int capacity) {
   8.100 +        super(capacity);
   8.101 +    }
   8.102 +
   8.103 +    /**
   8.104 +     * Constructs a string builder initialized to the contents of the
   8.105 +     * specified string. The initial capacity of the string builder is
   8.106 +     * <code>16</code> plus the length of the string argument.
   8.107 +     *
   8.108 +     * @param   str   the initial contents of the buffer.
   8.109 +     * @throws    NullPointerException if <code>str</code> is <code>null</code>
   8.110 +     */
   8.111 +    public StringBuilder(String str) {
   8.112 +        super(str.length() + 16);
   8.113 +        append(str);
   8.114 +    }
   8.115 +
   8.116 +    /**
   8.117 +     * Constructs a string builder that contains the same characters
   8.118 +     * as the specified <code>CharSequence</code>. The initial capacity of
   8.119 +     * the string builder is <code>16</code> plus the length of the
   8.120 +     * <code>CharSequence</code> argument.
   8.121 +     *
   8.122 +     * @param      seq   the sequence to copy.
   8.123 +     * @throws    NullPointerException if <code>seq</code> is <code>null</code>
   8.124 +     */
   8.125 +    public StringBuilder(CharSequence seq) {
   8.126 +        this(seq.length() + 16);
   8.127 +        append(seq);
   8.128 +    }
   8.129 +
   8.130 +    public StringBuilder append(Object obj) {
   8.131 +        return append(String.valueOf(obj));
   8.132 +    }
   8.133 +
   8.134 +    public StringBuilder append(String str) {
   8.135 +        super.append(str);
   8.136 +        return this;
   8.137 +    }
   8.138 +
   8.139 +    // Appends the specified string builder to this sequence.
   8.140 +    private StringBuilder append(StringBuilder sb) {
   8.141 +        if (sb == null)
   8.142 +            return append("null");
   8.143 +        int len = sb.length();
   8.144 +        int newcount = count + len;
   8.145 +        if (newcount > value.length)
   8.146 +            expandCapacity(newcount);
   8.147 +        sb.getChars(0, len, value, count);
   8.148 +        count = newcount;
   8.149 +        return this;
   8.150 +    }
   8.151 +
   8.152 +    /**
   8.153 +     * Appends the specified <tt>StringBuffer</tt> to this sequence.
   8.154 +     * <p>
   8.155 +     * The characters of the <tt>StringBuffer</tt> argument are appended,
   8.156 +     * in order, to this sequence, increasing the
   8.157 +     * length of this sequence by the length of the argument.
   8.158 +     * If <tt>sb</tt> is <tt>null</tt>, then the four characters
   8.159 +     * <tt>"null"</tt> are appended to this sequence.
   8.160 +     * <p>
   8.161 +     * Let <i>n</i> be the length of this character sequence just prior to
   8.162 +     * execution of the <tt>append</tt> method. Then the character at index
   8.163 +     * <i>k</i> in the new character sequence is equal to the character at
   8.164 +     * index <i>k</i> in the old character sequence, if <i>k</i> is less than
   8.165 +     * <i>n</i>; otherwise, it is equal to the character at index <i>k-n</i>
   8.166 +     * in the argument <code>sb</code>.
   8.167 +     *
   8.168 +     * @param   sb   the <tt>StringBuffer</tt> to append.
   8.169 +     * @return  a reference to this object.
   8.170 +     */
   8.171 +    public StringBuilder append(StringBuffer sb) {
   8.172 +        super.append(sb);
   8.173 +        return this;
   8.174 +    }
   8.175 +
   8.176 +    /**
   8.177 +     */
   8.178 +    public StringBuilder append(CharSequence s) {
   8.179 +        if (s == null)
   8.180 +            s = "null";
   8.181 +        if (s instanceof String)
   8.182 +            return this.append((String)s);
   8.183 +        if (s instanceof StringBuffer)
   8.184 +            return this.append((StringBuffer)s);
   8.185 +        if (s instanceof StringBuilder)
   8.186 +            return this.append((StringBuilder)s);
   8.187 +        return this.append(s, 0, s.length());
   8.188 +    }
   8.189 +
   8.190 +    /**
   8.191 +     * @throws     IndexOutOfBoundsException {@inheritDoc}
   8.192 +     */
   8.193 +    public StringBuilder append(CharSequence s, int start, int end) {
   8.194 +        super.append(s, start, end);
   8.195 +        return this;
   8.196 +    }
   8.197 +
   8.198 +    public StringBuilder append(char[] str) {
   8.199 +        super.append(str);
   8.200 +        return this;
   8.201 +    }
   8.202 +
   8.203 +    /**
   8.204 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   8.205 +     */
   8.206 +    public StringBuilder append(char[] str, int offset, int len) {
   8.207 +        super.append(str, offset, len);
   8.208 +        return this;
   8.209 +    }
   8.210 +
   8.211 +    public StringBuilder append(boolean b) {
   8.212 +        super.append(b);
   8.213 +        return this;
   8.214 +    }
   8.215 +
   8.216 +    public StringBuilder append(char c) {
   8.217 +        super.append(c);
   8.218 +        return this;
   8.219 +    }
   8.220 +
   8.221 +    public StringBuilder append(int i) {
   8.222 +        super.append(i);
   8.223 +        return this;
   8.224 +    }
   8.225 +
   8.226 +    public StringBuilder append(long lng) {
   8.227 +        super.append(lng);
   8.228 +        return this;
   8.229 +    }
   8.230 +
   8.231 +    public StringBuilder append(float f) {
   8.232 +        super.append(f);
   8.233 +        return this;
   8.234 +    }
   8.235 +
   8.236 +    public StringBuilder append(double d) {
   8.237 +        super.append(d);
   8.238 +        return this;
   8.239 +    }
   8.240 +
   8.241 +    /**
   8.242 +     * @since 1.5
   8.243 +     */
   8.244 +    public StringBuilder appendCodePoint(int codePoint) {
   8.245 +        super.appendCodePoint(codePoint);
   8.246 +        return this;
   8.247 +    }
   8.248 +
   8.249 +    /**
   8.250 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   8.251 +     */
   8.252 +    public StringBuilder delete(int start, int end) {
   8.253 +        super.delete(start, end);
   8.254 +        return this;
   8.255 +    }
   8.256 +
   8.257 +    /**
   8.258 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   8.259 +     */
   8.260 +    public StringBuilder deleteCharAt(int index) {
   8.261 +        super.deleteCharAt(index);
   8.262 +        return this;
   8.263 +    }
   8.264 +
   8.265 +    /**
   8.266 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   8.267 +     */
   8.268 +    public StringBuilder replace(int start, int end, String str) {
   8.269 +        super.replace(start, end, str);
   8.270 +        return this;
   8.271 +    }
   8.272 +
   8.273 +    /**
   8.274 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   8.275 +     */
   8.276 +    public StringBuilder insert(int index, char[] str, int offset,
   8.277 +                                int len)
   8.278 +    {
   8.279 +        super.insert(index, str, offset, len);
   8.280 +        return this;
   8.281 +    }
   8.282 +
   8.283 +    /**
   8.284 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   8.285 +     */
   8.286 +    public StringBuilder insert(int offset, Object obj) {
   8.287 +        return insert(offset, String.valueOf(obj));
   8.288 +    }
   8.289 +
   8.290 +    /**
   8.291 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   8.292 +     */
   8.293 +    public StringBuilder insert(int offset, String str) {
   8.294 +        super.insert(offset, str);
   8.295 +        return this;
   8.296 +    }
   8.297 +
   8.298 +    /**
   8.299 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   8.300 +     */
   8.301 +    public StringBuilder insert(int offset, char[] str) {
   8.302 +        super.insert(offset, str);
   8.303 +        return this;
   8.304 +    }
   8.305 +
   8.306 +    /**
   8.307 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   8.308 +     */
   8.309 +    public StringBuilder insert(int dstOffset, CharSequence s) {
   8.310 +        if (s == null)
   8.311 +            s = "null";
   8.312 +        if (s instanceof String)
   8.313 +            return this.insert(dstOffset, (String)s);
   8.314 +        return this.insert(dstOffset, s, 0, s.length());
   8.315 +    }
   8.316 +
   8.317 +    /**
   8.318 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   8.319 +     */
   8.320 +    public StringBuilder insert(int dstOffset, CharSequence s,
   8.321 +                                int start, int end)
   8.322 +    {
   8.323 +        super.insert(dstOffset, s, start, end);
   8.324 +        return this;
   8.325 +    }
   8.326 +
   8.327 +    /**
   8.328 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   8.329 +     */
   8.330 +    public StringBuilder insert(int offset, boolean b) {
   8.331 +        super.insert(offset, b);
   8.332 +        return this;
   8.333 +    }
   8.334 +
   8.335 +    /**
   8.336 +     * @throws IndexOutOfBoundsException {@inheritDoc}
   8.337 +     */
   8.338 +    public StringBuilder insert(int offset, char c) {
   8.339 +        super.insert(offset, c);
   8.340 +        return this;
   8.341 +    }
   8.342 +
   8.343 +    /**
   8.344 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   8.345 +     */
   8.346 +    public StringBuilder insert(int offset, int i) {
   8.347 +        return insert(offset, String.valueOf(i));
   8.348 +    }
   8.349 +
   8.350 +    /**
   8.351 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   8.352 +     */
   8.353 +    public StringBuilder insert(int offset, long l) {
   8.354 +        return insert(offset, String.valueOf(l));
   8.355 +    }
   8.356 +
   8.357 +    /**
   8.358 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   8.359 +     */
   8.360 +    public StringBuilder insert(int offset, float f) {
   8.361 +        return insert(offset, String.valueOf(f));
   8.362 +    }
   8.363 +
   8.364 +    /**
   8.365 +     * @throws StringIndexOutOfBoundsException {@inheritDoc}
   8.366 +     */
   8.367 +    public StringBuilder insert(int offset, double d) {
   8.368 +        return insert(offset, String.valueOf(d));
   8.369 +    }
   8.370 +
   8.371 +    /**
   8.372 +     * @throws NullPointerException {@inheritDoc}
   8.373 +     */
   8.374 +    public int indexOf(String str) {
   8.375 +        return indexOf(str, 0);
   8.376 +    }
   8.377 +
   8.378 +    /**
   8.379 +     * @throws NullPointerException {@inheritDoc}
   8.380 +     */
   8.381 +    public int indexOf(String str, int fromIndex) {
   8.382 +        return String.indexOf(value, 0, count,
   8.383 +                              str.toCharArray(), 0, str.length(), fromIndex);
   8.384 +    }
   8.385 +
   8.386 +    /**
   8.387 +     * @throws NullPointerException {@inheritDoc}
   8.388 +     */
   8.389 +    public int lastIndexOf(String str) {
   8.390 +        return lastIndexOf(str, count);
   8.391 +    }
   8.392 +
   8.393 +    /**
   8.394 +     * @throws NullPointerException {@inheritDoc}
   8.395 +     */
   8.396 +    public int lastIndexOf(String str, int fromIndex) {
   8.397 +        return String.lastIndexOf(value, 0, count,
   8.398 +                              str.toCharArray(), 0, str.length(), fromIndex);
   8.399 +    }
   8.400 +
   8.401 +    public StringBuilder reverse() {
   8.402 +        super.reverse();
   8.403 +        return this;
   8.404 +    }
   8.405 +
   8.406 +    public String toString() {
   8.407 +        // Create a copy, don't share the array
   8.408 +        return new String(value, 0, count);
   8.409 +    }
   8.410 +
   8.411 +    /**
   8.412 +     * Save the state of the <tt>StringBuilder</tt> instance to a stream
   8.413 +     * (that is, serialize it).
   8.414 +     *
   8.415 +     * @serialData the number of characters currently stored in the string
   8.416 +     *             builder (<tt>int</tt>), followed by the characters in the
   8.417 +     *             string builder (<tt>char[]</tt>).   The length of the
   8.418 +     *             <tt>char</tt> array may be greater than the number of
   8.419 +     *             characters currently stored in the string builder, in which
   8.420 +     *             case extra characters are ignored.
   8.421 +     */
   8.422 +    private void writeObject(java.io.ObjectOutputStream s)
   8.423 +        throws java.io.IOException {
   8.424 +        s.defaultWriteObject();
   8.425 +        s.writeInt(count);
   8.426 +        s.writeObject(value);
   8.427 +    }
   8.428 +
   8.429 +    /**
   8.430 +     * readObject is called to restore the state of the StringBuffer from
   8.431 +     * a stream.
   8.432 +     */
   8.433 +    private void readObject(java.io.ObjectInputStream s)
   8.434 +        throws java.io.IOException, ClassNotFoundException {
   8.435 +        s.defaultReadObject();
   8.436 +        count = s.readInt();
   8.437 +        value = (char[]) s.readObject();
   8.438 +    }
   8.439 +
   8.440 +}