# HG changeset patch # User Jaroslav Tulach # Date 1349961360 25200 # Node ID ff3f0de0b8a26896f6581e0d51a89f2f4aa04a38 # Parent 4fca8ddf46deb916941a4d6996a657b6ffeae199# Parent 029e6eed60e91b10b133a921f30cda5cec704348 The emulation approach turned to be working well. Let's merge it to trunk. diff -r 4fca8ddf46de -r ff3f0de0b8a2 .hgtags --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgtags Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,1 @@ +0a115f1c6f3c70458fc479ae82b4d7fcdeb7e95a jdk7-b147_base diff -r 4fca8ddf46de -r ff3f0de0b8a2 core/pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/pom.xml Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,26 @@ + + + 4.0.0 + + org.apidesign + bck2brwsr + 1.0-SNAPSHOT + + org.apidesign.bck2brwsr + core + 1.0-SNAPSHOT + core + http://maven.apache.org + + UTF-8 + + + + junit + junit + 3.8.1 + test + + + diff -r 4fca8ddf46de -r ff3f0de0b8a2 core/src/main/java/org/apidesign/bck2brwsr/core/ExtraJavaScript.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/src/main/java/org/apidesign/bck2brwsr/core/ExtraJavaScript.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,19 @@ +package org.apidesign.bck2brwsr.core; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * + * @author Jaroslav Tulach + */ +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.TYPE) +public @interface ExtraJavaScript { + /** location of a script to load */ + String resource(); + /** should the class file still be processed or not? */ + boolean processByteCode() default true; +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 core/src/main/java/org/apidesign/bck2brwsr/core/JavaScriptBody.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/src/main/java/org/apidesign/bck2brwsr/core/JavaScriptBody.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,38 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.apidesign.bck2brwsr.core; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** Put this method on a method in case it should have a special + * body in the JavaScript. + * + * @author Jaroslav Tulach + */ +@Retention(RetentionPolicy.CLASS) +@Target({ ElementType.METHOD, ElementType.CONSTRUCTOR }) +public @interface JavaScriptBody { + /** Names of parameters for the method. + * + * + * + * @return array of the names of parameters for the method + * in JavaScript + */ + public String[] args(); + + /** The actual body of the method in JavaScript. This string will be + * put into generated header (ends with '{') and footer (ends with '}'). + */ + public String body(); +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 core/src/main/java/org/apidesign/bck2brwsr/core/NoJavaScript.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/src/main/java/org/apidesign/bck2brwsr/core/NoJavaScript.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,16 @@ +package org.apidesign.bck2brwsr.core; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** Don't include given field or method in generated JavaScript. + * + * @author Jaroslav Tulach + */ +@Retention(RetentionPolicy.CLASS) +@Target({ ElementType.METHOD, ElementType.FIELD }) +public @interface NoJavaScript { + +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/pom.xml Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,48 @@ + + + 4.0.0 + + org.apidesign + bck2brwsr + 1.0-SNAPSHOT + + org.apidesign.bck2brwsr + emul + 1.0-SNAPSHOT + Java API Emulation + http://maven.apache.org + + UTF-8 + + + + junit + junit + 3.8.1 + test + + + org.apidesign.bck2brwsr + core + 1.0-SNAPSHOT + jar + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + + non-existing + + 1.7 + 1.7 + + + + + diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/io/IOException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/io/IOException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,101 @@ +/* + * Copyright (c) 1994, 2006, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.io; + +/** + * Signals that an I/O exception of some sort has occurred. This + * class is the general class of exceptions produced by failed or + * interrupted I/O operations. + * + * @author unascribed + * @see java.io.InputStream + * @see java.io.OutputStream + * @since JDK1.0 + */ +public +class IOException extends Exception { + static final long serialVersionUID = 7818375828146090155L; + + /** + * Constructs an {@code IOException} with {@code null} + * as its error detail message. + */ + public IOException() { + super(); + } + + /** + * Constructs an {@code IOException} with the specified detail message. + * + * @param message + * The detail message (which is saved for later retrieval + * by the {@link #getMessage()} method) + */ + public IOException(String message) { + super(message); + } + + /** + * Constructs an {@code IOException} with the specified detail message + * and cause. + * + *

Note that the detail message associated with {@code cause} is + * not automatically incorporated into this exception's detail + * message. + * + * @param message + * The detail message (which is saved for later retrieval + * by the {@link #getMessage()} method) + * + * @param cause + * The cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A null value is permitted, + * and indicates that the cause is nonexistent or unknown.) + * + * @since 1.6 + */ + public IOException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs an {@code IOException} with the specified cause and a + * detail message of {@code (cause==null ? null : cause.toString())} + * (which typically contains the class and detail message of {@code cause}). + * This constructor is useful for IO exceptions that are little more + * than wrappers for other throwables. + * + * @param cause + * The cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A null value is permitted, + * and indicates that the cause is nonexistent or unknown.) + * + * @since 1.6 + */ + public IOException(Throwable cause) { + super(cause); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/io/Serializable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/io/Serializable.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,170 @@ +/* + * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.io; + +/** + * Serializability of a class is enabled by the class implementing the + * java.io.Serializable interface. Classes that do not implement this + * interface will not have any of their state serialized or + * deserialized. All subtypes of a serializable class are themselves + * serializable. The serialization interface has no methods or fields + * and serves only to identify the semantics of being serializable.

+ * + * To allow subtypes of non-serializable classes to be serialized, the + * subtype may assume responsibility for saving and restoring the + * state of the supertype's public, protected, and (if accessible) + * package fields. The subtype may assume this responsibility only if + * the class it extends has an accessible no-arg constructor to + * initialize the class's state. It is an error to declare a class + * Serializable if this is not the case. The error will be detected at + * runtime.

+ * + * During deserialization, the fields of non-serializable classes will + * be initialized using the public or protected no-arg constructor of + * the class. A no-arg constructor must be accessible to the subclass + * that is serializable. The fields of serializable subclasses will + * be restored from the stream.

+ * + * When traversing a graph, an object may be encountered that does not + * support the Serializable interface. In this case the + * NotSerializableException will be thrown and will identify the class + * of the non-serializable object.

+ * + * Classes that require special handling during the serialization and + * deserialization process must implement special methods with these exact + * signatures:

+ * + *

+ * private void writeObject(java.io.ObjectOutputStream out)
+ *     throws IOException
+ * private void readObject(java.io.ObjectInputStream in)
+ *     throws IOException, ClassNotFoundException;
+ * private void readObjectNoData()
+ *     throws ObjectStreamException;
+ * 
+ * + *

The writeObject method is responsible for writing the state of the + * object for its particular class so that the corresponding + * readObject method can restore it. The default mechanism for saving + * the Object's fields can be invoked by calling + * out.defaultWriteObject. The method does not need to concern + * itself with the state belonging to its superclasses or subclasses. + * State is saved by writing the individual fields to the + * ObjectOutputStream using the writeObject method or by using the + * methods for primitive data types supported by DataOutput. + * + *

The readObject method is responsible for reading from the stream and + * restoring the classes fields. It may call in.defaultReadObject to invoke + * the default mechanism for restoring the object's non-static and + * non-transient fields. The defaultReadObject method uses information in + * the stream to assign the fields of the object saved in the stream with the + * correspondingly named fields in the current object. This handles the case + * when the class has evolved to add new fields. The method does not need to + * concern itself with the state belonging to its superclasses or subclasses. + * State is saved by writing the individual fields to the + * ObjectOutputStream using the writeObject method or by using the + * methods for primitive data types supported by DataOutput. + * + *

The readObjectNoData method is responsible for initializing the state of + * the object for its particular class in the event that the serialization + * stream does not list the given class as a superclass of the object being + * deserialized. This may occur in cases where the receiving party uses a + * different version of the deserialized instance's class than the sending + * party, and the receiver's version extends classes that are not extended by + * the sender's version. This may also occur if the serialization stream has + * been tampered; hence, readObjectNoData is useful for initializing + * deserialized objects properly despite a "hostile" or incomplete source + * stream. + * + *

Serializable classes that need to designate an alternative object to be + * used when writing an object to the stream should implement this + * special method with the exact signature:

+ * + *

+ * ANY-ACCESS-MODIFIER Object writeReplace() throws ObjectStreamException;
+ * 

+ * + * This writeReplace method is invoked by serialization if the method + * exists and it would be accessible from a method defined within the + * class of the object being serialized. Thus, the method can have private, + * protected and package-private access. Subclass access to this method + * follows java accessibility rules.

+ * + * Classes that need to designate a replacement when an instance of it + * is read from the stream should implement this special method with the + * exact signature.

+ * + *

+ * ANY-ACCESS-MODIFIER Object readResolve() throws ObjectStreamException;
+ * 

+ * + * This readResolve method follows the same invocation rules and + * accessibility rules as writeReplace.

+ * + * The serialization runtime associates with each serializable class a version + * number, called a serialVersionUID, which is used during deserialization to + * verify that the sender and receiver of a serialized object have loaded + * classes for that object that are compatible with respect to serialization. + * If the receiver has loaded a class for the object that has a different + * serialVersionUID than that of the corresponding sender's class, then + * deserialization will result in an {@link InvalidClassException}. A + * serializable class can declare its own serialVersionUID explicitly by + * declaring a field named "serialVersionUID" that must be static, + * final, and of type long:

+ * + *

+ * ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;
+ * 
+ * + * If a serializable class does not explicitly declare a serialVersionUID, then + * the serialization runtime will calculate a default serialVersionUID value + * for that class based on various aspects of the class, as described in the + * Java(TM) Object Serialization Specification. However, it is strongly + * recommended that all serializable classes explicitly declare + * serialVersionUID values, since the default serialVersionUID computation is + * highly sensitive to class details that may vary depending on compiler + * implementations, and can thus result in unexpected + * InvalidClassExceptions during deserialization. Therefore, to + * guarantee a consistent serialVersionUID value across different java compiler + * implementations, a serializable class must declare an explicit + * serialVersionUID value. It is also strongly advised that explicit + * serialVersionUID declarations use the private modifier where + * possible, since such declarations apply only to the immediately declaring + * class--serialVersionUID fields are not useful as inherited members. Array + * classes cannot declare an explicit serialVersionUID, so they always have + * the default computed value, but the requirement for matching + * serialVersionUID values is waived for array classes. + * + * @author unascribed + * @see java.io.ObjectOutputStream + * @see java.io.ObjectInputStream + * @see java.io.ObjectOutput + * @see java.io.ObjectInput + * @see java.io.Externalizable + * @since JDK1.1 + */ +public interface Serializable { +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/io/UnsupportedEncodingException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/io/UnsupportedEncodingException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package java.io; + +/** + * The Character Encoding is not supported. + * + * @author Asmus Freytag + * @since JDK1.1 + */ +public class UnsupportedEncodingException + extends IOException +{ + private static final long serialVersionUID = -4274276298326136670L; + + /** + * Constructs an UnsupportedEncodingException without a detail message. + */ + public UnsupportedEncodingException() { + super(); + } + + /** + * Constructs an UnsupportedEncodingException with a detail message. + * @param s Describes the reason for the exception. + */ + public UnsupportedEncodingException(String s) { + super(s); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/AbstractStringBuilder.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/AbstractStringBuilder.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,1408 @@ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +import org.apidesign.bck2brwsr.core.JavaScriptBody; + +/** + * A mutable sequence of characters. + *

+ * Implements a modifiable string. At any point in time it contains some + * particular sequence of characters, but the length and content of the + * sequence can be changed through certain method calls. + * + * @author Michael McCloskey + * @author Martin Buchholz + * @author Ulf Zibis + * @since 1.5 + */ +abstract class AbstractStringBuilder implements Appendable, CharSequence { + /** + * The value is used for character storage. + */ + char[] value; + + /** + * The count is the number of characters used. + */ + int count; + + /** + * This no-arg constructor is necessary for serialization of subclasses. + */ + AbstractStringBuilder() { + } + + /** + * Creates an AbstractStringBuilder of the specified capacity. + */ + AbstractStringBuilder(int capacity) { + value = new char[capacity]; + } + + /** + * Returns the length (character count). + * + * @return the length of the sequence of characters currently + * represented by this object + */ + public int length() { + return count; + } + + /** + * Returns the current capacity. The capacity is the amount of storage + * available for newly inserted characters, beyond which an allocation + * will occur. + * + * @return the current capacity + */ + public int capacity() { + return value.length; + } + + /** + * Ensures that the capacity is at least equal to the specified minimum. + * If the current capacity is less than the argument, then a new internal + * array is allocated with greater capacity. The new capacity is the + * larger of: + *

    + *
  • The minimumCapacity argument. + *
  • Twice the old capacity, plus 2. + *
+ * If the minimumCapacity argument is nonpositive, this + * method takes no action and simply returns. + * + * @param minimumCapacity the minimum desired capacity. + */ + public void ensureCapacity(int minimumCapacity) { + if (minimumCapacity > 0) + ensureCapacityInternal(minimumCapacity); + } + + /** + * This method has the same contract as ensureCapacity, but is + * never synchronized. + */ + private void ensureCapacityInternal(int minimumCapacity) { + // overflow-conscious code + if (minimumCapacity - value.length > 0) + expandCapacity(minimumCapacity); + } + + /** + * This implements the expansion semantics of ensureCapacity with no + * size check or synchronization. + */ + void expandCapacity(int minimumCapacity) { + int newCapacity = value.length * 2 + 2; + if (newCapacity - minimumCapacity < 0) + newCapacity = minimumCapacity; + if (newCapacity < 0) { + if (minimumCapacity < 0) // overflow + throw new OutOfMemoryError(); + newCapacity = Integer.MAX_VALUE; + } + value = String.copyOf(value, newCapacity); + } + + /** + * Attempts to reduce storage used for the character sequence. + * If the buffer is larger than necessary to hold its current sequence of + * characters, then it may be resized to become more space efficient. + * Calling this method may, but is not required to, affect the value + * returned by a subsequent call to the {@link #capacity()} method. + */ + public void trimToSize() { + if (count < value.length) { + value = String.copyOf(value, count); + } + } + + /** + * Sets the length of the character sequence. + * The sequence is changed to a new character sequence + * whose length is specified by the argument. For every nonnegative + * index k less than newLength, the character at + * index k in the new character sequence is the same as the + * character at index k in the old sequence if k is less + * than the length of the old character sequence; otherwise, it is the + * null character '\u0000'. + * + * In other words, if the newLength argument is less than + * the current length, the length is changed to the specified length. + *

+ * If the newLength argument is greater than or equal + * to the current length, sufficient null characters + * ('\u0000') are appended so that + * length becomes the newLength argument. + *

+ * The newLength argument must be greater than or equal + * to 0. + * + * @param newLength the new length + * @throws IndexOutOfBoundsException if the + * newLength argument is negative. + */ + public void setLength(int newLength) { + if (newLength < 0) + throw new StringIndexOutOfBoundsException(newLength); + ensureCapacityInternal(newLength); + + if (count < newLength) { + for (; count < newLength; count++) + value[count] = '\0'; + } else { + count = newLength; + } + } + + /** + * Returns the char value in this sequence at the specified index. + * The first char value is at index 0, the next at index + * 1, and so on, as in array indexing. + *

+ * The index argument must be greater than or equal to + * 0, and less than the length of this sequence. + * + *

If the char value specified by the index is a + * surrogate, the surrogate + * value is returned. + * + * @param index the index of the desired char value. + * @return the char value at the specified index. + * @throws IndexOutOfBoundsException if index is + * negative or greater than or equal to length(). + */ + public char charAt(int index) { + if ((index < 0) || (index >= count)) + throw new StringIndexOutOfBoundsException(index); + return value[index]; + } + + /** + * Returns the character (Unicode code point) at the specified + * index. The index refers to char values + * (Unicode code units) and ranges from 0 to + * {@link #length()} - 1. + * + *

If the char value specified at the given index + * is in the high-surrogate range, the following index is less + * than the length of this sequence, and the + * char value at the following index is in the + * low-surrogate range, then the supplementary code point + * corresponding to this surrogate pair is returned. Otherwise, + * the char value at the given index is returned. + * + * @param index the index to the char values + * @return the code point value of the character at the + * index + * @exception IndexOutOfBoundsException if the index + * argument is negative or not less than the length of this + * sequence. + */ + public int codePointAt(int index) { + if ((index < 0) || (index >= count)) { + throw new StringIndexOutOfBoundsException(index); + } + return Character.codePointAt(value, index); + } + + /** + * Returns the character (Unicode code point) before the specified + * index. The index refers to char values + * (Unicode code units) and ranges from 1 to {@link + * #length()}. + * + *

If the char value at (index - 1) + * is in the low-surrogate range, (index - 2) is not + * negative, and the char value at (index - + * 2) is in the high-surrogate range, then the + * supplementary code point value of the surrogate pair is + * returned. If the char value at index - + * 1 is an unpaired low-surrogate or a high-surrogate, the + * surrogate value is returned. + * + * @param index the index following the code point that should be returned + * @return the Unicode code point value before the given index. + * @exception IndexOutOfBoundsException if the index + * argument is less than 1 or greater than the length + * of this sequence. + */ + public int codePointBefore(int index) { + int i = index - 1; + if ((i < 0) || (i >= count)) { + throw new StringIndexOutOfBoundsException(index); + } + return Character.codePointBefore(value, index); + } + + /** + * Returns the number of Unicode code points in the specified text + * range of this sequence. The text range begins at the specified + * beginIndex and extends to the char at + * index endIndex - 1. Thus the length (in + * chars) of the text range is + * endIndex-beginIndex. Unpaired surrogates within + * this sequence count as one code point each. + * + * @param beginIndex the index to the first char of + * the text range. + * @param endIndex the index after the last char of + * the text range. + * @return the number of Unicode code points in the specified text + * range + * @exception IndexOutOfBoundsException if the + * beginIndex is negative, or endIndex + * is larger than the length of this sequence, or + * beginIndex is larger than endIndex. + */ + public int codePointCount(int beginIndex, int endIndex) { + if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) { + throw new IndexOutOfBoundsException(); + } + return Character.codePointCountImpl(value, beginIndex, endIndex-beginIndex); + } + + /** + * Returns the index within this sequence that is offset from the + * given index by codePointOffset code + * points. Unpaired surrogates within the text range given by + * index and codePointOffset count as + * one code point each. + * + * @param index the index to be offset + * @param codePointOffset the offset in code points + * @return the index within this sequence + * @exception IndexOutOfBoundsException if index + * is negative or larger then the length of this sequence, + * or if codePointOffset is positive and the subsequence + * starting with index has fewer than + * codePointOffset code points, + * or if codePointOffset is negative and the subsequence + * before index has fewer than the absolute value of + * codePointOffset code points. + */ + public int offsetByCodePoints(int index, int codePointOffset) { + if (index < 0 || index > count) { + throw new IndexOutOfBoundsException(); + } + return Character.offsetByCodePointsImpl(value, 0, count, + index, codePointOffset); + } + + /** + * Characters are copied from this sequence into the + * destination character array dst. The first character to + * be copied is at index srcBegin; the last character to + * be copied is at index srcEnd-1. The total number of + * characters to be copied is srcEnd-srcBegin. The + * characters are copied into the subarray of dst starting + * at index dstBegin and ending at index: + *

+     * dstbegin + (srcEnd-srcBegin) - 1
+     * 
+ * + * @param srcBegin start copying at this offset. + * @param srcEnd stop copying at this offset. + * @param dst the array to copy the data into. + * @param dstBegin offset into dst. + * @throws NullPointerException if dst is + * null. + * @throws IndexOutOfBoundsException if any of the following is true: + *
    + *
  • srcBegin is negative + *
  • dstBegin is negative + *
  • the srcBegin argument is greater than + * the srcEnd argument. + *
  • srcEnd is greater than + * this.length(). + *
  • dstBegin+srcEnd-srcBegin is greater than + * dst.length + *
+ */ + public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) + { + if (srcBegin < 0) + throw new StringIndexOutOfBoundsException(srcBegin); + if ((srcEnd < 0) || (srcEnd > count)) + throw new StringIndexOutOfBoundsException(srcEnd); + if (srcBegin > srcEnd) + throw new StringIndexOutOfBoundsException("srcBegin > srcEnd"); + String.arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin); + } + + /** + * The character at the specified index is set to ch. This + * sequence is altered to represent a new character sequence that is + * identical to the old character sequence, except that it contains the + * character ch at position index. + *

+ * The index argument must be greater than or equal to + * 0, and less than the length of this sequence. + * + * @param index the index of the character to modify. + * @param ch the new character. + * @throws IndexOutOfBoundsException if index is + * negative or greater than or equal to length(). + */ + public void setCharAt(int index, char ch) { + if ((index < 0) || (index >= count)) + throw new StringIndexOutOfBoundsException(index); + value[index] = ch; + } + + /** + * Appends the string representation of the {@code Object} argument. + *

+ * The overall effect is exactly as if the argument were converted + * to a string by the method {@link String#valueOf(Object)}, + * and the characters of that string were then + * {@link #append(String) appended} to this character sequence. + * + * @param obj an {@code Object}. + * @return a reference to this object. + */ + public AbstractStringBuilder append(Object obj) { + return append(String.valueOf(obj)); + } + + /** + * Appends the specified string to this character sequence. + *

+ * The characters of the {@code String} argument are appended, in + * order, increasing the length of this sequence by the length of the + * argument. If {@code str} is {@code null}, then the four + * characters {@code "null"} are appended. + *

+ * Let n be the length of this character sequence just prior to + * execution of the {@code append} method. Then the character at + * index k in the new character sequence is equal to the character + * at index k in the old character sequence, if k is less + * than n; otherwise, it is equal to the character at index + * k-n in the argument {@code str}. + * + * @param str a string. + * @return a reference to this object. + */ + public AbstractStringBuilder append(String str) { + if (str == null) str = "null"; + int len = str.length(); + ensureCapacityInternal(count + len); + str.getChars(0, len, value, count); + count += len; + return this; + } + + // Documentation in subclasses because of synchro difference + public AbstractStringBuilder append(StringBuffer sb) { + if (sb == null) + return append("null"); + int len = sb.length(); + ensureCapacityInternal(count + len); + sb.getChars(0, len, value, count); + count += len; + return this; + } + + // Documentation in subclasses because of synchro difference + public AbstractStringBuilder append(CharSequence s) { + if (s == null) + s = "null"; + if (s instanceof String) + return this.append((String)s); + if (s instanceof StringBuffer) + return this.append((StringBuffer)s); + return this.append(s, 0, s.length()); + } + + /** + * Appends a subsequence of the specified {@code CharSequence} to this + * sequence. + *

+ * Characters of the argument {@code s}, starting at + * index {@code start}, are appended, in order, to the contents of + * this sequence up to the (exclusive) index {@code end}. The length + * of this sequence is increased by the value of {@code end - start}. + *

+ * Let n be the length of this character sequence just prior to + * execution of the {@code append} method. Then the character at + * index k in this character sequence becomes equal to the + * character at index k in this sequence, if k is less than + * n; otherwise, it is equal to the character at index + * k+start-n in the argument {@code s}. + *

+ * If {@code s} is {@code null}, then this method appends + * characters as if the s parameter was a sequence containing the four + * characters {@code "null"}. + * + * @param s the sequence to append. + * @param start the starting index of the subsequence to be appended. + * @param end the end index of the subsequence to be appended. + * @return a reference to this object. + * @throws IndexOutOfBoundsException if + * {@code start} is negative, or + * {@code start} is greater than {@code end} or + * {@code end} is greater than {@code s.length()} + */ + public AbstractStringBuilder append(CharSequence s, int start, int end) { + if (s == null) + s = "null"; + if ((start < 0) || (start > end) || (end > s.length())) + throw new IndexOutOfBoundsException( + "start " + start + ", end " + end + ", s.length() " + + s.length()); + int len = end - start; + ensureCapacityInternal(count + len); + for (int i = start, j = count; i < end; i++, j++) + value[j] = s.charAt(i); + count += len; + return this; + } + + /** + * Appends the string representation of the {@code char} array + * argument to this sequence. + *

+ * The characters of the array argument are appended, in order, to + * the contents of this sequence. The length of this sequence + * increases by the length of the argument. + *

+ * The overall effect is exactly as if the argument were converted + * to a string by the method {@link String#valueOf(char[])}, + * and the characters of that string were then + * {@link #append(String) appended} to this character sequence. + * + * @param str the characters to be appended. + * @return a reference to this object. + */ + public AbstractStringBuilder append(char[] str) { + int len = str.length; + ensureCapacityInternal(count + len); + String.arraycopy(str, 0, value, count, len); + count += len; + return this; + } + + /** + * Appends the string representation of a subarray of the + * {@code char} array argument to this sequence. + *

+ * Characters of the {@code char} array {@code str}, starting at + * index {@code offset}, are appended, in order, to the contents + * of this sequence. The length of this sequence increases + * by the value of {@code len}. + *

+ * The overall effect is exactly as if the arguments were converted + * to a string by the method {@link String#valueOf(char[],int,int)}, + * and the characters of that string were then + * {@link #append(String) appended} to this character sequence. + * + * @param str the characters to be appended. + * @param offset the index of the first {@code char} to append. + * @param len the number of {@code char}s to append. + * @return a reference to this object. + * @throws IndexOutOfBoundsException + * if {@code offset < 0} or {@code len < 0} + * or {@code offset+len > str.length} + */ + public AbstractStringBuilder append(char str[], int offset, int len) { + if (len > 0) // let arraycopy report AIOOBE for len < 0 + ensureCapacityInternal(count + len); + String.arraycopy(str, offset, value, count, len); + count += len; + return this; + } + + /** + * Appends the string representation of the {@code boolean} + * argument to the sequence. + *

+ * The overall effect is exactly as if the argument were converted + * to a string by the method {@link String#valueOf(boolean)}, + * and the characters of that string were then + * {@link #append(String) appended} to this character sequence. + * + * @param b a {@code boolean}. + * @return a reference to this object. + */ + public AbstractStringBuilder append(boolean b) { + if (b) { + ensureCapacityInternal(count + 4); + value[count++] = 't'; + value[count++] = 'r'; + value[count++] = 'u'; + value[count++] = 'e'; + } else { + ensureCapacityInternal(count + 5); + value[count++] = 'f'; + value[count++] = 'a'; + value[count++] = 'l'; + value[count++] = 's'; + value[count++] = 'e'; + } + return this; + } + + /** + * Appends the string representation of the {@code char} + * argument to this sequence. + *

+ * The argument is appended to the contents of this sequence. + * The length of this sequence increases by {@code 1}. + *

+ * The overall effect is exactly as if the argument were converted + * to a string by the method {@link String#valueOf(char)}, + * and the character in that string were then + * {@link #append(String) appended} to this character sequence. + * + * @param c a {@code char}. + * @return a reference to this object. + */ + public AbstractStringBuilder append(char c) { + ensureCapacityInternal(count + 1); + value[count++] = c; + return this; + } + + /** + * Appends the string representation of the {@code int} + * argument to this sequence. + *

+ * The overall effect is exactly as if the argument were converted + * to a string by the method {@link String#valueOf(int)}, + * and the characters of that string were then + * {@link #append(String) appended} to this character sequence. + * + * @param i an {@code int}. + * @return a reference to this object. + */ + @JavaScriptBody( + args={ "self", "i" }, + body="return java_lang_AbstractStringBuilder_appendLjava_lang_AbstractStringBuilderLjava_lang_String(self,i.toString());" + ) + public AbstractStringBuilder append(int i) { + if (i == Integer.MIN_VALUE) { + append("-2147483648"); + return this; + } + int appendedLength = (i < 0) ? Integer.stringSize(-i) + 1 + : Integer.stringSize(i); + int spaceNeeded = count + appendedLength; + ensureCapacityInternal(spaceNeeded); + Integer.getChars(i, spaceNeeded, value); + count = spaceNeeded; + return this; + } + + /** + * Appends the string representation of the {@code long} + * argument to this sequence. + *

+ * The overall effect is exactly as if the argument were converted + * to a string by the method {@link String#valueOf(long)}, + * and the characters of that string were then + * {@link #append(String) appended} to this character sequence. + * + * @param l a {@code long}. + * @return a reference to this object. + */ + public AbstractStringBuilder append(long l) { + if (l == Long.MIN_VALUE) { + append("-9223372036854775808"); + return this; + } + int appendedLength = (l < 0) ? Long.stringSize(-l) + 1 + : Long.stringSize(l); + int spaceNeeded = count + appendedLength; + ensureCapacityInternal(spaceNeeded); + Long.getChars(l, spaceNeeded, value); + count = spaceNeeded; + return this; + } + + /** + * Appends the string representation of the {@code float} + * argument to this sequence. + *

+ * The overall effect is exactly as if the argument were converted + * to a string by the method {@link String#valueOf(float)}, + * and the characters of that string were then + * {@link #append(String) appended} to this character sequence. + * + * @param f a {@code float}. + * @return a reference to this object. + */ + public AbstractStringBuilder append(float f) { + throw new UnsupportedOperationException(); + } + + /** + * Appends the string representation of the {@code double} + * argument to this sequence. + *

+ * The overall effect is exactly as if the argument were converted + * to a string by the method {@link String#valueOf(double)}, + * and the characters of that string were then + * {@link #append(String) appended} to this character sequence. + * + * @param d a {@code double}. + * @return a reference to this object. + */ + public AbstractStringBuilder append(double d) { + throw new UnsupportedOperationException(); + } + + /** + * Removes the characters in a substring of this sequence. + * The substring begins at the specified {@code start} and extends to + * the character at index {@code end - 1} or to the end of the + * sequence if no such character exists. If + * {@code start} is equal to {@code end}, no changes are made. + * + * @param start The beginning index, inclusive. + * @param end The ending index, exclusive. + * @return This object. + * @throws StringIndexOutOfBoundsException if {@code start} + * is negative, greater than {@code length()}, or + * greater than {@code end}. + */ + public AbstractStringBuilder delete(int start, int end) { + if (start < 0) + throw new StringIndexOutOfBoundsException(start); + if (end > count) + end = count; + if (start > end) + throw new StringIndexOutOfBoundsException(); + int len = end - start; + if (len > 0) { + String.arraycopy(value, start+len, value, start, count-end); + count -= len; + } + return this; + } + + /** + * Appends the string representation of the {@code codePoint} + * argument to this sequence. + * + *

The argument is appended to the contents of this sequence. + * The length of this sequence increases by + * {@link Character#charCount(int) Character.charCount(codePoint)}. + * + *

The overall effect is exactly as if the argument were + * converted to a {@code char} array by the method + * {@link Character#toChars(int)} and the character in that array + * were then {@link #append(char[]) appended} to this character + * sequence. + * + * @param codePoint a Unicode code point + * @return a reference to this object. + * @exception IllegalArgumentException if the specified + * {@code codePoint} isn't a valid Unicode code point + */ + public AbstractStringBuilder appendCodePoint(int codePoint) { + final int count = this.count; + + if (Character.isBmpCodePoint(codePoint)) { + ensureCapacityInternal(count + 1); + value[count] = (char) codePoint; + this.count = count + 1; + } else if (Character.isValidCodePoint(codePoint)) { + ensureCapacityInternal(count + 2); + Character.toSurrogates(codePoint, value, count); + this.count = count + 2; + } else { + throw new IllegalArgumentException(); + } + return this; + } + + /** + * Removes the char at the specified position in this + * sequence. This sequence is shortened by one char. + * + *

Note: If the character at the given index is a supplementary + * character, this method does not remove the entire character. If + * correct handling of supplementary characters is required, + * determine the number of chars to remove by calling + * Character.charCount(thisSequence.codePointAt(index)), + * where thisSequence is this sequence. + * + * @param index Index of char to remove + * @return This object. + * @throws StringIndexOutOfBoundsException if the index + * is negative or greater than or equal to + * length(). + */ + public AbstractStringBuilder deleteCharAt(int index) { + if ((index < 0) || (index >= count)) + throw new StringIndexOutOfBoundsException(index); + String.arraycopy(value, index+1, value, index, count-index-1); + count--; + return this; + } + + /** + * Replaces the characters in a substring of this sequence + * with characters in the specified String. The substring + * begins at the specified start and extends to the character + * at index end - 1 or to the end of the + * sequence if no such character exists. First the + * characters in the substring are removed and then the specified + * String is inserted at start. (This + * sequence will be lengthened to accommodate the + * specified String if necessary.) + * + * @param start The beginning index, inclusive. + * @param end The ending index, exclusive. + * @param str String that will replace previous contents. + * @return This object. + * @throws StringIndexOutOfBoundsException if start + * is negative, greater than length(), or + * greater than end. + */ + public AbstractStringBuilder replace(int start, int end, String str) { + if (start < 0) + throw new StringIndexOutOfBoundsException(start); + if (start > count) + throw new StringIndexOutOfBoundsException("start > length()"); + if (start > end) + throw new StringIndexOutOfBoundsException("start > end"); + + if (end > count) + end = count; + int len = str.length(); + int newCount = count + len - (end - start); + ensureCapacityInternal(newCount); + + String.arraycopy(value, end, value, start + len, count - end); + str.getChars(value, start); + count = newCount; + return this; + } + + /** + * Returns a new String that contains a subsequence of + * characters currently contained in this character sequence. The + * substring begins at the specified index and extends to the end of + * this sequence. + * + * @param start The beginning index, inclusive. + * @return The new string. + * @throws StringIndexOutOfBoundsException if start is + * less than zero, or greater than the length of this object. + */ + public String substring(int start) { + return substring(start, count); + } + + /** + * Returns a new character sequence that is a subsequence of this sequence. + * + *

An invocation of this method of the form + * + *

+     * sb.subSequence(begin, end)
+ * + * behaves in exactly the same way as the invocation + * + *
+     * sb.substring(begin, end)
+ * + * This method is provided so that this class can + * implement the {@link CharSequence} interface.

+ * + * @param start the start index, inclusive. + * @param end the end index, exclusive. + * @return the specified subsequence. + * + * @throws IndexOutOfBoundsException + * if start or end are negative, + * if end is greater than length(), + * or if start is greater than end + * @spec JSR-51 + */ + public CharSequence subSequence(int start, int end) { + return substring(start, end); + } + + /** + * Returns a new String that contains a subsequence of + * characters currently contained in this sequence. The + * substring begins at the specified start and + * extends to the character at index end - 1. + * + * @param start The beginning index, inclusive. + * @param end The ending index, exclusive. + * @return The new string. + * @throws StringIndexOutOfBoundsException if start + * or end are negative or greater than + * length(), or start is + * greater than end. + */ + public String substring(int start, int end) { + if (start < 0) + throw new StringIndexOutOfBoundsException(start); + if (end > count) + throw new StringIndexOutOfBoundsException(end); + if (start > end) + throw new StringIndexOutOfBoundsException(end - start); + return new String(value, start, end - start); + } + + /** + * Inserts the string representation of a subarray of the {@code str} + * array argument into this sequence. The subarray begins at the + * specified {@code offset} and extends {@code len} {@code char}s. + * The characters of the subarray are inserted into this sequence at + * the position indicated by {@code index}. The length of this + * sequence increases by {@code len} {@code char}s. + * + * @param index position at which to insert subarray. + * @param str A {@code char} array. + * @param offset the index of the first {@code char} in subarray to + * be inserted. + * @param len the number of {@code char}s in the subarray to + * be inserted. + * @return This object + * @throws StringIndexOutOfBoundsException if {@code index} + * is negative or greater than {@code length()}, or + * {@code offset} or {@code len} are negative, or + * {@code (offset+len)} is greater than + * {@code str.length}. + */ + public AbstractStringBuilder insert(int index, char[] str, int offset, + int len) + { + if ((index < 0) || (index > length())) + throw new StringIndexOutOfBoundsException(index); + if ((offset < 0) || (len < 0) || (offset > str.length - len)) + throw new StringIndexOutOfBoundsException( + "offset " + offset + ", len " + len + ", str.length " + + str.length); + ensureCapacityInternal(count + len); + String.arraycopy(value, index, value, index + len, count - index); + String.arraycopy(str, offset, value, index, len); + count += len; + return this; + } + + /** + * Inserts the string representation of the {@code Object} + * argument into this character sequence. + *

+ * The overall effect is exactly as if the second argument were + * converted to a string by the method {@link String#valueOf(Object)}, + * and the characters of that string were then + * {@link #insert(int,String) inserted} into this character + * sequence at the indicated offset. + *

+ * The {@code offset} argument must be greater than or equal to + * {@code 0}, and less than or equal to the {@linkplain #length() length} + * of this sequence. + * + * @param offset the offset. + * @param obj an {@code Object}. + * @return a reference to this object. + * @throws StringIndexOutOfBoundsException if the offset is invalid. + */ + public AbstractStringBuilder insert(int offset, Object obj) { + return insert(offset, String.valueOf(obj)); + } + + /** + * Inserts the string into this character sequence. + *

+ * The characters of the {@code String} argument are inserted, in + * order, into this sequence at the indicated offset, moving up any + * characters originally above that position and increasing the length + * of this sequence by the length of the argument. If + * {@code str} is {@code null}, then the four characters + * {@code "null"} are inserted into this sequence. + *

+ * The character at index k in the new character sequence is + * equal to: + *

    + *
  • the character at index k in the old character sequence, if + * k is less than {@code offset} + *
  • the character at index k{@code -offset} in the + * argument {@code str}, if k is not less than + * {@code offset} but is less than {@code offset+str.length()} + *
  • the character at index k{@code -str.length()} in the + * old character sequence, if k is not less than + * {@code offset+str.length()} + *

+ * The {@code offset} argument must be greater than or equal to + * {@code 0}, and less than or equal to the {@linkplain #length() length} + * of this sequence. + * + * @param offset the offset. + * @param str a string. + * @return a reference to this object. + * @throws StringIndexOutOfBoundsException if the offset is invalid. + */ + public AbstractStringBuilder insert(int offset, String str) { + if ((offset < 0) || (offset > length())) + throw new StringIndexOutOfBoundsException(offset); + if (str == null) + str = "null"; + int len = str.length(); + ensureCapacityInternal(count + len); + String.arraycopy(value, offset, value, offset + len, count - offset); + str.getChars(value, offset); + count += len; + return this; + } + + /** + * Inserts the string representation of the {@code char} array + * argument into this sequence. + *

+ * The characters of the array argument are inserted into the + * contents of this sequence at the position indicated by + * {@code offset}. The length of this sequence increases by + * the length of the argument. + *

+ * The overall effect is exactly as if the second argument were + * converted to a string by the method {@link String#valueOf(char[])}, + * and the characters of that string were then + * {@link #insert(int,String) inserted} into this character + * sequence at the indicated offset. + *

+ * The {@code offset} argument must be greater than or equal to + * {@code 0}, and less than or equal to the {@linkplain #length() length} + * of this sequence. + * + * @param offset the offset. + * @param str a character array. + * @return a reference to this object. + * @throws StringIndexOutOfBoundsException if the offset is invalid. + */ + public AbstractStringBuilder insert(int offset, char[] str) { + if ((offset < 0) || (offset > length())) + throw new StringIndexOutOfBoundsException(offset); + int len = str.length; + ensureCapacityInternal(count + len); + String.arraycopy(value, offset, value, offset + len, count - offset); + String.arraycopy(str, 0, value, offset, len); + count += len; + return this; + } + + /** + * Inserts the specified {@code CharSequence} into this sequence. + *

+ * The characters of the {@code CharSequence} argument are inserted, + * in order, into this sequence at the indicated offset, moving up + * any characters originally above that position and increasing the length + * of this sequence by the length of the argument s. + *

+ * The result of this method is exactly the same as if it were an + * invocation of this object's + * {@link #insert(int,CharSequence,int,int) insert}(dstOffset, s, 0, s.length()) + * method. + * + *

If {@code s} is {@code null}, then the four characters + * {@code "null"} are inserted into this sequence. + * + * @param dstOffset the offset. + * @param s the sequence to be inserted + * @return a reference to this object. + * @throws IndexOutOfBoundsException if the offset is invalid. + */ + public AbstractStringBuilder insert(int dstOffset, CharSequence s) { + if (s == null) + s = "null"; + if (s instanceof String) + return this.insert(dstOffset, (String)s); + return this.insert(dstOffset, s, 0, s.length()); + } + + /** + * Inserts a subsequence of the specified {@code CharSequence} into + * this sequence. + *

+ * The subsequence of the argument {@code s} specified by + * {@code start} and {@code end} are inserted, + * in order, into this sequence at the specified destination offset, moving + * up any characters originally above that position. The length of this + * sequence is increased by {@code end - start}. + *

+ * The character at index k in this sequence becomes equal to: + *

    + *
  • the character at index k in this sequence, if + * k is less than {@code dstOffset} + *
  • the character at index k{@code +start-dstOffset} in + * the argument {@code s}, if k is greater than or equal to + * {@code dstOffset} but is less than {@code dstOffset+end-start} + *
  • the character at index k{@code -(end-start)} in this + * sequence, if k is greater than or equal to + * {@code dstOffset+end-start} + *

+ * The {@code dstOffset} argument must be greater than or equal to + * {@code 0}, and less than or equal to the {@linkplain #length() length} + * of this sequence. + *

The start argument must be nonnegative, and not greater than + * {@code end}. + *

The end argument must be greater than or equal to + * {@code start}, and less than or equal to the length of s. + * + *

If {@code s} is {@code null}, then this method inserts + * characters as if the s parameter was a sequence containing the four + * characters {@code "null"}. + * + * @param dstOffset the offset in this sequence. + * @param s the sequence to be inserted. + * @param start the starting index of the subsequence to be inserted. + * @param end the end index of the subsequence to be inserted. + * @return a reference to this object. + * @throws IndexOutOfBoundsException if {@code dstOffset} + * is negative or greater than {@code this.length()}, or + * {@code start} or {@code end} are negative, or + * {@code start} is greater than {@code end} or + * {@code end} is greater than {@code s.length()} + */ + public AbstractStringBuilder insert(int dstOffset, CharSequence s, + int start, int end) { + if (s == null) + s = "null"; + if ((dstOffset < 0) || (dstOffset > this.length())) + throw new IndexOutOfBoundsException("dstOffset "+dstOffset); + if ((start < 0) || (end < 0) || (start > end) || (end > s.length())) + throw new IndexOutOfBoundsException( + "start " + start + ", end " + end + ", s.length() " + + s.length()); + int len = end - start; + ensureCapacityInternal(count + len); + String.arraycopy(value, dstOffset, value, dstOffset + len, + count - dstOffset); + for (int i=start; i + * The overall effect is exactly as if the second argument were + * converted to a string by the method {@link String#valueOf(boolean)}, + * and the characters of that string were then + * {@link #insert(int,String) inserted} into this character + * sequence at the indicated offset. + *

+ * The {@code offset} argument must be greater than or equal to + * {@code 0}, and less than or equal to the {@linkplain #length() length} + * of this sequence. + * + * @param offset the offset. + * @param b a {@code boolean}. + * @return a reference to this object. + * @throws StringIndexOutOfBoundsException if the offset is invalid. + */ + public AbstractStringBuilder insert(int offset, boolean b) { + return insert(offset, String.valueOf(b)); + } + + /** + * Inserts the string representation of the {@code char} + * argument into this sequence. + *

+ * The overall effect is exactly as if the second argument were + * converted to a string by the method {@link String#valueOf(char)}, + * and the character in that string were then + * {@link #insert(int,String) inserted} into this character + * sequence at the indicated offset. + *

+ * The {@code offset} argument must be greater than or equal to + * {@code 0}, and less than or equal to the {@linkplain #length() length} + * of this sequence. + * + * @param offset the offset. + * @param c a {@code char}. + * @return a reference to this object. + * @throws IndexOutOfBoundsException if the offset is invalid. + */ + public AbstractStringBuilder insert(int offset, char c) { + ensureCapacityInternal(count + 1); + String.arraycopy(value, offset, value, offset + 1, count - offset); + value[offset] = c; + count += 1; + return this; + } + + /** + * Inserts the string representation of the second {@code int} + * argument into this sequence. + *

+ * The overall effect is exactly as if the second argument were + * converted to a string by the method {@link String#valueOf(int)}, + * and the characters of that string were then + * {@link #insert(int,String) inserted} into this character + * sequence at the indicated offset. + *

+ * The {@code offset} argument must be greater than or equal to + * {@code 0}, and less than or equal to the {@linkplain #length() length} + * of this sequence. + * + * @param offset the offset. + * @param i an {@code int}. + * @return a reference to this object. + * @throws StringIndexOutOfBoundsException if the offset is invalid. + */ + public AbstractStringBuilder insert(int offset, int i) { + return insert(offset, String.valueOf(i)); + } + + /** + * Inserts the string representation of the {@code long} + * argument into this sequence. + *

+ * The overall effect is exactly as if the second argument were + * converted to a string by the method {@link String#valueOf(long)}, + * and the characters of that string were then + * {@link #insert(int,String) inserted} into this character + * sequence at the indicated offset. + *

+ * The {@code offset} argument must be greater than or equal to + * {@code 0}, and less than or equal to the {@linkplain #length() length} + * of this sequence. + * + * @param offset the offset. + * @param l a {@code long}. + * @return a reference to this object. + * @throws StringIndexOutOfBoundsException if the offset is invalid. + */ + public AbstractStringBuilder insert(int offset, long l) { + return insert(offset, String.valueOf(l)); + } + + /** + * Inserts the string representation of the {@code float} + * argument into this sequence. + *

+ * The overall effect is exactly as if the second argument were + * converted to a string by the method {@link String#valueOf(float)}, + * and the characters of that string were then + * {@link #insert(int,String) inserted} into this character + * sequence at the indicated offset. + *

+ * The {@code offset} argument must be greater than or equal to + * {@code 0}, and less than or equal to the {@linkplain #length() length} + * of this sequence. + * + * @param offset the offset. + * @param f a {@code float}. + * @return a reference to this object. + * @throws StringIndexOutOfBoundsException if the offset is invalid. + */ + public AbstractStringBuilder insert(int offset, float f) { + return insert(offset, String.valueOf(f)); + } + + /** + * Inserts the string representation of the {@code double} + * argument into this sequence. + *

+ * The overall effect is exactly as if the second argument were + * converted to a string by the method {@link String#valueOf(double)}, + * and the characters of that string were then + * {@link #insert(int,String) inserted} into this character + * sequence at the indicated offset. + *

+ * The {@code offset} argument must be greater than or equal to + * {@code 0}, and less than or equal to the {@linkplain #length() length} + * of this sequence. + * + * @param offset the offset. + * @param d a {@code double}. + * @return a reference to this object. + * @throws StringIndexOutOfBoundsException if the offset is invalid. + */ + public AbstractStringBuilder insert(int offset, double d) { + return insert(offset, String.valueOf(d)); + } + + /** + * Returns the index within this string of the first occurrence of the + * specified substring. The integer returned is the smallest value + * k such that: + *

+     * this.toString().startsWith(str, k)
+     * 
+ * is true. + * + * @param str any string. + * @return if the string argument occurs as a substring within this + * object, then the index of the first character of the first + * such substring is returned; if it does not occur as a + * substring, -1 is returned. + * @throws java.lang.NullPointerException if str is + * null. + */ + public int indexOf(String str) { + return indexOf(str, 0); + } + + /** + * Returns the index within this string of the first occurrence of the + * specified substring, starting at the specified index. The integer + * returned is the smallest value k for which: + *
+     *     k >= Math.min(fromIndex, str.length()) &&
+     *                   this.toString().startsWith(str, k)
+     * 
+ * If no such value of k exists, then -1 is returned. + * + * @param str the substring for which to search. + * @param fromIndex the index from which to start the search. + * @return the index within this string of the first occurrence of the + * specified substring, starting at the specified index. + * @throws java.lang.NullPointerException if str is + * null. + */ + public int indexOf(String str, int fromIndex) { + return String.indexOf(value, 0, count, + str.toCharArray(), 0, str.length(), fromIndex); + } + + /** + * Returns the index within this string of the rightmost occurrence + * of the specified substring. The rightmost empty string "" is + * considered to occur at the index value this.length(). + * The returned index is the largest value k such that + *
+     * this.toString().startsWith(str, k)
+     * 
+ * is true. + * + * @param str the substring to search for. + * @return if the string argument occurs one or more times as a substring + * within this object, then the index of the first character of + * the last such substring is returned. If it does not occur as + * a substring, -1 is returned. + * @throws java.lang.NullPointerException if str is + * null. + */ + public int lastIndexOf(String str) { + return lastIndexOf(str, count); + } + + /** + * Returns the index within this string of the last occurrence of the + * specified substring. The integer returned is the largest value k + * such that: + *
+     *     k <= Math.min(fromIndex, str.length()) &&
+     *                   this.toString().startsWith(str, k)
+     * 
+ * If no such value of k exists, then -1 is returned. + * + * @param str the substring to search for. + * @param fromIndex the index to start the search from. + * @return the index within this sequence of the last occurrence of the + * specified substring. + * @throws java.lang.NullPointerException if str is + * null. + */ + public int lastIndexOf(String str, int fromIndex) { + return String.lastIndexOf(value, 0, count, + str.toCharArray(), 0, str.length(), fromIndex); + } + + /** + * Causes this character sequence to be replaced by the reverse of + * the sequence. If there are any surrogate pairs included in the + * sequence, these are treated as single characters for the + * reverse operation. Thus, the order of the high-low surrogates + * is never reversed. + * + * Let n be the character length of this character sequence + * (not the length in char values) just prior to + * execution of the reverse method. Then the + * character at index k in the new character sequence is + * equal to the character at index n-k-1 in the old + * character sequence. + * + *

Note that the reverse operation may result in producing + * surrogate pairs that were unpaired low-surrogates and + * high-surrogates before the operation. For example, reversing + * "\uDC00\uD800" produces "\uD800\uDC00" which is + * a valid surrogate pair. + * + * @return a reference to this object. + */ + public AbstractStringBuilder reverse() { + boolean hasSurrogate = false; + int n = count - 1; + for (int j = (n-1) >> 1; j >= 0; --j) { + char temp = value[j]; + char temp2 = value[n - j]; + if (!hasSurrogate) { + hasSurrogate = (temp >= Character.MIN_SURROGATE && temp <= Character.MAX_SURROGATE) + || (temp2 >= Character.MIN_SURROGATE && temp2 <= Character.MAX_SURROGATE); + } + value[j] = temp2; + value[n - j] = temp; + } + if (hasSurrogate) { + // Reverse back all valid surrogate pairs + for (int i = 0; i < count - 1; i++) { + char c2 = value[i]; + if (Character.isLowSurrogate(c2)) { + char c1 = value[i + 1]; + if (Character.isHighSurrogate(c1)) { + value[i++] = c1; + value[i] = c2; + } + } + } + } + return this; + } + + /** + * Returns a string representing the data in this sequence. + * A new String object is allocated and initialized to + * contain the character sequence currently represented by this + * object. This String is then returned. Subsequent + * changes to this sequence do not affect the contents of the + * String. + * + * @return a string representation of this sequence of characters. + */ + public abstract String toString(); + + /** + * Needed by String for the contentEquals method. + */ + final char[] getValue() { + return value; + } + +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Appendable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Appendable.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +import java.io.IOException; + +/** + * An object to which char sequences and values can be appended. The + * Appendable interface must be implemented by any class whose + * instances are intended to receive formatted output from a {@link + * java.util.Formatter}. + * + *

The characters to be appended should be valid Unicode characters as + * described in Unicode Character + * Representation. Note that supplementary characters may be composed of + * multiple 16-bit char values. + * + *

Appendables are not necessarily safe for multithreaded access. Thread + * safety is the responsibility of classes that extend and implement this + * interface. + * + *

Since this interface may be implemented by existing classes + * with different styles of error handling there is no guarantee that + * errors will be propagated to the invoker. + * + * @since 1.5 + */ +public interface Appendable { + + /** + * Appends the specified character sequence to this Appendable. + * + *

Depending on which class implements the character sequence + * csq, the entire sequence may not be appended. For + * instance, if csq is a {@link java.nio.CharBuffer} then + * the subsequence to append is defined by the buffer's position and limit. + * + * @param csq + * The character sequence to append. If csq is + * null, then the four characters "null" are + * appended to this Appendable. + * + * @return A reference to this Appendable + * + * @throws IOException + * If an I/O error occurs + */ + Appendable append(CharSequence csq) throws IOException; + + /** + * Appends a subsequence of the specified character sequence to this + * Appendable. + * + *

An invocation of this method of the form out.append(csq, start, + * end) when csq is not null, behaves in + * exactly the same way as the invocation + * + *

+     *     out.append(csq.subSequence(start, end)) 
+ * + * @param csq + * The character sequence from which a subsequence will be + * appended. If csq is null, then characters + * will be appended as if csq contained the four + * characters "null". + * + * @param start + * The index of the first character in the subsequence + * + * @param end + * The index of the character following the last character in the + * subsequence + * + * @return A reference to this Appendable + * + * @throws IndexOutOfBoundsException + * If start or end are negative, start + * is greater than end, or end is greater than + * csq.length() + * + * @throws IOException + * If an I/O error occurs + */ + Appendable append(CharSequence csq, int start, int end) throws IOException; + + /** + * Appends the specified character to this Appendable. + * + * @param c + * The character to append + * + * @return A reference to this Appendable + * + * @throws IOException + * If an I/O error occurs + */ + Appendable append(char c) throws IOException; +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/ArrayIndexOutOfBoundsException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/ArrayIndexOutOfBoundsException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown to indicate that an array has been accessed with an + * illegal index. The index is either negative or greater than or + * equal to the size of the array. + * + * @author unascribed + * @since JDK1.0 + */ +public +class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException { + private static final long serialVersionUID = -5116101128118950844L; + + /** + * Constructs an ArrayIndexOutOfBoundsException with no + * detail message. + */ + public ArrayIndexOutOfBoundsException() { + super(); + } + + /** + * Constructs a new ArrayIndexOutOfBoundsException + * class with an argument indicating the illegal index. + * + * @param index the illegal index. + */ + public ArrayIndexOutOfBoundsException(int index) { + super("Array index out of range: " + index); + } + + /** + * Constructs an ArrayIndexOutOfBoundsException class + * with the specified detail message. + * + * @param s the detail message. + */ + public ArrayIndexOutOfBoundsException(String s) { + super(s); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/AssertionError.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/AssertionError.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown to indicate that an assertion has failed. + * + *

The seven one-argument public constructors provided by this + * class ensure that the assertion error returned by the invocation: + *

+ *     new AssertionError(expression)
+ * 
+ * has as its detail message the string conversion of + * expression (as defined in section 15.18.1.1 of + * The Java™ Language Specification), + * regardless of the type of expression. + * + * @since 1.4 + */ +public class AssertionError extends Error { + private static final long serialVersionUID = -5013299493970297370L; + + /** + * Constructs an AssertionError with no detail message. + */ + public AssertionError() { + } + + /** + * This internal constructor does no processing on its string argument, + * even if it is a null reference. The public constructors will + * never call this constructor with a null argument. + */ + private AssertionError(String detailMessage) { + super(detailMessage); + } + + /** + * Constructs an AssertionError with its detail message derived + * from the specified object, which is converted to a string as + * defined in section 15.18.1.1 of + * The Java™ Language Specification. + *

+ * If the specified object is an instance of {@code Throwable}, it + * becomes the cause of the newly constructed assertion error. + * + * @param detailMessage value to be used in constructing detail message + * @see Throwable#getCause() + */ + public AssertionError(Object detailMessage) { + this("" + detailMessage); + if (detailMessage instanceof Throwable) + initCause((Throwable) detailMessage); + } + + /** + * Constructs an AssertionError with its detail message derived + * from the specified boolean, which is converted to + * a string as defined in section 15.18.1.1 of + * The Java™ Language Specification. + * + * @param detailMessage value to be used in constructing detail message + */ + public AssertionError(boolean detailMessage) { + this("" + detailMessage); + } + + /** + * Constructs an AssertionError with its detail message derived + * from the specified char, which is converted to a + * string as defined in section 15.18.1.1 of + * The Java™ Language Specification. + * + * @param detailMessage value to be used in constructing detail message + */ + public AssertionError(char detailMessage) { + this("" + detailMessage); + } + + /** + * Constructs an AssertionError with its detail message derived + * from the specified int, which is converted to a + * string as defined in section 15.18.1.1 of + * The Java™ Language Specification. + * + * @param detailMessage value to be used in constructing detail message + */ + public AssertionError(int detailMessage) { + this("" + detailMessage); + } + + /** + * Constructs an AssertionError with its detail message derived + * from the specified long, which is converted to a + * string as defined in section 15.18.1.1 of + * The Java™ Language Specification. + * + * @param detailMessage value to be used in constructing detail message + */ + public AssertionError(long detailMessage) { + this("" + detailMessage); + } + + /** + * Constructs an AssertionError with its detail message derived + * from the specified float, which is converted to a + * string as defined in section 15.18.1.1 of + * The Java™ Language Specification. + * + * @param detailMessage value to be used in constructing detail message + */ + public AssertionError(float detailMessage) { + this("" + detailMessage); + } + + /** + * Constructs an AssertionError with its detail message derived + * from the specified double, which is converted to a + * string as defined in section 15.18.1.1 of + * The Java™ Language Specification. + * + * @param detailMessage value to be used in constructing detail message + */ + public AssertionError(double detailMessage) { + this("" + detailMessage); + } + + /** + * Constructs a new {@code AssertionError} with the specified + * detail message and cause. + * + *

Note that the detail message associated with + * {@code cause} is not automatically incorporated in + * this error's detail message. + * + * @param message the detail message, may be {@code null} + * @param cause the cause, may be {@code null} + * + * @since 1.7 + */ + public AssertionError(String message, Throwable cause) { + super(message, cause); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Boolean.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Boolean.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,282 @@ +/* + * Copyright (c) 1994, 2006, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * The Boolean class wraps a value of the primitive type + * {@code boolean} in an object. An object of type + * {@code Boolean} contains a single field whose type is + * {@code boolean}. + *

+ * In addition, this class provides many methods for + * converting a {@code boolean} to a {@code String} and a + * {@code String} to a {@code boolean}, as well as other + * constants and methods useful when dealing with a + * {@code boolean}. + * + * @author Arthur van Hoff + * @since JDK1.0 + */ +public final class Boolean implements java.io.Serializable, + Comparable +{ + /** + * The {@code Boolean} object corresponding to the primitive + * value {@code true}. + */ + public static final Boolean TRUE = new Boolean(true); + + /** + * The {@code Boolean} object corresponding to the primitive + * value {@code false}. + */ + public static final Boolean FALSE = new Boolean(false); + + /** + * The Class object representing the primitive type boolean. + * + * @since JDK1.1 + */ + public static final Class TYPE = Class.getPrimitiveClass("boolean"); + + /** + * The value of the Boolean. + * + * @serial + */ + private final boolean value; + + /** use serialVersionUID from JDK 1.0.2 for interoperability */ + private static final long serialVersionUID = -3665804199014368530L; + + /** + * Allocates a {@code Boolean} object representing the + * {@code value} argument. + * + *

Note: It is rarely appropriate to use this constructor. + * Unless a new instance is required, the static factory + * {@link #valueOf(boolean)} is generally a better choice. It is + * likely to yield significantly better space and time performance. + * + * @param value the value of the {@code Boolean}. + */ + public Boolean(boolean value) { + this.value = value; + } + + /** + * Allocates a {@code Boolean} object representing the value + * {@code true} if the string argument is not {@code null} + * and is equal, ignoring case, to the string {@code "true"}. + * Otherwise, allocate a {@code Boolean} object representing the + * value {@code false}. Examples:

+ * {@code new Boolean("True")} produces a {@code Boolean} object + * that represents {@code true}.
+ * {@code new Boolean("yes")} produces a {@code Boolean} object + * that represents {@code false}. + * + * @param s the string to be converted to a {@code Boolean}. + */ + public Boolean(String s) { + this(toBoolean(s)); + } + + /** + * Parses the string argument as a boolean. The {@code boolean} + * returned represents the value {@code true} if the string argument + * is not {@code null} and is equal, ignoring case, to the string + * {@code "true"}.

+ * Example: {@code Boolean.parseBoolean("True")} returns {@code true}.
+ * Example: {@code Boolean.parseBoolean("yes")} returns {@code false}. + * + * @param s the {@code String} containing the boolean + * representation to be parsed + * @return the boolean represented by the string argument + * @since 1.5 + */ + public static boolean parseBoolean(String s) { + return toBoolean(s); + } + + /** + * Returns the value of this {@code Boolean} object as a boolean + * primitive. + * + * @return the primitive {@code boolean} value of this object. + */ + public boolean booleanValue() { + return value; + } + + /** + * Returns a {@code Boolean} instance representing the specified + * {@code boolean} value. If the specified {@code boolean} value + * is {@code true}, this method returns {@code Boolean.TRUE}; + * if it is {@code false}, this method returns {@code Boolean.FALSE}. + * If a new {@code Boolean} instance is not required, this method + * should generally be used in preference to the constructor + * {@link #Boolean(boolean)}, as this method is likely to yield + * significantly better space and time performance. + * + * @param b a boolean value. + * @return a {@code Boolean} instance representing {@code b}. + * @since 1.4 + */ + public static Boolean valueOf(boolean b) { + return (b ? TRUE : FALSE); + } + + /** + * Returns a {@code Boolean} with a value represented by the + * specified string. The {@code Boolean} returned represents a + * true value if the string argument is not {@code null} + * and is equal, ignoring case, to the string {@code "true"}. + * + * @param s a string. + * @return the {@code Boolean} value represented by the string. + */ + public static Boolean valueOf(String s) { + return toBoolean(s) ? TRUE : FALSE; + } + + /** + * Returns a {@code String} object representing the specified + * boolean. If the specified boolean is {@code true}, then + * the string {@code "true"} will be returned, otherwise the + * string {@code "false"} will be returned. + * + * @param b the boolean to be converted + * @return the string representation of the specified {@code boolean} + * @since 1.4 + */ + public static String toString(boolean b) { + return b ? "true" : "false"; + } + + /** + * Returns a {@code String} object representing this Boolean's + * value. If this object represents the value {@code true}, + * a string equal to {@code "true"} is returned. Otherwise, a + * string equal to {@code "false"} is returned. + * + * @return a string representation of this object. + */ + public String toString() { + return value ? "true" : "false"; + } + + /** + * Returns a hash code for this {@code Boolean} object. + * + * @return the integer {@code 1231} if this object represents + * {@code true}; returns the integer {@code 1237} if this + * object represents {@code false}. + */ + public int hashCode() { + return value ? 1231 : 1237; + } + + /** + * Returns {@code true} if and only if the argument is not + * {@code null} and is a {@code Boolean} object that + * represents the same {@code boolean} value as this object. + * + * @param obj the object to compare with. + * @return {@code true} if the Boolean objects represent the + * same value; {@code false} otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof Boolean) { + return value == ((Boolean)obj).booleanValue(); + } + return false; + } + + /** + * Returns {@code true} if and only if the system property + * named by the argument exists and is equal to the string + * {@code "true"}. (Beginning with version 1.0.2 of the + * JavaTM platform, the test of + * this string is case insensitive.) A system property is accessible + * through {@code getProperty}, a method defined by the + * {@code System} class. + *

+ * If there is no property with the specified name, or if the specified + * name is empty or null, then {@code false} is returned. + * + * @param name the system property name. + * @return the {@code boolean} value of the system property. + * @see java.lang.System#getProperty(java.lang.String) + * @see java.lang.System#getProperty(java.lang.String, java.lang.String) + */ + public static boolean getBoolean(String name) { + boolean result = false; + try { + result = toBoolean(String.getProperty(name)); + } catch (IllegalArgumentException e) { + } catch (NullPointerException e) { + } + return result; + } + + /** + * Compares this {@code Boolean} instance with another. + * + * @param b the {@code Boolean} instance to be compared + * @return zero if this object represents the same boolean value as the + * argument; a positive value if this object represents true + * and the argument represents false; and a negative value if + * this object represents false and the argument represents true + * @throws NullPointerException if the argument is {@code null} + * @see Comparable + * @since 1.5 + */ + public int compareTo(Boolean b) { + return compare(this.value, b.value); + } + + /** + * Compares two {@code boolean} values. + * The value returned is identical to what would be returned by: + *

+     *    Boolean.valueOf(x).compareTo(Boolean.valueOf(y))
+     * 
+ * + * @param x the first {@code boolean} to compare + * @param y the second {@code boolean} to compare + * @return the value {@code 0} if {@code x == y}; + * a value less than {@code 0} if {@code !x && y}; and + * a value greater than {@code 0} if {@code x && !y} + * @since 1.7 + */ + public static int compare(boolean x, boolean y) { + return (x == y) ? 0 : (x ? 1 : -1); + } + + private static boolean toBoolean(String name) { + return ((name != null) && name.equalsIgnoreCase("true")); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Byte.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Byte.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,452 @@ +/* + * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * + * The {@code Byte} class wraps a value of primitive type {@code byte} + * in an object. An object of type {@code Byte} contains a single + * field whose type is {@code byte}. + * + *

In addition, this class provides several methods for converting + * a {@code byte} to a {@code String} and a {@code String} to a {@code + * byte}, as well as other constants and methods useful when dealing + * with a {@code byte}. + * + * @author Nakul Saraiya + * @author Joseph D. Darcy + * @see java.lang.Number + * @since JDK1.1 + */ +public final class Byte extends Number implements Comparable { + + /** + * A constant holding the minimum value a {@code byte} can + * have, -27. + */ + public static final byte MIN_VALUE = -128; + + /** + * A constant holding the maximum value a {@code byte} can + * have, 27-1. + */ + public static final byte MAX_VALUE = 127; + + /** + * The {@code Class} instance representing the primitive type + * {@code byte}. + */ + public static final Class TYPE = (Class) Class.getPrimitiveClass("byte"); + + /** + * Returns a new {@code String} object representing the + * specified {@code byte}. The radix is assumed to be 10. + * + * @param b the {@code byte} to be converted + * @return the string representation of the specified {@code byte} + * @see java.lang.Integer#toString(int) + */ + public static String toString(byte b) { + return Integer.toString((int)b, 10); + } + + private static class ByteCache { + private ByteCache(){} + + static final Byte cache[] = new Byte[-(-128) + 127 + 1]; + + static { + for(int i = 0; i < cache.length; i++) + cache[i] = new Byte((byte)(i - 128)); + } + } + + /** + * Returns a {@code Byte} instance representing the specified + * {@code byte} value. + * If a new {@code Byte} instance is not required, this method + * should generally be used in preference to the constructor + * {@link #Byte(byte)}, as this method is likely to yield + * significantly better space and time performance since + * all byte values are cached. + * + * @param b a byte value. + * @return a {@code Byte} instance representing {@code b}. + * @since 1.5 + */ + public static Byte valueOf(byte b) { + final int offset = 128; + return ByteCache.cache[(int)b + offset]; + } + + /** + * Parses the string argument as a signed {@code byte} in the + * radix specified by the second argument. The characters in the + * string must all be digits, of the specified radix (as + * determined by whether {@link java.lang.Character#digit(char, + * int)} returns a nonnegative value) except that the first + * character may be an ASCII minus sign {@code '-'} + * ('\u002D') to indicate a negative value or an + * ASCII plus sign {@code '+'} ('\u002B') to + * indicate a positive value. The resulting {@code byte} value is + * returned. + * + *

An exception of type {@code NumberFormatException} is + * thrown if any of the following situations occurs: + *

    + *
  • The first argument is {@code null} or is a string of + * length zero. + * + *
  • The radix is either smaller than {@link + * java.lang.Character#MIN_RADIX} or larger than {@link + * java.lang.Character#MAX_RADIX}. + * + *
  • Any character of the string is not a digit of the + * specified radix, except that the first character may be a minus + * sign {@code '-'} ('\u002D') or plus sign + * {@code '+'} ('\u002B') provided that the + * string is longer than length 1. + * + *
  • The value represented by the string is not a value of type + * {@code byte}. + *
+ * + * @param s the {@code String} containing the + * {@code byte} + * representation to be parsed + * @param radix the radix to be used while parsing {@code s} + * @return the {@code byte} value represented by the string + * argument in the specified radix + * @throws NumberFormatException If the string does + * not contain a parsable {@code byte}. + */ + public static byte parseByte(String s, int radix) + throws NumberFormatException { + int i = Integer.parseInt(s, radix); + if (i < MIN_VALUE || i > MAX_VALUE) + throw new NumberFormatException( + "Value out of range. Value:\"" + s + "\" Radix:" + radix); + return (byte)i; + } + + /** + * Parses the string argument as a signed decimal {@code + * byte}. The characters in the string must all be decimal digits, + * except that the first character may be an ASCII minus sign + * {@code '-'} ('\u002D') to indicate a negative + * value or an ASCII plus sign {@code '+'} + * ('\u002B') to indicate a positive value. The + * resulting {@code byte} value is returned, exactly as if the + * argument and the radix 10 were given as arguments to the {@link + * #parseByte(java.lang.String, int)} method. + * + * @param s a {@code String} containing the + * {@code byte} representation to be parsed + * @return the {@code byte} value represented by the + * argument in decimal + * @throws NumberFormatException if the string does not + * contain a parsable {@code byte}. + */ + public static byte parseByte(String s) throws NumberFormatException { + return parseByte(s, 10); + } + + /** + * Returns a {@code Byte} object holding the value + * extracted from the specified {@code String} when parsed + * with the radix given by the second argument. The first argument + * is interpreted as representing a signed {@code byte} in + * the radix specified by the second argument, exactly as if the + * argument were given to the {@link #parseByte(java.lang.String, + * int)} method. The result is a {@code Byte} object that + * represents the {@code byte} value specified by the string. + * + *

In other words, this method returns a {@code Byte} object + * equal to the value of: + * + *

+ * {@code new Byte(Byte.parseByte(s, radix))} + *
+ * + * @param s the string to be parsed + * @param radix the radix to be used in interpreting {@code s} + * @return a {@code Byte} object holding the value + * represented by the string argument in the + * specified radix. + * @throws NumberFormatException If the {@code String} does + * not contain a parsable {@code byte}. + */ + public static Byte valueOf(String s, int radix) + throws NumberFormatException { + return valueOf(parseByte(s, radix)); + } + + /** + * Returns a {@code Byte} object holding the value + * given by the specified {@code String}. The argument is + * interpreted as representing a signed decimal {@code byte}, + * exactly as if the argument were given to the {@link + * #parseByte(java.lang.String)} method. The result is a + * {@code Byte} object that represents the {@code byte} + * value specified by the string. + * + *

In other words, this method returns a {@code Byte} object + * equal to the value of: + * + *

+ * {@code new Byte(Byte.parseByte(s))} + *
+ * + * @param s the string to be parsed + * @return a {@code Byte} object holding the value + * represented by the string argument + * @throws NumberFormatException If the {@code String} does + * not contain a parsable {@code byte}. + */ + public static Byte valueOf(String s) throws NumberFormatException { + return valueOf(s, 10); + } + + /** + * Decodes a {@code String} into a {@code Byte}. + * Accepts decimal, hexadecimal, and octal numbers given by + * the following grammar: + * + *
+ *
+ *
DecodableString: + *
Signopt DecimalNumeral + *
Signopt {@code 0x} HexDigits + *
Signopt {@code 0X} HexDigits + *
Signopt {@code #} HexDigits + *
Signopt {@code 0} OctalDigits + *

+ *

Sign: + *
{@code -} + *
{@code +} + *
+ *
+ * + * DecimalNumeral, HexDigits, and OctalDigits + * are as defined in section 3.10.1 of + * The Java™ Language Specification, + * except that underscores are not accepted between digits. + * + *

The sequence of characters following an optional + * sign and/or radix specifier ("{@code 0x}", "{@code 0X}", + * "{@code #}", or leading zero) is parsed as by the {@code + * Byte.parseByte} method with the indicated radix (10, 16, or 8). + * This sequence of characters must represent a positive value or + * a {@link NumberFormatException} will be thrown. The result is + * negated if first character of the specified {@code String} is + * the minus sign. No whitespace characters are permitted in the + * {@code String}. + * + * @param nm the {@code String} to decode. + * @return a {@code Byte} object holding the {@code byte} + * value represented by {@code nm} + * @throws NumberFormatException if the {@code String} does not + * contain a parsable {@code byte}. + * @see java.lang.Byte#parseByte(java.lang.String, int) + */ + public static Byte decode(String nm) throws NumberFormatException { + int i = Integer.decode(nm); + if (i < MIN_VALUE || i > MAX_VALUE) + throw new NumberFormatException( + "Value " + i + " out of range from input " + nm); + return valueOf((byte)i); + } + + /** + * The value of the {@code Byte}. + * + * @serial + */ + private final byte value; + + /** + * Constructs a newly allocated {@code Byte} object that + * represents the specified {@code byte} value. + * + * @param value the value to be represented by the + * {@code Byte}. + */ + public Byte(byte value) { + this.value = value; + } + + /** + * Constructs a newly allocated {@code Byte} object that + * represents the {@code byte} value indicated by the + * {@code String} parameter. The string is converted to a + * {@code byte} value in exactly the manner used by the + * {@code parseByte} method for radix 10. + * + * @param s the {@code String} to be converted to a + * {@code Byte} + * @throws NumberFormatException If the {@code String} + * does not contain a parsable {@code byte}. + * @see java.lang.Byte#parseByte(java.lang.String, int) + */ + public Byte(String s) throws NumberFormatException { + this.value = parseByte(s, 10); + } + + /** + * Returns the value of this {@code Byte} as a + * {@code byte}. + */ + public byte byteValue() { + return value; + } + + /** + * Returns the value of this {@code Byte} as a + * {@code short}. + */ + public short shortValue() { + return (short)value; + } + + /** + * Returns the value of this {@code Byte} as an + * {@code int}. + */ + public int intValue() { + return (int)value; + } + + /** + * Returns the value of this {@code Byte} as a + * {@code long}. + */ + public long longValue() { + return (long)value; + } + + /** + * Returns the value of this {@code Byte} as a + * {@code float}. + */ + public float floatValue() { + return (float)value; + } + + /** + * Returns the value of this {@code Byte} as a + * {@code double}. + */ + public double doubleValue() { + return (double)value; + } + + /** + * Returns a {@code String} object representing this + * {@code Byte}'s value. The value is converted to signed + * decimal representation and returned as a string, exactly as if + * the {@code byte} value were given as an argument to the + * {@link java.lang.Byte#toString(byte)} method. + * + * @return a string representation of the value of this object in + * base 10. + */ + public String toString() { + return Integer.toString((int)value); + } + + /** + * Returns a hash code for this {@code Byte}; equal to the result + * of invoking {@code intValue()}. + * + * @return a hash code value for this {@code Byte} + */ + public int hashCode() { + return (int)value; + } + + /** + * Compares this object to the specified object. The result is + * {@code true} if and only if the argument is not + * {@code null} and is a {@code Byte} object that + * contains the same {@code byte} value as this object. + * + * @param obj the object to compare with + * @return {@code true} if the objects are the same; + * {@code false} otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof Byte) { + return value == ((Byte)obj).byteValue(); + } + return false; + } + + /** + * Compares two {@code Byte} objects numerically. + * + * @param anotherByte the {@code Byte} to be compared. + * @return the value {@code 0} if this {@code Byte} is + * equal to the argument {@code Byte}; a value less than + * {@code 0} if this {@code Byte} is numerically less + * than the argument {@code Byte}; and a value greater than + * {@code 0} if this {@code Byte} is numerically + * greater than the argument {@code Byte} (signed + * comparison). + * @since 1.2 + */ + public int compareTo(Byte anotherByte) { + return compare(this.value, anotherByte.value); + } + + /** + * Compares two {@code byte} values numerically. + * The value returned is identical to what would be returned by: + *

+     *    Byte.valueOf(x).compareTo(Byte.valueOf(y))
+     * 
+ * + * @param x the first {@code byte} to compare + * @param y the second {@code byte} to compare + * @return the value {@code 0} if {@code x == y}; + * a value less than {@code 0} if {@code x < y}; and + * a value greater than {@code 0} if {@code x > y} + * @since 1.7 + */ + public static int compare(byte x, byte y) { + return x - y; + } + + /** + * The number of bits used to represent a {@code byte} value in two's + * complement binary form. + * + * @since 1.5 + */ + public static final int SIZE = 8; + + /** use serialVersionUID from JDK 1.1. for interoperability */ + private static final long serialVersionUID = -7183698231559129828L; +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/CharSequence.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/CharSequence.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + + +/** + * A CharSequence is a readable sequence of char values. This + * interface provides uniform, read-only access to many different kinds of + * char sequences. + * A char value represents a character in the Basic + * Multilingual Plane (BMP) or a surrogate. Refer to Unicode Character Representation for details. + * + *

This interface does not refine the general contracts of the {@link + * java.lang.Object#equals(java.lang.Object) equals} and {@link + * java.lang.Object#hashCode() hashCode} methods. The result of comparing two + * objects that implement CharSequence is therefore, in general, + * undefined. Each object may be implemented by a different class, and there + * is no guarantee that each class will be capable of testing its instances + * for equality with those of the other. It is therefore inappropriate to use + * arbitrary CharSequence instances as elements in a set or as keys in + * a map.

+ * + * @author Mike McCloskey + * @since 1.4 + * @spec JSR-51 + */ + +public interface CharSequence { + + /** + * Returns the length of this character sequence. The length is the number + * of 16-bit chars in the sequence.

+ * + * @return the number of chars in this sequence + */ + int length(); + + /** + * Returns the char value at the specified index. An index ranges from zero + * to length() - 1. The first char value of the sequence is at + * index zero, the next at index one, and so on, as for array + * indexing.

+ * + *

If the char value specified by the index is a + * surrogate, the surrogate + * value is returned. + * + * @param index the index of the char value to be returned + * + * @return the specified char value + * + * @throws IndexOutOfBoundsException + * if the index argument is negative or not less than + * length() + */ + char charAt(int index); + + /** + * Returns a new CharSequence that is a subsequence of this sequence. + * The subsequence starts with the char value at the specified index and + * ends with the char value at index end - 1. The length + * (in chars) of the + * returned sequence is end - start, so if start == end + * then an empty sequence is returned.

+ * + * @param start the start index, inclusive + * @param end the end index, exclusive + * + * @return the specified subsequence + * + * @throws IndexOutOfBoundsException + * if start or end are negative, + * if end is greater than length(), + * or if start is greater than end + */ + CharSequence subSequence(int start, int end); + + /** + * Returns a string containing the characters in this sequence in the same + * order as this sequence. The length of the string will be the length of + * this sequence.

+ * + * @return a string consisting of exactly this sequence of characters + */ + public String toString(); + +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Character.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Character.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,2388 @@ +/* + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * The {@code Character} class wraps a value of the primitive + * type {@code char} in an object. An object of type + * {@code Character} contains a single field whose type is + * {@code char}. + *

+ * In addition, this class provides several methods for determining + * a character's category (lowercase letter, digit, etc.) and for converting + * characters from uppercase to lowercase and vice versa. + *

+ * Character information is based on the Unicode Standard, version 6.0.0. + *

+ * The methods and data of class {@code Character} are defined by + * the information in the UnicodeData file that is part of the + * Unicode Character Database maintained by the Unicode + * Consortium. This file specifies various properties including name + * and general category for every defined Unicode code point or + * character range. + *

+ * The file and its description are available from the Unicode Consortium at: + *

+ * + *

Unicode Character Representations

+ * + *

The {@code char} data type (and therefore the value that a + * {@code Character} object encapsulates) are based on the + * original Unicode specification, which defined characters as + * fixed-width 16-bit entities. The Unicode Standard has since been + * changed to allow for characters whose representation requires more + * than 16 bits. The range of legal code points is now + * U+0000 to U+10FFFF, known as Unicode scalar value. + * (Refer to the + * definition of the U+n notation in the Unicode + * Standard.) + * + *

The set of characters from U+0000 to U+FFFF is + * sometimes referred to as the Basic Multilingual Plane (BMP). + * Characters whose code points are greater + * than U+FFFF are called supplementary characters. The Java + * platform uses the UTF-16 representation in {@code char} arrays and + * in the {@code String} and {@code StringBuffer} classes. In + * this representation, supplementary characters are represented as a pair + * of {@code char} values, the first from the high-surrogates + * range, (\uD800-\uDBFF), the second from the + * low-surrogates range (\uDC00-\uDFFF). + * + *

A {@code char} value, therefore, represents Basic + * Multilingual Plane (BMP) code points, including the surrogate + * code points, or code units of the UTF-16 encoding. An + * {@code int} value represents all Unicode code points, + * including supplementary code points. The lower (least significant) + * 21 bits of {@code int} are used to represent Unicode code + * points and the upper (most significant) 11 bits must be zero. + * Unless otherwise specified, the behavior with respect to + * supplementary characters and surrogate {@code char} values is + * as follows: + * + *

    + *
  • The methods that only accept a {@code char} value cannot support + * supplementary characters. They treat {@code char} values from the + * surrogate ranges as undefined characters. For example, + * {@code Character.isLetter('\u005CuD840')} returns {@code false}, even though + * this specific value if followed by any low-surrogate value in a string + * would represent a letter. + * + *
  • The methods that accept an {@code int} value support all + * Unicode characters, including supplementary characters. For + * example, {@code Character.isLetter(0x2F81A)} returns + * {@code true} because the code point value represents a letter + * (a CJK ideograph). + *
+ * + *

In the Java SE API documentation, Unicode code point is + * used for character values in the range between U+0000 and U+10FFFF, + * and Unicode code unit is used for 16-bit + * {@code char} values that are code units of the UTF-16 + * encoding. For more information on Unicode terminology, refer to the + * Unicode Glossary. + * + * @author Lee Boynton + * @author Guy Steele + * @author Akira Tanaka + * @author Martin Buchholz + * @author Ulf Zibis + * @since 1.0 + */ +public final +class Character implements java.io.Serializable, Comparable { + /** + * The minimum radix available for conversion to and from strings. + * The constant value of this field is the smallest value permitted + * for the radix argument in radix-conversion methods such as the + * {@code digit} method, the {@code forDigit} method, and the + * {@code toString} method of class {@code Integer}. + * + * @see Character#digit(char, int) + * @see Character#forDigit(int, int) + * @see Integer#toString(int, int) + * @see Integer#valueOf(String) + */ + public static final int MIN_RADIX = 2; + + /** + * The maximum radix available for conversion to and from strings. + * The constant value of this field is the largest value permitted + * for the radix argument in radix-conversion methods such as the + * {@code digit} method, the {@code forDigit} method, and the + * {@code toString} method of class {@code Integer}. + * + * @see Character#digit(char, int) + * @see Character#forDigit(int, int) + * @see Integer#toString(int, int) + * @see Integer#valueOf(String) + */ + public static final int MAX_RADIX = 36; + + /** + * The constant value of this field is the smallest value of type + * {@code char}, {@code '\u005Cu0000'}. + * + * @since 1.0.2 + */ + public static final char MIN_VALUE = '\u0000'; + + /** + * The constant value of this field is the largest value of type + * {@code char}, {@code '\u005CuFFFF'}. + * + * @since 1.0.2 + */ + public static final char MAX_VALUE = '\uFFFF'; + + /** + * The {@code Class} instance representing the primitive type + * {@code char}. + * + * @since 1.1 + */ + public static final Class TYPE = Class.getPrimitiveClass("char"); + + /* + * Normative general types + */ + + /* + * General character types + */ + + /** + * General category "Cn" in the Unicode specification. + * @since 1.1 + */ + public static final byte UNASSIGNED = 0; + + /** + * General category "Lu" in the Unicode specification. + * @since 1.1 + */ + public static final byte UPPERCASE_LETTER = 1; + + /** + * General category "Ll" in the Unicode specification. + * @since 1.1 + */ + public static final byte LOWERCASE_LETTER = 2; + + /** + * General category "Lt" in the Unicode specification. + * @since 1.1 + */ + public static final byte TITLECASE_LETTER = 3; + + /** + * General category "Lm" in the Unicode specification. + * @since 1.1 + */ + public static final byte MODIFIER_LETTER = 4; + + /** + * General category "Lo" in the Unicode specification. + * @since 1.1 + */ + public static final byte OTHER_LETTER = 5; + + /** + * General category "Mn" in the Unicode specification. + * @since 1.1 + */ + public static final byte NON_SPACING_MARK = 6; + + /** + * General category "Me" in the Unicode specification. + * @since 1.1 + */ + public static final byte ENCLOSING_MARK = 7; + + /** + * General category "Mc" in the Unicode specification. + * @since 1.1 + */ + public static final byte COMBINING_SPACING_MARK = 8; + + /** + * General category "Nd" in the Unicode specification. + * @since 1.1 + */ + public static final byte DECIMAL_DIGIT_NUMBER = 9; + + /** + * General category "Nl" in the Unicode specification. + * @since 1.1 + */ + public static final byte LETTER_NUMBER = 10; + + /** + * General category "No" in the Unicode specification. + * @since 1.1 + */ + public static final byte OTHER_NUMBER = 11; + + /** + * General category "Zs" in the Unicode specification. + * @since 1.1 + */ + public static final byte SPACE_SEPARATOR = 12; + + /** + * General category "Zl" in the Unicode specification. + * @since 1.1 + */ + public static final byte LINE_SEPARATOR = 13; + + /** + * General category "Zp" in the Unicode specification. + * @since 1.1 + */ + public static final byte PARAGRAPH_SEPARATOR = 14; + + /** + * General category "Cc" in the Unicode specification. + * @since 1.1 + */ + public static final byte CONTROL = 15; + + /** + * General category "Cf" in the Unicode specification. + * @since 1.1 + */ + public static final byte FORMAT = 16; + + /** + * General category "Co" in the Unicode specification. + * @since 1.1 + */ + public static final byte PRIVATE_USE = 18; + + /** + * General category "Cs" in the Unicode specification. + * @since 1.1 + */ + public static final byte SURROGATE = 19; + + /** + * General category "Pd" in the Unicode specification. + * @since 1.1 + */ + public static final byte DASH_PUNCTUATION = 20; + + /** + * General category "Ps" in the Unicode specification. + * @since 1.1 + */ + public static final byte START_PUNCTUATION = 21; + + /** + * General category "Pe" in the Unicode specification. + * @since 1.1 + */ + public static final byte END_PUNCTUATION = 22; + + /** + * General category "Pc" in the Unicode specification. + * @since 1.1 + */ + public static final byte CONNECTOR_PUNCTUATION = 23; + + /** + * General category "Po" in the Unicode specification. + * @since 1.1 + */ + public static final byte OTHER_PUNCTUATION = 24; + + /** + * General category "Sm" in the Unicode specification. + * @since 1.1 + */ + public static final byte MATH_SYMBOL = 25; + + /** + * General category "Sc" in the Unicode specification. + * @since 1.1 + */ + public static final byte CURRENCY_SYMBOL = 26; + + /** + * General category "Sk" in the Unicode specification. + * @since 1.1 + */ + public static final byte MODIFIER_SYMBOL = 27; + + /** + * General category "So" in the Unicode specification. + * @since 1.1 + */ + public static final byte OTHER_SYMBOL = 28; + + /** + * General category "Pi" in the Unicode specification. + * @since 1.4 + */ + public static final byte INITIAL_QUOTE_PUNCTUATION = 29; + + /** + * General category "Pf" in the Unicode specification. + * @since 1.4 + */ + public static final byte FINAL_QUOTE_PUNCTUATION = 30; + + /** + * Error flag. Use int (code point) to avoid confusion with U+FFFF. + */ + static final int ERROR = 0xFFFFFFFF; + + + /** + * Undefined bidirectional character type. Undefined {@code char} + * values have undefined directionality in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_UNDEFINED = -1; + + /** + * Strong bidirectional character type "L" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = 0; + + /** + * Strong bidirectional character type "R" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = 1; + + /** + * Strong bidirectional character type "AL" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = 2; + + /** + * Weak bidirectional character type "EN" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = 3; + + /** + * Weak bidirectional character type "ES" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = 4; + + /** + * Weak bidirectional character type "ET" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = 5; + + /** + * Weak bidirectional character type "AN" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_ARABIC_NUMBER = 6; + + /** + * Weak bidirectional character type "CS" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = 7; + + /** + * Weak bidirectional character type "NSM" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_NONSPACING_MARK = 8; + + /** + * Weak bidirectional character type "BN" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL = 9; + + /** + * Neutral bidirectional character type "B" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR = 10; + + /** + * Neutral bidirectional character type "S" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR = 11; + + /** + * Neutral bidirectional character type "WS" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_WHITESPACE = 12; + + /** + * Neutral bidirectional character type "ON" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_OTHER_NEUTRALS = 13; + + /** + * Strong bidirectional character type "LRE" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = 14; + + /** + * Strong bidirectional character type "LRO" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = 15; + + /** + * Strong bidirectional character type "RLE" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = 16; + + /** + * Strong bidirectional character type "RLO" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = 17; + + /** + * Weak bidirectional character type "PDF" in the Unicode specification. + * @since 1.4 + */ + public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = 18; + + /** + * The minimum value of a + * + * Unicode high-surrogate code unit + * in the UTF-16 encoding, constant {@code '\u005CuD800'}. + * A high-surrogate is also known as a leading-surrogate. + * + * @since 1.5 + */ + public static final char MIN_HIGH_SURROGATE = '\uD800'; + + /** + * The maximum value of a + * + * Unicode high-surrogate code unit + * in the UTF-16 encoding, constant {@code '\u005CuDBFF'}. + * A high-surrogate is also known as a leading-surrogate. + * + * @since 1.5 + */ + public static final char MAX_HIGH_SURROGATE = '\uDBFF'; + + /** + * The minimum value of a + * + * Unicode low-surrogate code unit + * in the UTF-16 encoding, constant {@code '\u005CuDC00'}. + * A low-surrogate is also known as a trailing-surrogate. + * + * @since 1.5 + */ + public static final char MIN_LOW_SURROGATE = '\uDC00'; + + /** + * The maximum value of a + * + * Unicode low-surrogate code unit + * in the UTF-16 encoding, constant {@code '\u005CuDFFF'}. + * A low-surrogate is also known as a trailing-surrogate. + * + * @since 1.5 + */ + public static final char MAX_LOW_SURROGATE = '\uDFFF'; + + /** + * The minimum value of a Unicode surrogate code unit in the + * UTF-16 encoding, constant {@code '\u005CuD800'}. + * + * @since 1.5 + */ + public static final char MIN_SURROGATE = MIN_HIGH_SURROGATE; + + /** + * The maximum value of a Unicode surrogate code unit in the + * UTF-16 encoding, constant {@code '\u005CuDFFF'}. + * + * @since 1.5 + */ + public static final char MAX_SURROGATE = MAX_LOW_SURROGATE; + + /** + * The minimum value of a + * + * Unicode supplementary code point, constant {@code U+10000}. + * + * @since 1.5 + */ + public static final int MIN_SUPPLEMENTARY_CODE_POINT = 0x010000; + + /** + * The minimum value of a + * + * Unicode code point, constant {@code U+0000}. + * + * @since 1.5 + */ + public static final int MIN_CODE_POINT = 0x000000; + + /** + * The maximum value of a + * + * Unicode code point, constant {@code U+10FFFF}. + * + * @since 1.5 + */ + public static final int MAX_CODE_POINT = 0X10FFFF; + + + /** + * Instances of this class represent particular subsets of the Unicode + * character set. The only family of subsets defined in the + * {@code Character} class is {@link Character.UnicodeBlock}. + * Other portions of the Java API may define other subsets for their + * own purposes. + * + * @since 1.2 + */ + public static class Subset { + + private String name; + + /** + * Constructs a new {@code Subset} instance. + * + * @param name The name of this subset + * @exception NullPointerException if name is {@code null} + */ + protected Subset(String name) { + if (name == null) { + throw new NullPointerException("name"); + } + this.name = name; + } + + /** + * Compares two {@code Subset} objects for equality. + * This method returns {@code true} if and only if + * {@code this} and the argument refer to the same + * object; since this method is {@code final}, this + * guarantee holds for all subclasses. + */ + public final boolean equals(Object obj) { + return (this == obj); + } + + /** + * Returns the standard hash code as defined by the + * {@link Object#hashCode} method. This method + * is {@code final} in order to ensure that the + * {@code equals} and {@code hashCode} methods will + * be consistent in all subclasses. + */ + public final int hashCode() { + return super.hashCode(); + } + + /** + * Returns the name of this subset. + */ + public final String toString() { + return name; + } + } + + // See http://www.unicode.org/Public/UNIDATA/Blocks.txt + // for the latest specification of Unicode Blocks. + + + /** + * The value of the {@code Character}. + * + * @serial + */ + private final char value; + + /** use serialVersionUID from JDK 1.0.2 for interoperability */ + private static final long serialVersionUID = 3786198910865385080L; + + /** + * Constructs a newly allocated {@code Character} object that + * represents the specified {@code char} value. + * + * @param value the value to be represented by the + * {@code Character} object. + */ + public Character(char value) { + this.value = value; + } + + private static class CharacterCache { + private CharacterCache(){} + + static final Character cache[] = new Character[127 + 1]; + + static { + for (int i = 0; i < cache.length; i++) + cache[i] = new Character((char)i); + } + } + + /** + * Returns a Character instance representing the specified + * char value. + * If a new Character instance is not required, this method + * should generally be used in preference to the constructor + * {@link #Character(char)}, as this method is likely to yield + * significantly better space and time performance by caching + * frequently requested values. + * + * This method will always cache values in the range {@code + * '\u005Cu0000'} to {@code '\u005Cu007F'}, inclusive, and may + * cache other values outside of this range. + * + * @param c a char value. + * @return a Character instance representing c. + * @since 1.5 + */ + public static Character valueOf(char c) { + if (c <= 127) { // must cache + return CharacterCache.cache[(int)c]; + } + return new Character(c); + } + + /** + * Returns the value of this {@code Character} object. + * @return the primitive {@code char} value represented by + * this object. + */ + public char charValue() { + return value; + } + + /** + * Returns a hash code for this {@code Character}; equal to the result + * of invoking {@code charValue()}. + * + * @return a hash code value for this {@code Character} + */ + public int hashCode() { + return (int)value; + } + + /** + * Compares this object against the specified object. + * The result is {@code true} if and only if the argument is not + * {@code null} and is a {@code Character} object that + * represents the same {@code char} value as this object. + * + * @param obj the object to compare with. + * @return {@code true} if the objects are the same; + * {@code false} otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof Character) { + return value == ((Character)obj).charValue(); + } + return false; + } + + /** + * Returns a {@code String} object representing this + * {@code Character}'s value. The result is a string of + * length 1 whose sole component is the primitive + * {@code char} value represented by this + * {@code Character} object. + * + * @return a string representation of this object. + */ + public String toString() { + char buf[] = {value}; + return String.valueOf(buf); + } + + /** + * Returns a {@code String} object representing the + * specified {@code char}. The result is a string of length + * 1 consisting solely of the specified {@code char}. + * + * @param c the {@code char} to be converted + * @return the string representation of the specified {@code char} + * @since 1.4 + */ + public static String toString(char c) { + return String.valueOf(c); + } + + /** + * Determines whether the specified code point is a valid + * + * Unicode code point value. + * + * @param codePoint the Unicode code point to be tested + * @return {@code true} if the specified code point value is between + * {@link #MIN_CODE_POINT} and + * {@link #MAX_CODE_POINT} inclusive; + * {@code false} otherwise. + * @since 1.5 + */ + public static boolean isValidCodePoint(int codePoint) { + // Optimized form of: + // codePoint >= MIN_CODE_POINT && codePoint <= MAX_CODE_POINT + int plane = codePoint >>> 16; + return plane < ((MAX_CODE_POINT + 1) >>> 16); + } + + /** + * Determines whether the specified character (Unicode code point) + * is in the Basic Multilingual Plane (BMP). + * Such code points can be represented using a single {@code char}. + * + * @param codePoint the character (Unicode code point) to be tested + * @return {@code true} if the specified code point is between + * {@link #MIN_VALUE} and {@link #MAX_VALUE} inclusive; + * {@code false} otherwise. + * @since 1.7 + */ + public static boolean isBmpCodePoint(int codePoint) { + return codePoint >>> 16 == 0; + // Optimized form of: + // codePoint >= MIN_VALUE && codePoint <= MAX_VALUE + // We consistently use logical shift (>>>) to facilitate + // additional runtime optimizations. + } + + /** + * Determines whether the specified character (Unicode code point) + * is in the supplementary character range. + * + * @param codePoint the character (Unicode code point) to be tested + * @return {@code true} if the specified code point is between + * {@link #MIN_SUPPLEMENTARY_CODE_POINT} and + * {@link #MAX_CODE_POINT} inclusive; + * {@code false} otherwise. + * @since 1.5 + */ + public static boolean isSupplementaryCodePoint(int codePoint) { + return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT + && codePoint < MAX_CODE_POINT + 1; + } + + /** + * Determines if the given {@code char} value is a + * + * Unicode high-surrogate code unit + * (also known as leading-surrogate code unit). + * + *

Such values do not represent characters by themselves, + * but are used in the representation of + * supplementary characters + * in the UTF-16 encoding. + * + * @param ch the {@code char} value to be tested. + * @return {@code true} if the {@code char} value is between + * {@link #MIN_HIGH_SURROGATE} and + * {@link #MAX_HIGH_SURROGATE} inclusive; + * {@code false} otherwise. + * @see Character#isLowSurrogate(char) + * @see Character.UnicodeBlock#of(int) + * @since 1.5 + */ + public static boolean isHighSurrogate(char ch) { + // Help VM constant-fold; MAX_HIGH_SURROGATE + 1 == MIN_LOW_SURROGATE + return ch >= MIN_HIGH_SURROGATE && ch < (MAX_HIGH_SURROGATE + 1); + } + + /** + * Determines if the given {@code char} value is a + * + * Unicode low-surrogate code unit + * (also known as trailing-surrogate code unit). + * + *

Such values do not represent characters by themselves, + * but are used in the representation of + * supplementary characters + * in the UTF-16 encoding. + * + * @param ch the {@code char} value to be tested. + * @return {@code true} if the {@code char} value is between + * {@link #MIN_LOW_SURROGATE} and + * {@link #MAX_LOW_SURROGATE} inclusive; + * {@code false} otherwise. + * @see Character#isHighSurrogate(char) + * @since 1.5 + */ + public static boolean isLowSurrogate(char ch) { + return ch >= MIN_LOW_SURROGATE && ch < (MAX_LOW_SURROGATE + 1); + } + + /** + * Determines if the given {@code char} value is a Unicode + * surrogate code unit. + * + *

Such values do not represent characters by themselves, + * but are used in the representation of + * supplementary characters + * in the UTF-16 encoding. + * + *

A char value is a surrogate code unit if and only if it is either + * a {@linkplain #isLowSurrogate(char) low-surrogate code unit} or + * a {@linkplain #isHighSurrogate(char) high-surrogate code unit}. + * + * @param ch the {@code char} value to be tested. + * @return {@code true} if the {@code char} value is between + * {@link #MIN_SURROGATE} and + * {@link #MAX_SURROGATE} inclusive; + * {@code false} otherwise. + * @since 1.7 + */ + public static boolean isSurrogate(char ch) { + return ch >= MIN_SURROGATE && ch < (MAX_SURROGATE + 1); + } + + /** + * Determines whether the specified pair of {@code char} + * values is a valid + * + * Unicode surrogate pair. + + *

This method is equivalent to the expression: + *

+     * isHighSurrogate(high) && isLowSurrogate(low)
+     * 
+ * + * @param high the high-surrogate code value to be tested + * @param low the low-surrogate code value to be tested + * @return {@code true} if the specified high and + * low-surrogate code values represent a valid surrogate pair; + * {@code false} otherwise. + * @since 1.5 + */ + public static boolean isSurrogatePair(char high, char low) { + return isHighSurrogate(high) && isLowSurrogate(low); + } + + /** + * Determines the number of {@code char} values needed to + * represent the specified character (Unicode code point). If the + * specified character is equal to or greater than 0x10000, then + * the method returns 2. Otherwise, the method returns 1. + * + *

This method doesn't validate the specified character to be a + * valid Unicode code point. The caller must validate the + * character value using {@link #isValidCodePoint(int) isValidCodePoint} + * if necessary. + * + * @param codePoint the character (Unicode code point) to be tested. + * @return 2 if the character is a valid supplementary character; 1 otherwise. + * @see Character#isSupplementaryCodePoint(int) + * @since 1.5 + */ + public static int charCount(int codePoint) { + return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT ? 2 : 1; + } + + /** + * Converts the specified surrogate pair to its supplementary code + * point value. This method does not validate the specified + * surrogate pair. The caller must validate it using {@link + * #isSurrogatePair(char, char) isSurrogatePair} if necessary. + * + * @param high the high-surrogate code unit + * @param low the low-surrogate code unit + * @return the supplementary code point composed from the + * specified surrogate pair. + * @since 1.5 + */ + public static int toCodePoint(char high, char low) { + // Optimized form of: + // return ((high - MIN_HIGH_SURROGATE) << 10) + // + (low - MIN_LOW_SURROGATE) + // + MIN_SUPPLEMENTARY_CODE_POINT; + return ((high << 10) + low) + (MIN_SUPPLEMENTARY_CODE_POINT + - (MIN_HIGH_SURROGATE << 10) + - MIN_LOW_SURROGATE); + } + + /** + * Returns the code point at the given index of the + * {@code CharSequence}. If the {@code char} value at + * the given index in the {@code CharSequence} is in the + * high-surrogate range, the following index is less than the + * length of the {@code CharSequence}, and the + * {@code char} value at the following index is in the + * low-surrogate range, then the supplementary code point + * corresponding to this surrogate pair is returned. Otherwise, + * the {@code char} value at the given index is returned. + * + * @param seq a sequence of {@code char} values (Unicode code + * units) + * @param index the index to the {@code char} values (Unicode + * code units) in {@code seq} to be converted + * @return the Unicode code point at the given index + * @exception NullPointerException if {@code seq} is null. + * @exception IndexOutOfBoundsException if the value + * {@code index} is negative or not less than + * {@link CharSequence#length() seq.length()}. + * @since 1.5 + */ + public static int codePointAt(CharSequence seq, int index) { + char c1 = seq.charAt(index++); + if (isHighSurrogate(c1)) { + if (index < seq.length()) { + char c2 = seq.charAt(index); + if (isLowSurrogate(c2)) { + return toCodePoint(c1, c2); + } + } + } + return c1; + } + + /** + * Returns the code point at the given index of the + * {@code char} array. If the {@code char} value at + * the given index in the {@code char} array is in the + * high-surrogate range, the following index is less than the + * length of the {@code char} array, and the + * {@code char} value at the following index is in the + * low-surrogate range, then the supplementary code point + * corresponding to this surrogate pair is returned. Otherwise, + * the {@code char} value at the given index is returned. + * + * @param a the {@code char} array + * @param index the index to the {@code char} values (Unicode + * code units) in the {@code char} array to be converted + * @return the Unicode code point at the given index + * @exception NullPointerException if {@code a} is null. + * @exception IndexOutOfBoundsException if the value + * {@code index} is negative or not less than + * the length of the {@code char} array. + * @since 1.5 + */ + public static int codePointAt(char[] a, int index) { + return codePointAtImpl(a, index, a.length); + } + + /** + * Returns the code point at the given index of the + * {@code char} array, where only array elements with + * {@code index} less than {@code limit} can be used. If + * the {@code char} value at the given index in the + * {@code char} array is in the high-surrogate range, the + * following index is less than the {@code limit}, and the + * {@code char} value at the following index is in the + * low-surrogate range, then the supplementary code point + * corresponding to this surrogate pair is returned. Otherwise, + * the {@code char} value at the given index is returned. + * + * @param a the {@code char} array + * @param index the index to the {@code char} values (Unicode + * code units) in the {@code char} array to be converted + * @param limit the index after the last array element that + * can be used in the {@code char} array + * @return the Unicode code point at the given index + * @exception NullPointerException if {@code a} is null. + * @exception IndexOutOfBoundsException if the {@code index} + * argument is negative or not less than the {@code limit} + * argument, or if the {@code limit} argument is negative or + * greater than the length of the {@code char} array. + * @since 1.5 + */ + public static int codePointAt(char[] a, int index, int limit) { + if (index >= limit || limit < 0 || limit > a.length) { + throw new IndexOutOfBoundsException(); + } + return codePointAtImpl(a, index, limit); + } + + // throws ArrayIndexOutofBoundsException if index out of bounds + static int codePointAtImpl(char[] a, int index, int limit) { + char c1 = a[index++]; + if (isHighSurrogate(c1)) { + if (index < limit) { + char c2 = a[index]; + if (isLowSurrogate(c2)) { + return toCodePoint(c1, c2); + } + } + } + return c1; + } + + /** + * Returns the code point preceding the given index of the + * {@code CharSequence}. If the {@code char} value at + * {@code (index - 1)} in the {@code CharSequence} is in + * the low-surrogate range, {@code (index - 2)} is not + * negative, and the {@code char} value at {@code (index - 2)} + * in the {@code CharSequence} is in the + * high-surrogate range, then the supplementary code point + * corresponding to this surrogate pair is returned. Otherwise, + * the {@code char} value at {@code (index - 1)} is + * returned. + * + * @param seq the {@code CharSequence} instance + * @param index the index following the code point that should be returned + * @return the Unicode code point value before the given index. + * @exception NullPointerException if {@code seq} is null. + * @exception IndexOutOfBoundsException if the {@code index} + * argument is less than 1 or greater than {@link + * CharSequence#length() seq.length()}. + * @since 1.5 + */ + public static int codePointBefore(CharSequence seq, int index) { + char c2 = seq.charAt(--index); + if (isLowSurrogate(c2)) { + if (index > 0) { + char c1 = seq.charAt(--index); + if (isHighSurrogate(c1)) { + return toCodePoint(c1, c2); + } + } + } + return c2; + } + + /** + * Returns the code point preceding the given index of the + * {@code char} array. If the {@code char} value at + * {@code (index - 1)} in the {@code char} array is in + * the low-surrogate range, {@code (index - 2)} is not + * negative, and the {@code char} value at {@code (index - 2)} + * in the {@code char} array is in the + * high-surrogate range, then the supplementary code point + * corresponding to this surrogate pair is returned. Otherwise, + * the {@code char} value at {@code (index - 1)} is + * returned. + * + * @param a the {@code char} array + * @param index the index following the code point that should be returned + * @return the Unicode code point value before the given index. + * @exception NullPointerException if {@code a} is null. + * @exception IndexOutOfBoundsException if the {@code index} + * argument is less than 1 or greater than the length of the + * {@code char} array + * @since 1.5 + */ + public static int codePointBefore(char[] a, int index) { + return codePointBeforeImpl(a, index, 0); + } + + /** + * Returns the code point preceding the given index of the + * {@code char} array, where only array elements with + * {@code index} greater than or equal to {@code start} + * can be used. If the {@code char} value at {@code (index - 1)} + * in the {@code char} array is in the + * low-surrogate range, {@code (index - 2)} is not less than + * {@code start}, and the {@code char} value at + * {@code (index - 2)} in the {@code char} array is in + * the high-surrogate range, then the supplementary code point + * corresponding to this surrogate pair is returned. Otherwise, + * the {@code char} value at {@code (index - 1)} is + * returned. + * + * @param a the {@code char} array + * @param index the index following the code point that should be returned + * @param start the index of the first array element in the + * {@code char} array + * @return the Unicode code point value before the given index. + * @exception NullPointerException if {@code a} is null. + * @exception IndexOutOfBoundsException if the {@code index} + * argument is not greater than the {@code start} argument or + * is greater than the length of the {@code char} array, or + * if the {@code start} argument is negative or not less than + * the length of the {@code char} array. + * @since 1.5 + */ + public static int codePointBefore(char[] a, int index, int start) { + if (index <= start || start < 0 || start >= a.length) { + throw new IndexOutOfBoundsException(); + } + return codePointBeforeImpl(a, index, start); + } + + // throws ArrayIndexOutofBoundsException if index-1 out of bounds + static int codePointBeforeImpl(char[] a, int index, int start) { + char c2 = a[--index]; + if (isLowSurrogate(c2)) { + if (index > start) { + char c1 = a[--index]; + if (isHighSurrogate(c1)) { + return toCodePoint(c1, c2); + } + } + } + return c2; + } + + /** + * Returns the leading surrogate (a + * + * high surrogate code unit) of the + * + * surrogate pair + * representing the specified supplementary character (Unicode + * code point) in the UTF-16 encoding. If the specified character + * is not a + * supplementary character, + * an unspecified {@code char} is returned. + * + *

If + * {@link #isSupplementaryCodePoint isSupplementaryCodePoint(x)} + * is {@code true}, then + * {@link #isHighSurrogate isHighSurrogate}{@code (highSurrogate(x))} and + * {@link #toCodePoint toCodePoint}{@code (highSurrogate(x), }{@link #lowSurrogate lowSurrogate}{@code (x)) == x} + * are also always {@code true}. + * + * @param codePoint a supplementary character (Unicode code point) + * @return the leading surrogate code unit used to represent the + * character in the UTF-16 encoding + * @since 1.7 + */ + public static char highSurrogate(int codePoint) { + return (char) ((codePoint >>> 10) + + (MIN_HIGH_SURROGATE - (MIN_SUPPLEMENTARY_CODE_POINT >>> 10))); + } + + /** + * Returns the trailing surrogate (a + * + * low surrogate code unit) of the + * + * surrogate pair + * representing the specified supplementary character (Unicode + * code point) in the UTF-16 encoding. If the specified character + * is not a + * supplementary character, + * an unspecified {@code char} is returned. + * + *

If + * {@link #isSupplementaryCodePoint isSupplementaryCodePoint(x)} + * is {@code true}, then + * {@link #isLowSurrogate isLowSurrogate}{@code (lowSurrogate(x))} and + * {@link #toCodePoint toCodePoint}{@code (}{@link #highSurrogate highSurrogate}{@code (x), lowSurrogate(x)) == x} + * are also always {@code true}. + * + * @param codePoint a supplementary character (Unicode code point) + * @return the trailing surrogate code unit used to represent the + * character in the UTF-16 encoding + * @since 1.7 + */ + public static char lowSurrogate(int codePoint) { + return (char) ((codePoint & 0x3ff) + MIN_LOW_SURROGATE); + } + + /** + * Converts the specified character (Unicode code point) to its + * UTF-16 representation. If the specified code point is a BMP + * (Basic Multilingual Plane or Plane 0) value, the same value is + * stored in {@code dst[dstIndex]}, and 1 is returned. If the + * specified code point is a supplementary character, its + * surrogate values are stored in {@code dst[dstIndex]} + * (high-surrogate) and {@code dst[dstIndex+1]} + * (low-surrogate), and 2 is returned. + * + * @param codePoint the character (Unicode code point) to be converted. + * @param dst an array of {@code char} in which the + * {@code codePoint}'s UTF-16 value is stored. + * @param dstIndex the start index into the {@code dst} + * array where the converted value is stored. + * @return 1 if the code point is a BMP code point, 2 if the + * code point is a supplementary code point. + * @exception IllegalArgumentException if the specified + * {@code codePoint} is not a valid Unicode code point. + * @exception NullPointerException if the specified {@code dst} is null. + * @exception IndexOutOfBoundsException if {@code dstIndex} + * is negative or not less than {@code dst.length}, or if + * {@code dst} at {@code dstIndex} doesn't have enough + * array element(s) to store the resulting {@code char} + * value(s). (If {@code dstIndex} is equal to + * {@code dst.length-1} and the specified + * {@code codePoint} is a supplementary character, the + * high-surrogate value is not stored in + * {@code dst[dstIndex]}.) + * @since 1.5 + */ + public static int toChars(int codePoint, char[] dst, int dstIndex) { + if (isBmpCodePoint(codePoint)) { + dst[dstIndex] = (char) codePoint; + return 1; + } else if (isValidCodePoint(codePoint)) { + toSurrogates(codePoint, dst, dstIndex); + return 2; + } else { + throw new IllegalArgumentException(); + } + } + + /** + * Converts the specified character (Unicode code point) to its + * UTF-16 representation stored in a {@code char} array. If + * the specified code point is a BMP (Basic Multilingual Plane or + * Plane 0) value, the resulting {@code char} array has + * the same value as {@code codePoint}. If the specified code + * point is a supplementary code point, the resulting + * {@code char} array has the corresponding surrogate pair. + * + * @param codePoint a Unicode code point + * @return a {@code char} array having + * {@code codePoint}'s UTF-16 representation. + * @exception IllegalArgumentException if the specified + * {@code codePoint} is not a valid Unicode code point. + * @since 1.5 + */ + public static char[] toChars(int codePoint) { + if (isBmpCodePoint(codePoint)) { + return new char[] { (char) codePoint }; + } else if (isValidCodePoint(codePoint)) { + char[] result = new char[2]; + toSurrogates(codePoint, result, 0); + return result; + } else { + throw new IllegalArgumentException(); + } + } + + static void toSurrogates(int codePoint, char[] dst, int index) { + // We write elements "backwards" to guarantee all-or-nothing + dst[index+1] = lowSurrogate(codePoint); + dst[index] = highSurrogate(codePoint); + } + + /** + * Returns the number of Unicode code points in the text range of + * the specified char sequence. The text range begins at the + * specified {@code beginIndex} and extends to the + * {@code char} at index {@code endIndex - 1}. Thus the + * length (in {@code char}s) of the text range is + * {@code endIndex-beginIndex}. Unpaired surrogates within + * the text range count as one code point each. + * + * @param seq the char sequence + * @param beginIndex the index to the first {@code char} of + * the text range. + * @param endIndex the index after the last {@code char} of + * the text range. + * @return the number of Unicode code points in the specified text + * range + * @exception NullPointerException if {@code seq} is null. + * @exception IndexOutOfBoundsException if the + * {@code beginIndex} is negative, or {@code endIndex} + * is larger than the length of the given sequence, or + * {@code beginIndex} is larger than {@code endIndex}. + * @since 1.5 + */ + public static int codePointCount(CharSequence seq, int beginIndex, int endIndex) { + int length = seq.length(); + if (beginIndex < 0 || endIndex > length || beginIndex > endIndex) { + throw new IndexOutOfBoundsException(); + } + int n = endIndex - beginIndex; + for (int i = beginIndex; i < endIndex; ) { + if (isHighSurrogate(seq.charAt(i++)) && i < endIndex && + isLowSurrogate(seq.charAt(i))) { + n--; + i++; + } + } + return n; + } + + /** + * Returns the number of Unicode code points in a subarray of the + * {@code char} array argument. The {@code offset} + * argument is the index of the first {@code char} of the + * subarray and the {@code count} argument specifies the + * length of the subarray in {@code char}s. Unpaired + * surrogates within the subarray count as one code point each. + * + * @param a the {@code char} array + * @param offset the index of the first {@code char} in the + * given {@code char} array + * @param count the length of the subarray in {@code char}s + * @return the number of Unicode code points in the specified subarray + * @exception NullPointerException if {@code a} is null. + * @exception IndexOutOfBoundsException if {@code offset} or + * {@code count} is negative, or if {@code offset + + * count} is larger than the length of the given array. + * @since 1.5 + */ + public static int codePointCount(char[] a, int offset, int count) { + if (count > a.length - offset || offset < 0 || count < 0) { + throw new IndexOutOfBoundsException(); + } + return codePointCountImpl(a, offset, count); + } + + static int codePointCountImpl(char[] a, int offset, int count) { + int endIndex = offset + count; + int n = count; + for (int i = offset; i < endIndex; ) { + if (isHighSurrogate(a[i++]) && i < endIndex && + isLowSurrogate(a[i])) { + n--; + i++; + } + } + return n; + } + + /** + * Returns the index within the given char sequence that is offset + * from the given {@code index} by {@code codePointOffset} + * code points. Unpaired surrogates within the text range given by + * {@code index} and {@code codePointOffset} count as + * one code point each. + * + * @param seq the char sequence + * @param index the index to be offset + * @param codePointOffset the offset in code points + * @return the index within the char sequence + * @exception NullPointerException if {@code seq} is null. + * @exception IndexOutOfBoundsException if {@code index} + * is negative or larger then the length of the char sequence, + * or if {@code codePointOffset} is positive and the + * subsequence starting with {@code index} has fewer than + * {@code codePointOffset} code points, or if + * {@code codePointOffset} is negative and the subsequence + * before {@code index} has fewer than the absolute value + * of {@code codePointOffset} code points. + * @since 1.5 + */ + public static int offsetByCodePoints(CharSequence seq, int index, + int codePointOffset) { + int length = seq.length(); + if (index < 0 || index > length) { + throw new IndexOutOfBoundsException(); + } + + int x = index; + if (codePointOffset >= 0) { + int i; + for (i = 0; x < length && i < codePointOffset; i++) { + if (isHighSurrogate(seq.charAt(x++)) && x < length && + isLowSurrogate(seq.charAt(x))) { + x++; + } + } + if (i < codePointOffset) { + throw new IndexOutOfBoundsException(); + } + } else { + int i; + for (i = codePointOffset; x > 0 && i < 0; i++) { + if (isLowSurrogate(seq.charAt(--x)) && x > 0 && + isHighSurrogate(seq.charAt(x-1))) { + x--; + } + } + if (i < 0) { + throw new IndexOutOfBoundsException(); + } + } + return x; + } + + /** + * Returns the index within the given {@code char} subarray + * that is offset from the given {@code index} by + * {@code codePointOffset} code points. The + * {@code start} and {@code count} arguments specify a + * subarray of the {@code char} array. Unpaired surrogates + * within the text range given by {@code index} and + * {@code codePointOffset} count as one code point each. + * + * @param a the {@code char} array + * @param start the index of the first {@code char} of the + * subarray + * @param count the length of the subarray in {@code char}s + * @param index the index to be offset + * @param codePointOffset the offset in code points + * @return the index within the subarray + * @exception NullPointerException if {@code a} is null. + * @exception IndexOutOfBoundsException + * if {@code start} or {@code count} is negative, + * or if {@code start + count} is larger than the length of + * the given array, + * or if {@code index} is less than {@code start} or + * larger then {@code start + count}, + * or if {@code codePointOffset} is positive and the text range + * starting with {@code index} and ending with {@code start + count - 1} + * has fewer than {@code codePointOffset} code + * points, + * or if {@code codePointOffset} is negative and the text range + * starting with {@code start} and ending with {@code index - 1} + * has fewer than the absolute value of + * {@code codePointOffset} code points. + * @since 1.5 + */ + public static int offsetByCodePoints(char[] a, int start, int count, + int index, int codePointOffset) { + if (count > a.length-start || start < 0 || count < 0 + || index < start || index > start+count) { + throw new IndexOutOfBoundsException(); + } + return offsetByCodePointsImpl(a, start, count, index, codePointOffset); + } + + static int offsetByCodePointsImpl(char[]a, int start, int count, + int index, int codePointOffset) { + int x = index; + if (codePointOffset >= 0) { + int limit = start + count; + int i; + for (i = 0; x < limit && i < codePointOffset; i++) { + if (isHighSurrogate(a[x++]) && x < limit && + isLowSurrogate(a[x])) { + x++; + } + } + if (i < codePointOffset) { + throw new IndexOutOfBoundsException(); + } + } else { + int i; + for (i = codePointOffset; x > start && i < 0; i++) { + if (isLowSurrogate(a[--x]) && x > start && + isHighSurrogate(a[x-1])) { + x--; + } + } + if (i < 0) { + throw new IndexOutOfBoundsException(); + } + } + return x; + } + + /** + * Determines if the specified character is a lowercase character. + *

+ * A character is lowercase if its general category type, provided + * by {@code Character.getType(ch)}, is + * {@code LOWERCASE_LETTER}, or it has contributory property + * Other_Lowercase as defined by the Unicode Standard. + *

+ * The following are examples of lowercase characters: + *

+     * 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
+     * '\u00DF' '\u00E0' '\u00E1' '\u00E2' '\u00E3' '\u00E4' '\u00E5' '\u00E6'
+     * '\u00E7' '\u00E8' '\u00E9' '\u00EA' '\u00EB' '\u00EC' '\u00ED' '\u00EE'
+     * '\u00EF' '\u00F0' '\u00F1' '\u00F2' '\u00F3' '\u00F4' '\u00F5' '\u00F6'
+     * '\u00F8' '\u00F9' '\u00FA' '\u00FB' '\u00FC' '\u00FD' '\u00FE' '\u00FF'
+     * 
+ *

Many other Unicode characters are lowercase too. + * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #isLowerCase(int)} method. + * + * @param ch the character to be tested. + * @return {@code true} if the character is lowercase; + * {@code false} otherwise. + * @see Character#isLowerCase(char) + * @see Character#isTitleCase(char) + * @see Character#toLowerCase(char) + * @see Character#getType(char) + */ + public static boolean isLowerCase(char ch) { + throw new UnsupportedOperationException(); + } + + /** + * Determines if the specified character is an uppercase character. + *

+ * A character is uppercase if its general category type, provided by + * {@code Character.getType(ch)}, is {@code UPPERCASE_LETTER}. + * or it has contributory property Other_Uppercase as defined by the Unicode Standard. + *

+ * The following are examples of uppercase characters: + *

+     * 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
+     * '\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7'
+     * '\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF'
+     * '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8'
+     * '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'
+     * 
+ *

Many other Unicode characters are uppercase too.

+ * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #isUpperCase(int)} method. + * + * @param ch the character to be tested. + * @return {@code true} if the character is uppercase; + * {@code false} otherwise. + * @see Character#isLowerCase(char) + * @see Character#isTitleCase(char) + * @see Character#toUpperCase(char) + * @see Character#getType(char) + * @since 1.0 + */ + public static boolean isUpperCase(char ch) { + throw new UnsupportedOperationException(); + } + + /** + * Determines if the specified character is a titlecase character. + *

+ * A character is a titlecase character if its general + * category type, provided by {@code Character.getType(ch)}, + * is {@code TITLECASE_LETTER}. + *

+ * Some characters look like pairs of Latin letters. For example, there + * is an uppercase letter that looks like "LJ" and has a corresponding + * lowercase letter that looks like "lj". A third form, which looks like "Lj", + * is the appropriate form to use when rendering a word in lowercase + * with initial capitals, as for a book title. + *

+ * These are some of the Unicode characters for which this method returns + * {@code true}: + *

    + *
  • {@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON} + *
  • {@code LATIN CAPITAL LETTER L WITH SMALL LETTER J} + *
  • {@code LATIN CAPITAL LETTER N WITH SMALL LETTER J} + *
  • {@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z} + *
+ *

Many other Unicode characters are titlecase too.

+ * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #isTitleCase(int)} method. + * + * @param ch the character to be tested. + * @return {@code true} if the character is titlecase; + * {@code false} otherwise. + * @see Character#isLowerCase(char) + * @see Character#isUpperCase(char) + * @see Character#toTitleCase(char) + * @see Character#getType(char) + * @since 1.0.2 + */ + public static boolean isTitleCase(char ch) { + return isTitleCase((int)ch); + } + + /** + * Determines if the specified character (Unicode code point) is a titlecase character. + *

+ * A character is a titlecase character if its general + * category type, provided by {@link Character#getType(int) getType(codePoint)}, + * is {@code TITLECASE_LETTER}. + *

+ * Some characters look like pairs of Latin letters. For example, there + * is an uppercase letter that looks like "LJ" and has a corresponding + * lowercase letter that looks like "lj". A third form, which looks like "Lj", + * is the appropriate form to use when rendering a word in lowercase + * with initial capitals, as for a book title. + *

+ * These are some of the Unicode characters for which this method returns + * {@code true}: + *

    + *
  • {@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON} + *
  • {@code LATIN CAPITAL LETTER L WITH SMALL LETTER J} + *
  • {@code LATIN CAPITAL LETTER N WITH SMALL LETTER J} + *
  • {@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z} + *
+ *

Many other Unicode characters are titlecase too.

+ * + * @param codePoint the character (Unicode code point) to be tested. + * @return {@code true} if the character is titlecase; + * {@code false} otherwise. + * @see Character#isLowerCase(int) + * @see Character#isUpperCase(int) + * @see Character#toTitleCase(int) + * @see Character#getType(int) + * @since 1.5 + */ + public static boolean isTitleCase(int codePoint) { + return getType(codePoint) == Character.TITLECASE_LETTER; + } + + /** + * Determines if the specified character is a digit. + *

+ * A character is a digit if its general category type, provided + * by {@code Character.getType(ch)}, is + * {@code DECIMAL_DIGIT_NUMBER}. + *

+ * Some Unicode character ranges that contain digits: + *

    + *
  • {@code '\u005Cu0030'} through {@code '\u005Cu0039'}, + * ISO-LATIN-1 digits ({@code '0'} through {@code '9'}) + *
  • {@code '\u005Cu0660'} through {@code '\u005Cu0669'}, + * Arabic-Indic digits + *
  • {@code '\u005Cu06F0'} through {@code '\u005Cu06F9'}, + * Extended Arabic-Indic digits + *
  • {@code '\u005Cu0966'} through {@code '\u005Cu096F'}, + * Devanagari digits + *
  • {@code '\u005CuFF10'} through {@code '\u005CuFF19'}, + * Fullwidth digits + *
+ * + * Many other character ranges contain digits as well. + * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #isDigit(int)} method. + * + * @param ch the character to be tested. + * @return {@code true} if the character is a digit; + * {@code false} otherwise. + * @see Character#digit(char, int) + * @see Character#forDigit(int, int) + * @see Character#getType(char) + */ + public static boolean isDigit(char ch) { + return isDigit((int)ch); + } + + /** + * Determines if the specified character (Unicode code point) is a digit. + *

+ * A character is a digit if its general category type, provided + * by {@link Character#getType(int) getType(codePoint)}, is + * {@code DECIMAL_DIGIT_NUMBER}. + *

+ * Some Unicode character ranges that contain digits: + *

    + *
  • {@code '\u005Cu0030'} through {@code '\u005Cu0039'}, + * ISO-LATIN-1 digits ({@code '0'} through {@code '9'}) + *
  • {@code '\u005Cu0660'} through {@code '\u005Cu0669'}, + * Arabic-Indic digits + *
  • {@code '\u005Cu06F0'} through {@code '\u005Cu06F9'}, + * Extended Arabic-Indic digits + *
  • {@code '\u005Cu0966'} through {@code '\u005Cu096F'}, + * Devanagari digits + *
  • {@code '\u005CuFF10'} through {@code '\u005CuFF19'}, + * Fullwidth digits + *
+ * + * Many other character ranges contain digits as well. + * + * @param codePoint the character (Unicode code point) to be tested. + * @return {@code true} if the character is a digit; + * {@code false} otherwise. + * @see Character#forDigit(int, int) + * @see Character#getType(int) + * @since 1.5 + */ + public static boolean isDigit(int codePoint) { + return getType(codePoint) == Character.DECIMAL_DIGIT_NUMBER; + } + + /** + * Determines if a character is defined in Unicode. + *

+ * A character is defined if at least one of the following is true: + *

    + *
  • It has an entry in the UnicodeData file. + *
  • It has a value in a range defined by the UnicodeData file. + *
+ * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #isDefined(int)} method. + * + * @param ch the character to be tested + * @return {@code true} if the character has a defined meaning + * in Unicode; {@code false} otherwise. + * @see Character#isDigit(char) + * @see Character#isLetter(char) + * @see Character#isLetterOrDigit(char) + * @see Character#isLowerCase(char) + * @see Character#isTitleCase(char) + * @see Character#isUpperCase(char) + * @since 1.0.2 + */ + public static boolean isDefined(char ch) { + return isDefined((int)ch); + } + + /** + * Determines if a character (Unicode code point) is defined in Unicode. + *

+ * A character is defined if at least one of the following is true: + *

    + *
  • It has an entry in the UnicodeData file. + *
  • It has a value in a range defined by the UnicodeData file. + *
+ * + * @param codePoint the character (Unicode code point) to be tested. + * @return {@code true} if the character has a defined meaning + * in Unicode; {@code false} otherwise. + * @see Character#isDigit(int) + * @see Character#isLetter(int) + * @see Character#isLetterOrDigit(int) + * @see Character#isLowerCase(int) + * @see Character#isTitleCase(int) + * @see Character#isUpperCase(int) + * @since 1.5 + */ + public static boolean isDefined(int codePoint) { + return getType(codePoint) != Character.UNASSIGNED; + } + + /** + * Determines if the specified character is a letter. + *

+ * A character is considered to be a letter if its general + * category type, provided by {@code Character.getType(ch)}, + * is any of the following: + *

    + *
  • {@code UPPERCASE_LETTER} + *
  • {@code LOWERCASE_LETTER} + *
  • {@code TITLECASE_LETTER} + *
  • {@code MODIFIER_LETTER} + *
  • {@code OTHER_LETTER} + *
+ * + * Not all letters have case. Many characters are + * letters but are neither uppercase nor lowercase nor titlecase. + * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #isLetter(int)} method. + * + * @param ch the character to be tested. + * @return {@code true} if the character is a letter; + * {@code false} otherwise. + * @see Character#isDigit(char) + * @see Character#isJavaIdentifierStart(char) + * @see Character#isJavaLetter(char) + * @see Character#isJavaLetterOrDigit(char) + * @see Character#isLetterOrDigit(char) + * @see Character#isLowerCase(char) + * @see Character#isTitleCase(char) + * @see Character#isUnicodeIdentifierStart(char) + * @see Character#isUpperCase(char) + */ + public static boolean isLetter(char ch) { + return isLetter((int)ch); + } + + /** + * Determines if the specified character (Unicode code point) is a letter. + *

+ * A character is considered to be a letter if its general + * category type, provided by {@link Character#getType(int) getType(codePoint)}, + * is any of the following: + *

    + *
  • {@code UPPERCASE_LETTER} + *
  • {@code LOWERCASE_LETTER} + *
  • {@code TITLECASE_LETTER} + *
  • {@code MODIFIER_LETTER} + *
  • {@code OTHER_LETTER} + *
+ * + * Not all letters have case. Many characters are + * letters but are neither uppercase nor lowercase nor titlecase. + * + * @param codePoint the character (Unicode code point) to be tested. + * @return {@code true} if the character is a letter; + * {@code false} otherwise. + * @see Character#isDigit(int) + * @see Character#isJavaIdentifierStart(int) + * @see Character#isLetterOrDigit(int) + * @see Character#isLowerCase(int) + * @see Character#isTitleCase(int) + * @see Character#isUnicodeIdentifierStart(int) + * @see Character#isUpperCase(int) + * @since 1.5 + */ + public static boolean isLetter(int codePoint) { + return ((((1 << Character.UPPERCASE_LETTER) | + (1 << Character.LOWERCASE_LETTER) | + (1 << Character.TITLECASE_LETTER) | + (1 << Character.MODIFIER_LETTER) | + (1 << Character.OTHER_LETTER)) >> getType(codePoint)) & 1) + != 0; + } + + /** + * Determines if the specified character is a letter or digit. + *

+ * A character is considered to be a letter or digit if either + * {@code Character.isLetter(char ch)} or + * {@code Character.isDigit(char ch)} returns + * {@code true} for the character. + * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #isLetterOrDigit(int)} method. + * + * @param ch the character to be tested. + * @return {@code true} if the character is a letter or digit; + * {@code false} otherwise. + * @see Character#isDigit(char) + * @see Character#isJavaIdentifierPart(char) + * @see Character#isJavaLetter(char) + * @see Character#isJavaLetterOrDigit(char) + * @see Character#isLetter(char) + * @see Character#isUnicodeIdentifierPart(char) + * @since 1.0.2 + */ + public static boolean isLetterOrDigit(char ch) { + return isLetterOrDigit((int)ch); + } + + /** + * Determines if the specified character (Unicode code point) is a letter or digit. + *

+ * A character is considered to be a letter or digit if either + * {@link #isLetter(int) isLetter(codePoint)} or + * {@link #isDigit(int) isDigit(codePoint)} returns + * {@code true} for the character. + * + * @param codePoint the character (Unicode code point) to be tested. + * @return {@code true} if the character is a letter or digit; + * {@code false} otherwise. + * @see Character#isDigit(int) + * @see Character#isJavaIdentifierPart(int) + * @see Character#isLetter(int) + * @see Character#isUnicodeIdentifierPart(int) + * @since 1.5 + */ + public static boolean isLetterOrDigit(int codePoint) { + return ((((1 << Character.UPPERCASE_LETTER) | + (1 << Character.LOWERCASE_LETTER) | + (1 << Character.TITLECASE_LETTER) | + (1 << Character.MODIFIER_LETTER) | + (1 << Character.OTHER_LETTER) | + (1 << Character.DECIMAL_DIGIT_NUMBER)) >> getType(codePoint)) & 1) + != 0; + } + + static int getType(int x) { + throw new UnsupportedOperationException(); + } + + /** + * Converts the character argument to lowercase using case + * mapping information from the UnicodeData file. + *

+ * Note that + * {@code Character.isLowerCase(Character.toLowerCase(ch))} + * does not always return {@code true} for some ranges of + * characters, particularly those that are symbols or ideographs. + * + *

In general, {@link String#toLowerCase()} should be used to map + * characters to lowercase. {@code String} case mapping methods + * have several benefits over {@code Character} case mapping methods. + * {@code String} case mapping methods can perform locale-sensitive + * mappings, context-sensitive mappings, and 1:M character mappings, whereas + * the {@code Character} case mapping methods cannot. + * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #toLowerCase(int)} method. + * + * @param ch the character to be converted. + * @return the lowercase equivalent of the character, if any; + * otherwise, the character itself. + * @see Character#isLowerCase(char) + * @see String#toLowerCase() + */ + public static char toLowerCase(char ch) { + throw new UnsupportedOperationException(); + } + + /** + * Converts the character argument to uppercase using case mapping + * information from the UnicodeData file. + *

+ * Note that + * {@code Character.isUpperCase(Character.toUpperCase(ch))} + * does not always return {@code true} for some ranges of + * characters, particularly those that are symbols or ideographs. + * + *

In general, {@link String#toUpperCase()} should be used to map + * characters to uppercase. {@code String} case mapping methods + * have several benefits over {@code Character} case mapping methods. + * {@code String} case mapping methods can perform locale-sensitive + * mappings, context-sensitive mappings, and 1:M character mappings, whereas + * the {@code Character} case mapping methods cannot. + * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #toUpperCase(int)} method. + * + * @param ch the character to be converted. + * @return the uppercase equivalent of the character, if any; + * otherwise, the character itself. + * @see Character#isUpperCase(char) + * @see String#toUpperCase() + */ + public static char toUpperCase(char ch) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the numeric value of the character {@code ch} in the + * specified radix. + *

+ * If the radix is not in the range {@code MIN_RADIX} ≤ + * {@code radix} ≤ {@code MAX_RADIX} or if the + * value of {@code ch} is not a valid digit in the specified + * radix, {@code -1} is returned. A character is a valid digit + * if at least one of the following is true: + *

    + *
  • The method {@code isDigit} is {@code true} of the character + * and the Unicode decimal digit value of the character (or its + * single-character decomposition) is less than the specified radix. + * In this case the decimal digit value is returned. + *
  • The character is one of the uppercase Latin letters + * {@code 'A'} through {@code 'Z'} and its code is less than + * {@code radix + 'A' - 10}. + * In this case, {@code ch - 'A' + 10} + * is returned. + *
  • The character is one of the lowercase Latin letters + * {@code 'a'} through {@code 'z'} and its code is less than + * {@code radix + 'a' - 10}. + * In this case, {@code ch - 'a' + 10} + * is returned. + *
  • The character is one of the fullwidth uppercase Latin letters A + * ({@code '\u005CuFF21'}) through Z ({@code '\u005CuFF3A'}) + * and its code is less than + * {@code radix + '\u005CuFF21' - 10}. + * In this case, {@code ch - '\u005CuFF21' + 10} + * is returned. + *
  • The character is one of the fullwidth lowercase Latin letters a + * ({@code '\u005CuFF41'}) through z ({@code '\u005CuFF5A'}) + * and its code is less than + * {@code radix + '\u005CuFF41' - 10}. + * In this case, {@code ch - '\u005CuFF41' + 10} + * is returned. + *
+ * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #digit(int, int)} method. + * + * @param ch the character to be converted. + * @param radix the radix. + * @return the numeric value represented by the character in the + * specified radix. + * @see Character#forDigit(int, int) + * @see Character#isDigit(char) + */ + public static int digit(char ch, int radix) { + return digit((int)ch, radix); + } + + /** + * Returns the numeric value of the specified character (Unicode + * code point) in the specified radix. + * + *

If the radix is not in the range {@code MIN_RADIX} ≤ + * {@code radix} ≤ {@code MAX_RADIX} or if the + * character is not a valid digit in the specified + * radix, {@code -1} is returned. A character is a valid digit + * if at least one of the following is true: + *

    + *
  • The method {@link #isDigit(int) isDigit(codePoint)} is {@code true} of the character + * and the Unicode decimal digit value of the character (or its + * single-character decomposition) is less than the specified radix. + * In this case the decimal digit value is returned. + *
  • The character is one of the uppercase Latin letters + * {@code 'A'} through {@code 'Z'} and its code is less than + * {@code radix + 'A' - 10}. + * In this case, {@code codePoint - 'A' + 10} + * is returned. + *
  • The character is one of the lowercase Latin letters + * {@code 'a'} through {@code 'z'} and its code is less than + * {@code radix + 'a' - 10}. + * In this case, {@code codePoint - 'a' + 10} + * is returned. + *
  • The character is one of the fullwidth uppercase Latin letters A + * ({@code '\u005CuFF21'}) through Z ({@code '\u005CuFF3A'}) + * and its code is less than + * {@code radix + '\u005CuFF21' - 10}. + * In this case, + * {@code codePoint - '\u005CuFF21' + 10} + * is returned. + *
  • The character is one of the fullwidth lowercase Latin letters a + * ({@code '\u005CuFF41'}) through z ({@code '\u005CuFF5A'}) + * and its code is less than + * {@code radix + '\u005CuFF41'- 10}. + * In this case, + * {@code codePoint - '\u005CuFF41' + 10} + * is returned. + *
+ * + * @param codePoint the character (Unicode code point) to be converted. + * @param radix the radix. + * @return the numeric value represented by the character in the + * specified radix. + * @see Character#forDigit(int, int) + * @see Character#isDigit(int) + * @since 1.5 + */ + public static int digit(int codePoint, int radix) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the {@code int} value that the specified Unicode + * character represents. For example, the character + * {@code '\u005Cu216C'} (the roman numeral fifty) will return + * an int with a value of 50. + *

+ * The letters A-Z in their uppercase ({@code '\u005Cu0041'} through + * {@code '\u005Cu005A'}), lowercase + * ({@code '\u005Cu0061'} through {@code '\u005Cu007A'}), and + * full width variant ({@code '\u005CuFF21'} through + * {@code '\u005CuFF3A'} and {@code '\u005CuFF41'} through + * {@code '\u005CuFF5A'}) forms have numeric values from 10 + * through 35. This is independent of the Unicode specification, + * which does not assign numeric values to these {@code char} + * values. + *

+ * If the character does not have a numeric value, then -1 is returned. + * If the character has a numeric value that cannot be represented as a + * nonnegative integer (for example, a fractional value), then -2 + * is returned. + * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #getNumericValue(int)} method. + * + * @param ch the character to be converted. + * @return the numeric value of the character, as a nonnegative {@code int} + * value; -2 if the character has a numeric value that is not a + * nonnegative integer; -1 if the character has no numeric value. + * @see Character#forDigit(int, int) + * @see Character#isDigit(char) + * @since 1.1 + */ + public static int getNumericValue(char ch) { + return getNumericValue((int)ch); + } + + /** + * Returns the {@code int} value that the specified + * character (Unicode code point) represents. For example, the character + * {@code '\u005Cu216C'} (the Roman numeral fifty) will return + * an {@code int} with a value of 50. + *

+ * The letters A-Z in their uppercase ({@code '\u005Cu0041'} through + * {@code '\u005Cu005A'}), lowercase + * ({@code '\u005Cu0061'} through {@code '\u005Cu007A'}), and + * full width variant ({@code '\u005CuFF21'} through + * {@code '\u005CuFF3A'} and {@code '\u005CuFF41'} through + * {@code '\u005CuFF5A'}) forms have numeric values from 10 + * through 35. This is independent of the Unicode specification, + * which does not assign numeric values to these {@code char} + * values. + *

+ * If the character does not have a numeric value, then -1 is returned. + * If the character has a numeric value that cannot be represented as a + * nonnegative integer (for example, a fractional value), then -2 + * is returned. + * + * @param codePoint the character (Unicode code point) to be converted. + * @return the numeric value of the character, as a nonnegative {@code int} + * value; -2 if the character has a numeric value that is not a + * nonnegative integer; -1 if the character has no numeric value. + * @see Character#forDigit(int, int) + * @see Character#isDigit(int) + * @since 1.5 + */ + public static int getNumericValue(int codePoint) { + throw new UnsupportedOperationException(); + } + + /** + * Determines if the specified character is ISO-LATIN-1 white space. + * This method returns {@code true} for the following five + * characters only: + * + * + * + * + * + * + * + * + * + * + * + *
{@code '\t'} {@code U+0009}{@code HORIZONTAL TABULATION}
{@code '\n'} {@code U+000A}{@code NEW LINE}
{@code '\f'} {@code U+000C}{@code FORM FEED}
{@code '\r'} {@code U+000D}{@code CARRIAGE RETURN}
{@code ' '} {@code U+0020}{@code SPACE}
+ * + * @param ch the character to be tested. + * @return {@code true} if the character is ISO-LATIN-1 white + * space; {@code false} otherwise. + * @see Character#isSpaceChar(char) + * @see Character#isWhitespace(char) + * @deprecated Replaced by isWhitespace(char). + */ + @Deprecated + public static boolean isSpace(char ch) { + return (ch <= 0x0020) && + (((((1L << 0x0009) | + (1L << 0x000A) | + (1L << 0x000C) | + (1L << 0x000D) | + (1L << 0x0020)) >> ch) & 1L) != 0); + } + + + + /** + * Determines if the specified character is white space according to Java. + * A character is a Java whitespace character if and only if it satisfies + * one of the following criteria: + *

    + *
  • It is a Unicode space character ({@code SPACE_SEPARATOR}, + * {@code LINE_SEPARATOR}, or {@code PARAGRAPH_SEPARATOR}) + * but is not also a non-breaking space ({@code '\u005Cu00A0'}, + * {@code '\u005Cu2007'}, {@code '\u005Cu202F'}). + *
  • It is {@code '\u005Ct'}, U+0009 HORIZONTAL TABULATION. + *
  • It is {@code '\u005Cn'}, U+000A LINE FEED. + *
  • It is {@code '\u005Cu000B'}, U+000B VERTICAL TABULATION. + *
  • It is {@code '\u005Cf'}, U+000C FORM FEED. + *
  • It is {@code '\u005Cr'}, U+000D CARRIAGE RETURN. + *
  • It is {@code '\u005Cu001C'}, U+001C FILE SEPARATOR. + *
  • It is {@code '\u005Cu001D'}, U+001D GROUP SEPARATOR. + *
  • It is {@code '\u005Cu001E'}, U+001E RECORD SEPARATOR. + *
  • It is {@code '\u005Cu001F'}, U+001F UNIT SEPARATOR. + *
+ * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #isWhitespace(int)} method. + * + * @param ch the character to be tested. + * @return {@code true} if the character is a Java whitespace + * character; {@code false} otherwise. + * @see Character#isSpaceChar(char) + * @since 1.1 + */ + public static boolean isWhitespace(char ch) { + return isWhitespace((int)ch); + } + + /** + * Determines if the specified character (Unicode code point) is + * white space according to Java. A character is a Java + * whitespace character if and only if it satisfies one of the + * following criteria: + *

    + *
  • It is a Unicode space character ({@link #SPACE_SEPARATOR}, + * {@link #LINE_SEPARATOR}, or {@link #PARAGRAPH_SEPARATOR}) + * but is not also a non-breaking space ({@code '\u005Cu00A0'}, + * {@code '\u005Cu2007'}, {@code '\u005Cu202F'}). + *
  • It is {@code '\u005Ct'}, U+0009 HORIZONTAL TABULATION. + *
  • It is {@code '\u005Cn'}, U+000A LINE FEED. + *
  • It is {@code '\u005Cu000B'}, U+000B VERTICAL TABULATION. + *
  • It is {@code '\u005Cf'}, U+000C FORM FEED. + *
  • It is {@code '\u005Cr'}, U+000D CARRIAGE RETURN. + *
  • It is {@code '\u005Cu001C'}, U+001C FILE SEPARATOR. + *
  • It is {@code '\u005Cu001D'}, U+001D GROUP SEPARATOR. + *
  • It is {@code '\u005Cu001E'}, U+001E RECORD SEPARATOR. + *
  • It is {@code '\u005Cu001F'}, U+001F UNIT SEPARATOR. + *
+ *

+ * + * @param codePoint the character (Unicode code point) to be tested. + * @return {@code true} if the character is a Java whitespace + * character; {@code false} otherwise. + * @see Character#isSpaceChar(int) + * @since 1.5 + */ + public static boolean isWhitespace(int codePoint) { + throw new UnsupportedOperationException(); + } + + /** + * Determines if the specified character is an ISO control + * character. A character is considered to be an ISO control + * character if its code is in the range {@code '\u005Cu0000'} + * through {@code '\u005Cu001F'} or in the range + * {@code '\u005Cu007F'} through {@code '\u005Cu009F'}. + * + *

Note: This method cannot handle supplementary characters. To support + * all Unicode characters, including supplementary characters, use + * the {@link #isISOControl(int)} method. + * + * @param ch the character to be tested. + * @return {@code true} if the character is an ISO control character; + * {@code false} otherwise. + * + * @see Character#isSpaceChar(char) + * @see Character#isWhitespace(char) + * @since 1.1 + */ + public static boolean isISOControl(char ch) { + return isISOControl((int)ch); + } + + /** + * Determines if the referenced character (Unicode code point) is an ISO control + * character. A character is considered to be an ISO control + * character if its code is in the range {@code '\u005Cu0000'} + * through {@code '\u005Cu001F'} or in the range + * {@code '\u005Cu007F'} through {@code '\u005Cu009F'}. + * + * @param codePoint the character (Unicode code point) to be tested. + * @return {@code true} if the character is an ISO control character; + * {@code false} otherwise. + * @see Character#isSpaceChar(int) + * @see Character#isWhitespace(int) + * @since 1.5 + */ + public static boolean isISOControl(int codePoint) { + // Optimized form of: + // (codePoint >= 0x00 && codePoint <= 0x1F) || + // (codePoint >= 0x7F && codePoint <= 0x9F); + return codePoint <= 0x9F && + (codePoint >= 0x7F || (codePoint >>> 5 == 0)); + } + + /** + * Determines the character representation for a specific digit in + * the specified radix. If the value of {@code radix} is not a + * valid radix, or the value of {@code digit} is not a valid + * digit in the specified radix, the null character + * ({@code '\u005Cu0000'}) is returned. + *

+ * The {@code radix} argument is valid if it is greater than or + * equal to {@code MIN_RADIX} and less than or equal to + * {@code MAX_RADIX}. The {@code digit} argument is valid if + * {@code 0 <= digit < radix}. + *

+ * If the digit is less than 10, then + * {@code '0' + digit} is returned. Otherwise, the value + * {@code 'a' + digit - 10} is returned. + * + * @param digit the number to convert to a character. + * @param radix the radix. + * @return the {@code char} representation of the specified digit + * in the specified radix. + * @see Character#MIN_RADIX + * @see Character#MAX_RADIX + * @see Character#digit(char, int) + */ + public static char forDigit(int digit, int radix) { + if ((digit >= radix) || (digit < 0)) { + return '\0'; + } + if ((radix < Character.MIN_RADIX) || (radix > Character.MAX_RADIX)) { + return '\0'; + } + if (digit < 10) { + return (char)('0' + digit); + } + return (char)('a' - 10 + digit); + } + + /** + * Compares two {@code Character} objects numerically. + * + * @param anotherCharacter the {@code Character} to be compared. + + * @return the value {@code 0} if the argument {@code Character} + * is equal to this {@code Character}; a value less than + * {@code 0} if this {@code Character} is numerically less + * than the {@code Character} argument; and a value greater than + * {@code 0} if this {@code Character} is numerically greater + * than the {@code Character} argument (unsigned comparison). + * Note that this is strictly a numerical comparison; it is not + * locale-dependent. + * @since 1.2 + */ + public int compareTo(Character anotherCharacter) { + return compare(this.value, anotherCharacter.value); + } + + /** + * Compares two {@code char} values numerically. + * The value returned is identical to what would be returned by: + *

+     *    Character.valueOf(x).compareTo(Character.valueOf(y))
+     * 
+ * + * @param x the first {@code char} to compare + * @param y the second {@code char} to compare + * @return the value {@code 0} if {@code x == y}; + * a value less than {@code 0} if {@code x < y}; and + * a value greater than {@code 0} if {@code x > y} + * @since 1.7 + */ + public static int compare(char x, char y) { + return x - y; + } + + + /** + * The number of bits used to represent a char value in unsigned + * binary form, constant {@code 16}. + * + * @since 1.5 + */ + public static final int SIZE = 16; + + /** + * Returns the value obtained by reversing the order of the bytes in the + * specified char value. + * + * @return the value obtained by reversing (or, equivalently, swapping) + * the bytes in the specified char value. + * @since 1.5 + */ + public static char reverseBytes(char ch) { + return (char) (((ch & 0xFF00) >> 8) | (ch << 8)); + } + +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Class.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Class.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,720 @@ +/* + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +import java.lang.annotation.Annotation; + +/** + * Instances of the class {@code Class} represent classes and + * interfaces in a running Java application. An enum is a kind of + * class and an annotation is a kind of interface. Every array also + * belongs to a class that is reflected as a {@code Class} object + * that is shared by all arrays with the same element type and number + * of dimensions. The primitive Java types ({@code boolean}, + * {@code byte}, {@code char}, {@code short}, + * {@code int}, {@code long}, {@code float}, and + * {@code double}), and the keyword {@code void} are also + * represented as {@code Class} objects. + * + *

{@code Class} has no public constructor. Instead {@code Class} + * objects are constructed automatically by the Java Virtual Machine as classes + * are loaded and by calls to the {@code defineClass} method in the class + * loader. + * + *

The following example uses a {@code Class} object to print the + * class name of an object: + * + *

+ *     void printClassName(Object obj) {
+ *         System.out.println("The class of " + obj +
+ *                            " is " + obj.getClass().getName());
+ *     }
+ * 
+ * + *

It is also possible to get the {@code Class} object for a named + * type (or for void) using a class literal. See Section 15.8.2 of + * The Java™ Language Specification. + * For example: + * + *

+ * {@code System.out.println("The name of class Foo is: "+Foo.class.getName());} + *
+ * + * @param the type of the class modeled by this {@code Class} + * object. For example, the type of {@code String.class} is {@code + * Class}. Use {@code Class} if the class being modeled is + * unknown. + * + * @author unascribed + * @see java.lang.ClassLoader#defineClass(byte[], int, int) + * @since JDK1.0 + */ +public final + class Class implements java.io.Serializable { +// java.lang.reflect.GenericDeclaration, +// java.lang.reflect.Type, +// java.lang.reflect.AnnotatedElement { + private static final int ANNOTATION= 0x00002000; + private static final int ENUM = 0x00004000; + private static final int SYNTHETIC = 0x00001000; + + /* + * Constructor. Only the Java Virtual Machine creates Class + * objects. + */ + private Class() {} + + + /** + * Converts the object to a string. The string representation is the + * string "class" or "interface", followed by a space, and then by the + * fully qualified name of the class in the format returned by + * {@code getName}. If this {@code Class} object represents a + * primitive type, this method returns the name of the primitive type. If + * this {@code Class} object represents void this method returns + * "void". + * + * @return a string representation of this class object. + */ + public String toString() { + return (isInterface() ? "interface " : (isPrimitive() ? "" : "class ")) + + getName(); + } + + + /** + * Returns the {@code Class} object associated with the class or + * interface with the given string name. Invoking this method is + * equivalent to: + * + *
+ * {@code Class.forName(className, true, currentLoader)} + *
+ * + * where {@code currentLoader} denotes the defining class loader of + * the current class. + * + *

For example, the following code fragment returns the + * runtime {@code Class} descriptor for the class named + * {@code java.lang.Thread}: + * + *

+ * {@code Class t = Class.forName("java.lang.Thread")} + *
+ *

+ * A call to {@code forName("X")} causes the class named + * {@code X} to be initialized. + * + * @param className the fully qualified name of the desired class. + * @return the {@code Class} object for the class with the + * specified name. + * @exception LinkageError if the linkage fails + * @exception ExceptionInInitializerError if the initialization provoked + * by this method fails + * @exception ClassNotFoundException if the class cannot be located + */ + public static Class forName(String className) + throws ClassNotFoundException { + throw new UnsupportedOperationException(); + } + + + /** + * Creates a new instance of the class represented by this {@code Class} + * object. The class is instantiated as if by a {@code new} + * expression with an empty argument list. The class is initialized if it + * has not already been initialized. + * + *

Note that this method propagates any exception thrown by the + * nullary constructor, including a checked exception. Use of + * this method effectively bypasses the compile-time exception + * checking that would otherwise be performed by the compiler. + * The {@link + * java.lang.reflect.Constructor#newInstance(java.lang.Object...) + * Constructor.newInstance} method avoids this problem by wrapping + * any exception thrown by the constructor in a (checked) {@link + * java.lang.reflect.InvocationTargetException}. + * + * @return a newly allocated instance of the class represented by this + * object. + * @exception IllegalAccessException if the class or its nullary + * constructor is not accessible. + * @exception InstantiationException + * if this {@code Class} represents an abstract class, + * an interface, an array class, a primitive type, or void; + * or if the class has no nullary constructor; + * or if the instantiation fails for some other reason. + * @exception ExceptionInInitializerError if the initialization + * provoked by this method fails. + * @exception SecurityException + * If a security manager, s, is present and any of the + * following conditions is met: + * + *

    + * + *
  • invocation of + * {@link SecurityManager#checkMemberAccess + * s.checkMemberAccess(this, Member.PUBLIC)} denies + * creation of new instances of this class + * + *
  • the caller's class loader is not the same as or an + * ancestor of the class loader for the current class and + * invocation of {@link SecurityManager#checkPackageAccess + * s.checkPackageAccess()} denies access to the package + * of this class + * + *
+ * + */ + public T newInstance() + throws InstantiationException, IllegalAccessException + { + throw new UnsupportedOperationException("Should be somehow supported"); + } + + /** + * Determines if the specified {@code Object} is assignment-compatible + * with the object represented by this {@code Class}. This method is + * the dynamic equivalent of the Java language {@code instanceof} + * operator. The method returns {@code true} if the specified + * {@code Object} argument is non-null and can be cast to the + * reference type represented by this {@code Class} object without + * raising a {@code ClassCastException.} It returns {@code false} + * otherwise. + * + *

Specifically, if this {@code Class} object represents a + * declared class, this method returns {@code true} if the specified + * {@code Object} argument is an instance of the represented class (or + * of any of its subclasses); it returns {@code false} otherwise. If + * this {@code Class} object represents an array class, this method + * returns {@code true} if the specified {@code Object} argument + * can be converted to an object of the array class by an identity + * conversion or by a widening reference conversion; it returns + * {@code false} otherwise. If this {@code Class} object + * represents an interface, this method returns {@code true} if the + * class or any superclass of the specified {@code Object} argument + * implements this interface; it returns {@code false} otherwise. If + * this {@code Class} object represents a primitive type, this method + * returns {@code false}. + * + * @param obj the object to check + * @return true if {@code obj} is an instance of this class + * + * @since JDK1.1 + */ + public native boolean isInstance(Object obj); + + + /** + * Determines if the class or interface represented by this + * {@code Class} object is either the same as, or is a superclass or + * superinterface of, the class or interface represented by the specified + * {@code Class} parameter. It returns {@code true} if so; + * otherwise it returns {@code false}. If this {@code Class} + * object represents a primitive type, this method returns + * {@code true} if the specified {@code Class} parameter is + * exactly this {@code Class} object; otherwise it returns + * {@code false}. + * + *

Specifically, this method tests whether the type represented by the + * specified {@code Class} parameter can be converted to the type + * represented by this {@code Class} object via an identity conversion + * or via a widening reference conversion. See The Java Language + * Specification, sections 5.1.1 and 5.1.4 , for details. + * + * @param cls the {@code Class} object to be checked + * @return the {@code boolean} value indicating whether objects of the + * type {@code cls} can be assigned to objects of this class + * @exception NullPointerException if the specified Class parameter is + * null. + * @since JDK1.1 + */ + public native boolean isAssignableFrom(Class cls); + + + /** + * Determines if the specified {@code Class} object represents an + * interface type. + * + * @return {@code true} if this object represents an interface; + * {@code false} otherwise. + */ + public native boolean isInterface(); + + + /** + * Determines if this {@code Class} object represents an array class. + * + * @return {@code true} if this object represents an array class; + * {@code false} otherwise. + * @since JDK1.1 + */ + public native boolean isArray(); + + + /** + * Determines if the specified {@code Class} object represents a + * primitive type. + * + *

There are nine predefined {@code Class} objects to represent + * the eight primitive types and void. These are created by the Java + * Virtual Machine, and have the same names as the primitive types that + * they represent, namely {@code boolean}, {@code byte}, + * {@code char}, {@code short}, {@code int}, + * {@code long}, {@code float}, and {@code double}. + * + *

These objects may only be accessed via the following public static + * final variables, and are the only {@code Class} objects for which + * this method returns {@code true}. + * + * @return true if and only if this class represents a primitive type + * + * @see java.lang.Boolean#TYPE + * @see java.lang.Character#TYPE + * @see java.lang.Byte#TYPE + * @see java.lang.Short#TYPE + * @see java.lang.Integer#TYPE + * @see java.lang.Long#TYPE + * @see java.lang.Float#TYPE + * @see java.lang.Double#TYPE + * @see java.lang.Void#TYPE + * @since JDK1.1 + */ + public native boolean isPrimitive(); + + /** + * Returns true if this {@code Class} object represents an annotation + * type. Note that if this method returns true, {@link #isInterface()} + * would also return true, as all annotation types are also interfaces. + * + * @return {@code true} if this class object represents an annotation + * type; {@code false} otherwise + * @since 1.5 + */ + public boolean isAnnotation() { + return (getModifiers() & ANNOTATION) != 0; + } + + /** + * Returns {@code true} if this class is a synthetic class; + * returns {@code false} otherwise. + * @return {@code true} if and only if this class is a synthetic class as + * defined by the Java Language Specification. + * @since 1.5 + */ + public boolean isSynthetic() { + return (getModifiers() & SYNTHETIC) != 0; + } + + /** + * Returns the name of the entity (class, interface, array class, + * primitive type, or void) represented by this {@code Class} object, + * as a {@code String}. + * + *

If this class object represents a reference type that is not an + * array type then the binary name of the class is returned, as specified + * by + * The Java™ Language Specification. + * + *

If this class object represents a primitive type or void, then the + * name returned is a {@code String} equal to the Java language + * keyword corresponding to the primitive type or void. + * + *

If this class object represents a class of arrays, then the internal + * form of the name consists of the name of the element type preceded by + * one or more '{@code [}' characters representing the depth of the array + * nesting. The encoding of element type names is as follows: + * + *

+ *
Element Type     Encoding + *
boolean     Z + *
byte     B + *
char     C + *
class or interface + *     Lclassname; + *
double     D + *
float     F + *
int     I + *
long     J + *
short     S + *
+ * + *

The class or interface name classname is the binary name of + * the class specified above. + * + *

Examples: + *

+     * String.class.getName()
+     *     returns "java.lang.String"
+     * byte.class.getName()
+     *     returns "byte"
+     * (new Object[3]).getClass().getName()
+     *     returns "[Ljava.lang.Object;"
+     * (new int[3][4][5][6][7][8][9]).getClass().getName()
+     *     returns "[[[[[[[I"
+     * 
+ * + * @return the name of the class or interface + * represented by this object. + */ + public String getName() { + throw new UnsupportedOperationException(); +// String name = this.name; +// if (name == null) +// this.name = name = getName0(); +// return name; + } + + /** + * Returns the {@code Class} representing the superclass of the entity + * (class, interface, primitive type or void) represented by this + * {@code Class}. If this {@code Class} represents either the + * {@code Object} class, an interface, a primitive type, or void, then + * null is returned. If this object represents an array class then the + * {@code Class} object representing the {@code Object} class is + * returned. + * + * @return the superclass of the class represented by this object. + */ + public native Class getSuperclass(); + + /** + * Returns the Java language modifiers for this class or interface, encoded + * in an integer. The modifiers consist of the Java Virtual Machine's + * constants for {@code public}, {@code protected}, + * {@code private}, {@code final}, {@code static}, + * {@code abstract} and {@code interface}; they should be decoded + * using the methods of class {@code Modifier}. + * + *

If the underlying class is an array class, then its + * {@code public}, {@code private} and {@code protected} + * modifiers are the same as those of its component type. If this + * {@code Class} represents a primitive type or void, its + * {@code public} modifier is always {@code true}, and its + * {@code protected} and {@code private} modifiers are always + * {@code false}. If this object represents an array class, a + * primitive type or void, then its {@code final} modifier is always + * {@code true} and its interface modifier is always + * {@code false}. The values of its other modifiers are not determined + * by this specification. + * + *

The modifier encodings are defined in The Java Virtual Machine + * Specification, table 4.1. + * + * @return the {@code int} representing the modifiers for this class + * @see java.lang.reflect.Modifier + * @since JDK1.1 + */ + public native int getModifiers(); + + + /** + * Returns the simple name of the underlying class as given in the + * source code. Returns an empty string if the underlying class is + * anonymous. + * + *

The simple name of an array is the simple name of the + * component type with "[]" appended. In particular the simple + * name of an array whose component type is anonymous is "[]". + * + * @return the simple name of the underlying class + * @since 1.5 + */ + public String getSimpleName() { + throw new UnsupportedOperationException(); +//// if (isArray()) +//// return getComponentType().getSimpleName()+"[]"; +//// +//// String simpleName = getSimpleBinaryName(); +//// if (simpleName == null) { // top level class +//// simpleName = getName(); +//// return simpleName.substring(simpleName.lastIndexOf(".")+1); // strip the package name +//// } +//// // According to JLS3 "Binary Compatibility" (13.1) the binary +//// // name of non-package classes (not top level) is the binary +//// // name of the immediately enclosing class followed by a '$' followed by: +//// // (for nested and inner classes): the simple name. +//// // (for local classes): 1 or more digits followed by the simple name. +//// // (for anonymous classes): 1 or more digits. +//// +//// // Since getSimpleBinaryName() will strip the binary name of +//// // the immediatly enclosing class, we are now looking at a +//// // string that matches the regular expression "\$[0-9]*" +//// // followed by a simple name (considering the simple of an +//// // anonymous class to be the empty string). +//// +//// // Remove leading "\$[0-9]*" from the name +//// int length = simpleName.length(); +//// if (length < 1 || simpleName.charAt(0) != '$') +//// throw new InternalError("Malformed class name"); +//// int index = 1; +//// while (index < length && isAsciiDigit(simpleName.charAt(index))) +//// index++; +//// // Eventually, this is the empty string iff this is an anonymous class +//// return simpleName.substring(index); + } + + /** + * Character.isDigit answers {@code true} to some non-ascii + * digits. This one does not. + */ + private static boolean isAsciiDigit(char c) { + return '0' <= c && c <= '9'; + } + + /** + * Returns the canonical name of the underlying class as + * defined by the Java Language Specification. Returns null if + * the underlying class does not have a canonical name (i.e., if + * it is a local or anonymous class or an array whose component + * type does not have a canonical name). + * @return the canonical name of the underlying class if it exists, and + * {@code null} otherwise. + * @since 1.5 + */ + public String getCanonicalName() { + throw new UnsupportedOperationException(); +// if (isArray()) { +// String canonicalName = getComponentType().getCanonicalName(); +// if (canonicalName != null) +// return canonicalName + "[]"; +// else +// return null; +// } +// if (isLocalOrAnonymousClass()) +// return null; +// Class enclosingClass = getEnclosingClass(); +// if (enclosingClass == null) { // top level class +// return getName(); +// } else { +// String enclosingName = enclosingClass.getCanonicalName(); +// if (enclosingName == null) +// return null; +// return enclosingName + "." + getSimpleName(); +// } + } + + /** + * Finds a resource with a given name. The rules for searching resources + * associated with a given class are implemented by the defining + * {@linkplain ClassLoader class loader} of the class. This method + * delegates to this object's class loader. If this object was loaded by + * the bootstrap class loader, the method delegates to {@link + * ClassLoader#getSystemResourceAsStream}. + * + *

Before delegation, an absolute resource name is constructed from the + * given resource name using this algorithm: + * + *

    + * + *
  • If the {@code name} begins with a {@code '/'} + * ('\u002f'), then the absolute name of the resource is the + * portion of the {@code name} following the {@code '/'}. + * + *
  • Otherwise, the absolute name is of the following form: + * + *
    + * {@code modified_package_name/name} + *
    + * + *

    Where the {@code modified_package_name} is the package name of this + * object with {@code '/'} substituted for {@code '.'} + * ('\u002e'). + * + *

+ * + * @param name name of the desired resource + * @return A {@link java.io.InputStream} object or {@code null} if + * no resource with this name is found + * @throws NullPointerException If {@code name} is {@code null} + * @since JDK1.1 + */ +// public InputStream getResourceAsStream(String name) { +// name = resolveName(name); +// ClassLoader cl = getClassLoader0(); +// if (cl==null) { +// // A system class. +// return ClassLoader.getSystemResourceAsStream(name); +// } +// return cl.getResourceAsStream(name); +// } + + /** + * Finds a resource with a given name. The rules for searching resources + * associated with a given class are implemented by the defining + * {@linkplain ClassLoader class loader} of the class. This method + * delegates to this object's class loader. If this object was loaded by + * the bootstrap class loader, the method delegates to {@link + * ClassLoader#getSystemResource}. + * + *

Before delegation, an absolute resource name is constructed from the + * given resource name using this algorithm: + * + *

    + * + *
  • If the {@code name} begins with a {@code '/'} + * ('\u002f'), then the absolute name of the resource is the + * portion of the {@code name} following the {@code '/'}. + * + *
  • Otherwise, the absolute name is of the following form: + * + *
    + * {@code modified_package_name/name} + *
    + * + *

    Where the {@code modified_package_name} is the package name of this + * object with {@code '/'} substituted for {@code '.'} + * ('\u002e'). + * + *

+ * + * @param name name of the desired resource + * @return A {@link java.net.URL} object or {@code null} if no + * resource with this name is found + * @since JDK1.1 + */ +// public java.net.URL getResource(String name) { +// name = resolveName(name); +// ClassLoader cl = getClassLoader0(); +// if (cl==null) { +// // A system class. +// return ClassLoader.getSystemResource(name); +// } +// return cl.getResource(name); +// } + + + + + /** + * Returns true if and only if this class was declared as an enum in the + * source code. + * + * @return true if and only if this class was declared as an enum in the + * source code + * @since 1.5 + */ + public boolean isEnum() { + // An enum must both directly extend java.lang.Enum and have + // the ENUM bit set; classes for specialized enum constants + // don't do the former. + return (this.getModifiers() & ENUM) != 0 && + this.getSuperclass() == java.lang.Enum.class; + } + + /** + * Casts an object to the class or interface represented + * by this {@code Class} object. + * + * @param obj the object to be cast + * @return the object after casting, or null if obj is null + * + * @throws ClassCastException if the object is not + * null and is not assignable to the type T. + * + * @since 1.5 + */ + public T cast(Object obj) { + if (obj != null && !isInstance(obj)) + throw new ClassCastException(cannotCastMsg(obj)); + return (T) obj; + } + + private String cannotCastMsg(Object obj) { + return "Cannot cast " + obj.getClass().getName() + " to " + getName(); + } + + /** + * Casts this {@code Class} object to represent a subclass of the class + * represented by the specified class object. Checks that that the cast + * is valid, and throws a {@code ClassCastException} if it is not. If + * this method succeeds, it always returns a reference to this class object. + * + *

This method is useful when a client needs to "narrow" the type of + * a {@code Class} object to pass it to an API that restricts the + * {@code Class} objects that it is willing to accept. A cast would + * generate a compile-time warning, as the correctness of the cast + * could not be checked at runtime (because generic types are implemented + * by erasure). + * + * @return this {@code Class} object, cast to represent a subclass of + * the specified class object. + * @throws ClassCastException if this {@code Class} object does not + * represent a subclass of the specified class (here "subclass" includes + * the class itself). + * @since 1.5 + */ + public Class asSubclass(Class clazz) { + if (clazz.isAssignableFrom(this)) + return (Class) this; + else + throw new ClassCastException(this.toString()); + } + + /** + * @throws NullPointerException {@inheritDoc} + * @since 1.5 + */ + public A getAnnotation(Class annotationClass) { + throw new UnsupportedOperationException(); + } + + /** + * @throws NullPointerException {@inheritDoc} + * @since 1.5 + */ + public boolean isAnnotationPresent( + Class annotationClass) { + if (annotationClass == null) + throw new NullPointerException(); + + return getAnnotation(annotationClass) != null; + } + + + /** + * @since 1.5 + */ + public Annotation[] getAnnotations() { + throw new UnsupportedOperationException(); + } + + /** + * @since 1.5 + */ + public Annotation[] getDeclaredAnnotations() { + throw new UnsupportedOperationException(); + } + + static Class getPrimitiveClass(String type) { + // XXX + return Object.class; + } + + public boolean desiredAssertionStatus() { + return false; + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/ClassCastException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/ClassCastException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown to indicate that the code has attempted to cast an object + * to a subclass of which it is not an instance. For example, the + * following code generates a ClassCastException: + *

+ *     Object x = new Integer(0);
+ *     System.out.println((String)x);
+ * 
+ * + * @author unascribed + * @since JDK1.0 + */ +public +class ClassCastException extends RuntimeException { + private static final long serialVersionUID = -9223365651070458532L; + + /** + * Constructs a ClassCastException with no detail message. + */ + public ClassCastException() { + super(); + } + + /** + * Constructs a ClassCastException with the specified + * detail message. + * + * @param s the detail message. + */ + public ClassCastException(String s) { + super(s); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/ClassNotFoundException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/ClassNotFoundException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,125 @@ +/* + * Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown when an application tries to load in a class through its + * string name using: + *
    + *
  • The forName method in class Class. + *
  • The findSystemClass method in class + * ClassLoader . + *
  • The loadClass method in class ClassLoader. + *
+ *

+ * but no definition for the class with the specified name could be found. + * + *

As of release 1.4, this exception has been retrofitted to conform to + * the general purpose exception-chaining mechanism. The "optional exception + * that was raised while loading the class" that may be provided at + * construction time and accessed via the {@link #getException()} method is + * now known as the cause, and may be accessed via the {@link + * Throwable#getCause()} method, as well as the aforementioned "legacy method." + * + * @author unascribed + * @see java.lang.Class#forName(java.lang.String) + * @see java.lang.ClassLoader#findSystemClass(java.lang.String) + * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean) + * @since JDK1.0 + */ +public class ClassNotFoundException extends ReflectiveOperationException { + /** + * use serialVersionUID from JDK 1.1.X for interoperability + */ + private static final long serialVersionUID = 9176873029745254542L; + + /** + * This field holds the exception ex if the + * ClassNotFoundException(String s, Throwable ex) constructor was + * used to instantiate the object + * @serial + * @since 1.2 + */ + private Throwable ex; + + /** + * Constructs a ClassNotFoundException with no detail message. + */ + public ClassNotFoundException() { + super((Throwable)null); // Disallow initCause + } + + /** + * Constructs a ClassNotFoundException with the + * specified detail message. + * + * @param s the detail message. + */ + public ClassNotFoundException(String s) { + super(s, null); // Disallow initCause + } + + /** + * Constructs a ClassNotFoundException with the + * specified detail message and optional exception that was + * raised while loading the class. + * + * @param s the detail message + * @param ex the exception that was raised while loading the class + * @since 1.2 + */ + public ClassNotFoundException(String s, Throwable ex) { + super(s, null); // Disallow initCause + this.ex = ex; + } + + /** + * Returns the exception that was raised if an error occurred while + * attempting to load the class. Otherwise, returns null. + * + *

This method predates the general-purpose exception chaining facility. + * The {@link Throwable#getCause()} method is now the preferred means of + * obtaining this information. + * + * @return the Exception that was raised while loading a class + * @since 1.2 + */ + public Throwable getException() { + return ex; + } + + /** + * Returns the cause of this exception (the exception that was raised + * if an error occurred while attempting to load the class; otherwise + * null). + * + * @return the cause of this exception. + * @since 1.4 + */ + public Throwable getCause() { + return ex; + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/CloneNotSupportedException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/CloneNotSupportedException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown to indicate that the clone method in class + * Object has been called to clone an object, but that + * the object's class does not implement the Cloneable + * interface. + *

+ * Applications that override the clone method can also + * throw this exception to indicate that an object could not or + * should not be cloned. + * + * @author unascribed + * @see java.lang.Cloneable + * @see java.lang.Object#clone() + * @since JDK1.0 + */ + +public +class CloneNotSupportedException extends Exception { + private static final long serialVersionUID = 5195511250079656443L; + + /** + * Constructs a CloneNotSupportedException with no + * detail message. + */ + public CloneNotSupportedException() { + super(); + } + + /** + * Constructs a CloneNotSupportedException with the + * specified detail message. + * + * @param s the detail message. + */ + public CloneNotSupportedException(String s) { + super(s); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Comparable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Comparable.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,137 @@ +/* + * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * This interface imposes a total ordering on the objects of each class that + * implements it. This ordering is referred to as the class's natural + * ordering, and the class's compareTo method is referred to as + * its natural comparison method.

+ * + * Lists (and arrays) of objects that implement this interface can be sorted + * automatically by {@link Collections#sort(List) Collections.sort} (and + * {@link Arrays#sort(Object[]) Arrays.sort}). Objects that implement this + * interface can be used as keys in a {@linkplain SortedMap sorted map} or as + * elements in a {@linkplain SortedSet sorted set}, without the need to + * specify a {@linkplain Comparator comparator}.

+ * + * The natural ordering for a class C is said to be consistent + * with equals if and only if e1.compareTo(e2) == 0 has + * the same boolean value as e1.equals(e2) for every + * e1 and e2 of class C. Note that null + * is not an instance of any class, and e.compareTo(null) should + * throw a NullPointerException even though e.equals(null) + * returns false.

+ * + * It is strongly recommended (though not required) that natural orderings be + * consistent with equals. This is so because sorted sets (and sorted maps) + * without explicit comparators behave "strangely" when they are used with + * elements (or keys) whose natural ordering is inconsistent with equals. In + * particular, such a sorted set (or sorted map) violates the general contract + * for set (or map), which is defined in terms of the equals + * method.

+ * + * For example, if one adds two keys a and b such that + * (!a.equals(b) && a.compareTo(b) == 0) to a sorted + * set that does not use an explicit comparator, the second add + * operation returns false (and the size of the sorted set does not increase) + * because a and b are equivalent from the sorted set's + * perspective.

+ * + * Virtually all Java core classes that implement Comparable have natural + * orderings that are consistent with equals. One exception is + * java.math.BigDecimal, whose natural ordering equates + * BigDecimal objects with equal values and different precisions + * (such as 4.0 and 4.00).

+ * + * For the mathematically inclined, the relation that defines + * the natural ordering on a given class C is:

+ *       {(x, y) such that x.compareTo(y) <= 0}.
+ * 
The quotient for this total order is:
+ *       {(x, y) such that x.compareTo(y) == 0}.
+ * 
+ * + * It follows immediately from the contract for compareTo that the + * quotient is an equivalence relation on C, and that the + * natural ordering is a total order on C. When we say that a + * class's natural ordering is consistent with equals, we mean that the + * quotient for the natural ordering is the equivalence relation defined by + * the class's {@link Object#equals(Object) equals(Object)} method:
+ *     {(x, y) such that x.equals(y)}. 

+ * + * This interface is a member of the + * + * Java Collections Framework. + * + * @param the type of objects that this object may be compared to + * + * @author Josh Bloch + * @see java.util.Comparator + * @since 1.2 + */ + +public interface Comparable { + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * + *

The implementor must ensure sgn(x.compareTo(y)) == + * -sgn(y.compareTo(x)) for all x and y. (This + * implies that x.compareTo(y) must throw an exception iff + * y.compareTo(x) throws an exception.) + * + *

The implementor must also ensure that the relation is transitive: + * (x.compareTo(y)>0 && y.compareTo(z)>0) implies + * x.compareTo(z)>0. + * + *

Finally, the implementor must ensure that x.compareTo(y)==0 + * implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for + * all z. + * + *

It is strongly recommended, but not strictly required that + * (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any + * class that implements the Comparable interface and violates + * this condition should clearly indicate this fact. The recommended + * language is "Note: this class has a natural ordering that is + * inconsistent with equals." + * + *

In the foregoing description, the notation + * sgn(expression) designates the mathematical + * signum function, which is defined to return one of -1, + * 0, or 1 according to whether the value of + * expression is negative, zero or positive. + * + * @param o the object to be compared. + * @return a negative integer, zero, or a positive integer as this object + * is less than, equal to, or greater than the specified object. + * + * @throws NullPointerException if the specified object is null + * @throws ClassCastException if the specified object's type prevents it + * from being compared to this object. + */ + public int compareTo(T o); +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Deprecated.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Deprecated.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +import java.lang.annotation.*; +import static java.lang.annotation.ElementType.*; + +/** + * A program element annotated @Deprecated is one that programmers + * are discouraged from using, typically because it is dangerous, + * or because a better alternative exists. Compilers warn when a + * deprecated program element is used or overridden in non-deprecated code. + * + * @author Neal Gafter + * @since 1.5 + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(value={CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE}) +public @interface Deprecated { +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Double.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Double.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,988 @@ +/* + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * The {@code Double} class wraps a value of the primitive type + * {@code double} in an object. An object of type + * {@code Double} contains a single field whose type is + * {@code double}. + * + *

In addition, this class provides several methods for converting a + * {@code double} to a {@code String} and a + * {@code String} to a {@code double}, as well as other + * constants and methods useful when dealing with a + * {@code double}. + * + * @author Lee Boynton + * @author Arthur van Hoff + * @author Joseph D. Darcy + * @since JDK1.0 + */ +public final class Double extends Number implements Comparable { + /** + * A constant holding the positive infinity of type + * {@code double}. It is equal to the value returned by + * {@code Double.longBitsToDouble(0x7ff0000000000000L)}. + */ + public static final double POSITIVE_INFINITY = 1.0 / 0.0; + + /** + * A constant holding the negative infinity of type + * {@code double}. It is equal to the value returned by + * {@code Double.longBitsToDouble(0xfff0000000000000L)}. + */ + public static final double NEGATIVE_INFINITY = -1.0 / 0.0; + + /** + * A constant holding a Not-a-Number (NaN) value of type + * {@code double}. It is equivalent to the value returned by + * {@code Double.longBitsToDouble(0x7ff8000000000000L)}. + */ + public static final double NaN = 0.0d / 0.0; + + /** + * A constant holding the largest positive finite value of type + * {@code double}, + * (2-2-52)·21023. It is equal to + * the hexadecimal floating-point literal + * {@code 0x1.fffffffffffffP+1023} and also equal to + * {@code Double.longBitsToDouble(0x7fefffffffffffffL)}. + */ + public static final double MAX_VALUE = 0x1.fffffffffffffP+1023; // 1.7976931348623157e+308 + + /** + * A constant holding the smallest positive normal value of type + * {@code double}, 2-1022. It is equal to the + * hexadecimal floating-point literal {@code 0x1.0p-1022} and also + * equal to {@code Double.longBitsToDouble(0x0010000000000000L)}. + * + * @since 1.6 + */ + public static final double MIN_NORMAL = 0x1.0p-1022; // 2.2250738585072014E-308 + + /** + * A constant holding the smallest positive nonzero value of type + * {@code double}, 2-1074. It is equal to the + * hexadecimal floating-point literal + * {@code 0x0.0000000000001P-1022} and also equal to + * {@code Double.longBitsToDouble(0x1L)}. + */ + public static final double MIN_VALUE = 0x0.0000000000001P-1022; // 4.9e-324 + + /** + * Maximum exponent a finite {@code double} variable may have. + * It is equal to the value returned by + * {@code Math.getExponent(Double.MAX_VALUE)}. + * + * @since 1.6 + */ + public static final int MAX_EXPONENT = 1023; + + /** + * Minimum exponent a normalized {@code double} variable may + * have. It is equal to the value returned by + * {@code Math.getExponent(Double.MIN_NORMAL)}. + * + * @since 1.6 + */ + public static final int MIN_EXPONENT = -1022; + + /** + * The number of bits used to represent a {@code double} value. + * + * @since 1.5 + */ + public static final int SIZE = 64; + + /** + * The {@code Class} instance representing the primitive type + * {@code double}. + * + * @since JDK1.1 + */ + public static final Class TYPE = (Class) Class.getPrimitiveClass("double"); + + /** + * Returns a string representation of the {@code double} + * argument. All characters mentioned below are ASCII characters. + *

    + *
  • If the argument is NaN, the result is the string + * "{@code NaN}". + *
  • Otherwise, the result is a string that represents the sign and + * magnitude (absolute value) of the argument. If the sign is negative, + * the first character of the result is '{@code -}' + * ('\u002D'); if the sign is positive, no sign character + * appears in the result. As for the magnitude m: + *
      + *
    • If m is infinity, it is represented by the characters + * {@code "Infinity"}; thus, positive infinity produces the result + * {@code "Infinity"} and negative infinity produces the result + * {@code "-Infinity"}. + * + *
    • If m is zero, it is represented by the characters + * {@code "0.0"}; thus, negative zero produces the result + * {@code "-0.0"} and positive zero produces the result + * {@code "0.0"}. + * + *
    • If m is greater than or equal to 10-3 but less + * than 107, then it is represented as the integer part of + * m, in decimal form with no leading zeroes, followed by + * '{@code .}' ('\u002E'), followed by one or + * more decimal digits representing the fractional part of m. + * + *
    • If m is less than 10-3 or greater than or + * equal to 107, then it is represented in so-called + * "computerized scientific notation." Let n be the unique + * integer such that 10nm {@literal <} + * 10n+1; then let a be the + * mathematically exact quotient of m and + * 10n so that 1 ≤ a {@literal <} 10. The + * magnitude is then represented as the integer part of a, + * as a single decimal digit, followed by '{@code .}' + * ('\u002E'), followed by decimal digits + * representing the fractional part of a, followed by the + * letter '{@code E}' ('\u0045'), followed + * by a representation of n as a decimal integer, as + * produced by the method {@link Integer#toString(int)}. + *
    + *
+ * How many digits must be printed for the fractional part of + * m or a? There must be at least one digit to represent + * the fractional part, and beyond that as many, but only as many, more + * digits as are needed to uniquely distinguish the argument value from + * adjacent values of type {@code double}. That is, suppose that + * x is the exact mathematical value represented by the decimal + * representation produced by this method for a finite nonzero argument + * d. Then d must be the {@code double} value nearest + * to x; or if two {@code double} values are equally close + * to x, then d must be one of them and the least + * significant bit of the significand of d must be {@code 0}. + * + *

To create localized string representations of a floating-point + * value, use subclasses of {@link java.text.NumberFormat}. + * + * @param d the {@code double} to be converted. + * @return a string representation of the argument. + */ + public static String toString(double d) { + throw new UnsupportedOperationException(); + } + + /** + * Returns a hexadecimal string representation of the + * {@code double} argument. All characters mentioned below + * are ASCII characters. + * + *

    + *
  • If the argument is NaN, the result is the string + * "{@code NaN}". + *
  • Otherwise, the result is a string that represents the sign + * and magnitude of the argument. If the sign is negative, the + * first character of the result is '{@code -}' + * ('\u002D'); if the sign is positive, no sign + * character appears in the result. As for the magnitude m: + * + *
      + *
    • If m is infinity, it is represented by the string + * {@code "Infinity"}; thus, positive infinity produces the + * result {@code "Infinity"} and negative infinity produces + * the result {@code "-Infinity"}. + * + *
    • If m is zero, it is represented by the string + * {@code "0x0.0p0"}; thus, negative zero produces the result + * {@code "-0x0.0p0"} and positive zero produces the result + * {@code "0x0.0p0"}. + * + *
    • If m is a {@code double} value with a + * normalized representation, substrings are used to represent the + * significand and exponent fields. The significand is + * represented by the characters {@code "0x1."} + * followed by a lowercase hexadecimal representation of the rest + * of the significand as a fraction. Trailing zeros in the + * hexadecimal representation are removed unless all the digits + * are zero, in which case a single zero is used. Next, the + * exponent is represented by {@code "p"} followed + * by a decimal string of the unbiased exponent as if produced by + * a call to {@link Integer#toString(int) Integer.toString} on the + * exponent value. + * + *
    • If m is a {@code double} value with a subnormal + * representation, the significand is represented by the + * characters {@code "0x0."} followed by a + * hexadecimal representation of the rest of the significand as a + * fraction. Trailing zeros in the hexadecimal representation are + * removed. Next, the exponent is represented by + * {@code "p-1022"}. Note that there must be at + * least one nonzero digit in a subnormal significand. + * + *
    + * + *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *

Examples

Floating-point ValueHexadecimal String
{@code 1.0} {@code 0x1.0p0}
{@code -1.0} {@code -0x1.0p0}
{@code 2.0} {@code 0x1.0p1}
{@code 3.0} {@code 0x1.8p1}
{@code 0.5} {@code 0x1.0p-1}
{@code 0.25} {@code 0x1.0p-2}
{@code Double.MAX_VALUE}{@code 0x1.fffffffffffffp1023}
{@code Minimum Normal Value}{@code 0x1.0p-1022}
{@code Maximum Subnormal Value}{@code 0x0.fffffffffffffp-1022}
{@code Double.MIN_VALUE}{@code 0x0.0000000000001p-1022}
+ * @param d the {@code double} to be converted. + * @return a hex string representation of the argument. + * @since 1.5 + * @author Joseph D. Darcy + */ + public static String toHexString(double d) { + throw new UnsupportedOperationException(); +// /* +// * Modeled after the "a" conversion specifier in C99, section +// * 7.19.6.1; however, the output of this method is more +// * tightly specified. +// */ +// if (!FpUtils.isFinite(d) ) +// // For infinity and NaN, use the decimal output. +// return Double.toString(d); +// else { +// // Initialized to maximum size of output. +// StringBuffer answer = new StringBuffer(24); +// +// if (FpUtils.rawCopySign(1.0, d) == -1.0) // value is negative, +// answer.append("-"); // so append sign info +// +// answer.append("0x"); +// +// d = Math.abs(d); +// +// if(d == 0.0) { +// answer.append("0.0p0"); +// } +// else { +// boolean subnormal = (d < DoubleConsts.MIN_NORMAL); +// +// // Isolate significand bits and OR in a high-order bit +// // so that the string representation has a known +// // length. +// long signifBits = (Double.doubleToLongBits(d) +// & DoubleConsts.SIGNIF_BIT_MASK) | +// 0x1000000000000000L; +// +// // Subnormal values have a 0 implicit bit; normal +// // values have a 1 implicit bit. +// answer.append(subnormal ? "0." : "1."); +// +// // Isolate the low-order 13 digits of the hex +// // representation. If all the digits are zero, +// // replace with a single 0; otherwise, remove all +// // trailing zeros. +// String signif = Long.toHexString(signifBits).substring(3,16); +// answer.append(signif.equals("0000000000000") ? // 13 zeros +// "0": +// signif.replaceFirst("0{1,12}$", "")); +// +// // If the value is subnormal, use the E_min exponent +// // value for double; otherwise, extract and report d's +// // exponent (the representation of a subnormal uses +// // E_min -1). +// answer.append("p" + (subnormal ? +// DoubleConsts.MIN_EXPONENT: +// FpUtils.getExponent(d) )); +// } +// return answer.toString(); +// } + } + + /** + * Returns a {@code Double} object holding the + * {@code double} value represented by the argument string + * {@code s}. + * + *

If {@code s} is {@code null}, then a + * {@code NullPointerException} is thrown. + * + *

Leading and trailing whitespace characters in {@code s} + * are ignored. Whitespace is removed as if by the {@link + * String#trim} method; that is, both ASCII space and control + * characters are removed. The rest of {@code s} should + * constitute a FloatValue as described by the lexical + * syntax rules: + * + *

+ *
+ *
FloatValue: + *
Signopt {@code NaN} + *
Signopt {@code Infinity} + *
Signopt FloatingPointLiteral + *
Signopt HexFloatingPointLiteral + *
SignedInteger + *
+ * + *

+ * + *

+ *
HexFloatingPointLiteral: + *
HexSignificand BinaryExponent FloatTypeSuffixopt + *
+ * + *

+ * + *

+ *
HexSignificand: + *
HexNumeral + *
HexNumeral {@code .} + *
{@code 0x} HexDigitsopt + * {@code .} HexDigits + *
{@code 0X} HexDigitsopt + * {@code .} HexDigits + *
+ * + *

+ * + *

+ *
BinaryExponent: + *
BinaryExponentIndicator SignedInteger + *
+ * + *

+ * + *

+ *
BinaryExponentIndicator: + *
{@code p} + *
{@code P} + *
+ * + *
+ * + * where Sign, FloatingPointLiteral, + * HexNumeral, HexDigits, SignedInteger and + * FloatTypeSuffix are as defined in the lexical structure + * sections of + * The Java™ Language Specification, + * except that underscores are not accepted between digits. + * If {@code s} does not have the form of + * a FloatValue, then a {@code NumberFormatException} + * is thrown. Otherwise, {@code s} is regarded as + * representing an exact decimal value in the usual + * "computerized scientific notation" or as an exact + * hexadecimal value; this exact numerical value is then + * conceptually converted to an "infinitely precise" + * binary value that is then rounded to type {@code double} + * by the usual round-to-nearest rule of IEEE 754 floating-point + * arithmetic, which includes preserving the sign of a zero + * value. + * + * Note that the round-to-nearest rule also implies overflow and + * underflow behaviour; if the exact value of {@code s} is large + * enough in magnitude (greater than or equal to ({@link + * #MAX_VALUE} + {@link Math#ulp(double) ulp(MAX_VALUE)}/2), + * rounding to {@code double} will result in an infinity and if the + * exact value of {@code s} is small enough in magnitude (less + * than or equal to {@link #MIN_VALUE}/2), rounding to float will + * result in a zero. + * + * Finally, after rounding a {@code Double} object representing + * this {@code double} value is returned. + * + *

To interpret localized string representations of a + * floating-point value, use subclasses of {@link + * java.text.NumberFormat}. + * + *

Note that trailing format specifiers, specifiers that + * determine the type of a floating-point literal + * ({@code 1.0f} is a {@code float} value; + * {@code 1.0d} is a {@code double} value), do + * not influence the results of this method. In other + * words, the numerical value of the input string is converted + * directly to the target floating-point type. The two-step + * sequence of conversions, string to {@code float} followed + * by {@code float} to {@code double}, is not + * equivalent to converting a string directly to + * {@code double}. For example, the {@code float} + * literal {@code 0.1f} is equal to the {@code double} + * value {@code 0.10000000149011612}; the {@code float} + * literal {@code 0.1f} represents a different numerical + * value than the {@code double} literal + * {@code 0.1}. (The numerical value 0.1 cannot be exactly + * represented in a binary floating-point number.) + * + *

To avoid calling this method on an invalid string and having + * a {@code NumberFormatException} be thrown, the regular + * expression below can be used to screen the input string: + * + * + *

+     *  final String Digits     = "(\\p{Digit}+)";
+     *  final String HexDigits  = "(\\p{XDigit}+)";
+     *  // an exponent is 'e' or 'E' followed by an optionally
+     *  // signed decimal integer.
+     *  final String Exp        = "[eE][+-]?"+Digits;
+     *  final String fpRegex    =
+     *      ("[\\x00-\\x20]*"+  // Optional leading "whitespace"
+     *       "[+-]?(" + // Optional sign character
+     *       "NaN|" +           // "NaN" string
+     *       "Infinity|" +      // "Infinity" string
+     *
+     *       // A decimal floating-point string representing a finite positive
+     *       // number without a leading sign has at most five basic pieces:
+     *       // Digits . Digits ExponentPart FloatTypeSuffix
+     *       //
+     *       // Since this method allows integer-only strings as input
+     *       // in addition to strings of floating-point literals, the
+     *       // two sub-patterns below are simplifications of the grammar
+     *       // productions from section 3.10.2 of
+     *       // The Java™ Language Specification.
+     *
+     *       // Digits ._opt Digits_opt ExponentPart_opt FloatTypeSuffix_opt
+     *       "((("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+
+     *
+     *       // . Digits ExponentPart_opt FloatTypeSuffix_opt
+     *       "(\\.("+Digits+")("+Exp+")?)|"+
+     *
+     *       // Hexadecimal strings
+     *       "((" +
+     *        // 0[xX] HexDigits ._opt BinaryExponent FloatTypeSuffix_opt
+     *        "(0[xX]" + HexDigits + "(\\.)?)|" +
+     *
+     *        // 0[xX] HexDigits_opt . HexDigits BinaryExponent FloatTypeSuffix_opt
+     *        "(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" +
+     *
+     *        ")[pP][+-]?" + Digits + "))" +
+     *       "[fFdD]?))" +
+     *       "[\\x00-\\x20]*");// Optional trailing "whitespace"
+     *
+     *  if (Pattern.matches(fpRegex, myString))
+     *      Double.valueOf(myString); // Will not throw NumberFormatException
+     *  else {
+     *      // Perform suitable alternative action
+     *  }
+     * 
+ * + * + * @param s the string to be parsed. + * @return a {@code Double} object holding the value + * represented by the {@code String} argument. + * @throws NumberFormatException if the string does not contain a + * parsable number. + */ + public static Double valueOf(String s) throws NumberFormatException { + throw new UnsupportedOperationException(); +// return new Double(FloatingDecimal.readJavaFormatString(s).doubleValue()); + } + + /** + * Returns a {@code Double} instance representing the specified + * {@code double} value. + * If a new {@code Double} instance is not required, this method + * should generally be used in preference to the constructor + * {@link #Double(double)}, as this method is likely to yield + * significantly better space and time performance by caching + * frequently requested values. + * + * @param d a double value. + * @return a {@code Double} instance representing {@code d}. + * @since 1.5 + */ + public static Double valueOf(double d) { + return new Double(d); + } + + /** + * Returns a new {@code double} initialized to the value + * represented by the specified {@code String}, as performed + * by the {@code valueOf} method of class + * {@code Double}. + * + * @param s the string to be parsed. + * @return the {@code double} value represented by the string + * argument. + * @throws NullPointerException if the string is null + * @throws NumberFormatException if the string does not contain + * a parsable {@code double}. + * @see java.lang.Double#valueOf(String) + * @since 1.2 + */ + public static double parseDouble(String s) throws NumberFormatException { + throw new UnsupportedOperationException(); +// return FloatingDecimal.readJavaFormatString(s).doubleValue(); + } + + /** + * Returns {@code true} if the specified number is a + * Not-a-Number (NaN) value, {@code false} otherwise. + * + * @param v the value to be tested. + * @return {@code true} if the value of the argument is NaN; + * {@code false} otherwise. + */ + static public boolean isNaN(double v) { + return (v != v); + } + + /** + * Returns {@code true} if the specified number is infinitely + * large in magnitude, {@code false} otherwise. + * + * @param v the value to be tested. + * @return {@code true} if the value of the argument is positive + * infinity or negative infinity; {@code false} otherwise. + */ + static public boolean isInfinite(double v) { + return (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY); + } + + /** + * The value of the Double. + * + * @serial + */ + private final double value; + + /** + * Constructs a newly allocated {@code Double} object that + * represents the primitive {@code double} argument. + * + * @param value the value to be represented by the {@code Double}. + */ + public Double(double value) { + this.value = value; + } + + /** + * Constructs a newly allocated {@code Double} object that + * represents the floating-point value of type {@code double} + * represented by the string. The string is converted to a + * {@code double} value as if by the {@code valueOf} method. + * + * @param s a string to be converted to a {@code Double}. + * @throws NumberFormatException if the string does not contain a + * parsable number. + * @see java.lang.Double#valueOf(java.lang.String) + */ + public Double(String s) throws NumberFormatException { + // REMIND: this is inefficient + this(valueOf(s).doubleValue()); + } + + /** + * Returns {@code true} if this {@code Double} value is + * a Not-a-Number (NaN), {@code false} otherwise. + * + * @return {@code true} if the value represented by this object is + * NaN; {@code false} otherwise. + */ + public boolean isNaN() { + return isNaN(value); + } + + /** + * Returns {@code true} if this {@code Double} value is + * infinitely large in magnitude, {@code false} otherwise. + * + * @return {@code true} if the value represented by this object is + * positive infinity or negative infinity; + * {@code false} otherwise. + */ + public boolean isInfinite() { + return isInfinite(value); + } + + /** + * Returns a string representation of this {@code Double} object. + * The primitive {@code double} value represented by this + * object is converted to a string exactly as if by the method + * {@code toString} of one argument. + * + * @return a {@code String} representation of this object. + * @see java.lang.Double#toString(double) + */ + public String toString() { + return toString(value); + } + + /** + * Returns the value of this {@code Double} as a {@code byte} (by + * casting to a {@code byte}). + * + * @return the {@code double} value represented by this object + * converted to type {@code byte} + * @since JDK1.1 + */ + public byte byteValue() { + return (byte)value; + } + + /** + * Returns the value of this {@code Double} as a + * {@code short} (by casting to a {@code short}). + * + * @return the {@code double} value represented by this object + * converted to type {@code short} + * @since JDK1.1 + */ + public short shortValue() { + return (short)value; + } + + /** + * Returns the value of this {@code Double} as an + * {@code int} (by casting to type {@code int}). + * + * @return the {@code double} value represented by this object + * converted to type {@code int} + */ + public int intValue() { + return (int)value; + } + + /** + * Returns the value of this {@code Double} as a + * {@code long} (by casting to type {@code long}). + * + * @return the {@code double} value represented by this object + * converted to type {@code long} + */ + public long longValue() { + return (long)value; + } + + /** + * Returns the {@code float} value of this + * {@code Double} object. + * + * @return the {@code double} value represented by this object + * converted to type {@code float} + * @since JDK1.0 + */ + public float floatValue() { + return (float)value; + } + + /** + * Returns the {@code double} value of this + * {@code Double} object. + * + * @return the {@code double} value represented by this object + */ + public double doubleValue() { + return (double)value; + } + + /** + * Returns a hash code for this {@code Double} object. The + * result is the exclusive OR of the two halves of the + * {@code long} integer bit representation, exactly as + * produced by the method {@link #doubleToLongBits(double)}, of + * the primitive {@code double} value represented by this + * {@code Double} object. That is, the hash code is the value + * of the expression: + * + *
+ * {@code (int)(v^(v>>>32))} + *
+ * + * where {@code v} is defined by: + * + *
+ * {@code long v = Double.doubleToLongBits(this.doubleValue());} + *
+ * + * @return a {@code hash code} value for this object. + */ + public int hashCode() { + long bits = doubleToLongBits(value); + return (int)(bits ^ (bits >>> 32)); + } + + /** + * Compares this object against the specified object. The result + * is {@code true} if and only if the argument is not + * {@code null} and is a {@code Double} object that + * represents a {@code double} that has the same value as the + * {@code double} represented by this object. For this + * purpose, two {@code double} values are considered to be + * the same if and only if the method {@link + * #doubleToLongBits(double)} returns the identical + * {@code long} value when applied to each. + * + *

Note that in most cases, for two instances of class + * {@code Double}, {@code d1} and {@code d2}, the + * value of {@code d1.equals(d2)} is {@code true} if and + * only if + * + *

+ * {@code d1.doubleValue() == d2.doubleValue()} + *
+ * + *

also has the value {@code true}. However, there are two + * exceptions: + *

    + *
  • If {@code d1} and {@code d2} both represent + * {@code Double.NaN}, then the {@code equals} method + * returns {@code true}, even though + * {@code Double.NaN==Double.NaN} has the value + * {@code false}. + *
  • If {@code d1} represents {@code +0.0} while + * {@code d2} represents {@code -0.0}, or vice versa, + * the {@code equal} test has the value {@code false}, + * even though {@code +0.0==-0.0} has the value {@code true}. + *
+ * This definition allows hash tables to operate properly. + * @param obj the object to compare with. + * @return {@code true} if the objects are the same; + * {@code false} otherwise. + * @see java.lang.Double#doubleToLongBits(double) + */ + public boolean equals(Object obj) { + return (obj instanceof Double) + && (doubleToLongBits(((Double)obj).value) == + doubleToLongBits(value)); + } + + /** + * Returns a representation of the specified floating-point value + * according to the IEEE 754 floating-point "double + * format" bit layout. + * + *

Bit 63 (the bit that is selected by the mask + * {@code 0x8000000000000000L}) represents the sign of the + * floating-point number. Bits + * 62-52 (the bits that are selected by the mask + * {@code 0x7ff0000000000000L}) represent the exponent. Bits 51-0 + * (the bits that are selected by the mask + * {@code 0x000fffffffffffffL}) represent the significand + * (sometimes called the mantissa) of the floating-point number. + * + *

If the argument is positive infinity, the result is + * {@code 0x7ff0000000000000L}. + * + *

If the argument is negative infinity, the result is + * {@code 0xfff0000000000000L}. + * + *

If the argument is NaN, the result is + * {@code 0x7ff8000000000000L}. + * + *

In all cases, the result is a {@code long} integer that, when + * given to the {@link #longBitsToDouble(long)} method, will produce a + * floating-point value the same as the argument to + * {@code doubleToLongBits} (except all NaN values are + * collapsed to a single "canonical" NaN value). + * + * @param value a {@code double} precision floating-point number. + * @return the bits that represent the floating-point number. + */ + public static long doubleToLongBits(double value) { + throw new UnsupportedOperationException(); +// long result = doubleToRawLongBits(value); +// // Check for NaN based on values of bit fields, maximum +// // exponent and nonzero significand. +// if ( ((result & DoubleConsts.EXP_BIT_MASK) == +// DoubleConsts.EXP_BIT_MASK) && +// (result & DoubleConsts.SIGNIF_BIT_MASK) != 0L) +// result = 0x7ff8000000000000L; +// return result; + } + + /** + * Returns a representation of the specified floating-point value + * according to the IEEE 754 floating-point "double + * format" bit layout, preserving Not-a-Number (NaN) values. + * + *

Bit 63 (the bit that is selected by the mask + * {@code 0x8000000000000000L}) represents the sign of the + * floating-point number. Bits + * 62-52 (the bits that are selected by the mask + * {@code 0x7ff0000000000000L}) represent the exponent. Bits 51-0 + * (the bits that are selected by the mask + * {@code 0x000fffffffffffffL}) represent the significand + * (sometimes called the mantissa) of the floating-point number. + * + *

If the argument is positive infinity, the result is + * {@code 0x7ff0000000000000L}. + * + *

If the argument is negative infinity, the result is + * {@code 0xfff0000000000000L}. + * + *

If the argument is NaN, the result is the {@code long} + * integer representing the actual NaN value. Unlike the + * {@code doubleToLongBits} method, + * {@code doubleToRawLongBits} does not collapse all the bit + * patterns encoding a NaN to a single "canonical" NaN + * value. + * + *

In all cases, the result is a {@code long} integer that, + * when given to the {@link #longBitsToDouble(long)} method, will + * produce a floating-point value the same as the argument to + * {@code doubleToRawLongBits}. + * + * @param value a {@code double} precision floating-point number. + * @return the bits that represent the floating-point number. + * @since 1.3 + */ + public static native long doubleToRawLongBits(double value); + + /** + * Returns the {@code double} value corresponding to a given + * bit representation. + * The argument is considered to be a representation of a + * floating-point value according to the IEEE 754 floating-point + * "double format" bit layout. + * + *

If the argument is {@code 0x7ff0000000000000L}, the result + * is positive infinity. + * + *

If the argument is {@code 0xfff0000000000000L}, the result + * is negative infinity. + * + *

If the argument is any value in the range + * {@code 0x7ff0000000000001L} through + * {@code 0x7fffffffffffffffL} or in the range + * {@code 0xfff0000000000001L} through + * {@code 0xffffffffffffffffL}, the result is a NaN. No IEEE + * 754 floating-point operation provided by Java can distinguish + * between two NaN values of the same type with different bit + * patterns. Distinct values of NaN are only distinguishable by + * use of the {@code Double.doubleToRawLongBits} method. + * + *

In all other cases, let s, e, and m be three + * values that can be computed from the argument: + * + *

+     * int s = ((bits >> 63) == 0) ? 1 : -1;
+     * int e = (int)((bits >> 52) & 0x7ffL);
+     * long m = (e == 0) ?
+     *                 (bits & 0xfffffffffffffL) << 1 :
+     *                 (bits & 0xfffffffffffffL) | 0x10000000000000L;
+     * 
+ * + * Then the floating-point result equals the value of the mathematical + * expression s·m·2e-1075. + * + *

Note that this method may not be able to return a + * {@code double} NaN with exactly same bit pattern as the + * {@code long} argument. IEEE 754 distinguishes between two + * kinds of NaNs, quiet NaNs and signaling NaNs. The + * differences between the two kinds of NaN are generally not + * visible in Java. Arithmetic operations on signaling NaNs turn + * them into quiet NaNs with a different, but often similar, bit + * pattern. However, on some processors merely copying a + * signaling NaN also performs that conversion. In particular, + * copying a signaling NaN to return it to the calling method + * may perform this conversion. So {@code longBitsToDouble} + * may not be able to return a {@code double} with a + * signaling NaN bit pattern. Consequently, for some + * {@code long} values, + * {@code doubleToRawLongBits(longBitsToDouble(start))} may + * not equal {@code start}. Moreover, which + * particular bit patterns represent signaling NaNs is platform + * dependent; although all NaN bit patterns, quiet or signaling, + * must be in the NaN range identified above. + * + * @param bits any {@code long} integer. + * @return the {@code double} floating-point value with the same + * bit pattern. + */ + public static native double longBitsToDouble(long bits); + + /** + * Compares two {@code Double} objects numerically. There + * are two ways in which comparisons performed by this method + * differ from those performed by the Java language numerical + * comparison operators ({@code <, <=, ==, >=, >}) + * when applied to primitive {@code double} values: + *

  • + * {@code Double.NaN} is considered by this method + * to be equal to itself and greater than all other + * {@code double} values (including + * {@code Double.POSITIVE_INFINITY}). + *
  • + * {@code 0.0d} is considered by this method to be greater + * than {@code -0.0d}. + *
+ * This ensures that the natural ordering of + * {@code Double} objects imposed by this method is consistent + * with equals. + * + * @param anotherDouble the {@code Double} to be compared. + * @return the value {@code 0} if {@code anotherDouble} is + * numerically equal to this {@code Double}; a value + * less than {@code 0} if this {@code Double} + * is numerically less than {@code anotherDouble}; + * and a value greater than {@code 0} if this + * {@code Double} is numerically greater than + * {@code anotherDouble}. + * + * @since 1.2 + */ + public int compareTo(Double anotherDouble) { + return Double.compare(value, anotherDouble.value); + } + + /** + * Compares the two specified {@code double} values. The sign + * of the integer value returned is the same as that of the + * integer that would be returned by the call: + *
+     *    new Double(d1).compareTo(new Double(d2))
+     * 
+ * + * @param d1 the first {@code double} to compare + * @param d2 the second {@code double} to compare + * @return the value {@code 0} if {@code d1} is + * numerically equal to {@code d2}; a value less than + * {@code 0} if {@code d1} is numerically less than + * {@code d2}; and a value greater than {@code 0} + * if {@code d1} is numerically greater than + * {@code d2}. + * @since 1.4 + */ + public static int compare(double d1, double d2) { + if (d1 < d2) + return -1; // Neither val is NaN, thisVal is smaller + if (d1 > d2) + return 1; // Neither val is NaN, thisVal is larger + + // Cannot use doubleToRawLongBits because of possibility of NaNs. + long thisBits = Double.doubleToLongBits(d1); + long anotherBits = Double.doubleToLongBits(d2); + + return (thisBits == anotherBits ? 0 : // Values are equal + (thisBits < anotherBits ? -1 : // (-0.0, 0.0) or (!NaN, NaN) + 1)); // (0.0, -0.0) or (NaN, !NaN) + } + + /** use serialVersionUID from JDK 1.0.2 for interoperability */ + private static final long serialVersionUID = -9172774392245257468L; +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Enum.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Enum.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +import java.io.Serializable; +import java.io.IOException; + +/** + * This is the common base class of all Java language enumeration types. + * + * More information about enums, including descriptions of the + * implicitly declared methods synthesized by the compiler, can be + * found in section 8.9 of + * The Java™ Language Specification. + * + *

Note that when using an enumeration type as the type of a set + * or as the type of the keys in a map, specialized and efficient + * {@linkplain java.util.EnumSet set} and {@linkplain + * java.util.EnumMap map} implementations are available. + * + * @param The enum type subclass + * @author Josh Bloch + * @author Neal Gafter + * @see Class#getEnumConstants() + * @see java.util.EnumSet + * @see java.util.EnumMap + * @since 1.5 + */ +public abstract class Enum> + implements Comparable, Serializable { + /** + * The name of this enum constant, as declared in the enum declaration. + * Most programmers should use the {@link #toString} method rather than + * accessing this field. + */ + private final String name; + + /** + * Returns the name of this enum constant, exactly as declared in its + * enum declaration. + * + * Most programmers should use the {@link #toString} method in + * preference to this one, as the toString method may return + * a more user-friendly name. This method is designed primarily for + * use in specialized situations where correctness depends on getting the + * exact name, which will not vary from release to release. + * + * @return the name of this enum constant + */ + public final String name() { + return name; + } + + /** + * The ordinal of this enumeration constant (its position + * in the enum declaration, where the initial constant is assigned + * an ordinal of zero). + * + * Most programmers will have no use for this field. It is designed + * for use by sophisticated enum-based data structures, such as + * {@link java.util.EnumSet} and {@link java.util.EnumMap}. + */ + private final int ordinal; + + /** + * Returns the ordinal of this enumeration constant (its position + * in its enum declaration, where the initial constant is assigned + * an ordinal of zero). + * + * Most programmers will have no use for this method. It is + * designed for use by sophisticated enum-based data structures, such + * as {@link java.util.EnumSet} and {@link java.util.EnumMap}. + * + * @return the ordinal of this enumeration constant + */ + public final int ordinal() { + return ordinal; + } + + /** + * Sole constructor. Programmers cannot invoke this constructor. + * It is for use by code emitted by the compiler in response to + * enum type declarations. + * + * @param name - The name of this enum constant, which is the identifier + * used to declare it. + * @param ordinal - The ordinal of this enumeration constant (its position + * in the enum declaration, where the initial constant is assigned + * an ordinal of zero). + */ + protected Enum(String name, int ordinal) { + this.name = name; + this.ordinal = ordinal; + } + + /** + * Returns the name of this enum constant, as contained in the + * declaration. This method may be overridden, though it typically + * isn't necessary or desirable. An enum type should override this + * method when a more "programmer-friendly" string form exists. + * + * @return the name of this enum constant + */ + public String toString() { + return name; + } + + /** + * Returns true if the specified object is equal to this + * enum constant. + * + * @param other the object to be compared for equality with this object. + * @return true if the specified object is equal to this + * enum constant. + */ + public final boolean equals(Object other) { + return this==other; + } + + /** + * Returns a hash code for this enum constant. + * + * @return a hash code for this enum constant. + */ + public final int hashCode() { + return super.hashCode(); + } + + /** + * Throws CloneNotSupportedException. This guarantees that enums + * are never cloned, which is necessary to preserve their "singleton" + * status. + * + * @return (never returns) + */ + protected final Object clone() throws CloneNotSupportedException { + throw new CloneNotSupportedException(); + } + + /** + * Compares this enum with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * + * Enum constants are only comparable to other enum constants of the + * same enum type. The natural order implemented by this + * method is the order in which the constants are declared. + */ + public final int compareTo(E o) { + Enum other = (Enum)o; + Enum self = this; + if (self.getClass() != other.getClass() && // optimization + self.getDeclaringClass() != other.getDeclaringClass()) + throw new ClassCastException(); + return self.ordinal - other.ordinal; + } + + /** + * Returns the Class object corresponding to this enum constant's + * enum type. Two enum constants e1 and e2 are of the + * same enum type if and only if + * e1.getDeclaringClass() == e2.getDeclaringClass(). + * (The value returned by this method may differ from the one returned + * by the {@link Object#getClass} method for enum constants with + * constant-specific class bodies.) + * + * @return the Class object corresponding to this enum constant's + * enum type + */ + public final Class getDeclaringClass() { + Class clazz = getClass(); + Class zuper = clazz.getSuperclass(); + return (zuper == Enum.class) ? clazz : zuper; + } + + /** + * Returns the enum constant of the specified enum type with the + * specified name. The name must match exactly an identifier used + * to declare an enum constant in this type. (Extraneous whitespace + * characters are not permitted.) + * + *

Note that for a particular enum type {@code T}, the + * implicitly declared {@code public static T valueOf(String)} + * method on that enum may be used instead of this method to map + * from a name to the corresponding enum constant. All the + * constants of an enum type can be obtained by calling the + * implicit {@code public static T[] values()} method of that + * type. + * + * @param The enum type whose constant is to be returned + * @param enumType the {@code Class} object of the enum type from which + * to return a constant + * @param name the name of the constant to return + * @return the enum constant of the specified enum type with the + * specified name + * @throws IllegalArgumentException if the specified enum type has + * no constant with the specified name, or the specified + * class object does not represent an enum type + * @throws NullPointerException if {@code enumType} or {@code name} + * is null + * @since 1.5 + */ + public static > T valueOf(Class enumType, + String name) { + throw new UnsupportedOperationException(); +// T result = enumType.enumConstantDirectory().get(name); +// if (result != null) +// return result; +// if (name == null) +// throw new NullPointerException("Name is null"); +// throw new IllegalArgumentException( +// "No enum constant " + enumType.getCanonicalName() + "." + name); + } + + /** + * enum classes cannot have finalize methods. + */ + protected final void finalize() { } + + /** + * prevent default deserialization + */ +// private void readObject(ObjectInputStream in) throws IOException, +// ClassNotFoundException { +// throw new InvalidObjectException("can't deserialize enum"); +// } +// +// private void readObjectNoData() throws ObjectStreamException { +// throw new InvalidObjectException("can't deserialize enum"); +// } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Error.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Error.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,128 @@ +/* + * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * An {@code Error} is a subclass of {@code Throwable} + * that indicates serious problems that a reasonable application + * should not try to catch. Most such errors are abnormal conditions. + * The {@code ThreadDeath} error, though a "normal" condition, + * is also a subclass of {@code Error} because most applications + * should not try to catch it. + *

+ * A method is not required to declare in its {@code throws} + * clause any subclasses of {@code Error} that might be thrown + * during the execution of the method but not caught, since these + * errors are abnormal conditions that should never occur. + * + * That is, {@code Error} and its subclasses are regarded as unchecked + * exceptions for the purposes of compile-time checking of exceptions. + * + * @author Frank Yellin + * @see java.lang.ThreadDeath + * @jls 11.2 Compile-Time Checking of Exceptions + * @since JDK1.0 + */ +public class Error extends Throwable { + static final long serialVersionUID = 4980196508277280342L; + + /** + * Constructs a new error with {@code null} as its detail message. + * The cause is not initialized, and may subsequently be initialized by a + * call to {@link #initCause}. + */ + public Error() { + super(); + } + + /** + * Constructs a new error with the specified detail message. The + * cause is not initialized, and may subsequently be initialized by + * a call to {@link #initCause}. + * + * @param message the detail message. The detail message is saved for + * later retrieval by the {@link #getMessage()} method. + */ + public Error(String message) { + super(message); + } + + /** + * Constructs a new error with the specified detail message and + * cause.

Note that the detail message associated with + * {@code cause} is not automatically incorporated in + * this error's detail message. + * + * @param message the detail message (which is saved for later retrieval + * by the {@link #getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A {@code null} value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.4 + */ + public Error(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new error with the specified cause and a detail + * message of {@code (cause==null ? null : cause.toString())} (which + * typically contains the class and detail message of {@code cause}). + * This constructor is useful for errors that are little more than + * wrappers for other throwables. + * + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A {@code null} value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.4 + */ + public Error(Throwable cause) { + super(cause); + } + + /** + * Constructs a new error with the specified detail message, + * cause, suppression enabled or disabled, and writable stack + * trace enabled or disabled. + * + * @param message the detail message. + * @param cause the cause. (A {@code null} value is permitted, + * and indicates that the cause is nonexistent or unknown.) + * @param enableSuppression whether or not suppression is enabled + * or disabled + * @param writableStackTrace whether or not the stack trace should + * be writable + * + * @since 1.7 + */ + protected Error(String message, Throwable cause, + boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Exception.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Exception.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,124 @@ +/* + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * The class {@code Exception} and its subclasses are a form of + * {@code Throwable} that indicates conditions that a reasonable + * application might want to catch. + * + *

The class {@code Exception} and any subclasses that are not also + * subclasses of {@link RuntimeException} are checked + * exceptions. Checked exceptions need to be declared in a + * method or constructor's {@code throws} clause if they can be thrown + * by the execution of the method or constructor and propagate outside + * the method or constructor boundary. + * + * @author Frank Yellin + * @see java.lang.Error + * @jls 11.2 Compile-Time Checking of Exceptions + * @since JDK1.0 + */ +public class Exception extends Throwable { + static final long serialVersionUID = -3387516993124229948L; + + /** + * Constructs a new exception with {@code null} as its detail message. + * The cause is not initialized, and may subsequently be initialized by a + * call to {@link #initCause}. + */ + public Exception() { + super(); + } + + /** + * Constructs a new exception with the specified detail message. The + * cause is not initialized, and may subsequently be initialized by + * a call to {@link #initCause}. + * + * @param message the detail message. The detail message is saved for + * later retrieval by the {@link #getMessage()} method. + */ + public Exception(String message) { + super(message); + } + + /** + * Constructs a new exception with the specified detail message and + * cause.

Note that the detail message associated with + * {@code cause} is not automatically incorporated in + * this exception's detail message. + * + * @param message the detail message (which is saved for later retrieval + * by the {@link #getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.4 + */ + public Exception(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new exception with the specified cause and a detail + * message of (cause==null ? null : cause.toString()) (which + * typically contains the class and detail message of cause). + * This constructor is useful for exceptions that are little more than + * wrappers for other throwables (for example, {@link + * java.security.PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.4 + */ + public Exception(Throwable cause) { + super(cause); + } + + /** + * Constructs a new exception with the specified detail message, + * cause, suppression enabled or disabled, and writable stack + * trace enabled or disabled. + * + * @param message the detail message. + * @param cause the cause. (A {@code null} value is permitted, + * and indicates that the cause is nonexistent or unknown.) + * @param enableSuppression whether or not suppression is enabled + * or disabled + * @param writableStackTrace whether or not the stack trace should + * be writable + * @since 1.7 + */ + protected Exception(String message, Throwable cause, + boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Float.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Float.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,892 @@ +/* + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * The {@code Float} class wraps a value of primitive type + * {@code float} in an object. An object of type + * {@code Float} contains a single field whose type is + * {@code float}. + * + *

In addition, this class provides several methods for converting a + * {@code float} to a {@code String} and a + * {@code String} to a {@code float}, as well as other + * constants and methods useful when dealing with a + * {@code float}. + * + * @author Lee Boynton + * @author Arthur van Hoff + * @author Joseph D. Darcy + * @since JDK1.0 + */ +public final class Float extends Number implements Comparable { + /** + * A constant holding the positive infinity of type + * {@code float}. It is equal to the value returned by + * {@code Float.intBitsToFloat(0x7f800000)}. + */ + public static final float POSITIVE_INFINITY = 1.0f / 0.0f; + + /** + * A constant holding the negative infinity of type + * {@code float}. It is equal to the value returned by + * {@code Float.intBitsToFloat(0xff800000)}. + */ + public static final float NEGATIVE_INFINITY = -1.0f / 0.0f; + + /** + * A constant holding a Not-a-Number (NaN) value of type + * {@code float}. It is equivalent to the value returned by + * {@code Float.intBitsToFloat(0x7fc00000)}. + */ + public static final float NaN = 0.0f / 0.0f; + + /** + * A constant holding the largest positive finite value of type + * {@code float}, (2-2-23)·2127. + * It is equal to the hexadecimal floating-point literal + * {@code 0x1.fffffeP+127f} and also equal to + * {@code Float.intBitsToFloat(0x7f7fffff)}. + */ + public static final float MAX_VALUE = 0x1.fffffeP+127f; // 3.4028235e+38f + + /** + * A constant holding the smallest positive normal value of type + * {@code float}, 2-126. It is equal to the + * hexadecimal floating-point literal {@code 0x1.0p-126f} and also + * equal to {@code Float.intBitsToFloat(0x00800000)}. + * + * @since 1.6 + */ + public static final float MIN_NORMAL = 0x1.0p-126f; // 1.17549435E-38f + + /** + * A constant holding the smallest positive nonzero value of type + * {@code float}, 2-149. It is equal to the + * hexadecimal floating-point literal {@code 0x0.000002P-126f} + * and also equal to {@code Float.intBitsToFloat(0x1)}. + */ + public static final float MIN_VALUE = 0x0.000002P-126f; // 1.4e-45f + + /** + * Maximum exponent a finite {@code float} variable may have. It + * is equal to the value returned by {@code + * Math.getExponent(Float.MAX_VALUE)}. + * + * @since 1.6 + */ + public static final int MAX_EXPONENT = 127; + + /** + * Minimum exponent a normalized {@code float} variable may have. + * It is equal to the value returned by {@code + * Math.getExponent(Float.MIN_NORMAL)}. + * + * @since 1.6 + */ + public static final int MIN_EXPONENT = -126; + + /** + * The number of bits used to represent a {@code float} value. + * + * @since 1.5 + */ + public static final int SIZE = 32; + + /** + * The {@code Class} instance representing the primitive type + * {@code float}. + * + * @since JDK1.1 + */ + public static final Class TYPE = Class.getPrimitiveClass("float"); + + /** + * Returns a string representation of the {@code float} + * argument. All characters mentioned below are ASCII characters. + *

    + *
  • If the argument is NaN, the result is the string + * "{@code NaN}". + *
  • Otherwise, the result is a string that represents the sign and + * magnitude (absolute value) of the argument. If the sign is + * negative, the first character of the result is + * '{@code -}' ('\u002D'); if the sign is + * positive, no sign character appears in the result. As for + * the magnitude m: + *
      + *
    • If m is infinity, it is represented by the characters + * {@code "Infinity"}; thus, positive infinity produces + * the result {@code "Infinity"} and negative infinity + * produces the result {@code "-Infinity"}. + *
    • If m is zero, it is represented by the characters + * {@code "0.0"}; thus, negative zero produces the result + * {@code "-0.0"} and positive zero produces the result + * {@code "0.0"}. + *
    • If m is greater than or equal to 10-3 but + * less than 107, then it is represented as the + * integer part of m, in decimal form with no leading + * zeroes, followed by '{@code .}' + * ('\u002E'), followed by one or more + * decimal digits representing the fractional part of + * m. + *
    • If m is less than 10-3 or greater than or + * equal to 107, then it is represented in + * so-called "computerized scientific notation." Let n + * be the unique integer such that 10n ≤ + * m {@literal <} 10n+1; then let a + * be the mathematically exact quotient of m and + * 10n so that 1 ≤ a {@literal <} 10. + * The magnitude is then represented as the integer part of + * a, as a single decimal digit, followed by + * '{@code .}' ('\u002E'), followed by + * decimal digits representing the fractional part of + * a, followed by the letter '{@code E}' + * ('\u0045'), followed by a representation + * of n as a decimal integer, as produced by the + * method {@link java.lang.Integer#toString(int)}. + * + *
    + *
+ * How many digits must be printed for the fractional part of + * m or a? There must be at least one digit + * to represent the fractional part, and beyond that as many, but + * only as many, more digits as are needed to uniquely distinguish + * the argument value from adjacent values of type + * {@code float}. That is, suppose that x is the + * exact mathematical value represented by the decimal + * representation produced by this method for a finite nonzero + * argument f. Then f must be the {@code float} + * value nearest to x; or, if two {@code float} values are + * equally close to x, then f must be one of + * them and the least significant bit of the significand of + * f must be {@code 0}. + * + *

To create localized string representations of a floating-point + * value, use subclasses of {@link java.text.NumberFormat}. + * + * @param f the float to be converted. + * @return a string representation of the argument. + */ + public static String toString(float f) { + throw new UnsupportedOperationException(); +// return new FloatingDecimal(f).toJavaFormatString(); + } + + /** + * Returns a hexadecimal string representation of the + * {@code float} argument. All characters mentioned below are + * ASCII characters. + * + *

    + *
  • If the argument is NaN, the result is the string + * "{@code NaN}". + *
  • Otherwise, the result is a string that represents the sign and + * magnitude (absolute value) of the argument. If the sign is negative, + * the first character of the result is '{@code -}' + * ('\u002D'); if the sign is positive, no sign character + * appears in the result. As for the magnitude m: + * + *
      + *
    • If m is infinity, it is represented by the string + * {@code "Infinity"}; thus, positive infinity produces the + * result {@code "Infinity"} and negative infinity produces + * the result {@code "-Infinity"}. + * + *
    • If m is zero, it is represented by the string + * {@code "0x0.0p0"}; thus, negative zero produces the result + * {@code "-0x0.0p0"} and positive zero produces the result + * {@code "0x0.0p0"}. + * + *
    • If m is a {@code float} value with a + * normalized representation, substrings are used to represent the + * significand and exponent fields. The significand is + * represented by the characters {@code "0x1."} + * followed by a lowercase hexadecimal representation of the rest + * of the significand as a fraction. Trailing zeros in the + * hexadecimal representation are removed unless all the digits + * are zero, in which case a single zero is used. Next, the + * exponent is represented by {@code "p"} followed + * by a decimal string of the unbiased exponent as if produced by + * a call to {@link Integer#toString(int) Integer.toString} on the + * exponent value. + * + *
    • If m is a {@code float} value with a subnormal + * representation, the significand is represented by the + * characters {@code "0x0."} followed by a + * hexadecimal representation of the rest of the significand as a + * fraction. Trailing zeros in the hexadecimal representation are + * removed. Next, the exponent is represented by + * {@code "p-126"}. Note that there must be at + * least one nonzero digit in a subnormal significand. + * + *
    + * + *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *

Examples

Floating-point ValueHexadecimal String
{@code 1.0} {@code 0x1.0p0}
{@code -1.0} {@code -0x1.0p0}
{@code 2.0} {@code 0x1.0p1}
{@code 3.0} {@code 0x1.8p1}
{@code 0.5} {@code 0x1.0p-1}
{@code 0.25} {@code 0x1.0p-2}
{@code Float.MAX_VALUE}{@code 0x1.fffffep127}
{@code Minimum Normal Value}{@code 0x1.0p-126}
{@code Maximum Subnormal Value}{@code 0x0.fffffep-126}
{@code Float.MIN_VALUE}{@code 0x0.000002p-126}
+ * @param f the {@code float} to be converted. + * @return a hex string representation of the argument. + * @since 1.5 + * @author Joseph D. Darcy + */ + public static String toHexString(float f) { + throw new UnsupportedOperationException(); +// if (Math.abs(f) < FloatConsts.MIN_NORMAL +// && f != 0.0f ) {// float subnormal +// // Adjust exponent to create subnormal double, then +// // replace subnormal double exponent with subnormal float +// // exponent +// String s = Double.toHexString(FpUtils.scalb((double)f, +// /* -1022+126 */ +// DoubleConsts.MIN_EXPONENT- +// FloatConsts.MIN_EXPONENT)); +// return s.replaceFirst("p-1022$", "p-126"); +// } +// else // double string will be the same as float string +// return Double.toHexString(f); + } + + /** + * Returns a {@code Float} object holding the + * {@code float} value represented by the argument string + * {@code s}. + * + *

If {@code s} is {@code null}, then a + * {@code NullPointerException} is thrown. + * + *

Leading and trailing whitespace characters in {@code s} + * are ignored. Whitespace is removed as if by the {@link + * String#trim} method; that is, both ASCII space and control + * characters are removed. The rest of {@code s} should + * constitute a FloatValue as described by the lexical + * syntax rules: + * + *

+ *
+ *
FloatValue: + *
Signopt {@code NaN} + *
Signopt {@code Infinity} + *
Signopt FloatingPointLiteral + *
Signopt HexFloatingPointLiteral + *
SignedInteger + *
+ * + *

+ * + *

+ *
HexFloatingPointLiteral: + *
HexSignificand BinaryExponent FloatTypeSuffixopt + *
+ * + *

+ * + *

+ *
HexSignificand: + *
HexNumeral + *
HexNumeral {@code .} + *
{@code 0x} HexDigitsopt + * {@code .} HexDigits + *
{@code 0X} HexDigitsopt + * {@code .} HexDigits + *
+ * + *

+ * + *

+ *
BinaryExponent: + *
BinaryExponentIndicator SignedInteger + *
+ * + *

+ * + *

+ *
BinaryExponentIndicator: + *
{@code p} + *
{@code P} + *
+ * + *
+ * + * where Sign, FloatingPointLiteral, + * HexNumeral, HexDigits, SignedInteger and + * FloatTypeSuffix are as defined in the lexical structure + * sections of + * The Java™ Language Specification, + * except that underscores are not accepted between digits. + * If {@code s} does not have the form of + * a FloatValue, then a {@code NumberFormatException} + * is thrown. Otherwise, {@code s} is regarded as + * representing an exact decimal value in the usual + * "computerized scientific notation" or as an exact + * hexadecimal value; this exact numerical value is then + * conceptually converted to an "infinitely precise" + * binary value that is then rounded to type {@code float} + * by the usual round-to-nearest rule of IEEE 754 floating-point + * arithmetic, which includes preserving the sign of a zero + * value. + * + * Note that the round-to-nearest rule also implies overflow and + * underflow behaviour; if the exact value of {@code s} is large + * enough in magnitude (greater than or equal to ({@link + * #MAX_VALUE} + {@link Math#ulp(float) ulp(MAX_VALUE)}/2), + * rounding to {@code float} will result in an infinity and if the + * exact value of {@code s} is small enough in magnitude (less + * than or equal to {@link #MIN_VALUE}/2), rounding to float will + * result in a zero. + * + * Finally, after rounding a {@code Float} object representing + * this {@code float} value is returned. + * + *

To interpret localized string representations of a + * floating-point value, use subclasses of {@link + * java.text.NumberFormat}. + * + *

Note that trailing format specifiers, specifiers that + * determine the type of a floating-point literal + * ({@code 1.0f} is a {@code float} value; + * {@code 1.0d} is a {@code double} value), do + * not influence the results of this method. In other + * words, the numerical value of the input string is converted + * directly to the target floating-point type. In general, the + * two-step sequence of conversions, string to {@code double} + * followed by {@code double} to {@code float}, is + * not equivalent to converting a string directly to + * {@code float}. For example, if first converted to an + * intermediate {@code double} and then to + * {@code float}, the string
+ * {@code "1.00000017881393421514957253748434595763683319091796875001d"}
+ * results in the {@code float} value + * {@code 1.0000002f}; if the string is converted directly to + * {@code float}, 1.0000001f results. + * + *

To avoid calling this method on an invalid string and having + * a {@code NumberFormatException} be thrown, the documentation + * for {@link Double#valueOf Double.valueOf} lists a regular + * expression which can be used to screen the input. + * + * @param s the string to be parsed. + * @return a {@code Float} object holding the value + * represented by the {@code String} argument. + * @throws NumberFormatException if the string does not contain a + * parsable number. + */ + public static Float valueOf(String s) throws NumberFormatException { + throw new UnsupportedOperationException(); +// return new Float(FloatingDecimal.readJavaFormatString(s).floatValue()); + } + + /** + * Returns a {@code Float} instance representing the specified + * {@code float} value. + * If a new {@code Float} instance is not required, this method + * should generally be used in preference to the constructor + * {@link #Float(float)}, as this method is likely to yield + * significantly better space and time performance by caching + * frequently requested values. + * + * @param f a float value. + * @return a {@code Float} instance representing {@code f}. + * @since 1.5 + */ + public static Float valueOf(float f) { + return new Float(f); + } + + /** + * Returns a new {@code float} initialized to the value + * represented by the specified {@code String}, as performed + * by the {@code valueOf} method of class {@code Float}. + * + * @param s the string to be parsed. + * @return the {@code float} value represented by the string + * argument. + * @throws NullPointerException if the string is null + * @throws NumberFormatException if the string does not contain a + * parsable {@code float}. + * @see java.lang.Float#valueOf(String) + * @since 1.2 + */ + public static float parseFloat(String s) throws NumberFormatException { + throw new UnsupportedOperationException(); +// return FloatingDecimal.readJavaFormatString(s).floatValue(); + } + + /** + * Returns {@code true} if the specified number is a + * Not-a-Number (NaN) value, {@code false} otherwise. + * + * @param v the value to be tested. + * @return {@code true} if the argument is NaN; + * {@code false} otherwise. + */ + static public boolean isNaN(float v) { + return (v != v); + } + + /** + * Returns {@code true} if the specified number is infinitely + * large in magnitude, {@code false} otherwise. + * + * @param v the value to be tested. + * @return {@code true} if the argument is positive infinity or + * negative infinity; {@code false} otherwise. + */ + static public boolean isInfinite(float v) { + return (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY); + } + + /** + * The value of the Float. + * + * @serial + */ + private final float value; + + /** + * Constructs a newly allocated {@code Float} object that + * represents the primitive {@code float} argument. + * + * @param value the value to be represented by the {@code Float}. + */ + public Float(float value) { + this.value = value; + } + + /** + * Constructs a newly allocated {@code Float} object that + * represents the argument converted to type {@code float}. + * + * @param value the value to be represented by the {@code Float}. + */ + public Float(double value) { + this.value = (float)value; + } + + /** + * Constructs a newly allocated {@code Float} object that + * represents the floating-point value of type {@code float} + * represented by the string. The string is converted to a + * {@code float} value as if by the {@code valueOf} method. + * + * @param s a string to be converted to a {@code Float}. + * @throws NumberFormatException if the string does not contain a + * parsable number. + * @see java.lang.Float#valueOf(java.lang.String) + */ + public Float(String s) throws NumberFormatException { + // REMIND: this is inefficient + this(valueOf(s).floatValue()); + } + + /** + * Returns {@code true} if this {@code Float} value is a + * Not-a-Number (NaN), {@code false} otherwise. + * + * @return {@code true} if the value represented by this object is + * NaN; {@code false} otherwise. + */ + public boolean isNaN() { + return isNaN(value); + } + + /** + * Returns {@code true} if this {@code Float} value is + * infinitely large in magnitude, {@code false} otherwise. + * + * @return {@code true} if the value represented by this object is + * positive infinity or negative infinity; + * {@code false} otherwise. + */ + public boolean isInfinite() { + return isInfinite(value); + } + + /** + * Returns a string representation of this {@code Float} object. + * The primitive {@code float} value represented by this object + * is converted to a {@code String} exactly as if by the method + * {@code toString} of one argument. + * + * @return a {@code String} representation of this object. + * @see java.lang.Float#toString(float) + */ + public String toString() { + return Float.toString(value); + } + + /** + * Returns the value of this {@code Float} as a {@code byte} (by + * casting to a {@code byte}). + * + * @return the {@code float} value represented by this object + * converted to type {@code byte} + */ + public byte byteValue() { + return (byte)value; + } + + /** + * Returns the value of this {@code Float} as a {@code short} (by + * casting to a {@code short}). + * + * @return the {@code float} value represented by this object + * converted to type {@code short} + * @since JDK1.1 + */ + public short shortValue() { + return (short)value; + } + + /** + * Returns the value of this {@code Float} as an {@code int} (by + * casting to type {@code int}). + * + * @return the {@code float} value represented by this object + * converted to type {@code int} + */ + public int intValue() { + return (int)value; + } + + /** + * Returns value of this {@code Float} as a {@code long} (by + * casting to type {@code long}). + * + * @return the {@code float} value represented by this object + * converted to type {@code long} + */ + public long longValue() { + return (long)value; + } + + /** + * Returns the {@code float} value of this {@code Float} object. + * + * @return the {@code float} value represented by this object + */ + public float floatValue() { + return value; + } + + /** + * Returns the {@code double} value of this {@code Float} object. + * + * @return the {@code float} value represented by this + * object is converted to type {@code double} and the + * result of the conversion is returned. + */ + public double doubleValue() { + return (double)value; + } + + /** + * Returns a hash code for this {@code Float} object. The + * result is the integer bit representation, exactly as produced + * by the method {@link #floatToIntBits(float)}, of the primitive + * {@code float} value represented by this {@code Float} + * object. + * + * @return a hash code value for this object. + */ + public int hashCode() { + return floatToIntBits(value); + } + + /** + + * Compares this object against the specified object. The result + * is {@code true} if and only if the argument is not + * {@code null} and is a {@code Float} object that + * represents a {@code float} with the same value as the + * {@code float} represented by this object. For this + * purpose, two {@code float} values are considered to be the + * same if and only if the method {@link #floatToIntBits(float)} + * returns the identical {@code int} value when applied to + * each. + * + *

Note that in most cases, for two instances of class + * {@code Float}, {@code f1} and {@code f2}, the value + * of {@code f1.equals(f2)} is {@code true} if and only if + * + *

+     *   f1.floatValue() == f2.floatValue()
+     * 
+ * + *

also has the value {@code true}. However, there are two exceptions: + *

    + *
  • If {@code f1} and {@code f2} both represent + * {@code Float.NaN}, then the {@code equals} method returns + * {@code true}, even though {@code Float.NaN==Float.NaN} + * has the value {@code false}. + *
  • If {@code f1} represents {@code +0.0f} while + * {@code f2} represents {@code -0.0f}, or vice + * versa, the {@code equal} test has the value + * {@code false}, even though {@code 0.0f==-0.0f} + * has the value {@code true}. + *
+ * + * This definition allows hash tables to operate properly. + * + * @param obj the object to be compared + * @return {@code true} if the objects are the same; + * {@code false} otherwise. + * @see java.lang.Float#floatToIntBits(float) + */ + public boolean equals(Object obj) { + return (obj instanceof Float) + && (floatToIntBits(((Float)obj).value) == floatToIntBits(value)); + } + + /** + * Returns a representation of the specified floating-point value + * according to the IEEE 754 floating-point "single format" bit + * layout. + * + *

Bit 31 (the bit that is selected by the mask + * {@code 0x80000000}) represents the sign of the floating-point + * number. + * Bits 30-23 (the bits that are selected by the mask + * {@code 0x7f800000}) represent the exponent. + * Bits 22-0 (the bits that are selected by the mask + * {@code 0x007fffff}) represent the significand (sometimes called + * the mantissa) of the floating-point number. + * + *

If the argument is positive infinity, the result is + * {@code 0x7f800000}. + * + *

If the argument is negative infinity, the result is + * {@code 0xff800000}. + * + *

If the argument is NaN, the result is {@code 0x7fc00000}. + * + *

In all cases, the result is an integer that, when given to the + * {@link #intBitsToFloat(int)} method, will produce a floating-point + * value the same as the argument to {@code floatToIntBits} + * (except all NaN values are collapsed to a single + * "canonical" NaN value). + * + * @param value a floating-point number. + * @return the bits that represent the floating-point number. + */ + public static int floatToIntBits(float value) { + throw new UnsupportedOperationException(); +// int result = floatToRawIntBits(value); +// // Check for NaN based on values of bit fields, maximum +// // exponent and nonzero significand. +// if ( ((result & FloatConsts.EXP_BIT_MASK) == +// FloatConsts.EXP_BIT_MASK) && +// (result & FloatConsts.SIGNIF_BIT_MASK) != 0) +// result = 0x7fc00000; +// return result; + } + + /** + * Returns a representation of the specified floating-point value + * according to the IEEE 754 floating-point "single format" bit + * layout, preserving Not-a-Number (NaN) values. + * + *

Bit 31 (the bit that is selected by the mask + * {@code 0x80000000}) represents the sign of the floating-point + * number. + * Bits 30-23 (the bits that are selected by the mask + * {@code 0x7f800000}) represent the exponent. + * Bits 22-0 (the bits that are selected by the mask + * {@code 0x007fffff}) represent the significand (sometimes called + * the mantissa) of the floating-point number. + * + *

If the argument is positive infinity, the result is + * {@code 0x7f800000}. + * + *

If the argument is negative infinity, the result is + * {@code 0xff800000}. + * + *

If the argument is NaN, the result is the integer representing + * the actual NaN value. Unlike the {@code floatToIntBits} + * method, {@code floatToRawIntBits} does not collapse all the + * bit patterns encoding a NaN to a single "canonical" + * NaN value. + * + *

In all cases, the result is an integer that, when given to the + * {@link #intBitsToFloat(int)} method, will produce a + * floating-point value the same as the argument to + * {@code floatToRawIntBits}. + * + * @param value a floating-point number. + * @return the bits that represent the floating-point number. + * @since 1.3 + */ + public static native int floatToRawIntBits(float value); + + /** + * Returns the {@code float} value corresponding to a given + * bit representation. + * The argument is considered to be a representation of a + * floating-point value according to the IEEE 754 floating-point + * "single format" bit layout. + * + *

If the argument is {@code 0x7f800000}, the result is positive + * infinity. + * + *

If the argument is {@code 0xff800000}, the result is negative + * infinity. + * + *

If the argument is any value in the range + * {@code 0x7f800001} through {@code 0x7fffffff} or in + * the range {@code 0xff800001} through + * {@code 0xffffffff}, the result is a NaN. No IEEE 754 + * floating-point operation provided by Java can distinguish + * between two NaN values of the same type with different bit + * patterns. Distinct values of NaN are only distinguishable by + * use of the {@code Float.floatToRawIntBits} method. + * + *

In all other cases, let s, e, and m be three + * values that can be computed from the argument: + * + *

+     * int s = ((bits >> 31) == 0) ? 1 : -1;
+     * int e = ((bits >> 23) & 0xff);
+     * int m = (e == 0) ?
+     *                 (bits & 0x7fffff) << 1 :
+     *                 (bits & 0x7fffff) | 0x800000;
+     * 
+ * + * Then the floating-point result equals the value of the mathematical + * expression s·m·2e-150. + * + *

Note that this method may not be able to return a + * {@code float} NaN with exactly same bit pattern as the + * {@code int} argument. IEEE 754 distinguishes between two + * kinds of NaNs, quiet NaNs and signaling NaNs. The + * differences between the two kinds of NaN are generally not + * visible in Java. Arithmetic operations on signaling NaNs turn + * them into quiet NaNs with a different, but often similar, bit + * pattern. However, on some processors merely copying a + * signaling NaN also performs that conversion. In particular, + * copying a signaling NaN to return it to the calling method may + * perform this conversion. So {@code intBitsToFloat} may + * not be able to return a {@code float} with a signaling NaN + * bit pattern. Consequently, for some {@code int} values, + * {@code floatToRawIntBits(intBitsToFloat(start))} may + * not equal {@code start}. Moreover, which + * particular bit patterns represent signaling NaNs is platform + * dependent; although all NaN bit patterns, quiet or signaling, + * must be in the NaN range identified above. + * + * @param bits an integer. + * @return the {@code float} floating-point value with the same bit + * pattern. + */ + public static native float intBitsToFloat(int bits); + + /** + * Compares two {@code Float} objects numerically. There are + * two ways in which comparisons performed by this method differ + * from those performed by the Java language numerical comparison + * operators ({@code <, <=, ==, >=, >}) when + * applied to primitive {@code float} values: + * + *

  • + * {@code Float.NaN} is considered by this method to + * be equal to itself and greater than all other + * {@code float} values + * (including {@code Float.POSITIVE_INFINITY}). + *
  • + * {@code 0.0f} is considered by this method to be greater + * than {@code -0.0f}. + *
+ * + * This ensures that the natural ordering of {@code Float} + * objects imposed by this method is consistent with equals. + * + * @param anotherFloat the {@code Float} to be compared. + * @return the value {@code 0} if {@code anotherFloat} is + * numerically equal to this {@code Float}; a value + * less than {@code 0} if this {@code Float} + * is numerically less than {@code anotherFloat}; + * and a value greater than {@code 0} if this + * {@code Float} is numerically greater than + * {@code anotherFloat}. + * + * @since 1.2 + * @see Comparable#compareTo(Object) + */ + public int compareTo(Float anotherFloat) { + return Float.compare(value, anotherFloat.value); + } + + /** + * Compares the two specified {@code float} values. The sign + * of the integer value returned is the same as that of the + * integer that would be returned by the call: + *
+     *    new Float(f1).compareTo(new Float(f2))
+     * 
+ * + * @param f1 the first {@code float} to compare. + * @param f2 the second {@code float} to compare. + * @return the value {@code 0} if {@code f1} is + * numerically equal to {@code f2}; a value less than + * {@code 0} if {@code f1} is numerically less than + * {@code f2}; and a value greater than {@code 0} + * if {@code f1} is numerically greater than + * {@code f2}. + * @since 1.4 + */ + public static int compare(float f1, float f2) { + if (f1 < f2) + return -1; // Neither val is NaN, thisVal is smaller + if (f1 > f2) + return 1; // Neither val is NaN, thisVal is larger + + // Cannot use floatToRawIntBits because of possibility of NaNs. + int thisBits = Float.floatToIntBits(f1); + int anotherBits = Float.floatToIntBits(f2); + + return (thisBits == anotherBits ? 0 : // Values are equal + (thisBits < anotherBits ? -1 : // (-0.0, 0.0) or (!NaN, NaN) + 1)); // (0.0, -0.0) or (NaN, !NaN) + } + + /** use serialVersionUID from JDK 1.0.2 for interoperability */ + private static final long serialVersionUID = -2671257302660747028L; +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/IllegalAccessException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/IllegalAccessException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * An IllegalAccessException is thrown when an application tries + * to reflectively create an instance (other than an array), + * set or get a field, or invoke a method, but the currently + * executing method does not have access to the definition of + * the specified class, field, method or constructor. + * + * @author unascribed + * @see Class#newInstance() + * @see java.lang.reflect.Field#set(Object, Object) + * @see java.lang.reflect.Field#setBoolean(Object, boolean) + * @see java.lang.reflect.Field#setByte(Object, byte) + * @see java.lang.reflect.Field#setShort(Object, short) + * @see java.lang.reflect.Field#setChar(Object, char) + * @see java.lang.reflect.Field#setInt(Object, int) + * @see java.lang.reflect.Field#setLong(Object, long) + * @see java.lang.reflect.Field#setFloat(Object, float) + * @see java.lang.reflect.Field#setDouble(Object, double) + * @see java.lang.reflect.Field#get(Object) + * @see java.lang.reflect.Field#getBoolean(Object) + * @see java.lang.reflect.Field#getByte(Object) + * @see java.lang.reflect.Field#getShort(Object) + * @see java.lang.reflect.Field#getChar(Object) + * @see java.lang.reflect.Field#getInt(Object) + * @see java.lang.reflect.Field#getLong(Object) + * @see java.lang.reflect.Field#getFloat(Object) + * @see java.lang.reflect.Field#getDouble(Object) + * @see java.lang.reflect.Method#invoke(Object, Object[]) + * @see java.lang.reflect.Constructor#newInstance(Object[]) + * @since JDK1.0 + */ +public class IllegalAccessException extends ReflectiveOperationException { + private static final long serialVersionUID = 6616958222490762034L; + + /** + * Constructs an IllegalAccessException without a + * detail message. + */ + public IllegalAccessException() { + super(); + } + + /** + * Constructs an IllegalAccessException with a detail message. + * + * @param s the detail message. + */ + public IllegalAccessException(String s) { + super(s); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/IllegalArgumentException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/IllegalArgumentException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 1994, 2003, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown to indicate that a method has been passed an illegal or + * inappropriate argument. + * + * @author unascribed + * @see java.lang.Thread#setPriority(int) + * @since JDK1.0 + */ +public +class IllegalArgumentException extends RuntimeException { + /** + * Constructs an IllegalArgumentException with no + * detail message. + */ + public IllegalArgumentException() { + super(); + } + + /** + * Constructs an IllegalArgumentException with the + * specified detail message. + * + * @param s the detail message. + */ + public IllegalArgumentException(String s) { + super(s); + } + + /** + * Constructs a new exception with the specified detail message and + * cause. + * + *

Note that the detail message associated with cause is + * not automatically incorporated in this exception's detail + * message. + * + * @param message the detail message (which is saved for later retrieval + * by the {@link Throwable#getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the + * {@link Throwable#getCause()} method). (A null value + * is permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public IllegalArgumentException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new exception with the specified cause and a detail + * message of (cause==null ? null : cause.toString()) (which + * typically contains the class and detail message of cause). + * This constructor is useful for exceptions that are little more than + * wrappers for other throwables (for example, {@link + * java.security.PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the + * {@link Throwable#getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public IllegalArgumentException(Throwable cause) { + super(cause); + } + + private static final long serialVersionUID = -5365630128856068164L; +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/IllegalStateException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/IllegalStateException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Signals that a method has been invoked at an illegal or + * inappropriate time. In other words, the Java environment or + * Java application is not in an appropriate state for the requested + * operation. + * + * @author Jonni Kanerva + * @since JDK1.1 + */ +public +class IllegalStateException extends RuntimeException { + /** + * Constructs an IllegalStateException with no detail message. + * A detail message is a String that describes this particular exception. + */ + public IllegalStateException() { + super(); + } + + /** + * Constructs an IllegalStateException with the specified detail + * message. A detail message is a String that describes this particular + * exception. + * + * @param s the String that contains a detailed message + */ + public IllegalStateException(String s) { + super(s); + } + + /** + * Constructs a new exception with the specified detail message and + * cause. + * + *

Note that the detail message associated with cause is + * not automatically incorporated in this exception's detail + * message. + * + * @param message the detail message (which is saved for later retrieval + * by the {@link Throwable#getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the + * {@link Throwable#getCause()} method). (A null value + * is permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public IllegalStateException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new exception with the specified cause and a detail + * message of (cause==null ? null : cause.toString()) (which + * typically contains the class and detail message of cause). + * This constructor is useful for exceptions that are little more than + * wrappers for other throwables (for example, {@link + * java.security.PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the + * {@link Throwable#getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public IllegalStateException(Throwable cause) { + super(cause); + } + + static final long serialVersionUID = -1848914673093119416L; +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/IndexOutOfBoundsException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/IndexOutOfBoundsException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown to indicate that an index of some sort (such as to an array, to a + * string, or to a vector) is out of range. + *

+ * Applications can subclass this class to indicate similar exceptions. + * + * @author Frank Yellin + * @since JDK1.0 + */ +public +class IndexOutOfBoundsException extends RuntimeException { + private static final long serialVersionUID = 234122996006267687L; + + /** + * Constructs an IndexOutOfBoundsException with no + * detail message. + */ + public IndexOutOfBoundsException() { + super(); + } + + /** + * Constructs an IndexOutOfBoundsException with the + * specified detail message. + * + * @param s the detail message. + */ + public IndexOutOfBoundsException(String s) { + super(s); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/InstantiationException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/InstantiationException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown when an application tries to create an instance of a class + * using the {@code newInstance} method in class + * {@code Class}, but the specified class object cannot be + * instantiated. The instantiation can fail for a variety of + * reasons including but not limited to: + * + *

    + *
  • the class object represents an abstract class, an interface, + * an array class, a primitive type, or {@code void} + *
  • the class has no nullary constructor + *
+ * + * @author unascribed + * @see java.lang.Class#newInstance() + * @since JDK1.0 + */ +public +class InstantiationException extends ReflectiveOperationException { + private static final long serialVersionUID = -8441929162975509110L; + + /** + * Constructs an {@code InstantiationException} with no detail message. + */ + public InstantiationException() { + super(); + } + + /** + * Constructs an {@code InstantiationException} with the + * specified detail message. + * + * @param s the detail message. + */ + public InstantiationException(String s) { + super(s); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Integer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Integer.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,1242 @@ +/* + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * The {@code Integer} class wraps a value of the primitive type + * {@code int} in an object. An object of type {@code Integer} + * contains a single field whose type is {@code int}. + * + *

In addition, this class provides several methods for converting + * an {@code int} to a {@code String} and a {@code String} to an + * {@code int}, as well as other constants and methods useful when + * dealing with an {@code int}. + * + *

Implementation note: The implementations of the "bit twiddling" + * methods (such as {@link #highestOneBit(int) highestOneBit} and + * {@link #numberOfTrailingZeros(int) numberOfTrailingZeros}) are + * based on material from Henry S. Warren, Jr.'s Hacker's + * Delight, (Addison Wesley, 2002). + * + * @author Lee Boynton + * @author Arthur van Hoff + * @author Josh Bloch + * @author Joseph D. Darcy + * @since JDK1.0 + */ +public final class Integer extends Number implements Comparable { + /** + * A constant holding the minimum value an {@code int} can + * have, -231. + */ + public static final int MIN_VALUE = 0x80000000; + + /** + * A constant holding the maximum value an {@code int} can + * have, 231-1. + */ + public static final int MAX_VALUE = 0x7fffffff; + + /** + * The {@code Class} instance representing the primitive type + * {@code int}. + * + * @since JDK1.1 + */ + public static final Class TYPE = (Class) Class.getPrimitiveClass("int"); + + /** + * All possible chars for representing a number as a String + */ + final static 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' + }; + + /** + * Returns a string representation of the first argument in the + * radix specified by the second argument. + * + *

If the radix is smaller than {@code Character.MIN_RADIX} + * or larger than {@code Character.MAX_RADIX}, then the radix + * {@code 10} is used instead. + * + *

If the first argument is negative, the first element of the + * result is the ASCII minus character {@code '-'} + * ('\u002D'). If the first argument is not + * negative, no sign character appears in the result. + * + *

The remaining characters of the result represent the magnitude + * of the first argument. If the magnitude is zero, it is + * represented by a single zero character {@code '0'} + * ('\u0030'); otherwise, the first character of + * the representation of the magnitude will not be the zero + * character. The following ASCII characters are used as digits: + * + *

+ * {@code 0123456789abcdefghijklmnopqrstuvwxyz} + *
+ * + * These are '\u0030' through + * '\u0039' and '\u0061' through + * '\u007A'. If {@code radix} is + * N, then the first N of these characters + * are used as radix-N digits in the order shown. Thus, + * the digits for hexadecimal (radix 16) are + * {@code 0123456789abcdef}. If uppercase letters are + * desired, the {@link java.lang.String#toUpperCase()} method may + * be called on the result: + * + *
+ * {@code Integer.toString(n, 16).toUpperCase()} + *
+ * + * @param i an integer to be converted to a string. + * @param radix the radix to use in the string representation. + * @return a string representation of the argument in the specified radix. + * @see java.lang.Character#MAX_RADIX + * @see java.lang.Character#MIN_RADIX + */ + public static String toString(int i, int radix) { + + if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) + radix = 10; + + /* Use the faster version */ + if (radix == 10) { + return toString(i); + } + + char buf[] = new char[33]; + boolean negative = (i < 0); + int charPos = 32; + + if (!negative) { + i = -i; + } + + while (i <= -radix) { + buf[charPos--] = digits[-(i % radix)]; + i = i / radix; + } + buf[charPos] = digits[-i]; + + if (negative) { + buf[--charPos] = '-'; + } + + return new String(buf, charPos, (33 - charPos)); + } + + /** + * Returns a string representation of the integer argument as an + * unsigned integer in base 16. + * + *

The unsigned integer value is the argument plus 232 + * if the argument is negative; otherwise, it is equal to the + * argument. This value is converted to a string of ASCII digits + * in hexadecimal (base 16) with no extra leading + * {@code 0}s. If the unsigned magnitude is zero, it is + * represented by a single zero character {@code '0'} + * ('\u0030'); otherwise, the first character of + * the representation of the unsigned magnitude will not be the + * zero character. The following characters are used as + * hexadecimal digits: + * + *

+ * {@code 0123456789abcdef} + *
+ * + * These are the characters '\u0030' through + * '\u0039' and '\u0061' through + * '\u0066'. If uppercase letters are + * desired, the {@link java.lang.String#toUpperCase()} method may + * be called on the result: + * + *
+ * {@code Integer.toHexString(n).toUpperCase()} + *
+ * + * @param i an integer to be converted to a string. + * @return the string representation of the unsigned integer value + * represented by the argument in hexadecimal (base 16). + * @since JDK1.0.2 + */ + public static String toHexString(int i) { + return toUnsignedString(i, 4); + } + + /** + * Returns a string representation of the integer argument as an + * unsigned integer in base 8. + * + *

The unsigned integer value is the argument plus 232 + * if the argument is negative; otherwise, it is equal to the + * argument. This value is converted to a string of ASCII digits + * in octal (base 8) with no extra leading {@code 0}s. + * + *

If the unsigned magnitude is zero, it is represented by a + * single zero character {@code '0'} + * ('\u0030'); otherwise, the first character of + * the representation of the unsigned magnitude will not be the + * zero character. The following characters are used as octal + * digits: + * + *

+ * {@code 01234567} + *
+ * + * These are the characters '\u0030' through + * '\u0037'. + * + * @param i an integer to be converted to a string. + * @return the string representation of the unsigned integer value + * represented by the argument in octal (base 8). + * @since JDK1.0.2 + */ + public static String toOctalString(int i) { + return toUnsignedString(i, 3); + } + + /** + * Returns a string representation of the integer argument as an + * unsigned integer in base 2. + * + *

The unsigned integer value is the argument plus 232 + * if the argument is negative; otherwise it is equal to the + * argument. This value is converted to a string of ASCII digits + * in binary (base 2) with no extra leading {@code 0}s. + * If the unsigned magnitude is zero, it is represented by a + * single zero character {@code '0'} + * ('\u0030'); otherwise, the first character of + * the representation of the unsigned magnitude will not be the + * zero character. The characters {@code '0'} + * ('\u0030') and {@code '1'} + * ('\u0031') are used as binary digits. + * + * @param i an integer to be converted to a string. + * @return the string representation of the unsigned integer value + * represented by the argument in binary (base 2). + * @since JDK1.0.2 + */ + public static String toBinaryString(int i) { + return toUnsignedString(i, 1); + } + + /** + * Convert the integer to an unsigned number. + */ + private static String toUnsignedString(int i, int shift) { + char[] buf = new char[32]; + int charPos = 32; + int radix = 1 << shift; + int mask = radix - 1; + do { + buf[--charPos] = digits[i & mask]; + i >>>= shift; + } while (i != 0); + + return new String(buf, charPos, (32 - charPos)); + } + + + final static char [] DigitTens = { + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', + '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', + '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', + '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', + '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', + '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', + '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', + '8', '8', '8', '8', '8', '8', '8', '8', '8', '8', + '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', + } ; + + final static char [] DigitOnes = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + } ; + + // I use the "invariant division by multiplication" trick to + // accelerate Integer.toString. In particular we want to + // avoid division by 10. + // + // The "trick" has roughly the same performance characteristics + // as the "classic" Integer.toString code on a non-JIT VM. + // The trick avoids .rem and .div calls but has a longer code + // path and is thus dominated by dispatch overhead. In the + // JIT case the dispatch overhead doesn't exist and the + // "trick" is considerably faster than the classic code. + // + // TODO-FIXME: convert (x * 52429) into the equiv shift-add + // sequence. + // + // RE: Division by Invariant Integers using Multiplication + // T Gralund, P Montgomery + // ACM PLDI 1994 + // + + /** + * Returns a {@code String} object representing the + * specified integer. The argument is converted to signed decimal + * representation and returned as a string, exactly as if the + * argument and radix 10 were given as arguments to the {@link + * #toString(int, int)} method. + * + * @param i an integer to be converted. + * @return a string representation of the argument in base 10. + */ + public static String toString(int i) { + if (i == Integer.MIN_VALUE) + return "-2147483648"; + int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i); + char[] buf = new char[size]; + getChars(i, size, buf); + return new String(0, size, buf); + } + + /** + * Places characters representing the integer i into the + * character array buf. The characters are placed into + * the buffer backwards starting with the least significant + * digit at the specified index (exclusive), and working + * backwards from there. + * + * Will fail if i == Integer.MIN_VALUE + */ + static void getChars(int i, int index, char[] buf) { + int q, r; + int charPos = index; + char sign = 0; + + if (i < 0) { + sign = '-'; + i = -i; + } + + // Generate two digits per iteration + while (i >= 65536) { + q = i / 100; + // really: r = i - (q * 100); + r = i - ((q << 6) + (q << 5) + (q << 2)); + i = q; + buf [--charPos] = DigitOnes[r]; + buf [--charPos] = DigitTens[r]; + } + + // Fall thru to fast mode for smaller numbers + // assert(i <= 65536, i); + for (;;) { + q = (i * 52429) >>> (16+3); + r = i - ((q << 3) + (q << 1)); // r = i-(q*10) ... + buf [--charPos] = digits [r]; + i = q; + if (i == 0) break; + } + if (sign != 0) { + buf [--charPos] = sign; + } + } + + final static int [] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999, + 99999999, 999999999, Integer.MAX_VALUE }; + + // Requires positive x + static int stringSize(int x) { + for (int i=0; ; i++) + if (x <= sizeTable[i]) + return i+1; + } + + /** + * Parses the string argument as a signed integer in the radix + * specified by the second argument. The characters in the string + * must all be digits of the specified radix (as determined by + * whether {@link java.lang.Character#digit(char, int)} returns a + * nonnegative value), except that the first character may be an + * ASCII minus sign {@code '-'} ('\u002D') to + * indicate a negative value or an ASCII plus sign {@code '+'} + * ('\u002B') to indicate a positive value. The + * resulting integer value is returned. + * + *

An exception of type {@code NumberFormatException} is + * thrown if any of the following situations occurs: + *

    + *
  • The first argument is {@code null} or is a string of + * length zero. + * + *
  • The radix is either smaller than + * {@link java.lang.Character#MIN_RADIX} or + * larger than {@link java.lang.Character#MAX_RADIX}. + * + *
  • Any character of the string is not a digit of the specified + * radix, except that the first character may be a minus sign + * {@code '-'} ('\u002D') or plus sign + * {@code '+'} ('\u002B') provided that the + * string is longer than length 1. + * + *
  • The value represented by the string is not a value of type + * {@code int}. + *
+ * + *

Examples: + *

+     * parseInt("0", 10) returns 0
+     * parseInt("473", 10) returns 473
+     * parseInt("+42", 10) returns 42
+     * parseInt("-0", 10) returns 0
+     * parseInt("-FF", 16) returns -255
+     * parseInt("1100110", 2) returns 102
+     * parseInt("2147483647", 10) returns 2147483647
+     * parseInt("-2147483648", 10) returns -2147483648
+     * parseInt("2147483648", 10) throws a NumberFormatException
+     * parseInt("99", 8) throws a NumberFormatException
+     * parseInt("Kona", 10) throws a NumberFormatException
+     * parseInt("Kona", 27) returns 411787
+     * 
+ * + * @param s the {@code String} containing the integer + * representation to be parsed + * @param radix the radix to be used while parsing {@code s}. + * @return the integer represented by the string argument in the + * specified radix. + * @exception NumberFormatException if the {@code String} + * does not contain a parsable {@code int}. + */ + public static int parseInt(String s, int radix) + throws NumberFormatException + { + /* + * WARNING: This method may be invoked early during VM initialization + * before IntegerCache is initialized. Care must be taken to not use + * the valueOf method. + */ + + if (s == null) { + throw new NumberFormatException("null"); + } + + if (radix < Character.MIN_RADIX) { + throw new NumberFormatException("radix " + radix + + " less than Character.MIN_RADIX"); + } + + if (radix > Character.MAX_RADIX) { + throw new NumberFormatException("radix " + radix + + " greater than Character.MAX_RADIX"); + } + + int result = 0; + boolean negative = false; + int i = 0, len = s.length(); + int limit = -Integer.MAX_VALUE; + int multmin; + int digit; + + if (len > 0) { + char firstChar = s.charAt(0); + if (firstChar < '0') { // Possible leading "+" or "-" + if (firstChar == '-') { + negative = true; + limit = Integer.MIN_VALUE; + } else if (firstChar != '+') + throw NumberFormatException.forInputString(s); + + if (len == 1) // Cannot have lone "+" or "-" + throw NumberFormatException.forInputString(s); + i++; + } + multmin = limit / radix; + while (i < len) { + // Accumulating negatively avoids surprises near MAX_VALUE + digit = Character.digit(s.charAt(i++),radix); + if (digit < 0) { + throw NumberFormatException.forInputString(s); + } + if (result < multmin) { + throw NumberFormatException.forInputString(s); + } + result *= radix; + if (result < limit + digit) { + throw NumberFormatException.forInputString(s); + } + result -= digit; + } + } else { + throw NumberFormatException.forInputString(s); + } + return negative ? result : -result; + } + + /** + * Parses the string argument as a signed decimal integer. The + * characters in the string must all be decimal digits, except + * that the first character may be an ASCII minus sign {@code '-'} + * ('\u002D') to indicate a negative value or an + * ASCII plus sign {@code '+'} ('\u002B') to + * indicate a positive value. The resulting integer value is + * returned, exactly as if the argument and the radix 10 were + * given as arguments to the {@link #parseInt(java.lang.String, + * int)} method. + * + * @param s a {@code String} containing the {@code int} + * representation to be parsed + * @return the integer value represented by the argument in decimal. + * @exception NumberFormatException if the string does not contain a + * parsable integer. + */ + public static int parseInt(String s) throws NumberFormatException { + return parseInt(s,10); + } + + /** + * Returns an {@code Integer} object holding the value + * extracted from the specified {@code String} when parsed + * with the radix given by the second argument. The first argument + * is interpreted as representing a signed integer in the radix + * specified by the second argument, exactly as if the arguments + * were given to the {@link #parseInt(java.lang.String, int)} + * method. The result is an {@code Integer} object that + * represents the integer value specified by the string. + * + *

In other words, this method returns an {@code Integer} + * object equal to the value of: + * + *

+ * {@code new Integer(Integer.parseInt(s, radix))} + *
+ * + * @param s the string to be parsed. + * @param radix the radix to be used in interpreting {@code s} + * @return an {@code Integer} object holding the value + * represented by the string argument in the specified + * radix. + * @exception NumberFormatException if the {@code String} + * does not contain a parsable {@code int}. + */ + public static Integer valueOf(String s, int radix) throws NumberFormatException { + return Integer.valueOf(parseInt(s,radix)); + } + + /** + * Returns an {@code Integer} object holding the + * value of the specified {@code String}. The argument is + * interpreted as representing a signed decimal integer, exactly + * as if the argument were given to the {@link + * #parseInt(java.lang.String)} method. The result is an + * {@code Integer} object that represents the integer value + * specified by the string. + * + *

In other words, this method returns an {@code Integer} + * object equal to the value of: + * + *

+ * {@code new Integer(Integer.parseInt(s))} + *
+ * + * @param s the string to be parsed. + * @return an {@code Integer} object holding the value + * represented by the string argument. + * @exception NumberFormatException if the string cannot be parsed + * as an integer. + */ + public static Integer valueOf(String s) throws NumberFormatException { + return Integer.valueOf(parseInt(s, 10)); + } + + /** + * Cache to support the object identity semantics of autoboxing for values between + * -128 and 127 (inclusive) as required by JLS. + * + * The cache is initialized on first usage. The size of the cache + * may be controlled by the -XX:AutoBoxCacheMax= option. + * During VM initialization, java.lang.Integer.IntegerCache.high property + * may be set and saved in the private system properties in the + * sun.misc.VM class. + */ + + private static class IntegerCache { + static final int low = -128; + static final int high; + static final Integer cache[]; + + static { + // high value may be configured by property + int h = 127; + String integerCacheHighPropValue = + String.getProperty("java.lang.Integer.IntegerCache.high"); + if (integerCacheHighPropValue != null) { + int i = parseInt(integerCacheHighPropValue); + i = Math.max(i, 127); + // Maximum array size is Integer.MAX_VALUE + h = Math.min(i, Integer.MAX_VALUE - (-low)); + } + high = h; + + cache = new Integer[(high - low) + 1]; + int j = low; + for(int k = 0; k < cache.length; k++) + cache[k] = new Integer(j++); + } + + private IntegerCache() {} + } + + /** + * Returns an {@code Integer} instance representing the specified + * {@code int} value. If a new {@code Integer} instance is not + * required, this method should generally be used in preference to + * the constructor {@link #Integer(int)}, as this method is likely + * to yield significantly better space and time performance by + * caching frequently requested values. + * + * This method will always cache values in the range -128 to 127, + * inclusive, and may cache other values outside of this range. + * + * @param i an {@code int} value. + * @return an {@code Integer} instance representing {@code i}. + * @since 1.5 + */ + public static Integer valueOf(int i) { + //assert IntegerCache.high >= 127; + if (i >= IntegerCache.low && i <= IntegerCache.high) + return IntegerCache.cache[i + (-IntegerCache.low)]; + return new Integer(i); + } + + /** + * The value of the {@code Integer}. + * + * @serial + */ + private final int value; + + /** + * Constructs a newly allocated {@code Integer} object that + * represents the specified {@code int} value. + * + * @param value the value to be represented by the + * {@code Integer} object. + */ + public Integer(int value) { + this.value = value; + } + + /** + * Constructs a newly allocated {@code Integer} object that + * represents the {@code int} value indicated by the + * {@code String} parameter. The string is converted to an + * {@code int} value in exactly the manner used by the + * {@code parseInt} method for radix 10. + * + * @param s the {@code String} to be converted to an + * {@code Integer}. + * @exception NumberFormatException if the {@code String} does not + * contain a parsable integer. + * @see java.lang.Integer#parseInt(java.lang.String, int) + */ + public Integer(String s) throws NumberFormatException { + this.value = parseInt(s, 10); + } + + /** + * Returns the value of this {@code Integer} as a + * {@code byte}. + */ + public byte byteValue() { + return (byte)value; + } + + /** + * Returns the value of this {@code Integer} as a + * {@code short}. + */ + public short shortValue() { + return (short)value; + } + + /** + * Returns the value of this {@code Integer} as an + * {@code int}. + */ + public int intValue() { + return value; + } + + /** + * Returns the value of this {@code Integer} as a + * {@code long}. + */ + public long longValue() { + return (long)value; + } + + /** + * Returns the value of this {@code Integer} as a + * {@code float}. + */ + public float floatValue() { + return (float)value; + } + + /** + * Returns the value of this {@code Integer} as a + * {@code double}. + */ + public double doubleValue() { + return (double)value; + } + + /** + * Returns a {@code String} object representing this + * {@code Integer}'s value. The value is converted to signed + * decimal representation and returned as a string, exactly as if + * the integer value were given as an argument to the {@link + * java.lang.Integer#toString(int)} method. + * + * @return a string representation of the value of this object in + * base 10. + */ + public String toString() { + return toString(value); + } + + /** + * Returns a hash code for this {@code Integer}. + * + * @return a hash code value for this object, equal to the + * primitive {@code int} value represented by this + * {@code Integer} object. + */ + public int hashCode() { + return value; + } + + /** + * Compares this object to the specified object. The result is + * {@code true} if and only if the argument is not + * {@code null} and is an {@code Integer} object that + * contains the same {@code int} value as this object. + * + * @param obj the object to compare with. + * @return {@code true} if the objects are the same; + * {@code false} otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof Integer) { + return value == ((Integer)obj).intValue(); + } + return false; + } + + /** + * Determines the integer value of the system property with the + * specified name. + * + *

The first argument is treated as the name of a system property. + * System properties are accessible through the + * {@link java.lang.System#getProperty(java.lang.String)} method. The + * string value of this property is then interpreted as an integer + * value and an {@code Integer} object representing this value is + * returned. Details of possible numeric formats can be found with + * the definition of {@code getProperty}. + * + *

If there is no property with the specified name, if the specified name + * is empty or {@code null}, or if the property does not have + * the correct numeric format, then {@code null} is returned. + * + *

In other words, this method returns an {@code Integer} + * object equal to the value of: + * + *

+ * {@code getInteger(nm, null)} + *
+ * + * @param nm property name. + * @return the {@code Integer} value of the property. + * @see java.lang.System#getProperty(java.lang.String) + * @see java.lang.System#getProperty(java.lang.String, java.lang.String) + */ + public static Integer getInteger(String nm) { + return getInteger(nm, null); + } + + /** + * Determines the integer value of the system property with the + * specified name. + * + *

The first argument is treated as the name of a system property. + * System properties are accessible through the {@link + * java.lang.System#getProperty(java.lang.String)} method. The + * string value of this property is then interpreted as an integer + * value and an {@code Integer} object representing this value is + * returned. Details of possible numeric formats can be found with + * the definition of {@code getProperty}. + * + *

The second argument is the default value. An {@code Integer} object + * that represents the value of the second argument is returned if there + * is no property of the specified name, if the property does not have + * the correct numeric format, or if the specified name is empty or + * {@code null}. + * + *

In other words, this method returns an {@code Integer} object + * equal to the value of: + * + *

+ * {@code getInteger(nm, new Integer(val))} + *
+ * + * but in practice it may be implemented in a manner such as: + * + *
+     * Integer result = getInteger(nm, null);
+     * return (result == null) ? new Integer(val) : result;
+     * 
+ * + * to avoid the unnecessary allocation of an {@code Integer} + * object when the default value is not needed. + * + * @param nm property name. + * @param val default value. + * @return the {@code Integer} value of the property. + * @see java.lang.System#getProperty(java.lang.String) + * @see java.lang.System#getProperty(java.lang.String, java.lang.String) + */ + public static Integer getInteger(String nm, int val) { + Integer result = getInteger(nm, null); + return (result == null) ? Integer.valueOf(val) : result; + } + + /** + * Returns the integer value of the system property with the + * specified name. The first argument is treated as the name of a + * system property. System properties are accessible through the + * {@link java.lang.System#getProperty(java.lang.String)} method. + * The string value of this property is then interpreted as an + * integer value, as per the {@code Integer.decode} method, + * and an {@code Integer} object representing this value is + * returned. + * + *
  • If the property value begins with the two ASCII characters + * {@code 0x} or the ASCII character {@code #}, not + * followed by a minus sign, then the rest of it is parsed as a + * hexadecimal integer exactly as by the method + * {@link #valueOf(java.lang.String, int)} with radix 16. + *
  • If the property value begins with the ASCII character + * {@code 0} followed by another character, it is parsed as an + * octal integer exactly as by the method + * {@link #valueOf(java.lang.String, int)} with radix 8. + *
  • Otherwise, the property value is parsed as a decimal integer + * exactly as by the method {@link #valueOf(java.lang.String, int)} + * with radix 10. + *
+ * + *

The second argument is the default value. The default value is + * returned if there is no property of the specified name, if the + * property does not have the correct numeric format, or if the + * specified name is empty or {@code null}. + * + * @param nm property name. + * @param val default value. + * @return the {@code Integer} value of the property. + * @see java.lang.System#getProperty(java.lang.String) + * @see java.lang.System#getProperty(java.lang.String, java.lang.String) + * @see java.lang.Integer#decode + */ + public static Integer getInteger(String nm, Integer val) { + String v = null; + try { + v = String.getProperty(nm); + } catch (IllegalArgumentException e) { + } catch (NullPointerException e) { + } + if (v != null) { + try { + return Integer.decode(v); + } catch (NumberFormatException e) { + } + } + return val; + } + + /** + * Decodes a {@code String} into an {@code Integer}. + * Accepts decimal, hexadecimal, and octal numbers given + * by the following grammar: + * + *

+ *
+ *
DecodableString: + *
Signopt DecimalNumeral + *
Signopt {@code 0x} HexDigits + *
Signopt {@code 0X} HexDigits + *
Signopt {@code #} HexDigits + *
Signopt {@code 0} OctalDigits + *

+ *

Sign: + *
{@code -} + *
{@code +} + *
+ *
+ * + * DecimalNumeral, HexDigits, and OctalDigits + * are as defined in section 3.10.1 of + * The Java™ Language Specification, + * except that underscores are not accepted between digits. + * + *

The sequence of characters following an optional + * sign and/or radix specifier ("{@code 0x}", "{@code 0X}", + * "{@code #}", or leading zero) is parsed as by the {@code + * Integer.parseInt} method with the indicated radix (10, 16, or + * 8). This sequence of characters must represent a positive + * value or a {@link NumberFormatException} will be thrown. The + * result is negated if first character of the specified {@code + * String} is the minus sign. No whitespace characters are + * permitted in the {@code String}. + * + * @param nm the {@code String} to decode. + * @return an {@code Integer} object holding the {@code int} + * value represented by {@code nm} + * @exception NumberFormatException if the {@code String} does not + * contain a parsable integer. + * @see java.lang.Integer#parseInt(java.lang.String, int) + */ + public static Integer decode(String nm) throws NumberFormatException { + int radix = 10; + int index = 0; + boolean negative = false; + Integer result; + + if (nm.length() == 0) + throw new NumberFormatException("Zero length string"); + char firstChar = nm.charAt(0); + // Handle sign, if present + if (firstChar == '-') { + negative = true; + index++; + } else if (firstChar == '+') + index++; + + // Handle radix specifier, if present + if (nm.startsWith("0x", index) || nm.startsWith("0X", index)) { + index += 2; + radix = 16; + } + else if (nm.startsWith("#", index)) { + index ++; + radix = 16; + } + else if (nm.startsWith("0", index) && nm.length() > 1 + index) { + index ++; + radix = 8; + } + + if (nm.startsWith("-", index) || nm.startsWith("+", index)) + throw new NumberFormatException("Sign character in wrong position"); + + try { + result = Integer.valueOf(nm.substring(index), radix); + result = negative ? Integer.valueOf(-result.intValue()) : result; + } catch (NumberFormatException e) { + // If number is Integer.MIN_VALUE, we'll end up here. The next line + // handles this case, and causes any genuine format error to be + // rethrown. + String constant = negative ? ("-" + nm.substring(index)) + : nm.substring(index); + result = Integer.valueOf(constant, radix); + } + return result; + } + + /** + * Compares two {@code Integer} objects numerically. + * + * @param anotherInteger the {@code Integer} to be compared. + * @return the value {@code 0} if this {@code Integer} is + * equal to the argument {@code Integer}; a value less than + * {@code 0} if this {@code Integer} is numerically less + * than the argument {@code Integer}; and a value greater + * than {@code 0} if this {@code Integer} is numerically + * greater than the argument {@code Integer} (signed + * comparison). + * @since 1.2 + */ + public int compareTo(Integer anotherInteger) { + return compare(this.value, anotherInteger.value); + } + + /** + * Compares two {@code int} values numerically. + * The value returned is identical to what would be returned by: + *

+     *    Integer.valueOf(x).compareTo(Integer.valueOf(y))
+     * 
+ * + * @param x the first {@code int} to compare + * @param y the second {@code int} to compare + * @return the value {@code 0} if {@code x == y}; + * a value less than {@code 0} if {@code x < y}; and + * a value greater than {@code 0} if {@code x > y} + * @since 1.7 + */ + public static int compare(int x, int y) { + return (x < y) ? -1 : ((x == y) ? 0 : 1); + } + + + // Bit twiddling + + /** + * The number of bits used to represent an {@code int} value in two's + * complement binary form. + * + * @since 1.5 + */ + public static final int SIZE = 32; + + /** + * Returns an {@code int} value with at most a single one-bit, in the + * position of the highest-order ("leftmost") one-bit in the specified + * {@code int} value. Returns zero if the specified value has no + * one-bits in its two's complement binary representation, that is, if it + * is equal to zero. + * + * @return an {@code int} value with a single one-bit, in the position + * of the highest-order one-bit in the specified value, or zero if + * the specified value is itself equal to zero. + * @since 1.5 + */ + public static int highestOneBit(int i) { + // HD, Figure 3-1 + i |= (i >> 1); + i |= (i >> 2); + i |= (i >> 4); + i |= (i >> 8); + i |= (i >> 16); + return i - (i >>> 1); + } + + /** + * Returns an {@code int} value with at most a single one-bit, in the + * position of the lowest-order ("rightmost") one-bit in the specified + * {@code int} value. Returns zero if the specified value has no + * one-bits in its two's complement binary representation, that is, if it + * is equal to zero. + * + * @return an {@code int} value with a single one-bit, in the position + * of the lowest-order one-bit in the specified value, or zero if + * the specified value is itself equal to zero. + * @since 1.5 + */ + public static int lowestOneBit(int i) { + // HD, Section 2-1 + return i & -i; + } + + /** + * Returns the number of zero bits preceding the highest-order + * ("leftmost") one-bit in the two's complement binary representation + * of the specified {@code int} value. Returns 32 if the + * specified value has no one-bits in its two's complement representation, + * in other words if it is equal to zero. + * + *

Note that this method is closely related to the logarithm base 2. + * For all positive {@code int} values x: + *

    + *
  • floor(log2(x)) = {@code 31 - numberOfLeadingZeros(x)} + *
  • ceil(log2(x)) = {@code 32 - numberOfLeadingZeros(x - 1)} + *
+ * + * @return the number of zero bits preceding the highest-order + * ("leftmost") one-bit in the two's complement binary representation + * of the specified {@code int} value, or 32 if the value + * is equal to zero. + * @since 1.5 + */ + public static int numberOfLeadingZeros(int i) { + // HD, Figure 5-6 + if (i == 0) + return 32; + int n = 1; + if (i >>> 16 == 0) { n += 16; i <<= 16; } + if (i >>> 24 == 0) { n += 8; i <<= 8; } + if (i >>> 28 == 0) { n += 4; i <<= 4; } + if (i >>> 30 == 0) { n += 2; i <<= 2; } + n -= i >>> 31; + return n; + } + + /** + * Returns the number of zero bits following the lowest-order ("rightmost") + * one-bit in the two's complement binary representation of the specified + * {@code int} value. Returns 32 if the specified value has no + * one-bits in its two's complement representation, in other words if it is + * equal to zero. + * + * @return the number of zero bits following the lowest-order ("rightmost") + * one-bit in the two's complement binary representation of the + * specified {@code int} value, or 32 if the value is equal + * to zero. + * @since 1.5 + */ + public static int numberOfTrailingZeros(int i) { + // HD, Figure 5-14 + int y; + if (i == 0) return 32; + int n = 31; + y = i <<16; if (y != 0) { n = n -16; i = y; } + y = i << 8; if (y != 0) { n = n - 8; i = y; } + y = i << 4; if (y != 0) { n = n - 4; i = y; } + y = i << 2; if (y != 0) { n = n - 2; i = y; } + return n - ((i << 1) >>> 31); + } + + /** + * Returns the number of one-bits in the two's complement binary + * representation of the specified {@code int} value. This function is + * sometimes referred to as the population count. + * + * @return the number of one-bits in the two's complement binary + * representation of the specified {@code int} value. + * @since 1.5 + */ + public static int bitCount(int i) { + // HD, Figure 5-2 + i = i - ((i >>> 1) & 0x55555555); + i = (i & 0x33333333) + ((i >>> 2) & 0x33333333); + i = (i + (i >>> 4)) & 0x0f0f0f0f; + i = i + (i >>> 8); + i = i + (i >>> 16); + return i & 0x3f; + } + + /** + * Returns the value obtained by rotating the two's complement binary + * representation of the specified {@code int} value left by the + * specified number of bits. (Bits shifted out of the left hand, or + * high-order, side reenter on the right, or low-order.) + * + *

Note that left rotation with a negative distance is equivalent to + * right rotation: {@code rotateLeft(val, -distance) == rotateRight(val, + * distance)}. Note also that rotation by any multiple of 32 is a + * no-op, so all but the last five bits of the rotation distance can be + * ignored, even if the distance is negative: {@code rotateLeft(val, + * distance) == rotateLeft(val, distance & 0x1F)}. + * + * @return the value obtained by rotating the two's complement binary + * representation of the specified {@code int} value left by the + * specified number of bits. + * @since 1.5 + */ + public static int rotateLeft(int i, int distance) { + return (i << distance) | (i >>> -distance); + } + + /** + * Returns the value obtained by rotating the two's complement binary + * representation of the specified {@code int} value right by the + * specified number of bits. (Bits shifted out of the right hand, or + * low-order, side reenter on the left, or high-order.) + * + *

Note that right rotation with a negative distance is equivalent to + * left rotation: {@code rotateRight(val, -distance) == rotateLeft(val, + * distance)}. Note also that rotation by any multiple of 32 is a + * no-op, so all but the last five bits of the rotation distance can be + * ignored, even if the distance is negative: {@code rotateRight(val, + * distance) == rotateRight(val, distance & 0x1F)}. + * + * @return the value obtained by rotating the two's complement binary + * representation of the specified {@code int} value right by the + * specified number of bits. + * @since 1.5 + */ + public static int rotateRight(int i, int distance) { + return (i >>> distance) | (i << -distance); + } + + /** + * Returns the value obtained by reversing the order of the bits in the + * two's complement binary representation of the specified {@code int} + * value. + * + * @return the value obtained by reversing order of the bits in the + * specified {@code int} value. + * @since 1.5 + */ + public static int reverse(int i) { + // HD, Figure 7-1 + i = (i & 0x55555555) << 1 | (i >>> 1) & 0x55555555; + i = (i & 0x33333333) << 2 | (i >>> 2) & 0x33333333; + i = (i & 0x0f0f0f0f) << 4 | (i >>> 4) & 0x0f0f0f0f; + i = (i << 24) | ((i & 0xff00) << 8) | + ((i >>> 8) & 0xff00) | (i >>> 24); + return i; + } + + /** + * Returns the signum function of the specified {@code int} value. (The + * return value is -1 if the specified value is negative; 0 if the + * specified value is zero; and 1 if the specified value is positive.) + * + * @return the signum function of the specified {@code int} value. + * @since 1.5 + */ + public static int signum(int i) { + // HD, Section 2-7 + return (i >> 31) | (-i >>> 31); + } + + /** + * Returns the value obtained by reversing the order of the bytes in the + * two's complement representation of the specified {@code int} value. + * + * @return the value obtained by reversing the bytes in the specified + * {@code int} value. + * @since 1.5 + */ + public static int reverseBytes(int i) { + return ((i >>> 24) ) | + ((i >> 8) & 0xFF00) | + ((i << 8) & 0xFF0000) | + ((i << 24)); + } + + /** use serialVersionUID from JDK 1.0.2 for interoperability */ + private static final long serialVersionUID = 1360826667806852920L; +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/InterruptedException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/InterruptedException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown when a thread is waiting, sleeping, or otherwise occupied, + * and the thread is interrupted, either before or during the activity. + * Occasionally a method may wish to test whether the current + * thread has been interrupted, and if so, to immediately throw + * this exception. The following code can be used to achieve + * this effect: + *

+ *  if (Thread.interrupted())  // Clears interrupted status!
+ *      throw new InterruptedException();
+ * 
+ * + * @author Frank Yellin + * @see java.lang.Object#wait() + * @see java.lang.Object#wait(long) + * @see java.lang.Object#wait(long, int) + * @see java.lang.Thread#sleep(long) + * @see java.lang.Thread#interrupt() + * @see java.lang.Thread#interrupted() + * @since JDK1.0 + */ +public +class InterruptedException extends Exception { + private static final long serialVersionUID = 6700697376100628473L; + + /** + * Constructs an InterruptedException with no detail message. + */ + public InterruptedException() { + super(); + } + + /** + * Constructs an InterruptedException with the + * specified detail message. + * + * @param s the detail message. + */ + public InterruptedException(String s) { + super(s); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Long.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Long.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,1199 @@ +/* + * Copyright (c) 1994, 2009, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * The {@code Long} class wraps a value of the primitive type {@code + * long} in an object. An object of type {@code Long} contains a + * single field whose type is {@code long}. + * + *

In addition, this class provides several methods for converting + * a {@code long} to a {@code String} and a {@code String} to a {@code + * long}, as well as other constants and methods useful when dealing + * with a {@code long}. + * + *

Implementation note: The implementations of the "bit twiddling" + * methods (such as {@link #highestOneBit(long) highestOneBit} and + * {@link #numberOfTrailingZeros(long) numberOfTrailingZeros}) are + * based on material from Henry S. Warren, Jr.'s Hacker's + * Delight, (Addison Wesley, 2002). + * + * @author Lee Boynton + * @author Arthur van Hoff + * @author Josh Bloch + * @author Joseph D. Darcy + * @since JDK1.0 + */ +public final class Long extends Number implements Comparable { + /** + * A constant holding the minimum value a {@code long} can + * have, -263. + */ + public static final long MIN_VALUE = 0x8000000000000000L; + + /** + * A constant holding the maximum value a {@code long} can + * have, 263-1. + */ + public static final long MAX_VALUE = 0x7fffffffffffffffL; + + /** + * The {@code Class} instance representing the primitive type + * {@code long}. + * + * @since JDK1.1 + */ + public static final Class TYPE = (Class) Class.getPrimitiveClass("long"); + + /** + * Returns a string representation of the first argument in the + * radix specified by the second argument. + * + *

If the radix is smaller than {@code Character.MIN_RADIX} + * or larger than {@code Character.MAX_RADIX}, then the radix + * {@code 10} is used instead. + * + *

If the first argument is negative, the first element of the + * result is the ASCII minus sign {@code '-'} + * ('\u002d'). If the first argument is not + * negative, no sign character appears in the result. + * + *

The remaining characters of the result represent the magnitude + * of the first argument. If the magnitude is zero, it is + * represented by a single zero character {@code '0'} + * ('\u0030'); otherwise, the first character of + * the representation of the magnitude will not be the zero + * character. The following ASCII characters are used as digits: + * + *

+ * {@code 0123456789abcdefghijklmnopqrstuvwxyz} + *
+ * + * These are '\u0030' through + * '\u0039' and '\u0061' through + * '\u007a'. If {@code radix} is + * N, then the first N of these characters + * are used as radix-N digits in the order shown. Thus, + * the digits for hexadecimal (radix 16) are + * {@code 0123456789abcdef}. If uppercase letters are + * desired, the {@link java.lang.String#toUpperCase()} method may + * be called on the result: + * + *
+ * {@code Long.toString(n, 16).toUpperCase()} + *
+ * + * @param i a {@code long} to be converted to a string. + * @param radix the radix to use in the string representation. + * @return a string representation of the argument in the specified radix. + * @see java.lang.Character#MAX_RADIX + * @see java.lang.Character#MIN_RADIX + */ + public static String toString(long i, int radix) { + if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) + radix = 10; + if (radix == 10) + return toString(i); + char[] buf = new char[65]; + int charPos = 64; + boolean negative = (i < 0); + + if (!negative) { + i = -i; + } + + while (i <= -radix) { + buf[charPos--] = Integer.digits[(int)(-(i % radix))]; + i = i / radix; + } + buf[charPos] = Integer.digits[(int)(-i)]; + + if (negative) { + buf[--charPos] = '-'; + } + + return new String(buf, charPos, (65 - charPos)); + } + + /** + * Returns a string representation of the {@code long} + * argument as an unsigned integer in base 16. + * + *

The unsigned {@code long} value is the argument plus + * 264 if the argument is negative; otherwise, it is + * equal to the argument. This value is converted to a string of + * ASCII digits in hexadecimal (base 16) with no extra + * leading {@code 0}s. If the unsigned magnitude is zero, it + * is represented by a single zero character {@code '0'} + * ('\u0030'); otherwise, the first character of + * the representation of the unsigned magnitude will not be the + * zero character. The following characters are used as + * hexadecimal digits: + * + *

+ * {@code 0123456789abcdef} + *
+ * + * These are the characters '\u0030' through + * '\u0039' and '\u0061' through + * '\u0066'. If uppercase letters are desired, + * the {@link java.lang.String#toUpperCase()} method may be called + * on the result: + * + *
+ * {@code Long.toHexString(n).toUpperCase()} + *
+ * + * @param i a {@code long} to be converted to a string. + * @return the string representation of the unsigned {@code long} + * value represented by the argument in hexadecimal + * (base 16). + * @since JDK 1.0.2 + */ + public static String toHexString(long i) { + return toUnsignedString(i, 4); + } + + /** + * Returns a string representation of the {@code long} + * argument as an unsigned integer in base 8. + * + *

The unsigned {@code long} value is the argument plus + * 264 if the argument is negative; otherwise, it is + * equal to the argument. This value is converted to a string of + * ASCII digits in octal (base 8) with no extra leading + * {@code 0}s. + * + *

If the unsigned magnitude is zero, it is represented by a + * single zero character {@code '0'} + * ('\u0030'); otherwise, the first character of + * the representation of the unsigned magnitude will not be the + * zero character. The following characters are used as octal + * digits: + * + *

+ * {@code 01234567} + *
+ * + * These are the characters '\u0030' through + * '\u0037'. + * + * @param i a {@code long} to be converted to a string. + * @return the string representation of the unsigned {@code long} + * value represented by the argument in octal (base 8). + * @since JDK 1.0.2 + */ + public static String toOctalString(long i) { + return toUnsignedString(i, 3); + } + + /** + * Returns a string representation of the {@code long} + * argument as an unsigned integer in base 2. + * + *

The unsigned {@code long} value is the argument plus + * 264 if the argument is negative; otherwise, it is + * equal to the argument. This value is converted to a string of + * ASCII digits in binary (base 2) with no extra leading + * {@code 0}s. If the unsigned magnitude is zero, it is + * represented by a single zero character {@code '0'} + * ('\u0030'); otherwise, the first character of + * the representation of the unsigned magnitude will not be the + * zero character. The characters {@code '0'} + * ('\u0030') and {@code '1'} + * ('\u0031') are used as binary digits. + * + * @param i a {@code long} to be converted to a string. + * @return the string representation of the unsigned {@code long} + * value represented by the argument in binary (base 2). + * @since JDK 1.0.2 + */ + public static String toBinaryString(long i) { + return toUnsignedString(i, 1); + } + + /** + * Convert the integer to an unsigned number. + */ + private static String toUnsignedString(long i, int shift) { + char[] buf = new char[64]; + int charPos = 64; + int radix = 1 << shift; + long mask = radix - 1; + do { + buf[--charPos] = Integer.digits[(int)(i & mask)]; + i >>>= shift; + } while (i != 0); + return new String(buf, charPos, (64 - charPos)); + } + + /** + * Returns a {@code String} object representing the specified + * {@code long}. The argument is converted to signed decimal + * representation and returned as a string, exactly as if the + * argument and the radix 10 were given as arguments to the {@link + * #toString(long, int)} method. + * + * @param i a {@code long} to be converted. + * @return a string representation of the argument in base 10. + */ + public static String toString(long i) { + if (i == Long.MIN_VALUE) + return "-9223372036854775808"; + int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i); + char[] buf = new char[size]; + getChars(i, size, buf); + return new String(0, size, buf); + } + + /** + * Places characters representing the integer i into the + * character array buf. The characters are placed into + * the buffer backwards starting with the least significant + * digit at the specified index (exclusive), and working + * backwards from there. + * + * Will fail if i == Long.MIN_VALUE + */ + static void getChars(long i, int index, char[] buf) { + long q; + int r; + int charPos = index; + char sign = 0; + + if (i < 0) { + sign = '-'; + i = -i; + } + + // Get 2 digits/iteration using longs until quotient fits into an int + while (i > Integer.MAX_VALUE) { + q = i / 100; + // really: r = i - (q * 100); + r = (int)(i - ((q << 6) + (q << 5) + (q << 2))); + i = q; + buf[--charPos] = Integer.DigitOnes[r]; + buf[--charPos] = Integer.DigitTens[r]; + } + + // Get 2 digits/iteration using ints + int q2; + int i2 = (int)i; + while (i2 >= 65536) { + q2 = i2 / 100; + // really: r = i2 - (q * 100); + r = i2 - ((q2 << 6) + (q2 << 5) + (q2 << 2)); + i2 = q2; + buf[--charPos] = Integer.DigitOnes[r]; + buf[--charPos] = Integer.DigitTens[r]; + } + + // Fall thru to fast mode for smaller numbers + // assert(i2 <= 65536, i2); + for (;;) { + q2 = (i2 * 52429) >>> (16+3); + r = i2 - ((q2 << 3) + (q2 << 1)); // r = i2-(q2*10) ... + buf[--charPos] = Integer.digits[r]; + i2 = q2; + if (i2 == 0) break; + } + if (sign != 0) { + buf[--charPos] = sign; + } + } + + // Requires positive x + static int stringSize(long x) { + long p = 10; + for (int i=1; i<19; i++) { + if (x < p) + return i; + p = 10*p; + } + return 19; + } + + /** + * Parses the string argument as a signed {@code long} in the + * radix specified by the second argument. The characters in the + * string must all be digits of the specified radix (as determined + * by whether {@link java.lang.Character#digit(char, int)} returns + * a nonnegative value), except that the first character may be an + * ASCII minus sign {@code '-'} ('\u002D') to + * indicate a negative value or an ASCII plus sign {@code '+'} + * ('\u002B') to indicate a positive value. The + * resulting {@code long} value is returned. + * + *

Note that neither the character {@code L} + * ('\u004C') nor {@code l} + * ('\u006C') is permitted to appear at the end + * of the string as a type indicator, as would be permitted in + * Java programming language source code - except that either + * {@code L} or {@code l} may appear as a digit for a + * radix greater than 22. + * + *

An exception of type {@code NumberFormatException} is + * thrown if any of the following situations occurs: + *

    + * + *
  • The first argument is {@code null} or is a string of + * length zero. + * + *
  • The {@code radix} is either smaller than {@link + * java.lang.Character#MIN_RADIX} or larger than {@link + * java.lang.Character#MAX_RADIX}. + * + *
  • Any character of the string is not a digit of the specified + * radix, except that the first character may be a minus sign + * {@code '-'} ('\u002d') or plus sign {@code + * '+'} ('\u002B') provided that the string is + * longer than length 1. + * + *
  • The value represented by the string is not a value of type + * {@code long}. + *
+ * + *

Examples: + *

+     * parseLong("0", 10) returns 0L
+     * parseLong("473", 10) returns 473L
+     * parseLong("+42", 10) returns 42L
+     * parseLong("-0", 10) returns 0L
+     * parseLong("-FF", 16) returns -255L
+     * parseLong("1100110", 2) returns 102L
+     * parseLong("99", 8) throws a NumberFormatException
+     * parseLong("Hazelnut", 10) throws a NumberFormatException
+     * parseLong("Hazelnut", 36) returns 1356099454469L
+     * 
+ * + * @param s the {@code String} containing the + * {@code long} representation to be parsed. + * @param radix the radix to be used while parsing {@code s}. + * @return the {@code long} represented by the string argument in + * the specified radix. + * @throws NumberFormatException if the string does not contain a + * parsable {@code long}. + */ + public static long parseLong(String s, int radix) + throws NumberFormatException + { + if (s == null) { + throw new NumberFormatException("null"); + } + + if (radix < Character.MIN_RADIX) { + throw new NumberFormatException("radix " + radix + + " less than Character.MIN_RADIX"); + } + if (radix > Character.MAX_RADIX) { + throw new NumberFormatException("radix " + radix + + " greater than Character.MAX_RADIX"); + } + + long result = 0; + boolean negative = false; + int i = 0, len = s.length(); + long limit = -Long.MAX_VALUE; + long multmin; + int digit; + + if (len > 0) { + char firstChar = s.charAt(0); + if (firstChar < '0') { // Possible leading "+" or "-" + if (firstChar == '-') { + negative = true; + limit = Long.MIN_VALUE; + } else if (firstChar != '+') + throw NumberFormatException.forInputString(s); + + if (len == 1) // Cannot have lone "+" or "-" + throw NumberFormatException.forInputString(s); + i++; + } + multmin = limit / radix; + while (i < len) { + // Accumulating negatively avoids surprises near MAX_VALUE + digit = Character.digit(s.charAt(i++),radix); + if (digit < 0) { + throw NumberFormatException.forInputString(s); + } + if (result < multmin) { + throw NumberFormatException.forInputString(s); + } + result *= radix; + if (result < limit + digit) { + throw NumberFormatException.forInputString(s); + } + result -= digit; + } + } else { + throw NumberFormatException.forInputString(s); + } + return negative ? result : -result; + } + + /** + * Parses the string argument as a signed decimal {@code long}. + * The characters in the string must all be decimal digits, except + * that the first character may be an ASCII minus sign {@code '-'} + * (\u002D') to indicate a negative value or an + * ASCII plus sign {@code '+'} ('\u002B') to + * indicate a positive value. The resulting {@code long} value is + * returned, exactly as if the argument and the radix {@code 10} + * were given as arguments to the {@link + * #parseLong(java.lang.String, int)} method. + * + *

Note that neither the character {@code L} + * ('\u004C') nor {@code l} + * ('\u006C') is permitted to appear at the end + * of the string as a type indicator, as would be permitted in + * Java programming language source code. + * + * @param s a {@code String} containing the {@code long} + * representation to be parsed + * @return the {@code long} represented by the argument in + * decimal. + * @throws NumberFormatException if the string does not contain a + * parsable {@code long}. + */ + public static long parseLong(String s) throws NumberFormatException { + return parseLong(s, 10); + } + + /** + * Returns a {@code Long} object holding the value + * extracted from the specified {@code String} when parsed + * with the radix given by the second argument. The first + * argument is interpreted as representing a signed + * {@code long} in the radix specified by the second + * argument, exactly as if the arguments were given to the {@link + * #parseLong(java.lang.String, int)} method. The result is a + * {@code Long} object that represents the {@code long} + * value specified by the string. + * + *

In other words, this method returns a {@code Long} object equal + * to the value of: + * + *

+ * {@code new Long(Long.parseLong(s, radix))} + *
+ * + * @param s the string to be parsed + * @param radix the radix to be used in interpreting {@code s} + * @return a {@code Long} object holding the value + * represented by the string argument in the specified + * radix. + * @throws NumberFormatException If the {@code String} does not + * contain a parsable {@code long}. + */ + public static Long valueOf(String s, int radix) throws NumberFormatException { + return Long.valueOf(parseLong(s, radix)); + } + + /** + * Returns a {@code Long} object holding the value + * of the specified {@code String}. The argument is + * interpreted as representing a signed decimal {@code long}, + * exactly as if the argument were given to the {@link + * #parseLong(java.lang.String)} method. The result is a + * {@code Long} object that represents the integer value + * specified by the string. + * + *

In other words, this method returns a {@code Long} object + * equal to the value of: + * + *

+ * {@code new Long(Long.parseLong(s))} + *
+ * + * @param s the string to be parsed. + * @return a {@code Long} object holding the value + * represented by the string argument. + * @throws NumberFormatException If the string cannot be parsed + * as a {@code long}. + */ + public static Long valueOf(String s) throws NumberFormatException + { + return Long.valueOf(parseLong(s, 10)); + } + + private static class LongCache { + private LongCache(){} + + static final Long cache[] = new Long[-(-128) + 127 + 1]; + + static { + for(int i = 0; i < cache.length; i++) + cache[i] = new Long(i - 128); + } + } + + /** + * Returns a {@code Long} instance representing the specified + * {@code long} value. + * If a new {@code Long} instance is not required, this method + * should generally be used in preference to the constructor + * {@link #Long(long)}, as this method is likely to yield + * significantly better space and time performance by caching + * frequently requested values. + * + * Note that unlike the {@linkplain Integer#valueOf(int) + * corresponding method} in the {@code Integer} class, this method + * is not required to cache values within a particular + * range. + * + * @param l a long value. + * @return a {@code Long} instance representing {@code l}. + * @since 1.5 + */ + public static Long valueOf(long l) { + final int offset = 128; + if (l >= -128 && l <= 127) { // will cache + return LongCache.cache[(int)l + offset]; + } + return new Long(l); + } + + /** + * Decodes a {@code String} into a {@code Long}. + * Accepts decimal, hexadecimal, and octal numbers given by the + * following grammar: + * + *
+ *
+ *
DecodableString: + *
Signopt DecimalNumeral + *
Signopt {@code 0x} HexDigits + *
Signopt {@code 0X} HexDigits + *
Signopt {@code #} HexDigits + *
Signopt {@code 0} OctalDigits + *

+ *

Sign: + *
{@code -} + *
{@code +} + *
+ *
+ * + * DecimalNumeral, HexDigits, and OctalDigits + * are as defined in section 3.10.1 of + * The Java™ Language Specification, + * except that underscores are not accepted between digits. + * + *

The sequence of characters following an optional + * sign and/or radix specifier ("{@code 0x}", "{@code 0X}", + * "{@code #}", or leading zero) is parsed as by the {@code + * Long.parseLong} method with the indicated radix (10, 16, or 8). + * This sequence of characters must represent a positive value or + * a {@link NumberFormatException} will be thrown. The result is + * negated if first character of the specified {@code String} is + * the minus sign. No whitespace characters are permitted in the + * {@code String}. + * + * @param nm the {@code String} to decode. + * @return a {@code Long} object holding the {@code long} + * value represented by {@code nm} + * @throws NumberFormatException if the {@code String} does not + * contain a parsable {@code long}. + * @see java.lang.Long#parseLong(String, int) + * @since 1.2 + */ + public static Long decode(String nm) throws NumberFormatException { + int radix = 10; + int index = 0; + boolean negative = false; + Long result; + + if (nm.length() == 0) + throw new NumberFormatException("Zero length string"); + char firstChar = nm.charAt(0); + // Handle sign, if present + if (firstChar == '-') { + negative = true; + index++; + } else if (firstChar == '+') + index++; + + // Handle radix specifier, if present + if (nm.startsWith("0x", index) || nm.startsWith("0X", index)) { + index += 2; + radix = 16; + } + else if (nm.startsWith("#", index)) { + index ++; + radix = 16; + } + else if (nm.startsWith("0", index) && nm.length() > 1 + index) { + index ++; + radix = 8; + } + + if (nm.startsWith("-", index) || nm.startsWith("+", index)) + throw new NumberFormatException("Sign character in wrong position"); + + try { + result = Long.valueOf(nm.substring(index), radix); + result = negative ? Long.valueOf(-result.longValue()) : result; + } catch (NumberFormatException e) { + // If number is Long.MIN_VALUE, we'll end up here. The next line + // handles this case, and causes any genuine format error to be + // rethrown. + String constant = negative ? ("-" + nm.substring(index)) + : nm.substring(index); + result = Long.valueOf(constant, radix); + } + return result; + } + + /** + * The value of the {@code Long}. + * + * @serial + */ + private final long value; + + /** + * Constructs a newly allocated {@code Long} object that + * represents the specified {@code long} argument. + * + * @param value the value to be represented by the + * {@code Long} object. + */ + public Long(long value) { + this.value = value; + } + + /** + * Constructs a newly allocated {@code Long} object that + * represents the {@code long} value indicated by the + * {@code String} parameter. The string is converted to a + * {@code long} value in exactly the manner used by the + * {@code parseLong} method for radix 10. + * + * @param s the {@code String} to be converted to a + * {@code Long}. + * @throws NumberFormatException if the {@code String} does not + * contain a parsable {@code long}. + * @see java.lang.Long#parseLong(java.lang.String, int) + */ + public Long(String s) throws NumberFormatException { + this.value = parseLong(s, 10); + } + + /** + * Returns the value of this {@code Long} as a + * {@code byte}. + */ + public byte byteValue() { + return (byte)value; + } + + /** + * Returns the value of this {@code Long} as a + * {@code short}. + */ + public short shortValue() { + return (short)value; + } + + /** + * Returns the value of this {@code Long} as an + * {@code int}. + */ + public int intValue() { + return (int)value; + } + + /** + * Returns the value of this {@code Long} as a + * {@code long} value. + */ + public long longValue() { + return (long)value; + } + + /** + * Returns the value of this {@code Long} as a + * {@code float}. + */ + public float floatValue() { + return (float)value; + } + + /** + * Returns the value of this {@code Long} as a + * {@code double}. + */ + public double doubleValue() { + return (double)value; + } + + /** + * Returns a {@code String} object representing this + * {@code Long}'s value. The value is converted to signed + * decimal representation and returned as a string, exactly as if + * the {@code long} value were given as an argument to the + * {@link java.lang.Long#toString(long)} method. + * + * @return a string representation of the value of this object in + * base 10. + */ + public String toString() { + return toString(value); + } + + /** + * Returns a hash code for this {@code Long}. The result is + * the exclusive OR of the two halves of the primitive + * {@code long} value held by this {@code Long} + * object. That is, the hashcode is the value of the expression: + * + *

+ * {@code (int)(this.longValue()^(this.longValue()>>>32))} + *
+ * + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)(value ^ (value >>> 32)); + } + + /** + * Compares this object to the specified object. The result is + * {@code true} if and only if the argument is not + * {@code null} and is a {@code Long} object that + * contains the same {@code long} value as this object. + * + * @param obj the object to compare with. + * @return {@code true} if the objects are the same; + * {@code false} otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof Long) { + return value == ((Long)obj).longValue(); + } + return false; + } + + /** + * Determines the {@code long} value of the system property + * with the specified name. + * + *

The first argument is treated as the name of a system property. + * System properties are accessible through the {@link + * java.lang.System#getProperty(java.lang.String)} method. The + * string value of this property is then interpreted as a + * {@code long} value and a {@code Long} object + * representing this value is returned. Details of possible + * numeric formats can be found with the definition of + * {@code getProperty}. + * + *

If there is no property with the specified name, if the + * specified name is empty or {@code null}, or if the + * property does not have the correct numeric format, then + * {@code null} is returned. + * + *

In other words, this method returns a {@code Long} object equal to + * the value of: + * + *

+ * {@code getLong(nm, null)} + *
+ * + * @param nm property name. + * @return the {@code Long} value of the property. + * @see java.lang.System#getProperty(java.lang.String) + * @see java.lang.System#getProperty(java.lang.String, java.lang.String) + */ + public static Long getLong(String nm) { + return getLong(nm, null); + } + + /** + * Determines the {@code long} value of the system property + * with the specified name. + * + *

The first argument is treated as the name of a system property. + * System properties are accessible through the {@link + * java.lang.System#getProperty(java.lang.String)} method. The + * string value of this property is then interpreted as a + * {@code long} value and a {@code Long} object + * representing this value is returned. Details of possible + * numeric formats can be found with the definition of + * {@code getProperty}. + * + *

The second argument is the default value. A {@code Long} object + * that represents the value of the second argument is returned if there + * is no property of the specified name, if the property does not have + * the correct numeric format, or if the specified name is empty or null. + * + *

In other words, this method returns a {@code Long} object equal + * to the value of: + * + *

+ * {@code getLong(nm, new Long(val))} + *
+ * + * but in practice it may be implemented in a manner such as: + * + *
+     * Long result = getLong(nm, null);
+     * return (result == null) ? new Long(val) : result;
+     * 
+ * + * to avoid the unnecessary allocation of a {@code Long} object when + * the default value is not needed. + * + * @param nm property name. + * @param val default value. + * @return the {@code Long} value of the property. + * @see java.lang.System#getProperty(java.lang.String) + * @see java.lang.System#getProperty(java.lang.String, java.lang.String) + */ + public static Long getLong(String nm, long val) { + Long result = Long.getLong(nm, null); + return (result == null) ? Long.valueOf(val) : result; + } + + /** + * Returns the {@code long} value of the system property with + * the specified name. The first argument is treated as the name + * of a system property. System properties are accessible through + * the {@link java.lang.System#getProperty(java.lang.String)} + * method. The string value of this property is then interpreted + * as a {@code long} value, as per the + * {@code Long.decode} method, and a {@code Long} object + * representing this value is returned. + * + *
    + *
  • If the property value begins with the two ASCII characters + * {@code 0x} or the ASCII character {@code #}, not followed by + * a minus sign, then the rest of it is parsed as a hexadecimal integer + * exactly as for the method {@link #valueOf(java.lang.String, int)} + * with radix 16. + *
  • If the property value begins with the ASCII character + * {@code 0} followed by another character, it is parsed as + * an octal integer exactly as by the method {@link + * #valueOf(java.lang.String, int)} with radix 8. + *
  • Otherwise the property value is parsed as a decimal + * integer exactly as by the method + * {@link #valueOf(java.lang.String, int)} with radix 10. + *
+ * + *

Note that, in every case, neither {@code L} + * ('\u004C') nor {@code l} + * ('\u006C') is permitted to appear at the end + * of the property value as a type indicator, as would be + * permitted in Java programming language source code. + * + *

The second argument is the default value. The default value is + * returned if there is no property of the specified name, if the + * property does not have the correct numeric format, or if the + * specified name is empty or {@code null}. + * + * @param nm property name. + * @param val default value. + * @return the {@code Long} value of the property. + * @see java.lang.System#getProperty(java.lang.String) + * @see java.lang.System#getProperty(java.lang.String, java.lang.String) + * @see java.lang.Long#decode + */ + public static Long getLong(String nm, Long val) { + String v = null; + try { + v = String.getProperty(nm); + } catch (IllegalArgumentException e) { + } catch (NullPointerException e) { + } + if (v != null) { + try { + return Long.decode(v); + } catch (NumberFormatException e) { + } + } + return val; + } + + /** + * Compares two {@code Long} objects numerically. + * + * @param anotherLong the {@code Long} to be compared. + * @return the value {@code 0} if this {@code Long} is + * equal to the argument {@code Long}; a value less than + * {@code 0} if this {@code Long} is numerically less + * than the argument {@code Long}; and a value greater + * than {@code 0} if this {@code Long} is numerically + * greater than the argument {@code Long} (signed + * comparison). + * @since 1.2 + */ + public int compareTo(Long anotherLong) { + return compare(this.value, anotherLong.value); + } + + /** + * Compares two {@code long} values numerically. + * The value returned is identical to what would be returned by: + *

+     *    Long.valueOf(x).compareTo(Long.valueOf(y))
+     * 
+ * + * @param x the first {@code long} to compare + * @param y the second {@code long} to compare + * @return the value {@code 0} if {@code x == y}; + * a value less than {@code 0} if {@code x < y}; and + * a value greater than {@code 0} if {@code x > y} + * @since 1.7 + */ + public static int compare(long x, long y) { + return (x < y) ? -1 : ((x == y) ? 0 : 1); + } + + + // Bit Twiddling + + /** + * The number of bits used to represent a {@code long} value in two's + * complement binary form. + * + * @since 1.5 + */ + public static final int SIZE = 64; + + /** + * Returns a {@code long} value with at most a single one-bit, in the + * position of the highest-order ("leftmost") one-bit in the specified + * {@code long} value. Returns zero if the specified value has no + * one-bits in its two's complement binary representation, that is, if it + * is equal to zero. + * + * @return a {@code long} value with a single one-bit, in the position + * of the highest-order one-bit in the specified value, or zero if + * the specified value is itself equal to zero. + * @since 1.5 + */ + public static long highestOneBit(long i) { + // HD, Figure 3-1 + i |= (i >> 1); + i |= (i >> 2); + i |= (i >> 4); + i |= (i >> 8); + i |= (i >> 16); + i |= (i >> 32); + return i - (i >>> 1); + } + + /** + * Returns a {@code long} value with at most a single one-bit, in the + * position of the lowest-order ("rightmost") one-bit in the specified + * {@code long} value. Returns zero if the specified value has no + * one-bits in its two's complement binary representation, that is, if it + * is equal to zero. + * + * @return a {@code long} value with a single one-bit, in the position + * of the lowest-order one-bit in the specified value, or zero if + * the specified value is itself equal to zero. + * @since 1.5 + */ + public static long lowestOneBit(long i) { + // HD, Section 2-1 + return i & -i; + } + + /** + * Returns the number of zero bits preceding the highest-order + * ("leftmost") one-bit in the two's complement binary representation + * of the specified {@code long} value. Returns 64 if the + * specified value has no one-bits in its two's complement representation, + * in other words if it is equal to zero. + * + *

Note that this method is closely related to the logarithm base 2. + * For all positive {@code long} values x: + *

    + *
  • floor(log2(x)) = {@code 63 - numberOfLeadingZeros(x)} + *
  • ceil(log2(x)) = {@code 64 - numberOfLeadingZeros(x - 1)} + *
+ * + * @return the number of zero bits preceding the highest-order + * ("leftmost") one-bit in the two's complement binary representation + * of the specified {@code long} value, or 64 if the value + * is equal to zero. + * @since 1.5 + */ + public static int numberOfLeadingZeros(long i) { + // HD, Figure 5-6 + if (i == 0) + return 64; + int n = 1; + int x = (int)(i >>> 32); + if (x == 0) { n += 32; x = (int)i; } + if (x >>> 16 == 0) { n += 16; x <<= 16; } + if (x >>> 24 == 0) { n += 8; x <<= 8; } + if (x >>> 28 == 0) { n += 4; x <<= 4; } + if (x >>> 30 == 0) { n += 2; x <<= 2; } + n -= x >>> 31; + return n; + } + + /** + * Returns the number of zero bits following the lowest-order ("rightmost") + * one-bit in the two's complement binary representation of the specified + * {@code long} value. Returns 64 if the specified value has no + * one-bits in its two's complement representation, in other words if it is + * equal to zero. + * + * @return the number of zero bits following the lowest-order ("rightmost") + * one-bit in the two's complement binary representation of the + * specified {@code long} value, or 64 if the value is equal + * to zero. + * @since 1.5 + */ + public static int numberOfTrailingZeros(long i) { + // HD, Figure 5-14 + int x, y; + if (i == 0) return 64; + int n = 63; + y = (int)i; if (y != 0) { n = n -32; x = y; } else x = (int)(i>>>32); + y = x <<16; if (y != 0) { n = n -16; x = y; } + y = x << 8; if (y != 0) { n = n - 8; x = y; } + y = x << 4; if (y != 0) { n = n - 4; x = y; } + y = x << 2; if (y != 0) { n = n - 2; x = y; } + return n - ((x << 1) >>> 31); + } + + /** + * Returns the number of one-bits in the two's complement binary + * representation of the specified {@code long} value. This function is + * sometimes referred to as the population count. + * + * @return the number of one-bits in the two's complement binary + * representation of the specified {@code long} value. + * @since 1.5 + */ + public static int bitCount(long i) { + // HD, Figure 5-14 + i = i - ((i >>> 1) & 0x5555555555555555L); + i = (i & 0x3333333333333333L) + ((i >>> 2) & 0x3333333333333333L); + i = (i + (i >>> 4)) & 0x0f0f0f0f0f0f0f0fL; + i = i + (i >>> 8); + i = i + (i >>> 16); + i = i + (i >>> 32); + return (int)i & 0x7f; + } + + /** + * Returns the value obtained by rotating the two's complement binary + * representation of the specified {@code long} value left by the + * specified number of bits. (Bits shifted out of the left hand, or + * high-order, side reenter on the right, or low-order.) + * + *

Note that left rotation with a negative distance is equivalent to + * right rotation: {@code rotateLeft(val, -distance) == rotateRight(val, + * distance)}. Note also that rotation by any multiple of 64 is a + * no-op, so all but the last six bits of the rotation distance can be + * ignored, even if the distance is negative: {@code rotateLeft(val, + * distance) == rotateLeft(val, distance & 0x3F)}. + * + * @return the value obtained by rotating the two's complement binary + * representation of the specified {@code long} value left by the + * specified number of bits. + * @since 1.5 + */ + public static long rotateLeft(long i, int distance) { + return (i << distance) | (i >>> -distance); + } + + /** + * Returns the value obtained by rotating the two's complement binary + * representation of the specified {@code long} value right by the + * specified number of bits. (Bits shifted out of the right hand, or + * low-order, side reenter on the left, or high-order.) + * + *

Note that right rotation with a negative distance is equivalent to + * left rotation: {@code rotateRight(val, -distance) == rotateLeft(val, + * distance)}. Note also that rotation by any multiple of 64 is a + * no-op, so all but the last six bits of the rotation distance can be + * ignored, even if the distance is negative: {@code rotateRight(val, + * distance) == rotateRight(val, distance & 0x3F)}. + * + * @return the value obtained by rotating the two's complement binary + * representation of the specified {@code long} value right by the + * specified number of bits. + * @since 1.5 + */ + public static long rotateRight(long i, int distance) { + return (i >>> distance) | (i << -distance); + } + + /** + * Returns the value obtained by reversing the order of the bits in the + * two's complement binary representation of the specified {@code long} + * value. + * + * @return the value obtained by reversing order of the bits in the + * specified {@code long} value. + * @since 1.5 + */ + public static long reverse(long i) { + // HD, Figure 7-1 + i = (i & 0x5555555555555555L) << 1 | (i >>> 1) & 0x5555555555555555L; + i = (i & 0x3333333333333333L) << 2 | (i >>> 2) & 0x3333333333333333L; + i = (i & 0x0f0f0f0f0f0f0f0fL) << 4 | (i >>> 4) & 0x0f0f0f0f0f0f0f0fL; + i = (i & 0x00ff00ff00ff00ffL) << 8 | (i >>> 8) & 0x00ff00ff00ff00ffL; + i = (i << 48) | ((i & 0xffff0000L) << 16) | + ((i >>> 16) & 0xffff0000L) | (i >>> 48); + return i; + } + + /** + * Returns the signum function of the specified {@code long} value. (The + * return value is -1 if the specified value is negative; 0 if the + * specified value is zero; and 1 if the specified value is positive.) + * + * @return the signum function of the specified {@code long} value. + * @since 1.5 + */ + public static int signum(long i) { + // HD, Section 2-7 + return (int) ((i >> 63) | (-i >>> 63)); + } + + /** + * Returns the value obtained by reversing the order of the bytes in the + * two's complement representation of the specified {@code long} value. + * + * @return the value obtained by reversing the bytes in the specified + * {@code long} value. + * @since 1.5 + */ + public static long reverseBytes(long i) { + i = (i & 0x00ff00ff00ff00ffL) << 8 | (i >>> 8) & 0x00ff00ff00ff00ffL; + return (i << 48) | ((i & 0xffff0000L) << 16) | + ((i >>> 16) & 0xffff0000L) | (i >>> 48); + } + + /** use serialVersionUID from JDK 1.0.2 for interoperability */ + private static final long serialVersionUID = 4290774380558885855L; +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Math.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Math.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,1523 @@ +/* + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + + +/** + * The class {@code Math} contains methods for performing basic + * numeric operations such as the elementary exponential, logarithm, + * square root, and trigonometric functions. + * + *

Unlike some of the numeric methods of class + * {@code StrictMath}, all implementations of the equivalent + * functions of class {@code Math} are not defined to return the + * bit-for-bit same results. This relaxation permits + * better-performing implementations where strict reproducibility is + * not required. + * + *

By default many of the {@code Math} methods simply call + * the equivalent method in {@code StrictMath} for their + * implementation. Code generators are encouraged to use + * platform-specific native libraries or microprocessor instructions, + * where available, to provide higher-performance implementations of + * {@code Math} methods. Such higher-performance + * implementations still must conform to the specification for + * {@code Math}. + * + *

The quality of implementation specifications concern two + * properties, accuracy of the returned result and monotonicity of the + * method. Accuracy of the floating-point {@code Math} methods + * is measured in terms of ulps, units in the last place. For + * a given floating-point format, an ulp of a specific real number + * value is the distance between the two floating-point values + * bracketing that numerical value. When discussing the accuracy of a + * method as a whole rather than at a specific argument, the number of + * ulps cited is for the worst-case error at any argument. If a + * method always has an error less than 0.5 ulps, the method always + * returns the floating-point number nearest the exact result; such a + * method is correctly rounded. A correctly rounded method is + * generally the best a floating-point approximation can be; however, + * it is impractical for many floating-point methods to be correctly + * rounded. Instead, for the {@code Math} class, a larger error + * bound of 1 or 2 ulps is allowed for certain methods. Informally, + * with a 1 ulp error bound, when the exact result is a representable + * number, the exact result should be returned as the computed result; + * otherwise, either of the two floating-point values which bracket + * the exact result may be returned. For exact results large in + * magnitude, one of the endpoints of the bracket may be infinite. + * Besides accuracy at individual arguments, maintaining proper + * relations between the method at different arguments is also + * important. Therefore, most methods with more than 0.5 ulp errors + * are required to be semi-monotonic: whenever the mathematical + * function is non-decreasing, so is the floating-point approximation, + * likewise, whenever the mathematical function is non-increasing, so + * is the floating-point approximation. Not all approximations that + * have 1 ulp accuracy will automatically meet the monotonicity + * requirements. + * + * @author unascribed + * @author Joseph D. Darcy + * @since JDK1.0 + */ + +public final class Math { + + /** + * Don't let anyone instantiate this class. + */ + private Math() {} + + /** + * The {@code double} value that is closer than any other to + * e, the base of the natural logarithms. + */ + public static final double E = 2.7182818284590452354; + + /** + * The {@code double} value that is closer than any other to + * pi, the ratio of the circumference of a circle to its + * diameter. + */ + public static final double PI = 3.14159265358979323846; + + /** + * Returns the trigonometric sine of an angle. Special cases: + *

  • If the argument is NaN or an infinity, then the + * result is NaN. + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument.
+ * + *

The computed result must be within 1 ulp of the exact result. + * Results must be semi-monotonic. + * + * @param a an angle, in radians. + * @return the sine of the argument. + */ + public static double sin(double a) { + return StrictMath.sin(a); // default impl. delegates to StrictMath + } + + /** + * Returns the trigonometric cosine of an angle. Special cases: + *

  • If the argument is NaN or an infinity, then the + * result is NaN.
+ * + *

The computed result must be within 1 ulp of the exact result. + * Results must be semi-monotonic. + * + * @param a an angle, in radians. + * @return the cosine of the argument. + */ + public static double cos(double a) { + return StrictMath.cos(a); // default impl. delegates to StrictMath + } + + /** + * Returns the trigonometric tangent of an angle. Special cases: + *

  • If the argument is NaN or an infinity, then the result + * is NaN. + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument.
+ * + *

The computed result must be within 1 ulp of the exact result. + * Results must be semi-monotonic. + * + * @param a an angle, in radians. + * @return the tangent of the argument. + */ + public static double tan(double a) { + return StrictMath.tan(a); // default impl. delegates to StrictMath + } + + /** + * Returns the arc sine of a value; the returned angle is in the + * range -pi/2 through pi/2. Special cases: + *

  • If the argument is NaN or its absolute value is greater + * than 1, then the result is NaN. + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument.
+ * + *

The computed result must be within 1 ulp of the exact result. + * Results must be semi-monotonic. + * + * @param a the value whose arc sine is to be returned. + * @return the arc sine of the argument. + */ + public static double asin(double a) { + return StrictMath.asin(a); // default impl. delegates to StrictMath + } + + /** + * Returns the arc cosine of a value; the returned angle is in the + * range 0.0 through pi. Special case: + *

  • If the argument is NaN or its absolute value is greater + * than 1, then the result is NaN.
+ * + *

The computed result must be within 1 ulp of the exact result. + * Results must be semi-monotonic. + * + * @param a the value whose arc cosine is to be returned. + * @return the arc cosine of the argument. + */ + public static double acos(double a) { + return StrictMath.acos(a); // default impl. delegates to StrictMath + } + + /** + * Returns the arc tangent of a value; the returned angle is in the + * range -pi/2 through pi/2. Special cases: + *

  • If the argument is NaN, then the result is NaN. + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument.
+ * + *

The computed result must be within 1 ulp of the exact result. + * Results must be semi-monotonic. + * + * @param a the value whose arc tangent is to be returned. + * @return the arc tangent of the argument. + */ + public static double atan(double a) { + return StrictMath.atan(a); // default impl. delegates to StrictMath + } + + /** + * Converts an angle measured in degrees to an approximately + * equivalent angle measured in radians. The conversion from + * degrees to radians is generally inexact. + * + * @param angdeg an angle, in degrees + * @return the measurement of the angle {@code angdeg} + * in radians. + * @since 1.2 + */ + public static double toRadians(double angdeg) { + return angdeg / 180.0 * PI; + } + + /** + * Converts an angle measured in radians to an approximately + * equivalent angle measured in degrees. The conversion from + * radians to degrees is generally inexact; users should + * not expect {@code cos(toRadians(90.0))} to exactly + * equal {@code 0.0}. + * + * @param angrad an angle, in radians + * @return the measurement of the angle {@code angrad} + * in degrees. + * @since 1.2 + */ + public static double toDegrees(double angrad) { + return angrad * 180.0 / PI; + } + + /** + * Returns Euler's number e raised to the power of a + * {@code double} value. Special cases: + *

  • If the argument is NaN, the result is NaN. + *
  • If the argument is positive infinity, then the result is + * positive infinity. + *
  • If the argument is negative infinity, then the result is + * positive zero.
+ * + *

The computed result must be within 1 ulp of the exact result. + * Results must be semi-monotonic. + * + * @param a the exponent to raise e to. + * @return the value e{@code a}, + * where e is the base of the natural logarithms. + */ + public static double exp(double a) { + return StrictMath.exp(a); // default impl. delegates to StrictMath + } + + /** + * Returns the natural logarithm (base e) of a {@code double} + * value. Special cases: + *

  • If the argument is NaN or less than zero, then the result + * is NaN. + *
  • If the argument is positive infinity, then the result is + * positive infinity. + *
  • If the argument is positive zero or negative zero, then the + * result is negative infinity.
+ * + *

The computed result must be within 1 ulp of the exact result. + * Results must be semi-monotonic. + * + * @param a a value + * @return the value ln {@code a}, the natural logarithm of + * {@code a}. + */ + public static double log(double a) { + return StrictMath.log(a); // default impl. delegates to StrictMath + } + + /** + * Returns the base 10 logarithm of a {@code double} value. + * Special cases: + * + *

  • If the argument is NaN or less than zero, then the result + * is NaN. + *
  • If the argument is positive infinity, then the result is + * positive infinity. + *
  • If the argument is positive zero or negative zero, then the + * result is negative infinity. + *
  • If the argument is equal to 10n for + * integer n, then the result is n. + *
+ * + *

The computed result must be within 1 ulp of the exact result. + * Results must be semi-monotonic. + * + * @param a a value + * @return the base 10 logarithm of {@code a}. + * @since 1.5 + */ + public static double log10(double a) { + return StrictMath.log10(a); // default impl. delegates to StrictMath + } + + /** + * Returns the correctly rounded positive square root of a + * {@code double} value. + * Special cases: + *

  • If the argument is NaN or less than zero, then the result + * is NaN. + *
  • If the argument is positive infinity, then the result is positive + * infinity. + *
  • If the argument is positive zero or negative zero, then the + * result is the same as the argument.
+ * Otherwise, the result is the {@code double} value closest to + * the true mathematical square root of the argument value. + * + * @param a a value. + * @return the positive square root of {@code a}. + * If the argument is NaN or less than zero, the result is NaN. + */ + public static double sqrt(double a) { + return StrictMath.sqrt(a); // default impl. delegates to StrictMath + // Note that hardware sqrt instructions + // frequently can be directly used by JITs + // and should be much faster than doing + // Math.sqrt in software. + } + + + /** + * Returns the cube root of a {@code double} value. For + * positive finite {@code x}, {@code cbrt(-x) == + * -cbrt(x)}; that is, the cube root of a negative value is + * the negative of the cube root of that value's magnitude. + * + * Special cases: + * + *
    + * + *
  • If the argument is NaN, then the result is NaN. + * + *
  • If the argument is infinite, then the result is an infinity + * with the same sign as the argument. + * + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument. + * + *
+ * + *

The computed result must be within 1 ulp of the exact result. + * + * @param a a value. + * @return the cube root of {@code a}. + * @since 1.5 + */ + public static double cbrt(double a) { + return StrictMath.cbrt(a); + } + + /** + * Computes the remainder operation on two arguments as prescribed + * by the IEEE 754 standard. + * The remainder value is mathematically equal to + * f1 - f2 × n, + * where n is the mathematical integer closest to the exact + * mathematical value of the quotient {@code f1/f2}, and if two + * mathematical integers are equally close to {@code f1/f2}, + * then n is the integer that is even. If the remainder is + * zero, its sign is the same as the sign of the first argument. + * Special cases: + *

  • If either argument is NaN, or the first argument is infinite, + * or the second argument is positive zero or negative zero, then the + * result is NaN. + *
  • If the first argument is finite and the second argument is + * infinite, then the result is the same as the first argument.
+ * + * @param f1 the dividend. + * @param f2 the divisor. + * @return the remainder when {@code f1} is divided by + * {@code f2}. + */ + public static double IEEEremainder(double f1, double f2) { + return StrictMath.IEEEremainder(f1, f2); // delegate to StrictMath + } + + /** + * Returns the smallest (closest to negative infinity) + * {@code double} value that is greater than or equal to the + * argument and is equal to a mathematical integer. Special cases: + *
  • If the argument value is already equal to a + * mathematical integer, then the result is the same as the + * argument.
  • If the argument is NaN or an infinity or + * positive zero or negative zero, then the result is the same as + * the argument.
  • If the argument value is less than zero but + * greater than -1.0, then the result is negative zero.
Note + * that the value of {@code Math.ceil(x)} is exactly the + * value of {@code -Math.floor(-x)}. + * + * + * @param a a value. + * @return the smallest (closest to negative infinity) + * floating-point value that is greater than or equal to + * the argument and is equal to a mathematical integer. + */ + public static double ceil(double a) { + return StrictMath.ceil(a); // default impl. delegates to StrictMath + } + + /** + * Returns the largest (closest to positive infinity) + * {@code double} value that is less than or equal to the + * argument and is equal to a mathematical integer. Special cases: + *
  • If the argument value is already equal to a + * mathematical integer, then the result is the same as the + * argument.
  • If the argument is NaN or an infinity or + * positive zero or negative zero, then the result is the same as + * the argument.
+ * + * @param a a value. + * @return the largest (closest to positive infinity) + * floating-point value that less than or equal to the argument + * and is equal to a mathematical integer. + */ + public static double floor(double a) { + return StrictMath.floor(a); // default impl. delegates to StrictMath + } + + /** + * Returns the {@code double} value that is closest in value + * to the argument and is equal to a mathematical integer. If two + * {@code double} values that are mathematical integers are + * equally close, the result is the integer value that is + * even. Special cases: + *
  • If the argument value is already equal to a mathematical + * integer, then the result is the same as the argument. + *
  • If the argument is NaN or an infinity or positive zero or negative + * zero, then the result is the same as the argument.
+ * + * @param a a {@code double} value. + * @return the closest floating-point value to {@code a} that is + * equal to a mathematical integer. + */ + public static double rint(double a) { + return StrictMath.rint(a); // default impl. delegates to StrictMath + } + + /** + * Returns the angle theta from the conversion of rectangular + * coordinates ({@code x}, {@code y}) to polar + * coordinates (r, theta). + * This method computes the phase theta by computing an arc tangent + * of {@code y/x} in the range of -pi to pi. Special + * cases: + *
  • If either argument is NaN, then the result is NaN. + *
  • 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. + *
  • 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. + *
  • 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 + * {@code double} value closest to pi. + *
  • 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 + * {@code double} value closest to -pi. + *
  • 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 + * {@code double} value closest to pi/2. + *
  • 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 + * {@code double} value closest to -pi/2. + *
  • If both arguments are positive infinity, then the result is the + * {@code double} value closest to pi/4. + *
  • If the first argument is positive infinity and the second argument + * is negative infinity, then the result is the {@code double} + * value closest to 3*pi/4. + *
  • If the first argument is negative infinity and the second argument + * is positive infinity, then the result is the {@code double} value + * closest to -pi/4. + *
  • If both arguments are negative infinity, then the result is the + * {@code double} value closest to -3*pi/4.
+ * + *

The computed result must be within 2 ulps of the exact result. + * Results must be semi-monotonic. + * + * @param y the ordinate coordinate + * @param x the abscissa coordinate + * @return the theta component of the point + * (rtheta) + * in polar coordinates that corresponds to the point + * (xy) in Cartesian coordinates. + */ + public static double atan2(double y, double x) { + return StrictMath.atan2(y, x); // default impl. delegates to StrictMath + } + + /** + * Returns the value of the first argument raised to the power of the + * second argument. Special cases: + * + *

  • If the second argument is positive or negative zero, then the + * result is 1.0. + *
  • If the second argument is 1.0, then the result is the same as the + * first argument. + *
  • If the second argument is NaN, then the result is NaN. + *
  • If the first argument is NaN and the second argument is nonzero, + * then the result is NaN. + * + *
  • 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. + * + *
  • 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. + * + *
  • If the absolute value of the first argument equals 1 and the + * second argument is infinite, then the result is NaN. + * + *
  • 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. + * + *
  • 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. + * + *
  • 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. + * + *
  • 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. + * + *
  • 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. + * + *
  • 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. + * + *
  • If the first argument is finite and less than zero + *
      + *
    • if the second argument is a finite even integer, the + * result is equal to the result of raising the absolute value of + * the first argument to the power of the second argument + * + *
    • if the second argument is a finite odd integer, 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 + * + *
    • if the second argument is finite and not an integer, then + * the result is NaN. + *
    + * + *
  • 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 {@code double} value.
+ * + *

(In the foregoing descriptions, a floating-point value is + * considered to be an integer if and only if it is finite and a + * fixed point of the method {@link #ceil ceil} or, + * equivalently, a fixed point of the method {@link #floor + * floor}. 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.) + * + *

The computed result must be within 1 ulp of the exact result. + * Results must be semi-monotonic. + * + * @param a the base. + * @param b the exponent. + * @return the value {@code a}{@code b}. + */ + public static double pow(double a, double b) { + return StrictMath.pow(a, b); // default impl. delegates to StrictMath + } + + /** + * Returns the closest {@code int} to the argument, with ties + * rounding up. + * + *

+ * Special cases: + *

  • If the argument is NaN, the result is 0. + *
  • If the argument is negative infinity or any value less than or + * equal to the value of {@code Integer.MIN_VALUE}, the result is + * equal to the value of {@code Integer.MIN_VALUE}. + *
  • If the argument is positive infinity or any value greater than or + * equal to the value of {@code Integer.MAX_VALUE}, the result is + * equal to the value of {@code Integer.MAX_VALUE}.
+ * + * @param a a floating-point value to be rounded to an integer. + * @return the value of the argument rounded to the nearest + * {@code int} value. + * @see java.lang.Integer#MAX_VALUE + * @see java.lang.Integer#MIN_VALUE + */ + public static int round(float a) { + if (a != 0x1.fffffep-2f) // greatest float value less than 0.5 + return (int)floor(a + 0.5f); + else + return 0; + } + + /** + * Returns the closest {@code long} to the argument, with ties + * rounding up. + * + *

Special cases: + *

  • If the argument is NaN, the result is 0. + *
  • If the argument is negative infinity or any value less than or + * equal to the value of {@code Long.MIN_VALUE}, the result is + * equal to the value of {@code Long.MIN_VALUE}. + *
  • If the argument is positive infinity or any value greater than or + * equal to the value of {@code Long.MAX_VALUE}, the result is + * equal to the value of {@code Long.MAX_VALUE}.
+ * + * @param a a floating-point value to be rounded to a + * {@code long}. + * @return the value of the argument rounded to the nearest + * {@code long} value. + * @see java.lang.Long#MAX_VALUE + * @see java.lang.Long#MIN_VALUE + */ + public static long round(double a) { + if (a != 0x1.fffffffffffffp-2) // greatest double value less than 0.5 + return (long)floor(a + 0.5d); + else + return 0; + } + +// private static Random randomNumberGenerator; +// +// private static synchronized Random initRNG() { +// Random rnd = randomNumberGenerator; +// return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd; +// } + + /** + * Returns a {@code double} value with a positive sign, greater + * than or equal to {@code 0.0} and less than {@code 1.0}. + * Returned values are chosen pseudorandomly with (approximately) + * uniform distribution from that range. + * + *

When this method is first called, it creates a single new + * pseudorandom-number generator, exactly as if by the expression + * + *

{@code new java.util.Random()}
+ * + * This new pseudorandom-number generator is used thereafter for + * all calls to this method and is used nowhere else. + * + *

This method is properly synchronized to allow correct use by + * more than one thread. However, if many threads need to generate + * pseudorandom numbers at a great rate, it may reduce contention + * for each thread to have its own pseudorandom-number generator. + * + * @return a pseudorandom {@code double} greater than or equal + * to {@code 0.0} and less than {@code 1.0}. + * @see Random#nextDouble() + */ + public static double random() { + throw new UnsupportedOperationException(); + } + + /** + * Returns the absolute value of an {@code int} value. + * If the argument is not negative, the argument is returned. + * If the argument is negative, the negation of the argument is returned. + * + *

Note that if the argument is equal to the value of + * {@link Integer#MIN_VALUE}, the most negative representable + * {@code int} value, the result is that same value, which is + * negative. + * + * @param a the argument whose absolute value is to be determined + * @return the absolute value of the argument. + */ + public static int abs(int a) { + return (a < 0) ? -a : a; + } + + /** + * Returns the absolute value of a {@code long} value. + * If the argument is not negative, the argument is returned. + * If the argument is negative, the negation of the argument is returned. + * + *

Note that if the argument is equal to the value of + * {@link Long#MIN_VALUE}, the most negative representable + * {@code long} value, the result is that same value, which + * is negative. + * + * @param a the argument whose absolute value is to be determined + * @return the absolute value of the argument. + */ + public static long abs(long a) { + return (a < 0) ? -a : a; + } + + /** + * Returns the absolute value of a {@code float} value. + * If the argument is not negative, the argument is returned. + * If the argument is negative, the negation of the argument is returned. + * Special cases: + *

  • If the argument is positive zero or negative zero, the + * result is positive zero. + *
  • If the argument is infinite, the result is positive infinity. + *
  • If the argument is NaN, the result is NaN.
+ * In other words, the result is the same as the value of the expression: + *

{@code Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))} + * + * @param a the argument whose absolute value is to be determined + * @return the absolute value of the argument. + */ + public static float abs(float a) { + return (a <= 0.0F) ? 0.0F - a : a; + } + + /** + * Returns the absolute value of a {@code double} value. + * If the argument is not negative, the argument is returned. + * If the argument is negative, the negation of the argument is returned. + * Special cases: + *

  • If the argument is positive zero or negative zero, the result + * is positive zero. + *
  • If the argument is infinite, the result is positive infinity. + *
  • If the argument is NaN, the result is NaN.
+ * In other words, the result is the same as the value of the expression: + *

{@code Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)} + * + * @param a the argument whose absolute value is to be determined + * @return the absolute value of the argument. + */ + public static double abs(double a) { + return (a <= 0.0D) ? 0.0D - a : a; + } + + /** + * Returns the greater of two {@code int} values. That is, the + * result is the argument closer to the value of + * {@link Integer#MAX_VALUE}. If the arguments have the same value, + * the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the larger of {@code a} and {@code b}. + */ + public static int max(int a, int b) { + return (a >= b) ? a : b; + } + + /** + * Returns the greater of two {@code long} values. That is, the + * result is the argument closer to the value of + * {@link Long#MAX_VALUE}. If the arguments have the same value, + * the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the larger of {@code a} and {@code b}. + */ + public static long max(long a, long b) { + return (a >= b) ? a : b; + } + + private static long negativeZeroFloatBits = Float.floatToIntBits(-0.0f); + private static long negativeZeroDoubleBits = Double.doubleToLongBits(-0.0d); + + /** + * Returns the greater of two {@code float} values. That is, + * the result is the argument closer to positive infinity. If the + * arguments have the same value, the result is that same + * value. If either value is NaN, then the result is NaN. Unlike + * the numerical comparison operators, this method considers + * negative zero to be strictly smaller than positive zero. If one + * argument is positive zero and the other negative zero, the + * result is positive zero. + * + * @param a an argument. + * @param b another argument. + * @return the larger of {@code a} and {@code b}. + */ + public static float max(float a, float b) { + if (a != a) return a; // a is NaN + if ((a == 0.0f) && (b == 0.0f) + && (Float.floatToIntBits(a) == negativeZeroFloatBits)) { + return b; + } + return (a >= b) ? a : b; + } + + /** + * Returns the greater of two {@code double} values. That + * is, the result is the argument closer to positive infinity. If + * the arguments have the same value, the result is that same + * value. If either value is NaN, then the result is NaN. Unlike + * the numerical comparison operators, this method considers + * negative zero to be strictly smaller than positive zero. If one + * argument is positive zero and the other negative zero, the + * result is positive zero. + * + * @param a an argument. + * @param b another argument. + * @return the larger of {@code a} and {@code b}. + */ + public static double max(double a, double b) { + if (a != a) return a; // a is NaN + if ((a == 0.0d) && (b == 0.0d) + && (Double.doubleToLongBits(a) == negativeZeroDoubleBits)) { + return b; + } + return (a >= b) ? a : b; + } + + /** + * Returns the smaller of two {@code int} values. That is, + * the result the argument closer to the value of + * {@link Integer#MIN_VALUE}. If the arguments have the same + * value, the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the smaller of {@code a} and {@code b}. + */ + public static int min(int a, int b) { + return (a <= b) ? a : b; + } + + /** + * Returns the smaller of two {@code long} values. That is, + * the result is the argument closer to the value of + * {@link Long#MIN_VALUE}. If the arguments have the same + * value, the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the smaller of {@code a} and {@code b}. + */ + public static long min(long a, long b) { + return (a <= b) ? a : b; + } + + /** + * Returns the smaller of two {@code float} values. That is, + * the result is the value closer to negative infinity. If the + * arguments have the same value, the result is that same + * value. If either value is NaN, then the result is NaN. Unlike + * the numerical comparison operators, this method considers + * negative zero to be strictly smaller than positive zero. If + * one argument is positive zero and the other is negative zero, + * the result is negative zero. + * + * @param a an argument. + * @param b another argument. + * @return the smaller of {@code a} and {@code b}. + */ + public static float min(float a, float b) { + if (a != a) return a; // a is NaN + if ((a == 0.0f) && (b == 0.0f) + && (Float.floatToIntBits(b) == negativeZeroFloatBits)) { + return b; + } + return (a <= b) ? a : b; + } + + /** + * Returns the smaller of two {@code double} values. That + * is, the result is the value closer to negative infinity. If the + * arguments have the same value, the result is that same + * value. If either value is NaN, then the result is NaN. Unlike + * the numerical comparison operators, this method considers + * negative zero to be strictly smaller than positive zero. If one + * argument is positive zero and the other is negative zero, the + * result is negative zero. + * + * @param a an argument. + * @param b another argument. + * @return the smaller of {@code a} and {@code b}. + */ + public static double min(double a, double b) { + if (a != a) return a; // a is NaN + if ((a == 0.0d) && (b == 0.0d) + && (Double.doubleToLongBits(b) == negativeZeroDoubleBits)) { + return b; + } + return (a <= b) ? a : b; + } + + /** + * Returns the size of an ulp of the argument. An ulp of a + * {@code double} value is the positive distance between this + * floating-point value and the {@code double} value next + * larger in magnitude. Note that for non-NaN x, + * ulp(-x) == ulp(x). + * + *

Special Cases: + *

    + *
  • If the argument is NaN, then the result is NaN. + *
  • If the argument is positive or negative infinity, then the + * result is positive infinity. + *
  • If the argument is positive or negative zero, then the result is + * {@code Double.MIN_VALUE}. + *
  • If the argument is ±{@code Double.MAX_VALUE}, then + * the result is equal to 2971. + *
+ * + * @param d the floating-point value whose ulp is to be returned + * @return the size of an ulp of the argument + * @author Joseph D. Darcy + * @since 1.5 + */ +// public static double ulp(double d) { +// return sun.misc.FpUtils.ulp(d); +// } + + /** + * Returns the size of an ulp of the argument. An ulp of a + * {@code float} value is the positive distance between this + * floating-point value and the {@code float} value next + * larger in magnitude. Note that for non-NaN x, + * ulp(-x) == ulp(x). + * + *

Special Cases: + *

    + *
  • If the argument is NaN, then the result is NaN. + *
  • If the argument is positive or negative infinity, then the + * result is positive infinity. + *
  • If the argument is positive or negative zero, then the result is + * {@code Float.MIN_VALUE}. + *
  • If the argument is ±{@code Float.MAX_VALUE}, then + * the result is equal to 2104. + *
+ * + * @param f the floating-point value whose ulp is to be returned + * @return the size of an ulp of the argument + * @author Joseph D. Darcy + * @since 1.5 + */ +// public static float ulp(float f) { +// return sun.misc.FpUtils.ulp(f); +// } + + /** + * Returns the signum function of the argument; zero if the argument + * is zero, 1.0 if the argument is greater than zero, -1.0 if the + * argument is less than zero. + * + *

Special Cases: + *

    + *
  • If the argument is NaN, then the result is NaN. + *
  • If the argument is positive zero or negative zero, then the + * result is the same as the argument. + *
+ * + * @param d the floating-point value whose signum is to be returned + * @return the signum function of the argument + * @author Joseph D. Darcy + * @since 1.5 + */ +// public static double signum(double d) { +// return sun.misc.FpUtils.signum(d); +// } + + /** + * Returns the signum function of the argument; zero if the argument + * is zero, 1.0f if the argument is greater than zero, -1.0f if the + * argument is less than zero. + * + *

Special Cases: + *

    + *
  • If the argument is NaN, then the result is NaN. + *
  • If the argument is positive zero or negative zero, then the + * result is the same as the argument. + *
+ * + * @param f the floating-point value whose signum is to be returned + * @return the signum function of the argument + * @author Joseph D. Darcy + * @since 1.5 + */ +// public static float signum(float f) { +// return sun.misc.FpUtils.signum(f); +// } + + /** + * Returns the hyperbolic sine of a {@code double} value. + * The hyperbolic sine of x is defined to be + * (ex - e-x)/2 + * where e is {@linkplain Math#E Euler's number}. + * + *

Special cases: + *

    + * + *
  • If the argument is NaN, then the result is NaN. + * + *
  • If the argument is infinite, then the result is an infinity + * with the same sign as the argument. + * + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument. + * + *
+ * + *

The computed result must be within 2.5 ulps of the exact result. + * + * @param x The number whose hyperbolic sine is to be returned. + * @return The hyperbolic sine of {@code x}. + * @since 1.5 + */ + public static double sinh(double x) { + return StrictMath.sinh(x); + } + + /** + * Returns the hyperbolic cosine of a {@code double} value. + * The hyperbolic cosine of x is defined to be + * (ex + e-x)/2 + * where e is {@linkplain Math#E Euler's number}. + * + *

Special cases: + *

    + * + *
  • If the argument is NaN, then the result is NaN. + * + *
  • If the argument is infinite, then the result is positive + * infinity. + * + *
  • If the argument is zero, then the result is {@code 1.0}. + * + *
+ * + *

The computed result must be within 2.5 ulps of the exact result. + * + * @param x The number whose hyperbolic cosine is to be returned. + * @return The hyperbolic cosine of {@code x}. + * @since 1.5 + */ + public static double cosh(double x) { + return StrictMath.cosh(x); + } + + /** + * Returns the hyperbolic tangent of a {@code double} value. + * The hyperbolic tangent of x is defined to be + * (ex - e-x)/(ex + e-x), + * in other words, {@linkplain Math#sinh + * sinh(x)}/{@linkplain Math#cosh cosh(x)}. Note + * that the absolute value of the exact tanh is always less than + * 1. + * + *

Special cases: + *

    + * + *
  • If the argument is NaN, then the result is NaN. + * + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument. + * + *
  • If the argument is positive infinity, then the result is + * {@code +1.0}. + * + *
  • If the argument is negative infinity, then the result is + * {@code -1.0}. + * + *
+ * + *

The computed result must be within 2.5 ulps of the exact result. + * The result of {@code tanh} for any finite input must have + * an absolute value less than or equal to 1. Note that once the + * exact result of tanh is within 1/2 of an ulp of the limit value + * of ±1, correctly signed ±{@code 1.0} should + * be returned. + * + * @param x The number whose hyperbolic tangent is to be returned. + * @return The hyperbolic tangent of {@code x}. + * @since 1.5 + */ + public static double tanh(double x) { + return StrictMath.tanh(x); + } + + /** + * Returns sqrt(x2 +y2) + * without intermediate overflow or underflow. + * + *

Special cases: + *

    + * + *
  • If either argument is infinite, then the result + * is positive infinity. + * + *
  • If either argument is NaN and neither argument is infinite, + * then the result is NaN. + * + *
+ * + *

The computed result must be within 1 ulp of the exact + * result. If one parameter is held constant, the results must be + * semi-monotonic in the other parameter. + * + * @param x a value + * @param y a value + * @return sqrt(x2 +y2) + * without intermediate overflow or underflow + * @since 1.5 + */ + public static double hypot(double x, double y) { + return StrictMath.hypot(x, y); + } + + /** + * Returns ex -1. Note that for values of + * x near 0, the exact sum of + * {@code expm1(x)} + 1 is much closer to the true + * result of ex than {@code exp(x)}. + * + *

Special cases: + *

    + *
  • If the argument is NaN, the result is NaN. + * + *
  • If the argument is positive infinity, then the result is + * positive infinity. + * + *
  • If the argument is negative infinity, then the result is + * -1.0. + * + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument. + * + *
+ * + *

The computed result must be within 1 ulp of the exact result. + * Results must be semi-monotonic. The result of + * {@code expm1} for any finite input must be greater than or + * equal to {@code -1.0}. Note that once the exact result of + * e{@code x} - 1 is within 1/2 + * ulp of the limit value -1, {@code -1.0} should be + * returned. + * + * @param x the exponent to raise e to in the computation of + * e{@code x} -1. + * @return the value e{@code x} - 1. + * @since 1.5 + */ + public static double expm1(double x) { + return StrictMath.expm1(x); + } + + /** + * Returns the natural logarithm of the sum of the argument and 1. + * Note that for small values {@code x}, the result of + * {@code log1p(x)} is much closer to the true result of ln(1 + * + {@code x}) than the floating-point evaluation of + * {@code log(1.0+x)}. + * + *

Special cases: + * + *

    + * + *
  • If the argument is NaN or less than -1, then the result is + * NaN. + * + *
  • If the argument is positive infinity, then the result is + * positive infinity. + * + *
  • If the argument is negative one, then the result is + * negative infinity. + * + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument. + * + *
+ * + *

The computed result must be within 1 ulp of the exact result. + * Results must be semi-monotonic. + * + * @param x a value + * @return the value ln({@code x} + 1), the natural + * log of {@code x} + 1 + * @since 1.5 + */ + public static double log1p(double x) { + return StrictMath.log1p(x); + } + + /** + * Returns the first floating-point argument with the sign of the + * second floating-point argument. Note that unlike the {@link + * StrictMath#copySign(double, double) StrictMath.copySign} + * method, this method does not require NaN {@code sign} + * arguments to be treated as positive values; implementations are + * permitted to treat some NaN arguments as positive and other NaN + * arguments as negative to allow greater performance. + * + * @param magnitude the parameter providing the magnitude of the result + * @param sign the parameter providing the sign of the result + * @return a value with the magnitude of {@code magnitude} + * and the sign of {@code sign}. + * @since 1.6 + */ +// public static double copySign(double magnitude, double sign) { +// return sun.misc.FpUtils.rawCopySign(magnitude, sign); +// } + + /** + * Returns the first floating-point argument with the sign of the + * second floating-point argument. Note that unlike the {@link + * StrictMath#copySign(float, float) StrictMath.copySign} + * method, this method does not require NaN {@code sign} + * arguments to be treated as positive values; implementations are + * permitted to treat some NaN arguments as positive and other NaN + * arguments as negative to allow greater performance. + * + * @param magnitude the parameter providing the magnitude of the result + * @param sign the parameter providing the sign of the result + * @return a value with the magnitude of {@code magnitude} + * and the sign of {@code sign}. + * @since 1.6 + */ +// public static float copySign(float magnitude, float sign) { +// return sun.misc.FpUtils.rawCopySign(magnitude, sign); +// } + + /** + * Returns the unbiased exponent used in the representation of a + * {@code float}. Special cases: + * + *

    + *
  • If the argument is NaN or infinite, then the result is + * {@link Float#MAX_EXPONENT} + 1. + *
  • If the argument is zero or subnormal, then the result is + * {@link Float#MIN_EXPONENT} -1. + *
+ * @param f a {@code float} value + * @return the unbiased exponent of the argument + * @since 1.6 + */ +// public static int getExponent(float f) { +// return sun.misc.FpUtils.getExponent(f); +// } + + /** + * Returns the unbiased exponent used in the representation of a + * {@code double}. Special cases: + * + *
    + *
  • If the argument is NaN or infinite, then the result is + * {@link Double#MAX_EXPONENT} + 1. + *
  • If the argument is zero or subnormal, then the result is + * {@link Double#MIN_EXPONENT} -1. + *
+ * @param d a {@code double} value + * @return the unbiased exponent of the argument + * @since 1.6 + */ +// public static int getExponent(double d) { +// return sun.misc.FpUtils.getExponent(d); +// } + + /** + * Returns the floating-point number adjacent to the first + * argument in the direction of the second argument. If both + * arguments compare as equal the second argument is returned. + * + *

+ * Special cases: + *

    + *
  • If either argument is a NaN, then NaN is returned. + * + *
  • If both arguments are signed zeros, {@code direction} + * is returned unchanged (as implied by the requirement of + * returning the second argument if the arguments compare as + * equal). + * + *
  • If {@code start} is + * ±{@link Double#MIN_VALUE} and {@code direction} + * has a value such that the result should have a smaller + * magnitude, then a zero with the same sign as {@code start} + * is returned. + * + *
  • If {@code start} is infinite and + * {@code direction} has a value such that the result should + * have a smaller magnitude, {@link Double#MAX_VALUE} with the + * same sign as {@code start} is returned. + * + *
  • If {@code start} is equal to ± + * {@link Double#MAX_VALUE} and {@code direction} has a + * value such that the result should have a larger magnitude, an + * infinity with same sign as {@code start} is returned. + *
+ * + * @param start starting floating-point value + * @param direction value indicating which of + * {@code start}'s neighbors or {@code start} should + * be returned + * @return The floating-point number adjacent to {@code start} in the + * direction of {@code direction}. + * @since 1.6 + */ +// public static double nextAfter(double start, double direction) { +// return sun.misc.FpUtils.nextAfter(start, direction); +// } + + /** + * Returns the floating-point number adjacent to the first + * argument in the direction of the second argument. If both + * arguments compare as equal a value equivalent to the second argument + * is returned. + * + *

+ * Special cases: + *

    + *
  • If either argument is a NaN, then NaN is returned. + * + *
  • If both arguments are signed zeros, a value equivalent + * to {@code direction} is returned. + * + *
  • If {@code start} is + * ±{@link Float#MIN_VALUE} and {@code direction} + * has a value such that the result should have a smaller + * magnitude, then a zero with the same sign as {@code start} + * is returned. + * + *
  • If {@code start} is infinite and + * {@code direction} has a value such that the result should + * have a smaller magnitude, {@link Float#MAX_VALUE} with the + * same sign as {@code start} is returned. + * + *
  • If {@code start} is equal to ± + * {@link Float#MAX_VALUE} and {@code direction} has a + * value such that the result should have a larger magnitude, an + * infinity with same sign as {@code start} is returned. + *
+ * + * @param start starting floating-point value + * @param direction value indicating which of + * {@code start}'s neighbors or {@code start} should + * be returned + * @return The floating-point number adjacent to {@code start} in the + * direction of {@code direction}. + * @since 1.6 + */ +// public static float nextAfter(float start, double direction) { +// return sun.misc.FpUtils.nextAfter(start, direction); +// } + + /** + * Returns the floating-point value adjacent to {@code d} in + * the direction of positive infinity. This method is + * semantically equivalent to {@code nextAfter(d, + * Double.POSITIVE_INFINITY)}; however, a {@code nextUp} + * implementation may run faster than its equivalent + * {@code nextAfter} call. + * + *

Special Cases: + *

    + *
  • If the argument is NaN, the result is NaN. + * + *
  • If the argument is positive infinity, the result is + * positive infinity. + * + *
  • If the argument is zero, the result is + * {@link Double#MIN_VALUE} + * + *
+ * + * @param d starting floating-point value + * @return The adjacent floating-point value closer to positive + * infinity. + * @since 1.6 + */ +// public static double nextUp(double d) { +// return sun.misc.FpUtils.nextUp(d); +// } + + /** + * Returns the floating-point value adjacent to {@code f} in + * the direction of positive infinity. This method is + * semantically equivalent to {@code nextAfter(f, + * Float.POSITIVE_INFINITY)}; however, a {@code nextUp} + * implementation may run faster than its equivalent + * {@code nextAfter} call. + * + *

Special Cases: + *

    + *
  • If the argument is NaN, the result is NaN. + * + *
  • If the argument is positive infinity, the result is + * positive infinity. + * + *
  • If the argument is zero, the result is + * {@link Float#MIN_VALUE} + * + *
+ * + * @param f starting floating-point value + * @return The adjacent floating-point value closer to positive + * infinity. + * @since 1.6 + */ +// public static float nextUp(float f) { +// return sun.misc.FpUtils.nextUp(f); +// } + + + /** + * Return {@code d} × + * 2{@code scaleFactor} rounded as if performed + * by a single correctly rounded floating-point multiply to a + * member of the double value set. See the Java + * Language Specification for a discussion of floating-point + * value sets. If the exponent of the result is between {@link + * Double#MIN_EXPONENT} and {@link Double#MAX_EXPONENT}, the + * answer is calculated exactly. If the exponent of the result + * would be larger than {@code Double.MAX_EXPONENT}, an + * infinity is returned. Note that if the result is subnormal, + * precision may be lost; that is, when {@code scalb(x, n)} + * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal + * x. When the result is non-NaN, the result has the same + * sign as {@code d}. + * + *

Special cases: + *

    + *
  • If the first argument is NaN, NaN is returned. + *
  • If the first argument is infinite, then an infinity of the + * same sign is returned. + *
  • If the first argument is zero, then a zero of the same + * sign is returned. + *
+ * + * @param d number to be scaled by a power of two. + * @param scaleFactor power of 2 used to scale {@code d} + * @return {@code d} × 2{@code scaleFactor} + * @since 1.6 + */ +// public static double scalb(double d, int scaleFactor) { +// return sun.misc.FpUtils.scalb(d, scaleFactor); +// } + + /** + * Return {@code f} × + * 2{@code scaleFactor} rounded as if performed + * by a single correctly rounded floating-point multiply to a + * member of the float value set. See the Java + * Language Specification for a discussion of floating-point + * value sets. If the exponent of the result is between {@link + * Float#MIN_EXPONENT} and {@link Float#MAX_EXPONENT}, the + * answer is calculated exactly. If the exponent of the result + * would be larger than {@code Float.MAX_EXPONENT}, an + * infinity is returned. Note that if the result is subnormal, + * precision may be lost; that is, when {@code scalb(x, n)} + * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal + * x. When the result is non-NaN, the result has the same + * sign as {@code f}. + * + *

Special cases: + *

    + *
  • If the first argument is NaN, NaN is returned. + *
  • If the first argument is infinite, then an infinity of the + * same sign is returned. + *
  • If the first argument is zero, then a zero of the same + * sign is returned. + *
+ * + * @param f number to be scaled by a power of two. + * @param scaleFactor power of 2 used to scale {@code f} + * @return {@code f} × 2{@code scaleFactor} + * @since 1.6 + */ +// public static float scalb(float f, int scaleFactor) { +// return sun.misc.FpUtils.scalb(f, scaleFactor); +// } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/NullPointerException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/NullPointerException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown when an application attempts to use {@code null} in a + * case where an object is required. These include: + *
    + *
  • Calling the instance method of a {@code null} object. + *
  • Accessing or modifying the field of a {@code null} object. + *
  • Taking the length of {@code null} as if it were an array. + *
  • Accessing or modifying the slots of {@code null} as if it + * were an array. + *
  • Throwing {@code null} as if it were a {@code Throwable} + * value. + *
+ *

+ * Applications should throw instances of this class to indicate + * other illegal uses of the {@code null} object. + * + * {@code NullPointerException} objects may be constructed by the + * virtual machine as if {@linkplain Throwable#Throwable(String, + * Throwable, boolean, boolean) suppression were disabled and/or the + * stack trace was not writable}. + * + * @author unascribed + * @since JDK1.0 + */ +public +class NullPointerException extends RuntimeException { + private static final long serialVersionUID = 5162710183389028792L; + + /** + * Constructs a {@code NullPointerException} with no detail message. + */ + public NullPointerException() { + super(); + } + + /** + * Constructs a {@code NullPointerException} with the specified + * detail message. + * + * @param s the detail message. + */ + public NullPointerException(String s) { + super(s); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Number.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Number.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,112 @@ +/* + * Copyright (c) 1994, 2001, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * The abstract class Number is the superclass of classes + * BigDecimal, BigInteger, + * Byte, Double, Float, + * Integer, Long, and Short. + *

+ * Subclasses of Number must provide methods to convert + * the represented numeric value to byte, double, + * float, int, long, and + * short. + * + * @author Lee Boynton + * @author Arthur van Hoff + * @see java.lang.Byte + * @see java.lang.Double + * @see java.lang.Float + * @see java.lang.Integer + * @see java.lang.Long + * @see java.lang.Short + * @since JDK1.0 + */ +public abstract class Number implements java.io.Serializable { + /** + * Returns the value of the specified number as an int. + * This may involve rounding or truncation. + * + * @return the numeric value represented by this object after conversion + * to type int. + */ + public abstract int intValue(); + + /** + * Returns the value of the specified number as a long. + * This may involve rounding or truncation. + * + * @return the numeric value represented by this object after conversion + * to type long. + */ + public abstract long longValue(); + + /** + * Returns the value of the specified number as a float. + * This may involve rounding. + * + * @return the numeric value represented by this object after conversion + * to type float. + */ + public abstract float floatValue(); + + /** + * Returns the value of the specified number as a double. + * This may involve rounding. + * + * @return the numeric value represented by this object after conversion + * to type double. + */ + public abstract double doubleValue(); + + /** + * Returns the value of the specified number as a byte. + * This may involve rounding or truncation. + * + * @return the numeric value represented by this object after conversion + * to type byte. + * @since JDK1.1 + */ + public byte byteValue() { + return (byte)intValue(); + } + + /** + * Returns the value of the specified number as a short. + * This may involve rounding or truncation. + * + * @return the numeric value represented by this object after conversion + * to type short. + * @since JDK1.1 + */ + public short shortValue() { + return (short)intValue(); + } + + /** use serialVersionUID from JDK 1.0.2 for interoperability */ + private static final long serialVersionUID = -8742448824652078965L; +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/NumberFormatException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/NumberFormatException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1994, 2001, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown to indicate that the application has attempted to convert + * a string to one of the numeric types, but that the string does not + * have the appropriate format. + * + * @author unascribed + * @see java.lang.Integer#toString() + * @since JDK1.0 + */ +public +class NumberFormatException extends IllegalArgumentException { + static final long serialVersionUID = -2848938806368998894L; + + /** + * Constructs a NumberFormatException with no detail message. + */ + public NumberFormatException () { + super(); + } + + /** + * Constructs a NumberFormatException with the + * specified detail message. + * + * @param s the detail message. + */ + public NumberFormatException (String s) { + super (s); + } + + /** + * Factory method for making a NumberFormatException + * given the specified input which caused the error. + * + * @param s the input causing the error + */ + static NumberFormatException forInputString(String s) { + return new NumberFormatException("For input string: \"" + s + "\""); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Object.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Object.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,554 @@ +/* + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Class {@code Object} is the root of the class hierarchy. + * Every class has {@code Object} as a superclass. All objects, + * including arrays, implement the methods of this class. + * + * @author unascribed + * @see java.lang.Class + * @since JDK1.0 + */ +public class Object { + + private static native void registerNatives(); + static { + registerNatives(); + } + + /** + * Returns the runtime class of this {@code Object}. The returned + * {@code Class} object is the object that is locked by {@code + * static synchronized} methods of the represented class. + * + *

The actual result type is {@code Class} + * where {@code |X|} is the erasure of the static type of the + * expression on which {@code getClass} is called. For + * example, no cast is required in this code fragment:

+ * + *

+ * {@code Number n = 0; }
+ * {@code Class c = n.getClass(); } + *

+ * + * @return The {@code Class} object that represents the runtime + * class of this object. + * @see Class Literals, section 15.8.2 of + * The Java™ Language Specification. + */ + public final native Class getClass(); + + /** + * Returns a hash code value for the object. This method is + * supported for the benefit of hash tables such as those provided by + * {@link java.util.HashMap}. + *

+ * The general contract of {@code hashCode} is: + *

    + *
  • Whenever it is invoked on the same object more than once during + * an execution of a Java application, the {@code hashCode} method + * must consistently return the same integer, provided no information + * used in {@code equals} comparisons on the object is modified. + * This integer need not remain consistent from one execution of an + * application to another execution of the same application. + *
  • If two objects are equal according to the {@code equals(Object)} + * method, then calling the {@code hashCode} method on each of + * the two objects must produce the same integer result. + *
  • It is not required that if two objects are unequal + * according to the {@link java.lang.Object#equals(java.lang.Object)} + * method, then calling the {@code hashCode} method on each of the + * two objects must produce distinct integer results. However, the + * programmer should be aware that producing distinct integer results + * for unequal objects may improve the performance of hash tables. + *
+ *

+ * As much as is reasonably practical, the hashCode method defined by + * class {@code Object} does return distinct integers for distinct + * objects. (This is typically implemented by converting the internal + * address of the object into an integer, but this implementation + * technique is not required by the + * JavaTM programming language.) + * + * @return a hash code value for this object. + * @see java.lang.Object#equals(java.lang.Object) + * @see java.lang.System#identityHashCode + */ + public native int hashCode(); + + /** + * Indicates whether some other object is "equal to" this one. + *

+ * The {@code equals} method implements an equivalence relation + * on non-null object references: + *

    + *
  • It is reflexive: for any non-null reference value + * {@code x}, {@code x.equals(x)} should return + * {@code true}. + *
  • It is symmetric: for any non-null reference values + * {@code x} and {@code y}, {@code x.equals(y)} + * should return {@code true} if and only if + * {@code y.equals(x)} returns {@code true}. + *
  • It is transitive: for any non-null reference values + * {@code x}, {@code y}, and {@code z}, if + * {@code x.equals(y)} returns {@code true} and + * {@code y.equals(z)} returns {@code true}, then + * {@code x.equals(z)} should return {@code true}. + *
  • It is consistent: for any non-null reference values + * {@code x} and {@code y}, multiple invocations of + * {@code x.equals(y)} consistently return {@code true} + * or consistently return {@code false}, provided no + * information used in {@code equals} comparisons on the + * objects is modified. + *
  • For any non-null reference value {@code x}, + * {@code x.equals(null)} should return {@code false}. + *
+ *

+ * The {@code equals} method for class {@code Object} implements + * the most discriminating possible equivalence relation on objects; + * that is, for any non-null reference values {@code x} and + * {@code y}, this method returns {@code true} if and only + * if {@code x} and {@code y} refer to the same object + * ({@code x == y} has the value {@code true}). + *

+ * Note that it is generally necessary to override the {@code hashCode} + * method whenever this method is overridden, so as to maintain the + * general contract for the {@code hashCode} method, which states + * that equal objects must have equal hash codes. + * + * @param obj the reference object with which to compare. + * @return {@code true} if this object is the same as the obj + * argument; {@code false} otherwise. + * @see #hashCode() + * @see java.util.HashMap + */ + public boolean equals(Object obj) { + return (this == obj); + } + + /** + * Creates and returns a copy of this object. The precise meaning + * of "copy" may depend on the class of the object. The general + * intent is that, for any object {@code x}, the expression: + *

+ *
+     * x.clone() != x
+ * will be true, and that the expression: + *
+ *
+     * x.clone().getClass() == x.getClass()
+ * will be {@code true}, but these are not absolute requirements. + * While it is typically the case that: + *
+ *
+     * x.clone().equals(x)
+ * will be {@code true}, this is not an absolute requirement. + *

+ * By convention, the returned object should be obtained by calling + * {@code super.clone}. If a class and all of its superclasses (except + * {@code Object}) obey this convention, it will be the case that + * {@code x.clone().getClass() == x.getClass()}. + *

+ * By convention, the object returned by this method should be independent + * of this object (which is being cloned). To achieve this independence, + * it may be necessary to modify one or more fields of the object returned + * by {@code super.clone} before returning it. Typically, this means + * copying any mutable objects that comprise the internal "deep structure" + * of the object being cloned and replacing the references to these + * objects with references to the copies. If a class contains only + * primitive fields or references to immutable objects, then it is usually + * the case that no fields in the object returned by {@code super.clone} + * need to be modified. + *

+ * The method {@code clone} for class {@code Object} performs a + * specific cloning operation. First, if the class of this object does + * not implement the interface {@code Cloneable}, then a + * {@code CloneNotSupportedException} is thrown. Note that all arrays + * are considered to implement the interface {@code Cloneable} and that + * the return type of the {@code clone} method of an array type {@code T[]} + * is {@code T[]} where T is any reference or primitive type. + * Otherwise, this method creates a new instance of the class of this + * object and initializes all its fields with exactly the contents of + * the corresponding fields of this object, as if by assignment; the + * contents of the fields are not themselves cloned. Thus, this method + * performs a "shallow copy" of this object, not a "deep copy" operation. + *

+ * The class {@code Object} does not itself implement the interface + * {@code Cloneable}, so calling the {@code clone} method on an object + * whose class is {@code Object} will result in throwing an + * exception at run time. + * + * @return a clone of this instance. + * @exception CloneNotSupportedException if the object's class does not + * support the {@code Cloneable} interface. Subclasses + * that override the {@code clone} method can also + * throw this exception to indicate that an instance cannot + * be cloned. + * @see java.lang.Cloneable + */ + protected native Object clone() throws CloneNotSupportedException; + + /** + * Returns a string representation of the object. In general, the + * {@code toString} method returns a string that + * "textually represents" this object. The result should + * be a concise but informative representation that is easy for a + * person to read. + * It is recommended that all subclasses override this method. + *

+ * The {@code toString} method for class {@code Object} + * returns a string consisting of the name of the class of which the + * object is an instance, the at-sign character `{@code @}', and + * the unsigned hexadecimal representation of the hash code of the + * object. In other words, this method returns a string equal to the + * value of: + *

+ *
+     * getClass().getName() + '@' + Integer.toHexString(hashCode())
+     * 
+ * + * @return a string representation of the object. + */ + public String toString() { + return getClass().getName() + "@" + Integer.toHexString(hashCode()); + } + + /** + * Wakes up a single thread that is waiting on this object's + * monitor. If any threads are waiting on this object, one of them + * is chosen to be awakened. The choice is arbitrary and occurs at + * the discretion of the implementation. A thread waits on an object's + * monitor by calling one of the {@code wait} methods. + *

+ * The awakened thread will not be able to proceed until the current + * thread relinquishes the lock on this object. The awakened thread will + * compete in the usual manner with any other threads that might be + * actively competing to synchronize on this object; for example, the + * awakened thread enjoys no reliable privilege or disadvantage in being + * the next thread to lock this object. + *

+ * This method should only be called by a thread that is the owner + * of this object's monitor. A thread becomes the owner of the + * object's monitor in one of three ways: + *

    + *
  • By executing a synchronized instance method of that object. + *
  • By executing the body of a {@code synchronized} statement + * that synchronizes on the object. + *
  • For objects of type {@code Class,} by executing a + * synchronized static method of that class. + *
+ *

+ * Only one thread at a time can own an object's monitor. + * + * @exception IllegalMonitorStateException if the current thread is not + * the owner of this object's monitor. + * @see java.lang.Object#notifyAll() + * @see java.lang.Object#wait() + */ + public final native void notify(); + + /** + * Wakes up all threads that are waiting on this object's monitor. A + * thread waits on an object's monitor by calling one of the + * {@code wait} methods. + *

+ * The awakened threads will not be able to proceed until the current + * thread relinquishes the lock on this object. The awakened threads + * will compete in the usual manner with any other threads that might + * be actively competing to synchronize on this object; for example, + * the awakened threads enjoy no reliable privilege or disadvantage in + * being the next thread to lock this object. + *

+ * This method should only be called by a thread that is the owner + * of this object's monitor. See the {@code notify} method for a + * description of the ways in which a thread can become the owner of + * a monitor. + * + * @exception IllegalMonitorStateException if the current thread is not + * the owner of this object's monitor. + * @see java.lang.Object#notify() + * @see java.lang.Object#wait() + */ + public final native void notifyAll(); + + /** + * Causes the current thread to wait until either another thread invokes the + * {@link java.lang.Object#notify()} method or the + * {@link java.lang.Object#notifyAll()} method for this object, or a + * specified amount of time has elapsed. + *

+ * The current thread must own this object's monitor. + *

+ * This method causes the current thread (call it T) to + * place itself in the wait set for this object and then to relinquish + * any and all synchronization claims on this object. Thread T + * becomes disabled for thread scheduling purposes and lies dormant + * until one of four things happens: + *

    + *
  • Some other thread invokes the {@code notify} method for this + * object and thread T happens to be arbitrarily chosen as + * the thread to be awakened. + *
  • Some other thread invokes the {@code notifyAll} method for this + * object. + *
  • Some other thread {@linkplain Thread#interrupt() interrupts} + * thread T. + *
  • The specified amount of real time has elapsed, more or less. If + * {@code timeout} is zero, however, then real time is not taken into + * consideration and the thread simply waits until notified. + *
+ * The thread T is then removed from the wait set for this + * object and re-enabled for thread scheduling. It then competes in the + * usual manner with other threads for the right to synchronize on the + * object; once it has gained control of the object, all its + * synchronization claims on the object are restored to the status quo + * ante - that is, to the situation as of the time that the {@code wait} + * method was invoked. Thread T then returns from the + * invocation of the {@code wait} method. Thus, on return from the + * {@code wait} method, the synchronization state of the object and of + * thread {@code T} is exactly as it was when the {@code wait} method + * was invoked. + *

+ * A thread can also wake up without being notified, interrupted, or + * timing out, a so-called spurious wakeup. While this will rarely + * occur in practice, applications must guard against it by testing for + * the condition that should have caused the thread to be awakened, and + * continuing to wait if the condition is not satisfied. In other words, + * waits should always occur in loops, like this one: + *

+     *     synchronized (obj) {
+     *         while (<condition does not hold>)
+     *             obj.wait(timeout);
+     *         ... // Perform action appropriate to condition
+     *     }
+     * 
+ * (For more information on this topic, see Section 3.2.3 in Doug Lea's + * "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, + * 2000), or Item 50 in Joshua Bloch's "Effective Java Programming + * Language Guide" (Addison-Wesley, 2001). + * + *

If the current thread is {@linkplain java.lang.Thread#interrupt() + * interrupted} by any thread before or while it is waiting, then an + * {@code InterruptedException} is thrown. This exception is not + * thrown until the lock status of this object has been restored as + * described above. + * + *

+ * Note that the {@code wait} method, as it places the current thread + * into the wait set for this object, unlocks only this object; any + * other objects on which the current thread may be synchronized remain + * locked while the thread waits. + *

+ * This method should only be called by a thread that is the owner + * of this object's monitor. See the {@code notify} method for a + * description of the ways in which a thread can become the owner of + * a monitor. + * + * @param timeout the maximum time to wait in milliseconds. + * @exception IllegalArgumentException if the value of timeout is + * negative. + * @exception IllegalMonitorStateException if the current thread is not + * the owner of the object's monitor. + * @exception InterruptedException if any thread interrupted the + * current thread before or while the current thread + * was waiting for a notification. The interrupted + * status of the current thread is cleared when + * this exception is thrown. + * @see java.lang.Object#notify() + * @see java.lang.Object#notifyAll() + */ + public final native void wait(long timeout) throws InterruptedException; + + /** + * Causes the current thread to wait until another thread invokes the + * {@link java.lang.Object#notify()} method or the + * {@link java.lang.Object#notifyAll()} method for this object, or + * some other thread interrupts the current thread, or a certain + * amount of real time has elapsed. + *

+ * This method is similar to the {@code wait} method of one + * argument, but it allows finer control over the amount of time to + * wait for a notification before giving up. The amount of real time, + * measured in nanoseconds, is given by: + *

+ *
+     * 1000000*timeout+nanos
+ *

+ * In all other respects, this method does the same thing as the + * method {@link #wait(long)} of one argument. In particular, + * {@code wait(0, 0)} means the same thing as {@code wait(0)}. + *

+ * The current thread must own this object's monitor. The thread + * releases ownership of this monitor and waits until either of the + * following two conditions has occurred: + *

    + *
  • Another thread notifies threads waiting on this object's monitor + * to wake up either through a call to the {@code notify} method + * or the {@code notifyAll} method. + *
  • The timeout period, specified by {@code timeout} + * milliseconds plus {@code nanos} nanoseconds arguments, has + * elapsed. + *
+ *

+ * The thread then waits until it can re-obtain ownership of the + * monitor and resumes execution. + *

+ * As in the one argument version, interrupts and spurious wakeups are + * possible, and this method should always be used in a loop: + *

+     *     synchronized (obj) {
+     *         while (<condition does not hold>)
+     *             obj.wait(timeout, nanos);
+     *         ... // Perform action appropriate to condition
+     *     }
+     * 
+ * This method should only be called by a thread that is the owner + * of this object's monitor. See the {@code notify} method for a + * description of the ways in which a thread can become the owner of + * a monitor. + * + * @param timeout the maximum time to wait in milliseconds. + * @param nanos additional time, in nanoseconds range + * 0-999999. + * @exception IllegalArgumentException if the value of timeout is + * negative or the value of nanos is + * not in the range 0-999999. + * @exception IllegalMonitorStateException if the current thread is not + * the owner of this object's monitor. + * @exception InterruptedException if any thread interrupted the + * current thread before or while the current thread + * was waiting for a notification. The interrupted + * status of the current thread is cleared when + * this exception is thrown. + */ + public final void wait(long timeout, int nanos) throws InterruptedException { + if (timeout < 0) { + throw new IllegalArgumentException("timeout value is negative"); + } + + if (nanos < 0 || nanos > 999999) { + throw new IllegalArgumentException( + "nanosecond timeout value out of range"); + } + + if (nanos >= 500000 || (nanos != 0 && timeout == 0)) { + timeout++; + } + + wait(timeout); + } + + /** + * Causes the current thread to wait until another thread invokes the + * {@link java.lang.Object#notify()} method or the + * {@link java.lang.Object#notifyAll()} method for this object. + * In other words, this method behaves exactly as if it simply + * performs the call {@code wait(0)}. + *

+ * The current thread must own this object's monitor. The thread + * releases ownership of this monitor and waits until another thread + * notifies threads waiting on this object's monitor to wake up + * either through a call to the {@code notify} method or the + * {@code notifyAll} method. The thread then waits until it can + * re-obtain ownership of the monitor and resumes execution. + *

+ * As in the one argument version, interrupts and spurious wakeups are + * possible, and this method should always be used in a loop: + *

+     *     synchronized (obj) {
+     *         while (<condition does not hold>)
+     *             obj.wait();
+     *         ... // Perform action appropriate to condition
+     *     }
+     * 
+ * This method should only be called by a thread that is the owner + * of this object's monitor. See the {@code notify} method for a + * description of the ways in which a thread can become the owner of + * a monitor. + * + * @exception IllegalMonitorStateException if the current thread is not + * the owner of the object's monitor. + * @exception InterruptedException if any thread interrupted the + * current thread before or while the current thread + * was waiting for a notification. The interrupted + * status of the current thread is cleared when + * this exception is thrown. + * @see java.lang.Object#notify() + * @see java.lang.Object#notifyAll() + */ + public final void wait() throws InterruptedException { + wait(0); + } + + /** + * Called by the garbage collector on an object when garbage collection + * determines that there are no more references to the object. + * A subclass overrides the {@code finalize} method to dispose of + * system resources or to perform other cleanup. + *

+ * The general contract of {@code finalize} is that it is invoked + * if and when the JavaTM virtual + * machine has determined that there is no longer any + * means by which this object can be accessed by any thread that has + * not yet died, except as a result of an action taken by the + * finalization of some other object or class which is ready to be + * finalized. The {@code finalize} method may take any action, including + * making this object available again to other threads; the usual purpose + * of {@code finalize}, however, is to perform cleanup actions before + * the object is irrevocably discarded. For example, the finalize method + * for an object that represents an input/output connection might perform + * explicit I/O transactions to break the connection before the object is + * permanently discarded. + *

+ * The {@code finalize} method of class {@code Object} performs no + * special action; it simply returns normally. Subclasses of + * {@code Object} may override this definition. + *

+ * The Java programming language does not guarantee which thread will + * invoke the {@code finalize} method for any given object. It is + * guaranteed, however, that the thread that invokes finalize will not + * be holding any user-visible synchronization locks when finalize is + * invoked. If an uncaught exception is thrown by the finalize method, + * the exception is ignored and finalization of that object terminates. + *

+ * After the {@code finalize} method has been invoked for an object, no + * further action is taken until the Java virtual machine has again + * determined that there is no longer any means by which this object can + * be accessed by any thread that has not yet died, including possible + * actions by other objects or classes which are ready to be finalized, + * at which point the object may be discarded. + *

+ * The {@code finalize} method is never invoked more than once by a Java + * virtual machine for any given object. + *

+ * Any exception thrown by the {@code finalize} method causes + * the finalization of this object to be halted, but is otherwise + * ignored. + * + * @throws Throwable the {@code Exception} raised by this method + */ + protected void finalize() throws Throwable { } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/OutOfMemoryError.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/OutOfMemoryError.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown when the Java Virtual Machine cannot allocate an object + * because it is out of memory, and no more memory could be made + * available by the garbage collector. + * + * {@code OutOfMemoryError} objects may be constructed by the virtual + * machine as if {@linkplain Throwable#Throwable(String, Throwable, + * boolean, boolean) suppression were disabled and/or the stack trace was not + * writable}. + * + * @author unascribed + * @since JDK1.0 + */ +public class OutOfMemoryError extends VirtualMachineError { + private static final long serialVersionUID = 8228564086184010517L; + + /** + * Constructs an {@code OutOfMemoryError} with no detail message. + */ + public OutOfMemoryError() { + super(); + } + + /** + * Constructs an {@code OutOfMemoryError} with the specified + * detail message. + * + * @param s the detail message. + */ + public OutOfMemoryError(String s) { + super(s); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/ReflectiveOperationException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/ReflectiveOperationException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Common superclass of exceptions thrown by reflective operations in + * core reflection. + * + * @see LinkageError + * @since 1.7 + */ +public class ReflectiveOperationException extends Exception { + static final long serialVersionUID = 123456789L; + + /** + * Constructs a new exception with {@code null} as its detail + * message. The cause is not initialized, and may subsequently be + * initialized by a call to {@link #initCause}. + */ + public ReflectiveOperationException() { + super(); + } + + /** + * Constructs a new exception with the specified detail message. + * The cause is not initialized, and may subsequently be + * initialized by a call to {@link #initCause}. + * + * @param message the detail message. The detail message is saved for + * later retrieval by the {@link #getMessage()} method. + */ + public ReflectiveOperationException(String message) { + super(message); + } + + /** + * Constructs a new exception with the specified detail message + * and cause. + * + *

Note that the detail message associated with + * {@code cause} is not automatically incorporated in + * this exception's detail message. + * + * @param message the detail message (which is saved for later retrieval + * by the {@link #getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A {@code null} value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + */ + public ReflectiveOperationException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new exception with the specified cause and a detail + * message of {@code (cause==null ? null : cause.toString())} (which + * typically contains the class and detail message of {@code cause}). + * + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A {@code null} value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + */ + public ReflectiveOperationException(Throwable cause) { + super(cause); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/RuntimeException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/RuntimeException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,119 @@ +/* + * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * {@code RuntimeException} is the superclass of those + * exceptions that can be thrown during the normal operation of the + * Java Virtual Machine. + * + *

{@code RuntimeException} and its subclasses are unchecked + * exceptions. Unchecked exceptions do not need to be + * declared in a method or constructor's {@code throws} clause if they + * can be thrown by the execution of the method or constructor and + * propagate outside the method or constructor boundary. + * + * @author Frank Yellin + * @jls 11.2 Compile-Time Checking of Exceptions + * @since JDK1.0 + */ +public class RuntimeException extends Exception { + static final long serialVersionUID = -7034897190745766939L; + + /** Constructs a new runtime exception with {@code null} as its + * detail message. The cause is not initialized, and may subsequently be + * initialized by a call to {@link #initCause}. + */ + public RuntimeException() { + super(); + } + + /** Constructs a new runtime exception with the specified detail message. + * The cause is not initialized, and may subsequently be initialized by a + * call to {@link #initCause}. + * + * @param message the detail message. The detail message is saved for + * later retrieval by the {@link #getMessage()} method. + */ + public RuntimeException(String message) { + super(message); + } + + /** + * Constructs a new runtime exception with the specified detail message and + * cause.

Note that the detail message associated with + * {@code cause} is not automatically incorporated in + * this runtime exception's detail message. + * + * @param message the detail message (which is saved for later retrieval + * by the {@link #getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.4 + */ + public RuntimeException(String message, Throwable cause) { + super(message, cause); + } + + /** Constructs a new runtime exception with the specified cause and a + * detail message of (cause==null ? null : cause.toString()) + * (which typically contains the class and detail message of + * cause). This constructor is useful for runtime exceptions + * that are little more than wrappers for other throwables. + * + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.4 + */ + public RuntimeException(Throwable cause) { + super(cause); + } + + /** + * Constructs a new runtime exception with the specified detail + * message, cause, suppression enabled or disabled, and writable + * stack trace enabled or disabled. + * + * @param message the detail message. + * @param cause the cause. (A {@code null} value is permitted, + * and indicates that the cause is nonexistent or unknown.) + * @param enableSuppression whether or not suppression is enabled + * or disabled + * @param writableStackTrace whether or not the stack trace should + * be writable + * + * @since 1.7 + */ + protected RuntimeException(String message, Throwable cause, + boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Short.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Short.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,468 @@ +/* + * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * The {@code Short} class wraps a value of primitive type {@code + * short} in an object. An object of type {@code Short} contains a + * single field whose type is {@code short}. + * + *

In addition, this class provides several methods for converting + * a {@code short} to a {@code String} and a {@code String} to a + * {@code short}, as well as other constants and methods useful when + * dealing with a {@code short}. + * + * @author Nakul Saraiya + * @author Joseph D. Darcy + * @see java.lang.Number + * @since JDK1.1 + */ +public final class Short extends Number implements Comparable { + + /** + * A constant holding the minimum value a {@code short} can + * have, -215. + */ + public static final short MIN_VALUE = -32768; + + /** + * A constant holding the maximum value a {@code short} can + * have, 215-1. + */ + public static final short MAX_VALUE = 32767; + + /** + * The {@code Class} instance representing the primitive type + * {@code short}. + */ + public static final Class TYPE = (Class) Class.getPrimitiveClass("short"); + + /** + * Returns a new {@code String} object representing the + * specified {@code short}. The radix is assumed to be 10. + * + * @param s the {@code short} to be converted + * @return the string representation of the specified {@code short} + * @see java.lang.Integer#toString(int) + */ + public static String toString(short s) { + return Integer.toString((int)s, 10); + } + + /** + * Parses the string argument as a signed {@code short} in the + * radix specified by the second argument. The characters in the + * string must all be digits, of the specified radix (as + * determined by whether {@link java.lang.Character#digit(char, + * int)} returns a nonnegative value) except that the first + * character may be an ASCII minus sign {@code '-'} + * ('\u002D') to indicate a negative value or an + * ASCII plus sign {@code '+'} ('\u002B') to + * indicate a positive value. The resulting {@code short} value + * is returned. + * + *

An exception of type {@code NumberFormatException} is + * thrown if any of the following situations occurs: + *

    + *
  • The first argument is {@code null} or is a string of + * length zero. + * + *
  • The radix is either smaller than {@link + * java.lang.Character#MIN_RADIX} or larger than {@link + * java.lang.Character#MAX_RADIX}. + * + *
  • Any character of the string is not a digit of the + * specified radix, except that the first character may be a minus + * sign {@code '-'} ('\u002D') or plus sign + * {@code '+'} ('\u002B') provided that the + * string is longer than length 1. + * + *
  • The value represented by the string is not a value of type + * {@code short}. + *
+ * + * @param s the {@code String} containing the + * {@code short} representation to be parsed + * @param radix the radix to be used while parsing {@code s} + * @return the {@code short} represented by the string + * argument in the specified radix. + * @throws NumberFormatException If the {@code String} + * does not contain a parsable {@code short}. + */ + public static short parseShort(String s, int radix) + throws NumberFormatException { + int i = Integer.parseInt(s, radix); + if (i < MIN_VALUE || i > MAX_VALUE) + throw new NumberFormatException( + "Value out of range. Value:\"" + s + "\" Radix:" + radix); + return (short)i; + } + + /** + * Parses the string argument as a signed decimal {@code + * short}. The characters in the string must all be decimal + * digits, except that the first character may be an ASCII minus + * sign {@code '-'} ('\u002D') to indicate a + * negative value or an ASCII plus sign {@code '+'} + * ('\u002B') to indicate a positive value. The + * resulting {@code short} value is returned, exactly as if the + * argument and the radix 10 were given as arguments to the {@link + * #parseShort(java.lang.String, int)} method. + * + * @param s a {@code String} containing the {@code short} + * representation to be parsed + * @return the {@code short} value represented by the + * argument in decimal. + * @throws NumberFormatException If the string does not + * contain a parsable {@code short}. + */ + public static short parseShort(String s) throws NumberFormatException { + return parseShort(s, 10); + } + + /** + * Returns a {@code Short} object holding the value + * extracted from the specified {@code String} when parsed + * with the radix given by the second argument. The first argument + * is interpreted as representing a signed {@code short} in + * the radix specified by the second argument, exactly as if the + * argument were given to the {@link #parseShort(java.lang.String, + * int)} method. The result is a {@code Short} object that + * represents the {@code short} value specified by the string. + * + *

In other words, this method returns a {@code Short} object + * equal to the value of: + * + *

+ * {@code new Short(Short.parseShort(s, radix))} + *
+ * + * @param s the string to be parsed + * @param radix the radix to be used in interpreting {@code s} + * @return a {@code Short} object holding the value + * represented by the string argument in the + * specified radix. + * @throws NumberFormatException If the {@code String} does + * not contain a parsable {@code short}. + */ + public static Short valueOf(String s, int radix) + throws NumberFormatException { + return valueOf(parseShort(s, radix)); + } + + /** + * Returns a {@code Short} object holding the + * value given by the specified {@code String}. The argument + * is interpreted as representing a signed decimal + * {@code short}, exactly as if the argument were given to + * the {@link #parseShort(java.lang.String)} method. The result is + * a {@code Short} object that represents the + * {@code short} value specified by the string. + * + *

In other words, this method returns a {@code Short} object + * equal to the value of: + * + *

+ * {@code new Short(Short.parseShort(s))} + *
+ * + * @param s the string to be parsed + * @return a {@code Short} object holding the value + * represented by the string argument + * @throws NumberFormatException If the {@code String} does + * not contain a parsable {@code short}. + */ + public static Short valueOf(String s) throws NumberFormatException { + return valueOf(s, 10); + } + + private static class ShortCache { + private ShortCache(){} + + static final Short cache[] = new Short[-(-128) + 127 + 1]; + + static { + for(int i = 0; i < cache.length; i++) + cache[i] = new Short((short)(i - 128)); + } + } + + /** + * Returns a {@code Short} instance representing the specified + * {@code short} value. + * If a new {@code Short} instance is not required, this method + * should generally be used in preference to the constructor + * {@link #Short(short)}, as this method is likely to yield + * significantly better space and time performance by caching + * frequently requested values. + * + * This method will always cache values in the range -128 to 127, + * inclusive, and may cache other values outside of this range. + * + * @param s a short value. + * @return a {@code Short} instance representing {@code s}. + * @since 1.5 + */ + public static Short valueOf(short s) { + final int offset = 128; + int sAsInt = s; + if (sAsInt >= -128 && sAsInt <= 127) { // must cache + return ShortCache.cache[sAsInt + offset]; + } + return new Short(s); + } + + /** + * Decodes a {@code String} into a {@code Short}. + * Accepts decimal, hexadecimal, and octal numbers given by + * the following grammar: + * + *
+ *
+ *
DecodableString: + *
Signopt DecimalNumeral + *
Signopt {@code 0x} HexDigits + *
Signopt {@code 0X} HexDigits + *
Signopt {@code #} HexDigits + *
Signopt {@code 0} OctalDigits + *

+ *

Sign: + *
{@code -} + *
{@code +} + *
+ *
+ * + * DecimalNumeral, HexDigits, and OctalDigits + * are as defined in section 3.10.1 of + * The Java™ Language Specification, + * except that underscores are not accepted between digits. + * + *

The sequence of characters following an optional + * sign and/or radix specifier ("{@code 0x}", "{@code 0X}", + * "{@code #}", or leading zero) is parsed as by the {@code + * Short.parseShort} method with the indicated radix (10, 16, or + * 8). This sequence of characters must represent a positive + * value or a {@link NumberFormatException} will be thrown. The + * result is negated if first character of the specified {@code + * String} is the minus sign. No whitespace characters are + * permitted in the {@code String}. + * + * @param nm the {@code String} to decode. + * @return a {@code Short} object holding the {@code short} + * value represented by {@code nm} + * @throws NumberFormatException if the {@code String} does not + * contain a parsable {@code short}. + * @see java.lang.Short#parseShort(java.lang.String, int) + */ + public static Short decode(String nm) throws NumberFormatException { + int i = Integer.decode(nm); + if (i < MIN_VALUE || i > MAX_VALUE) + throw new NumberFormatException( + "Value " + i + " out of range from input " + nm); + return valueOf((short)i); + } + + /** + * The value of the {@code Short}. + * + * @serial + */ + private final short value; + + /** + * Constructs a newly allocated {@code Short} object that + * represents the specified {@code short} value. + * + * @param value the value to be represented by the + * {@code Short}. + */ + public Short(short value) { + this.value = value; + } + + /** + * Constructs a newly allocated {@code Short} object that + * represents the {@code short} value indicated by the + * {@code String} parameter. The string is converted to a + * {@code short} value in exactly the manner used by the + * {@code parseShort} method for radix 10. + * + * @param s the {@code String} to be converted to a + * {@code Short} + * @throws NumberFormatException If the {@code String} + * does not contain a parsable {@code short}. + * @see java.lang.Short#parseShort(java.lang.String, int) + */ + public Short(String s) throws NumberFormatException { + this.value = parseShort(s, 10); + } + + /** + * Returns the value of this {@code Short} as a + * {@code byte}. + */ + public byte byteValue() { + return (byte)value; + } + + /** + * Returns the value of this {@code Short} as a + * {@code short}. + */ + public short shortValue() { + return value; + } + + /** + * Returns the value of this {@code Short} as an + * {@code int}. + */ + public int intValue() { + return (int)value; + } + + /** + * Returns the value of this {@code Short} as a + * {@code long}. + */ + public long longValue() { + return (long)value; + } + + /** + * Returns the value of this {@code Short} as a + * {@code float}. + */ + public float floatValue() { + return (float)value; + } + + /** + * Returns the value of this {@code Short} as a + * {@code double}. + */ + public double doubleValue() { + return (double)value; + } + + /** + * Returns a {@code String} object representing this + * {@code Short}'s value. The value is converted to signed + * decimal representation and returned as a string, exactly as if + * the {@code short} value were given as an argument to the + * {@link java.lang.Short#toString(short)} method. + * + * @return a string representation of the value of this object in + * base 10. + */ + public String toString() { + return Integer.toString((int)value); + } + + /** + * Returns a hash code for this {@code Short}; equal to the result + * of invoking {@code intValue()}. + * + * @return a hash code value for this {@code Short} + */ + public int hashCode() { + return (int)value; + } + + /** + * Compares this object to the specified object. The result is + * {@code true} if and only if the argument is not + * {@code null} and is a {@code Short} object that + * contains the same {@code short} value as this object. + * + * @param obj the object to compare with + * @return {@code true} if the objects are the same; + * {@code false} otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof Short) { + return value == ((Short)obj).shortValue(); + } + return false; + } + + /** + * Compares two {@code Short} objects numerically. + * + * @param anotherShort the {@code Short} to be compared. + * @return the value {@code 0} if this {@code Short} is + * equal to the argument {@code Short}; a value less than + * {@code 0} if this {@code Short} is numerically less + * than the argument {@code Short}; and a value greater than + * {@code 0} if this {@code Short} is numerically + * greater than the argument {@code Short} (signed + * comparison). + * @since 1.2 + */ + public int compareTo(Short anotherShort) { + return compare(this.value, anotherShort.value); + } + + /** + * Compares two {@code short} values numerically. + * The value returned is identical to what would be returned by: + *

+     *    Short.valueOf(x).compareTo(Short.valueOf(y))
+     * 
+ * + * @param x the first {@code short} to compare + * @param y the second {@code short} to compare + * @return the value {@code 0} if {@code x == y}; + * a value less than {@code 0} if {@code x < y}; and + * a value greater than {@code 0} if {@code x > y} + * @since 1.7 + */ + public static int compare(short x, short y) { + return x - y; + } + + /** + * The number of bits used to represent a {@code short} value in two's + * complement binary form. + * @since 1.5 + */ + public static final int SIZE = 16; + + /** + * Returns the value obtained by reversing the order of the bytes in the + * two's complement representation of the specified {@code short} value. + * + * @return the value obtained by reversing (or, equivalently, swapping) + * the bytes in the specified {@code short} value. + * @since 1.5 + */ + public static short reverseBytes(short i) { + return (short) (((i & 0xFF00) >> 8) | (i << 8)); + } + + /** use serialVersionUID from JDK 1.1. for interoperability */ + private static final long serialVersionUID = 7515723908773894738L; +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/StackTraceElement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/StackTraceElement.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,223 @@ +/* + * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * An element in a stack trace, as returned by {@link + * Throwable#getStackTrace()}. Each element represents a single stack frame. + * All stack frames except for the one at the top of the stack represent + * a method invocation. The frame at the top of the stack represents the + * execution point at which the stack trace was generated. Typically, + * this is the point at which the throwable corresponding to the stack trace + * was created. + * + * @since 1.4 + * @author Josh Bloch + */ +public final class StackTraceElement implements java.io.Serializable { + // Normally initialized by VM (public constructor added in 1.5) + private String declaringClass; + private String methodName; + private String fileName; + private int lineNumber; + + /** + * Creates a stack trace element representing the specified execution + * point. + * + * @param declaringClass the fully qualified name of the class containing + * the execution point represented by the stack trace element + * @param methodName the name of the method containing the execution point + * represented by the stack trace element + * @param fileName the name of the file containing the execution point + * represented by the stack trace element, or {@code null} if + * this information is unavailable + * @param lineNumber the line number of the source line containing the + * execution point represented by this stack trace element, or + * a negative number if this information is unavailable. A value + * of -2 indicates that the method containing the execution point + * is a native method + * @throws NullPointerException if {@code declaringClass} or + * {@code methodName} is null + * @since 1.5 + */ + public StackTraceElement(String declaringClass, String methodName, + String fileName, int lineNumber) { + this.declaringClass = declaringClass; + this.methodName = methodName; + this.fileName = fileName; + this.lineNumber = lineNumber; + } + + /** + * Returns the name of the source file containing the execution point + * represented by this stack trace element. Generally, this corresponds + * to the {@code SourceFile} attribute of the relevant {@code class} + * file (as per The Java Virtual Machine Specification, Section + * 4.7.7). In some systems, the name may refer to some source code unit + * other than a file, such as an entry in source repository. + * + * @return the name of the file containing the execution point + * represented by this stack trace element, or {@code null} if + * this information is unavailable. + */ + public String getFileName() { + return fileName; + } + + /** + * Returns the line number of the source line containing the execution + * point represented by this stack trace element. Generally, this is + * derived from the {@code LineNumberTable} attribute of the relevant + * {@code class} file (as per The Java Virtual Machine + * Specification, Section 4.7.8). + * + * @return the line number of the source line containing the execution + * point represented by this stack trace element, or a negative + * number if this information is unavailable. + */ + public int getLineNumber() { + return lineNumber; + } + + /** + * Returns the fully qualified name of the class containing the + * execution point represented by this stack trace element. + * + * @return the fully qualified name of the {@code Class} containing + * the execution point represented by this stack trace element. + */ + public String getClassName() { + return declaringClass; + } + + /** + * Returns the name of the method containing the execution point + * represented by this stack trace element. If the execution point is + * contained in an instance or class initializer, this method will return + * the appropriate special method name, {@code } or + * {@code }, as per Section 3.9 of The Java Virtual + * Machine Specification. + * + * @return the name of the method containing the execution point + * represented by this stack trace element. + */ + public String getMethodName() { + return methodName; + } + + /** + * Returns true if the method containing the execution point + * represented by this stack trace element is a native method. + * + * @return {@code true} if the method containing the execution point + * represented by this stack trace element is a native method. + */ + public boolean isNativeMethod() { + return lineNumber == -2; + } + + /** + * Returns a string representation of this stack trace element. The + * format of this string depends on the implementation, but the following + * examples may be regarded as typical: + *
    + *
  • + * {@code "MyClass.mash(MyClass.java:9)"} - Here, {@code "MyClass"} + * is the fully-qualified name of the class containing the + * execution point represented by this stack trace element, + * {@code "mash"} is the name of the method containing the execution + * point, {@code "MyClass.java"} is the source file containing the + * execution point, and {@code "9"} is the line number of the source + * line containing the execution point. + *
  • + * {@code "MyClass.mash(MyClass.java)"} - As above, but the line + * number is unavailable. + *
  • + * {@code "MyClass.mash(Unknown Source)"} - As above, but neither + * the file name nor the line number are available. + *
  • + * {@code "MyClass.mash(Native Method)"} - As above, but neither + * the file name nor the line number are available, and the method + * containing the execution point is known to be a native method. + *
+ * @see Throwable#printStackTrace() + */ + public String toString() { + return getClassName() + "." + methodName + + (isNativeMethod() ? "(Native Method)" : + (fileName != null && lineNumber >= 0 ? + "(" + fileName + ":" + lineNumber + ")" : + (fileName != null ? "("+fileName+")" : "(Unknown Source)"))); + } + + /** + * Returns true if the specified object is another + * {@code StackTraceElement} instance representing the same execution + * point as this instance. Two stack trace elements {@code a} and + * {@code b} are equal if and only if: + *
+     *     equals(a.getFileName(), b.getFileName()) &&
+     *     a.getLineNumber() == b.getLineNumber()) &&
+     *     equals(a.getClassName(), b.getClassName()) &&
+     *     equals(a.getMethodName(), b.getMethodName())
+     * 
+ * where {@code equals} has the semantics of {@link + * java.util.Objects#equals(Object, Object) Objects.equals}. + * + * @param obj the object to be compared with this stack trace element. + * @return true if the specified object is another + * {@code StackTraceElement} instance representing the same + * execution point as this instance. + */ + public boolean equals(Object obj) { + if (obj==this) + return true; + if (!(obj instanceof StackTraceElement)) + return false; + StackTraceElement e = (StackTraceElement)obj; + return e.declaringClass.equals(declaringClass) && + e.lineNumber == lineNumber && + equals(methodName, e.methodName) && + equals(fileName, e.fileName); + } + + /** + * Returns a hash code value for this stack trace element. + */ + public int hashCode() { + int result = 31*declaringClass.hashCode() + methodName.hashCode(); + result = 31*result + (fileName == null ? 0 : fileName.hashCode()); + result = 31*result + lineNumber; + return result; + } + + private static boolean equals(Object a, Object b) { + return (a == b) || (a != null && a.equals(b)); + } + + private static final long serialVersionUID = 6992337162326171013L; +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/StrictMath.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/StrictMath.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,1457 @@ +/* + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * The class {@code StrictMath} contains methods for performing basic + * numeric operations such as the elementary exponential, logarithm, + * square root, and trigonometric functions. + * + *

To help ensure portability of Java programs, the definitions of + * some of the numeric functions in this package require that they + * produce the same results as certain published algorithms. These + * algorithms are available from the well-known network library + * {@code netlib} as the package "Freely Distributable Math + * Library," {@code fdlibm}. These + * algorithms, which are written in the C programming language, are + * then to be understood as executed with all floating-point + * operations following the rules of Java floating-point arithmetic. + * + *

The Java math library is defined with respect to + * {@code fdlibm} version 5.3. Where {@code fdlibm} provides + * more than one definition for a function (such as + * {@code acos}), use the "IEEE 754 core function" version + * (residing in a file whose name begins with the letter + * {@code e}). The methods which require {@code fdlibm} + * semantics are {@code sin}, {@code cos}, {@code tan}, + * {@code asin}, {@code acos}, {@code atan}, + * {@code exp}, {@code log}, {@code log10}, + * {@code cbrt}, {@code atan2}, {@code pow}, + * {@code sinh}, {@code cosh}, {@code tanh}, + * {@code hypot}, {@code expm1}, and {@code log1p}. + * + * @author unascribed + * @author Joseph D. Darcy + * @since 1.3 + */ + +public final class StrictMath { + + /** + * Don't let anyone instantiate this class. + */ + private StrictMath() {} + + /** + * The {@code double} value that is closer than any other to + * e, the base of the natural logarithms. + */ + public static final double E = 2.7182818284590452354; + + /** + * The {@code double} value that is closer than any other to + * pi, the ratio of the circumference of a circle to its + * diameter. + */ + public static final double PI = 3.14159265358979323846; + + /** + * Returns the trigonometric sine of an angle. Special cases: + *

  • If the argument is NaN or an infinity, then the + * result is NaN. + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument.
+ * + * @param a an angle, in radians. + * @return the sine of the argument. + */ + public static native double sin(double a); + + /** + * Returns the trigonometric cosine of an angle. Special cases: + *
  • If the argument is NaN or an infinity, then the + * result is NaN.
+ * + * @param a an angle, in radians. + * @return the cosine of the argument. + */ + public static native double cos(double a); + + /** + * Returns the trigonometric tangent of an angle. Special cases: + *
  • If the argument is NaN or an infinity, then the result + * is NaN. + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument.
+ * + * @param a an angle, in radians. + * @return the tangent of the argument. + */ + public static native double tan(double a); + + /** + * Returns the arc sine of a value; the returned angle is in the + * range -pi/2 through pi/2. Special cases: + *
  • If the argument is NaN or its absolute value is greater + * than 1, then the result is NaN. + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument.
+ * + * @param a the value whose arc sine is to be returned. + * @return the arc sine of the argument. + */ + public static native double asin(double a); + + /** + * Returns the arc cosine of a value; the returned angle is in the + * range 0.0 through pi. Special case: + *
  • If the argument is NaN or its absolute value is greater + * than 1, then the result is NaN.
+ * + * @param a the value whose arc cosine is to be returned. + * @return the arc cosine of the argument. + */ + public static native double acos(double a); + + /** + * Returns the arc tangent of a value; the returned angle is in the + * range -pi/2 through pi/2. Special cases: + *
  • If the argument is NaN, then the result is NaN. + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument.
+ * + * @param a the value whose arc tangent is to be returned. + * @return the arc tangent of the argument. + */ + public static native double atan(double a); + + /** + * Converts an angle measured in degrees to an approximately + * equivalent angle measured in radians. The conversion from + * degrees to radians is generally inexact. + * + * @param angdeg an angle, in degrees + * @return the measurement of the angle {@code angdeg} + * in radians. + */ + public static strictfp double toRadians(double angdeg) { + return angdeg / 180.0 * PI; + } + + /** + * Converts an angle measured in radians to an approximately + * equivalent angle measured in degrees. The conversion from + * radians to degrees is generally inexact; users should + * not expect {@code cos(toRadians(90.0))} to exactly + * equal {@code 0.0}. + * + * @param angrad an angle, in radians + * @return the measurement of the angle {@code angrad} + * in degrees. + */ + public static strictfp double toDegrees(double angrad) { + return angrad * 180.0 / PI; + } + + /** + * Returns Euler's number e raised to the power of a + * {@code double} value. Special cases: + *
  • If the argument is NaN, the result is NaN. + *
  • If the argument is positive infinity, then the result is + * positive infinity. + *
  • If the argument is negative infinity, then the result is + * positive zero.
+ * + * @param a the exponent to raise e to. + * @return the value e{@code a}, + * where e is the base of the natural logarithms. + */ + public static native double exp(double a); + + /** + * Returns the natural logarithm (base e) of a {@code double} + * value. Special cases: + *
  • If the argument is NaN or less than zero, then the result + * is NaN. + *
  • If the argument is positive infinity, then the result is + * positive infinity. + *
  • If the argument is positive zero or negative zero, then the + * result is negative infinity.
+ * + * @param a a value + * @return the value ln {@code a}, the natural logarithm of + * {@code a}. + */ + public static native double log(double a); + + + /** + * Returns the base 10 logarithm of a {@code double} value. + * Special cases: + * + *
  • If the argument is NaN or less than zero, then the result + * is NaN. + *
  • If the argument is positive infinity, then the result is + * positive infinity. + *
  • If the argument is positive zero or negative zero, then the + * result is negative infinity. + *
  • If the argument is equal to 10n for + * integer n, then the result is n. + *
+ * + * @param a a value + * @return the base 10 logarithm of {@code a}. + * @since 1.5 + */ + public static native double log10(double a); + + /** + * Returns the correctly rounded positive square root of a + * {@code double} value. + * Special cases: + *
  • If the argument is NaN or less than zero, then the result + * is NaN. + *
  • If the argument is positive infinity, then the result is positive + * infinity. + *
  • If the argument is positive zero or negative zero, then the + * result is the same as the argument.
+ * Otherwise, the result is the {@code double} value closest to + * the true mathematical square root of the argument value. + * + * @param a a value. + * @return the positive square root of {@code a}. + */ + public static native double sqrt(double a); + + /** + * Returns the cube root of a {@code double} value. For + * positive finite {@code x}, {@code cbrt(-x) == + * -cbrt(x)}; that is, the cube root of a negative value is + * the negative of the cube root of that value's magnitude. + * Special cases: + * + *
    + * + *
  • If the argument is NaN, then the result is NaN. + * + *
  • If the argument is infinite, then the result is an infinity + * with the same sign as the argument. + * + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument. + * + *
+ * + * @param a a value. + * @return the cube root of {@code a}. + * @since 1.5 + */ + public static native double cbrt(double a); + + /** + * Computes the remainder operation on two arguments as prescribed + * by the IEEE 754 standard. + * The remainder value is mathematically equal to + * f1 - f2 × n, + * where n is the mathematical integer closest to the exact + * mathematical value of the quotient {@code f1/f2}, and if two + * mathematical integers are equally close to {@code f1/f2}, + * then n is the integer that is even. If the remainder is + * zero, its sign is the same as the sign of the first argument. + * Special cases: + *
  • If either argument is NaN, or the first argument is infinite, + * or the second argument is positive zero or negative zero, then the + * result is NaN. + *
  • If the first argument is finite and the second argument is + * infinite, then the result is the same as the first argument.
+ * + * @param f1 the dividend. + * @param f2 the divisor. + * @return the remainder when {@code f1} is divided by + * {@code f2}. + */ + public static native double IEEEremainder(double f1, double f2); + + /** + * Returns the smallest (closest to negative infinity) + * {@code double} value that is greater than or equal to the + * argument and is equal to a mathematical integer. Special cases: + *
  • If the argument value is already equal to a + * mathematical integer, then the result is the same as the + * argument.
  • If the argument is NaN or an infinity or + * positive zero or negative zero, then the result is the same as + * the argument.
  • If the argument value is less than zero but + * greater than -1.0, then the result is negative zero.
Note + * that the value of {@code StrictMath.ceil(x)} is exactly the + * value of {@code -StrictMath.floor(-x)}. + * + * @param a a value. + * @return the smallest (closest to negative infinity) + * floating-point value that is greater than or equal to + * the argument and is equal to a mathematical integer. + */ + public static double ceil(double a) { + return floorOrCeil(a, -0.0, 1.0, 1.0); + } + + /** + * Returns the largest (closest to positive infinity) + * {@code double} value that is less than or equal to the + * argument and is equal to a mathematical integer. Special cases: + *
  • If the argument value is already equal to a + * mathematical integer, then the result is the same as the + * argument.
  • If the argument is NaN or an infinity or + * positive zero or negative zero, then the result is the same as + * the argument.
+ * + * @param a a value. + * @return the largest (closest to positive infinity) + * floating-point value that less than or equal to the argument + * and is equal to a mathematical integer. + */ + public static double floor(double a) { + return floorOrCeil(a, -1.0, 0.0, -1.0); + } + + /** + * Internal method to share logic between floor and ceil. + * + * @param a the value to be floored or ceiled + * @param negativeBoundary result for values in (-1, 0) + * @param positiveBoundary result for values in (0, 1) + * @param increment value to add when the argument is non-integral + */ + private static double floorOrCeil(double a, + double negativeBoundary, + double positiveBoundary, + double sign) { + int exponent = getExponent(a); + + if (exponent < 0) { + /* + * Absolute value of argument is less than 1. + * floorOrceil(-0.0) => -0.0 + * floorOrceil(+0.0) => +0.0 + */ + return ((a == 0.0) ? a : + ( (a < 0.0) ? negativeBoundary : positiveBoundary) ); + } else if (exponent >= 52) { + /* + * Infinity, NaN, or a value so large it must be integral. + */ + return a; + } + // Else the argument is either an integral value already XOR it + // has to be rounded to one. + assert exponent >= 0 && exponent <= 51; + + long doppel = Double.doubleToRawLongBits(a); + long mask = 0; // DoubleConsts.SIGNIF_BIT_MASK >> exponent; + + if ( (mask & doppel) == 0L ) + return a; // integral value + else { + double result = Double.longBitsToDouble(doppel & (~mask)); + if (sign*a > 0.0) + result = result + sign; + return result; + } + } + + /** + * Returns the {@code double} value that is closest in value + * to the argument and is equal to a mathematical integer. If two + * {@code double} values that are mathematical integers are + * equally close to the value of the argument, the result is the + * integer value that is even. Special cases: + *
  • If the argument value is already equal to a mathematical + * integer, then the result is the same as the argument. + *
  • If the argument is NaN or an infinity or positive zero or negative + * zero, then the result is the same as the argument.
+ * + * @param a a value. + * @return the closest floating-point value to {@code a} that is + * equal to a mathematical integer. + * @author Joseph D. Darcy + */ + public static double rint(double a) { + throw new UnsupportedOperationException(); + /* + * If the absolute value of a is not less than 2^52, it + * is either a finite integer (the double format does not have + * enough significand bits for a number that large to have any + * fractional portion), an infinity, or a NaN. In any of + * these cases, rint of the argument is the argument. + * + * Otherwise, the sum (twoToThe52 + a ) will properly round + * away any fractional portion of a since ulp(twoToThe52) == + * 1.0; subtracting out twoToThe52 from this sum will then be + * exact and leave the rounded integer portion of a. + * + * This method does *not* need to be declared strictfp to get + * fully reproducible results. Whether or not a method is + * declared strictfp can only make a difference in the + * returned result if some operation would overflow or + * underflow with strictfp semantics. The operation + * (twoToThe52 + a ) cannot overflow since large values of a + * are screened out; the add cannot underflow since twoToThe52 + * is too large. The subtraction ((twoToThe52 + a ) - + * twoToThe52) will be exact as discussed above and thus + * cannot overflow or meaningfully underflow. Finally, the + * last multiply in the return statement is by plus or minus + * 1.0, which is exact too. + */ +// double twoToThe52 = (double)(1L << 52); // 2^52 +// double sign = FpUtils.rawCopySign(1.0, a); // preserve sign info +// a = Math.abs(a); +// +// if (a < twoToThe52) { // E_min <= ilogb(a) <= 51 +// a = ((twoToThe52 + a ) - twoToThe52); +// } +// +// return sign * a; // restore original sign + } + + /** + * Returns the angle theta from the conversion of rectangular + * coordinates ({@code x}, {@code y}) to polar + * coordinates (r, theta). + * This method computes the phase theta by computing an arc tangent + * of {@code y/x} in the range of -pi to pi. Special + * cases: + *
  • If either argument is NaN, then the result is NaN. + *
  • 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. + *
  • 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. + *
  • 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 + * {@code double} value closest to pi. + *
  • 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 + * {@code double} value closest to -pi. + *
  • 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 + * {@code double} value closest to pi/2. + *
  • 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 + * {@code double} value closest to -pi/2. + *
  • If both arguments are positive infinity, then the result is the + * {@code double} value closest to pi/4. + *
  • If the first argument is positive infinity and the second argument + * is negative infinity, then the result is the {@code double} + * value closest to 3*pi/4. + *
  • If the first argument is negative infinity and the second argument + * is positive infinity, then the result is the {@code double} value + * closest to -pi/4. + *
  • If both arguments are negative infinity, then the result is the + * {@code double} value closest to -3*pi/4.
+ * + * @param y the ordinate coordinate + * @param x the abscissa coordinate + * @return the theta component of the point + * (rtheta) + * in polar coordinates that corresponds to the point + * (xy) in Cartesian coordinates. + */ + public static native double atan2(double y, double x); + + + /** + * Returns the value of the first argument raised to the power of the + * second argument. Special cases: + * + *
  • If the second argument is positive or negative zero, then the + * result is 1.0. + *
  • If the second argument is 1.0, then the result is the same as the + * first argument. + *
  • If the second argument is NaN, then the result is NaN. + *
  • If the first argument is NaN and the second argument is nonzero, + * then the result is NaN. + * + *
  • 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. + * + *
  • 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. + * + *
  • If the absolute value of the first argument equals 1 and the + * second argument is infinite, then the result is NaN. + * + *
  • 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. + * + *
  • 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. + * + *
  • 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. + * + *
  • 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. + * + *
  • 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. + * + *
  • 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. + * + *
  • If the first argument is finite and less than zero + *
      + *
    • if the second argument is a finite even integer, the + * result is equal to the result of raising the absolute value of + * the first argument to the power of the second argument + * + *
    • if the second argument is a finite odd integer, 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 + * + *
    • if the second argument is finite and not an integer, then + * the result is NaN. + *
    + * + *
  • 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 {@code double} value.
+ * + *

(In the foregoing descriptions, a floating-point value is + * considered to be an integer if and only if it is finite and a + * fixed point of the method {@link #ceil ceil} or, + * equivalently, a fixed point of the method {@link #floor + * floor}. 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 a base. + * @param b the exponent. + * @return the value {@code a}{@code b}. + */ + public static native double pow(double a, double b); + + /** + * Returns the closest {@code int} to the argument, with ties + * rounding up. + * + *

Special cases: + *

  • If the argument is NaN, the result is 0. + *
  • If the argument is negative infinity or any value less than or + * equal to the value of {@code Integer.MIN_VALUE}, the result is + * equal to the value of {@code Integer.MIN_VALUE}. + *
  • If the argument is positive infinity or any value greater than or + * equal to the value of {@code Integer.MAX_VALUE}, the result is + * equal to the value of {@code Integer.MAX_VALUE}.
+ * + * @param a a floating-point value to be rounded to an integer. + * @return the value of the argument rounded to the nearest + * {@code int} value. + * @see java.lang.Integer#MAX_VALUE + * @see java.lang.Integer#MIN_VALUE + */ + public static int round(float a) { + return Math.round(a); + } + + /** + * Returns the closest {@code long} to the argument, with ties + * rounding up. + * + *

Special cases: + *

  • If the argument is NaN, the result is 0. + *
  • If the argument is negative infinity or any value less than or + * equal to the value of {@code Long.MIN_VALUE}, the result is + * equal to the value of {@code Long.MIN_VALUE}. + *
  • If the argument is positive infinity or any value greater than or + * equal to the value of {@code Long.MAX_VALUE}, the result is + * equal to the value of {@code Long.MAX_VALUE}.
+ * + * @param a a floating-point value to be rounded to a + * {@code long}. + * @return the value of the argument rounded to the nearest + * {@code long} value. + * @see java.lang.Long#MAX_VALUE + * @see java.lang.Long#MIN_VALUE + */ + public static long round(double a) { + return Math.round(a); + } + + /** + * Returns a {@code double} value with a positive sign, greater + * than or equal to {@code 0.0} and less than {@code 1.0}. + * Returned values are chosen pseudorandomly with (approximately) + * uniform distribution from that range. + * + *

When this method is first called, it creates a single new + * pseudorandom-number generator, exactly as if by the expression + * + *

{@code new java.util.Random()}
+ * + * This new pseudorandom-number generator is used thereafter for + * all calls to this method and is used nowhere else. + * + *

This method is properly synchronized to allow correct use by + * more than one thread. However, if many threads need to generate + * pseudorandom numbers at a great rate, it may reduce contention + * for each thread to have its own pseudorandom number generator. + * + * @return a pseudorandom {@code double} greater than or equal + * to {@code 0.0} and less than {@code 1.0}. + * @see Random#nextDouble() + */ + public static double random() { + throw new UnsupportedOperationException(); + } + + /** + * Returns the absolute value of an {@code int} value.. + * If the argument is not negative, the argument is returned. + * If the argument is negative, the negation of the argument is returned. + * + *

Note that if the argument is equal to the value of + * {@link Integer#MIN_VALUE}, the most negative representable + * {@code int} value, the result is that same value, which is + * negative. + * + * @param a the argument whose absolute value is to be determined. + * @return the absolute value of the argument. + */ + public static int abs(int a) { + return (a < 0) ? -a : a; + } + + /** + * Returns the absolute value of a {@code long} value. + * If the argument is not negative, the argument is returned. + * If the argument is negative, the negation of the argument is returned. + * + *

Note that if the argument is equal to the value of + * {@link Long#MIN_VALUE}, the most negative representable + * {@code long} value, the result is that same value, which + * is negative. + * + * @param a the argument whose absolute value is to be determined. + * @return the absolute value of the argument. + */ + public static long abs(long a) { + return (a < 0) ? -a : a; + } + + /** + * Returns the absolute value of a {@code float} value. + * If the argument is not negative, the argument is returned. + * If the argument is negative, the negation of the argument is returned. + * Special cases: + *

  • If the argument is positive zero or negative zero, the + * result is positive zero. + *
  • If the argument is infinite, the result is positive infinity. + *
  • If the argument is NaN, the result is NaN.
+ * In other words, the result is the same as the value of the expression: + *

{@code Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))} + * + * @param a the argument whose absolute value is to be determined + * @return the absolute value of the argument. + */ + public static float abs(float a) { + return (a <= 0.0F) ? 0.0F - a : a; + } + + /** + * Returns the absolute value of a {@code double} value. + * If the argument is not negative, the argument is returned. + * If the argument is negative, the negation of the argument is returned. + * Special cases: + *

  • If the argument is positive zero or negative zero, the result + * is positive zero. + *
  • If the argument is infinite, the result is positive infinity. + *
  • If the argument is NaN, the result is NaN.
+ * In other words, the result is the same as the value of the expression: + *

{@code Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)} + * + * @param a the argument whose absolute value is to be determined + * @return the absolute value of the argument. + */ + public static double abs(double a) { + return (a <= 0.0D) ? 0.0D - a : a; + } + + /** + * Returns the greater of two {@code int} values. That is, the + * result is the argument closer to the value of + * {@link Integer#MAX_VALUE}. If the arguments have the same value, + * the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the larger of {@code a} and {@code b}. + */ + public static int max(int a, int b) { + return (a >= b) ? a : b; + } + + /** + * Returns the greater of two {@code long} values. That is, the + * result is the argument closer to the value of + * {@link Long#MAX_VALUE}. If the arguments have the same value, + * the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the larger of {@code a} and {@code b}. + */ + public static long max(long a, long b) { + return (a >= b) ? a : b; + } + + // Use raw bit-wise conversions on guaranteed non-NaN arguments. + private static long negativeZeroFloatBits = Float.floatToRawIntBits(-0.0f); + private static long negativeZeroDoubleBits = Double.doubleToRawLongBits(-0.0d); + + /** + * Returns the greater of two {@code float} values. That is, + * the result is the argument closer to positive infinity. If the + * arguments have the same value, the result is that same + * value. If either value is NaN, then the result is NaN. Unlike + * the numerical comparison operators, this method considers + * negative zero to be strictly smaller than positive zero. If one + * argument is positive zero and the other negative zero, the + * result is positive zero. + * + * @param a an argument. + * @param b another argument. + * @return the larger of {@code a} and {@code b}. + */ + public static float max(float a, float b) { + if (a != a) + return a; // a is NaN + if ((a == 0.0f) && + (b == 0.0f) && + (Float.floatToRawIntBits(a) == negativeZeroFloatBits)) { + // Raw conversion ok since NaN can't map to -0.0. + return b; + } + return (a >= b) ? a : b; + } + + /** + * Returns the greater of two {@code double} values. That + * is, the result is the argument closer to positive infinity. If + * the arguments have the same value, the result is that same + * value. If either value is NaN, then the result is NaN. Unlike + * the numerical comparison operators, this method considers + * negative zero to be strictly smaller than positive zero. If one + * argument is positive zero and the other negative zero, the + * result is positive zero. + * + * @param a an argument. + * @param b another argument. + * @return the larger of {@code a} and {@code b}. + */ + public static double max(double a, double b) { + if (a != a) + return a; // a is NaN + if ((a == 0.0d) && + (b == 0.0d) && + (Double.doubleToRawLongBits(a) == negativeZeroDoubleBits)) { + // Raw conversion ok since NaN can't map to -0.0. + return b; + } + return (a >= b) ? a : b; + } + + /** + * Returns the smaller of two {@code int} values. That is, + * the result the argument closer to the value of + * {@link Integer#MIN_VALUE}. If the arguments have the same + * value, the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the smaller of {@code a} and {@code b}. + */ + public static int min(int a, int b) { + return (a <= b) ? a : b; + } + + /** + * Returns the smaller of two {@code long} values. That is, + * the result is the argument closer to the value of + * {@link Long#MIN_VALUE}. If the arguments have the same + * value, the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the smaller of {@code a} and {@code b}. + */ + public static long min(long a, long b) { + return (a <= b) ? a : b; + } + + /** + * Returns the smaller of two {@code float} values. That is, + * the result is the value closer to negative infinity. If the + * arguments have the same value, the result is that same + * value. If either value is NaN, then the result is NaN. Unlike + * the numerical comparison operators, this method considers + * negative zero to be strictly smaller than positive zero. If + * one argument is positive zero and the other is negative zero, + * the result is negative zero. + * + * @param a an argument. + * @param b another argument. + * @return the smaller of {@code a} and {@code b.} + */ + public static float min(float a, float b) { + if (a != a) + return a; // a is NaN + if ((a == 0.0f) && + (b == 0.0f) && + (Float.floatToRawIntBits(b) == negativeZeroFloatBits)) { + // Raw conversion ok since NaN can't map to -0.0. + return b; + } + return (a <= b) ? a : b; + } + + /** + * Returns the smaller of two {@code double} values. That + * is, the result is the value closer to negative infinity. If the + * arguments have the same value, the result is that same + * value. If either value is NaN, then the result is NaN. Unlike + * the numerical comparison operators, this method considers + * negative zero to be strictly smaller than positive zero. If one + * argument is positive zero and the other is negative zero, the + * result is negative zero. + * + * @param a an argument. + * @param b another argument. + * @return the smaller of {@code a} and {@code b}. + */ + public static double min(double a, double b) { + if (a != a) + return a; // a is NaN + if ((a == 0.0d) && + (b == 0.0d) && + (Double.doubleToRawLongBits(b) == negativeZeroDoubleBits)) { + // Raw conversion ok since NaN can't map to -0.0. + return b; + } + return (a <= b) ? a : b; + } + + /** + * Returns the size of an ulp of the argument. An ulp of a + * {@code double} value is the positive distance between this + * floating-point value and the {@code double} value next + * larger in magnitude. Note that for non-NaN x, + * ulp(-x) == ulp(x). + * + *

Special Cases: + *

    + *
  • If the argument is NaN, then the result is NaN. + *
  • If the argument is positive or negative infinity, then the + * result is positive infinity. + *
  • If the argument is positive or negative zero, then the result is + * {@code Double.MIN_VALUE}. + *
  • If the argument is ±{@code Double.MAX_VALUE}, then + * the result is equal to 2971. + *
+ * + * @param d the floating-point value whose ulp is to be returned + * @return the size of an ulp of the argument + * @author Joseph D. Darcy + * @since 1.5 + */ + public static double ulp(double d) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the size of an ulp of the argument. An ulp of a + * {@code float} value is the positive distance between this + * floating-point value and the {@code float} value next + * larger in magnitude. Note that for non-NaN x, + * ulp(-x) == ulp(x). + * + *

Special Cases: + *

    + *
  • If the argument is NaN, then the result is NaN. + *
  • If the argument is positive or negative infinity, then the + * result is positive infinity. + *
  • If the argument is positive or negative zero, then the result is + * {@code Float.MIN_VALUE}. + *
  • If the argument is ±{@code Float.MAX_VALUE}, then + * the result is equal to 2104. + *
+ * + * @param f the floating-point value whose ulp is to be returned + * @return the size of an ulp of the argument + * @author Joseph D. Darcy + * @since 1.5 + */ + public static float ulp(float f) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the signum function of the argument; zero if the argument + * is zero, 1.0 if the argument is greater than zero, -1.0 if the + * argument is less than zero. + * + *

Special Cases: + *

    + *
  • If the argument is NaN, then the result is NaN. + *
  • If the argument is positive zero or negative zero, then the + * result is the same as the argument. + *
+ * + * @param d the floating-point value whose signum is to be returned + * @return the signum function of the argument + * @author Joseph D. Darcy + * @since 1.5 + */ + public static double signum(double d) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the signum function of the argument; zero if the argument + * is zero, 1.0f if the argument is greater than zero, -1.0f if the + * argument is less than zero. + * + *

Special Cases: + *

    + *
  • If the argument is NaN, then the result is NaN. + *
  • If the argument is positive zero or negative zero, then the + * result is the same as the argument. + *
+ * + * @param f the floating-point value whose signum is to be returned + * @return the signum function of the argument + * @author Joseph D. Darcy + * @since 1.5 + */ + public static float signum(float f) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the hyperbolic sine of a {@code double} value. + * The hyperbolic sine of x is defined to be + * (ex - e-x)/2 + * where e is {@linkplain Math#E Euler's number}. + * + *

Special cases: + *

    + * + *
  • If the argument is NaN, then the result is NaN. + * + *
  • If the argument is infinite, then the result is an infinity + * with the same sign as the argument. + * + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument. + * + *
+ * + * @param x The number whose hyperbolic sine is to be returned. + * @return The hyperbolic sine of {@code x}. + * @since 1.5 + */ + public static native double sinh(double x); + + /** + * Returns the hyperbolic cosine of a {@code double} value. + * The hyperbolic cosine of x is defined to be + * (ex + e-x)/2 + * where e is {@linkplain Math#E Euler's number}. + * + *

Special cases: + *

    + * + *
  • If the argument is NaN, then the result is NaN. + * + *
  • If the argument is infinite, then the result is positive + * infinity. + * + *
  • If the argument is zero, then the result is {@code 1.0}. + * + *
+ * + * @param x The number whose hyperbolic cosine is to be returned. + * @return The hyperbolic cosine of {@code x}. + * @since 1.5 + */ + public static native double cosh(double x); + + /** + * Returns the hyperbolic tangent of a {@code double} value. + * The hyperbolic tangent of x is defined to be + * (ex - e-x)/(ex + e-x), + * in other words, {@linkplain Math#sinh + * sinh(x)}/{@linkplain Math#cosh cosh(x)}. Note + * that the absolute value of the exact tanh is always less than + * 1. + * + *

Special cases: + *

    + * + *
  • If the argument is NaN, then the result is NaN. + * + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument. + * + *
  • If the argument is positive infinity, then the result is + * {@code +1.0}. + * + *
  • If the argument is negative infinity, then the result is + * {@code -1.0}. + * + *
+ * + * @param x The number whose hyperbolic tangent is to be returned. + * @return The hyperbolic tangent of {@code x}. + * @since 1.5 + */ + public static native double tanh(double x); + + /** + * Returns sqrt(x2 +y2) + * without intermediate overflow or underflow. + * + *

Special cases: + *

    + * + *
  • If either argument is infinite, then the result + * is positive infinity. + * + *
  • If either argument is NaN and neither argument is infinite, + * then the result is NaN. + * + *
+ * + * @param x a value + * @param y a value + * @return sqrt(x2 +y2) + * without intermediate overflow or underflow + * @since 1.5 + */ + public static native double hypot(double x, double y); + + /** + * Returns ex -1. Note that for values of + * x near 0, the exact sum of + * {@code expm1(x)} + 1 is much closer to the true + * result of ex than {@code exp(x)}. + * + *

Special cases: + *

    + *
  • If the argument is NaN, the result is NaN. + * + *
  • If the argument is positive infinity, then the result is + * positive infinity. + * + *
  • If the argument is negative infinity, then the result is + * -1.0. + * + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument. + * + *
+ * + * @param x the exponent to raise e to in the computation of + * e{@code x} -1. + * @return the value e{@code x} - 1. + * @since 1.5 + */ + public static native double expm1(double x); + + /** + * Returns the natural logarithm of the sum of the argument and 1. + * Note that for small values {@code x}, the result of + * {@code log1p(x)} is much closer to the true result of ln(1 + * + {@code x}) than the floating-point evaluation of + * {@code log(1.0+x)}. + * + *

Special cases: + *

    + * + *
  • If the argument is NaN or less than -1, then the result is + * NaN. + * + *
  • If the argument is positive infinity, then the result is + * positive infinity. + * + *
  • If the argument is negative one, then the result is + * negative infinity. + * + *
  • If the argument is zero, then the result is a zero with the + * same sign as the argument. + * + *
+ * + * @param x a value + * @return the value ln({@code x} + 1), the natural + * log of {@code x} + 1 + * @since 1.5 + */ + public static native double log1p(double x); + + /** + * Returns the first floating-point argument with the sign of the + * second floating-point argument. For this method, a NaN + * {@code sign} argument is always treated as if it were + * positive. + * + * @param magnitude the parameter providing the magnitude of the result + * @param sign the parameter providing the sign of the result + * @return a value with the magnitude of {@code magnitude} + * and the sign of {@code sign}. + * @since 1.6 + */ + public static double copySign(double magnitude, double sign) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the first floating-point argument with the sign of the + * second floating-point argument. For this method, a NaN + * {@code sign} argument is always treated as if it were + * positive. + * + * @param magnitude the parameter providing the magnitude of the result + * @param sign the parameter providing the sign of the result + * @return a value with the magnitude of {@code magnitude} + * and the sign of {@code sign}. + * @since 1.6 + */ + public static float copySign(float magnitude, float sign) { + throw new UnsupportedOperationException(); + } + /** + * Returns the unbiased exponent used in the representation of a + * {@code float}. Special cases: + * + *
    + *
  • If the argument is NaN or infinite, then the result is + * {@link Float#MAX_EXPONENT} + 1. + *
  • If the argument is zero or subnormal, then the result is + * {@link Float#MIN_EXPONENT} -1. + *
+ * @param f a {@code float} value + * @since 1.6 + */ + public static int getExponent(float f) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the unbiased exponent used in the representation of a + * {@code double}. Special cases: + * + *
    + *
  • If the argument is NaN or infinite, then the result is + * {@link Double#MAX_EXPONENT} + 1. + *
  • If the argument is zero or subnormal, then the result is + * {@link Double#MIN_EXPONENT} -1. + *
+ * @param d a {@code double} value + * @since 1.6 + */ + public static int getExponent(double d) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the floating-point number adjacent to the first + * argument in the direction of the second argument. If both + * arguments compare as equal the second argument is returned. + * + *

Special cases: + *

    + *
  • If either argument is a NaN, then NaN is returned. + * + *
  • If both arguments are signed zeros, {@code direction} + * is returned unchanged (as implied by the requirement of + * returning the second argument if the arguments compare as + * equal). + * + *
  • If {@code start} is + * ±{@link Double#MIN_VALUE} and {@code direction} + * has a value such that the result should have a smaller + * magnitude, then a zero with the same sign as {@code start} + * is returned. + * + *
  • If {@code start} is infinite and + * {@code direction} has a value such that the result should + * have a smaller magnitude, {@link Double#MAX_VALUE} with the + * same sign as {@code start} is returned. + * + *
  • If {@code start} is equal to ± + * {@link Double#MAX_VALUE} and {@code direction} has a + * value such that the result should have a larger magnitude, an + * infinity with same sign as {@code start} is returned. + *
+ * + * @param start starting floating-point value + * @param direction value indicating which of + * {@code start}'s neighbors or {@code start} should + * be returned + * @return The floating-point number adjacent to {@code start} in the + * direction of {@code direction}. + * @since 1.6 + */ + public static double nextAfter(double start, double direction) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the floating-point number adjacent to the first + * argument in the direction of the second argument. If both + * arguments compare as equal a value equivalent to the second argument + * is returned. + * + *

Special cases: + *

    + *
  • If either argument is a NaN, then NaN is returned. + * + *
  • If both arguments are signed zeros, a value equivalent + * to {@code direction} is returned. + * + *
  • If {@code start} is + * ±{@link Float#MIN_VALUE} and {@code direction} + * has a value such that the result should have a smaller + * magnitude, then a zero with the same sign as {@code start} + * is returned. + * + *
  • If {@code start} is infinite and + * {@code direction} has a value such that the result should + * have a smaller magnitude, {@link Float#MAX_VALUE} with the + * same sign as {@code start} is returned. + * + *
  • If {@code start} is equal to ± + * {@link Float#MAX_VALUE} and {@code direction} has a + * value such that the result should have a larger magnitude, an + * infinity with same sign as {@code start} is returned. + *
+ * + * @param start starting floating-point value + * @param direction value indicating which of + * {@code start}'s neighbors or {@code start} should + * be returned + * @return The floating-point number adjacent to {@code start} in the + * direction of {@code direction}. + * @since 1.6 + */ + public static float nextAfter(float start, double direction) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the floating-point value adjacent to {@code d} in + * the direction of positive infinity. This method is + * semantically equivalent to {@code nextAfter(d, + * Double.POSITIVE_INFINITY)}; however, a {@code nextUp} + * implementation may run faster than its equivalent + * {@code nextAfter} call. + * + *

Special Cases: + *

    + *
  • If the argument is NaN, the result is NaN. + * + *
  • If the argument is positive infinity, the result is + * positive infinity. + * + *
  • If the argument is zero, the result is + * {@link Double#MIN_VALUE} + * + *
+ * + * @param d starting floating-point value + * @return The adjacent floating-point value closer to positive + * infinity. + * @since 1.6 + */ + public static double nextUp(double d) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the floating-point value adjacent to {@code f} in + * the direction of positive infinity. This method is + * semantically equivalent to {@code nextAfter(f, + * Float.POSITIVE_INFINITY)}; however, a {@code nextUp} + * implementation may run faster than its equivalent + * {@code nextAfter} call. + * + *

Special Cases: + *

    + *
  • If the argument is NaN, the result is NaN. + * + *
  • If the argument is positive infinity, the result is + * positive infinity. + * + *
  • If the argument is zero, the result is + * {@link Float#MIN_VALUE} + * + *
+ * + * @param f starting floating-point value + * @return The adjacent floating-point value closer to positive + * infinity. + * @since 1.6 + */ + public static float nextUp(float f) { + throw new UnsupportedOperationException(); + } + + + /** + * Return {@code d} × + * 2{@code scaleFactor} rounded as if performed + * by a single correctly rounded floating-point multiply to a + * member of the double value set. See the Java + * Language Specification for a discussion of floating-point + * value sets. If the exponent of the result is between {@link + * Double#MIN_EXPONENT} and {@link Double#MAX_EXPONENT}, the + * answer is calculated exactly. If the exponent of the result + * would be larger than {@code Double.MAX_EXPONENT}, an + * infinity is returned. Note that if the result is subnormal, + * precision may be lost; that is, when {@code scalb(x, n)} + * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal + * x. When the result is non-NaN, the result has the same + * sign as {@code d}. + * + *

Special cases: + *

    + *
  • If the first argument is NaN, NaN is returned. + *
  • If the first argument is infinite, then an infinity of the + * same sign is returned. + *
  • If the first argument is zero, then a zero of the same + * sign is returned. + *
+ * + * @param d number to be scaled by a power of two. + * @param scaleFactor power of 2 used to scale {@code d} + * @return {@code d} × 2{@code scaleFactor} + * @since 1.6 + */ + public static double scalb(double d, int scaleFactor) { + throw new UnsupportedOperationException(); + } + + /** + * Return {@code f} × + * 2{@code scaleFactor} rounded as if performed + * by a single correctly rounded floating-point multiply to a + * member of the float value set. See the Java + * Language Specification for a discussion of floating-point + * value sets. If the exponent of the result is between {@link + * Float#MIN_EXPONENT} and {@link Float#MAX_EXPONENT}, the + * answer is calculated exactly. If the exponent of the result + * would be larger than {@code Float.MAX_EXPONENT}, an + * infinity is returned. Note that if the result is subnormal, + * precision may be lost; that is, when {@code scalb(x, n)} + * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal + * x. When the result is non-NaN, the result has the same + * sign as {@code f}. + * + *

Special cases: + *

    + *
  • If the first argument is NaN, NaN is returned. + *
  • If the first argument is infinite, then an infinity of the + * same sign is returned. + *
  • If the first argument is zero, then a zero of the same + * sign is returned. + *
+ * + * @param f number to be scaled by a power of two. + * @param scaleFactor power of 2 used to scale {@code f} + * @return {@code f} × 2{@code scaleFactor} + * @since 1.6 + */ + public static float scalb(float f, int scaleFactor) { + throw new UnsupportedOperationException(); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/String.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/String.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,3065 @@ +/* + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +import org.apidesign.bck2brwsr.core.ExtraJavaScript; +import java.util.Comparator; + +/** + * The String class represents character strings. All + * string literals in Java programs, such as "abc", are + * implemented as instances of this class. + *

+ * Strings are constant; their values cannot be changed after they + * are created. String buffers support mutable strings. + * Because String objects are immutable they can be shared. For example: + *

+ *     String str = "abc";
+ * 

+ * is equivalent to: + *

+ *     char data[] = {'a', 'b', 'c'};
+ *     String str = new String(data);
+ * 

+ * Here are some more examples of how strings can be used: + *

+ *     System.out.println("abc");
+ *     String cde = "cde";
+ *     System.out.println("abc" + cde);
+ *     String c = "abc".substring(2,3);
+ *     String d = cde.substring(1, 2);
+ * 
+ *

+ * The class String includes methods for examining + * individual characters of the sequence, for comparing strings, for + * searching strings, for extracting substrings, and for creating a + * copy of a string with all characters translated to uppercase or to + * lowercase. Case mapping is based on the Unicode Standard version + * specified by the {@link java.lang.Character Character} class. + *

+ * The Java language provides special support for the string + * concatenation operator ( + ), and for conversion of + * other objects to strings. String concatenation is implemented + * through the StringBuilder(or StringBuffer) + * class and its append method. + * String conversions are implemented through the method + * toString, defined by Object and + * inherited by all classes in Java. For additional information on + * string concatenation and conversion, see Gosling, Joy, and Steele, + * The Java Language Specification. + * + *

Unless otherwise noted, passing a null argument to a constructor + * or method in this class will cause a {@link NullPointerException} to be + * thrown. + * + *

A String represents a string in the UTF-16 format + * in which supplementary characters are represented by surrogate + * pairs (see the section Unicode + * Character Representations in the Character class for + * more information). + * Index values refer to char code units, so a supplementary + * character uses two positions in a String. + *

The String class provides methods for dealing with + * Unicode code points (i.e., characters), in addition to those for + * dealing with Unicode code units (i.e., char values). + * + * @author Lee Boynton + * @author Arthur van Hoff + * @author Martin Buchholz + * @author Ulf Zibis + * @see java.lang.Object#toString() + * @see java.lang.StringBuffer + * @see java.lang.StringBuilder + * @see java.nio.charset.Charset + * @since JDK1.0 + */ + +@ExtraJavaScript( + resource="/org/apidesign/vm4brwsr/emul/java_lang_String.js", + processByteCode=false +) +public final class String + implements java.io.Serializable, Comparable, CharSequence +{ + /** The value is used for character storage. */ + private final char value[]; + + /** The offset is the first index of the storage that is used. */ + private final int offset; + + /** The count is the number of characters in the String. */ + private final int count; + + /** Cache the hash code for the string */ + private int hash; // Default to 0 + + /** use serialVersionUID from JDK 1.0.2 for interoperability */ + private static final long serialVersionUID = -6849794470754667710L; + + /** + * Class String is special cased within the Serialization Stream Protocol. + * + * A String instance is written initially into an ObjectOutputStream in the + * following format: + *

+     *      TC_STRING (utf String)
+     * 
+ * The String is written by method DataOutput.writeUTF. + * A new handle is generated to refer to all future references to the + * string instance within the stream. + */ +// private static final ObjectStreamField[] serialPersistentFields = +// new ObjectStreamField[0]; + + /** + * Initializes a newly created {@code String} object so that it represents + * an empty character sequence. Note that use of this constructor is + * unnecessary since Strings are immutable. + */ + public String() { + this.offset = 0; + this.count = 0; + this.value = new char[0]; + } + + /** + * Initializes a newly created {@code String} object so that it represents + * the same sequence of characters as the argument; in other words, the + * newly created string is a copy of the argument string. Unless an + * explicit copy of {@code original} is needed, use of this constructor is + * unnecessary since Strings are immutable. + * + * @param original + * A {@code String} + */ + public String(String original) { + int size = original.count; + char[] originalValue = original.value; + char[] v; + if (originalValue.length > size) { + // The array representing the String is bigger than the new + // String itself. Perhaps this constructor is being called + // in order to trim the baggage, so make a copy of the array. + int off = original.offset; + v = copyOfRange(originalValue, off, off+size); + } else { + // The array representing the String is the same + // size as the String, so no point in making a copy. + v = originalValue; + } + this.offset = 0; + this.count = size; + this.value = v; + } + + /** + * Allocates a new {@code String} so that it represents the sequence of + * characters currently contained in the character array argument. The + * contents of the character array are copied; subsequent modification of + * the character array does not affect the newly created string. + * + * @param value + * The initial value of the string + */ + public String(char value[]) { + int size = value.length; + this.offset = 0; + this.count = size; + this.value = copyOf(value, size); + } + + /** + * Allocates a new {@code String} that contains characters from a subarray + * of the character array argument. The {@code offset} argument is the + * index of the first character of the subarray and the {@code count} + * argument specifies the length of the subarray. The contents of the + * subarray are copied; subsequent modification of the character array does + * not affect the newly created string. + * + * @param value + * Array that is the source of characters + * + * @param offset + * The initial offset + * + * @param count + * The length + * + * @throws IndexOutOfBoundsException + * If the {@code offset} and {@code count} arguments index + * characters outside the bounds of the {@code value} array + */ + public String(char value[], int offset, int count) { + if (offset < 0) { + throw new StringIndexOutOfBoundsException(offset); + } + if (count < 0) { + throw new StringIndexOutOfBoundsException(count); + } + // Note: offset or count might be near -1>>>1. + if (offset > value.length - count) { + throw new StringIndexOutOfBoundsException(offset + count); + } + this.offset = 0; + this.count = count; + this.value = copyOfRange(value, offset, offset+count); + } + + /** + * Allocates a new {@code String} that contains characters from a subarray + * of the Unicode code point array + * argument. The {@code offset} argument is the index of the first code + * point of the subarray and the {@code count} argument specifies the + * length of the subarray. The contents of the subarray are converted to + * {@code char}s; subsequent modification of the {@code int} array does not + * affect the newly created string. + * + * @param codePoints + * Array that is the source of Unicode code points + * + * @param offset + * The initial offset + * + * @param count + * The length + * + * @throws IllegalArgumentException + * If any invalid Unicode code point is found in {@code + * codePoints} + * + * @throws IndexOutOfBoundsException + * If the {@code offset} and {@code count} arguments index + * characters outside the bounds of the {@code codePoints} array + * + * @since 1.5 + */ + public String(int[] codePoints, int offset, int count) { + if (offset < 0) { + throw new StringIndexOutOfBoundsException(offset); + } + if (count < 0) { + throw new StringIndexOutOfBoundsException(count); + } + // Note: offset or count might be near -1>>>1. + if (offset > codePoints.length - count) { + throw new StringIndexOutOfBoundsException(offset + count); + } + + final int end = offset + count; + + // Pass 1: Compute precise size of char[] + int n = count; + for (int i = offset; i < end; i++) { + int c = codePoints[i]; + if (Character.isBmpCodePoint(c)) + continue; + else if (Character.isValidCodePoint(c)) + n++; + else throw new IllegalArgumentException(Integer.toString(c)); + } + + // Pass 2: Allocate and fill in char[] + final char[] v = new char[n]; + + for (int i = offset, j = 0; i < end; i++, j++) { + int c = codePoints[i]; + if (Character.isBmpCodePoint(c)) + v[j] = (char) c; + else + Character.toSurrogates(c, v, j++); + } + + this.value = v; + this.count = n; + this.offset = 0; + } + + /** + * Allocates a new {@code String} constructed from a subarray of an array + * of 8-bit integer values. + * + *

The {@code offset} argument is the index of the first byte of the + * subarray, and the {@code count} argument specifies the length of the + * subarray. + * + *

Each {@code byte} in the subarray is converted to a {@code char} as + * specified in the method above. + * + * @deprecated This method does not properly convert bytes into characters. + * As of JDK 1.1, the preferred way to do this is via the + * {@code String} constructors that take a {@link + * java.nio.charset.Charset}, charset name, or that use the platform's + * default charset. + * + * @param ascii + * The bytes to be converted to characters + * + * @param hibyte + * The top 8 bits of each 16-bit Unicode code unit + * + * @param offset + * The initial offset + * @param count + * The length + * + * @throws IndexOutOfBoundsException + * If the {@code offset} or {@code count} argument is invalid + * + * @see #String(byte[], int) + * @see #String(byte[], int, int, java.lang.String) + * @see #String(byte[], int, int, java.nio.charset.Charset) + * @see #String(byte[], int, int) + * @see #String(byte[], java.lang.String) + * @see #String(byte[], java.nio.charset.Charset) + * @see #String(byte[]) + */ + @Deprecated + public String(byte ascii[], int hibyte, int offset, int count) { + checkBounds(ascii, offset, count); + char value[] = new char[count]; + + if (hibyte == 0) { + for (int i = count ; i-- > 0 ;) { + value[i] = (char) (ascii[i + offset] & 0xff); + } + } else { + hibyte <<= 8; + for (int i = count ; i-- > 0 ;) { + value[i] = (char) (hibyte | (ascii[i + offset] & 0xff)); + } + } + this.offset = 0; + this.count = count; + this.value = value; + } + + /** + * Allocates a new {@code String} containing characters constructed from + * an array of 8-bit integer values. Each character cin the + * resulting string is constructed from the corresponding component + * b in the byte array such that: + * + *

+     *     c == (char)(((hibyte & 0xff) << 8)
+     *                         | (b & 0xff))
+     * 
+ * + * @deprecated This method does not properly convert bytes into + * characters. As of JDK 1.1, the preferred way to do this is via the + * {@code String} constructors that take a {@link + * java.nio.charset.Charset}, charset name, or that use the platform's + * default charset. + * + * @param ascii + * The bytes to be converted to characters + * + * @param hibyte + * The top 8 bits of each 16-bit Unicode code unit + * + * @see #String(byte[], int, int, java.lang.String) + * @see #String(byte[], int, int, java.nio.charset.Charset) + * @see #String(byte[], int, int) + * @see #String(byte[], java.lang.String) + * @see #String(byte[], java.nio.charset.Charset) + * @see #String(byte[]) + */ + @Deprecated + public String(byte ascii[], int hibyte) { + this(ascii, hibyte, 0, ascii.length); + } + + /* Common private utility method used to bounds check the byte array + * and requested offset & length values used by the String(byte[],..) + * constructors. + */ + private static void checkBounds(byte[] bytes, int offset, int length) { + if (length < 0) + throw new StringIndexOutOfBoundsException(length); + if (offset < 0) + throw new StringIndexOutOfBoundsException(offset); + if (offset > bytes.length - length) + throw new StringIndexOutOfBoundsException(offset + length); + } + + /** + * Constructs a new {@code String} by decoding the specified subarray of + * bytes using the specified charset. The length of the new {@code String} + * is a function of the charset, and hence may not be equal to the length + * of the subarray. + * + *

The behavior of this constructor when the given bytes are not valid + * in the given charset is unspecified. The {@link + * java.nio.charset.CharsetDecoder} class should be used when more control + * over the decoding process is required. + * + * @param bytes + * The bytes to be decoded into characters + * + * @param offset + * The index of the first byte to decode + * + * @param length + * The number of bytes to decode + + * @param charsetName + * The name of a supported {@linkplain java.nio.charset.Charset + * charset} + * + * @throws UnsupportedEncodingException + * If the named charset is not supported + * + * @throws IndexOutOfBoundsException + * If the {@code offset} and {@code length} arguments index + * characters outside the bounds of the {@code bytes} array + * + * @since JDK1.1 + */ +// public String(byte bytes[], int offset, int length, String charsetName) +// throws UnsupportedEncodingException +// { +// if (charsetName == null) +// throw new NullPointerException("charsetName"); +// checkBounds(bytes, offset, length); +// char[] v = StringCoding.decode(charsetName, bytes, offset, length); +// this.offset = 0; +// this.count = v.length; +// this.value = v; +// } + + /** + * Constructs a new {@code String} by decoding the specified subarray of + * bytes using the specified {@linkplain java.nio.charset.Charset charset}. + * The length of the new {@code String} is a function of the charset, and + * hence may not be equal to the length of the subarray. + * + *

This method always replaces malformed-input and unmappable-character + * sequences with this charset's default replacement string. The {@link + * java.nio.charset.CharsetDecoder} class should be used when more control + * over the decoding process is required. + * + * @param bytes + * The bytes to be decoded into characters + * + * @param offset + * The index of the first byte to decode + * + * @param length + * The number of bytes to decode + * + * @param charset + * The {@linkplain java.nio.charset.Charset charset} to be used to + * decode the {@code bytes} + * + * @throws IndexOutOfBoundsException + * If the {@code offset} and {@code length} arguments index + * characters outside the bounds of the {@code bytes} array + * + * @since 1.6 + */ + /* don't want dependnecy on Charset + public String(byte bytes[], int offset, int length, Charset charset) { + if (charset == null) + throw new NullPointerException("charset"); + checkBounds(bytes, offset, length); + char[] v = StringCoding.decode(charset, bytes, offset, length); + this.offset = 0; + this.count = v.length; + this.value = v; + } + */ + + /** + * Constructs a new {@code String} by decoding the specified array of bytes + * using the specified {@linkplain java.nio.charset.Charset charset}. The + * length of the new {@code String} is a function of the charset, and hence + * may not be equal to the length of the byte array. + * + *

The behavior of this constructor when the given bytes are not valid + * in the given charset is unspecified. The {@link + * java.nio.charset.CharsetDecoder} class should be used when more control + * over the decoding process is required. + * + * @param bytes + * The bytes to be decoded into characters + * + * @param charsetName + * The name of a supported {@linkplain java.nio.charset.Charset + * charset} + * + * @throws UnsupportedEncodingException + * If the named charset is not supported + * + * @since JDK1.1 + */ +// public String(byte bytes[], String charsetName) +// throws UnsupportedEncodingException +// { +// this(bytes, 0, bytes.length, charsetName); +// } + + /** + * Constructs a new {@code String} by decoding the specified array of + * bytes using the specified {@linkplain java.nio.charset.Charset charset}. + * The length of the new {@code String} is a function of the charset, and + * hence may not be equal to the length of the byte array. + * + *

This method always replaces malformed-input and unmappable-character + * sequences with this charset's default replacement string. The {@link + * java.nio.charset.CharsetDecoder} class should be used when more control + * over the decoding process is required. + * + * @param bytes + * The bytes to be decoded into characters + * + * @param charset + * The {@linkplain java.nio.charset.Charset charset} to be used to + * decode the {@code bytes} + * + * @since 1.6 + */ + /* don't want dep on Charset + public String(byte bytes[], Charset charset) { + this(bytes, 0, bytes.length, charset); + } + */ + + /** + * Constructs a new {@code String} by decoding the specified subarray of + * bytes using the platform's default charset. The length of the new + * {@code String} is a function of the charset, and hence may not be equal + * to the length of the subarray. + * + *

The behavior of this constructor when the given bytes are not valid + * in the default charset is unspecified. The {@link + * java.nio.charset.CharsetDecoder} class should be used when more control + * over the decoding process is required. + * + * @param bytes + * The bytes to be decoded into characters + * + * @param offset + * The index of the first byte to decode + * + * @param length + * The number of bytes to decode + * + * @throws IndexOutOfBoundsException + * If the {@code offset} and the {@code length} arguments index + * characters outside the bounds of the {@code bytes} array + * + * @since JDK1.1 + */ + public String(byte bytes[], int offset, int length) { + checkBounds(bytes, offset, length); + char[] v = new char[length]; + for (int i = 0; i < length; i++) { + v[i] = (char)bytes[offset++]; + } + this.offset = 0; + this.count = v.length; + this.value = v; + } + + /** + * Constructs a new {@code String} by decoding the specified array of bytes + * using the platform's default charset. The length of the new {@code + * String} is a function of the charset, and hence may not be equal to the + * length of the byte array. + * + *

The behavior of this constructor when the given bytes are not valid + * in the default charset is unspecified. The {@link + * java.nio.charset.CharsetDecoder} class should be used when more control + * over the decoding process is required. + * + * @param bytes + * The bytes to be decoded into characters + * + * @since JDK1.1 + */ + public String(byte bytes[]) { + this(bytes, 0, bytes.length); + } + + /** + * Allocates a new string that contains the sequence of characters + * currently contained in the string buffer argument. The contents of the + * string buffer are copied; subsequent modification of the string buffer + * does not affect the newly created string. + * + * @param buffer + * A {@code StringBuffer} + */ + public String(StringBuffer buffer) { + String result = buffer.toString(); + this.value = result.value; + this.count = result.count; + this.offset = result.offset; + } + + /** + * Allocates a new string that contains the sequence of characters + * currently contained in the string builder argument. The contents of the + * string builder are copied; subsequent modification of the string builder + * does not affect the newly created string. + * + *

This constructor is provided to ease migration to {@code + * StringBuilder}. Obtaining a string from a string builder via the {@code + * toString} method is likely to run faster and is generally preferred. + * + * @param builder + * A {@code StringBuilder} + * + * @since 1.5 + */ + public String(StringBuilder builder) { + String result = builder.toString(); + this.value = result.value; + this.count = result.count; + this.offset = result.offset; + } + + + // Package private constructor which shares value array for speed. + String(int offset, int count, char value[]) { + this.value = value; + this.offset = offset; + this.count = count; + } + + /** + * Returns the length of this string. + * The length is equal to the number of Unicode + * code units in the string. + * + * @return the length of the sequence of characters represented by this + * object. + */ + public int length() { + return count; + } + + /** + * Returns true if, and only if, {@link #length()} is 0. + * + * @return true if {@link #length()} is 0, otherwise + * false + * + * @since 1.6 + */ + public boolean isEmpty() { + return count == 0; + } + + /** + * Returns the char value at the + * specified index. An index ranges from 0 to + * length() - 1. The first char value of the sequence + * is at index 0, the next at index 1, + * and so on, as for array indexing. + * + *

If the char value specified by the index is a + * surrogate, the surrogate + * value is returned. + * + * @param index the index of the char value. + * @return the char value at the specified index of this string. + * The first char value is at index 0. + * @exception IndexOutOfBoundsException if the index + * argument is negative or not less than the length of this + * string. + */ + public char charAt(int index) { + if ((index < 0) || (index >= count)) { + throw new StringIndexOutOfBoundsException(index); + } + return value[index + offset]; + } + + /** + * Returns the character (Unicode code point) at the specified + * index. The index refers to char values + * (Unicode code units) and ranges from 0 to + * {@link #length()} - 1. + * + *

If the char value specified at the given index + * is in the high-surrogate range, the following index is less + * than the length of this String, and the + * char value at the following index is in the + * low-surrogate range, then the supplementary code point + * corresponding to this surrogate pair is returned. Otherwise, + * the char value at the given index is returned. + * + * @param index the index to the char values + * @return the code point value of the character at the + * index + * @exception IndexOutOfBoundsException if the index + * argument is negative or not less than the length of this + * string. + * @since 1.5 + */ + public int codePointAt(int index) { + if ((index < 0) || (index >= count)) { + throw new StringIndexOutOfBoundsException(index); + } + return Character.codePointAtImpl(value, offset + index, offset + count); + } + + /** + * Returns the character (Unicode code point) before the specified + * index. The index refers to char values + * (Unicode code units) and ranges from 1 to {@link + * CharSequence#length() length}. + * + *

If the char value at (index - 1) + * is in the low-surrogate range, (index - 2) is not + * negative, and the char value at (index - + * 2) is in the high-surrogate range, then the + * supplementary code point value of the surrogate pair is + * returned. If the char value at index - + * 1 is an unpaired low-surrogate or a high-surrogate, the + * surrogate value is returned. + * + * @param index the index following the code point that should be returned + * @return the Unicode code point value before the given index. + * @exception IndexOutOfBoundsException if the index + * argument is less than 1 or greater than the length + * of this string. + * @since 1.5 + */ + public int codePointBefore(int index) { + int i = index - 1; + if ((i < 0) || (i >= count)) { + throw new StringIndexOutOfBoundsException(index); + } + return Character.codePointBeforeImpl(value, offset + index, offset); + } + + /** + * Returns the number of Unicode code points in the specified text + * range of this String. The text range begins at the + * specified beginIndex and extends to the + * char at index endIndex - 1. Thus the + * length (in chars) of the text range is + * endIndex-beginIndex. Unpaired surrogates within + * the text range count as one code point each. + * + * @param beginIndex the index to the first char of + * the text range. + * @param endIndex the index after the last char of + * the text range. + * @return the number of Unicode code points in the specified text + * range + * @exception IndexOutOfBoundsException if the + * beginIndex is negative, or endIndex + * is larger than the length of this String, or + * beginIndex is larger than endIndex. + * @since 1.5 + */ + public int codePointCount(int beginIndex, int endIndex) { + if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) { + throw new IndexOutOfBoundsException(); + } + return Character.codePointCountImpl(value, offset+beginIndex, endIndex-beginIndex); + } + + /** + * Returns the index within this String that is + * offset from the given index by + * codePointOffset code points. Unpaired surrogates + * within the text range given by index and + * codePointOffset count as one code point each. + * + * @param index the index to be offset + * @param codePointOffset the offset in code points + * @return the index within this String + * @exception IndexOutOfBoundsException if index + * is negative or larger then the length of this + * String, or if codePointOffset is positive + * and the substring starting with index has fewer + * than codePointOffset code points, + * or if codePointOffset is negative and the substring + * before index has fewer than the absolute value + * of codePointOffset code points. + * @since 1.5 + */ + public int offsetByCodePoints(int index, int codePointOffset) { + if (index < 0 || index > count) { + throw new IndexOutOfBoundsException(); + } + return Character.offsetByCodePointsImpl(value, offset, count, + offset+index, codePointOffset) - offset; + } + + /** + * Copy characters from this string into dst starting at dstBegin. + * This method doesn't perform any range checking. + */ + void getChars(char dst[], int dstBegin) { + arraycopy(value, offset, dst, dstBegin, count); + } + + /** + * Copies characters from this string into the destination character + * array. + *

+ * The first character to be copied is at index srcBegin; + * the last character to be copied is at index srcEnd-1 + * (thus the total number of characters to be copied is + * srcEnd-srcBegin). The characters are copied into the + * subarray of dst starting at index dstBegin + * and ending at index: + *

+     *     dstbegin + (srcEnd-srcBegin) - 1
+     * 
+ * + * @param srcBegin index of the first character in the string + * to copy. + * @param srcEnd index after the last character in the string + * to copy. + * @param dst the destination array. + * @param dstBegin the start offset in the destination array. + * @exception IndexOutOfBoundsException If any of the following + * is true: + *
  • srcBegin is negative. + *
  • srcBegin is greater than srcEnd + *
  • srcEnd is greater than the length of this + * string + *
  • dstBegin is negative + *
  • dstBegin+(srcEnd-srcBegin) is larger than + * dst.length
+ */ + public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) { + if (srcBegin < 0) { + throw new StringIndexOutOfBoundsException(srcBegin); + } + if (srcEnd > count) { + throw new StringIndexOutOfBoundsException(srcEnd); + } + if (srcBegin > srcEnd) { + throw new StringIndexOutOfBoundsException(srcEnd - srcBegin); + } + arraycopy(value, offset + srcBegin, dst, dstBegin, + srcEnd - srcBegin); + } + + /** + * Copies characters from this string into the destination byte array. Each + * byte receives the 8 low-order bits of the corresponding character. The + * eight high-order bits of each character are not copied and do not + * participate in the transfer in any way. + * + *

The first character to be copied is at index {@code srcBegin}; the + * last character to be copied is at index {@code srcEnd-1}. The total + * number of characters to be copied is {@code srcEnd-srcBegin}. The + * characters, converted to bytes, are copied into the subarray of {@code + * dst} starting at index {@code dstBegin} and ending at index: + * + *

+     *     dstbegin + (srcEnd-srcBegin) - 1
+     * 
+ * + * @deprecated This method does not properly convert characters into + * bytes. As of JDK 1.1, the preferred way to do this is via the + * {@link #getBytes()} method, which uses the platform's default charset. + * + * @param srcBegin + * Index of the first character in the string to copy + * + * @param srcEnd + * Index after the last character in the string to copy + * + * @param dst + * The destination array + * + * @param dstBegin + * The start offset in the destination array + * + * @throws IndexOutOfBoundsException + * If any of the following is true: + *
    + *
  • {@code srcBegin} is negative + *
  • {@code srcBegin} is greater than {@code srcEnd} + *
  • {@code srcEnd} is greater than the length of this String + *
  • {@code dstBegin} is negative + *
  • {@code dstBegin+(srcEnd-srcBegin)} is larger than {@code + * dst.length} + *
+ */ + @Deprecated + public void getBytes(int srcBegin, int srcEnd, byte dst[], int dstBegin) { + if (srcBegin < 0) { + throw new StringIndexOutOfBoundsException(srcBegin); + } + if (srcEnd > count) { + throw new StringIndexOutOfBoundsException(srcEnd); + } + if (srcBegin > srcEnd) { + throw new StringIndexOutOfBoundsException(srcEnd - srcBegin); + } + int j = dstBegin; + int n = offset + srcEnd; + int i = offset + srcBegin; + char[] val = value; /* avoid getfield opcode */ + + while (i < n) { + dst[j++] = (byte)val[i++]; + } + } + + /** + * Encodes this {@code String} into a sequence of bytes using the named + * charset, storing the result into a new byte array. + * + *

The behavior of this method when this string cannot be encoded in + * the given charset is unspecified. The {@link + * java.nio.charset.CharsetEncoder} class should be used when more control + * over the encoding process is required. + * + * @param charsetName + * The name of a supported {@linkplain java.nio.charset.Charset + * charset} + * + * @return The resultant byte array + * + * @throws UnsupportedEncodingException + * If the named charset is not supported + * + * @since JDK1.1 + */ +// public byte[] getBytes(String charsetName) +// throws UnsupportedEncodingException +// { +// if (charsetName == null) throw new NullPointerException(); +// return StringCoding.encode(charsetName, value, offset, count); +// } + + /** + * Encodes this {@code String} into a sequence of bytes using the given + * {@linkplain java.nio.charset.Charset charset}, storing the result into a + * new byte array. + * + *

This method always replaces malformed-input and unmappable-character + * sequences with this charset's default replacement byte array. The + * {@link java.nio.charset.CharsetEncoder} class should be used when more + * control over the encoding process is required. + * + * @param charset + * The {@linkplain java.nio.charset.Charset} to be used to encode + * the {@code String} + * + * @return The resultant byte array + * + * @since 1.6 + */ + /* don't want dep on Charset + public byte[] getBytes(Charset charset) { + if (charset == null) throw new NullPointerException(); + return StringCoding.encode(charset, value, offset, count); + } + */ + + /** + * Encodes this {@code String} into a sequence of bytes using the + * platform's default charset, storing the result into a new byte array. + * + *

The behavior of this method when this string cannot be encoded in + * the default charset is unspecified. The {@link + * java.nio.charset.CharsetEncoder} class should be used when more control + * over the encoding process is required. + * + * @return The resultant byte array + * + * @since JDK1.1 + */ + public byte[] getBytes() { + byte[] arr = new byte[length()]; + for (int i = 0; i < arr.length; i++) { + final char v = charAt(i); + arr[i] = (byte)v; + } + return arr; + } + + /** + * Compares this string to the specified object. The result is {@code + * true} if and only if the argument is not {@code null} and is a {@code + * String} object that represents the same sequence of characters as this + * object. + * + * @param anObject + * The object to compare this {@code String} against + * + * @return {@code true} if the given object represents a {@code String} + * equivalent to this string, {@code false} otherwise + * + * @see #compareTo(String) + * @see #equalsIgnoreCase(String) + */ + public boolean equals(Object anObject) { + if (this == anObject) { + return true; + } + if (anObject instanceof String) { + String anotherString = (String)anObject; + int n = count; + if (n == anotherString.count) { + char v1[] = value; + char v2[] = anotherString.value; + int i = offset; + int j = anotherString.offset; + while (n-- != 0) { + if (v1[i++] != v2[j++]) + return false; + } + return true; + } + } + return false; + } + + /** + * Compares this string to the specified {@code StringBuffer}. The result + * is {@code true} if and only if this {@code String} represents the same + * sequence of characters as the specified {@code StringBuffer}. + * + * @param sb + * The {@code StringBuffer} to compare this {@code String} against + * + * @return {@code true} if this {@code String} represents the same + * sequence of characters as the specified {@code StringBuffer}, + * {@code false} otherwise + * + * @since 1.4 + */ + public boolean contentEquals(StringBuffer sb) { + synchronized(sb) { + return contentEquals((CharSequence)sb); + } + } + + /** + * Compares this string to the specified {@code CharSequence}. The result + * is {@code true} if and only if this {@code String} represents the same + * sequence of char values as the specified sequence. + * + * @param cs + * The sequence to compare this {@code String} against + * + * @return {@code true} if this {@code String} represents the same + * sequence of char values as the specified sequence, {@code + * false} otherwise + * + * @since 1.5 + */ + public boolean contentEquals(CharSequence cs) { + if (count != cs.length()) + return false; + // Argument is a StringBuffer, StringBuilder + if (cs instanceof AbstractStringBuilder) { + char v1[] = value; + char v2[] = ((AbstractStringBuilder)cs).getValue(); + int i = offset; + int j = 0; + int n = count; + while (n-- != 0) { + if (v1[i++] != v2[j++]) + return false; + } + return true; + } + // Argument is a String + if (cs.equals(this)) + return true; + // Argument is a generic CharSequence + char v1[] = value; + int i = offset; + int j = 0; + int n = count; + while (n-- != 0) { + if (v1[i++] != cs.charAt(j++)) + return false; + } + return true; + } + + /** + * Compares this {@code String} to another {@code String}, ignoring case + * considerations. Two strings are considered equal ignoring case if they + * are of the same length and corresponding characters in the two strings + * are equal ignoring case. + * + *

Two characters {@code c1} and {@code c2} are considered the same + * ignoring case if at least one of the following is true: + *

    + *
  • The two characters are the same (as compared by the + * {@code ==} operator) + *
  • Applying the method {@link + * java.lang.Character#toUpperCase(char)} to each character + * produces the same result + *
  • Applying the method {@link + * java.lang.Character#toLowerCase(char)} to each character + * produces the same result + *
+ * + * @param anotherString + * The {@code String} to compare this {@code String} against + * + * @return {@code true} if the argument is not {@code null} and it + * represents an equivalent {@code String} ignoring case; {@code + * false} otherwise + * + * @see #equals(Object) + */ + public boolean equalsIgnoreCase(String anotherString) { + return (this == anotherString) ? true : + (anotherString != null) && (anotherString.count == count) && + regionMatches(true, 0, anotherString, 0, count); + } + + /** + * Compares two strings lexicographically. + * The comparison is based on the Unicode value of each character in + * the strings. The character sequence represented by this + * String object is compared lexicographically to the + * character sequence represented by the argument string. The result is + * a negative integer if this String object + * lexicographically precedes the argument string. The result is a + * positive integer if this String object lexicographically + * follows the argument string. The result is zero if the strings + * are equal; compareTo returns 0 exactly when + * the {@link #equals(Object)} method would return true. + *

+ * This is the definition of lexicographic ordering. If two strings are + * different, then either they have different characters at some index + * that is a valid index for both strings, or their lengths are different, + * or both. If they have different characters at one or more index + * positions, let k be the smallest such index; then the string + * whose character at position k has the smaller value, as + * determined by using the < operator, lexicographically precedes the + * other string. In this case, compareTo returns the + * difference of the two character values at position k in + * the two string -- that is, the value: + *

+     * this.charAt(k)-anotherString.charAt(k)
+     * 
+ * If there is no index position at which they differ, then the shorter + * string lexicographically precedes the longer string. In this case, + * compareTo returns the difference of the lengths of the + * strings -- that is, the value: + *
+     * this.length()-anotherString.length()
+     * 
+ * + * @param anotherString the String to be compared. + * @return the value 0 if the argument string is equal to + * this string; a value less than 0 if this string + * is lexicographically less than the string argument; and a + * value greater than 0 if this string is + * lexicographically greater than the string argument. + */ + public int compareTo(String anotherString) { + int len1 = count; + int len2 = anotherString.count; + int n = Math.min(len1, len2); + char v1[] = value; + char v2[] = anotherString.value; + int i = offset; + int j = anotherString.offset; + + if (i == j) { + int k = i; + int lim = n + i; + while (k < lim) { + char c1 = v1[k]; + char c2 = v2[k]; + if (c1 != c2) { + return c1 - c2; + } + k++; + } + } else { + while (n-- != 0) { + char c1 = v1[i++]; + char c2 = v2[j++]; + if (c1 != c2) { + return c1 - c2; + } + } + } + return len1 - len2; + } + + /** + * A Comparator that orders String objects as by + * compareToIgnoreCase. This comparator is serializable. + *

+ * Note that this Comparator does not take locale into account, + * and will result in an unsatisfactory ordering for certain locales. + * The java.text package provides Collators to allow + * locale-sensitive ordering. + * + * @see java.text.Collator#compare(String, String) + * @since 1.2 + */ + public static final Comparator CASE_INSENSITIVE_ORDER + = new CaseInsensitiveComparator(); + private static class CaseInsensitiveComparator + implements Comparator, java.io.Serializable { + // use serialVersionUID from JDK 1.2.2 for interoperability + private static final long serialVersionUID = 8575799808933029326L; + + public int compare(String s1, String s2) { + int n1 = s1.length(); + int n2 = s2.length(); + int min = Math.min(n1, n2); + for (int i = 0; i < min; i++) { + char c1 = s1.charAt(i); + char c2 = s2.charAt(i); + if (c1 != c2) { + c1 = Character.toUpperCase(c1); + c2 = Character.toUpperCase(c2); + if (c1 != c2) { + c1 = Character.toLowerCase(c1); + c2 = Character.toLowerCase(c2); + if (c1 != c2) { + // No overflow because of numeric promotion + return c1 - c2; + } + } + } + } + return n1 - n2; + } + } + + /** + * Compares two strings lexicographically, ignoring case + * differences. This method returns an integer whose sign is that of + * calling compareTo with normalized versions of the strings + * where case differences have been eliminated by calling + * Character.toLowerCase(Character.toUpperCase(character)) on + * each character. + *

+ * Note that this method does not take locale into account, + * and will result in an unsatisfactory ordering for certain locales. + * The java.text package provides collators to allow + * locale-sensitive ordering. + * + * @param str the String to be compared. + * @return a negative integer, zero, or a positive integer as the + * specified String is greater than, equal to, or less + * than this String, ignoring case considerations. + * @see java.text.Collator#compare(String, String) + * @since 1.2 + */ + public int compareToIgnoreCase(String str) { + return CASE_INSENSITIVE_ORDER.compare(this, str); + } + + /** + * Tests if two string regions are equal. + *

+ * A substring of this String object is compared to a substring + * of the argument other. The result is true if these substrings + * represent identical character sequences. The substring of this + * String object to be compared begins at index toffset + * and has length len. The substring of other to be compared + * begins at index ooffset and has length len. The + * result is false if and only if at least one of the following + * is true: + *

  • toffset is negative. + *
  • ooffset is negative. + *
  • toffset+len is greater than the length of this + * String object. + *
  • ooffset+len is greater than the length of the other + * argument. + *
  • There is some nonnegative integer k less than len + * such that: + * this.charAt(toffset+k) != other.charAt(ooffset+k) + *
+ * + * @param toffset the starting offset of the subregion in this string. + * @param other the string argument. + * @param ooffset the starting offset of the subregion in the string + * argument. + * @param len the number of characters to compare. + * @return true if the specified subregion of this string + * exactly matches the specified subregion of the string argument; + * false otherwise. + */ + public boolean regionMatches(int toffset, String other, int ooffset, + int len) { + char ta[] = value; + int to = offset + toffset; + char pa[] = other.value; + int po = other.offset + ooffset; + // Note: toffset, ooffset, or len might be near -1>>>1. + if ((ooffset < 0) || (toffset < 0) || (toffset > (long)count - len) + || (ooffset > (long)other.count - len)) { + return false; + } + while (len-- > 0) { + if (ta[to++] != pa[po++]) { + return false; + } + } + return true; + } + + /** + * Tests if two string regions are equal. + *

+ * A substring of this String object is compared to a substring + * of the argument other. The result is true if these + * substrings represent character sequences that are the same, ignoring + * case if and only if ignoreCase is true. The substring of + * this String object to be compared begins at index + * toffset and has length len. The substring of + * other to be compared begins at index ooffset and + * has length len. The result is false if and only if + * at least one of the following is true: + *

  • toffset is negative. + *
  • ooffset is negative. + *
  • toffset+len is greater than the length of this + * String object. + *
  • ooffset+len is greater than the length of the other + * argument. + *
  • ignoreCase is false and there is some nonnegative + * integer k less than len such that: + *
    +     * this.charAt(toffset+k) != other.charAt(ooffset+k)
    +     * 
    + *
  • ignoreCase is true and there is some nonnegative + * integer k less than len such that: + *
    +     * Character.toLowerCase(this.charAt(toffset+k)) !=
    +               Character.toLowerCase(other.charAt(ooffset+k))
    +     * 
    + * and: + *
    +     * Character.toUpperCase(this.charAt(toffset+k)) !=
    +     *         Character.toUpperCase(other.charAt(ooffset+k))
    +     * 
    + *
+ * + * @param ignoreCase if true, ignore case when comparing + * characters. + * @param toffset the starting offset of the subregion in this + * string. + * @param other the string argument. + * @param ooffset the starting offset of the subregion in the string + * argument. + * @param len the number of characters to compare. + * @return true if the specified subregion of this string + * matches the specified subregion of the string argument; + * false otherwise. Whether the matching is exact + * or case insensitive depends on the ignoreCase + * argument. + */ + public boolean regionMatches(boolean ignoreCase, int toffset, + String other, int ooffset, int len) { + char ta[] = value; + int to = offset + toffset; + char pa[] = other.value; + int po = other.offset + ooffset; + // Note: toffset, ooffset, or len might be near -1>>>1. + if ((ooffset < 0) || (toffset < 0) || (toffset > (long)count - len) || + (ooffset > (long)other.count - len)) { + return false; + } + while (len-- > 0) { + char c1 = ta[to++]; + char c2 = pa[po++]; + if (c1 == c2) { + continue; + } + if (ignoreCase) { + // If characters don't match but case may be ignored, + // try converting both characters to uppercase. + // If the results match, then the comparison scan should + // continue. + char u1 = Character.toUpperCase(c1); + char u2 = Character.toUpperCase(c2); + if (u1 == u2) { + continue; + } + // Unfortunately, conversion to uppercase does not work properly + // for the Georgian alphabet, which has strange rules about case + // conversion. So we need to make one last check before + // exiting. + if (Character.toLowerCase(u1) == Character.toLowerCase(u2)) { + continue; + } + } + return false; + } + return true; + } + + /** + * Tests if the substring of this string beginning at the + * specified index starts with the specified prefix. + * + * @param prefix the prefix. + * @param toffset where to begin looking in this string. + * @return true if the character sequence represented by the + * argument is a prefix of the substring of this object starting + * at index toffset; false otherwise. + * The result is false if toffset is + * negative or greater than the length of this + * String object; otherwise the result is the same + * as the result of the expression + *
+     *          this.substring(toffset).startsWith(prefix)
+     *          
+ */ + public boolean startsWith(String prefix, int toffset) { + char ta[] = value; + int to = offset + toffset; + char pa[] = prefix.value; + int po = prefix.offset; + int pc = prefix.count; + // Note: toffset might be near -1>>>1. + if ((toffset < 0) || (toffset > count - pc)) { + return false; + } + while (--pc >= 0) { + if (ta[to++] != pa[po++]) { + return false; + } + } + return true; + } + + /** + * Tests if this string starts with the specified prefix. + * + * @param prefix the prefix. + * @return true if the character sequence represented by the + * argument is a prefix of the character sequence represented by + * this string; false otherwise. + * Note also that true will be returned if the + * argument is an empty string or is equal to this + * String object as determined by the + * {@link #equals(Object)} method. + * @since 1. 0 + */ + public boolean startsWith(String prefix) { + return startsWith(prefix, 0); + } + + /** + * Tests if this string ends with the specified suffix. + * + * @param suffix the suffix. + * @return true if the character sequence represented by the + * argument is a suffix of the character sequence represented by + * this object; false otherwise. Note that the + * result will be true if the argument is the + * empty string or is equal to this String object + * as determined by the {@link #equals(Object)} method. + */ + public boolean endsWith(String suffix) { + return startsWith(suffix, count - suffix.count); + } + + /** + * Returns a hash code for this string. The hash code for a + * String object is computed as + *
+     * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
+     * 
+ * using int arithmetic, where s[i] is the + * ith character of the string, n is the length of + * the string, and ^ indicates exponentiation. + * (The hash value of the empty string is zero.) + * + * @return a hash code value for this object. + */ + public int hashCode() { + int h = hash; + if (h == 0 && count > 0) { + int off = offset; + char val[] = value; + int len = count; + + for (int i = 0; i < len; i++) { + h = 31*h + val[off++]; + } + hash = h; + } + return h; + } + + /** + * Returns the index within this string of the first occurrence of + * the specified character. If a character with value + * ch occurs in the character sequence represented by + * this String object, then the index (in Unicode + * code units) of the first such occurrence is returned. For + * values of ch in the range from 0 to 0xFFFF + * (inclusive), this is the smallest value k such that: + *
+     * this.charAt(k) == ch
+     * 
+ * is true. For other values of ch, it is the + * smallest value k such that: + *
+     * this.codePointAt(k) == ch
+     * 
+ * is true. In either case, if no such character occurs in this + * string, then -1 is returned. + * + * @param ch a character (Unicode code point). + * @return the index of the first occurrence of the character in the + * character sequence represented by this object, or + * -1 if the character does not occur. + */ + public int indexOf(int ch) { + return indexOf(ch, 0); + } + + /** + * Returns the index within this string of the first occurrence of the + * specified character, starting the search at the specified index. + *

+ * If a character with value ch occurs in the + * character sequence represented by this String + * object at an index no smaller than fromIndex, then + * the index of the first such occurrence is returned. For values + * of ch in the range from 0 to 0xFFFF (inclusive), + * this is the smallest value k such that: + *

+     * (this.charAt(k) == ch) && (k >= fromIndex)
+     * 
+ * is true. For other values of ch, it is the + * smallest value k such that: + *
+     * (this.codePointAt(k) == ch) && (k >= fromIndex)
+     * 
+ * is true. In either case, if no such character occurs in this + * string at or after position fromIndex, then + * -1 is returned. + * + *

+ * There is no restriction on the value of fromIndex. If it + * is negative, it has the same effect as if it were zero: this entire + * string may be searched. If it is greater than the length of this + * string, it has the same effect as if it were equal to the length of + * this string: -1 is returned. + * + *

All indices are specified in char values + * (Unicode code units). + * + * @param ch a character (Unicode code point). + * @param fromIndex the index to start the search from. + * @return the index of the first occurrence of the character in the + * character sequence represented by this object that is greater + * than or equal to fromIndex, or -1 + * if the character does not occur. + */ + public int indexOf(int ch, int fromIndex) { + if (fromIndex < 0) { + fromIndex = 0; + } else if (fromIndex >= count) { + // Note: fromIndex might be near -1>>>1. + return -1; + } + + if (ch < Character.MIN_SUPPLEMENTARY_CODE_POINT) { + // handle most cases here (ch is a BMP code point or a + // negative value (invalid code point)) + final char[] value = this.value; + final int offset = this.offset; + final int max = offset + count; + for (int i = offset + fromIndex; i < max ; i++) { + if (value[i] == ch) { + return i - offset; + } + } + return -1; + } else { + return indexOfSupplementary(ch, fromIndex); + } + } + + /** + * Handles (rare) calls of indexOf with a supplementary character. + */ + private int indexOfSupplementary(int ch, int fromIndex) { + if (Character.isValidCodePoint(ch)) { + final char[] value = this.value; + final int offset = this.offset; + final char hi = Character.highSurrogate(ch); + final char lo = Character.lowSurrogate(ch); + final int max = offset + count - 1; + for (int i = offset + fromIndex; i < max; i++) { + if (value[i] == hi && value[i+1] == lo) { + return i - offset; + } + } + } + return -1; + } + + /** + * Returns the index within this string of the last occurrence of + * the specified character. For values of ch in the + * range from 0 to 0xFFFF (inclusive), the index (in Unicode code + * units) returned is the largest value k such that: + *

+     * this.charAt(k) == ch
+     * 
+ * is true. For other values of ch, it is the + * largest value k such that: + *
+     * this.codePointAt(k) == ch
+     * 
+ * is true. In either case, if no such character occurs in this + * string, then -1 is returned. The + * String is searched backwards starting at the last + * character. + * + * @param ch a character (Unicode code point). + * @return the index of the last occurrence of the character in the + * character sequence represented by this object, or + * -1 if the character does not occur. + */ + public int lastIndexOf(int ch) { + return lastIndexOf(ch, count - 1); + } + + /** + * Returns the index within this string of the last occurrence of + * the specified character, searching backward starting at the + * specified index. For values of ch in the range + * from 0 to 0xFFFF (inclusive), the index returned is the largest + * value k such that: + *
+     * (this.charAt(k) == ch) && (k <= fromIndex)
+     * 
+ * is true. For other values of ch, it is the + * largest value k such that: + *
+     * (this.codePointAt(k) == ch) && (k <= fromIndex)
+     * 
+ * is true. In either case, if no such character occurs in this + * string at or before position fromIndex, then + * -1 is returned. + * + *

All indices are specified in char values + * (Unicode code units). + * + * @param ch a character (Unicode code point). + * @param fromIndex the index to start the search from. There is no + * restriction on the value of fromIndex. If it is + * greater than or equal to the length of this string, it has + * the same effect as if it were equal to one less than the + * length of this string: this entire string may be searched. + * If it is negative, it has the same effect as if it were -1: + * -1 is returned. + * @return the index of the last occurrence of the character in the + * character sequence represented by this object that is less + * than or equal to fromIndex, or -1 + * if the character does not occur before that point. + */ + public int lastIndexOf(int ch, int fromIndex) { + if (ch < Character.MIN_SUPPLEMENTARY_CODE_POINT) { + // handle most cases here (ch is a BMP code point or a + // negative value (invalid code point)) + final char[] value = this.value; + final int offset = this.offset; + int i = offset + Math.min(fromIndex, count - 1); + for (; i >= offset ; i--) { + if (value[i] == ch) { + return i - offset; + } + } + return -1; + } else { + return lastIndexOfSupplementary(ch, fromIndex); + } + } + + /** + * Handles (rare) calls of lastIndexOf with a supplementary character. + */ + private int lastIndexOfSupplementary(int ch, int fromIndex) { + if (Character.isValidCodePoint(ch)) { + final char[] value = this.value; + final int offset = this.offset; + char hi = Character.highSurrogate(ch); + char lo = Character.lowSurrogate(ch); + int i = offset + Math.min(fromIndex, count - 2); + for (; i >= offset; i--) { + if (value[i] == hi && value[i+1] == lo) { + return i - offset; + } + } + } + return -1; + } + + /** + * Returns the index within this string of the first occurrence of the + * specified substring. + * + *

The returned index is the smallest value k for which: + *

+     * this.startsWith(str, k)
+     * 
+ * If no such value of k exists, then {@code -1} is returned. + * + * @param str the substring to search for. + * @return the index of the first occurrence of the specified substring, + * or {@code -1} if there is no such occurrence. + */ + public int indexOf(String str) { + return indexOf(str, 0); + } + + /** + * Returns the index within this string of the first occurrence of the + * specified substring, starting at the specified index. + * + *

The returned index is the smallest value k for which: + *

+     * k >= fromIndex && this.startsWith(str, k)
+     * 
+ * If no such value of k exists, then {@code -1} is returned. + * + * @param str the substring to search for. + * @param fromIndex the index from which to start the search. + * @return the index of the first occurrence of the specified substring, + * starting at the specified index, + * or {@code -1} if there is no such occurrence. + */ + public int indexOf(String str, int fromIndex) { + return indexOf(value, offset, count, + str.value, str.offset, str.count, fromIndex); + } + + /** + * Code shared by String and StringBuffer to do searches. The + * source is the character array being searched, and the target + * is the string being searched for. + * + * @param source the characters being searched. + * @param sourceOffset offset of the source string. + * @param sourceCount count of the source string. + * @param target the characters being searched for. + * @param targetOffset offset of the target string. + * @param targetCount count of the target string. + * @param fromIndex the index to begin searching from. + */ + static int indexOf(char[] source, int sourceOffset, int sourceCount, + char[] target, int targetOffset, int targetCount, + int fromIndex) { + if (fromIndex >= sourceCount) { + return (targetCount == 0 ? sourceCount : -1); + } + if (fromIndex < 0) { + fromIndex = 0; + } + if (targetCount == 0) { + return fromIndex; + } + + char first = target[targetOffset]; + int max = sourceOffset + (sourceCount - targetCount); + + for (int i = sourceOffset + fromIndex; i <= max; i++) { + /* Look for first character. */ + if (source[i] != first) { + while (++i <= max && source[i] != first); + } + + /* Found first character, now look at the rest of v2 */ + if (i <= max) { + int j = i + 1; + int end = j + targetCount - 1; + for (int k = targetOffset + 1; j < end && source[j] == + target[k]; j++, k++); + + if (j == end) { + /* Found whole string. */ + return i - sourceOffset; + } + } + } + return -1; + } + + /** + * Returns the index within this string of the last occurrence of the + * specified substring. The last occurrence of the empty string "" + * is considered to occur at the index value {@code this.length()}. + * + *

The returned index is the largest value k for which: + *

+     * this.startsWith(str, k)
+     * 
+ * If no such value of k exists, then {@code -1} is returned. + * + * @param str the substring to search for. + * @return the index of the last occurrence of the specified substring, + * or {@code -1} if there is no such occurrence. + */ + public int lastIndexOf(String str) { + return lastIndexOf(str, count); + } + + /** + * Returns the index within this string of the last occurrence of the + * specified substring, searching backward starting at the specified index. + * + *

The returned index is the largest value k for which: + *

+     * k <= fromIndex && this.startsWith(str, k)
+     * 
+ * If no such value of k exists, then {@code -1} is returned. + * + * @param str the substring to search for. + * @param fromIndex the index to start the search from. + * @return the index of the last occurrence of the specified substring, + * searching backward from the specified index, + * or {@code -1} if there is no such occurrence. + */ + public int lastIndexOf(String str, int fromIndex) { + return lastIndexOf(value, offset, count, + str.value, str.offset, str.count, fromIndex); + } + + /** + * Code shared by String and StringBuffer to do searches. The + * source is the character array being searched, and the target + * is the string being searched for. + * + * @param source the characters being searched. + * @param sourceOffset offset of the source string. + * @param sourceCount count of the source string. + * @param target the characters being searched for. + * @param targetOffset offset of the target string. + * @param targetCount count of the target string. + * @param fromIndex the index to begin searching from. + */ + static int lastIndexOf(char[] source, int sourceOffset, int sourceCount, + char[] target, int targetOffset, int targetCount, + int fromIndex) { + /* + * Check arguments; return immediately where possible. For + * consistency, don't check for null str. + */ + int rightIndex = sourceCount - targetCount; + if (fromIndex < 0) { + return -1; + } + if (fromIndex > rightIndex) { + fromIndex = rightIndex; + } + /* Empty string always matches. */ + if (targetCount == 0) { + return fromIndex; + } + + int strLastIndex = targetOffset + targetCount - 1; + char strLastChar = target[strLastIndex]; + int min = sourceOffset + targetCount - 1; + int i = min + fromIndex; + + startSearchForLastChar: + while (true) { + while (i >= min && source[i] != strLastChar) { + i--; + } + if (i < min) { + return -1; + } + int j = i - 1; + int start = j - (targetCount - 1); + int k = strLastIndex - 1; + + while (j > start) { + if (source[j--] != target[k--]) { + i--; + continue startSearchForLastChar; + } + } + return start - sourceOffset + 1; + } + } + + /** + * Returns a new string that is a substring of this string. The + * substring begins with the character at the specified index and + * extends to the end of this string.

+ * Examples: + *

+     * "unhappy".substring(2) returns "happy"
+     * "Harbison".substring(3) returns "bison"
+     * "emptiness".substring(9) returns "" (an empty string)
+     * 
+ * + * @param beginIndex the beginning index, inclusive. + * @return the specified substring. + * @exception IndexOutOfBoundsException if + * beginIndex is negative or larger than the + * length of this String object. + */ + public String substring(int beginIndex) { + return substring(beginIndex, count); + } + + /** + * Returns a new string that is a substring of this string. The + * substring begins at the specified beginIndex and + * extends to the character at index endIndex - 1. + * Thus the length of the substring is endIndex-beginIndex. + *

+ * Examples: + *

+     * "hamburger".substring(4, 8) returns "urge"
+     * "smiles".substring(1, 5) returns "mile"
+     * 
+ * + * @param beginIndex the beginning index, inclusive. + * @param endIndex the ending index, exclusive. + * @return the specified substring. + * @exception IndexOutOfBoundsException if the + * beginIndex is negative, or + * endIndex is larger than the length of + * this String object, or + * beginIndex is larger than + * endIndex. + */ + public String substring(int beginIndex, int endIndex) { + if (beginIndex < 0) { + throw new StringIndexOutOfBoundsException(beginIndex); + } + if (endIndex > count) { + throw new StringIndexOutOfBoundsException(endIndex); + } + if (beginIndex > endIndex) { + throw new StringIndexOutOfBoundsException(endIndex - beginIndex); + } + return ((beginIndex == 0) && (endIndex == count)) ? this : + new String(offset + beginIndex, endIndex - beginIndex, value); + } + + /** + * Returns a new character sequence that is a subsequence of this sequence. + * + *

An invocation of this method of the form + * + *

+     * str.subSequence(begin, end)
+ * + * behaves in exactly the same way as the invocation + * + *
+     * str.substring(begin, end)
+ * + * This method is defined so that the String class can implement + * the {@link CharSequence} interface.

+ * + * @param beginIndex the begin index, inclusive. + * @param endIndex the end index, exclusive. + * @return the specified subsequence. + * + * @throws IndexOutOfBoundsException + * if beginIndex or endIndex are negative, + * if endIndex is greater than length(), + * or if beginIndex is greater than startIndex + * + * @since 1.4 + * @spec JSR-51 + */ + public CharSequence subSequence(int beginIndex, int endIndex) { + return this.substring(beginIndex, endIndex); + } + + /** + * Concatenates the specified string to the end of this string. + *

+ * If the length of the argument string is 0, then this + * String object is returned. Otherwise, a new + * String object is created, representing a character + * sequence that is the concatenation of the character sequence + * represented by this String object and the character + * sequence represented by the argument string.

+ * Examples: + *

+     * "cares".concat("s") returns "caress"
+     * "to".concat("get").concat("her") returns "together"
+     * 
+ * + * @param str the String that is concatenated to the end + * of this String. + * @return a string that represents the concatenation of this object's + * characters followed by the string argument's characters. + */ + public String concat(String str) { + int otherLen = str.length(); + if (otherLen == 0) { + return this; + } + char buf[] = new char[count + otherLen]; + getChars(0, count, buf, 0); + str.getChars(0, otherLen, buf, count); + return new String(0, count + otherLen, buf); + } + + /** + * Returns a new string resulting from replacing all occurrences of + * oldChar in this string with newChar. + *

+ * If the character oldChar does not occur in the + * character sequence represented by this String object, + * then a reference to this String object is returned. + * Otherwise, a new String object is created that + * represents a character sequence identical to the character sequence + * represented by this String object, except that every + * occurrence of oldChar is replaced by an occurrence + * of newChar. + *

+ * Examples: + *

+     * "mesquite in your cellar".replace('e', 'o')
+     *         returns "mosquito in your collar"
+     * "the war of baronets".replace('r', 'y')
+     *         returns "the way of bayonets"
+     * "sparring with a purple porpoise".replace('p', 't')
+     *         returns "starring with a turtle tortoise"
+     * "JonL".replace('q', 'x') returns "JonL" (no change)
+     * 
+ * + * @param oldChar the old character. + * @param newChar the new character. + * @return a string derived from this string by replacing every + * occurrence of oldChar with newChar. + */ + public String replace(char oldChar, char newChar) { + if (oldChar != newChar) { + int len = count; + int i = -1; + char[] val = value; /* avoid getfield opcode */ + int off = offset; /* avoid getfield opcode */ + + while (++i < len) { + if (val[off + i] == oldChar) { + break; + } + } + if (i < len) { + char buf[] = new char[len]; + for (int j = 0 ; j < i ; j++) { + buf[j] = val[off+j]; + } + while (i < len) { + char c = val[off + i]; + buf[i] = (c == oldChar) ? newChar : c; + i++; + } + return new String(0, len, buf); + } + } + return this; + } + + /** + * Tells whether or not this string matches the given regular expression. + * + *

An invocation of this method of the form + * str.matches(regex) yields exactly the + * same result as the expression + * + *

{@link java.util.regex.Pattern}.{@link + * java.util.regex.Pattern#matches(String,CharSequence) + * matches}(regex, str)
+ * + * @param regex + * the regular expression to which this string is to be matched + * + * @return true if, and only if, this string matches the + * given regular expression + * + * @throws PatternSyntaxException + * if the regular expression's syntax is invalid + * + * @see java.util.regex.Pattern + * + * @since 1.4 + * @spec JSR-51 + */ + public boolean matches(String regex) { + throw new UnsupportedOperationException(); + } + + /** + * Returns true if and only if this string contains the specified + * sequence of char values. + * + * @param s the sequence to search for + * @return true if this string contains s, false otherwise + * @throws NullPointerException if s is null + * @since 1.5 + */ + public boolean contains(CharSequence s) { + return indexOf(s.toString()) > -1; + } + + /** + * Replaces the first substring of this string that matches the given regular expression with the + * given replacement. + * + *

An invocation of this method of the form + * str.replaceFirst(regex, repl) + * yields exactly the same result as the expression + * + *

+ * {@link java.util.regex.Pattern}.{@link java.util.regex.Pattern#compile + * compile}(regex).{@link + * java.util.regex.Pattern#matcher(java.lang.CharSequence) + * matcher}(str).{@link java.util.regex.Matcher#replaceFirst + * replaceFirst}(repl)
+ * + *

+ * Note that backslashes (\) and dollar signs ($) in the + * replacement string may cause the results to be different than if it were + * being treated as a literal replacement string; see + * {@link java.util.regex.Matcher#replaceFirst}. + * Use {@link java.util.regex.Matcher#quoteReplacement} to suppress the special + * meaning of these characters, if desired. + * + * @param regex + * the regular expression to which this string is to be matched + * @param replacement + * the string to be substituted for the first match + * + * @return The resulting String + * + * @throws PatternSyntaxException + * if the regular expression's syntax is invalid + * + * @see java.util.regex.Pattern + * + * @since 1.4 + * @spec JSR-51 + */ + public String replaceFirst(String regex, String replacement) { + throw new UnsupportedOperationException(); + } + + /** + * Replaces each substring of this string that matches the given regular expression with the + * given replacement. + * + *

An invocation of this method of the form + * str.replaceAll(regex, repl) + * yields exactly the same result as the expression + * + *

+ * {@link java.util.regex.Pattern}.{@link java.util.regex.Pattern#compile + * compile}(regex).{@link + * java.util.regex.Pattern#matcher(java.lang.CharSequence) + * matcher}(str).{@link java.util.regex.Matcher#replaceAll + * replaceAll}(repl)
+ * + *

+ * Note that backslashes (\) and dollar signs ($) in the + * replacement string may cause the results to be different than if it were + * being treated as a literal replacement string; see + * {@link java.util.regex.Matcher#replaceAll Matcher.replaceAll}. + * Use {@link java.util.regex.Matcher#quoteReplacement} to suppress the special + * meaning of these characters, if desired. + * + * @param regex + * the regular expression to which this string is to be matched + * @param replacement + * the string to be substituted for each match + * + * @return The resulting String + * + * @throws PatternSyntaxException + * if the regular expression's syntax is invalid + * + * @see java.util.regex.Pattern + * + * @since 1.4 + * @spec JSR-51 + */ + public String replaceAll(String regex, String replacement) { + throw new UnsupportedOperationException(); + } + + /** + * Replaces each substring of this string that matches the literal target + * sequence with the specified literal replacement sequence. The + * replacement proceeds from the beginning of the string to the end, for + * example, replacing "aa" with "b" in the string "aaa" will result in + * "ba" rather than "ab". + * + * @param target The sequence of char values to be replaced + * @param replacement The replacement sequence of char values + * @return The resulting string + * @throws NullPointerException if target or + * replacement is null. + * @since 1.5 + */ + public String replace(CharSequence target, CharSequence replacement) { + throw new UnsupportedOperationException("This one should be supported, but without dep on rest of regexp"); + } + + /** + * Splits this string around matches of the given + * regular expression. + * + *

The array returned by this method contains each substring of this + * string that is terminated by another substring that matches the given + * expression or is terminated by the end of the string. The substrings in + * the array are in the order in which they occur in this string. If the + * expression does not match any part of the input then the resulting array + * has just one element, namely this string. + * + *

The limit parameter controls the number of times the + * pattern is applied and therefore affects the length of the resulting + * array. If the limit n is greater than zero then the pattern + * will be applied at most n - 1 times, the array's + * length will be no greater than n, and the array's last entry + * will contain all input beyond the last matched delimiter. If n + * is non-positive then the pattern will be applied as many times as + * possible and the array can have any length. If n is zero then + * the pattern will be applied as many times as possible, the array can + * have any length, and trailing empty strings will be discarded. + * + *

The string "boo:and:foo", for example, yields the + * following results with these parameters: + * + *

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
RegexLimitResult
:2{ "boo", "and:foo" }
:5{ "boo", "and", "foo" }
:-2{ "boo", "and", "foo" }
o5{ "b", "", ":and:f", "", "" }
o-2{ "b", "", ":and:f", "", "" }
o0{ "b", "", ":and:f" }
+ * + *

An invocation of this method of the form + * str.split(regex, n) + * yields the same result as the expression + * + *

+ * {@link java.util.regex.Pattern}.{@link java.util.regex.Pattern#compile + * compile}(regex).{@link + * java.util.regex.Pattern#split(java.lang.CharSequence,int) + * split}(str, n) + *
+ * + * + * @param regex + * the delimiting regular expression + * + * @param limit + * the result threshold, as described above + * + * @return the array of strings computed by splitting this string + * around matches of the given regular expression + * + * @throws PatternSyntaxException + * if the regular expression's syntax is invalid + * + * @see java.util.regex.Pattern + * + * @since 1.4 + * @spec JSR-51 + */ + public String[] split(String regex, int limit) { + throw new UnsupportedOperationException("Needs regexp"); + } + + /** + * Splits this string around matches of the given regular expression. + * + *

This method works as if by invoking the two-argument {@link + * #split(String, int) split} method with the given expression and a limit + * argument of zero. Trailing empty strings are therefore not included in + * the resulting array. + * + *

The string "boo:and:foo", for example, yields the following + * results with these expressions: + * + *

+ * + * + * + * + * + * + * + * + *
RegexResult
:{ "boo", "and", "foo" }
o{ "b", "", ":and:f" }
+ * + * + * @param regex + * the delimiting regular expression + * + * @return the array of strings computed by splitting this string + * around matches of the given regular expression + * + * @throws PatternSyntaxException + * if the regular expression's syntax is invalid + * + * @see java.util.regex.Pattern + * + * @since 1.4 + * @spec JSR-51 + */ + public String[] split(String regex) { + return split(regex, 0); + } + + /** + * Converts all of the characters in this String to lower + * case using the rules of the given Locale. Case mapping is based + * on the Unicode Standard version specified by the {@link java.lang.Character Character} + * class. Since case mappings are not always 1:1 char mappings, the resulting + * String may be a different length than the original String. + *

+ * Examples of lowercase mappings are in the following table: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Language Code of LocaleUpper CaseLower CaseDescription
tr (Turkish)\u0130\u0069capital letter I with dot above -> small letter i
tr (Turkish)\u0049\u0131capital letter I -> small letter dotless i
(all)French Friesfrench frieslowercased all chars in String
(all)capiotacapchi + * capthetacapupsil + * capsigmaiotachi + * thetaupsilon + * sigmalowercased all chars in String
+ * + * @param locale use the case transformation rules for this locale + * @return the String, converted to lowercase. + * @see java.lang.String#toLowerCase() + * @see java.lang.String#toUpperCase() + * @see java.lang.String#toUpperCase(Locale) + * @since 1.1 + */ +// public String toLowerCase(Locale locale) { +// if (locale == null) { +// throw new NullPointerException(); +// } +// +// int firstUpper; +// +// /* Now check if there are any characters that need to be changed. */ +// scan: { +// for (firstUpper = 0 ; firstUpper < count; ) { +// char c = value[offset+firstUpper]; +// if ((c >= Character.MIN_HIGH_SURROGATE) && +// (c <= Character.MAX_HIGH_SURROGATE)) { +// int supplChar = codePointAt(firstUpper); +// if (supplChar != Character.toLowerCase(supplChar)) { +// break scan; +// } +// firstUpper += Character.charCount(supplChar); +// } else { +// if (c != Character.toLowerCase(c)) { +// break scan; +// } +// firstUpper++; +// } +// } +// return this; +// } +// +// char[] result = new char[count]; +// int resultOffset = 0; /* result may grow, so i+resultOffset +// * is the write location in result */ +// +// /* Just copy the first few lowerCase characters. */ +// arraycopy(value, offset, result, 0, firstUpper); +// +// String lang = locale.getLanguage(); +// boolean localeDependent = +// (lang == "tr" || lang == "az" || lang == "lt"); +// char[] lowerCharArray; +// int lowerChar; +// int srcChar; +// int srcCount; +// for (int i = firstUpper; i < count; i += srcCount) { +// srcChar = (int)value[offset+i]; +// if ((char)srcChar >= Character.MIN_HIGH_SURROGATE && +// (char)srcChar <= Character.MAX_HIGH_SURROGATE) { +// srcChar = codePointAt(i); +// srcCount = Character.charCount(srcChar); +// } else { +// srcCount = 1; +// } +// if (localeDependent || srcChar == '\u03A3') { // GREEK CAPITAL LETTER SIGMA +// lowerChar = ConditionalSpecialCasing.toLowerCaseEx(this, i, locale); +// } else if (srcChar == '\u0130') { // LATIN CAPITAL LETTER I DOT +// lowerChar = Character.ERROR; +// } else { +// lowerChar = Character.toLowerCase(srcChar); +// } +// if ((lowerChar == Character.ERROR) || +// (lowerChar >= Character.MIN_SUPPLEMENTARY_CODE_POINT)) { +// if (lowerChar == Character.ERROR) { +// if (!localeDependent && srcChar == '\u0130') { +// lowerCharArray = +// ConditionalSpecialCasing.toLowerCaseCharArray(this, i, Locale.ENGLISH); +// } else { +// lowerCharArray = +// ConditionalSpecialCasing.toLowerCaseCharArray(this, i, locale); +// } +// } else if (srcCount == 2) { +// resultOffset += Character.toChars(lowerChar, result, i + resultOffset) - srcCount; +// continue; +// } else { +// lowerCharArray = Character.toChars(lowerChar); +// } +// +// /* Grow result if needed */ +// int mapLen = lowerCharArray.length; +// if (mapLen > srcCount) { +// char[] result2 = new char[result.length + mapLen - srcCount]; +// arraycopy(result, 0, result2, 0, +// i + resultOffset); +// result = result2; +// } +// for (int x=0; xString to lower + * case using the rules of the default locale. This is equivalent to calling + * toLowerCase(Locale.getDefault()). + *

+ * Note: This method is locale sensitive, and may produce unexpected + * results if used for strings that are intended to be interpreted locale + * independently. + * Examples are programming language identifiers, protocol keys, and HTML + * tags. + * For instance, "TITLE".toLowerCase() in a Turkish locale + * returns "t\u005Cu0131tle", where '\u005Cu0131' is the + * LATIN SMALL LETTER DOTLESS I character. + * To obtain correct results for locale insensitive strings, use + * toLowerCase(Locale.ENGLISH). + *

+ * @return the String, converted to lowercase. + * @see java.lang.String#toLowerCase(Locale) + */ + public String toLowerCase() { + throw new UnsupportedOperationException("Should be supported but without connection to locale"); + } + + /** + * Converts all of the characters in this String to upper + * case using the rules of the given Locale. Case mapping is based + * on the Unicode Standard version specified by the {@link java.lang.Character Character} + * class. Since case mappings are not always 1:1 char mappings, the resulting + * String may be a different length than the original String. + *

+ * Examples of locale-sensitive and 1:M case mappings are in the following table. + *

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Language Code of LocaleLower CaseUpper CaseDescription
tr (Turkish)\u0069\u0130small letter i -> capital letter I with dot above
tr (Turkish)\u0131\u0049small letter dotless i -> capital letter I
(all)\u00df\u0053 \u0053small letter sharp s -> two letters: SS
(all)FahrvergnügenFAHRVERGNÜGEN
+ * @param locale use the case transformation rules for this locale + * @return the String, converted to uppercase. + * @see java.lang.String#toUpperCase() + * @see java.lang.String#toLowerCase() + * @see java.lang.String#toLowerCase(Locale) + * @since 1.1 + */ + /* not for javascript + public String toUpperCase(Locale locale) { + if (locale == null) { + throw new NullPointerException(); + } + + int firstLower; + + // Now check if there are any characters that need to be changed. + scan: { + for (firstLower = 0 ; firstLower < count; ) { + int c = (int)value[offset+firstLower]; + int srcCount; + if ((c >= Character.MIN_HIGH_SURROGATE) && + (c <= Character.MAX_HIGH_SURROGATE)) { + c = codePointAt(firstLower); + srcCount = Character.charCount(c); + } else { + srcCount = 1; + } + int upperCaseChar = Character.toUpperCaseEx(c); + if ((upperCaseChar == Character.ERROR) || + (c != upperCaseChar)) { + break scan; + } + firstLower += srcCount; + } + return this; + } + + char[] result = new char[count]; /* may grow * + int resultOffset = 0; /* result may grow, so i+resultOffset + * is the write location in result * + + /* Just copy the first few upperCase characters. * + arraycopy(value, offset, result, 0, firstLower); + + String lang = locale.getLanguage(); + boolean localeDependent = + (lang == "tr" || lang == "az" || lang == "lt"); + char[] upperCharArray; + int upperChar; + int srcChar; + int srcCount; + for (int i = firstLower; i < count; i += srcCount) { + srcChar = (int)value[offset+i]; + if ((char)srcChar >= Character.MIN_HIGH_SURROGATE && + (char)srcChar <= Character.MAX_HIGH_SURROGATE) { + srcChar = codePointAt(i); + srcCount = Character.charCount(srcChar); + } else { + srcCount = 1; + } + if (localeDependent) { + upperChar = ConditionalSpecialCasing.toUpperCaseEx(this, i, locale); + } else { + upperChar = Character.toUpperCaseEx(srcChar); + } + if ((upperChar == Character.ERROR) || + (upperChar >= Character.MIN_SUPPLEMENTARY_CODE_POINT)) { + if (upperChar == Character.ERROR) { + if (localeDependent) { + upperCharArray = + ConditionalSpecialCasing.toUpperCaseCharArray(this, i, locale); + } else { + upperCharArray = Character.toUpperCaseCharArray(srcChar); + } + } else if (srcCount == 2) { + resultOffset += Character.toChars(upperChar, result, i + resultOffset) - srcCount; + continue; + } else { + upperCharArray = Character.toChars(upperChar); + } + + /* Grow result if needed * + int mapLen = upperCharArray.length; + if (mapLen > srcCount) { + char[] result2 = new char[result.length + mapLen - srcCount]; + arraycopy(result, 0, result2, 0, + i + resultOffset); + result = result2; + } + for (int x=0; xString to upper + * case using the rules of the default locale. This method is equivalent to + * toUpperCase(Locale.getDefault()). + *

+ * Note: This method is locale sensitive, and may produce unexpected + * results if used for strings that are intended to be interpreted locale + * independently. + * Examples are programming language identifiers, protocol keys, and HTML + * tags. + * For instance, "title".toUpperCase() in a Turkish locale + * returns "T\u005Cu0130TLE", where '\u005Cu0130' is the + * LATIN CAPITAL LETTER I WITH DOT ABOVE character. + * To obtain correct results for locale insensitive strings, use + * toUpperCase(Locale.ENGLISH). + *

+ * @return the String, converted to uppercase. + * @see java.lang.String#toUpperCase(Locale) + */ + public String toUpperCase() { + throw new UnsupportedOperationException(); + } + + /** + * Returns a copy of the string, with leading and trailing whitespace + * omitted. + *

+ * If this String object represents an empty character + * sequence, or the first and last characters of character sequence + * represented by this String object both have codes + * greater than '\u0020' (the space character), then a + * reference to this String object is returned. + *

+ * Otherwise, if there is no character with a code greater than + * '\u0020' in the string, then a new + * String object representing an empty string is created + * and returned. + *

+ * Otherwise, let k be the index of the first character in the + * string whose code is greater than '\u0020', and let + * m be the index of the last character in the string whose code + * is greater than '\u0020'. A new String + * object is created, representing the substring of this string that + * begins with the character at index k and ends with the + * character at index m-that is, the result of + * this.substring(km+1). + *

+ * This method may be used to trim whitespace (as defined above) from + * the beginning and end of a string. + * + * @return A copy of this string with leading and trailing white + * space removed, or this string if it has no leading or + * trailing white space. + */ + public String trim() { + int len = count; + int st = 0; + int off = offset; /* avoid getfield opcode */ + char[] val = value; /* avoid getfield opcode */ + + while ((st < len) && (val[off + st] <= ' ')) { + st++; + } + while ((st < len) && (val[off + len - 1] <= ' ')) { + len--; + } + return ((st > 0) || (len < count)) ? substring(st, len) : this; + } + + /** + * This object (which is already a string!) is itself returned. + * + * @return the string itself. + */ + public String toString() { + return this; + } + + /** + * Converts this string to a new character array. + * + * @return a newly allocated character array whose length is the length + * of this string and whose contents are initialized to contain + * the character sequence represented by this string. + */ + public char[] toCharArray() { + char result[] = new char[count]; + getChars(0, count, result, 0); + return result; + } + + /** + * Returns a formatted string using the specified format string and + * arguments. + * + *

The locale always used is the one returned by {@link + * java.util.Locale#getDefault() Locale.getDefault()}. + * + * @param format + * A format string + * + * @param args + * Arguments referenced by the format specifiers in the format + * string. If there are more arguments than format specifiers, the + * extra arguments are ignored. The number of arguments is + * variable and may be zero. The maximum number of arguments is + * limited by the maximum dimension of a Java array as defined by + * The Java™ Virtual Machine Specification. + * The behaviour on a + * null argument depends on the conversion. + * + * @throws IllegalFormatException + * If a format string contains an illegal syntax, a format + * specifier that is incompatible with the given arguments, + * insufficient arguments given the format string, or other + * illegal conditions. For specification of all possible + * formatting errors, see the Details section of the + * formatter class specification. + * + * @throws NullPointerException + * If the format is null + * + * @return A formatted string + * + * @see java.util.Formatter + * @since 1.5 + */ + public static String format(String format, Object ... args) { + throw new UnsupportedOperationException(); + } + + /** + * Returns a formatted string using the specified locale, format string, + * and arguments. + * + * @param l + * The {@linkplain java.util.Locale locale} to apply during + * formatting. If l is null then no localization + * is applied. + * + * @param format + * A format string + * + * @param args + * Arguments referenced by the format specifiers in the format + * string. If there are more arguments than format specifiers, the + * extra arguments are ignored. The number of arguments is + * variable and may be zero. The maximum number of arguments is + * limited by the maximum dimension of a Java array as defined by + * The Java™ Virtual Machine Specification. + * The behaviour on a + * null argument depends on the conversion. + * + * @throws IllegalFormatException + * If a format string contains an illegal syntax, a format + * specifier that is incompatible with the given arguments, + * insufficient arguments given the format string, or other + * illegal conditions. For specification of all possible + * formatting errors, see the Details section of the + * formatter class specification + * + * @throws NullPointerException + * If the format is null + * + * @return A formatted string + * + * @see java.util.Formatter + * @since 1.5 + */ +// public static String format(Locale l, String format, Object ... args) { +// return new Formatter(l).format(format, args).toString(); +// } + + /** + * Returns the string representation of the Object argument. + * + * @param obj an Object. + * @return if the argument is null, then a string equal to + * "null"; otherwise, the value of + * obj.toString() is returned. + * @see java.lang.Object#toString() + */ + public static String valueOf(Object obj) { + return (obj == null) ? "null" : obj.toString(); + } + + /** + * Returns the string representation of the char array + * argument. The contents of the character array are copied; subsequent + * modification of the character array does not affect the newly + * created string. + * + * @param data a char array. + * @return a newly allocated string representing the same sequence of + * characters contained in the character array argument. + */ + public static String valueOf(char data[]) { + return new String(data); + } + + /** + * Returns the string representation of a specific subarray of the + * char array argument. + *

+ * The offset argument is the index of the first + * character of the subarray. The count argument + * specifies the length of the subarray. The contents of the subarray + * are copied; subsequent modification of the character array does not + * affect the newly created string. + * + * @param data the character array. + * @param offset the initial offset into the value of the + * String. + * @param count the length of the value of the String. + * @return a string representing the sequence of characters contained + * in the subarray of the character array argument. + * @exception IndexOutOfBoundsException if offset is + * negative, or count is negative, or + * offset+count is larger than + * data.length. + */ + public static String valueOf(char data[], int offset, int count) { + return new String(data, offset, count); + } + + /** + * Returns a String that represents the character sequence in the + * array specified. + * + * @param data the character array. + * @param offset initial offset of the subarray. + * @param count length of the subarray. + * @return a String that contains the characters of the + * specified subarray of the character array. + */ + public static String copyValueOf(char data[], int offset, int count) { + // All public String constructors now copy the data. + return new String(data, offset, count); + } + + /** + * Returns a String that represents the character sequence in the + * array specified. + * + * @param data the character array. + * @return a String that contains the characters of the + * character array. + */ + public static String copyValueOf(char data[]) { + return copyValueOf(data, 0, data.length); + } + + /** + * Returns the string representation of the boolean argument. + * + * @param b a boolean. + * @return if the argument is true, a string equal to + * "true" is returned; otherwise, a string equal to + * "false" is returned. + */ + public static String valueOf(boolean b) { + return b ? "true" : "false"; + } + + /** + * Returns the string representation of the char + * argument. + * + * @param c a char. + * @return a string of length 1 containing + * as its single character the argument c. + */ + public static String valueOf(char c) { + char data[] = {c}; + return new String(0, 1, data); + } + + /** + * Returns the string representation of the int argument. + *

+ * The representation is exactly the one returned by the + * Integer.toString method of one argument. + * + * @param i an int. + * @return a string representation of the int argument. + * @see java.lang.Integer#toString(int, int) + */ + public static String valueOf(int i) { + return Integer.toString(i); + } + + /** + * Returns the string representation of the long argument. + *

+ * The representation is exactly the one returned by the + * Long.toString method of one argument. + * + * @param l a long. + * @return a string representation of the long argument. + * @see java.lang.Long#toString(long) + */ + public static String valueOf(long l) { + return Long.toString(l); + } + + /** + * Returns the string representation of the float argument. + *

+ * The representation is exactly the one returned by the + * Float.toString method of one argument. + * + * @param f a float. + * @return a string representation of the float argument. + * @see java.lang.Float#toString(float) + */ + public static String valueOf(float f) { + return Float.toString(f); + } + + /** + * Returns the string representation of the double argument. + *

+ * The representation is exactly the one returned by the + * Double.toString method of one argument. + * + * @param d a double. + * @return a string representation of the double argument. + * @see java.lang.Double#toString(double) + */ + public static String valueOf(double d) { + return Double.toString(d); + } + + /** + * Returns a canonical representation for the string object. + *

+ * A pool of strings, initially empty, is maintained privately by the + * class String. + *

+ * When the intern method is invoked, if the pool already contains a + * string equal to this String object as determined by + * the {@link #equals(Object)} method, then the string from the pool is + * returned. Otherwise, this String object is added to the + * pool and a reference to this String object is returned. + *

+ * It follows that for any two strings s and t, + * s.intern() == t.intern() is true + * if and only if s.equals(t) is true. + *

+ * All literal strings and string-valued constant expressions are + * interned. String literals are defined in section 3.10.5 of the + * The Java™ Language Specification. + * + * @return a string that has the same contents as this string, but is + * guaranteed to be from a pool of unique strings. + */ + public native String intern(); + + static char[] copyOfRange(char[] original, int from, int to) { + int newLength = to - from; + if (newLength < 0) { + throw new IllegalArgumentException(from + " > " + to); + } + char[] copy = new char[newLength]; + arraycopy(original, from, copy, 0, + Math.min(original.length - from, newLength)); + return copy; + } + static char[] copyOf(char[] original, int newLength) { + char[] copy = new char[newLength]; + arraycopy(original, 0, copy, 0, + Math.min(original.length, newLength)); + return copy; + } + static void arraycopy( + char[] value, int srcBegin, char[] dst, int dstBegin, int count + ) { + while (count-- > 0) { + dst[dstBegin++] = value[srcBegin++]; + } + } + // access system property + static String getProperty(String nm) { + return null; + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/StringBuffer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/StringBuffer.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,605 @@ +/* + * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + + +/** + * A thread-safe, mutable sequence of characters. + * A string buffer is like a {@link String}, but can be modified. At any + * point in time it contains some particular sequence of characters, but + * the length and content of the sequence can be changed through certain + * method calls. + *

+ * String buffers are safe for use by multiple threads. The methods + * are synchronized where necessary so that all the operations on any + * particular instance behave as if they occur in some serial order + * that is consistent with the order of the method calls made by each of + * the individual threads involved. + *

+ * The principal operations on a StringBuffer are the + * append and insert methods, which are + * overloaded so as to accept data of any type. Each effectively + * converts a given datum to a string and then appends or inserts the + * characters of that string to the string buffer. The + * append method always adds these characters at the end + * of the buffer; the insert method adds the characters at + * a specified point. + *

+ * For example, if z refers to a string buffer object + * whose current contents are "start", then + * the method call z.append("le") would cause the string + * buffer to contain "startle", whereas + * z.insert(4, "le") would alter the string buffer to + * contain "starlet". + *

+ * In general, if sb refers to an instance of a StringBuffer, + * then sb.append(x) has the same effect as + * sb.insert(sb.length(), x). + *

+ * Whenever an operation occurs involving a source sequence (such as + * appending or inserting from a source sequence) this class synchronizes + * only on the string buffer performing the operation, not on the source. + *

+ * Every string buffer has a capacity. As long as the length of the + * character sequence contained in the string buffer does not exceed + * the capacity, it is not necessary to allocate a new internal + * buffer array. If the internal buffer overflows, it is + * automatically made larger. + * + * As of release JDK 5, this class has been supplemented with an equivalent + * class designed for use by a single thread, {@link StringBuilder}. The + * StringBuilder class should generally be used in preference to + * this one, as it supports all of the same operations but it is faster, as + * it performs no synchronization. + * + * @author Arthur van Hoff + * @see java.lang.StringBuilder + * @see java.lang.String + * @since JDK1.0 + */ + public final class StringBuffer + extends AbstractStringBuilder + implements java.io.Serializable, CharSequence +{ + + /** use serialVersionUID from JDK 1.0.2 for interoperability */ + static final long serialVersionUID = 3388685877147921107L; + + /** + * Constructs a string buffer with no characters in it and an + * initial capacity of 16 characters. + */ + public StringBuffer() { + super(16); + } + + /** + * Constructs a string buffer with no characters in it and + * the specified initial capacity. + * + * @param capacity the initial capacity. + * @exception NegativeArraySizeException if the capacity + * argument is less than 0. + */ + public StringBuffer(int capacity) { + super(capacity); + } + + /** + * Constructs a string buffer initialized to the contents of the + * specified string. The initial capacity of the string buffer is + * 16 plus the length of the string argument. + * + * @param str the initial contents of the buffer. + * @exception NullPointerException if str is null + */ + public StringBuffer(String str) { + super(str.length() + 16); + append(str); + } + + /** + * Constructs a string buffer that contains the same characters + * as the specified CharSequence. The initial capacity of + * the string buffer is 16 plus the length of the + * CharSequence argument. + *

+ * If the length of the specified CharSequence is + * less than or equal to zero, then an empty buffer of capacity + * 16 is returned. + * + * @param seq the sequence to copy. + * @exception NullPointerException if seq is null + * @since 1.5 + */ + public StringBuffer(CharSequence seq) { + this(seq.length() + 16); + append(seq); + } + + public synchronized int length() { + return count; + } + + public synchronized int capacity() { + return value.length; + } + + + public synchronized void ensureCapacity(int minimumCapacity) { + if (minimumCapacity > value.length) { + expandCapacity(minimumCapacity); + } + } + + /** + * @since 1.5 + */ + public synchronized void trimToSize() { + super.trimToSize(); + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + * @see #length() + */ + public synchronized void setLength(int newLength) { + super.setLength(newLength); + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + * @see #length() + */ + public synchronized char charAt(int index) { + if ((index < 0) || (index >= count)) + throw new StringIndexOutOfBoundsException(index); + return value[index]; + } + + /** + * @since 1.5 + */ + public synchronized int codePointAt(int index) { + return super.codePointAt(index); + } + + /** + * @since 1.5 + */ + public synchronized int codePointBefore(int index) { + return super.codePointBefore(index); + } + + /** + * @since 1.5 + */ + public synchronized int codePointCount(int beginIndex, int endIndex) { + return super.codePointCount(beginIndex, endIndex); + } + + /** + * @since 1.5 + */ + public synchronized int offsetByCodePoints(int index, int codePointOffset) { + return super.offsetByCodePoints(index, codePointOffset); + } + + /** + * @throws NullPointerException {@inheritDoc} + * @throws IndexOutOfBoundsException {@inheritDoc} + */ + public synchronized void getChars(int srcBegin, int srcEnd, char[] dst, + int dstBegin) + { + super.getChars(srcBegin, srcEnd, dst, dstBegin); + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + * @see #length() + */ + public synchronized void setCharAt(int index, char ch) { + if ((index < 0) || (index >= count)) + throw new StringIndexOutOfBoundsException(index); + value[index] = ch; + } + + public synchronized StringBuffer append(Object obj) { + super.append(String.valueOf(obj)); + return this; + } + + public synchronized StringBuffer append(String str) { + super.append(str); + return this; + } + + /** + * Appends the specified StringBuffer to this sequence. + *

+ * The characters of the StringBuffer argument are appended, + * in order, to the contents of this StringBuffer, increasing the + * length of this StringBuffer by the length of the argument. + * If sb is null, then the four characters + * "null" are appended to this StringBuffer. + *

+ * Let n be the length of the old character sequence, the one + * contained in the StringBuffer just prior to execution of the + * append method. Then the character at index k in + * the new character sequence is equal to the character at index k + * in the old character sequence, if k is less than n; + * otherwise, it is equal to the character at index k-n in the + * argument sb. + *

+ * This method synchronizes on this (the destination) + * object but does not synchronize on the source (sb). + * + * @param sb the StringBuffer to append. + * @return a reference to this object. + * @since 1.4 + */ + public synchronized StringBuffer append(StringBuffer sb) { + super.append(sb); + return this; + } + + + /** + * Appends the specified CharSequence to this + * sequence. + *

+ * The characters of the CharSequence argument are appended, + * in order, increasing the length of this sequence by the length of the + * argument. + * + *

The result of this method is exactly the same as if it were an + * invocation of this.append(s, 0, s.length()); + * + *

This method synchronizes on this (the destination) + * object but does not synchronize on the source (s). + * + *

If s is null, then the four characters + * "null" are appended. + * + * @param s the CharSequence to append. + * @return a reference to this object. + * @since 1.5 + */ + public StringBuffer append(CharSequence s) { + // Note, synchronization achieved via other invocations + if (s == null) + s = "null"; + if (s instanceof String) + return this.append((String)s); + if (s instanceof StringBuffer) + return this.append((StringBuffer)s); + return this.append(s, 0, s.length()); + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + * @since 1.5 + */ + public synchronized StringBuffer append(CharSequence s, int start, int end) + { + super.append(s, start, end); + return this; + } + + public synchronized StringBuffer append(char[] str) { + super.append(str); + return this; + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + */ + public synchronized StringBuffer append(char[] str, int offset, int len) { + super.append(str, offset, len); + return this; + } + + public synchronized StringBuffer append(boolean b) { + super.append(b); + return this; + } + + public synchronized StringBuffer append(char c) { + super.append(c); + return this; + } + + public synchronized StringBuffer append(int i) { + super.append(i); + return this; + } + + /** + * @since 1.5 + */ + public synchronized StringBuffer appendCodePoint(int codePoint) { + super.appendCodePoint(codePoint); + return this; + } + + public synchronized StringBuffer append(long lng) { + super.append(lng); + return this; + } + + public synchronized StringBuffer append(float f) { + super.append(f); + return this; + } + + public synchronized StringBuffer append(double d) { + super.append(d); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + * @since 1.2 + */ + public synchronized StringBuffer delete(int start, int end) { + super.delete(start, end); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + * @since 1.2 + */ + public synchronized StringBuffer deleteCharAt(int index) { + super.deleteCharAt(index); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + * @since 1.2 + */ + public synchronized StringBuffer replace(int start, int end, String str) { + super.replace(start, end, str); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + * @since 1.2 + */ + public synchronized String substring(int start) { + return substring(start, count); + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + * @since 1.4 + */ + public synchronized CharSequence subSequence(int start, int end) { + return super.substring(start, end); + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + * @since 1.2 + */ + public synchronized String substring(int start, int end) { + return super.substring(start, end); + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + * @since 1.2 + */ + public synchronized StringBuffer insert(int index, char[] str, int offset, + int len) + { + super.insert(index, str, offset, len); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public synchronized StringBuffer insert(int offset, Object obj) { + super.insert(offset, String.valueOf(obj)); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public synchronized StringBuffer insert(int offset, String str) { + super.insert(offset, str); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public synchronized StringBuffer insert(int offset, char[] str) { + super.insert(offset, str); + return this; + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + * @since 1.5 + */ + public StringBuffer insert(int dstOffset, CharSequence s) { + // Note, synchronization achieved via other invocations + if (s == null) + s = "null"; + if (s instanceof String) + return this.insert(dstOffset, (String)s); + return this.insert(dstOffset, s, 0, s.length()); + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + * @since 1.5 + */ + public synchronized StringBuffer insert(int dstOffset, CharSequence s, + int start, int end) + { + super.insert(dstOffset, s, start, end); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuffer insert(int offset, boolean b) { + return insert(offset, String.valueOf(b)); + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + */ + public synchronized StringBuffer insert(int offset, char c) { + super.insert(offset, c); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuffer insert(int offset, int i) { + return insert(offset, String.valueOf(i)); + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuffer insert(int offset, long l) { + return insert(offset, String.valueOf(l)); + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuffer insert(int offset, float f) { + return insert(offset, String.valueOf(f)); + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuffer insert(int offset, double d) { + return insert(offset, String.valueOf(d)); + } + + /** + * @throws NullPointerException {@inheritDoc} + * @since 1.4 + */ + public int indexOf(String str) { + return indexOf(str, 0); + } + + /** + * @throws NullPointerException {@inheritDoc} + * @since 1.4 + */ + public synchronized int indexOf(String str, int fromIndex) { + return String.indexOf(value, 0, count, + str.toCharArray(), 0, str.length(), fromIndex); + } + + /** + * @throws NullPointerException {@inheritDoc} + * @since 1.4 + */ + public int lastIndexOf(String str) { + // Note, synchronization achieved via other invocations + return lastIndexOf(str, count); + } + + /** + * @throws NullPointerException {@inheritDoc} + * @since 1.4 + */ + public synchronized int lastIndexOf(String str, int fromIndex) { + return String.lastIndexOf(value, 0, count, + str.toCharArray(), 0, str.length(), fromIndex); + } + + /** + * @since JDK1.0.2 + */ + public synchronized StringBuffer reverse() { + super.reverse(); + return this; + } + + public synchronized String toString() { + return new String(value, 0, count); + } + +// /** +// * Serializable fields for StringBuffer. +// * +// * @serialField value char[] +// * The backing character array of this StringBuffer. +// * @serialField count int +// * The number of characters in this StringBuffer. +// * @serialField shared boolean +// * A flag indicating whether the backing array is shared. +// * The value is ignored upon deserialization. +// */ +// private static final java.io.ObjectStreamField[] serialPersistentFields = +// { +// new java.io.ObjectStreamField("value", char[].class), +// new java.io.ObjectStreamField("count", Integer.TYPE), +// new java.io.ObjectStreamField("shared", Boolean.TYPE), +// }; +// +// /** +// * readObject is called to restore the state of the StringBuffer from +// * a stream. +// */ +// private synchronized void writeObject(java.io.ObjectOutputStream s) +// throws java.io.IOException { +// java.io.ObjectOutputStream.PutField fields = s.putFields(); +// fields.put("value", value); +// fields.put("count", count); +// fields.put("shared", false); +// s.writeFields(); +// } +// +// /** +// * readObject is called to restore the state of the StringBuffer from +// * a stream. +// */ +// private void readObject(java.io.ObjectInputStream s) +// throws java.io.IOException, ClassNotFoundException { +// java.io.ObjectInputStream.GetField fields = s.readFields(); +// value = (char[])fields.get("value", null); +// count = fields.get("count", 0); +// } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/StringBuilder.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/StringBuilder.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,437 @@ +/* + * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + + +/** + * A mutable sequence of characters. This class provides an API compatible + * with StringBuffer, but with no guarantee of synchronization. + * This class is designed for use as a drop-in replacement for + * StringBuffer in places where the string buffer was being + * used by a single thread (as is generally the case). Where possible, + * it is recommended that this class be used in preference to + * StringBuffer as it will be faster under most implementations. + * + *

The principal operations on a StringBuilder are the + * append and insert methods, which are + * overloaded so as to accept data of any type. Each effectively + * converts a given datum to a string and then appends or inserts the + * characters of that string to the string builder. The + * append method always adds these characters at the end + * of the builder; the insert method adds the characters at + * a specified point. + *

+ * For example, if z refers to a string builder object + * whose current contents are "start", then + * the method call z.append("le") would cause the string + * builder to contain "startle", whereas + * z.insert(4, "le") would alter the string builder to + * contain "starlet". + *

+ * In general, if sb refers to an instance of a StringBuilder, + * then sb.append(x) has the same effect as + * sb.insert(sb.length(), x). + * + * Every string builder has a capacity. As long as the length of the + * character sequence contained in the string builder does not exceed + * the capacity, it is not necessary to allocate a new internal + * buffer. If the internal buffer overflows, it is automatically made larger. + * + *

Instances of StringBuilder are not safe for + * use by multiple threads. If such synchronization is required then it is + * recommended that {@link java.lang.StringBuffer} be used. + * + * @author Michael McCloskey + * @see java.lang.StringBuffer + * @see java.lang.String + * @since 1.5 + */ +public final class StringBuilder + extends AbstractStringBuilder + implements java.io.Serializable, CharSequence +{ + + /** use serialVersionUID for interoperability */ + static final long serialVersionUID = 4383685877147921099L; + + /** + * Constructs a string builder with no characters in it and an + * initial capacity of 16 characters. + */ + public StringBuilder() { + super(16); + } + + /** + * Constructs a string builder with no characters in it and an + * initial capacity specified by the capacity argument. + * + * @param capacity the initial capacity. + * @throws NegativeArraySizeException if the capacity + * argument is less than 0. + */ + public StringBuilder(int capacity) { + super(capacity); + } + + /** + * Constructs a string builder initialized to the contents of the + * specified string. The initial capacity of the string builder is + * 16 plus the length of the string argument. + * + * @param str the initial contents of the buffer. + * @throws NullPointerException if str is null + */ + public StringBuilder(String str) { + super(str.length() + 16); + append(str); + } + + /** + * Constructs a string builder that contains the same characters + * as the specified CharSequence. The initial capacity of + * the string builder is 16 plus the length of the + * CharSequence argument. + * + * @param seq the sequence to copy. + * @throws NullPointerException if seq is null + */ + public StringBuilder(CharSequence seq) { + this(seq.length() + 16); + append(seq); + } + + public StringBuilder append(Object obj) { + return append(String.valueOf(obj)); + } + + public StringBuilder append(String str) { + super.append(str); + return this; + } + + // Appends the specified string builder to this sequence. + private StringBuilder append(StringBuilder sb) { + if (sb == null) + return append("null"); + int len = sb.length(); + int newcount = count + len; + if (newcount > value.length) + expandCapacity(newcount); + sb.getChars(0, len, value, count); + count = newcount; + return this; + } + + /** + * Appends the specified StringBuffer to this sequence. + *

+ * The characters of the StringBuffer argument are appended, + * in order, to this sequence, increasing the + * length of this sequence by the length of the argument. + * If sb is null, then the four characters + * "null" are appended to this sequence. + *

+ * Let n be the length of this character sequence just prior to + * execution of the append method. Then the character at index + * k in the new character sequence is equal to the character at + * index k in the old character sequence, if k is less than + * n; otherwise, it is equal to the character at index k-n + * in the argument sb. + * + * @param sb the StringBuffer to append. + * @return a reference to this object. + */ + public StringBuilder append(StringBuffer sb) { + super.append(sb); + return this; + } + + /** + */ + public StringBuilder append(CharSequence s) { + if (s == null) + s = "null"; + if (s instanceof String) + return this.append((String)s); + if (s instanceof StringBuffer) + return this.append((StringBuffer)s); + if (s instanceof StringBuilder) + return this.append((StringBuilder)s); + return this.append(s, 0, s.length()); + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder append(CharSequence s, int start, int end) { + super.append(s, start, end); + return this; + } + + public StringBuilder append(char[] str) { + super.append(str); + return this; + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder append(char[] str, int offset, int len) { + super.append(str, offset, len); + return this; + } + + public StringBuilder append(boolean b) { + super.append(b); + return this; + } + + public StringBuilder append(char c) { + super.append(c); + return this; + } + + public StringBuilder append(int i) { + super.append(i); + return this; + } + + public StringBuilder append(long lng) { + super.append(lng); + return this; + } + + public StringBuilder append(float f) { + super.append(f); + return this; + } + + public StringBuilder append(double d) { + super.append(d); + return this; + } + + /** + * @since 1.5 + */ + public StringBuilder appendCodePoint(int codePoint) { + super.appendCodePoint(codePoint); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder delete(int start, int end) { + super.delete(start, end); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder deleteCharAt(int index) { + super.deleteCharAt(index); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder replace(int start, int end, String str) { + super.replace(start, end, str); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder insert(int index, char[] str, int offset, + int len) + { + super.insert(index, str, offset, len); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder insert(int offset, Object obj) { + return insert(offset, String.valueOf(obj)); + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder insert(int offset, String str) { + super.insert(offset, str); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder insert(int offset, char[] str) { + super.insert(offset, str); + return this; + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder insert(int dstOffset, CharSequence s) { + if (s == null) + s = "null"; + if (s instanceof String) + return this.insert(dstOffset, (String)s); + return this.insert(dstOffset, s, 0, s.length()); + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder insert(int dstOffset, CharSequence s, + int start, int end) + { + super.insert(dstOffset, s, start, end); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder insert(int offset, boolean b) { + super.insert(offset, b); + return this; + } + + /** + * @throws IndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder insert(int offset, char c) { + super.insert(offset, c); + return this; + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder insert(int offset, int i) { + return insert(offset, String.valueOf(i)); + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder insert(int offset, long l) { + return insert(offset, String.valueOf(l)); + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder insert(int offset, float f) { + return insert(offset, String.valueOf(f)); + } + + /** + * @throws StringIndexOutOfBoundsException {@inheritDoc} + */ + public StringBuilder insert(int offset, double d) { + return insert(offset, String.valueOf(d)); + } + + /** + * @throws NullPointerException {@inheritDoc} + */ + public int indexOf(String str) { + return indexOf(str, 0); + } + + /** + * @throws NullPointerException {@inheritDoc} + */ + public int indexOf(String str, int fromIndex) { + return String.indexOf(value, 0, count, + str.toCharArray(), 0, str.length(), fromIndex); + } + + /** + * @throws NullPointerException {@inheritDoc} + */ + public int lastIndexOf(String str) { + return lastIndexOf(str, count); + } + + /** + * @throws NullPointerException {@inheritDoc} + */ + public int lastIndexOf(String str, int fromIndex) { + return String.lastIndexOf(value, 0, count, + str.toCharArray(), 0, str.length(), fromIndex); + } + + public StringBuilder reverse() { + super.reverse(); + return this; + } + + public String toString() { + // Create a copy, don't share the array + return new String(value, 0, count); + } + + /** + * Save the state of the StringBuilder instance to a stream + * (that is, serialize it). + * + * @serialData the number of characters currently stored in the string + * builder (int), followed by the characters in the + * string builder (char[]). The length of the + * char array may be greater than the number of + * characters currently stored in the string builder, in which + * case extra characters are ignored. + */ +// private void writeObject(java.io.ObjectOutputStream s) +// throws java.io.IOException { +// s.defaultWriteObject(); +// s.writeInt(count); +// s.writeObject(value); +// } + + /** + * readObject is called to restore the state of the StringBuffer from + * a stream. + */ +// private void readObject(java.io.ObjectInputStream s) +// throws java.io.IOException, ClassNotFoundException { +// s.defaultReadObject(); +// count = s.readInt(); +// value = (char[]) s.readObject(); +// } + +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/StringIndexOutOfBoundsException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/StringIndexOutOfBoundsException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown by String methods to indicate that an index + * is either negative or greater than the size of the string. For + * some methods such as the charAt method, this exception also is + * thrown when the index is equal to the size of the string. + * + * @author unascribed + * @see java.lang.String#charAt(int) + * @since JDK1.0 + */ +public +class StringIndexOutOfBoundsException extends IndexOutOfBoundsException { + private static final long serialVersionUID = -6762910422159637258L; + + /** + * Constructs a StringIndexOutOfBoundsException with no + * detail message. + * + * @since JDK1.0. + */ + public StringIndexOutOfBoundsException() { + super(); + } + + /** + * Constructs a StringIndexOutOfBoundsException with + * the specified detail message. + * + * @param s the detail message. + */ + public StringIndexOutOfBoundsException(String s) { + super(s); + } + + /** + * Constructs a new StringIndexOutOfBoundsException + * class with an argument indicating the illegal index. + * + * @param index the illegal index. + */ + public StringIndexOutOfBoundsException(int index) { + super("String index out of range: " + index); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/Throwable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/Throwable.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,1078 @@ +/* + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; +import java.io.*; + +/** + * The {@code Throwable} class is the superclass of all errors and + * exceptions in the Java language. Only objects that are instances of this + * class (or one of its subclasses) are thrown by the Java Virtual Machine or + * can be thrown by the Java {@code throw} statement. Similarly, only + * this class or one of its subclasses can be the argument type in a + * {@code catch} clause. + * + * For the purposes of compile-time checking of exceptions, {@code + * Throwable} and any subclass of {@code Throwable} that is not also a + * subclass of either {@link RuntimeException} or {@link Error} are + * regarded as checked exceptions. + * + *

Instances of two subclasses, {@link java.lang.Error} and + * {@link java.lang.Exception}, are conventionally used to indicate + * that exceptional situations have occurred. Typically, these instances + * are freshly created in the context of the exceptional situation so + * as to include relevant information (such as stack trace data). + * + *

A throwable contains a snapshot of the execution stack of its + * thread at the time it was created. It can also contain a message + * string that gives more information about the error. Over time, a + * throwable can {@linkplain Throwable#addSuppressed suppress} other + * throwables from being propagated. Finally, the throwable can also + * contain a cause: another throwable that caused this + * throwable to be constructed. The recording of this causal information + * is referred to as the chained exception facility, as the + * cause can, itself, have a cause, and so on, leading to a "chain" of + * exceptions, each caused by another. + * + *

One reason that a throwable may have a cause is that the class that + * throws it is built atop a lower layered abstraction, and an operation on + * the upper layer fails due to a failure in the lower layer. It would be bad + * design to let the throwable thrown by the lower layer propagate outward, as + * it is generally unrelated to the abstraction provided by the upper layer. + * Further, doing so would tie the API of the upper layer to the details of + * its implementation, assuming the lower layer's exception was a checked + * exception. Throwing a "wrapped exception" (i.e., an exception containing a + * cause) allows the upper layer to communicate the details of the failure to + * its caller without incurring either of these shortcomings. It preserves + * the flexibility to change the implementation of the upper layer without + * changing its API (in particular, the set of exceptions thrown by its + * methods). + * + *

A second reason that a throwable may have a cause is that the method + * that throws it must conform to a general-purpose interface that does not + * permit the method to throw the cause directly. For example, suppose + * a persistent collection conforms to the {@link java.util.Collection + * Collection} interface, and that its persistence is implemented atop + * {@code java.io}. Suppose the internals of the {@code add} method + * can throw an {@link java.io.IOException IOException}. The implementation + * can communicate the details of the {@code IOException} to its caller + * while conforming to the {@code Collection} interface by wrapping the + * {@code IOException} in an appropriate unchecked exception. (The + * specification for the persistent collection should indicate that it is + * capable of throwing such exceptions.) + * + *

A cause can be associated with a throwable in two ways: via a + * constructor that takes the cause as an argument, or via the + * {@link #initCause(Throwable)} method. New throwable classes that + * wish to allow causes to be associated with them should provide constructors + * that take a cause and delegate (perhaps indirectly) to one of the + * {@code Throwable} constructors that takes a cause. + * + * Because the {@code initCause} method is public, it allows a cause to be + * associated with any throwable, even a "legacy throwable" whose + * implementation predates the addition of the exception chaining mechanism to + * {@code Throwable}. + * + *

By convention, class {@code Throwable} and its subclasses have two + * constructors, one that takes no arguments and one that takes a + * {@code String} argument that can be used to produce a detail message. + * Further, those subclasses that might likely have a cause associated with + * them should have two more constructors, one that takes a + * {@code Throwable} (the cause), and one that takes a + * {@code String} (the detail message) and a {@code Throwable} (the + * cause). + * + * @author unascribed + * @author Josh Bloch (Added exception chaining and programmatic access to + * stack trace in 1.4.) + * @jls 11.2 Compile-Time Checking of Exceptions + * @since JDK1.0 + */ +public class Throwable implements Serializable { + /** use serialVersionUID from JDK 1.0.2 for interoperability */ + private static final long serialVersionUID = -3042686055658047285L; + + /** + * Native code saves some indication of the stack backtrace in this slot. + */ + private transient Object backtrace; + + /** + * Specific details about the Throwable. For example, for + * {@code FileNotFoundException}, this contains the name of + * the file that could not be found. + * + * @serial + */ + private String detailMessage; + + + /** + * Holder class to defer initializing sentinel objects only used + * for serialization. + */ + private static class SentinelHolder { + /** + * {@linkplain #setStackTrace(StackTraceElement[]) Setting the + * stack trace} to a one-element array containing this sentinel + * value indicates future attempts to set the stack trace will be + * ignored. The sentinal is equal to the result of calling:
+ * {@code new StackTraceElement("", "", null, Integer.MIN_VALUE)} + */ + public static final StackTraceElement STACK_TRACE_ELEMENT_SENTINEL = + new StackTraceElement("", "", null, Integer.MIN_VALUE); + + /** + * Sentinel value used in the serial form to indicate an immutable + * stack trace. + */ + public static final StackTraceElement[] STACK_TRACE_SENTINEL = + new StackTraceElement[] {STACK_TRACE_ELEMENT_SENTINEL}; + } + + /** + * A shared value for an empty stack. + */ + private static final StackTraceElement[] UNASSIGNED_STACK = new StackTraceElement[0]; + + /* + * To allow Throwable objects to be made immutable and safely + * reused by the JVM, such as OutOfMemoryErrors, fields of + * Throwable that are writable in response to user actions, cause, + * stackTrace, and suppressedExceptions obey the following + * protocol: + * + * 1) The fields are initialized to a non-null sentinel value + * which indicates the value has logically not been set. + * + * 2) Writing a null to the field indicates further writes + * are forbidden + * + * 3) The sentinel value may be replaced with another non-null + * value. + * + * For example, implementations of the HotSpot JVM have + * preallocated OutOfMemoryError objects to provide for better + * diagnosability of that situation. These objects are created + * without calling the constructor for that class and the fields + * in question are initialized to null. To support this + * capability, any new fields added to Throwable that require + * being initialized to a non-null value require a coordinated JVM + * change. + */ + + /** + * The throwable that caused this throwable to get thrown, or null if this + * throwable was not caused by another throwable, or if the causative + * throwable is unknown. If this field is equal to this throwable itself, + * it indicates that the cause of this throwable has not yet been + * initialized. + * + * @serial + * @since 1.4 + */ + private Throwable cause = this; + + /** + * The stack trace, as returned by {@link #getStackTrace()}. + * + * The field is initialized to a zero-length array. A {@code + * null} value of this field indicates subsequent calls to {@link + * #setStackTrace(StackTraceElement[])} and {@link + * #fillInStackTrace()} will be be no-ops. + * + * @serial + * @since 1.4 + */ + private StackTraceElement[] stackTrace = UNASSIGNED_STACK; + + // Setting this static field introduces an acceptable + // initialization dependency on a few java.util classes. +// I don't think this dependency is acceptable +// private static final List SUPPRESSED_SENTINEL = +// Collections.unmodifiableList(new ArrayList(0)); + + /** + * The list of suppressed exceptions, as returned by {@link + * #getSuppressed()}. The list is initialized to a zero-element + * unmodifiable sentinel list. When a serialized Throwable is + * read in, if the {@code suppressedExceptions} field points to a + * zero-element list, the field is reset to the sentinel value. + * + * @serial + * @since 1.7 + */ +// private List suppressedExceptions = SUPPRESSED_SENTINEL; + + /** Message for trying to suppress a null exception. */ + private static final String NULL_CAUSE_MESSAGE = "Cannot suppress a null exception."; + + /** Message for trying to suppress oneself. */ + private static final String SELF_SUPPRESSION_MESSAGE = "Self-suppression not permitted"; + + /** Caption for labeling causative exception stack traces */ + private static final String CAUSE_CAPTION = "Caused by: "; + + /** Caption for labeling suppressed exception stack traces */ + private static final String SUPPRESSED_CAPTION = "Suppressed: "; + + /** + * Constructs a new throwable with {@code null} as its detail message. + * The cause is not initialized, and may subsequently be initialized by a + * call to {@link #initCause}. + * + *

The {@link #fillInStackTrace()} method is called to initialize + * the stack trace data in the newly created throwable. + */ + public Throwable() { + fillInStackTrace(); + } + + /** + * Constructs a new throwable with the specified detail message. The + * cause is not initialized, and may subsequently be initialized by + * a call to {@link #initCause}. + * + *

The {@link #fillInStackTrace()} method is called to initialize + * the stack trace data in the newly created throwable. + * + * @param message the detail message. The detail message is saved for + * later retrieval by the {@link #getMessage()} method. + */ + public Throwable(String message) { + fillInStackTrace(); + detailMessage = message; + } + + /** + * Constructs a new throwable with the specified detail message and + * cause.

Note that the detail message associated with + * {@code cause} is not automatically incorporated in + * this throwable's detail message. + * + *

The {@link #fillInStackTrace()} method is called to initialize + * the stack trace data in the newly created throwable. + * + * @param message the detail message (which is saved for later retrieval + * by the {@link #getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A {@code null} value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.4 + */ + public Throwable(String message, Throwable cause) { + fillInStackTrace(); + detailMessage = message; + this.cause = cause; + } + + /** + * Constructs a new throwable with the specified cause and a detail + * message of {@code (cause==null ? null : cause.toString())} (which + * typically contains the class and detail message of {@code cause}). + * This constructor is useful for throwables that are little more than + * wrappers for other throwables (for example, {@link + * java.security.PrivilegedActionException}). + * + *

The {@link #fillInStackTrace()} method is called to initialize + * the stack trace data in the newly created throwable. + * + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A {@code null} value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.4 + */ + public Throwable(Throwable cause) { + fillInStackTrace(); + detailMessage = (cause==null ? null : cause.toString()); + this.cause = cause; + } + + /** + * Constructs a new throwable with the specified detail message, + * cause, {@linkplain #addSuppressed suppression} enabled or + * disabled, and writable stack trace enabled or disabled. If + * suppression is disabled, {@link #getSuppressed} for this object + * will return a zero-length array and calls to {@link + * #addSuppressed} that would otherwise append an exception to the + * suppressed list will have no effect. If the writable stack + * trace is false, this constructor will not call {@link + * #fillInStackTrace()}, a {@code null} will be written to the + * {@code stackTrace} field, and subsequent calls to {@code + * fillInStackTrace} and {@link + * #setStackTrace(StackTraceElement[])} will not set the stack + * trace. If the writable stack trace is false, {@link + * #getStackTrace} will return a zero length array. + * + *

Note that the other constructors of {@code Throwable} treat + * suppression as being enabled and the stack trace as being + * writable. Subclasses of {@code Throwable} should document any + * conditions under which suppression is disabled and document + * conditions under which the stack trace is not writable. + * Disabling of suppression should only occur in exceptional + * circumstances where special requirements exist, such as a + * virtual machine reusing exception objects under low-memory + * situations. Circumstances where a given exception object is + * repeatedly caught and rethrown, such as to implement control + * flow between two sub-systems, is another situation where + * immutable throwable objects would be appropriate. + * + * @param message the detail message. + * @param cause the cause. (A {@code null} value is permitted, + * and indicates that the cause is nonexistent or unknown.) + * @param enableSuppression whether or not suppression is enabled or disabled + * @param writableStackTrace whether or not the stack trace should be + * writable + * + * @see OutOfMemoryError + * @see NullPointerException + * @see ArithmeticException + * @since 1.7 + */ + protected Throwable(String message, Throwable cause, + boolean enableSuppression, + boolean writableStackTrace) { + if (writableStackTrace) { + fillInStackTrace(); + } else { + stackTrace = null; + } + detailMessage = message; + this.cause = cause; +// if (!enableSuppression) +// suppressedExceptions = null; + } + + /** + * Returns the detail message string of this throwable. + * + * @return the detail message string of this {@code Throwable} instance + * (which may be {@code null}). + */ + public String getMessage() { + return detailMessage; + } + + /** + * Creates a localized description of this throwable. + * Subclasses may override this method in order to produce a + * locale-specific message. For subclasses that do not override this + * method, the default implementation returns the same result as + * {@code getMessage()}. + * + * @return The localized description of this throwable. + * @since JDK1.1 + */ + public String getLocalizedMessage() { + return getMessage(); + } + + /** + * Returns the cause of this throwable or {@code null} if the + * cause is nonexistent or unknown. (The cause is the throwable that + * caused this throwable to get thrown.) + * + *

This implementation returns the cause that was supplied via one of + * the constructors requiring a {@code Throwable}, or that was set after + * creation with the {@link #initCause(Throwable)} method. While it is + * typically unnecessary to override this method, a subclass can override + * it to return a cause set by some other means. This is appropriate for + * a "legacy chained throwable" that predates the addition of chained + * exceptions to {@code Throwable}. Note that it is not + * necessary to override any of the {@code PrintStackTrace} methods, + * all of which invoke the {@code getCause} method to determine the + * cause of a throwable. + * + * @return the cause of this throwable or {@code null} if the + * cause is nonexistent or unknown. + * @since 1.4 + */ + public synchronized Throwable getCause() { + return (cause==this ? null : cause); + } + + /** + * Initializes the cause of this throwable to the specified value. + * (The cause is the throwable that caused this throwable to get thrown.) + * + *

This method can be called at most once. It is generally called from + * within the constructor, or immediately after creating the + * throwable. If this throwable was created + * with {@link #Throwable(Throwable)} or + * {@link #Throwable(String,Throwable)}, this method cannot be called + * even once. + * + *

An example of using this method on a legacy throwable type + * without other support for setting the cause is: + * + *

+     * try {
+     *     lowLevelOp();
+     * } catch (LowLevelException le) {
+     *     throw (HighLevelException)
+     *           new HighLevelException().initCause(le); // Legacy constructor
+     * }
+     * 
+ * + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A {@code null} value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @return a reference to this {@code Throwable} instance. + * @throws IllegalArgumentException if {@code cause} is this + * throwable. (A throwable cannot be its own cause.) + * @throws IllegalStateException if this throwable was + * created with {@link #Throwable(Throwable)} or + * {@link #Throwable(String,Throwable)}, or this method has already + * been called on this throwable. + * @since 1.4 + */ + public synchronized Throwable initCause(Throwable cause) { + if (this.cause != this) + throw new IllegalStateException("Can't overwrite cause"); + if (cause == this) + throw new IllegalArgumentException("Self-causation not permitted"); + this.cause = cause; + return this; + } + + /** + * Returns a short description of this throwable. + * The result is the concatenation of: + *
    + *
  • the {@linkplain Class#getName() name} of the class of this object + *
  • ": " (a colon and a space) + *
  • the result of invoking this object's {@link #getLocalizedMessage} + * method + *
+ * If {@code getLocalizedMessage} returns {@code null}, then just + * the class name is returned. + * + * @return a string representation of this throwable. + */ + public String toString() { + String s = getClass().getName(); + String message = getLocalizedMessage(); + return (message != null) ? (s + ": " + message) : s; + } + + /** + * Prints this throwable and its backtrace to the + * standard error stream. This method prints a stack trace for this + * {@code Throwable} object on the error output stream that is + * the value of the field {@code System.err}. The first line of + * output contains the result of the {@link #toString()} method for + * this object. Remaining lines represent data previously recorded by + * the method {@link #fillInStackTrace()}. The format of this + * information depends on the implementation, but the following + * example may be regarded as typical: + *
+     * java.lang.NullPointerException
+     *         at MyClass.mash(MyClass.java:9)
+     *         at MyClass.crunch(MyClass.java:6)
+     *         at MyClass.main(MyClass.java:3)
+     * 
+ * This example was produced by running the program: + *
+     * class MyClass {
+     *     public static void main(String[] args) {
+     *         crunch(null);
+     *     }
+     *     static void crunch(int[] a) {
+     *         mash(a);
+     *     }
+     *     static void mash(int[] b) {
+     *         System.out.println(b[0]);
+     *     }
+     * }
+     * 
+ * The backtrace for a throwable with an initialized, non-null cause + * should generally include the backtrace for the cause. The format + * of this information depends on the implementation, but the following + * example may be regarded as typical: + *
+     * HighLevelException: MidLevelException: LowLevelException
+     *         at Junk.a(Junk.java:13)
+     *         at Junk.main(Junk.java:4)
+     * Caused by: MidLevelException: LowLevelException
+     *         at Junk.c(Junk.java:23)
+     *         at Junk.b(Junk.java:17)
+     *         at Junk.a(Junk.java:11)
+     *         ... 1 more
+     * Caused by: LowLevelException
+     *         at Junk.e(Junk.java:30)
+     *         at Junk.d(Junk.java:27)
+     *         at Junk.c(Junk.java:21)
+     *         ... 3 more
+     * 
+ * Note the presence of lines containing the characters {@code "..."}. + * These lines indicate that the remainder of the stack trace for this + * exception matches the indicated number of frames from the bottom of the + * stack trace of the exception that was caused by this exception (the + * "enclosing" exception). This shorthand can greatly reduce the length + * of the output in the common case where a wrapped exception is thrown + * from same method as the "causative exception" is caught. The above + * example was produced by running the program: + *
+     * public class Junk {
+     *     public static void main(String args[]) {
+     *         try {
+     *             a();
+     *         } catch(HighLevelException e) {
+     *             e.printStackTrace();
+     *         }
+     *     }
+     *     static void a() throws HighLevelException {
+     *         try {
+     *             b();
+     *         } catch(MidLevelException e) {
+     *             throw new HighLevelException(e);
+     *         }
+     *     }
+     *     static void b() throws MidLevelException {
+     *         c();
+     *     }
+     *     static void c() throws MidLevelException {
+     *         try {
+     *             d();
+     *         } catch(LowLevelException e) {
+     *             throw new MidLevelException(e);
+     *         }
+     *     }
+     *     static void d() throws LowLevelException {
+     *        e();
+     *     }
+     *     static void e() throws LowLevelException {
+     *         throw new LowLevelException();
+     *     }
+     * }
+     *
+     * class HighLevelException extends Exception {
+     *     HighLevelException(Throwable cause) { super(cause); }
+     * }
+     *
+     * class MidLevelException extends Exception {
+     *     MidLevelException(Throwable cause)  { super(cause); }
+     * }
+     *
+     * class LowLevelException extends Exception {
+     * }
+     * 
+ * As of release 7, the platform supports the notion of + * suppressed exceptions (in conjunction with the {@code + * try}-with-resources statement). Any exceptions that were + * suppressed in order to deliver an exception are printed out + * beneath the stack trace. The format of this information + * depends on the implementation, but the following example may be + * regarded as typical: + * + *
+     * Exception in thread "main" java.lang.Exception: Something happened
+     *  at Foo.bar(Foo.java:10)
+     *  at Foo.main(Foo.java:5)
+     *  Suppressed: Resource$CloseFailException: Resource ID = 0
+     *          at Resource.close(Resource.java:26)
+     *          at Foo.bar(Foo.java:9)
+     *          ... 1 more
+     * 
+ * Note that the "... n more" notation is used on suppressed exceptions + * just at it is used on causes. Unlike causes, suppressed exceptions are + * indented beyond their "containing exceptions." + * + *

An exception can have both a cause and one or more suppressed + * exceptions: + *

+     * Exception in thread "main" java.lang.Exception: Main block
+     *  at Foo3.main(Foo3.java:7)
+     *  Suppressed: Resource$CloseFailException: Resource ID = 2
+     *          at Resource.close(Resource.java:26)
+     *          at Foo3.main(Foo3.java:5)
+     *  Suppressed: Resource$CloseFailException: Resource ID = 1
+     *          at Resource.close(Resource.java:26)
+     *          at Foo3.main(Foo3.java:5)
+     * Caused by: java.lang.Exception: I did it
+     *  at Foo3.main(Foo3.java:8)
+     * 
+ * Likewise, a suppressed exception can have a cause: + *
+     * Exception in thread "main" java.lang.Exception: Main block
+     *  at Foo4.main(Foo4.java:6)
+     *  Suppressed: Resource2$CloseFailException: Resource ID = 1
+     *          at Resource2.close(Resource2.java:20)
+     *          at Foo4.main(Foo4.java:5)
+     *  Caused by: java.lang.Exception: Rats, you caught me
+     *          at Resource2$CloseFailException.(Resource2.java:45)
+     *          ... 2 more
+     * 
+ */ +// public void printStackTrace() { +// printStackTrace(System.err); +// } +// +// /** +// * Prints this throwable and its backtrace to the specified print stream. +// * +// * @param s {@code PrintStream} to use for output +// */ +// public void printStackTrace(PrintStream s) { +// printStackTrace(new WrappedPrintStream(s)); +// } +// +// private void printStackTrace(PrintStreamOrWriter s) { +// // Guard against malicious overrides of Throwable.equals by +// // using a Set with identity equality semantics. +//// Set dejaVu = +//// Collections.newSetFromMap(new IdentityHashMap()); +//// dejaVu.add(this); +// +// synchronized (s.lock()) { +// // Print our stack trace +// s.println(this); +// StackTraceElement[] trace = getOurStackTrace(); +// for (StackTraceElement traceElement : trace) +// s.println("\tat " + traceElement); +// +// // Print suppressed exceptions, if any +//// for (Throwable se : getSuppressed()) +//// se.printEnclosedStackTrace(s, trace, SUPPRESSED_CAPTION, "\t", dejaVu); +// +// // Print cause, if any +// Throwable ourCause = getCause(); +//// if (ourCause != null) +//// ourCause.printEnclosedStackTrace(s, trace, CAUSE_CAPTION, "", dejaVu); +// } +// } +// +// /** +// * Print our stack trace as an enclosed exception for the specified +// * stack trace. +// */ +// private void printEnclosedStackTrace(PrintStreamOrWriter s, +// StackTraceElement[] enclosingTrace, +// String caption, +// String prefix, +// Object dejaVu) { +// assert Thread.holdsLock(s.lock()); +// { +// // Compute number of frames in common between this and enclosing trace +// StackTraceElement[] trace = getOurStackTrace(); +// int m = trace.length - 1; +// int n = enclosingTrace.length - 1; +// while (m >= 0 && n >=0 && trace[m].equals(enclosingTrace[n])) { +// m--; n--; +// } +// int framesInCommon = trace.length - 1 - m; +// +// // Print our stack trace +// s.println(prefix + caption + this); +// for (int i = 0; i <= m; i++) +// s.println(prefix + "\tat " + trace[i]); +// if (framesInCommon != 0) +// s.println(prefix + "\t... " + framesInCommon + " more"); +// +// // Print suppressed exceptions, if any +// for (Throwable se : getSuppressed()) +// se.printEnclosedStackTrace(s, trace, SUPPRESSED_CAPTION, +// prefix +"\t", dejaVu); +// +// // Print cause, if any +// Throwable ourCause = getCause(); +// if (ourCause != null) +// ourCause.printEnclosedStackTrace(s, trace, CAUSE_CAPTION, prefix, dejaVu); +// } +// } +// +// /** +// * Prints this throwable and its backtrace to the specified +// * print writer. +// * +// * @param s {@code PrintWriter} to use for output +// * @since JDK1.1 +// */ +// public void printStackTrace(PrintWriter s) { +// printStackTrace(new WrappedPrintWriter(s)); +// } +// +// /** +// * Wrapper class for PrintStream and PrintWriter to enable a single +// * implementation of printStackTrace. +// */ +// private abstract static class PrintStreamOrWriter { +// /** Returns the object to be locked when using this StreamOrWriter */ +// abstract Object lock(); +// +// /** Prints the specified string as a line on this StreamOrWriter */ +// abstract void println(Object o); +// } +// +// private static class WrappedPrintStream extends PrintStreamOrWriter { +// private final PrintStream printStream; +// +// WrappedPrintStream(PrintStream printStream) { +// this.printStream = printStream; +// } +// +// Object lock() { +// return printStream; +// } +// +// void println(Object o) { +// printStream.println(o); +// } +// } +// +// private static class WrappedPrintWriter extends PrintStreamOrWriter { +// private final PrintWriter printWriter; +// +// WrappedPrintWriter(PrintWriter printWriter) { +// this.printWriter = printWriter; +// } +// +// Object lock() { +// return printWriter; +// } +// +// void println(Object o) { +// printWriter.println(o); +// } +// } + + /** + * Fills in the execution stack trace. This method records within this + * {@code Throwable} object information about the current state of + * the stack frames for the current thread. + * + *

If the stack trace of this {@code Throwable} {@linkplain + * Throwable#Throwable(String, Throwable, boolean, boolean) is not + * writable}, calling this method has no effect. + * + * @return a reference to this {@code Throwable} instance. + * @see java.lang.Throwable#printStackTrace() + */ + public synchronized Throwable fillInStackTrace() { + if (stackTrace != null || + backtrace != null /* Out of protocol state */ ) { + fillInStackTrace(0); + stackTrace = UNASSIGNED_STACK; + } + return this; + } + + private native Throwable fillInStackTrace(int dummy); + + /** + * Provides programmatic access to the stack trace information printed by + * {@link #printStackTrace()}. Returns an array of stack trace elements, + * each representing one stack frame. The zeroth element of the array + * (assuming the array's length is non-zero) represents the top of the + * stack, which is the last method invocation in the sequence. Typically, + * this is the point at which this throwable was created and thrown. + * The last element of the array (assuming the array's length is non-zero) + * represents the bottom of the stack, which is the first method invocation + * in the sequence. + * + *

Some virtual machines may, under some circumstances, omit one + * or more stack frames from the stack trace. In the extreme case, + * a virtual machine that has no stack trace information concerning + * this throwable is permitted to return a zero-length array from this + * method. Generally speaking, the array returned by this method will + * contain one element for every frame that would be printed by + * {@code printStackTrace}. Writes to the returned array do not + * affect future calls to this method. + * + * @return an array of stack trace elements representing the stack trace + * pertaining to this throwable. + * @since 1.4 + */ + public StackTraceElement[] getStackTrace() { + return getOurStackTrace().clone(); + } + + private synchronized StackTraceElement[] getOurStackTrace() { + // Initialize stack trace field with information from + // backtrace if this is the first call to this method + if (stackTrace == UNASSIGNED_STACK || + (stackTrace == null && backtrace != null) /* Out of protocol state */) { + int depth = getStackTraceDepth(); + stackTrace = new StackTraceElement[depth]; + for (int i=0; i < depth; i++) + stackTrace[i] = getStackTraceElement(i); + } else if (stackTrace == null) { + return UNASSIGNED_STACK; + } + return stackTrace; + } + + /** + * Sets the stack trace elements that will be returned by + * {@link #getStackTrace()} and printed by {@link #printStackTrace()} + * and related methods. + * + * This method, which is designed for use by RPC frameworks and other + * advanced systems, allows the client to override the default + * stack trace that is either generated by {@link #fillInStackTrace()} + * when a throwable is constructed or deserialized when a throwable is + * read from a serialization stream. + * + *

If the stack trace of this {@code Throwable} {@linkplain + * Throwable#Throwable(String, Throwable, boolean, boolean) is not + * writable}, calling this method has no effect other than + * validating its argument. + * + * @param stackTrace the stack trace elements to be associated with + * this {@code Throwable}. The specified array is copied by this + * call; changes in the specified array after the method invocation + * returns will have no affect on this {@code Throwable}'s stack + * trace. + * + * @throws NullPointerException if {@code stackTrace} is + * {@code null} or if any of the elements of + * {@code stackTrace} are {@code null} + * + * @since 1.4 + */ + public void setStackTrace(StackTraceElement[] stackTrace) { + // Validate argument + StackTraceElement[] defensiveCopy = stackTrace.clone(); + for (int i = 0; i < defensiveCopy.length; i++) { + if (defensiveCopy[i] == null) + throw new NullPointerException("stackTrace[" + i + "]"); + } + + synchronized (this) { + if (this.stackTrace == null && // Immutable stack + backtrace == null) // Test for out of protocol state + return; + this.stackTrace = defensiveCopy; + } + } + + /** + * Returns the number of elements in the stack trace (or 0 if the stack + * trace is unavailable). + * + * package-protection for use by SharedSecrets. + */ + native int getStackTraceDepth(); + + /** + * Returns the specified element of the stack trace. + * + * package-protection for use by SharedSecrets. + * + * @param index index of the element to return. + * @throws IndexOutOfBoundsException if {@code index < 0 || + * index >= getStackTraceDepth() } + */ + native StackTraceElement getStackTraceElement(int index); + + /** + * Reads a {@code Throwable} from a stream, enforcing + * well-formedness constraints on fields. Null entries and + * self-pointers are not allowed in the list of {@code + * suppressedExceptions}. Null entries are not allowed for stack + * trace elements. A null stack trace in the serial form results + * in a zero-length stack element array. A single-element stack + * trace whose entry is equal to {@code new StackTraceElement("", + * "", null, Integer.MIN_VALUE)} results in a {@code null} {@code + * stackTrace} field. + * + * Note that there are no constraints on the value the {@code + * cause} field can hold; both {@code null} and {@code this} are + * valid values for the field. + */ +// private void readObject(ObjectInputStream s) +// throws IOException, ClassNotFoundException { +// s.defaultReadObject(); // read in all fields +// if (suppressedExceptions != null) { +// List suppressed = null; +// if (suppressedExceptions.isEmpty()) { +// // Use the sentinel for a zero-length list +// suppressed = SUPPRESSED_SENTINEL; +// } else { // Copy Throwables to new list +// suppressed = new ArrayList(1); +// for (Throwable t : suppressedExceptions) { +// // Enforce constraints on suppressed exceptions in +// // case of corrupt or malicious stream. +// if (t == null) +// throw new NullPointerException(NULL_CAUSE_MESSAGE); +// if (t == this) +// throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE); +// suppressed.add(t); +// } +// } +// suppressedExceptions = suppressed; +// } // else a null suppressedExceptions field remains null +// +// /* +// * For zero-length stack traces, use a clone of +// * UNASSIGNED_STACK rather than UNASSIGNED_STACK itself to +// * allow identity comparison against UNASSIGNED_STACK in +// * getOurStackTrace. The identity of UNASSIGNED_STACK in +// * stackTrace indicates to the getOurStackTrace method that +// * the stackTrace needs to be constructed from the information +// * in backtrace. +// */ +// if (stackTrace != null) { +// if (stackTrace.length == 0) { +// stackTrace = UNASSIGNED_STACK.clone(); +// } else if (stackTrace.length == 1 && +// // Check for the marker of an immutable stack trace +// SentinelHolder.STACK_TRACE_ELEMENT_SENTINEL.equals(stackTrace[0])) { +// stackTrace = null; +// } else { // Verify stack trace elements are non-null. +// for(StackTraceElement ste : stackTrace) { +// if (ste == null) +// throw new NullPointerException("null StackTraceElement in serial stream. "); +// } +// } +// } else { +// // A null stackTrace field in the serial form can result +// // from an exception serialized without that field in +// // older JDK releases; treat such exceptions as having +// // empty stack traces. +// stackTrace = UNASSIGNED_STACK.clone(); +// } +// } + + /** + * Write a {@code Throwable} object to a stream. + * + * A {@code null} stack trace field is represented in the serial + * form as a one-element array whose element is equal to {@code + * new StackTraceElement("", "", null, Integer.MIN_VALUE)}. + */ +// private synchronized void writeObject(ObjectOutputStream s) +// throws IOException { +// // Ensure that the stackTrace field is initialized to a +// // non-null value, if appropriate. As of JDK 7, a null stack +// // trace field is a valid value indicating the stack trace +// // should not be set. +// getOurStackTrace(); +// +// StackTraceElement[] oldStackTrace = stackTrace; +// try { +// if (stackTrace == null) +// stackTrace = SentinelHolder.STACK_TRACE_SENTINEL; +// s.defaultWriteObject(); +// } finally { +// stackTrace = oldStackTrace; +// } +// } + + /** + * Appends the specified exception to the exceptions that were + * suppressed in order to deliver this exception. This method is + * thread-safe and typically called (automatically and implicitly) + * by the {@code try}-with-resources statement. + * + *

The suppression behavior is enabled unless disabled + * {@linkplain #Throwable(String, Throwable, boolean, boolean) via + * a constructor}. When suppression is disabled, this method does + * nothing other than to validate its argument. + * + *

Note that when one exception {@linkplain + * #initCause(Throwable) causes} another exception, the first + * exception is usually caught and then the second exception is + * thrown in response. In other words, there is a causal + * connection between the two exceptions. + * + * In contrast, there are situations where two independent + * exceptions can be thrown in sibling code blocks, in particular + * in the {@code try} block of a {@code try}-with-resources + * statement and the compiler-generated {@code finally} block + * which closes the resource. + * + * In these situations, only one of the thrown exceptions can be + * propagated. In the {@code try}-with-resources statement, when + * there are two such exceptions, the exception originating from + * the {@code try} block is propagated and the exception from the + * {@code finally} block is added to the list of exceptions + * suppressed by the exception from the {@code try} block. As an + * exception unwinds the stack, it can accumulate multiple + * suppressed exceptions. + * + *

An exception may have suppressed exceptions while also being + * caused by another exception. Whether or not an exception has a + * cause is semantically known at the time of its creation, unlike + * whether or not an exception will suppress other exceptions + * which is typically only determined after an exception is + * thrown. + * + *

Note that programmer written code is also able to take + * advantage of calling this method in situations where there are + * multiple sibling exceptions and only one can be propagated. + * + * @param exception the exception to be added to the list of + * suppressed exceptions + * @throws IllegalArgumentException if {@code exception} is this + * throwable; a throwable cannot suppress itself. + * @throws NullPointerException if {@code exception} is {@code null} + * @since 1.7 + */ + public final synchronized void addSuppressed(Throwable exception) { + if (exception == this) + throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE); + + if (exception == null) + throw new NullPointerException(NULL_CAUSE_MESSAGE); + +// if (suppressedExceptions == null) // Suppressed exceptions not recorded +// return; +// +// if (suppressedExceptions == SUPPRESSED_SENTINEL) +// suppressedExceptions = new ArrayList(1); +// +// suppressedExceptions.add(exception); + } + + private static final Throwable[] EMPTY_THROWABLE_ARRAY = new Throwable[0]; + + /** + * Returns an array containing all of the exceptions that were + * suppressed, typically by the {@code try}-with-resources + * statement, in order to deliver this exception. + * + * If no exceptions were suppressed or {@linkplain + * #Throwable(String, Throwable, boolean, boolean) suppression is + * disabled}, an empty array is returned. This method is + * thread-safe. Writes to the returned array do not affect future + * calls to this method. + * + * @return an array containing all of the exceptions that were + * suppressed to deliver this exception. + * @since 1.7 + */ + public final synchronized Throwable[] getSuppressed() { + return new Throwable[0]; +// if (suppressedExceptions == SUPPRESSED_SENTINEL || +// suppressedExceptions == null) +// return EMPTY_THROWABLE_ARRAY; +// else +// return suppressedExceptions.toArray(EMPTY_THROWABLE_ARRAY); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/VirtualMachineError.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/VirtualMachineError.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown to indicate that the Java Virtual Machine is broken or has + * run out of resources necessary for it to continue operating. + * + * + * @author Frank Yellin + * @since JDK1.0 + */ +abstract public +class VirtualMachineError extends Error { + /** + * Constructs a VirtualMachineError with no detail message. + */ + public VirtualMachineError() { + super(); + } + + /** + * Constructs a VirtualMachineError with the specified + * detail message. + * + * @param s the detail message. + */ + public VirtualMachineError(String s) { + super(s); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/annotation/Annotation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/annotation/Annotation.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.annotation; + +/** + * The common interface extended by all annotation types. Note that an + * interface that manually extends this one does not define + * an annotation type. Also note that this interface does not itself + * define an annotation type. + * + * More information about annotation types can be found in section 9.6 of + * The Java™ Language Specification. + * + * @author Josh Bloch + * @since 1.5 + */ +public interface Annotation { + /** + * Returns true if the specified object represents an annotation + * that is logically equivalent to this one. In other words, + * returns true if the specified object is an instance of the same + * annotation type as this instance, all of whose members are equal + * to the corresponding member of this annotation, as defined below: + *

    + *
  • Two corresponding primitive typed members whose values are + * x and y are considered equal if x == y, + * unless their type is float or double. + * + *
  • Two corresponding float members whose values + * are x and y are considered equal if + * Float.valueOf(x).equals(Float.valueOf(y)). + * (Unlike the == operator, NaN is considered equal + * to itself, and 0.0f unequal to -0.0f.) + * + *
  • Two corresponding double members whose values + * are x and y are considered equal if + * Double.valueOf(x).equals(Double.valueOf(y)). + * (Unlike the == operator, NaN is considered equal + * to itself, and 0.0 unequal to -0.0.) + * + *
  • Two corresponding String, Class, enum, or + * annotation typed members whose values are x and y + * are considered equal if x.equals(y). (Note that this + * definition is recursive for annotation typed members.) + * + *
  • Two corresponding array typed members x and y + * are considered equal if Arrays.equals(x, y), for the + * appropriate overloading of {@link java.util.Arrays#equals}. + *
+ * + * @return true if the specified object represents an annotation + * that is logically equivalent to this one, otherwise false + */ + boolean equals(Object obj); + + /** + * Returns the hash code of this annotation, as defined below: + * + *

The hash code of an annotation is the sum of the hash codes + * of its members (including those with default values), as defined + * below: + * + * The hash code of an annotation member is (127 times the hash code + * of the member-name as computed by {@link String#hashCode()}) XOR + * the hash code of the member-value, as defined below: + * + *

The hash code of a member-value depends on its type: + *

    + *
  • The hash code of a primitive value v is equal to + * WrapperType.valueOf(v).hashCode(), where + * WrapperType is the wrapper type corresponding + * to the primitive type of v ({@link Byte}, + * {@link Character}, {@link Double}, {@link Float}, {@link Integer}, + * {@link Long}, {@link Short}, or {@link Boolean}). + * + *
  • The hash code of a string, enum, class, or annotation member-value + I v is computed as by calling + * v.hashCode(). (In the case of annotation + * member values, this is a recursive definition.) + * + *
  • The hash code of an array member-value is computed by calling + * the appropriate overloading of + * {@link java.util.Arrays#hashCode(long[]) Arrays.hashCode} + * on the value. (There is one overloading for each primitive + * type, and one for object reference types.) + *
+ * + * @return the hash code of this annotation + */ + int hashCode(); + + /** + * Returns a string representation of this annotation. The details + * of the representation are implementation-dependent, but the following + * may be regarded as typical: + *
+     *   @com.acme.util.Name(first=Alfred, middle=E., last=Neuman)
+     * 
+ * + * @return a string representation of this annotation + */ + String toString(); + + /** + * Returns the annotation type of this annotation. + */ + Class annotationType(); +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/annotation/Documented.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/annotation/Documented.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.annotation; + +/** + * Indicates that annotations with a type are to be documented by javadoc + * and similar tools by default. This type should be used to annotate the + * declarations of types whose annotations affect the use of annotated + * elements by their clients. If a type declaration is annotated with + * Documented, its annotations become part of the public API + * of the annotated elements. + * + * @author Joshua Bloch + * @since 1.5 + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Documented { +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/annotation/ElementType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/annotation/ElementType.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.annotation; + +/** + * A program element type. The constants of this enumerated type + * provide a simple classification of the declared elements in a + * Java program. + * + *

These constants are used with the {@link Target} meta-annotation type + * to specify where it is legal to use an annotation type. + * + * @author Joshua Bloch + * @since 1.5 + */ +public enum ElementType { + /** Class, interface (including annotation type), or enum declaration */ + TYPE, + + /** Field declaration (includes enum constants) */ + FIELD, + + /** Method declaration */ + METHOD, + + /** Parameter declaration */ + PARAMETER, + + /** Constructor declaration */ + CONSTRUCTOR, + + /** Local variable declaration */ + LOCAL_VARIABLE, + + /** Annotation type declaration */ + ANNOTATION_TYPE, + + /** Package declaration */ + PACKAGE +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/annotation/Retention.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/annotation/Retention.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.annotation; + +/** + * Indicates how long annotations with the annotated type are to + * be retained. If no Retention annotation is present on + * an annotation type declaration, the retention policy defaults to + * {@code RetentionPolicy.CLASS}. + * + *

A Retention meta-annotation has effect only if the + * meta-annotated type is used directly for annotation. It has no + * effect if the meta-annotated type is used as a member type in + * another annotation type. + * + * @author Joshua Bloch + * @since 1.5 + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Retention { + RetentionPolicy value(); +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/annotation/RetentionPolicy.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/annotation/RetentionPolicy.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.annotation; + +/** + * Annotation retention policy. The constants of this enumerated type + * describe the various policies for retaining annotations. They are used + * in conjunction with the {@link Retention} meta-annotation type to specify + * how long annotations are to be retained. + * + * @author Joshua Bloch + * @since 1.5 + */ +public enum RetentionPolicy { + /** + * Annotations are to be discarded by the compiler. + */ + SOURCE, + + /** + * Annotations are to be recorded in the class file by the compiler + * but need not be retained by the VM at run time. This is the default + * behavior. + */ + CLASS, + + /** + * Annotations are to be recorded in the class file by the compiler and + * retained by the VM at run time, so they may be read reflectively. + * + * @see java.lang.reflect.AnnotatedElement + */ + RUNTIME +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/annotation/Target.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/annotation/Target.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.annotation; + +/** + * Indicates the kinds of program element to which an annotation type + * is applicable. If a Target meta-annotation is not present on an + * annotation type declaration, the declared type may be used on any + * program element. If such a meta-annotation is present, the compiler + * will enforce the specified usage restriction. + * + * For example, this meta-annotation indicates that the declared type is + * itself a meta-annotation type. It can only be used on annotation type + * declarations: + *

+ *    @Target(ElementType.ANNOTATION_TYPE)
+ *    public @interface MetaAnnotationType {
+ *        ...
+ *    }
+ * 
+ * This meta-annotation indicates that the declared type is intended solely + * for use as a member type in complex annotation type declarations. It + * cannot be used to annotate anything directly: + *
+ *    @Target({})
+ *    public @interface MemberType {
+ *        ...
+ *    }
+ * 
+ * It is a compile-time error for a single ElementType constant to + * appear more than once in a Target annotation. For example, the + * following meta-annotation is illegal: + *
+ *    @Target({ElementType.FIELD, ElementType.METHOD, ElementType.FIELD})
+ *    public @interface Bogus {
+ *        ...
+ *    }
+ * 
+ */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.ANNOTATION_TYPE) +public @interface Target { + ElementType[] value(); +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/lang/annotation/UnsupportedOperationException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/lang/annotation/UnsupportedOperationException.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,94 @@ +/* + * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang; + +/** + * Thrown to indicate that the requested operation is not supported.

+ * + * This class is a member of the + * + * Java Collections Framework. + * + * @author Josh Bloch + * @since 1.2 + */ +public class UnsupportedOperationException extends RuntimeException { + /** + * Constructs an UnsupportedOperationException with no detail message. + */ + public UnsupportedOperationException() { + } + + /** + * Constructs an UnsupportedOperationException with the specified + * detail message. + * + * @param message the detail message + */ + public UnsupportedOperationException(String message) { + super(message); + } + + /** + * Constructs a new exception with the specified detail message and + * cause. + * + *

Note that the detail message associated with cause is + * not automatically incorporated in this exception's detail + * message. + * + * @param message the detail message (which is saved for later retrieval + * by the {@link Throwable#getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the + * {@link Throwable#getCause()} method). (A null value + * is permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public UnsupportedOperationException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new exception with the specified cause and a detail + * message of (cause==null ? null : cause.toString()) (which + * typically contains the class and detail message of cause). + * This constructor is useful for exceptions that are little more than + * wrappers for other throwables (for example, {@link + * java.security.PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the + * {@link Throwable#getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public UnsupportedOperationException(Throwable cause) { + super(cause); + } + + static final long serialVersionUID = -1242599979055084673L; +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/java/java/util/Comparator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/java/java/util/Comparator.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,168 @@ +/* + * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.util; + +/** + * A comparison function, which imposes a total ordering on some + * collection of objects. Comparators can be passed to a sort method (such + * as {@link Collections#sort(List,Comparator) Collections.sort} or {@link + * Arrays#sort(Object[],Comparator) Arrays.sort}) to allow precise control + * over the sort order. Comparators can also be used to control the order of + * certain data structures (such as {@link SortedSet sorted sets} or {@link + * SortedMap sorted maps}), or to provide an ordering for collections of + * objects that don't have a {@link Comparable natural ordering}.

+ * + * The ordering imposed by a comparator c on a set of elements + * S is said to be consistent with equals if and only if + * c.compare(e1, e2)==0 has the same boolean value as + * e1.equals(e2) for every e1 and e2 in + * S.

+ * + * Caution should be exercised when using a comparator capable of imposing an + * ordering inconsistent with equals to order a sorted set (or sorted map). + * Suppose a sorted set (or sorted map) with an explicit comparator c + * is used with elements (or keys) drawn from a set S. If the + * ordering imposed by c on S is inconsistent with equals, + * the sorted set (or sorted map) will behave "strangely." In particular the + * sorted set (or sorted map) will violate the general contract for set (or + * map), which is defined in terms of equals.

+ * + * For example, suppose one adds two elements {@code a} and {@code b} such that + * {@code (a.equals(b) && c.compare(a, b) != 0)} + * to an empty {@code TreeSet} with comparator {@code c}. + * The second {@code add} operation will return + * true (and the size of the tree set will increase) because {@code a} and + * {@code b} are not equivalent from the tree set's perspective, even though + * this is contrary to the specification of the + * {@link Set#add Set.add} method.

+ * + * Note: It is generally a good idea for comparators to also implement + * java.io.Serializable, as they may be used as ordering methods in + * serializable data structures (like {@link TreeSet}, {@link TreeMap}). In + * order for the data structure to serialize successfully, the comparator (if + * provided) must implement Serializable.

+ * + * For the mathematically inclined, the relation that defines the + * imposed ordering that a given comparator c imposes on a + * given set of objects S is:

+ *       {(x, y) such that c.compare(x, y) <= 0}.
+ * 
The quotient for this total order is:
+ *       {(x, y) such that c.compare(x, y) == 0}.
+ * 
+ * + * It follows immediately from the contract for compare that the + * quotient is an equivalence relation on S, and that the + * imposed ordering is a total order on S. When we say that + * the ordering imposed by c on S is consistent with + * equals, we mean that the quotient for the ordering is the equivalence + * relation defined by the objects' {@link Object#equals(Object) + * equals(Object)} method(s):
+ *     {(x, y) such that x.equals(y)}. 
+ * + *

Unlike {@code Comparable}, a comparator may optionally permit + * comparison of null arguments, while maintaining the requirements for + * an equivalence relation. + * + *

This interface is a member of the + * + * Java Collections Framework. + * + * @param the type of objects that may be compared by this comparator + * + * @author Josh Bloch + * @author Neal Gafter + * @see Comparable + * @see java.io.Serializable + * @since 1.2 + */ + +public interface Comparator { + /** + * Compares its two arguments for order. Returns a negative integer, + * zero, or a positive integer as the first argument is less than, equal + * to, or greater than the second.

+ * + * In the foregoing description, the notation + * sgn(expression) designates the mathematical + * signum function, which is defined to return one of -1, + * 0, or 1 according to whether the value of + * expression is negative, zero or positive.

+ * + * The implementor must ensure that sgn(compare(x, y)) == + * -sgn(compare(y, x)) for all x and y. (This + * implies that compare(x, y) must throw an exception if and only + * if compare(y, x) throws an exception.)

+ * + * The implementor must also ensure that the relation is transitive: + * ((compare(x, y)>0) && (compare(y, z)>0)) implies + * compare(x, z)>0.

+ * + * Finally, the implementor must ensure that compare(x, y)==0 + * implies that sgn(compare(x, z))==sgn(compare(y, z)) for all + * z.

+ * + * It is generally the case, but not strictly required that + * (compare(x, y)==0) == (x.equals(y)). Generally speaking, + * any comparator that violates this condition should clearly indicate + * this fact. The recommended language is "Note: this comparator + * imposes orderings that are inconsistent with equals." + * + * @param o1 the first object to be compared. + * @param o2 the second object to be compared. + * @return a negative integer, zero, or a positive integer as the + * first argument is less than, equal to, or greater than the + * second. + * @throws NullPointerException if an argument is null and this + * comparator does not permit null arguments + * @throws ClassCastException if the arguments' types prevent them from + * being compared by this comparator. + */ + int compare(T o1, T o2); + + /** + * Indicates whether some other object is "equal to" this + * comparator. This method must obey the general contract of + * {@link Object#equals(Object)}. Additionally, this method can return + * true only if the specified object is also a comparator + * and it imposes the same ordering as this comparator. Thus, + * comp1.equals(comp2) implies that sgn(comp1.compare(o1, + * o2))==sgn(comp2.compare(o1, o2)) for every object reference + * o1 and o2.

+ * + * Note that it is always safe not to override + * Object.equals(Object). However, overriding this method may, + * in some cases, improve performance by allowing programs to determine + * that two distinct comparators impose the same order. + * + * @param obj the reference object with which to compare. + * @return true only if the specified object is also + * a comparator and it imposes the same ordering as this + * comparator. + * @see Object#equals(Object) + * @see Object#hashCode() + */ + boolean equals(Object obj); +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 emul/src/main/resources/org/apidesign/vm4brwsr/emul/java_lang_String.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emul/src/main/resources/org/apidesign/vm4brwsr/emul/java_lang_String.js Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,2658 @@ +/* */ + + +function java_lang_String_consVAC(arg0,arg1) { + arg0.r = arg1.join(""); +} + +function java_lang_String_consVACII(self, charArr, off, cnt) { + self.r = charArr.slice(off, off + cnt).join(""); +} + +function java_lang_String_charAtCI(arg0,arg1) { + return arg0.toString().charAt(arg1); +} +function java_lang_String_lengthI(arg0) { + return arg0.toString().length; +} +function java_lang_String_isEmptyZ(arg0) { + return arg0.toString().length === 0; +} + +/* +function java_lang_String_codePointAtII(arg0,arg1) { + var arg2; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: if (stack.pop() < 0) { gt = 12; continue; } // 155 0 11 + case 4: stack.push(arg1); // 27 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().count); // 180 1 97 + case 9: if (stack.pop() > stack.pop()) { gt = 21; continue; } // 161 0 12 + case 12: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 15: stack.push(stack[stack.length - 1]); // 89 + case 16: stack.push(arg1); // 27 + case 17: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 20: // 191 + case 21: stack.push(arg0); // 42 + case 22: stack.push(stack.pop().value); // 180 1 100 + case 25: stack.push(arg0); // 42 + case 26: stack.push(stack.pop().offset); // 180 1 99 + case 29: stack.push(arg1); // 27 + case 30: stack.push(stack.pop() + stack.pop()); // 96 + case 31: stack.push(arg0); // 42 + case 32: stack.push(stack.pop().offset); // 180 1 99 + case 35: stack.push(arg0); // 42 + case 36: stack.push(stack.pop().count); // 180 1 97 + case 39: stack.push(stack.pop() + stack.pop()); // 96 + case 40: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Character_codePointAtImplAIACAIAI(v0, v1, v2)); } // 184 1 113 + case 43: return stack.pop(); // 172 + } +} +function java_lang_String_codePointBeforeII(arg0,arg1) { + var arg2; + var arg3; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: stack.push(1); // 4 + case 2: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 3: arg2 = stack.pop(); // 61 + case 4: stack.push(arg2); // 28 + case 5: if (stack.pop() < 0) { gt = 16; continue; } // 155 0 11 + case 8: stack.push(arg2); // 28 + case 9: stack.push(arg0); // 42 + case 10: stack.push(stack.pop().count); // 180 1 97 + case 13: if (stack.pop() > stack.pop()) { gt = 25; continue; } // 161 0 12 + case 16: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 19: stack.push(stack[stack.length - 1]); // 89 + case 20: stack.push(arg1); // 27 + case 21: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 24: // 191 + case 25: stack.push(arg0); // 42 + case 26: stack.push(stack.pop().value); // 180 1 100 + case 29: stack.push(arg0); // 42 + case 30: stack.push(stack.pop().offset); // 180 1 99 + case 33: stack.push(arg1); // 27 + case 34: stack.push(stack.pop() + stack.pop()); // 96 + case 35: stack.push(arg0); // 42 + case 36: stack.push(stack.pop().offset); // 180 1 99 + case 39: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Character_codePointBeforeImplAIACAIAI(v0, v1, v2)); } // 184 1 114 + case 42: return stack.pop(); // 172 + } +} +function java_lang_String_codePointCountIII(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: if (stack.pop() < 0) { gt = 17; continue; } // 155 0 16 + case 4: stack.push(arg2); // 28 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().count); // 180 1 97 + case 9: if (stack.pop() < stack.pop()) { gt = 17; continue; } // 163 0 8 + case 12: stack.push(arg1); // 27 + case 13: stack.push(arg2); // 28 + case 14: if (stack.pop() >= stack.pop()) { gt = 25; continue; } // 164 0 11 + case 17: stack.push(new java_lang_IndexOutOfBoundsException); // 187 0 194 + case 20: stack.push(stack[stack.length - 1]); // 89 + case 21: { java_lang_IndexOutOfBoundsException_consV(stack.pop()); } // 183 1 124 + case 24: // 191 + case 25: stack.push(arg0); // 42 + case 26: stack.push(stack.pop().value); // 180 1 100 + case 29: stack.push(arg0); // 42 + case 30: stack.push(stack.pop().offset); // 180 1 99 + case 33: stack.push(arg1); // 27 + case 34: stack.push(stack.pop() + stack.pop()); // 96 + case 35: stack.push(arg2); // 28 + case 36: stack.push(arg1); // 27 + case 37: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 38: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Character_codePointCountImplAIACAIAI(v0, v1, v2)); } // 184 1 115 + case 41: return stack.pop(); // 172 + } +} +function java_lang_String_offsetByCodePointsIII(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: if (stack.pop() < 0) { gt = 12; continue; } // 155 0 11 + case 4: stack.push(arg1); // 27 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().count); // 180 1 97 + case 9: if (stack.pop() >= stack.pop()) { gt = 20; continue; } // 164 0 11 + case 12: stack.push(new java_lang_IndexOutOfBoundsException); // 187 0 194 + case 15: stack.push(stack[stack.length - 1]); // 89 + case 16: { java_lang_IndexOutOfBoundsException_consV(stack.pop()); } // 183 1 124 + case 19: // 191 + case 20: stack.push(arg0); // 42 + case 21: stack.push(stack.pop().value); // 180 1 100 + case 24: stack.push(arg0); // 42 + case 25: stack.push(stack.pop().offset); // 180 1 99 + case 28: stack.push(arg0); // 42 + case 29: stack.push(stack.pop().count); // 180 1 97 + case 32: stack.push(arg0); // 42 + case 33: stack.push(stack.pop().offset); // 180 1 99 + case 36: stack.push(arg1); // 27 + case 37: stack.push(stack.pop() + stack.pop()); // 96 + case 38: stack.push(arg2); // 28 + case 39: { var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Character_offsetByCodePointsImplAIACAIAIAIAI(v0, v1, v2, v3, v4)); } // 184 1 116 + case 42: stack.push(arg0); // 42 + case 43: stack.push(stack.pop().offset); // 180 1 99 + case 46: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 47: return stack.pop(); // 172 + } +} +*/ + +// public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) { +function java_lang_String_getCharsVIIACAI(arg0,arg1,arg2,arg3,arg4) { + var s = arg0.toString(); + while (arg1 < arg2) { + arg3[arg4++] = s[arg1++]; + } +} + +/* +function java_lang_String_getBytesVIIABI(arg0,arg1,arg2,arg3,arg4) { + var arg5; + var arg6; + var arg7; + var arg8; + var arg9; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 12 + case 4: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 7: stack.push(stack[stack.length - 1]); // 89 + case 8: stack.push(arg1); // 27 + case 9: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 12: // 191 + case 13: stack.push(arg2); // 28 + case 14: stack.push(arg0); // 42 + case 15: stack.push(stack.pop().count); // 180 1 97 + case 18: if (stack.pop() >= stack.pop()) { gt = 30; continue; } // 164 0 12 + case 21: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 24: stack.push(stack[stack.length - 1]); // 89 + case 25: stack.push(arg2); // 28 + case 26: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 29: // 191 + case 30: stack.push(arg1); // 27 + case 31: stack.push(arg2); // 28 + case 32: if (stack.pop() >= stack.pop()) { gt = 46; continue; } // 164 0 14 + case 35: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 38: stack.push(stack[stack.length - 1]); // 89 + case 39: stack.push(arg2); // 28 + case 40: stack.push(arg1); // 27 + case 41: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 42: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 45: // 191 + case 46: stack.push(arg4); // 21 4 + case 48: arg5 = stack.pop() // 54 5 + case 50: stack.push(arg0); // 42 + case 51: stack.push(stack.pop().offset); // 180 1 99 + case 54: stack.push(arg2); // 28 + case 55: stack.push(stack.pop() + stack.pop()); // 96 + case 56: arg6 = stack.pop() // 54 6 + case 58: stack.push(arg0); // 42 + case 59: stack.push(stack.pop().offset); // 180 1 99 + case 62: stack.push(arg1); // 27 + case 63: stack.push(stack.pop() + stack.pop()); // 96 + case 64: arg7 = stack.pop() // 54 7 + case 66: stack.push(arg0); // 42 + case 67: stack.push(stack.pop().value); // 180 1 100 + case 70: arg8 = stack.pop() // 58 8 + case 72: stack.push(arg7); // 21 7 + case 74: stack.push(arg6); // 21 6 + case 76: if (stack.pop() <= stack.pop()) { gt = 98; continue; } // 162 0 22 + case 79: stack.push(arg3); // 45 + case 80: stack.push(arg5); // 21 5 + case 82: arg5++; // 132 5 1 + case 85: stack.push(arg8); // 25 8 + case 87: stack.push(arg7); // 21 7 + case 89: arg7++; // 132 7 1 + case 92: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 93: // number conversion // 145 + case 94: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 84 + case 95: gt = 72; continue; // 167 255 233 + case 98: return; // 177 + } +} +function java_lang_String_getBytesABLjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198 + case 7: stack.push(stack[stack.length - 1]); // 89 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128 + case 11: // 191 + case 12: stack.push(arg1); // 43 + case 13: stack.push(arg0); // 42 + case 14: stack.push(stack.pop().value); // 180 1 100 + case 17: stack.push(arg0); // 42 + case 18: stack.push(stack.pop().offset); // 180 1 99 + case 21: stack.push(arg0); // 42 + case 22: stack.push(stack.pop().count); // 180 1 97 + case 25: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_StringCoding_encodeABLjava_lang_StringACAIAI(v0, v1, v2, v3)); } // 184 1 166 + case 28: return stack.pop(); // 176 + } +} +function java_lang_String_getBytesABLjava_nio_charset_Charset(arg0,arg1) { + var arg2; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198 + case 7: stack.push(stack[stack.length - 1]); // 89 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128 + case 11: // 191 + case 12: stack.push(arg1); // 43 + case 13: stack.push(arg0); // 42 + case 14: stack.push(stack.pop().value); // 180 1 100 + case 17: stack.push(arg0); // 42 + case 18: stack.push(stack.pop().offset); // 180 1 99 + case 21: stack.push(arg0); // 42 + case 22: stack.push(stack.pop().count); // 180 1 97 + case 25: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_StringCoding_encodeABLjava_nio_charset_CharsetACAIAI(v0, v1, v2, v3)); } // 184 1 168 + case 28: return stack.pop(); // 176 + } +} +function java_lang_String_getBytesAB(arg0) { + var arg1; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().value); // 180 1 100 + case 4: stack.push(arg0); // 42 + case 5: stack.push(stack.pop().offset); // 180 1 99 + case 8: stack.push(arg0); // 42 + case 9: stack.push(stack.pop().count); // 180 1 97 + case 12: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_StringCoding_encodeABACAIAI(v0, v1, v2)); } // 184 1 164 + case 15: return stack.pop(); // 176 + } +} +function java_lang_String_equalsZLjava_lang_Object(arg0,arg1) { + var arg2; + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: // 166 + case 3: // 0 + case 4: stack.push(2); // 5 + case 5: stack.push(1); // 4 + case 6: return stack.pop(); // 172 + case 7: stack.push(arg1); // 43 + case 8: stack.push(stack.pop().$instOf_java_lang_String ? 1 : 0); // 193 0 200 + case 11: if (stack.pop() == 0) { gt = 86; continue; } // 153 0 75 + case 14: stack.push(arg1); // 43 + case 15: if(stack[stack.length - 1].$instOf_java_lang_String != 1) throw {}; // 192 0 200 + case 18: arg2 = stack.pop(); // 77 + case 19: stack.push(arg0); // 42 + case 20: stack.push(stack.pop().count); // 180 1 97 + case 23: arg3 = stack.pop(); // 62 + case 24: stack.push(arg3); // 29 + case 25: stack.push(arg2); // 44 + case 26: stack.push(stack.pop().count); // 180 1 97 + case 29: if (stack.pop() != stack.pop()) { gt = 86; continue; } // 160 0 57 + case 32: stack.push(arg0); // 42 + case 33: stack.push(stack.pop().value); // 180 1 100 + case 36: arg4 = stack.pop() // 58 4 + case 38: stack.push(arg2); // 44 + case 39: stack.push(stack.pop().value); // 180 1 100 + case 42: arg5 = stack.pop() // 58 5 + case 44: stack.push(arg0); // 42 + case 45: stack.push(stack.pop().offset); // 180 1 99 + case 48: arg6 = stack.pop() // 54 6 + case 50: stack.push(arg2); // 44 + case 51: stack.push(stack.pop().offset); // 180 1 99 + case 54: arg7 = stack.pop() // 54 7 + case 56: stack.push(arg3); // 29 + case 57: arg3 += 255; // 132 3 255 + case 60: if (stack.pop() == 0) { gt = 84; continue; } // 153 0 24 + case 63: stack.push(arg4); // 25 4 + case 65: stack.push(arg6); // 21 6 + case 67: arg6++; // 132 6 1 + case 70: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 71: stack.push(arg5); // 25 5 + case 73: stack.push(arg7); // 21 7 + case 75: arg7++; // 132 7 1 + case 78: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 79: if (stack.pop() == stack.pop()) { gt = 56; continue; } // 159 255 233 + case 82: stack.push(0); // 3 + case 83: return stack.pop(); // 172 + case 84: stack.push(1); // 4 + case 85: return stack.pop(); // 172 + case 86: stack.push(0); // 3 + case 87: return stack.pop(); // 172 + } +} +function java_lang_String_contentEqualsZLjava_lang_StringBuffer(arg0,arg1) { + var arg2; + var arg3; + var arg4; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: stack.push(stack[stack.length - 1]); // 89 + case 2: arg2 = stack.pop(); // 77 + case 3: // 194 + case 4: stack.push(arg0); // 42 + case 5: stack.push(arg1); // 43 + case 6: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.contentEqualsZLjava_lang_CharSequence(self, v0)); } // 182 1 146 + case 9: stack.push(arg2); // 44 + case 10: // 195 + case 11: return stack.pop(); // 172 + case 12: arg3 = stack.pop(); // 78 + case 13: stack.push(arg2); // 44 + case 14: // 195 + case 15: stack.push(arg3); // 45 + case 16: // 191 + } +} +function java_lang_String_contentEqualsZLjava_lang_CharSequence(arg0,arg1) { + var arg2; + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().count); // 180 1 97 + case 4: stack.push(arg1); // 43 + case 5: { var self = stack.pop(); stack.push(self.lengthI(self)); } // 185 1 188 + case 8: // 1 + case 9: // 0 + case 10: if (stack.pop() == stack.pop()) { gt = 15; continue; } // 159 0 5 + case 13: stack.push(0); // 3 + case 14: return stack.pop(); // 172 + case 15: stack.push(arg1); // 43 + case 16: stack.push(stack.pop().$instOf_java_lang_AbstractStringBuilder ? 1 : 0); // 193 0 186 + case 19: if (stack.pop() == 0) { gt = 77; continue; } // 153 0 58 + case 22: stack.push(arg0); // 42 + case 23: stack.push(stack.pop().value); // 180 1 100 + case 26: arg2 = stack.pop(); // 77 + case 27: stack.push(arg1); // 43 + case 28: if(stack[stack.length - 1].$instOf_java_lang_AbstractStringBuilder != 1) throw {}; // 192 0 186 + case 31: { var self = stack.pop(); stack.push(self.getValueAC(self)); } // 182 1 103 + case 34: arg3 = stack.pop(); // 78 + case 35: stack.push(arg0); // 42 + case 36: stack.push(stack.pop().offset); // 180 1 99 + case 39: arg4 = stack.pop() // 54 4 + case 41: stack.push(0); // 3 + case 42: arg5 = stack.pop() // 54 5 + case 44: stack.push(arg0); // 42 + case 45: stack.push(stack.pop().count); // 180 1 97 + case 48: arg6 = stack.pop() // 54 6 + case 50: stack.push(arg6); // 21 6 + case 52: arg6 += 255; // 132 6 255 + case 55: if (stack.pop() == 0) { gt = 77; continue; } // 153 0 22 + case 58: stack.push(arg2); // 44 + case 59: stack.push(arg4); // 21 4 + case 61: arg4++; // 132 4 1 + case 64: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 65: stack.push(arg3); // 45 + case 66: stack.push(arg5); // 21 5 + case 68: arg5++; // 132 5 1 + case 71: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 72: if (stack.pop() == stack.pop()) { gt = 50; continue; } // 159 255 234 + case 75: stack.push(0); // 3 + case 76: return stack.pop(); // 172 + case 77: stack.push(arg1); // 43 + case 78: stack.push(arg0); // 42 + case 79: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.equalsZLjava_lang_Object(self, v0)); } // 182 1 131 + case 82: if (stack.pop() == 0) { gt = 87; continue; } // 153 0 5 + case 85: stack.push(1); // 4 + case 86: return stack.pop(); // 172 + case 87: stack.push(arg0); // 42 + case 88: stack.push(stack.pop().value); // 180 1 100 + case 91: arg2 = stack.pop(); // 77 + case 92: stack.push(arg0); // 42 + case 93: stack.push(stack.pop().offset); // 180 1 99 + case 96: arg3 = stack.pop(); // 62 + case 97: stack.push(0); // 3 + case 98: arg4 = stack.pop() // 54 4 + case 100: stack.push(arg0); // 42 + case 101: stack.push(stack.pop().count); // 180 1 97 + case 104: arg5 = stack.pop() // 54 5 + case 106: stack.push(arg5); // 21 5 + case 108: arg5 += 255; // 132 5 255 + case 111: if (stack.pop() == 0) { gt = 136; continue; } // 153 0 25 + case 114: stack.push(arg2); // 44 + case 115: stack.push(arg3); // 29 + case 116: arg3++; // 132 3 1 + case 119: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 120: stack.push(arg1); // 43 + case 121: stack.push(arg4); // 21 4 + case 123: arg4++; // 132 4 1 + case 126: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.charAtCI(self, v0)); } // 185 1 189 + case 129: // 2 + case 130: // 0 + case 131: if (stack.pop() == stack.pop()) { gt = 106; continue; } // 159 255 231 + case 134: stack.push(0); // 3 + case 135: return stack.pop(); // 172 + case 136: stack.push(1); // 4 + case 137: return stack.pop(); // 172 + } +} +function java_lang_String_equalsIgnoreCaseZLjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(6); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: // 166 + case 3: // 0 + case 4: stack.push(4); // 7 + case 5: stack.push(1); // 4 + case 6: gt = 44; continue; // 167 0 38 + case 9: stack.push(arg1); // 43 + case 10: if (!stack.pop()) { gt = 43; continue; } // 198 0 33 + case 13: stack.push(arg1); // 43 + case 14: stack.push(stack.pop().count); // 180 1 97 + case 17: stack.push(arg0); // 42 + case 18: stack.push(stack.pop().count); // 180 1 97 + case 21: if (stack.pop() != stack.pop()) { gt = 43; continue; } // 160 0 22 + case 24: stack.push(arg0); // 42 + case 25: stack.push(1); // 4 + case 26: stack.push(0); // 3 + case 27: stack.push(arg1); // 43 + case 28: stack.push(0); // 3 + case 29: stack.push(arg0); // 42 + case 30: stack.push(stack.pop().count); // 180 1 97 + case 33: { var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.regionMatchesZZILjava_lang_StringII(self, v0, v1, v2, v3, v4)); } // 182 1 153 + case 36: if (stack.pop() == 0) { gt = 43; continue; } // 153 0 7 + case 39: stack.push(1); // 4 + case 40: gt = 44; continue; // 167 0 4 + case 43: stack.push(0); // 3 + case 44: return stack.pop(); // 172 + } +} +function java_lang_String_compareToILjava_lang_String(arg0,arg1) { + var arg2; + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; + var arg9; + var arg10; + var arg11; + var arg12; + var arg13; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().count); // 180 1 97 + case 4: arg2 = stack.pop(); // 61 + case 5: stack.push(arg1); // 43 + case 6: stack.push(stack.pop().count); // 180 1 97 + case 9: arg3 = stack.pop(); // 62 + case 10: stack.push(arg2); // 28 + case 11: stack.push(arg3); // 29 + case 12: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Math_minIII(v0, v1)); } // 184 1 127 + case 15: arg4 = stack.pop() // 54 4 + case 17: stack.push(arg0); // 42 + case 18: stack.push(stack.pop().value); // 180 1 100 + case 21: arg5 = stack.pop() // 58 5 + case 23: stack.push(arg1); // 43 + case 24: stack.push(stack.pop().value); // 180 1 100 + case 27: arg6 = stack.pop() // 58 6 + case 29: stack.push(arg0); // 42 + case 30: stack.push(stack.pop().offset); // 180 1 99 + case 33: arg7 = stack.pop() // 54 7 + case 35: stack.push(arg1); // 43 + case 36: stack.push(stack.pop().offset); // 180 1 99 + case 39: arg8 = stack.pop() // 54 8 + case 41: stack.push(arg7); // 21 7 + case 43: stack.push(arg8); // 21 8 + case 45: if (stack.pop() != stack.pop()) { gt = 102; continue; } // 160 0 57 + case 48: stack.push(arg7); // 21 7 + case 50: arg9 = stack.pop() // 54 9 + case 52: stack.push(arg4); // 21 4 + case 54: stack.push(arg7); // 21 7 + case 56: stack.push(stack.pop() + stack.pop()); // 96 + case 57: arg10 = stack.pop() // 54 10 + case 59: stack.push(arg9); // 21 9 + case 61: stack.push(arg10); // 21 10 + case 63: if (stack.pop() <= stack.pop()) { gt = 99; continue; } // 162 0 36 + case 66: stack.push(arg5); // 25 5 + case 68: stack.push(arg9); // 21 9 + case 70: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 71: arg11 = stack.pop() // 54 11 + case 73: stack.push(arg6); // 25 6 + case 75: stack.push(arg9); // 21 9 + case 77: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 78: arg12 = stack.pop() // 54 12 + case 80: stack.push(arg11); // 21 11 + case 82: stack.push(arg12); // 21 12 + case 84: if (stack.pop() == stack.pop()) { gt = 93; continue; } // 159 0 9 + case 87: stack.push(arg11); // 21 11 + case 89: stack.push(arg12); // 21 12 + case 91: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 92: return stack.pop(); // 172 + case 93: arg9++; // 132 9 1 + case 96: gt = 59; continue; // 167 255 219 + case 99: gt = 146; continue; // 167 0 47 + case 102: stack.push(arg4); // 21 4 + case 104: arg4 += 255; // 132 4 255 + case 107: if (stack.pop() == 0) { gt = 146; continue; } // 153 0 39 + case 110: stack.push(arg5); // 25 5 + case 112: stack.push(arg7); // 21 7 + case 114: arg7++; // 132 7 1 + case 117: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 118: arg9 = stack.pop() // 54 9 + case 120: stack.push(arg6); // 25 6 + case 122: stack.push(arg8); // 21 8 + case 124: arg8++; // 132 8 1 + case 127: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 128: arg10 = stack.pop() // 54 10 + case 130: stack.push(arg9); // 21 9 + case 132: stack.push(arg10); // 21 10 + case 134: if (stack.pop() == stack.pop()) { gt = 143; continue; } // 159 0 9 + case 137: stack.push(arg9); // 21 9 + case 139: stack.push(arg10); // 21 10 + case 141: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 142: return stack.pop(); // 172 + case 143: gt = 102; continue; // 167 255 215 + case 146: stack.push(arg2); // 28 + case 147: stack.push(arg3); // 29 + case 148: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 149: return stack.pop(); // 172 + } +} +function java_lang_String_compareToIgnoreCaseILjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(java_lang_String_CASE_INSENSITIVE_ORDER); // 178 1 102 + case 3: stack.push(arg0); // 42 + case 4: stack.push(arg1); // 43 + case 5: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.compareILjava_lang_ObjectLjava_lang_Object(self, v0, v1)); } // 185 1 190 + case 8: stack.push(0); // 3 + case 9: // 0 + case 10: return stack.pop(); // 172 + } +} +function java_lang_String_regionMatchesZILjava_lang_StringII(arg0,arg1,arg2,arg3,arg4) { + var arg5; + var arg6; + var arg7; + var arg8; + var arg9; +; + var stack = new Array(6); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().value); // 180 1 100 + case 4: arg5 = stack.pop() // 58 5 + case 6: stack.push(arg0); // 42 + case 7: stack.push(stack.pop().offset); // 180 1 99 + case 10: stack.push(arg1); // 27 + case 11: stack.push(stack.pop() + stack.pop()); // 96 + case 12: arg6 = stack.pop() // 54 6 + case 14: stack.push(arg2); // 44 + case 15: stack.push(stack.pop().value); // 180 1 100 + case 18: arg7 = stack.pop() // 58 7 + case 20: stack.push(arg2); // 44 + case 21: stack.push(stack.pop().offset); // 180 1 99 + case 24: stack.push(arg3); // 29 + case 25: stack.push(stack.pop() + stack.pop()); // 96 + case 26: arg8 = stack.pop() // 54 8 + case 28: stack.push(arg3); // 29 + case 29: if (stack.pop() < 0) { gt = 66; continue; } // 155 0 37 + case 32: stack.push(arg1); // 27 + case 33: if (stack.pop() < 0) { gt = 66; continue; } // 155 0 33 + case 36: stack.push(arg1); // 27 + case 37: // number conversion // 133 + case 38: stack.push(arg0); // 42 + case 39: stack.push(stack.pop().count); // 180 1 97 + case 42: // number conversion // 133 + case 43: stack.push(arg4); // 21 4 + case 45: // number conversion // 133 + case 46: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101 + case 47: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148 + case 48: if (stack.pop() > 0) { gt = 66; continue; } // 157 0 18 + case 51: stack.push(arg3); // 29 + case 52: // number conversion // 133 + case 53: stack.push(arg2); // 44 + case 54: stack.push(stack.pop().count); // 180 1 97 + case 57: // number conversion // 133 + case 58: stack.push(arg4); // 21 4 + case 60: // number conversion // 133 + case 61: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101 + case 62: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148 + case 63: if (stack.pop() <= 0) { gt = 68; continue; } // 158 0 5 + case 66: stack.push(0); // 3 + case 67: return stack.pop(); // 172 + case 68: stack.push(arg4); // 21 4 + case 70: arg4 += 255; // 132 4 255 + case 73: if (stack.pop() <= 0) { gt = 97; continue; } // 158 0 24 + case 76: stack.push(arg5); // 25 5 + case 78: stack.push(arg6); // 21 6 + case 80: arg6++; // 132 6 1 + case 83: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 84: stack.push(arg7); // 25 7 + case 86: stack.push(arg8); // 21 8 + case 88: arg8++; // 132 8 1 + case 91: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 92: if (stack.pop() == stack.pop()) { gt = 68; continue; } // 159 255 232 + case 95: stack.push(0); // 3 + case 96: return stack.pop(); // 172 + case 97: stack.push(1); // 4 + case 98: return stack.pop(); // 172 + } +} +function java_lang_String_regionMatchesZZILjava_lang_StringII(arg0,arg1,arg2,arg3,arg4,arg5) { + var arg6; + var arg7; + var arg8; + var arg9; + var arg10; + var arg11; + var arg12; + var arg13; + var arg14; +; + var stack = new Array(6); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().value); // 180 1 100 + case 4: arg6 = stack.pop() // 58 6 + case 6: stack.push(arg0); // 42 + case 7: stack.push(stack.pop().offset); // 180 1 99 + case 10: stack.push(arg2); // 28 + case 11: stack.push(stack.pop() + stack.pop()); // 96 + case 12: arg7 = stack.pop() // 54 7 + case 14: stack.push(arg3); // 45 + case 15: stack.push(stack.pop().value); // 180 1 100 + case 18: arg8 = stack.pop() // 58 8 + case 20: stack.push(arg3); // 45 + case 21: stack.push(stack.pop().offset); // 180 1 99 + case 24: stack.push(arg4); // 21 4 + case 26: stack.push(stack.pop() + stack.pop()); // 96 + case 27: arg9 = stack.pop() // 54 9 + case 29: stack.push(arg4); // 21 4 + case 31: if (stack.pop() < 0) { gt = 69; continue; } // 155 0 38 + case 34: stack.push(arg2); // 28 + case 35: if (stack.pop() < 0) { gt = 69; continue; } // 155 0 34 + case 38: stack.push(arg2); // 28 + case 39: // number conversion // 133 + case 40: stack.push(arg0); // 42 + case 41: stack.push(stack.pop().count); // 180 1 97 + case 44: // number conversion // 133 + case 45: stack.push(arg5); // 21 5 + case 47: // number conversion // 133 + case 48: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101 + case 49: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148 + case 50: if (stack.pop() > 0) { gt = 69; continue; } // 157 0 19 + case 53: stack.push(arg4); // 21 4 + case 55: // number conversion // 133 + case 56: stack.push(arg3); // 45 + case 57: stack.push(stack.pop().count); // 180 1 97 + case 60: // number conversion // 133 + case 61: stack.push(arg5); // 21 5 + case 63: // number conversion // 133 + case 64: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101 + case 65: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148 + case 66: if (stack.pop() <= 0) { gt = 71; continue; } // 158 0 5 + case 69: stack.push(0); // 3 + case 70: return stack.pop(); // 172 + case 71: stack.push(arg5); // 21 5 + case 73: arg5 += 255; // 132 5 255 + case 76: if (stack.pop() <= 0) { gt = 155; continue; } // 158 0 79 + case 79: stack.push(arg6); // 25 6 + case 81: stack.push(arg7); // 21 7 + case 83: arg7++; // 132 7 1 + case 86: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 87: arg10 = stack.pop() // 54 10 + case 89: stack.push(arg8); // 25 8 + case 91: stack.push(arg9); // 21 9 + case 93: arg9++; // 132 9 1 + case 96: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 97: arg11 = stack.pop() // 54 11 + case 99: stack.push(arg10); // 21 10 + case 101: stack.push(arg11); // 21 11 + case 103: if (stack.pop() != stack.pop()) { gt = 109; continue; } // 160 0 6 + case 106: gt = 71; continue; // 167 255 221 + case 109: stack.push(arg1); // 27 + case 110: if (stack.pop() == 0) { gt = 153; continue; } // 153 0 43 + case 113: stack.push(arg10); // 21 10 + case 115: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseCC(v0)); } // 184 1 105 + case 118: arg12 = stack.pop() // 54 12 + case 120: stack.push(arg11); // 21 11 + case 122: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseCC(v0)); } // 184 1 105 + case 125: arg13 = stack.pop() // 54 13 + case 127: stack.push(arg12); // 21 12 + case 129: stack.push(arg13); // 21 13 + case 131: if (stack.pop() != stack.pop()) { gt = 137; continue; } // 160 0 6 + case 134: gt = 71; continue; // 167 255 193 + case 137: stack.push(arg12); // 21 12 + case 139: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseCC(v0)); } // 184 1 104 + case 142: stack.push(arg13); // 21 13 + case 144: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseCC(v0)); } // 184 1 104 + case 147: if (stack.pop() != stack.pop()) { gt = 153; continue; } // 160 0 6 + case 150: gt = 71; continue; // 167 255 177 + case 153: stack.push(0); // 3 + case 154: return stack.pop(); // 172 + case 155: stack.push(1); // 4 + case 156: return stack.pop(); // 172 + } +} +function java_lang_String_startsWithZLjava_lang_StringI(arg0,arg1,arg2) { + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().value); // 180 1 100 + case 4: arg3 = stack.pop(); // 78 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().offset); // 180 1 99 + case 9: stack.push(arg2); // 28 + case 10: stack.push(stack.pop() + stack.pop()); // 96 + case 11: arg4 = stack.pop() // 54 4 + case 13: stack.push(arg1); // 43 + case 14: stack.push(stack.pop().value); // 180 1 100 + case 17: arg5 = stack.pop() // 58 5 + case 19: stack.push(arg1); // 43 + case 20: stack.push(stack.pop().offset); // 180 1 99 + case 23: arg6 = stack.pop() // 54 6 + case 25: stack.push(arg1); // 43 + case 26: stack.push(stack.pop().count); // 180 1 97 + case 29: arg7 = stack.pop() // 54 7 + case 31: stack.push(arg2); // 28 + case 32: if (stack.pop() < 0) { gt = 46; continue; } // 155 0 14 + case 35: stack.push(arg2); // 28 + case 36: stack.push(arg0); // 42 + case 37: stack.push(stack.pop().count); // 180 1 97 + case 40: stack.push(arg7); // 21 7 + case 42: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 43: if (stack.pop() >= stack.pop()) { gt = 48; continue; } // 164 0 5 + case 46: stack.push(0); // 3 + case 47: return stack.pop(); // 172 + case 48: arg7 += 255; // 132 7 255 + case 51: stack.push(arg7); // 21 7 + case 53: if (stack.pop() < 0) { gt = 76; continue; } // 155 0 23 + case 56: stack.push(arg3); // 45 + case 57: stack.push(arg4); // 21 4 + case 59: arg4++; // 132 4 1 + case 62: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 63: stack.push(arg5); // 25 5 + case 65: stack.push(arg6); // 21 6 + case 67: arg6++; // 132 6 1 + case 70: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 71: if (stack.pop() == stack.pop()) { gt = 48; continue; } // 159 255 233 + case 74: stack.push(0); // 3 + case 75: return stack.pop(); // 172 + case 76: stack.push(1); // 4 + case 77: return stack.pop(); // 172 + } +} +function java_lang_String_startsWithZLjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(0); // 3 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.startsWithZLjava_lang_StringI(self, v0, v1)); } // 182 1 152 + case 6: return stack.pop(); // 172 + } +} +function java_lang_String_endsWithZLjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(arg0); // 42 + case 3: stack.push(stack.pop().count); // 180 1 97 + case 6: stack.push(arg1); // 43 + case 7: stack.push(stack.pop().count); // 180 1 97 + case 10: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 11: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.startsWithZLjava_lang_StringI(self, v0, v1)); } // 182 1 152 + case 14: return stack.pop(); // 172 + } +} +function java_lang_String_hashCodeI(arg0) { + var arg1; + var arg2; + var arg3; + var arg4; + var arg5; + var arg6; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().hash); // 180 1 98 + case 4: arg1 = stack.pop(); // 60 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().count); // 180 1 97 + case 9: arg2 = stack.pop(); // 61 + case 10: stack.push(arg1); // 27 + case 11: if (stack.pop() != 0) { gt = 62; continue; } // 154 0 51 + case 14: stack.push(arg2); // 28 + case 15: if (stack.pop() <= 0) { gt = 62; continue; } // 158 0 47 + case 18: stack.push(arg0); // 42 + case 19: stack.push(stack.pop().offset); // 180 1 99 + case 22: arg3 = stack.pop(); // 62 + case 23: stack.push(arg0); // 42 + case 24: stack.push(stack.pop().value); // 180 1 100 + case 27: arg4 = stack.pop() // 58 4 + case 29: stack.push(0); // 3 + case 30: arg5 = stack.pop() // 54 5 + case 32: stack.push(arg5); // 21 5 + case 34: stack.push(arg2); // 28 + case 35: if (stack.pop() <= stack.pop()) { gt = 57; continue; } // 162 0 22 + case 38: stack.push(31); // 16 31 + case 40: stack.push(arg1); // 27 + case 41: stack.push(stack.pop() * stack.pop()); // 104 + case 42: stack.push(arg4); // 25 4 + case 44: stack.push(arg3); // 29 + case 45: arg3++; // 132 3 1 + case 48: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 49: stack.push(stack.pop() + stack.pop()); // 96 + case 50: arg1 = stack.pop(); // 60 + case 51: arg5++; // 132 5 1 + case 54: gt = 32; continue; // 167 255 234 + case 57: stack.push(arg0); // 42 + case 58: stack.push(arg1); // 27 + case 59: { var v = stack.pop(); stack.pop().hash = v; } // 181 1 98 + case 62: stack.push(arg1); // 27 + case 63: return stack.pop(); // 172 + } +} +function java_lang_String_indexOfII(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 27 + case 2: stack.push(0); // 3 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.indexOfIII(self, v0, v1)); } // 182 1 135 + case 6: return stack.pop(); // 172 + } +} +function java_lang_String_indexOfIII(arg0,arg1,arg2) { + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().offset); // 180 1 99 + case 4: stack.push(arg0); // 42 + case 5: stack.push(stack.pop().count); // 180 1 97 + case 8: stack.push(stack.pop() + stack.pop()); // 96 + case 9: arg3 = stack.pop(); // 62 + case 10: stack.push(arg0); // 42 + case 11: stack.push(stack.pop().value); // 180 1 100 + case 14: arg4 = stack.pop() // 58 4 + case 16: stack.push(arg2); // 28 + case 17: if (stack.pop() >= 0) { gt = 25; continue; } // 156 0 8 + case 20: stack.push(0); // 3 + case 21: arg2 = stack.pop(); // 61 + case 22: gt = 35; continue; // 167 0 13 + case 25: stack.push(arg2); // 28 + case 26: stack.push(arg0); // 42 + case 27: stack.push(stack.pop().count); // 180 1 97 + case 30: if (stack.pop() > stack.pop()) { gt = 35; continue; } // 161 0 5 + case 33: // 2 + case 34: return stack.pop(); // 172 + case 35: stack.push(arg0); // 42 + case 36: stack.push(stack.pop().offset); // 180 1 99 + case 39: stack.push(arg2); // 28 + case 40: stack.push(stack.pop() + stack.pop()); // 96 + case 41: arg5 = stack.pop() // 54 5 + case 43: stack.push(arg1); // 27 + case 44: stack.push(65536); // 18 3 + case 46: if (stack.pop() <= stack.pop()) { gt = 80; continue; } // 162 0 34 + case 49: stack.push(arg5); // 21 5 + case 51: stack.push(arg3); // 29 + case 52: if (stack.pop() <= stack.pop()) { gt = 78; continue; } // 162 0 26 + case 55: stack.push(arg4); // 25 4 + case 57: stack.push(arg5); // 21 5 + case 59: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 60: stack.push(arg1); // 27 + case 61: if (stack.pop() != stack.pop()) { gt = 72; continue; } // 160 0 11 + case 64: stack.push(arg5); // 21 5 + case 66: stack.push(arg0); // 42 + case 67: stack.push(stack.pop().offset); // 180 1 99 + case 70: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 71: return stack.pop(); // 172 + case 72: arg5++; // 132 5 1 + case 75: gt = 49; continue; // 167 255 230 + case 78: // 2 + case 79: return stack.pop(); // 172 + case 80: stack.push(arg1); // 27 + case 81: stack.push(1114111); // 18 4 + case 83: if (stack.pop() < stack.pop()) { gt = 149; continue; } // 163 0 66 + case 86: stack.push(arg1); // 27 + case 87: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109 + case 90: arg6 = stack.pop() // 58 6 + case 92: stack.push(arg5); // 21 5 + case 94: stack.push(arg3); // 29 + case 95: if (stack.pop() <= stack.pop()) { gt = 149; continue; } // 162 0 54 + case 98: stack.push(arg4); // 25 4 + case 100: stack.push(arg5); // 21 5 + case 102: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 103: stack.push(arg6); // 25 6 + case 105: stack.push(0); // 3 + case 106: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 107: if (stack.pop() != stack.pop()) { gt = 143; continue; } // 160 0 36 + case 110: stack.push(arg5); // 21 5 + case 112: stack.push(1); // 4 + case 113: stack.push(stack.pop() + stack.pop()); // 96 + case 114: stack.push(arg3); // 29 + case 115: if (stack.pop() != stack.pop()) { gt = 121; continue; } // 160 0 6 + case 118: gt = 149; continue; // 167 0 31 + case 121: stack.push(arg4); // 25 4 + case 123: stack.push(arg5); // 21 5 + case 125: stack.push(1); // 4 + case 126: stack.push(stack.pop() + stack.pop()); // 96 + case 127: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 128: stack.push(arg6); // 25 6 + case 130: stack.push(1); // 4 + case 131: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 132: if (stack.pop() != stack.pop()) { gt = 143; continue; } // 160 0 11 + case 135: stack.push(arg5); // 21 5 + case 137: stack.push(arg0); // 42 + case 138: stack.push(stack.pop().offset); // 180 1 99 + case 141: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 142: return stack.pop(); // 172 + case 143: arg5++; // 132 5 1 + case 146: gt = 92; continue; // 167 255 202 + case 149: // 2 + case 150: return stack.pop(); // 172 + } +} +function java_lang_String_lastIndexOfII(arg0,arg1) { + var arg2; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 27 + case 2: stack.push(arg0); // 42 + case 3: stack.push(stack.pop().count); // 180 1 97 + case 6: stack.push(1); // 4 + case 7: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 8: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.lastIndexOfIII(self, v0, v1)); } // 182 1 136 + case 11: return stack.pop(); // 172 + } +} +function java_lang_String_lastIndexOfIII(arg0,arg1,arg2) { + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().offset); // 180 1 99 + case 4: arg3 = stack.pop(); // 62 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().value); // 180 1 100 + case 9: arg4 = stack.pop() // 58 4 + case 11: stack.push(arg0); // 42 + case 12: stack.push(stack.pop().offset); // 180 1 99 + case 15: stack.push(arg2); // 28 + case 16: stack.push(arg0); // 42 + case 17: stack.push(stack.pop().count); // 180 1 97 + case 20: if (stack.pop() > stack.pop()) { gt = 32; continue; } // 161 0 12 + case 23: stack.push(arg0); // 42 + case 24: stack.push(stack.pop().count); // 180 1 97 + case 27: stack.push(1); // 4 + case 28: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 29: gt = 33; continue; // 167 0 4 + case 32: stack.push(arg2); // 28 + case 33: stack.push(stack.pop() + stack.pop()); // 96 + case 34: arg5 = stack.pop() // 54 5 + case 36: stack.push(arg1); // 27 + case 37: stack.push(65536); // 18 3 + case 39: if (stack.pop() <= stack.pop()) { gt = 73; continue; } // 162 0 34 + case 42: stack.push(arg5); // 21 5 + case 44: stack.push(arg3); // 29 + case 45: if (stack.pop() > stack.pop()) { gt = 71; continue; } // 161 0 26 + case 48: stack.push(arg4); // 25 4 + case 50: stack.push(arg5); // 21 5 + case 52: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 53: stack.push(arg1); // 27 + case 54: if (stack.pop() != stack.pop()) { gt = 65; continue; } // 160 0 11 + case 57: stack.push(arg5); // 21 5 + case 59: stack.push(arg0); // 42 + case 60: stack.push(stack.pop().offset); // 180 1 99 + case 63: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 64: return stack.pop(); // 172 + case 65: arg5 += 255; // 132 5 255 + case 68: gt = 42; continue; // 167 255 230 + case 71: // 2 + case 72: return stack.pop(); // 172 + case 73: stack.push(arg0); // 42 + case 74: stack.push(stack.pop().offset); // 180 1 99 + case 77: stack.push(arg0); // 42 + case 78: stack.push(stack.pop().count); // 180 1 97 + case 81: stack.push(stack.pop() + stack.pop()); // 96 + case 82: arg6 = stack.pop() // 54 6 + case 84: stack.push(arg1); // 27 + case 85: stack.push(1114111); // 18 4 + case 87: if (stack.pop() < stack.pop()) { gt = 154; continue; } // 163 0 67 + case 90: stack.push(arg1); // 27 + case 91: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109 + case 94: arg7 = stack.pop() // 58 7 + case 96: stack.push(arg5); // 21 5 + case 98: stack.push(arg3); // 29 + case 99: if (stack.pop() > stack.pop()) { gt = 154; continue; } // 161 0 55 + case 102: stack.push(arg4); // 25 4 + case 104: stack.push(arg5); // 21 5 + case 106: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 107: stack.push(arg7); // 25 7 + case 109: stack.push(0); // 3 + case 110: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 111: if (stack.pop() != stack.pop()) { gt = 148; continue; } // 160 0 37 + case 114: stack.push(arg5); // 21 5 + case 116: stack.push(1); // 4 + case 117: stack.push(stack.pop() + stack.pop()); // 96 + case 118: stack.push(arg6); // 21 6 + case 120: if (stack.pop() != stack.pop()) { gt = 126; continue; } // 160 0 6 + case 123: gt = 154; continue; // 167 0 31 + case 126: stack.push(arg4); // 25 4 + case 128: stack.push(arg5); // 21 5 + case 130: stack.push(1); // 4 + case 131: stack.push(stack.pop() + stack.pop()); // 96 + case 132: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 133: stack.push(arg7); // 25 7 + case 135: stack.push(1); // 4 + case 136: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 137: if (stack.pop() != stack.pop()) { gt = 148; continue; } // 160 0 11 + case 140: stack.push(arg5); // 21 5 + case 142: stack.push(arg0); // 42 + case 143: stack.push(stack.pop().offset); // 180 1 99 + case 146: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 147: return stack.pop(); // 172 + case 148: arg5 += 255; // 132 5 255 + case 151: gt = 96; continue; // 167 255 201 + case 154: // 2 + case 155: return stack.pop(); // 172 + } +} +function java_lang_String_indexOfILjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(0); // 3 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.indexOfILjava_lang_StringI(self, v0, v1)); } // 182 1 150 + case 6: return stack.pop(); // 172 + } +} +function java_lang_String_indexOfILjava_lang_StringI(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(7); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().value); // 180 1 100 + case 4: stack.push(arg0); // 42 + case 5: stack.push(stack.pop().offset); // 180 1 99 + case 8: stack.push(arg0); // 42 + case 9: stack.push(stack.pop().count); // 180 1 97 + case 12: stack.push(arg1); // 43 + case 13: stack.push(stack.pop().value); // 180 1 100 + case 16: stack.push(arg1); // 43 + case 17: stack.push(stack.pop().offset); // 180 1 99 + case 20: stack.push(arg1); // 43 + case 21: stack.push(stack.pop().count); // 180 1 97 + case 24: stack.push(arg2); // 28 + case 25: { var v6 = stack.pop(); var v5 = stack.pop(); var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_String_indexOfAIACAIAIACAIAIAI(v0, v1, v2, v3, v4, v5, v6)); } // 184 1 144 + case 28: return stack.pop(); // 172 + } +} +function java_lang_String_indexOfIACIIACIII(arg0,arg1,arg2,arg3,arg4,arg5,arg6) { + var arg7; + var arg8; + var arg9; + var arg10; + var arg11; + var arg12; + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg6); // 21 6 + case 2: stack.push(arg2); // 28 + case 3: if (stack.pop() > stack.pop()) { gt = 17; continue; } // 161 0 14 + case 6: stack.push(arg5); // 21 5 + case 8: if (stack.pop() != 0) { gt = 15; continue; } // 154 0 7 + case 11: stack.push(arg2); // 28 + case 12: gt = 16; continue; // 167 0 4 + case 15: // 2 + case 16: return stack.pop(); // 172 + case 17: stack.push(arg6); // 21 6 + case 19: if (stack.pop() >= 0) { gt = 25; continue; } // 156 0 6 + case 22: stack.push(0); // 3 + case 23: arg6 = stack.pop() // 54 6 + case 25: stack.push(arg5); // 21 5 + case 27: if (stack.pop() != 0) { gt = 33; continue; } // 154 0 6 + case 30: stack.push(arg6); // 21 6 + case 32: return stack.pop(); // 172 + case 33: stack.push(arg3); // 45 + case 34: stack.push(arg4); // 21 4 + case 36: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 37: arg7 = stack.pop() // 54 7 + case 39: stack.push(arg1); // 27 + case 40: stack.push(arg2); // 28 + case 41: stack.push(arg5); // 21 5 + case 43: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 44: stack.push(stack.pop() + stack.pop()); // 96 + case 45: arg8 = stack.pop() // 54 8 + case 47: stack.push(arg1); // 27 + case 48: stack.push(arg6); // 21 6 + case 50: stack.push(stack.pop() + stack.pop()); // 96 + case 51: arg9 = stack.pop() // 54 9 + case 53: stack.push(arg9); // 21 9 + case 55: stack.push(arg8); // 21 8 + case 57: if (stack.pop() < stack.pop()) { gt = 164; continue; } // 163 0 107 + case 60: stack.push(arg0); // 42 + case 61: stack.push(arg9); // 21 9 + case 63: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 64: stack.push(arg7); // 21 7 + case 66: if (stack.pop() == stack.pop()) { gt = 91; continue; } // 159 0 25 + case 69: arg9++; // 132 9 1 + case 72: stack.push(arg9); // 21 9 + case 74: stack.push(arg8); // 21 8 + case 76: if (stack.pop() < stack.pop()) { gt = 91; continue; } // 163 0 15 + case 79: stack.push(arg0); // 42 + case 80: stack.push(arg9); // 21 9 + case 82: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 83: stack.push(arg7); // 21 7 + case 85: if (stack.pop() == stack.pop()) { gt = 91; continue; } // 159 0 6 + case 88: gt = 69; continue; // 167 255 237 + case 91: stack.push(arg9); // 21 9 + case 93: stack.push(arg8); // 21 8 + case 95: if (stack.pop() < stack.pop()) { gt = 158; continue; } // 163 0 63 + case 98: stack.push(arg9); // 21 9 + case 100: stack.push(1); // 4 + case 101: stack.push(stack.pop() + stack.pop()); // 96 + case 102: arg10 = stack.pop() // 54 10 + case 104: stack.push(arg10); // 21 10 + case 106: stack.push(arg5); // 21 5 + case 108: stack.push(stack.pop() + stack.pop()); // 96 + case 109: stack.push(1); // 4 + case 110: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 111: arg11 = stack.pop() // 54 11 + case 113: stack.push(arg4); // 21 4 + case 115: stack.push(1); // 4 + case 116: stack.push(stack.pop() + stack.pop()); // 96 + case 117: arg12 = stack.pop() // 54 12 + case 119: stack.push(arg10); // 21 10 + case 121: stack.push(arg11); // 21 11 + case 123: if (stack.pop() <= stack.pop()) { gt = 146; continue; } // 162 0 23 + case 126: stack.push(arg0); // 42 + case 127: stack.push(arg10); // 21 10 + case 129: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 130: stack.push(arg3); // 45 + case 131: stack.push(arg12); // 21 12 + case 133: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 134: if (stack.pop() != stack.pop()) { gt = 146; continue; } // 160 0 12 + case 137: arg10++; // 132 10 1 + case 140: arg12++; // 132 12 1 + case 143: gt = 119; continue; // 167 255 232 + case 146: stack.push(arg10); // 21 10 + case 148: stack.push(arg11); // 21 11 + case 150: if (stack.pop() != stack.pop()) { gt = 158; continue; } // 160 0 8 + case 153: stack.push(arg9); // 21 9 + case 155: stack.push(arg1); // 27 + case 156: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 157: return stack.pop(); // 172 + case 158: arg9++; // 132 9 1 + case 161: gt = 53; continue; // 167 255 148 + case 164: // 2 + case 165: return stack.pop(); // 172 + } +} +function java_lang_String_lastIndexOfILjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(arg0); // 42 + case 3: stack.push(stack.pop().count); // 180 1 97 + case 6: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.lastIndexOfILjava_lang_StringI(self, v0, v1)); } // 182 1 151 + case 9: return stack.pop(); // 172 + } +} +function java_lang_String_lastIndexOfILjava_lang_StringI(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(7); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().value); // 180 1 100 + case 4: stack.push(arg0); // 42 + case 5: stack.push(stack.pop().offset); // 180 1 99 + case 8: stack.push(arg0); // 42 + case 9: stack.push(stack.pop().count); // 180 1 97 + case 12: stack.push(arg1); // 43 + case 13: stack.push(stack.pop().value); // 180 1 100 + case 16: stack.push(arg1); // 43 + case 17: stack.push(stack.pop().offset); // 180 1 99 + case 20: stack.push(arg1); // 43 + case 21: stack.push(stack.pop().count); // 180 1 97 + case 24: stack.push(arg2); // 28 + case 25: { var v6 = stack.pop(); var v5 = stack.pop(); var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_String_lastIndexOfAIACAIAIACAIAIAI(v0, v1, v2, v3, v4, v5, v6)); } // 184 1 145 + case 28: return stack.pop(); // 172 + } +} +function java_lang_String_lastIndexOfIACIIACIII(arg0,arg1,arg2,arg3,arg4,arg5,arg6) { + var arg7; + var arg8; + var arg9; + var arg10; + var arg11; + var arg12; + var arg13; + var arg14; + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg2); // 28 + case 1: stack.push(arg5); // 21 5 + case 3: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 4: arg7 = stack.pop() // 54 7 + case 6: stack.push(arg6); // 21 6 + case 8: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 5 + case 11: // 2 + case 12: return stack.pop(); // 172 + case 13: stack.push(arg6); // 21 6 + case 15: stack.push(arg7); // 21 7 + case 17: if (stack.pop() >= stack.pop()) { gt = 24; continue; } // 164 0 7 + case 20: stack.push(arg7); // 21 7 + case 22: arg6 = stack.pop() // 54 6 + case 24: stack.push(arg5); // 21 5 + case 26: if (stack.pop() != 0) { gt = 32; continue; } // 154 0 6 + case 29: stack.push(arg6); // 21 6 + case 31: return stack.pop(); // 172 + case 32: stack.push(arg4); // 21 4 + case 34: stack.push(arg5); // 21 5 + case 36: stack.push(stack.pop() + stack.pop()); // 96 + case 37: stack.push(1); // 4 + case 38: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 39: arg8 = stack.pop() // 54 8 + case 41: stack.push(arg3); // 45 + case 42: stack.push(arg8); // 21 8 + case 44: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 45: arg9 = stack.pop() // 54 9 + case 47: stack.push(arg1); // 27 + case 48: stack.push(arg5); // 21 5 + case 50: stack.push(stack.pop() + stack.pop()); // 96 + case 51: stack.push(1); // 4 + case 52: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 53: arg10 = stack.pop() // 54 10 + case 55: stack.push(arg10); // 21 10 + case 57: stack.push(arg6); // 21 6 + case 59: stack.push(stack.pop() + stack.pop()); // 96 + case 60: arg11 = stack.pop() // 54 11 + case 62: stack.push(arg11); // 21 11 + case 64: stack.push(arg10); // 21 10 + case 66: if (stack.pop() > stack.pop()) { gt = 84; continue; } // 161 0 18 + case 69: stack.push(arg0); // 42 + case 70: stack.push(arg11); // 21 11 + case 72: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 73: stack.push(arg9); // 21 9 + case 75: if (stack.pop() == stack.pop()) { gt = 84; continue; } // 159 0 9 + case 78: arg11 += 255; // 132 11 255 + case 81: gt = 62; continue; // 167 255 237 + case 84: stack.push(arg11); // 21 11 + case 86: stack.push(arg10); // 21 10 + case 88: if (stack.pop() <= stack.pop()) { gt = 93; continue; } // 162 0 5 + case 91: // 2 + case 92: return stack.pop(); // 172 + case 93: stack.push(arg11); // 21 11 + case 95: stack.push(1); // 4 + case 96: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 97: arg12 = stack.pop() // 54 12 + case 99: stack.push(arg12); // 21 12 + case 101: stack.push(arg5); // 21 5 + case 103: stack.push(1); // 4 + case 104: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 105: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 106: arg13 = stack.pop() // 54 13 + case 108: stack.push(arg8); // 21 8 + case 110: stack.push(1); // 4 + case 111: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 112: arg14 = stack.pop() // 54 14 + case 114: stack.push(arg12); // 21 12 + case 116: stack.push(arg13); // 21 13 + case 118: if (stack.pop() >= stack.pop()) { gt = 144; continue; } // 164 0 26 + case 121: stack.push(arg0); // 42 + case 122: stack.push(arg12); // 21 12 + case 124: arg12 += 255; // 132 12 255 + case 127: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 128: stack.push(arg3); // 45 + case 129: stack.push(arg14); // 21 14 + case 131: arg14 += 255; // 132 14 255 + case 134: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 135: if (stack.pop() == stack.pop()) { gt = 114; continue; } // 159 255 235 + case 138: arg11 += 255; // 132 11 255 + case 141: gt = 62; continue; // 167 255 177 + case 144: stack.push(arg13); // 21 13 + case 146: stack.push(arg1); // 27 + case 147: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 148: stack.push(1); // 4 + case 149: stack.push(stack.pop() + stack.pop()); // 96 + case 150: return stack.pop(); // 172 + } +} +function java_lang_String_substringLjava_lang_StringI(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 27 + case 2: stack.push(arg0); // 42 + case 3: stack.push(stack.pop().count); // 180 1 97 + case 6: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.substringLjava_lang_StringII(self, v0, v1)); } // 182 1 147 + case 9: return stack.pop(); // 176 + } +} +function java_lang_String_substringLjava_lang_StringII(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 12 + case 4: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 7: stack.push(stack[stack.length - 1]); // 89 + case 8: stack.push(arg1); // 27 + case 9: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 12: // 191 + case 13: stack.push(arg2); // 28 + case 14: stack.push(arg0); // 42 + case 15: stack.push(stack.pop().count); // 180 1 97 + case 18: if (stack.pop() >= stack.pop()) { gt = 30; continue; } // 164 0 12 + case 21: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 24: stack.push(stack[stack.length - 1]); // 89 + case 25: stack.push(arg2); // 28 + case 26: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 29: // 191 + case 30: stack.push(arg1); // 27 + case 31: stack.push(arg2); // 28 + case 32: if (stack.pop() >= stack.pop()) { gt = 46; continue; } // 164 0 14 + case 35: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 38: stack.push(stack[stack.length - 1]); // 89 + case 39: stack.push(arg2); // 28 + case 40: stack.push(arg1); // 27 + case 41: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 42: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 45: // 191 + case 46: stack.push(arg1); // 27 + case 47: if (stack.pop() != 0) { gt = 62; continue; } // 154 0 15 + case 50: stack.push(arg2); // 28 + case 51: stack.push(arg0); // 42 + case 52: stack.push(stack.pop().count); // 180 1 97 + case 55: if (stack.pop() != stack.pop()) { gt = 62; continue; } // 160 0 7 + case 58: stack.push(arg0); // 42 + case 59: gt = 82; continue; // 167 0 23 + case 62: stack.push(new java_lang_String); // 187 0 200 + case 65: stack.push(stack[stack.length - 1]); // 89 + case 66: stack.push(arg0); // 42 + case 67: stack.push(stack.pop().offset); // 180 1 99 + case 70: stack.push(arg1); // 27 + case 71: stack.push(stack.pop() + stack.pop()); // 96 + case 72: stack.push(arg2); // 28 + case 73: stack.push(arg1); // 27 + case 74: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 75: stack.push(arg0); // 42 + case 76: stack.push(stack.pop().value); // 180 1 100 + case 79: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVIIAC(stack.pop(), v0, v1, v2); } // 183 1 137 + case 82: return stack.pop(); // 176 + } +} +function java_lang_String_subSequenceLjava_lang_CharSequenceII(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 27 + case 2: stack.push(arg2); // 28 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.substringLjava_lang_StringII(self, v0, v1)); } // 182 1 147 + case 6: return stack.pop(); // 176 + } +} +function java_lang_String_concatLjava_lang_StringLjava_lang_String(arg0,arg1) { + var arg2; + var arg3; + var arg4; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: { var self = stack.pop(); stack.push(self.lengthI(self)); } // 182 1 133 + case 4: arg2 = stack.pop(); // 61 + case 5: stack.push(arg2); // 28 + case 6: if (stack.pop() != 0) { gt = 11; continue; } // 154 0 5 + case 9: stack.push(arg0); // 42 + case 10: return stack.pop(); // 176 + case 11: stack.push(arg0); // 42 + case 12: stack.push(stack.pop().count); // 180 1 97 + case 15: stack.push(arg2); // 28 + case 16: stack.push(stack.pop() + stack.pop()); // 96 + case 17: stack.push(new Array(stack.pop())); // 188 5 + case 19: arg3 = stack.pop(); // 78 + case 20: stack.push(arg0); // 42 + case 21: stack.push(0); // 3 + case 22: stack.push(arg0); // 42 + case 23: stack.push(stack.pop().count); // 180 1 97 + case 26: stack.push(arg3); // 45 + case 27: stack.push(0); // 3 + case 28: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); self.getCharsVIIACAI(self, v0, v1, v2, v3); } // 182 1 138 + case 31: stack.push(arg1); // 43 + case 32: stack.push(0); // 3 + case 33: stack.push(arg2); // 28 + case 34: stack.push(arg3); // 45 + case 35: stack.push(arg0); // 42 + case 36: stack.push(stack.pop().count); // 180 1 97 + case 39: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); self.getCharsVIIACAI(self, v0, v1, v2, v3); } // 182 1 138 + case 42: stack.push(new java_lang_String); // 187 0 200 + case 45: stack.push(stack[stack.length - 1]); // 89 + case 46: stack.push(0); // 3 + case 47: stack.push(arg0); // 42 + case 48: stack.push(stack.pop().count); // 180 1 97 + case 51: stack.push(arg2); // 28 + case 52: stack.push(stack.pop() + stack.pop()); // 96 + case 53: stack.push(arg3); // 45 + case 54: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVIIAC(stack.pop(), v0, v1, v2); } // 183 1 137 + case 57: return stack.pop(); // 176 + } +} +function java_lang_String_replaceLjava_lang_StringCC(arg0,arg1,arg2) { + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; + var arg9; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: stack.push(arg2); // 28 + case 2: if (stack.pop() == stack.pop()) { gt = 140; continue; } // 159 0 138 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().count); // 180 1 97 + case 9: arg3 = stack.pop(); // 62 + case 10: // 2 + case 11: arg4 = stack.pop() // 54 4 + case 13: stack.push(arg0); // 42 + case 14: stack.push(stack.pop().value); // 180 1 100 + case 17: arg5 = stack.pop() // 58 5 + case 19: stack.push(arg0); // 42 + case 20: stack.push(stack.pop().offset); // 180 1 99 + case 23: arg6 = stack.pop() // 54 6 + case 25: arg4++; // 132 4 1 + case 28: stack.push(arg4); // 21 4 + case 30: stack.push(arg3); // 29 + case 31: if (stack.pop() <= stack.pop()) { gt = 49; continue; } // 162 0 18 + case 34: stack.push(arg5); // 25 5 + case 36: stack.push(arg6); // 21 6 + case 38: stack.push(arg4); // 21 4 + case 40: stack.push(stack.pop() + stack.pop()); // 96 + case 41: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 42: stack.push(arg1); // 27 + case 43: if (stack.pop() != stack.pop()) { gt = 25; continue; } // 160 255 238 + case 46: gt = 49; continue; // 167 0 3 + case 49: stack.push(arg4); // 21 4 + case 51: stack.push(arg3); // 29 + case 52: if (stack.pop() <= stack.pop()) { gt = 140; continue; } // 162 0 88 + case 55: stack.push(arg3); // 29 + case 56: stack.push(new Array(stack.pop())); // 188 5 + case 58: arg7 = stack.pop() // 58 7 + case 60: stack.push(0); // 3 + case 61: arg8 = stack.pop() // 54 8 + case 63: stack.push(arg8); // 21 8 + case 65: stack.push(arg4); // 21 4 + case 67: if (stack.pop() <= stack.pop()) { gt = 89; continue; } // 162 0 22 + case 70: stack.push(arg7); // 25 7 + case 72: stack.push(arg8); // 21 8 + case 74: stack.push(arg5); // 25 5 + case 76: stack.push(arg6); // 21 6 + case 78: stack.push(arg8); // 21 8 + case 80: stack.push(stack.pop() + stack.pop()); // 96 + case 81: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 82: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 83: arg8++; // 132 8 1 + case 86: gt = 63; continue; // 167 255 233 + case 89: stack.push(arg4); // 21 4 + case 91: stack.push(arg3); // 29 + case 92: if (stack.pop() <= stack.pop()) { gt = 128; continue; } // 162 0 36 + case 95: stack.push(arg5); // 25 5 + case 97: stack.push(arg6); // 21 6 + case 99: stack.push(arg4); // 21 4 + case 101: stack.push(stack.pop() + stack.pop()); // 96 + case 102: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 103: arg8 = stack.pop() // 54 8 + case 105: stack.push(arg7); // 25 7 + case 107: stack.push(arg4); // 21 4 + case 109: stack.push(arg8); // 21 8 + case 111: stack.push(arg1); // 27 + case 112: if (stack.pop() != stack.pop()) { gt = 119; continue; } // 160 0 7 + case 115: stack.push(arg2); // 28 + case 116: gt = 121; continue; // 167 0 5 + case 119: stack.push(arg8); // 21 8 + case 121: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 122: arg4++; // 132 4 1 + case 125: gt = 89; continue; // 167 255 220 + case 128: stack.push(new java_lang_String); // 187 0 200 + case 131: stack.push(stack[stack.length - 1]); // 89 + case 132: stack.push(0); // 3 + case 133: stack.push(arg3); // 29 + case 134: stack.push(arg7); // 25 7 + case 136: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVIIAC(stack.pop(), v0, v1, v2); } // 183 1 137 + case 139: return stack.pop(); // 176 + case 140: stack.push(arg0); // 42 + case 141: return stack.pop(); // 176 + } +} +function java_lang_String_matchesZLjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: stack.push(arg0); // 42 + case 2: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_util_regex_Pattern_matchesZLjava_lang_StringLjava_lang_CharSequence(v0, v1)); } // 184 1 183 + case 5: return stack.pop(); // 172 + } +} +function java_lang_String_containsZLjava_lang_CharSequence(arg0,arg1) { + var arg2; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.indexOfILjava_lang_String(self, v0)); } // 182 1 149 + case 8: // 2 + case 9: if (stack.pop() >= stack.pop()) { gt = 16; continue; } // 164 0 7 + case 12: stack.push(1); // 4 + case 13: gt = 17; continue; // 167 0 4 + case 16: stack.push(0); // 3 + case 17: return stack.pop(); // 172 + } +} +function java_lang_String_replaceFirstLjava_lang_StringLjava_lang_StringLjava_lang_String(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: { var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_String(v0)); } // 184 1 186 + case 4: stack.push(arg0); // 42 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.matcherLjava_util_regex_MatcherLjava_lang_CharSequence(self, v0)); } // 182 1 185 + case 8: stack.push(arg2); // 44 + case 9: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.replaceFirstLjava_lang_StringLjava_lang_String(self, v0)); } // 182 1 182 + case 12: return stack.pop(); // 176 + } +} +function java_lang_String_replaceAllLjava_lang_StringLjava_lang_StringLjava_lang_String(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: { var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_String(v0)); } // 184 1 186 + case 4: stack.push(arg0); // 42 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.matcherLjava_util_regex_MatcherLjava_lang_CharSequence(self, v0)); } // 182 1 185 + case 8: stack.push(arg2); // 44 + case 9: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.replaceAllLjava_lang_StringLjava_lang_String(self, v0)); } // 182 1 181 + case 12: return stack.pop(); // 176 + } +} +function java_lang_String_replaceLjava_lang_StringLjava_lang_CharSequenceLjava_lang_CharSequence(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132 + case 4: stack.push(16); // 16 16 + case 6: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_StringI(v0, v1)); } // 184 1 187 + case 9: stack.push(arg0); // 42 + case 10: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.matcherLjava_util_regex_MatcherLjava_lang_CharSequence(self, v0)); } // 182 1 185 + case 13: stack.push(arg2); // 44 + case 14: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132 + case 17: { var v0 = stack.pop(); stack.push(java_util_regex_Matcher_quoteReplacementLjava_lang_StringLjava_lang_String(v0)); } // 184 1 180 + case 20: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.replaceAllLjava_lang_StringLjava_lang_String(self, v0)); } // 182 1 181 + case 23: return stack.pop(); // 176 + } +} +function java_lang_String_splitALjava_lang_StringLjava_lang_StringI(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: { var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_String(v0)); } // 184 1 186 + case 4: stack.push(arg0); // 42 + case 5: stack.push(arg2); // 28 + case 6: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.splitALjava_lang_StringLjava_lang_CharSequenceI(self, v0, v1)); } // 182 1 184 + case 9: return stack.pop(); // 176 + } +} +function java_lang_String_splitALjava_lang_StringLjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(0); // 3 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.splitALjava_lang_StringLjava_lang_StringI(self, v0, v1)); } // 182 1 157 + case 6: return stack.pop(); // 176 + } +} +function java_lang_String_toLowerCaseLjava_lang_StringLjava_util_Locale(arg0,arg1) { + var arg2; + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; + var arg9; + var arg10; + var arg11; + var arg12; + var arg13; + var arg14; +; + var stack = new Array(6); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198 + case 7: stack.push(stack[stack.length - 1]); // 89 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128 + case 11: // 191 + case 12: stack.push(0); // 3 + case 13: arg2 = stack.pop(); // 61 + case 14: stack.push(arg2); // 28 + case 15: stack.push(arg0); // 42 + case 16: stack.push(stack.pop().count); // 180 1 97 + case 19: if (stack.pop() <= stack.pop()) { gt = 94; continue; } // 162 0 75 + case 22: stack.push(arg0); // 42 + case 23: stack.push(stack.pop().value); // 180 1 100 + case 26: stack.push(arg0); // 42 + case 27: stack.push(stack.pop().offset); // 180 1 99 + case 30: stack.push(arg2); // 28 + case 31: stack.push(stack.pop() + stack.pop()); // 96 + case 32: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 33: arg3 = stack.pop(); // 62 + case 34: stack.push(arg3); // 29 + case 35: stack.push(55296); // 18 1 + case 37: if (stack.pop() > stack.pop()) { gt = 77; continue; } // 161 0 40 + case 40: stack.push(arg3); // 29 + case 41: stack.push(56319); // 18 2 + case 43: if (stack.pop() < stack.pop()) { gt = 77; continue; } // 163 0 34 + case 46: stack.push(arg0); // 42 + case 47: stack.push(arg2); // 28 + case 48: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134 + case 51: arg4 = stack.pop() // 54 4 + case 53: stack.push(arg4); // 21 4 + case 55: stack.push(arg4); // 21 4 + case 57: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseII(v0)); } // 184 1 107 + case 60: if (stack.pop() == stack.pop()) { gt = 66; continue; } // 159 0 6 + case 63: gt = 96; continue; // 167 0 33 + case 66: stack.push(arg2); // 28 + case 67: stack.push(arg4); // 21 4 + case 69: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106 + case 72: stack.push(stack.pop() + stack.pop()); // 96 + case 73: arg2 = stack.pop(); // 61 + case 74: gt = 91; continue; // 167 0 17 + case 77: stack.push(arg3); // 29 + case 78: stack.push(arg3); // 29 + case 79: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseCC(v0)); } // 184 1 104 + case 82: if (stack.pop() == stack.pop()) { gt = 88; continue; } // 159 0 6 + case 85: gt = 96; continue; // 167 0 11 + case 88: arg2++; // 132 2 1 + case 91: gt = 14; continue; // 167 255 179 + case 94: stack.push(arg0); // 42 + case 95: return stack.pop(); // 176 + case 96: stack.push(arg0); // 42 + case 97: stack.push(stack.pop().count); // 180 1 97 + case 100: stack.push(new Array(stack.pop())); // 188 5 + case 102: arg3 = stack.pop(); // 78 + case 103: stack.push(0); // 3 + case 104: arg4 = stack.pop() // 54 4 + case 106: stack.push(arg0); // 42 + case 107: stack.push(stack.pop().value); // 180 1 100 + case 110: stack.push(arg0); // 42 + case 111: stack.push(stack.pop().offset); // 180 1 99 + case 114: stack.push(arg3); // 45 + case 115: stack.push(0); // 3 + case 116: stack.push(arg2); // 28 + case 117: { var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_System_arraycopyVLjava_lang_ObjectILjava_lang_ObjectII(v0, v1, v2, v3, v4); } // 184 1 171 + case 120: stack.push(arg1); // 43 + case 121: { var self = stack.pop(); stack.push(self.getLanguageLjava_lang_String(self)); } // 182 1 178 + case 124: arg5 = stack.pop() // 58 5 + case 126: stack.push(arg5); // 25 5 + case 128: stack.push("tr"); // 18 11 + case 130: // 165 + case 131: // 0 + case 132: stack.push(6405); // 17 25 5 + case 135: stack.push("az"); // 18 5 + case 137: // 165 + case 138: // 0 + case 139: stack.push(1); // 10 + case 140: stack.push(arg5); // 25 5 + case 142: stack.push("lt"); // 18 9 + case 144: // 166 + case 145: // 0 + case 146: stack.push(4); // 7 + case 147: stack.push(1); // 4 + case 148: gt = 152; continue; // 167 0 4 + case 151: stack.push(0); // 3 + case 152: arg6 = stack.pop() // 54 6 + case 154: stack.push(arg2); // 28 + case 155: arg11 = stack.pop() // 54 11 + case 157: stack.push(arg11); // 21 11 + case 159: stack.push(arg0); // 42 + case 160: stack.push(stack.pop().count); // 180 1 97 + case 163: if (stack.pop() <= stack.pop()) { gt = 419; continue; } // 162 1 0 + case 166: stack.push(arg0); // 42 + case 167: stack.push(stack.pop().value); // 180 1 100 + case 170: stack.push(arg0); // 42 + case 171: stack.push(stack.pop().offset); // 180 1 99 + case 174: stack.push(arg11); // 21 11 + case 176: stack.push(stack.pop() + stack.pop()); // 96 + case 177: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 178: arg9 = stack.pop() // 54 9 + case 180: stack.push(arg9); // 21 9 + case 182: // number conversion // 146 + case 183: stack.push(55296); // 18 1 + case 185: if (stack.pop() > stack.pop()) { gt = 214; continue; } // 161 0 29 + case 188: stack.push(arg9); // 21 9 + case 190: // number conversion // 146 + case 191: stack.push(56319); // 18 2 + case 193: if (stack.pop() < stack.pop()) { gt = 214; continue; } // 163 0 21 + case 196: stack.push(arg0); // 42 + case 197: stack.push(arg11); // 21 11 + case 199: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134 + case 202: arg9 = stack.pop() // 54 9 + case 204: stack.push(arg9); // 21 9 + case 206: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106 + case 209: arg10 = stack.pop() // 54 10 + case 211: gt = 217; continue; // 167 0 6 + case 214: stack.push(1); // 4 + case 215: arg10 = stack.pop() // 54 10 + case 217: stack.push(arg6); // 21 6 + case 219: if (stack.pop() != 0) { gt = 230; continue; } // 154 0 11 + case 222: stack.push(arg9); // 21 9 + case 224: stack.push(931); // 17 3 163 + case 227: if (stack.pop() != stack.pop()) { gt = 242; continue; } // 160 0 15 + case 230: stack.push(arg0); // 42 + case 231: stack.push(arg11); // 21 11 + case 233: stack.push(arg1); // 43 + case 234: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_ConditionalSpecialCasing_toLowerCaseExILjava_lang_StringILjava_util_Locale(v0, v1, v2)); } // 184 1 117 + case 237: arg8 = stack.pop() // 54 8 + case 239: gt = 249; continue; // 167 0 10 + case 242: stack.push(arg9); // 21 9 + case 244: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseII(v0)); } // 184 1 107 + case 247: arg8 = stack.pop() // 54 8 + case 249: stack.push(arg8); // 21 8 + case 251: // 2 + case 252: if (stack.pop() == stack.pop()) { gt = 262; continue; } // 159 0 10 + case 255: stack.push(arg8); // 21 8 + case 257: stack.push(65536); // 18 3 + case 259: if (stack.pop() > stack.pop()) { gt = 399; continue; } // 161 0 140 + case 262: stack.push(arg8); // 21 8 + case 264: // 2 + case 265: if (stack.pop() != stack.pop()) { gt = 280; continue; } // 160 0 15 + case 268: stack.push(arg0); // 42 + case 269: stack.push(arg11); // 21 11 + case 271: stack.push(arg1); // 43 + case 272: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_ConditionalSpecialCasing_toLowerCaseCharArrayACLjava_lang_StringILjava_util_Locale(v0, v1, v2)); } // 184 1 119 + case 275: arg7 = stack.pop() // 58 7 + case 277: gt = 315; continue; // 167 0 38 + case 280: stack.push(arg10); // 21 10 + case 282: stack.push(2); // 5 + case 283: if (stack.pop() != stack.pop()) { gt = 308; continue; } // 160 0 25 + case 286: stack.push(arg4); // 21 4 + case 288: stack.push(arg8); // 21 8 + case 290: stack.push(arg3); // 45 + case 291: stack.push(arg11); // 21 11 + case 293: stack.push(arg4); // 21 4 + case 295: stack.push(stack.pop() + stack.pop()); // 96 + case 296: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Character_toCharsAIIACAI(v0, v1, v2)); } // 184 1 111 + case 299: stack.push(arg10); // 21 10 + case 301: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 302: stack.push(stack.pop() + stack.pop()); // 96 + case 303: arg4 = stack.pop() // 54 4 + case 305: gt = 409; continue; // 167 0 104 + case 308: stack.push(arg8); // 21 8 + case 310: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109 + case 313: arg7 = stack.pop() // 58 7 + case 315: stack.push(arg7); // 25 7 + case 317: stack.push(stack.pop().length); // 190 + case 318: arg12 = stack.pop() // 54 12 + case 320: stack.push(arg12); // 21 12 + case 322: stack.push(arg10); // 21 10 + case 324: if (stack.pop() >= stack.pop()) { gt = 355; continue; } // 164 0 31 + case 327: stack.push(arg3); // 45 + case 328: stack.push(stack.pop().length); // 190 + case 329: stack.push(arg12); // 21 12 + case 331: stack.push(stack.pop() + stack.pop()); // 96 + case 332: stack.push(arg10); // 21 10 + case 334: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 335: stack.push(new Array(stack.pop())); // 188 5 + case 337: arg13 = stack.pop() // 58 13 + case 339: stack.push(arg3); // 45 + case 340: stack.push(0); // 3 + case 341: stack.push(arg13); // 25 13 + case 343: stack.push(0); // 3 + case 344: stack.push(arg11); // 21 11 + case 346: stack.push(arg4); // 21 4 + case 348: stack.push(stack.pop() + stack.pop()); // 96 + case 349: { var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_System_arraycopyVLjava_lang_ObjectILjava_lang_ObjectII(v0, v1, v2, v3, v4); } // 184 1 171 + case 352: stack.push(arg13); // 25 13 + case 354: arg3 = stack.pop(); // 78 + case 355: stack.push(0); // 3 + case 356: arg13 = stack.pop() // 54 13 + case 358: stack.push(arg13); // 21 13 + case 360: stack.push(arg12); // 21 12 + case 362: if (stack.pop() <= stack.pop()) { gt = 386; continue; } // 162 0 24 + case 365: stack.push(arg3); // 45 + case 366: stack.push(arg11); // 21 11 + case 368: stack.push(arg4); // 21 4 + case 370: stack.push(stack.pop() + stack.pop()); // 96 + case 371: stack.push(arg13); // 21 13 + case 373: stack.push(stack.pop() + stack.pop()); // 96 + case 374: stack.push(arg7); // 25 7 + case 376: stack.push(arg13); // 21 13 + case 378: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 379: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 380: arg13++; // 132 13 1 + case 383: gt = 358; continue; // 167 255 231 + case 386: stack.push(arg4); // 21 4 + case 388: stack.push(arg12); // 21 12 + case 390: stack.push(arg10); // 21 10 + case 392: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 393: stack.push(stack.pop() + stack.pop()); // 96 + case 394: arg4 = stack.pop() // 54 4 + case 396: gt = 409; continue; // 167 0 13 + case 399: stack.push(arg3); // 45 + case 400: stack.push(arg11); // 21 11 + case 402: stack.push(arg4); // 21 4 + case 404: stack.push(stack.pop() + stack.pop()); // 96 + case 405: stack.push(arg8); // 21 8 + case 407: // number conversion // 146 + case 408: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 409: stack.push(arg11); // 21 11 + case 411: stack.push(arg10); // 21 10 + case 413: stack.push(stack.pop() + stack.pop()); // 96 + case 414: arg11 = stack.pop() // 54 11 + case 416: gt = 157; continue; // 167 254 253 + case 419: stack.push(new java_lang_String); // 187 0 200 + case 422: stack.push(stack[stack.length - 1]); // 89 + case 423: stack.push(0); // 3 + case 424: stack.push(arg0); // 42 + case 425: stack.push(stack.pop().count); // 180 1 97 + case 428: stack.push(arg4); // 21 4 + case 430: stack.push(stack.pop() + stack.pop()); // 96 + case 431: stack.push(arg3); // 45 + case 432: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVIIAC(stack.pop(), v0, v1, v2); } // 183 1 137 + case 435: return stack.pop(); // 176 + } +} +function java_lang_String_toLowerCaseLjava_lang_String(arg0) { + var arg1; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { stack.push(java_util_Locale_getDefaultLjava_util_Locale()); } // 184 1 179 + case 4: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.toLowerCaseLjava_lang_StringLjava_util_Locale(self, v0)); } // 182 1 158 + case 7: return stack.pop(); // 176 + } +} +function java_lang_String_toUpperCaseLjava_lang_StringLjava_util_Locale(arg0,arg1) { + var arg2; + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; + var arg9; + var arg10; + var arg11; + var arg12; + var arg13; + var arg14; +; + var stack = new Array(6); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198 + case 7: stack.push(stack[stack.length - 1]); // 89 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128 + case 11: // 191 + case 12: stack.push(0); // 3 + case 13: arg2 = stack.pop(); // 61 + case 14: stack.push(arg2); // 28 + case 15: stack.push(arg0); // 42 + case 16: stack.push(stack.pop().count); // 180 1 97 + case 19: if (stack.pop() <= stack.pop()) { gt = 93; continue; } // 162 0 74 + case 22: stack.push(arg0); // 42 + case 23: stack.push(stack.pop().value); // 180 1 100 + case 26: stack.push(arg0); // 42 + case 27: stack.push(stack.pop().offset); // 180 1 99 + case 30: stack.push(arg2); // 28 + case 31: stack.push(stack.pop() + stack.pop()); // 96 + case 32: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 33: arg3 = stack.pop(); // 62 + case 34: stack.push(arg3); // 29 + case 35: stack.push(55296); // 18 1 + case 37: if (stack.pop() > stack.pop()) { gt = 61; continue; } // 161 0 24 + case 40: stack.push(arg3); // 29 + case 41: stack.push(56319); // 18 2 + case 43: if (stack.pop() < stack.pop()) { gt = 61; continue; } // 163 0 18 + case 46: stack.push(arg0); // 42 + case 47: stack.push(arg2); // 28 + case 48: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134 + case 51: arg3 = stack.pop(); // 62 + case 52: stack.push(arg3); // 29 + case 53: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106 + case 56: arg4 = stack.pop() // 54 4 + case 58: gt = 64; continue; // 167 0 6 + case 61: stack.push(1); // 4 + case 62: arg4 = stack.pop() // 54 4 + case 64: stack.push(arg3); // 29 + case 65: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseExII(v0)); } // 184 1 108 + case 68: arg5 = stack.pop() // 54 5 + case 70: stack.push(arg5); // 21 5 + case 72: // 2 + case 73: if (stack.pop() == stack.pop()) { gt = 95; continue; } // 159 0 22 + case 76: stack.push(arg3); // 29 + case 77: stack.push(arg5); // 21 5 + case 79: if (stack.pop() == stack.pop()) { gt = 85; continue; } // 159 0 6 + case 82: gt = 95; continue; // 167 0 13 + case 85: stack.push(arg2); // 28 + case 86: stack.push(arg4); // 21 4 + case 88: stack.push(stack.pop() + stack.pop()); // 96 + case 89: arg2 = stack.pop(); // 61 + case 90: gt = 14; continue; // 167 255 180 + case 93: stack.push(arg0); // 42 + case 94: return stack.pop(); // 176 + case 95: stack.push(arg0); // 42 + case 96: stack.push(stack.pop().count); // 180 1 97 + case 99: stack.push(new Array(stack.pop())); // 188 5 + case 101: arg3 = stack.pop(); // 78 + case 102: stack.push(0); // 3 + case 103: arg4 = stack.pop() // 54 4 + case 105: stack.push(arg0); // 42 + case 106: stack.push(stack.pop().value); // 180 1 100 + case 109: stack.push(arg0); // 42 + case 110: stack.push(stack.pop().offset); // 180 1 99 + case 113: stack.push(arg3); // 45 + case 114: stack.push(0); // 3 + case 115: stack.push(arg2); // 28 + case 116: { var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_System_arraycopyVLjava_lang_ObjectILjava_lang_ObjectII(v0, v1, v2, v3, v4); } // 184 1 171 + case 119: stack.push(arg1); // 43 + case 120: { var self = stack.pop(); stack.push(self.getLanguageLjava_lang_String(self)); } // 182 1 178 + case 123: arg5 = stack.pop() // 58 5 + case 125: stack.push(arg5); // 25 5 + case 127: stack.push("tr"); // 18 11 + case 129: // 165 + case 130: // 0 + case 131: stack.push(6405); // 17 25 5 + case 134: stack.push("az"); // 18 5 + case 136: // 165 + case 137: // 0 + case 138: stack.push(1); // 10 + case 139: stack.push(arg5); // 25 5 + case 141: stack.push("lt"); // 18 9 + case 143: // 166 + case 144: // 0 + case 145: stack.push(4); // 7 + case 146: stack.push(1); // 4 + case 147: gt = 151; continue; // 167 0 4 + case 150: stack.push(0); // 3 + case 151: arg6 = stack.pop() // 54 6 + case 153: stack.push(arg2); // 28 + case 154: arg11 = stack.pop() // 54 11 + case 156: stack.push(arg11); // 21 11 + case 158: stack.push(arg0); // 42 + case 159: stack.push(stack.pop().count); // 180 1 97 + case 162: if (stack.pop() <= stack.pop()) { gt = 425; continue; } // 162 1 7 + case 165: stack.push(arg0); // 42 + case 166: stack.push(stack.pop().value); // 180 1 100 + case 169: stack.push(arg0); // 42 + case 170: stack.push(stack.pop().offset); // 180 1 99 + case 173: stack.push(arg11); // 21 11 + case 175: stack.push(stack.pop() + stack.pop()); // 96 + case 176: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 177: arg9 = stack.pop() // 54 9 + case 179: stack.push(arg9); // 21 9 + case 181: // number conversion // 146 + case 182: stack.push(55296); // 18 1 + case 184: if (stack.pop() > stack.pop()) { gt = 213; continue; } // 161 0 29 + case 187: stack.push(arg9); // 21 9 + case 189: // number conversion // 146 + case 190: stack.push(56319); // 18 2 + case 192: if (stack.pop() < stack.pop()) { gt = 213; continue; } // 163 0 21 + case 195: stack.push(arg0); // 42 + case 196: stack.push(arg11); // 21 11 + case 198: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134 + case 201: arg9 = stack.pop() // 54 9 + case 203: stack.push(arg9); // 21 9 + case 205: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106 + case 208: arg10 = stack.pop() // 54 10 + case 210: gt = 216; continue; // 167 0 6 + case 213: stack.push(1); // 4 + case 214: arg10 = stack.pop() // 54 10 + case 216: stack.push(arg6); // 21 6 + case 218: if (stack.pop() == 0) { gt = 233; continue; } // 153 0 15 + case 221: stack.push(arg0); // 42 + case 222: stack.push(arg11); // 21 11 + case 224: stack.push(arg1); // 43 + case 225: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_ConditionalSpecialCasing_toUpperCaseExILjava_lang_StringILjava_util_Locale(v0, v1, v2)); } // 184 1 118 + case 228: arg8 = stack.pop() // 54 8 + case 230: gt = 240; continue; // 167 0 10 + case 233: stack.push(arg9); // 21 9 + case 235: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseExII(v0)); } // 184 1 108 + case 238: arg8 = stack.pop() // 54 8 + case 240: stack.push(arg8); // 21 8 + case 242: // 2 + case 243: if (stack.pop() == stack.pop()) { gt = 253; continue; } // 159 0 10 + case 246: stack.push(arg8); // 21 8 + case 248: stack.push(65536); // 18 3 + case 250: if (stack.pop() > stack.pop()) { gt = 405; continue; } // 161 0 155 + case 253: stack.push(arg8); // 21 8 + case 255: // 2 + case 256: if (stack.pop() != stack.pop()) { gt = 286; continue; } // 160 0 30 + case 259: stack.push(arg6); // 21 6 + case 261: if (stack.pop() == 0) { gt = 276; continue; } // 153 0 15 + case 264: stack.push(arg0); // 42 + case 265: stack.push(arg11); // 21 11 + case 267: stack.push(arg1); // 43 + case 268: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_ConditionalSpecialCasing_toUpperCaseCharArrayACLjava_lang_StringILjava_util_Locale(v0, v1, v2)); } // 184 1 120 + case 271: arg7 = stack.pop() // 58 7 + case 273: gt = 321; continue; // 167 0 48 + case 276: stack.push(arg9); // 21 9 + case 278: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseCharArrayACI(v0)); } // 184 1 110 + case 281: arg7 = stack.pop() // 58 7 + case 283: gt = 321; continue; // 167 0 38 + case 286: stack.push(arg10); // 21 10 + case 288: stack.push(2); // 5 + case 289: if (stack.pop() != stack.pop()) { gt = 314; continue; } // 160 0 25 + case 292: stack.push(arg4); // 21 4 + case 294: stack.push(arg8); // 21 8 + case 296: stack.push(arg3); // 45 + case 297: stack.push(arg11); // 21 11 + case 299: stack.push(arg4); // 21 4 + case 301: stack.push(stack.pop() + stack.pop()); // 96 + case 302: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Character_toCharsAIIACAI(v0, v1, v2)); } // 184 1 111 + case 305: stack.push(arg10); // 21 10 + case 307: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 308: stack.push(stack.pop() + stack.pop()); // 96 + case 309: arg4 = stack.pop() // 54 4 + case 311: gt = 415; continue; // 167 0 104 + case 314: stack.push(arg8); // 21 8 + case 316: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109 + case 319: arg7 = stack.pop() // 58 7 + case 321: stack.push(arg7); // 25 7 + case 323: stack.push(stack.pop().length); // 190 + case 324: arg12 = stack.pop() // 54 12 + case 326: stack.push(arg12); // 21 12 + case 328: stack.push(arg10); // 21 10 + case 330: if (stack.pop() >= stack.pop()) { gt = 361; continue; } // 164 0 31 + case 333: stack.push(arg3); // 45 + case 334: stack.push(stack.pop().length); // 190 + case 335: stack.push(arg12); // 21 12 + case 337: stack.push(stack.pop() + stack.pop()); // 96 + case 338: stack.push(arg10); // 21 10 + case 340: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 341: stack.push(new Array(stack.pop())); // 188 5 + case 343: arg13 = stack.pop() // 58 13 + case 345: stack.push(arg3); // 45 + case 346: stack.push(0); // 3 + case 347: stack.push(arg13); // 25 13 + case 349: stack.push(0); // 3 + case 350: stack.push(arg11); // 21 11 + case 352: stack.push(arg4); // 21 4 + case 354: stack.push(stack.pop() + stack.pop()); // 96 + case 355: { var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_System_arraycopyVLjava_lang_ObjectILjava_lang_ObjectII(v0, v1, v2, v3, v4); } // 184 1 171 + case 358: stack.push(arg13); // 25 13 + case 360: arg3 = stack.pop(); // 78 + case 361: stack.push(0); // 3 + case 362: arg13 = stack.pop() // 54 13 + case 364: stack.push(arg13); // 21 13 + case 366: stack.push(arg12); // 21 12 + case 368: if (stack.pop() <= stack.pop()) { gt = 392; continue; } // 162 0 24 + case 371: stack.push(arg3); // 45 + case 372: stack.push(arg11); // 21 11 + case 374: stack.push(arg4); // 21 4 + case 376: stack.push(stack.pop() + stack.pop()); // 96 + case 377: stack.push(arg13); // 21 13 + case 379: stack.push(stack.pop() + stack.pop()); // 96 + case 380: stack.push(arg7); // 25 7 + case 382: stack.push(arg13); // 21 13 + case 384: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 385: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 386: arg13++; // 132 13 1 + case 389: gt = 364; continue; // 167 255 231 + case 392: stack.push(arg4); // 21 4 + case 394: stack.push(arg12); // 21 12 + case 396: stack.push(arg10); // 21 10 + case 398: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 399: stack.push(stack.pop() + stack.pop()); // 96 + case 400: arg4 = stack.pop() // 54 4 + case 402: gt = 415; continue; // 167 0 13 + case 405: stack.push(arg3); // 45 + case 406: stack.push(arg11); // 21 11 + case 408: stack.push(arg4); // 21 4 + case 410: stack.push(stack.pop() + stack.pop()); // 96 + case 411: stack.push(arg8); // 21 8 + case 413: // number conversion // 146 + case 414: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 415: stack.push(arg11); // 21 11 + case 417: stack.push(arg10); // 21 10 + case 419: stack.push(stack.pop() + stack.pop()); // 96 + case 420: arg11 = stack.pop() // 54 11 + case 422: gt = 156; continue; // 167 254 246 + case 425: stack.push(new java_lang_String); // 187 0 200 + case 428: stack.push(stack[stack.length - 1]); // 89 + case 429: stack.push(0); // 3 + case 430: stack.push(arg0); // 42 + case 431: stack.push(stack.pop().count); // 180 1 97 + case 434: stack.push(arg4); // 21 4 + case 436: stack.push(stack.pop() + stack.pop()); // 96 + case 437: stack.push(arg3); // 45 + case 438: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVIIAC(stack.pop(), v0, v1, v2); } // 183 1 137 + case 441: return stack.pop(); // 176 + } +} +function java_lang_String_toUpperCaseLjava_lang_String(arg0) { + var arg1; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { stack.push(java_util_Locale_getDefaultLjava_util_Locale()); } // 184 1 179 + case 4: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.toUpperCaseLjava_lang_StringLjava_util_Locale(self, v0)); } // 182 1 159 + case 7: return stack.pop(); // 176 + } +} +function java_lang_String_trimLjava_lang_String(arg0) { + var arg1; + var arg2; + var arg3; + var arg4; + var arg5; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().count); // 180 1 97 + case 4: arg1 = stack.pop(); // 60 + case 5: stack.push(0); // 3 + case 6: arg2 = stack.pop(); // 61 + case 7: stack.push(arg0); // 42 + case 8: stack.push(stack.pop().offset); // 180 1 99 + case 11: arg3 = stack.pop(); // 62 + case 12: stack.push(arg0); // 42 + case 13: stack.push(stack.pop().value); // 180 1 100 + case 16: arg4 = stack.pop() // 58 4 + case 18: stack.push(arg2); // 28 + case 19: stack.push(arg1); // 27 + case 20: if (stack.pop() <= stack.pop()) { gt = 40; continue; } // 162 0 20 + case 23: stack.push(arg4); // 25 4 + case 25: stack.push(arg3); // 29 + case 26: stack.push(arg2); // 28 + case 27: stack.push(stack.pop() + stack.pop()); // 96 + case 28: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 29: stack.push(32); // 16 32 + case 31: if (stack.pop() < stack.pop()) { gt = 40; continue; } // 163 0 9 + case 34: arg2++; // 132 2 1 + case 37: gt = 18; continue; // 167 255 237 + case 40: stack.push(arg2); // 28 + case 41: stack.push(arg1); // 27 + case 42: if (stack.pop() <= stack.pop()) { gt = 64; continue; } // 162 0 22 + case 45: stack.push(arg4); // 25 4 + case 47: stack.push(arg3); // 29 + case 48: stack.push(arg1); // 27 + case 49: stack.push(stack.pop() + stack.pop()); // 96 + case 50: stack.push(1); // 4 + case 51: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 52: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 53: stack.push(32); // 16 32 + case 55: if (stack.pop() < stack.pop()) { gt = 64; continue; } // 163 0 9 + case 58: arg1 += 255; // 132 1 255 + case 61: gt = 40; continue; // 167 255 235 + case 64: stack.push(arg2); // 28 + case 65: if (stack.pop() > 0) { gt = 76; continue; } // 157 0 11 + case 68: stack.push(arg1); // 27 + case 69: stack.push(arg0); // 42 + case 70: stack.push(stack.pop().count); // 180 1 97 + case 73: if (stack.pop() <= stack.pop()) { gt = 85; continue; } // 162 0 12 + case 76: stack.push(arg0); // 42 + case 77: stack.push(arg2); // 28 + case 78: stack.push(arg1); // 27 + case 79: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.substringLjava_lang_StringII(self, v0, v1)); } // 182 1 147 + case 82: gt = 86; continue; // 167 0 4 + case 85: stack.push(arg0); // 42 + case 86: return stack.pop(); // 176 + } +} +*/ +function java_lang_String_toStringLjava_lang_String(arg0) { + return arg0.toString(); +} +/* +function java_lang_String_toCharArrayAC(arg0) { + var arg1; + var arg2; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().count); // 180 1 97 + case 4: stack.push(new Array(stack.pop())); // 188 5 + case 6: arg1 = stack.pop(); // 76 + case 7: stack.push(arg0); // 42 + case 8: stack.push(0); // 3 + case 9: stack.push(arg0); // 42 + case 10: stack.push(stack.pop().count); // 180 1 97 + case 13: stack.push(arg1); // 43 + case 14: stack.push(0); // 3 + case 15: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); self.getCharsVIIACAI(self, v0, v1, v2, v3); } // 182 1 138 + case 18: stack.push(arg1); // 43 + case 19: return stack.pop(); // 176 + } +} +function java_lang_String_formatLjava_lang_StringLjava_lang_StringLjava_lang_Object(arg0,arg1) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(new java_util_Formatter); // 187 0 211 + case 3: stack.push(stack[stack.length - 1]); // 89 + case 4: { java_util_Formatter_consV(stack.pop()); } // 183 1 174 + case 7: stack.push(arg0); // 42 + case 8: stack.push(arg1); // 43 + case 9: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.formatALjava_util_FormatterLjava_lang_StringALjava_lang_Object(self, v0, v1)); } // 182 1 177 + case 12: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 175 + case 15: return stack.pop(); // 176 + } +} +function java_lang_String_formatLjava_lang_StringLjava_util_LocaleLjava_lang_StringLjava_lang_Object(arg0,arg1,arg2) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(new java_util_Formatter); // 187 0 211 + case 3: stack.push(stack[stack.length - 1]); // 89 + case 4: stack.push(arg0); // 42 + case 5: { var v0 = stack.pop(); java_util_Formatter_consVLjava_util_Locale(stack.pop(), v0); } // 183 1 176 + case 8: stack.push(arg1); // 43 + case 9: stack.push(arg2); // 44 + case 10: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.formatALjava_util_FormatterLjava_lang_StringALjava_lang_Object(self, v0, v1)); } // 182 1 177 + case 13: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 175 + case 16: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringLjava_lang_Object(arg0) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: if (stack.pop()) { gt = 9; continue; } // 199 0 8 + case 4: stack.push("null"); // 18 10 + case 6: gt = 13; continue; // 167 0 7 + case 9: stack.push(arg0); // 42 + case 10: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132 + case 13: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringAC(arg0) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(new java_lang_String); // 187 0 200 + case 3: stack.push(stack[stack.length - 1]); // 89 + case 4: stack.push(arg0); // 42 + case 5: { var v0 = stack.pop(); java_lang_String_consVAC(stack.pop(), v0); } // 183 1 142 + case 8: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringACII(arg0,arg1,arg2) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(new java_lang_String); // 187 0 200 + case 3: stack.push(stack[stack.length - 1]); // 89 + case 4: stack.push(arg0); // 42 + case 5: stack.push(arg1); // 27 + case 6: stack.push(arg2); // 28 + case 7: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVACAIAI(stack.pop(), v0, v1, v2); } // 183 1 143 + case 10: return stack.pop(); // 176 + } +} +function java_lang_String_copyValueOfLjava_lang_StringACII(arg0,arg1,arg2) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(new java_lang_String); // 187 0 200 + case 3: stack.push(stack[stack.length - 1]); // 89 + case 4: stack.push(arg0); // 42 + case 5: stack.push(arg1); // 27 + case 6: stack.push(arg2); // 28 + case 7: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVACAIAI(stack.pop(), v0, v1, v2); } // 183 1 143 + case 10: return stack.pop(); // 176 + } +} +function java_lang_String_copyValueOfLjava_lang_StringAC(arg0) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(0); // 3 + case 2: stack.push(arg0); // 42 + case 3: stack.push(stack.pop().length); // 190 + case 4: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_String_copyValueOfALjava_lang_StringACAIAI(v0, v1, v2)); } // 184 1 155 + case 7: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringZ(arg0) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 26 + case 1: if (stack.pop() == 0) { gt = 9; continue; } // 153 0 8 + case 4: stack.push("true"); // 18 12 + case 6: gt = 11; continue; // 167 0 5 + case 9: stack.push("false"); // 18 8 + case 11: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringC(arg0) { + var arg1; + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(1); // 4 + case 1: stack.push(new Array(stack.pop())); // 188 5 + case 3: stack.push(stack[stack.length - 1]); // 89 + case 4: stack.push(0); // 3 + case 5: stack.push(arg0); // 26 + case 6: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 7: arg1 = stack.pop(); // 76 + case 8: stack.push(new java_lang_String); // 187 0 200 + case 11: stack.push(stack[stack.length - 1]); // 89 + case 12: stack.push(0); // 3 + case 13: stack.push(1); // 4 + case 14: stack.push(arg1); // 43 + case 15: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVIIAC(stack.pop(), v0, v1, v2); } // 183 1 137 + case 18: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringI(arg0) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 26 + case 1: stack.push(10); // 16 10 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Integer_toStringLjava_lang_StringII(v0, v1)); } // 184 1 125 + case 6: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringJ(arg0) { + var arg1; + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 30 + case 1: stack.push(10); // 16 10 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Long_toStringLjava_lang_StringJI(v0, v1)); } // 184 1 126 + case 6: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringF(arg0) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 34 + case 1: { var v0 = stack.pop(); stack.push(java_lang_Float_toStringLjava_lang_StringF(v0)); } // 184 1 122 + case 4: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringD(arg0) { + var arg1; + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 38 + case 1: { var v0 = stack.pop(); stack.push(java_lang_Double_toStringLjava_lang_StringD(v0)); } // 184 1 121 + case 4: return stack.pop(); // 176 + } +} +function java_lang_String_internLjava_lang_String(arg0) { + // no code found for null +} +function java_lang_String_compareToILjava_lang_Object(arg0,arg1) { + var arg2; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: if(stack[stack.length - 1].$instOf_java_lang_String != 1) throw {}; // 192 0 200 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.compareToILjava_lang_String(self, v0)); } // 182 1 148 + case 8: return stack.pop(); // 172 + } +} +function java_lang_String_classV() { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(0); // 3 + case 1: stack.push(new Array(stack.pop())); // 189 0 183 + case 4: java_lang_String_serialPersistentFields = stack.pop(); // 179 1 101 + case 7: stack.push(new java_lang_String$CaseInsensitiveComparator); // 187 0 202 + case 10: stack.push(stack[stack.length - 1]); // 89 + case 11: // 1 + case 12: { var v0 = stack.pop(); java_lang_String$CaseInsensitiveComparator_consVLjava_lang_String$1(stack.pop(), v0); } // 183 1 160 + case 15: java_lang_String_CASE_INSENSITIVE_ORDER = stack.pop(); // 179 1 102 + case 18: return; // 177 + } +} +*/ +var java_lang_String_serialVersionUID = 0; +var java_lang_String_serialPersistentFields = 0; +var java_lang_String_CASE_INSENSITIVE_ORDER = 0; +function java_lang_String() { + /** the real value of this 'string' we delegate to */ + this.r = ''; + + var self = this; + /* + this.value = 0; + this.offset = 0; + this.count = 0; + this.hash = 0; + */ + this.toString = function() { return self.r; }; +} +java_lang_String.prototype = new String; +//java_lang_String_classV(); + +/* new method for JavaScript String */ +String.prototype.charAtCI = java_lang_String_charAtCI; +String.prototype.lengthI = java_lang_String_lengthI; +String.prototype.isEmptyZ = java_lang_String_isEmptyZ; +String.prototype.getCharsVIIACI = java_lang_String_getCharsVIIACAI; +String.prototype.toStringLjava_lang_String = java_lang_String_toStringLjava_lang_String; +String.prototype.$instOf_java_lang_String = true; +String.prototype.$instOf_java_io_Serializable = true; +String.prototype.$instOf_java_lang_Comparable = true; +String.prototype.$instOf_java_lang_CharSequence = true; + +/* + this.lengthI = java_lang_String_lengthI; + this.isEmptyZ = java_lang_String_isEmptyZ; + this.charAtCI = java_lang_String_charAtCI; + this.codePointAtII = java_lang_String_codePointAtII; + this.codePointBeforeII = java_lang_String_codePointBeforeII; + this.codePointCountIII = java_lang_String_codePointCountIII; + this.offsetByCodePointsIII = java_lang_String_offsetByCodePointsIII; + this.getCharsVACI = java_lang_String_getCharsVACI; + this.getCharsVIIACI = java_lang_String_getCharsVIIACI; + this.getBytesVIIABI = java_lang_String_getBytesVIIABI; + this.getBytesABLjava_lang_String = java_lang_String_getBytesABLjava_lang_String; + this.getBytesABLjava_nio_charset_Charset = java_lang_String_getBytesABLjava_nio_charset_Charset; + this.getBytesAB = java_lang_String_getBytesAB; + this.equalsZLjava_lang_Object = java_lang_String_equalsZLjava_lang_Object; + this.contentEqualsZLjava_lang_StringBuffer = java_lang_String_contentEqualsZLjava_lang_StringBuffer; + this.contentEqualsZLjava_lang_CharSequence = java_lang_String_contentEqualsZLjava_lang_CharSequence; + this.equalsIgnoreCaseZLjava_lang_String = java_lang_String_equalsIgnoreCaseZLjava_lang_String; + this.compareToILjava_lang_String = java_lang_String_compareToILjava_lang_String; + this.compareToIgnoreCaseILjava_lang_String = java_lang_String_compareToIgnoreCaseILjava_lang_String; + this.regionMatchesZILjava_lang_StringII = java_lang_String_regionMatchesZILjava_lang_StringII; + this.regionMatchesZZILjava_lang_StringII = java_lang_String_regionMatchesZZILjava_lang_StringII; + this.startsWithZLjava_lang_StringI = java_lang_String_startsWithZLjava_lang_StringI; + this.startsWithZLjava_lang_String = java_lang_String_startsWithZLjava_lang_String; + this.endsWithZLjava_lang_String = java_lang_String_endsWithZLjava_lang_String; + this.hashCodeI = java_lang_String_hashCodeI; + this.indexOfII = java_lang_String_indexOfII; + this.indexOfIII = java_lang_String_indexOfIII; + this.lastIndexOfII = java_lang_String_lastIndexOfII; + this.lastIndexOfIII = java_lang_String_lastIndexOfIII; + this.indexOfILjava_lang_String = java_lang_String_indexOfILjava_lang_String; + this.indexOfILjava_lang_StringI = java_lang_String_indexOfILjava_lang_StringI; + this.lastIndexOfILjava_lang_String = java_lang_String_lastIndexOfILjava_lang_String; + this.lastIndexOfILjava_lang_StringI = java_lang_String_lastIndexOfILjava_lang_StringI; + this.substringLjava_lang_StringI = java_lang_String_substringLjava_lang_StringI; + this.substringLjava_lang_StringII = java_lang_String_substringLjava_lang_StringII; + this.subSequenceLjava_lang_CharSequenceII = java_lang_String_subSequenceLjava_lang_CharSequenceII; + this.concatLjava_lang_StringLjava_lang_String = java_lang_String_concatLjava_lang_StringLjava_lang_String; + this.replaceLjava_lang_StringCC = java_lang_String_replaceLjava_lang_StringCC; + this.matchesZLjava_lang_String = java_lang_String_matchesZLjava_lang_String; + this.containsZLjava_lang_CharSequence = java_lang_String_containsZLjava_lang_CharSequence; + this.replaceFirstLjava_lang_StringLjava_lang_StringLjava_lang_String = java_lang_String_replaceFirstLjava_lang_StringLjava_lang_StringLjava_lang_String; + this.replaceAllLjava_lang_StringLjava_lang_StringLjava_lang_String = java_lang_String_replaceAllLjava_lang_StringLjava_lang_StringLjava_lang_String; + this.replaceLjava_lang_StringLjava_lang_CharSequenceLjava_lang_CharSequence = java_lang_String_replaceLjava_lang_StringLjava_lang_CharSequenceLjava_lang_CharSequence; + this.splitALjava_lang_StringLjava_lang_StringI = java_lang_String_splitALjava_lang_StringLjava_lang_StringI; + this.splitALjava_lang_StringLjava_lang_String = java_lang_String_splitALjava_lang_StringLjava_lang_String; + this.toLowerCaseLjava_lang_StringLjava_util_Locale = java_lang_String_toLowerCaseLjava_lang_StringLjava_util_Locale; + this.toLowerCaseLjava_lang_String = java_lang_String_toLowerCaseLjava_lang_String; + this.toUpperCaseLjava_lang_StringLjava_util_Locale = java_lang_String_toUpperCaseLjava_lang_StringLjava_util_Locale; + this.toUpperCaseLjava_lang_String = java_lang_String_toUpperCaseLjava_lang_String; + this.trimLjava_lang_String = java_lang_String_trimLjava_lang_String; + this.toStringLjava_lang_String = java_lang_String_toStringLjava_lang_String; + this.toCharArrayAC = java_lang_String_toCharArrayAC; + this.internLjava_lang_String = java_lang_String_internLjava_lang_String; + this.compareToILjava_lang_Object = java_lang_String_compareToILjava_lang_Object; + */ + + + diff -r 4fca8ddf46de -r ff3f0de0b8a2 htmlpage/pom.xml --- a/htmlpage/pom.xml Fri Sep 28 14:58:21 2012 +0200 +++ b/htmlpage/pom.xml Thu Oct 11 06:16:00 2012 -0700 @@ -31,6 +31,25 @@ org.netbeans.api org-openide-util-lookup + + org.apidesign.bck2brwsr + core + 1.0-SNAPSHOT + jar + + + org.apidesign.bck2brwsr + emul + 1.0-SNAPSHOT + jar + + + org.apidesign.bck2brwsr + vm4brwsr + 0.1-SNAPSHOT + jar + test + diff -r 4fca8ddf46de -r ff3f0de0b8a2 htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java --- a/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Fri Sep 28 14:58:21 2012 +0200 +++ b/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Thu Oct 11 06:16:00 2012 -0700 @@ -55,7 +55,7 @@ public boolean process(Set annotations, RoundEnvironment roundEnv) { for (Element e : roundEnv.getElementsAnnotatedWith(Page.class)) { Page p = e.getAnnotation(Page.class); - PackageElement pe = (PackageElement)e; + PackageElement pe = (PackageElement)e.getEnclosingElement(); String pkg = pe.getQualifiedName().toString(); ProcessPage pp; diff -r 4fca8ddf46de -r ff3f0de0b8a2 htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.java --- a/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.java Fri Sep 28 14:58:21 2012 +0200 +++ b/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.java Thu Oct 11 06:16:00 2012 -0700 @@ -17,6 +17,8 @@ */ package org.apidesign.bck2brwsr.htmlpage.api; +import org.apidesign.bck2brwsr.core.JavaScriptBody; + /** Represents a generic HTML element. * * @author Jaroslav Tulach @@ -30,14 +32,33 @@ abstract void dontSubclass(); + @JavaScriptBody( + args={"el", "property", "value"}, + body="var e = window.document.getElementById(el.id);\n" + + "e[property] = value;\n" + ) static void setAttribute(Element el, String property, Object value) { throw new UnsupportedOperationException("Needs JavaScript!"); } + + @JavaScriptBody( + args={"el", "property"}, + body="var e = window.document.getElementById(el.id);\n" + + "return e[property];\n" + ) + static Object getAttribute(Element el, String property) { + throw new UnsupportedOperationException("Needs JavaScript!"); + } /** Executes given runnable when user performs a "click" on the given * element. * @param r the runnable to execute, never null */ + @JavaScriptBody( + args={"el", "r"}, + body="var e = window.document.getElementById(el.id);\n" + + "e.onclick = function() { r.runV(); };\n" + ) public final void addOnClick(Runnable r) { throw new UnsupportedOperationException("Needs JavaScript!"); } diff -r 4fca8ddf46de -r ff3f0de0b8a2 htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.js --- a/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.js Fri Sep 28 14:58:21 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ - - -function org_apidesign_bck2brwsr_htmlpage_api_Element_setAttribute_Lorg_apidesign_bck2brwsr_htmlpage_api_ElementLjava_lang_StringLjava_lang_Object(self, property, value) { - document.getElementById(self.id)[property] = value; -} - -function org_apidesign_bck2brwsr_htmlpage_api_Element_addOnClick_Ljava_lang_Runnable(self, run) { - document.getElementById(self.id).onClick = function() { run.runV(); }; -} - diff -r 4fca8ddf46de -r ff3f0de0b8a2 htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Input.java --- a/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Input.java Fri Sep 28 14:58:21 2012 +0200 +++ b/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Input.java Thu Oct 11 06:16:00 2012 -0700 @@ -31,6 +31,10 @@ } public void setAutocomplete(boolean state) { - setAttribute(this, "autocomplete", state); + Element.setAttribute(this, "autocomplete", state); + } + + public final String getValue() { + return (String)Element.getAttribute(this, "value"); } } diff -r 4fca8ddf46de -r ff3f0de0b8a2 htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Page.java --- a/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Page.java Fri Sep 28 14:58:21 2012 +0200 +++ b/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Page.java Thu Oct 11 06:16:00 2012 -0700 @@ -32,7 +32,7 @@ * @author Jaroslav Tulach */ @Retention(RetentionPolicy.SOURCE) -@Target(ElementType.PACKAGE) +@Target(ElementType.TYPE) public @interface Page { /** Path to the XHTML page to read in */ String xhtml(); diff -r 4fca8ddf46de -r ff3f0de0b8a2 htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Title.java --- a/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Title.java Fri Sep 28 14:58:21 2012 +0200 +++ b/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Title.java Thu Oct 11 06:16:00 2012 -0700 @@ -29,4 +29,8 @@ @Override void dontSubclass() { } + + public final void setText(String text) { + Element.setAttribute(this, "innerHTML", text); + } } diff -r 4fca8ddf46de -r ff3f0de0b8a2 htmlpage/src/test/java/org/apidesign/bck2brwsr/htmlpage/PageController.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htmlpage/src/test/java/org/apidesign/bck2brwsr/htmlpage/PageController.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,32 @@ +package org.apidesign.bck2brwsr.htmlpage; + +import org.apidesign.bck2brwsr.htmlpage.api.OnClick; +import org.apidesign.bck2brwsr.htmlpage.api.Page; + +/** Trivial demo for the bck2brwsr project. First of all start + * with your XHTML page. Include there + * a script that will boot Java in your browser. + *

+ * Then use @Page annotation to + * generate a Java representation of elements with IDs in that page. + * Depending on the type of the elements, they will have different + * methods (e.g. PG_TITLE has setText, etc.). + * Use @OnClick annotation to associate behavior + * with existing elements. Use the generated elements + * (PG_TITLE, PG_TEXT) to modify the page. + *

+ * Everything is type-safe. As soon as somebody modifies the page and + * removes the IDs or re-assigns them to wrong elements. Java compiler + * will emit an error. + *

+ * Welcome to the type-safe HTML5 world! + * + * @author Jaroslav Tulach + */ +@Page(xhtml="TestPage.html", name="TestPage") +public class PageController { + @OnClick(id="pg.button") + static void updateTitle() { + TestPage.PG_TITLE.setText(TestPage.PG_TEXT.getValue()); + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 htmlpage/src/test/java/org/apidesign/bck2brwsr/htmlpage/ProcessPageTest.java --- a/htmlpage/src/test/java/org/apidesign/bck2brwsr/htmlpage/ProcessPageTest.java Fri Sep 28 14:58:21 2012 +0200 +++ b/htmlpage/src/test/java/org/apidesign/bck2brwsr/htmlpage/ProcessPageTest.java Thu Oct 11 06:16:00 2012 -0700 @@ -19,17 +19,20 @@ import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.Method; import java.util.Set; +import javax.script.Invocable; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; import org.testng.annotations.Test; import static org.testng.Assert.*; -import org.apidesign.bck2brwsr.htmlpage.api.*; - public class ProcessPageTest { @Test public void findsThreeIds() throws IOException { - InputStream is = ProcessPageTest.class.getResourceAsStream("TestPage.xhtml"); + InputStream is = ProcessPageTest.class.getResourceAsStream("TestPage.html"); assertNotNull(is, "Sample HTML page found"); ProcessPage res = ProcessPage.readPage(is); final Set ids = res.ids(); @@ -40,16 +43,67 @@ assertEquals(res.tagNameForId("pg.text"), "input"); } - void testWhetherWeCanCallTheGeneratedIdFields() { - Title t = TestPage.PG_TITLE; + @Test public void testCompileAndRunPageController() throws Exception { + StringBuilder sb = new StringBuilder(); + sb.append( + "var window = new Object();\n" + + "var doc = new Object();\n" + + "doc.button = new Object();\n" + + "doc.title = new Object();\n" + + "doc.title.innerHTML = 'nothing';\n" + + "doc.text = new Object();\n" + + "doc.text.value = 'something';\n" + + "doc.getElementById = function(id) {\n" + + " switch(id) {\n" + + " case 'pg.button': return doc.button;\n" + + " case 'pg.title': return doc.title;\n" + + " case 'pg.text': return doc.text;\n" + + " }\n" + + " throw id;\n" + + " }\n" + + "\n" + + "function clickAndCheck() {\n" + + " doc.button.onclick();\n" + + " return doc.title.innerHTML.toString();\n" + + "};\n" + + "\n" + + "window.document = doc;\n" + ); + Invocable i = compileClass(sb, "org/apidesign/bck2brwsr/htmlpage/PageController"); + + Object ret = null; + try { + ret = i.invokeFunction("clickAndCheck"); + } catch (ScriptException ex) { + fail("Execution failed in " + sb, ex); + } catch (NoSuchMethodException ex) { + fail("Cannot find method in " + sb, ex); + } + assertEquals(ret, "something", "We expect that the JavaCode performs all the wiring"); } - - @OnClick(id="pg.button") - static void handleButtonClick() { - - } - - @Test public void testOnclickHandlerGenerated() { - + + static Invocable compileClass(StringBuilder sb, String... names) throws ScriptException, IOException { + if (sb == null) { + sb = new StringBuilder(); + } + try { + Method m; + Class genJS = Class.forName("org.apidesign.vm4brwsr.GenJS"); + m = genJS.getDeclaredMethod("compile", Appendable.class, String[].class); + m.setAccessible(true); + m.invoke(null, sb, names); + } catch (Exception exception) { + throw new IOException(exception); + } + ScriptEngineManager sem = new ScriptEngineManager(); + ScriptEngine js = sem.getEngineByExtension("js"); + try { + Object res = js.eval(sb.toString()); + assertTrue(js instanceof Invocable, "It is invocable object: " + res); + return (Invocable) js; + } catch (ScriptException ex) { + fail("Could not compile:\n" + sb, ex); + return null; + } } } diff -r 4fca8ddf46de -r ff3f0de0b8a2 htmlpage/src/test/java/org/apidesign/bck2brwsr/htmlpage/package-info.java --- a/htmlpage/src/test/java/org/apidesign/bck2brwsr/htmlpage/package-info.java Fri Sep 28 14:58:21 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -/** - * Java 4 Browser Bytecode Translator - * Copyright (C) 2012-2012 Jaroslav Tulach - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. Look for COPYING file in the top folder. - * If not, see http://opensource.org/licenses/GPL-2.0. - */ -@Page(xhtml="TestPage.xhtml", name="TestPage") -package org.apidesign.bck2brwsr.htmlpage; - -import org.apidesign.bck2brwsr.htmlpage.api.Page; - diff -r 4fca8ddf46de -r ff3f0de0b8a2 htmlpage/src/test/resources/org/apidesign/bck2brwsr/htmlpage/TestPage.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htmlpage/src/test/resources/org/apidesign/bck2brwsr/htmlpage/TestPage.html Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,30 @@ + + + + + + Default Title + + + New title: + + + diff -r 4fca8ddf46de -r ff3f0de0b8a2 htmlpage/src/test/resources/org/apidesign/bck2brwsr/htmlpage/TestPage.xhtml --- a/htmlpage/src/test/resources/org/apidesign/bck2brwsr/htmlpage/TestPage.xhtml Fri Sep 28 14:58:21 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ - - - - - - Default Title - - - New title: - - - diff -r 4fca8ddf46de -r ff3f0de0b8a2 pom.xml --- a/pom.xml Fri Sep 28 14:58:21 2012 +0200 +++ b/pom.xml Thu Oct 11 06:16:00 2012 -0700 @@ -9,6 +9,8 @@ vm htmlpage + emul + core diff -r 4fca8ddf46de -r ff3f0de0b8a2 vm/pom.xml --- a/vm/pom.xml Fri Sep 28 14:58:21 2012 +0200 +++ b/vm/pom.xml Thu Oct 11 06:16:00 2012 -0700 @@ -7,7 +7,7 @@ 1.0-SNAPSHOT - org.apidesign + org.apidesign.bck2brwsr vm4brwsr 0.1-SNAPSHOT jar @@ -86,5 +86,17 @@ org-netbeans-modules-classfile jar + + org.apidesign.bck2brwsr + core + 1.0-SNAPSHOT + jar + + + org.apidesign.bck2brwsr + emul + 1.0-SNAPSHOT + test + diff -r 4fca8ddf46de -r ff3f0de0b8a2 vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java --- a/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Fri Sep 28 14:58:21 2012 +0200 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Thu Oct 11 06:16:00 2012 -0700 @@ -22,6 +22,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.apidesign.bck2brwsr.core.ExtraJavaScript; +import org.apidesign.bck2brwsr.core.JavaScriptBody; +import org.netbeans.modules.classfile.Annotation; +import org.netbeans.modules.classfile.AnnotationComponent; +import org.netbeans.modules.classfile.ArrayElementValue; import static org.netbeans.modules.classfile.ByteCodes.*; import org.netbeans.modules.classfile.CPClassInfo; import org.netbeans.modules.classfile.CPEntry; @@ -31,8 +36,10 @@ import org.netbeans.modules.classfile.ClassFile; import org.netbeans.modules.classfile.ClassName; import org.netbeans.modules.classfile.Code; +import org.netbeans.modules.classfile.ElementValue; import org.netbeans.modules.classfile.Method; import org.netbeans.modules.classfile.Parameter; +import org.netbeans.modules.classfile.PrimitiveElementValue; import org.netbeans.modules.classfile.Variable; /** Translator of the code inside class files to JavaScript. @@ -62,14 +69,30 @@ * generated JavaScript code works properly. The names are in internal * JVM form so String is java/lang/String. Can be null * if one is not interested in knowing references + * @param scripts write only collection with names of resources to read + * @return the initialization code for this class, if any. Otherwise null + * * @throws IOException if something goes wrong during read or write or translating */ - public static void compile( + public static String compile( InputStream classFile, Appendable out, - Collection references + Collection references, + Collection scripts ) throws IOException { ClassFile jc = new ClassFile(classFile, true); + final ClassName extraAnn = ClassName.getClassName(ExtraJavaScript.class.getName().replace('.', '/')); + Annotation a = jc.getAnnotation(extraAnn); + if (a != null) { + final ElementValue annVal = a.getComponent("resource").getValue(); + String res = ((PrimitiveElementValue)annVal).getValue().getValue().toString(); + scripts.add(res); + final AnnotationComponent process = a.getComponent("processByteCode"); + if (process != null && "const=0".equals(process.getValue().toString())) { + return null; + } + } + ByteCodeToJavaScript compiler = new ByteCodeToJavaScript( jc, out, references ); @@ -95,26 +118,39 @@ out.append("\n this." + v.getName() + " = 0;"); } } - out.append("\n}"); + out.append("\n}\n\nfunction ").append(className).append("_proto() {"); + out.append("\n if (").append(className). + append(".prototype.$instOf_").append(className).append(") {"); + out.append("\n return ").append(className).append(".prototype;"); + out.append("\n }"); ClassName sc = jc.getSuperClass(); if (sc != null) { - out.append("\n").append(className) + out.append("\n ").append(sc.getInternalName().replace('/', '_')).append("_proto();"); + out.append("\n ").append(className) .append(".prototype = new ").append(sc.getInternalName().replace('/', '_')).append(';'); } for (Method m : jc.getMethods()) { if (!m.isStatic() && !m.isPrivate() && !m.getName().contains("")) { - compiler.generateMethodReference("\n" + className + ".prototype.", m); + compiler.generateMethodReference("\n " + className + ".prototype.", m); } } - out.append("\n" + className + ".prototype.$instOf_").append(className).append(" = true;"); + out.append("\n " + className + ".prototype.$instOf_").append(className).append(" = true;"); for (ClassName superInterface : jc.getInterfaces()) { - out.append("\n" + className + ".prototype.$instOf_").append(superInterface.getInternalName().replace('/', '_')).append(" = true;"); + out.append("\n " + className + ".prototype.$instOf_").append(superInterface.getInternalName().replace('/', '_')).append(" = true;"); } + out.append("\n return ").append(className).append(".prototype;"); + out.append("\n}"); + out.append("\n").append(className).append("_proto();"); + StringBuilder sb = new StringBuilder(); for (String init : toInitilize) { - out.append("\n").append(init).append("();"); + sb.append("\n").append(init).append("();"); } + return sb.toString(); } private void generateStaticMethod(Method m, List toInitilize) throws IOException { + if (javaScriptBody(m, true)) { + return; + } final String mn = findMethodName(m); out.append("\nfunction ").append( jc.getName().getInternalName().replace('/', '_') @@ -160,6 +196,9 @@ } private void generateInstanceMethod(Method m) throws IOException { + if (javaScriptBody(m, false)) { + return; + } out.append("\nfunction ").append( jc.getName().getInternalName().replace('/', '_') ).append('_').append(findMethodName(m)); @@ -184,9 +223,7 @@ out.append(" var "); out.append("arg").append(String.valueOf(i + 1)).append(";\n"); } - out.append(";\n var stack = new Array("); - out.append(Integer.toString(code.getMaxStack())); - out.append(");\n"); + out.append(";\n var stack = new Array();\n"); produceCode(code.getByteCodes()); } else { out.append(" /* no code found for ").append(m.getTypeSignature()).append(" */\n"); @@ -313,6 +350,24 @@ case bc_lxor: out.append("stack.push(stack.pop() ^ stack.pop());"); break; + case bc_ineg: + case bc_lneg: + case bc_fneg: + case bc_dneg: + out.append("stack.push(- stack.pop());"); + break; + case bc_ishl: + case bc_lshl: + out.append("{ var v = stack.pop(); stack.push(stack.pop() << v); }"); + break; + case bc_ishr: + case bc_lshr: + out.append("{ var v = stack.pop(); stack.push(stack.pop() >> v); }"); + break; + case bc_iushr: + case bc_lushr: + out.append("{ var v = stack.pop(); stack.push(stack.pop() >>> v); }"); + break; case bc_iinc: { final int varIndx = (byteCodes[++i] + 256) % 256; final int incrBy = (byteCodes[++i] + 256) % 256; @@ -549,6 +604,11 @@ out.append("{ var indx = stack.pop(); stack.push(stack.pop()[indx]); }"); break; } + case bc_pop2: + out.append("stack.pop();"); + case bc_pop: + out.append("stack.pop();"); + break; case bc_dup: out.append("stack.push(stack[stack.length - 1]);"); break; @@ -681,6 +741,7 @@ sig.insert(firstPos, 'A'); } } + array = false; continue; case 'V': assert !count; @@ -843,7 +904,9 @@ private String encodeConstant(CPEntry entry) { final String v; - if (entry instanceof CPStringInfo) { + if (entry instanceof CPClassInfo) { + v = "new java_lang_Class"; + } else if (entry instanceof CPStringInfo) { v = "\"" + entry.getValue().toString().replace("\"", "\\\"") + "\""; } else { v = entry.getValue().toString(); @@ -854,4 +917,46 @@ private String findDescriptor(String d) { return d.replace('[', 'A'); } + + private boolean javaScriptBody(Method m, boolean isStatic) throws IOException { + final ClassName extraAnn = ClassName.getClassName(JavaScriptBody.class.getName().replace('.', '/')); + Annotation a = m.getAnnotation(extraAnn); + if (a != null) { + final ElementValue annVal = a.getComponent("body").getValue(); + String body = ((PrimitiveElementValue) annVal).getValue().getValue().toString(); + + final ArrayElementValue arrVal = (ArrayElementValue) a.getComponent("args").getValue(); + final int len = arrVal.getValues().length; + String[] names = new String[len]; + for (int i = 0; i < len; i++) { + names[i] = ((PrimitiveElementValue) arrVal.getValues()[i]).getValue().getValue().toString(); + } + out.append("\nfunction ").append( + jc.getName().getInternalName().replace('/', '_')).append('_').append(findMethodName(m)); + out.append("("); + String space; + int index; + if (!isStatic) { + out.append(names[0]); + space = ","; + index = 1; + } else { + space = ""; + index = 0; + } + List args = m.getParameters(); + for (int i = 0; i < args.size(); i++) { + out.append(space); + out.append(names[index]); + final String desc = findDescriptor(args.get(i).getDescriptor()); + index++; + space = ","; + } + out.append(") {").append("\n"); + out.append(body); + out.append("\n}\n"); + return true; + } + return false; + } } diff -r 4fca8ddf46de -r ff3f0de0b8a2 vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java --- a/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Fri Sep 28 14:58:21 2012 +0200 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Thu Oct 11 06:16:00 2012 -0700 @@ -5,11 +5,15 @@ import java.io.IOException; import java.io.InputStream; import java.io.Writer; +import java.net.URL; import java.util.Arrays; -import java.util.HashSet; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import java.util.Set; +import java.util.Map; /** Generator of JavaScript from bytecode of classes on classpath of the VM. * @@ -34,43 +38,142 @@ compile(out, Arrays.asList(names)); } static void compile(Appendable out, List names) throws IOException { - Set processed = new HashSet(); - LinkedList toProcess = new LinkedList(names); - for (;;) { - toProcess.removeAll(processed); - if (toProcess.isEmpty()) { - break; + for (String baseClass : names) { + Map processed = new HashMap(); + LinkedList toProcess = new LinkedList(); + toProcess.add(baseClass); + for (;;) { + String name = null; + Iterator it = toProcess.iterator(); + while (it.hasNext() && name == null) { + String n = it.next(); + if (processed.get(n) != null) { + continue; + } + name = n; + } + if (name == null) { + break; + } + if (name.startsWith("java/") + && !name.equals("java/lang/Object") + && !name.equals("java/lang/Class") + && !name.equals("java/lang/Number") + && !name.equals("java/lang/Integer") + && !name.equals("java/lang/Throwable") + && !name.equals("java/lang/Exception") + && !name.equals("java/lang/RuntimeException") + && !name.equals("java/lang/UnsupportedOperationException") + && !name.equals("java/lang/String") + && !name.equals("java/lang/String$CaseInsensitiveComparator") + && !name.equals("java/lang/StringBuilder") + && !name.equals("java/lang/AbstractStringBuilder") + ) { + processed.put(name, ""); + continue; + } + InputStream is = loadClass(name); + if (is == null) { + throw new IOException("Can't find class " + name); + } + LinkedList scripts = new LinkedList(); + try { + String initCode = ByteCodeToJavaScript.compile(is, out, toProcess, scripts); + processed.put(name, initCode == null ? "" : initCode); + } catch (RuntimeException ex) { + if (out instanceof CharSequence) { + CharSequence seq = (CharSequence)out; + int lastBlock = seq.length(); + while (lastBlock-- >= 0) { + if (seq.charAt(lastBlock) == '{') { + break; + } + } + throw new IOException("Error while compiling " + name + "\n" + + seq.subSequence(lastBlock + 1, seq.length()), ex + ); + } else { + throw new IOException("Error while compiling " + name + "\n" + + out, ex + ); + } + } + for (String resource : scripts) { + InputStream emul = GenJS.class.getResourceAsStream(resource); + if (emul == null) { + throw new IOException("Can't find " + resource); + } + readResource(emul, out); + } } - String name = toProcess.getFirst(); - processed.add(name); - if (name.startsWith("java/") && !name.equals("java/lang/Object")) { - continue; - } - InputStream is = GenJS.class.getClassLoader().getResourceAsStream(name + ".class"); - if (is == null) { - throw new IOException("Can't find class " + name); - } - try { - ByteCodeToJavaScript.compile(is, out, toProcess); - } catch (RuntimeException ex) { - if (out instanceof CharSequence) { - CharSequence seq = (CharSequence)out; - int lastBlock = seq.length(); - while (lastBlock-- >= 0) { - if (seq.charAt(lastBlock) == '{') { - break; - } - } - throw new IOException("Error while compiling " + name + "\n" - + seq.subSequence(lastBlock + 1, seq.length()), ex - ); - } else { - throw new IOException("Error while compiling " + name + "\n" - + out, ex - ); + + Collections.reverse(toProcess); + + for (String clazz : toProcess) { + String initCode = processed.remove(clazz); + if (initCode != null) { + out.append(initCode).append("\n"); } } } + + } + private static void readResource(InputStream emul, Appendable out) throws IOException { + try { + int state = 0; + for (;;) { + int ch = emul.read(); + if (ch == -1) { + break; + } + if (ch < 0 || ch > 255) { + throw new IOException("Invalid char in emulation " + ch); + } + switch (state) { + case 0: + if (ch == '/') { + state = 1; + } else { + out.append((char)ch); + } + break; + case 1: + if (ch == '*') { + state = 2; + } else { + out.append('/').append((char)ch); + state = 0; + } + break; + case 2: + if (ch == '*') { + state = 3; + } + break; + case 3: + if (ch == '/') { + state = 0; + } else { + state = 2; + } + break; + } + } + } finally { + emul.close(); + } + } + + private static InputStream loadClass(String name) throws IOException { + Enumeration en = ClassLoader.getSystemClassLoader().getResources(name + ".class"); + URL u = null; + while (en.hasMoreElements()) { + u = en.nextElement(); + } + if (u == null) { + throw new IOException("Can't find " + name); + } + return u.openStream(); } } diff -r 4fca8ddf46de -r ff3f0de0b8a2 vm/src/main/resources/org/apidesign/vm4brwsr/emulation/java_lang_String.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm/src/main/resources/org/apidesign/vm4brwsr/emulation/java_lang_String.js Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,3296 @@ +/* */ + + +/* +function java_lang_String_consV(arg0) { + var arg1; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130 + case 4: stack.push(arg0); // 42 + case 5: stack.push(0); // 3 + case 6: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99 + case 9: stack.push(arg0); // 42 + case 10: stack.push(0); // 3 + case 11: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97 + case 14: stack.push(arg0); // 42 + case 15: stack.push(0); // 3 + case 16: stack.push(new Array(stack.pop())); // 188 5 + case 18: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100 + case 21: return; // 177 + } +} +function java_lang_String_consVLjava_lang_String(arg0,arg1) { + var arg2; + var arg3; + var arg4; + var arg5; + var arg6; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130 + case 4: stack.push(arg1); // 43 + case 5: stack.push(stack.pop().count); // 180 1 97 + case 8: arg2 = stack.pop(); // 61 + case 9: stack.push(arg1); // 43 + case 10: stack.push(stack.pop().value); // 180 1 100 + case 13: arg3 = stack.pop(); // 78 + case 14: stack.push(arg3); // 45 + case 15: stack.push(stack.pop().length); // 190 + case 16: stack.push(arg2); // 28 + case 17: if (stack.pop() >= stack.pop()) { gt = 41; continue; } // 164 0 24 + case 20: stack.push(arg1); // 43 + case 21: stack.push(stack.pop().offset); // 180 1 99 + case 24: arg5 = stack.pop() // 54 5 + case 26: stack.push(arg3); // 45 + case 27: stack.push(arg5); // 21 5 + case 29: stack.push(arg5); // 21 5 + case 31: stack.push(arg2); // 28 + case 32: stack.push(stack.pop() + stack.pop()); // 96 + case 33: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_util_Arrays_copyOfRangeACACAIAI(v0, v1, v2)); } // 184 1 173 + case 36: arg4 = stack.pop() // 58 4 + case 38: gt = 44; continue; // 167 0 6 + case 41: stack.push(arg3); // 45 + case 42: arg4 = stack.pop() // 58 4 + case 44: stack.push(arg0); // 42 + case 45: stack.push(0); // 3 + case 46: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99 + case 49: stack.push(arg0); // 42 + case 50: stack.push(arg2); // 28 + case 51: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97 + case 54: stack.push(arg0); // 42 + case 55: stack.push(arg4); // 25 4 + case 57: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100 + case 60: return; // 177 + } +} +*/ +function java_lang_String_consVAC(arg0,arg1) { + arg0.r = arg1.join(""); +} +/* +function java_lang_String_consVACII(arg0,arg1,arg2,arg3) { + var arg4; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130 + case 4: stack.push(arg2); // 28 + case 5: if (stack.pop() >= 0) { gt = 17; continue; } // 156 0 12 + case 8: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 11: stack.push(stack[stack.length - 1]); // 89 + case 12: stack.push(arg2); // 28 + case 13: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 16: // 191 + case 17: stack.push(arg3); // 29 + case 18: if (stack.pop() >= 0) { gt = 30; continue; } // 156 0 12 + case 21: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 24: stack.push(stack[stack.length - 1]); // 89 + case 25: stack.push(arg3); // 29 + case 26: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 29: // 191 + case 30: stack.push(arg2); // 28 + case 31: stack.push(arg1); // 43 + case 32: stack.push(stack.pop().length); // 190 + case 33: stack.push(arg3); // 29 + case 34: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 35: if (stack.pop() >= stack.pop()) { gt = 49; continue; } // 164 0 14 + case 38: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 41: stack.push(stack[stack.length - 1]); // 89 + case 42: stack.push(arg2); // 28 + case 43: stack.push(arg3); // 29 + case 44: stack.push(stack.pop() + stack.pop()); // 96 + case 45: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 48: // 191 + case 49: stack.push(arg0); // 42 + case 50: stack.push(0); // 3 + case 51: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99 + case 54: stack.push(arg0); // 42 + case 55: stack.push(arg3); // 29 + case 56: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97 + case 59: stack.push(arg0); // 42 + case 60: stack.push(arg1); // 43 + case 61: stack.push(arg2); // 28 + case 62: stack.push(arg2); // 28 + case 63: stack.push(arg3); // 29 + case 64: stack.push(stack.pop() + stack.pop()); // 96 + case 65: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_util_Arrays_copyOfRangeACACAIAI(v0, v1, v2)); } // 184 1 173 + case 68: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100 + case 71: return; // 177 + } +} +function java_lang_String_consVAIII(arg0,arg1,arg2,arg3) { + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; + var arg9; + var arg10; + var arg11; + var arg12; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130 + case 4: stack.push(arg2); // 28 + case 5: if (stack.pop() >= 0) { gt = 17; continue; } // 156 0 12 + case 8: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 11: stack.push(stack[stack.length - 1]); // 89 + case 12: stack.push(arg2); // 28 + case 13: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 16: // 191 + case 17: stack.push(arg3); // 29 + case 18: if (stack.pop() >= 0) { gt = 30; continue; } // 156 0 12 + case 21: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 24: stack.push(stack[stack.length - 1]); // 89 + case 25: stack.push(arg3); // 29 + case 26: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 29: // 191 + case 30: stack.push(arg2); // 28 + case 31: stack.push(arg1); // 43 + case 32: stack.push(stack.pop().length); // 190 + case 33: stack.push(arg3); // 29 + case 34: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 35: if (stack.pop() >= stack.pop()) { gt = 49; continue; } // 164 0 14 + case 38: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 41: stack.push(stack[stack.length - 1]); // 89 + case 42: stack.push(arg2); // 28 + case 43: stack.push(arg3); // 29 + case 44: stack.push(stack.pop() + stack.pop()); // 96 + case 45: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 48: // 191 + case 49: stack.push(0); // 3 + case 50: arg4 = stack.pop() // 54 4 + case 52: stack.push(1); // 4 + case 53: arg5 = stack.pop() // 54 5 + case 55: stack.push(arg3); // 29 + case 56: stack.push(arg5); // 21 5 + case 58: stack.push(stack.pop() + stack.pop()); // 96 + case 59: stack.push(new Array(stack.pop())); // 188 5 + case 61: arg6 = stack.pop() // 58 6 + case 63: stack.push(arg2); // 28 + case 64: arg7 = stack.pop() // 54 7 + case 66: stack.push(0); // 3 + case 67: arg8 = stack.pop() // 54 8 + case 69: stack.push(0); // 3 + case 70: arg9 = stack.pop() // 54 9 + case 72: stack.push(arg9); // 21 9 + case 74: stack.push(arg3); // 29 + case 75: if (stack.pop() <= stack.pop()) { gt = 255; continue; } // 162 0 180 + case 78: stack.push(arg1); // 43 + case 79: stack.push(arg7); // 21 7 + case 81: arg7++; // 132 7 1 + case 84: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 46 + case 85: arg10 = stack.pop() // 54 10 + case 87: stack.push(arg10); // 21 10 + case 89: if (stack.pop() >= 0) { gt = 100; continue; } // 156 0 11 + case 92: stack.push(new java_lang_IllegalArgumentException); // 187 0 193 + case 95: stack.push(stack[stack.length - 1]); // 89 + case 96: { java_lang_IllegalArgumentException_consV(stack.pop()); } // 183 1 123 + case 99: // 191 + case 100: stack.push(arg5); // 21 5 + case 102: if (stack.pop() > 0) { gt = 195; continue; } // 157 0 93 + case 105: stack.push(arg8); // 21 8 + case 107: stack.push(1); // 4 + case 108: stack.push(stack.pop() + stack.pop()); // 96 + case 109: stack.push(arg6); // 25 6 + case 111: stack.push(stack.pop().length); // 190 + case 112: if (stack.pop() > stack.pop()) { gt = 195; continue; } // 161 0 83 + case 115: stack.push(arg4); // 21 4 + case 117: if (stack.pop() != 0) { gt = 153; continue; } // 154 0 36 + case 120: stack.push(arg5); // 21 5 + case 122: // 116 + case 123: stack.push(1); // 4 + case 124: stack.push(stack.pop() + stack.pop()); // 96 + case 125: stack.push(arg3); // 29 + case 126: stack.push(stack.pop() * stack.pop()); // 104 + case 127: stack.push(10); // 16 10 + case 129: // 120 + case 130: stack.push(arg9); // 21 9 + case 132: { var tmp = stack.pop(); stack.push(Math.floor(stack.pop() / tmp)); } // 108 + case 133: arg4 = stack.pop() // 54 4 + case 135: stack.push(arg4); // 21 4 + case 137: stack.push(10); // 16 10 + case 139: // 122 + case 140: arg4 = stack.pop() // 54 4 + case 142: stack.push(arg4); // 21 4 + case 144: if (stack.pop() > 0) { gt = 159; continue; } // 157 0 15 + case 147: stack.push(1); // 4 + case 148: arg4 = stack.pop() // 54 4 + case 150: gt = 159; continue; // 167 0 9 + case 153: stack.push(arg4); // 21 4 + case 155: stack.push(2); // 5 + case 156: stack.push(stack.pop() * stack.pop()); // 104 + case 157: arg4 = stack.pop() // 54 4 + case 159: stack.push(arg6); // 25 6 + case 161: stack.push(stack.pop().length); // 190 + case 162: stack.push(arg4); // 21 4 + case 164: stack.push(stack.pop() + stack.pop()); // 96 + case 165: stack.push(arg3); // 29 + case 166: stack.push(2); // 5 + case 167: stack.push(stack.pop() * stack.pop()); // 104 + case 168: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Math_minIII(v0, v1)); } // 184 1 127 + case 171: arg11 = stack.pop() // 54 11 + case 173: stack.push(arg11); // 21 11 + case 175: stack.push(arg6); // 25 6 + case 177: stack.push(stack.pop().length); // 190 + case 178: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 179: stack.push(arg3); // 29 + case 180: stack.push(arg9); // 21 9 + case 182: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 183: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 184: arg5 = stack.pop() // 54 5 + case 186: stack.push(arg6); // 25 6 + case 188: stack.push(arg11); // 21 11 + case 190: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_util_Arrays_copyOfACACAI(v0, v1)); } // 184 1 172 + case 193: arg6 = stack.pop() // 58 6 + case 195: stack.push(arg10); // 21 10 + case 197: stack.push(65536); // 18 3 + case 199: if (stack.pop() <= stack.pop()) { gt = 216; continue; } // 162 0 17 + case 202: stack.push(arg6); // 25 6 + case 204: stack.push(arg8); // 21 8 + case 206: arg8++; // 132 8 1 + case 209: stack.push(arg10); // 21 10 + case 211: // number conversion // 146 + case 212: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 213: gt = 249; continue; // 167 0 36 + case 216: stack.push(arg10); // 21 10 + case 218: stack.push(1114111); // 18 4 + case 220: if (stack.pop() < stack.pop()) { gt = 241; continue; } // 163 0 21 + case 223: stack.push(arg10); // 21 10 + case 225: stack.push(arg6); // 25 6 + case 227: stack.push(arg8); // 21 8 + case 229: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_Character_toSurrogatesVIACAI(v0, v1, v2); } // 184 1 112 + case 232: arg8 += 2; // 132 8 2 + case 235: arg5 += 255; // 132 5 255 + case 238: gt = 249; continue; // 167 0 11 + case 241: stack.push(new java_lang_IllegalArgumentException); // 187 0 193 + case 244: stack.push(stack[stack.length - 1]); // 89 + case 245: { java_lang_IllegalArgumentException_consV(stack.pop()); } // 183 1 123 + case 248: // 191 + case 249: arg9++; // 132 9 1 + case 252: gt = 72; continue; // 167 255 76 + case 255: stack.push(arg0); // 42 + case 256: stack.push(0); // 3 + case 257: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99 + case 260: stack.push(arg0); // 42 + case 261: stack.push(arg6); // 25 6 + case 263: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100 + case 266: stack.push(arg0); // 42 + case 267: stack.push(arg8); // 21 8 + case 269: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97 + case 272: return; // 177 + } +} +function java_lang_String_consVABIII(arg0,arg1,arg2,arg3,arg4) { + var arg5; + var arg6; + var arg7; +; + var stack = new Array(6); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130 + case 4: stack.push(arg1); // 43 + case 5: stack.push(arg3); // 29 + case 6: stack.push(arg4); // 21 4 + case 8: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_checkBoundsVABAIAI(v0, v1, v2); } // 184 1 140 + case 11: stack.push(arg4); // 21 4 + case 13: stack.push(new Array(stack.pop())); // 188 5 + case 15: arg5 = stack.pop() // 58 5 + case 17: stack.push(arg2); // 28 + case 18: if (stack.pop() != 0) { gt = 55; continue; } // 154 0 37 + case 21: stack.push(arg4); // 21 4 + case 23: arg6 = stack.pop() // 54 6 + case 25: stack.push(arg6); // 21 6 + case 27: arg6 += 255; // 132 6 255 + case 30: if (stack.pop() <= 0) { gt = 52; continue; } // 158 0 22 + case 33: stack.push(arg5); // 25 5 + case 35: stack.push(arg6); // 21 6 + case 37: stack.push(arg1); // 43 + case 38: stack.push(arg6); // 21 6 + case 40: stack.push(arg3); // 29 + case 41: stack.push(stack.pop() + stack.pop()); // 96 + case 42: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 51 + case 43: stack.push(255); // 17 0 255 + case 46: stack.push(stack.pop() & stack.pop()); // 126 + case 47: // number conversion // 146 + case 48: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 49: gt = 25; continue; // 167 255 232 + case 52: gt = 93; continue; // 167 0 41 + case 55: stack.push(arg2); // 28 + case 56: stack.push(8); // 16 8 + case 58: // 120 + case 59: arg2 = stack.pop(); // 61 + case 60: stack.push(arg4); // 21 4 + case 62: arg6 = stack.pop() // 54 6 + case 64: stack.push(arg6); // 21 6 + case 66: arg6 += 255; // 132 6 255 + case 69: if (stack.pop() <= 0) { gt = 93; continue; } // 158 0 24 + case 72: stack.push(arg5); // 25 5 + case 74: stack.push(arg6); // 21 6 + case 76: stack.push(arg2); // 28 + case 77: stack.push(arg1); // 43 + case 78: stack.push(arg6); // 21 6 + case 80: stack.push(arg3); // 29 + case 81: stack.push(stack.pop() + stack.pop()); // 96 + case 82: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 51 + case 83: stack.push(255); // 17 0 255 + case 86: stack.push(stack.pop() & stack.pop()); // 126 + case 87: stack.push(stack.pop() | stack.pop()); // 128 + case 88: // number conversion // 146 + case 89: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 90: gt = 64; continue; // 167 255 230 + case 93: stack.push(arg0); // 42 + case 94: stack.push(0); // 3 + case 95: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99 + case 98: stack.push(arg0); // 42 + case 99: stack.push(arg4); // 21 4 + case 101: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97 + case 104: stack.push(arg0); // 42 + case 105: stack.push(arg5); // 25 5 + case 107: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100 + case 110: return; // 177 + } +} +function java_lang_String_consVABI(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(arg2); // 28 + case 3: stack.push(0); // 3 + case 4: stack.push(arg1); // 43 + case 5: stack.push(stack.pop().length); // 190 + case 6: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVABAIAIAI(stack.pop(), v0, v1, v2, v3); } // 183 1 141 + case 9: return; // 177 + } +} +function java_lang_String_checkBoundsVABII(arg0,arg1,arg2) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg2); // 28 + case 1: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 12 + case 4: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 7: stack.push(stack[stack.length - 1]); // 89 + case 8: stack.push(arg2); // 28 + case 9: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 12: // 191 + case 13: stack.push(arg1); // 27 + case 14: if (stack.pop() >= 0) { gt = 26; continue; } // 156 0 12 + case 17: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 20: stack.push(stack[stack.length - 1]); // 89 + case 21: stack.push(arg1); // 27 + case 22: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 25: // 191 + case 26: stack.push(arg1); // 27 + case 27: stack.push(arg0); // 42 + case 28: stack.push(stack.pop().length); // 190 + case 29: stack.push(arg2); // 28 + case 30: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 31: if (stack.pop() >= stack.pop()) { gt = 45; continue; } // 164 0 14 + case 34: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 37: stack.push(stack[stack.length - 1]); // 89 + case 38: stack.push(arg1); // 27 + case 39: stack.push(arg2); // 28 + case 40: stack.push(stack.pop() + stack.pop()); // 96 + case 41: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 44: // 191 + case 45: return; // 177 + } +} +function java_lang_String_consVABIILjava_lang_String(arg0,arg1,arg2,arg3,arg4) { + var arg5; + var arg6; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130 + case 4: stack.push(arg4); // 25 4 + case 6: if (stack.pop()) { gt = 19; continue; } // 199 0 13 + case 9: stack.push(new java_lang_NullPointerException); // 187 0 198 + case 12: stack.push(stack[stack.length - 1]); // 89 + case 13: stack.push("charsetName"); // 18 7 + case 15: { var v0 = stack.pop(); java_lang_NullPointerException_consVLjava_lang_String(stack.pop(), v0); } // 183 1 129 + case 18: // 191 + case 19: stack.push(arg1); // 43 + case 20: stack.push(arg2); // 28 + case 21: stack.push(arg3); // 29 + case 22: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_checkBoundsVABAIAI(v0, v1, v2); } // 184 1 140 + case 25: stack.push(arg4); // 25 4 + case 27: stack.push(arg1); // 43 + case 28: stack.push(arg2); // 28 + case 29: stack.push(arg3); // 29 + case 30: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_StringCoding_decodeACLjava_lang_StringABAIAI(v0, v1, v2, v3)); } // 184 1 165 + case 33: arg5 = stack.pop() // 58 5 + case 35: stack.push(arg0); // 42 + case 36: stack.push(0); // 3 + case 37: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99 + case 40: stack.push(arg0); // 42 + case 41: stack.push(arg5); // 25 5 + case 43: stack.push(stack.pop().length); // 190 + case 44: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97 + case 47: stack.push(arg0); // 42 + case 48: stack.push(arg5); // 25 5 + case 50: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100 + case 53: return; // 177 + } +} +function java_lang_String_consVABIILjava_nio_charset_Charset(arg0,arg1,arg2,arg3,arg4) { + var arg5; + var arg6; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130 + case 4: stack.push(arg4); // 25 4 + case 6: if (stack.pop()) { gt = 19; continue; } // 199 0 13 + case 9: stack.push(new java_lang_NullPointerException); // 187 0 198 + case 12: stack.push(stack[stack.length - 1]); // 89 + case 13: stack.push("charset"); // 18 6 + case 15: { var v0 = stack.pop(); java_lang_NullPointerException_consVLjava_lang_String(stack.pop(), v0); } // 183 1 129 + case 18: // 191 + case 19: stack.push(arg1); // 43 + case 20: stack.push(arg2); // 28 + case 21: stack.push(arg3); // 29 + case 22: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_checkBoundsVABAIAI(v0, v1, v2); } // 184 1 140 + case 25: stack.push(arg4); // 25 4 + case 27: stack.push(arg1); // 43 + case 28: stack.push(arg2); // 28 + case 29: stack.push(arg3); // 29 + case 30: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_StringCoding_decodeACLjava_nio_charset_CharsetABAIAI(v0, v1, v2, v3)); } // 184 1 167 + case 33: arg5 = stack.pop() // 58 5 + case 35: stack.push(arg0); // 42 + case 36: stack.push(0); // 3 + case 37: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99 + case 40: stack.push(arg0); // 42 + case 41: stack.push(arg5); // 25 5 + case 43: stack.push(stack.pop().length); // 190 + case 44: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97 + case 47: stack.push(arg0); // 42 + case 48: stack.push(arg5); // 25 5 + case 50: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100 + case 53: return; // 177 + } +} +function java_lang_String_consVABLjava_lang_String(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(0); // 3 + case 3: stack.push(arg1); // 43 + case 4: stack.push(stack.pop().length); // 190 + case 5: stack.push(arg2); // 44 + case 6: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVABAIAIALjava_lang_String(stack.pop(), v0, v1, v2, v3); } // 183 1 154 + case 9: return; // 177 + } +} +function java_lang_String_consVABLjava_nio_charset_Charset(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(0); // 3 + case 3: stack.push(arg1); // 43 + case 4: stack.push(stack.pop().length); // 190 + case 5: stack.push(arg2); // 44 + case 6: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVABAIAIALjava_nio_charset_Charset(stack.pop(), v0, v1, v2, v3); } // 183 1 156 + case 9: return; // 177 + } +} +function java_lang_String_consVABII(arg0,arg1,arg2,arg3) { + var arg4; + var arg5; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130 + case 4: stack.push(arg1); // 43 + case 5: stack.push(arg2); // 28 + case 6: stack.push(arg3); // 29 + case 7: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_checkBoundsVABAIAI(v0, v1, v2); } // 184 1 140 + case 10: stack.push(arg1); // 43 + case 11: stack.push(arg2); // 28 + case 12: stack.push(arg3); // 29 + case 13: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_StringCoding_decodeACABAIAI(v0, v1, v2)); } // 184 1 163 + case 16: arg4 = stack.pop() // 58 4 + case 18: stack.push(arg0); // 42 + case 19: stack.push(0); // 3 + case 20: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99 + case 23: stack.push(arg0); // 42 + case 24: stack.push(arg4); // 25 4 + case 26: stack.push(stack.pop().length); // 190 + case 27: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97 + case 30: stack.push(arg0); // 42 + case 31: stack.push(arg4); // 25 4 + case 33: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100 + case 36: return; // 177 + } +} +function java_lang_String_consVAB(arg0,arg1) { + var arg2; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(0); // 3 + case 3: stack.push(arg1); // 43 + case 4: stack.push(stack.pop().length); // 190 + case 5: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVABAIAI(stack.pop(), v0, v1, v2); } // 183 1 139 + case 8: return; // 177 + } +} +function java_lang_String_consVLjava_lang_StringBuffer(arg0,arg1) { + var arg2; + var arg3; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130 + case 4: stack.push(arg1); // 43 + case 5: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 161 + case 8: arg2 = stack.pop(); // 77 + case 9: stack.push(arg0); // 42 + case 10: stack.push(arg2); // 44 + case 11: stack.push(stack.pop().value); // 180 1 100 + case 14: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100 + case 17: stack.push(arg0); // 42 + case 18: stack.push(arg2); // 44 + case 19: stack.push(stack.pop().count); // 180 1 97 + case 22: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97 + case 25: stack.push(arg0); // 42 + case 26: stack.push(arg2); // 44 + case 27: stack.push(stack.pop().offset); // 180 1 99 + case 30: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99 + case 33: return; // 177 + } +} +function java_lang_String_consVLjava_lang_StringBuilder(arg0,arg1) { + var arg2; + var arg3; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130 + case 4: stack.push(arg1); // 43 + case 5: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 162 + case 8: arg2 = stack.pop(); // 77 + case 9: stack.push(arg0); // 42 + case 10: stack.push(arg2); // 44 + case 11: stack.push(stack.pop().value); // 180 1 100 + case 14: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100 + case 17: stack.push(arg0); // 42 + case 18: stack.push(arg2); // 44 + case 19: stack.push(stack.pop().count); // 180 1 97 + case 22: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97 + case 25: stack.push(arg0); // 42 + case 26: stack.push(arg2); // 44 + case 27: stack.push(stack.pop().offset); // 180 1 99 + case 30: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99 + case 33: return; // 177 + } +} +function java_lang_String_consVIIAC(arg0,arg1,arg2,arg3) { + var arg4; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130 + case 4: stack.push(arg0); // 42 + case 5: stack.push(arg3); // 45 + case 6: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100 + case 9: stack.push(arg0); // 42 + case 10: stack.push(arg1); // 27 + case 11: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99 + case 14: stack.push(arg0); // 42 + case 15: stack.push(arg2); // 28 + case 16: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97 + case 19: return; // 177 + } +} +*/ + +function java_lang_String_charAtCI(arg0,arg1) { + return arg0.toString().charAt(arg1); +} +function java_lang_String_lengthI(arg0) { + return arg0.toString().length; +} +function java_lang_String_isEmptyZ(arg0) { + return arg0.toString().length === 0; +} + +/* +function java_lang_String_codePointAtII(arg0,arg1) { + var arg2; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: if (stack.pop() < 0) { gt = 12; continue; } // 155 0 11 + case 4: stack.push(arg1); // 27 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().count); // 180 1 97 + case 9: if (stack.pop() > stack.pop()) { gt = 21; continue; } // 161 0 12 + case 12: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 15: stack.push(stack[stack.length - 1]); // 89 + case 16: stack.push(arg1); // 27 + case 17: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 20: // 191 + case 21: stack.push(arg0); // 42 + case 22: stack.push(stack.pop().value); // 180 1 100 + case 25: stack.push(arg0); // 42 + case 26: stack.push(stack.pop().offset); // 180 1 99 + case 29: stack.push(arg1); // 27 + case 30: stack.push(stack.pop() + stack.pop()); // 96 + case 31: stack.push(arg0); // 42 + case 32: stack.push(stack.pop().offset); // 180 1 99 + case 35: stack.push(arg0); // 42 + case 36: stack.push(stack.pop().count); // 180 1 97 + case 39: stack.push(stack.pop() + stack.pop()); // 96 + case 40: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Character_codePointAtImplAIACAIAI(v0, v1, v2)); } // 184 1 113 + case 43: return stack.pop(); // 172 + } +} +function java_lang_String_codePointBeforeII(arg0,arg1) { + var arg2; + var arg3; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: stack.push(1); // 4 + case 2: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 3: arg2 = stack.pop(); // 61 + case 4: stack.push(arg2); // 28 + case 5: if (stack.pop() < 0) { gt = 16; continue; } // 155 0 11 + case 8: stack.push(arg2); // 28 + case 9: stack.push(arg0); // 42 + case 10: stack.push(stack.pop().count); // 180 1 97 + case 13: if (stack.pop() > stack.pop()) { gt = 25; continue; } // 161 0 12 + case 16: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 19: stack.push(stack[stack.length - 1]); // 89 + case 20: stack.push(arg1); // 27 + case 21: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 24: // 191 + case 25: stack.push(arg0); // 42 + case 26: stack.push(stack.pop().value); // 180 1 100 + case 29: stack.push(arg0); // 42 + case 30: stack.push(stack.pop().offset); // 180 1 99 + case 33: stack.push(arg1); // 27 + case 34: stack.push(stack.pop() + stack.pop()); // 96 + case 35: stack.push(arg0); // 42 + case 36: stack.push(stack.pop().offset); // 180 1 99 + case 39: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Character_codePointBeforeImplAIACAIAI(v0, v1, v2)); } // 184 1 114 + case 42: return stack.pop(); // 172 + } +} +function java_lang_String_codePointCountIII(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: if (stack.pop() < 0) { gt = 17; continue; } // 155 0 16 + case 4: stack.push(arg2); // 28 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().count); // 180 1 97 + case 9: if (stack.pop() < stack.pop()) { gt = 17; continue; } // 163 0 8 + case 12: stack.push(arg1); // 27 + case 13: stack.push(arg2); // 28 + case 14: if (stack.pop() >= stack.pop()) { gt = 25; continue; } // 164 0 11 + case 17: stack.push(new java_lang_IndexOutOfBoundsException); // 187 0 194 + case 20: stack.push(stack[stack.length - 1]); // 89 + case 21: { java_lang_IndexOutOfBoundsException_consV(stack.pop()); } // 183 1 124 + case 24: // 191 + case 25: stack.push(arg0); // 42 + case 26: stack.push(stack.pop().value); // 180 1 100 + case 29: stack.push(arg0); // 42 + case 30: stack.push(stack.pop().offset); // 180 1 99 + case 33: stack.push(arg1); // 27 + case 34: stack.push(stack.pop() + stack.pop()); // 96 + case 35: stack.push(arg2); // 28 + case 36: stack.push(arg1); // 27 + case 37: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 38: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Character_codePointCountImplAIACAIAI(v0, v1, v2)); } // 184 1 115 + case 41: return stack.pop(); // 172 + } +} +function java_lang_String_offsetByCodePointsIII(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: if (stack.pop() < 0) { gt = 12; continue; } // 155 0 11 + case 4: stack.push(arg1); // 27 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().count); // 180 1 97 + case 9: if (stack.pop() >= stack.pop()) { gt = 20; continue; } // 164 0 11 + case 12: stack.push(new java_lang_IndexOutOfBoundsException); // 187 0 194 + case 15: stack.push(stack[stack.length - 1]); // 89 + case 16: { java_lang_IndexOutOfBoundsException_consV(stack.pop()); } // 183 1 124 + case 19: // 191 + case 20: stack.push(arg0); // 42 + case 21: stack.push(stack.pop().value); // 180 1 100 + case 24: stack.push(arg0); // 42 + case 25: stack.push(stack.pop().offset); // 180 1 99 + case 28: stack.push(arg0); // 42 + case 29: stack.push(stack.pop().count); // 180 1 97 + case 32: stack.push(arg0); // 42 + case 33: stack.push(stack.pop().offset); // 180 1 99 + case 36: stack.push(arg1); // 27 + case 37: stack.push(stack.pop() + stack.pop()); // 96 + case 38: stack.push(arg2); // 28 + case 39: { var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Character_offsetByCodePointsImplAIACAIAIAIAI(v0, v1, v2, v3, v4)); } // 184 1 116 + case 42: stack.push(arg0); // 42 + case 43: stack.push(stack.pop().offset); // 180 1 99 + case 46: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 47: return stack.pop(); // 172 + } +} +*/ + +// public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) { +function java_lang_String_getCharsVIIACAI(arg0,arg1,arg2,arg3,arg4) { + var s = arg0.toString(); + while (arg1 < arg2) { + arg3[arg4++] = s[arg1++]; + } +} + +/* +function java_lang_String_getBytesVIIABI(arg0,arg1,arg2,arg3,arg4) { + var arg5; + var arg6; + var arg7; + var arg8; + var arg9; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 12 + case 4: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 7: stack.push(stack[stack.length - 1]); // 89 + case 8: stack.push(arg1); // 27 + case 9: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 12: // 191 + case 13: stack.push(arg2); // 28 + case 14: stack.push(arg0); // 42 + case 15: stack.push(stack.pop().count); // 180 1 97 + case 18: if (stack.pop() >= stack.pop()) { gt = 30; continue; } // 164 0 12 + case 21: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 24: stack.push(stack[stack.length - 1]); // 89 + case 25: stack.push(arg2); // 28 + case 26: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 29: // 191 + case 30: stack.push(arg1); // 27 + case 31: stack.push(arg2); // 28 + case 32: if (stack.pop() >= stack.pop()) { gt = 46; continue; } // 164 0 14 + case 35: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 38: stack.push(stack[stack.length - 1]); // 89 + case 39: stack.push(arg2); // 28 + case 40: stack.push(arg1); // 27 + case 41: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 42: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 45: // 191 + case 46: stack.push(arg4); // 21 4 + case 48: arg5 = stack.pop() // 54 5 + case 50: stack.push(arg0); // 42 + case 51: stack.push(stack.pop().offset); // 180 1 99 + case 54: stack.push(arg2); // 28 + case 55: stack.push(stack.pop() + stack.pop()); // 96 + case 56: arg6 = stack.pop() // 54 6 + case 58: stack.push(arg0); // 42 + case 59: stack.push(stack.pop().offset); // 180 1 99 + case 62: stack.push(arg1); // 27 + case 63: stack.push(stack.pop() + stack.pop()); // 96 + case 64: arg7 = stack.pop() // 54 7 + case 66: stack.push(arg0); // 42 + case 67: stack.push(stack.pop().value); // 180 1 100 + case 70: arg8 = stack.pop() // 58 8 + case 72: stack.push(arg7); // 21 7 + case 74: stack.push(arg6); // 21 6 + case 76: if (stack.pop() <= stack.pop()) { gt = 98; continue; } // 162 0 22 + case 79: stack.push(arg3); // 45 + case 80: stack.push(arg5); // 21 5 + case 82: arg5++; // 132 5 1 + case 85: stack.push(arg8); // 25 8 + case 87: stack.push(arg7); // 21 7 + case 89: arg7++; // 132 7 1 + case 92: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 93: // number conversion // 145 + case 94: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 84 + case 95: gt = 72; continue; // 167 255 233 + case 98: return; // 177 + } +} +function java_lang_String_getBytesABLjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198 + case 7: stack.push(stack[stack.length - 1]); // 89 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128 + case 11: // 191 + case 12: stack.push(arg1); // 43 + case 13: stack.push(arg0); // 42 + case 14: stack.push(stack.pop().value); // 180 1 100 + case 17: stack.push(arg0); // 42 + case 18: stack.push(stack.pop().offset); // 180 1 99 + case 21: stack.push(arg0); // 42 + case 22: stack.push(stack.pop().count); // 180 1 97 + case 25: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_StringCoding_encodeABLjava_lang_StringACAIAI(v0, v1, v2, v3)); } // 184 1 166 + case 28: return stack.pop(); // 176 + } +} +function java_lang_String_getBytesABLjava_nio_charset_Charset(arg0,arg1) { + var arg2; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198 + case 7: stack.push(stack[stack.length - 1]); // 89 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128 + case 11: // 191 + case 12: stack.push(arg1); // 43 + case 13: stack.push(arg0); // 42 + case 14: stack.push(stack.pop().value); // 180 1 100 + case 17: stack.push(arg0); // 42 + case 18: stack.push(stack.pop().offset); // 180 1 99 + case 21: stack.push(arg0); // 42 + case 22: stack.push(stack.pop().count); // 180 1 97 + case 25: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_StringCoding_encodeABLjava_nio_charset_CharsetACAIAI(v0, v1, v2, v3)); } // 184 1 168 + case 28: return stack.pop(); // 176 + } +} +function java_lang_String_getBytesAB(arg0) { + var arg1; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().value); // 180 1 100 + case 4: stack.push(arg0); // 42 + case 5: stack.push(stack.pop().offset); // 180 1 99 + case 8: stack.push(arg0); // 42 + case 9: stack.push(stack.pop().count); // 180 1 97 + case 12: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_StringCoding_encodeABACAIAI(v0, v1, v2)); } // 184 1 164 + case 15: return stack.pop(); // 176 + } +} +function java_lang_String_equalsZLjava_lang_Object(arg0,arg1) { + var arg2; + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: // 166 + case 3: // 0 + case 4: stack.push(2); // 5 + case 5: stack.push(1); // 4 + case 6: return stack.pop(); // 172 + case 7: stack.push(arg1); // 43 + case 8: stack.push(stack.pop().$instOf_java_lang_String ? 1 : 0); // 193 0 200 + case 11: if (stack.pop() == 0) { gt = 86; continue; } // 153 0 75 + case 14: stack.push(arg1); // 43 + case 15: if(stack[stack.length - 1].$instOf_java_lang_String != 1) throw {}; // 192 0 200 + case 18: arg2 = stack.pop(); // 77 + case 19: stack.push(arg0); // 42 + case 20: stack.push(stack.pop().count); // 180 1 97 + case 23: arg3 = stack.pop(); // 62 + case 24: stack.push(arg3); // 29 + case 25: stack.push(arg2); // 44 + case 26: stack.push(stack.pop().count); // 180 1 97 + case 29: if (stack.pop() != stack.pop()) { gt = 86; continue; } // 160 0 57 + case 32: stack.push(arg0); // 42 + case 33: stack.push(stack.pop().value); // 180 1 100 + case 36: arg4 = stack.pop() // 58 4 + case 38: stack.push(arg2); // 44 + case 39: stack.push(stack.pop().value); // 180 1 100 + case 42: arg5 = stack.pop() // 58 5 + case 44: stack.push(arg0); // 42 + case 45: stack.push(stack.pop().offset); // 180 1 99 + case 48: arg6 = stack.pop() // 54 6 + case 50: stack.push(arg2); // 44 + case 51: stack.push(stack.pop().offset); // 180 1 99 + case 54: arg7 = stack.pop() // 54 7 + case 56: stack.push(arg3); // 29 + case 57: arg3 += 255; // 132 3 255 + case 60: if (stack.pop() == 0) { gt = 84; continue; } // 153 0 24 + case 63: stack.push(arg4); // 25 4 + case 65: stack.push(arg6); // 21 6 + case 67: arg6++; // 132 6 1 + case 70: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 71: stack.push(arg5); // 25 5 + case 73: stack.push(arg7); // 21 7 + case 75: arg7++; // 132 7 1 + case 78: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 79: if (stack.pop() == stack.pop()) { gt = 56; continue; } // 159 255 233 + case 82: stack.push(0); // 3 + case 83: return stack.pop(); // 172 + case 84: stack.push(1); // 4 + case 85: return stack.pop(); // 172 + case 86: stack.push(0); // 3 + case 87: return stack.pop(); // 172 + } +} +function java_lang_String_contentEqualsZLjava_lang_StringBuffer(arg0,arg1) { + var arg2; + var arg3; + var arg4; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: stack.push(stack[stack.length - 1]); // 89 + case 2: arg2 = stack.pop(); // 77 + case 3: // 194 + case 4: stack.push(arg0); // 42 + case 5: stack.push(arg1); // 43 + case 6: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.contentEqualsZLjava_lang_CharSequence(self, v0)); } // 182 1 146 + case 9: stack.push(arg2); // 44 + case 10: // 195 + case 11: return stack.pop(); // 172 + case 12: arg3 = stack.pop(); // 78 + case 13: stack.push(arg2); // 44 + case 14: // 195 + case 15: stack.push(arg3); // 45 + case 16: // 191 + } +} +function java_lang_String_contentEqualsZLjava_lang_CharSequence(arg0,arg1) { + var arg2; + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().count); // 180 1 97 + case 4: stack.push(arg1); // 43 + case 5: { var self = stack.pop(); stack.push(self.lengthI(self)); } // 185 1 188 + case 8: // 1 + case 9: // 0 + case 10: if (stack.pop() == stack.pop()) { gt = 15; continue; } // 159 0 5 + case 13: stack.push(0); // 3 + case 14: return stack.pop(); // 172 + case 15: stack.push(arg1); // 43 + case 16: stack.push(stack.pop().$instOf_java_lang_AbstractStringBuilder ? 1 : 0); // 193 0 186 + case 19: if (stack.pop() == 0) { gt = 77; continue; } // 153 0 58 + case 22: stack.push(arg0); // 42 + case 23: stack.push(stack.pop().value); // 180 1 100 + case 26: arg2 = stack.pop(); // 77 + case 27: stack.push(arg1); // 43 + case 28: if(stack[stack.length - 1].$instOf_java_lang_AbstractStringBuilder != 1) throw {}; // 192 0 186 + case 31: { var self = stack.pop(); stack.push(self.getValueAC(self)); } // 182 1 103 + case 34: arg3 = stack.pop(); // 78 + case 35: stack.push(arg0); // 42 + case 36: stack.push(stack.pop().offset); // 180 1 99 + case 39: arg4 = stack.pop() // 54 4 + case 41: stack.push(0); // 3 + case 42: arg5 = stack.pop() // 54 5 + case 44: stack.push(arg0); // 42 + case 45: stack.push(stack.pop().count); // 180 1 97 + case 48: arg6 = stack.pop() // 54 6 + case 50: stack.push(arg6); // 21 6 + case 52: arg6 += 255; // 132 6 255 + case 55: if (stack.pop() == 0) { gt = 77; continue; } // 153 0 22 + case 58: stack.push(arg2); // 44 + case 59: stack.push(arg4); // 21 4 + case 61: arg4++; // 132 4 1 + case 64: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 65: stack.push(arg3); // 45 + case 66: stack.push(arg5); // 21 5 + case 68: arg5++; // 132 5 1 + case 71: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 72: if (stack.pop() == stack.pop()) { gt = 50; continue; } // 159 255 234 + case 75: stack.push(0); // 3 + case 76: return stack.pop(); // 172 + case 77: stack.push(arg1); // 43 + case 78: stack.push(arg0); // 42 + case 79: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.equalsZLjava_lang_Object(self, v0)); } // 182 1 131 + case 82: if (stack.pop() == 0) { gt = 87; continue; } // 153 0 5 + case 85: stack.push(1); // 4 + case 86: return stack.pop(); // 172 + case 87: stack.push(arg0); // 42 + case 88: stack.push(stack.pop().value); // 180 1 100 + case 91: arg2 = stack.pop(); // 77 + case 92: stack.push(arg0); // 42 + case 93: stack.push(stack.pop().offset); // 180 1 99 + case 96: arg3 = stack.pop(); // 62 + case 97: stack.push(0); // 3 + case 98: arg4 = stack.pop() // 54 4 + case 100: stack.push(arg0); // 42 + case 101: stack.push(stack.pop().count); // 180 1 97 + case 104: arg5 = stack.pop() // 54 5 + case 106: stack.push(arg5); // 21 5 + case 108: arg5 += 255; // 132 5 255 + case 111: if (stack.pop() == 0) { gt = 136; continue; } // 153 0 25 + case 114: stack.push(arg2); // 44 + case 115: stack.push(arg3); // 29 + case 116: arg3++; // 132 3 1 + case 119: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 120: stack.push(arg1); // 43 + case 121: stack.push(arg4); // 21 4 + case 123: arg4++; // 132 4 1 + case 126: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.charAtCI(self, v0)); } // 185 1 189 + case 129: // 2 + case 130: // 0 + case 131: if (stack.pop() == stack.pop()) { gt = 106; continue; } // 159 255 231 + case 134: stack.push(0); // 3 + case 135: return stack.pop(); // 172 + case 136: stack.push(1); // 4 + case 137: return stack.pop(); // 172 + } +} +function java_lang_String_equalsIgnoreCaseZLjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(6); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: // 166 + case 3: // 0 + case 4: stack.push(4); // 7 + case 5: stack.push(1); // 4 + case 6: gt = 44; continue; // 167 0 38 + case 9: stack.push(arg1); // 43 + case 10: if (!stack.pop()) { gt = 43; continue; } // 198 0 33 + case 13: stack.push(arg1); // 43 + case 14: stack.push(stack.pop().count); // 180 1 97 + case 17: stack.push(arg0); // 42 + case 18: stack.push(stack.pop().count); // 180 1 97 + case 21: if (stack.pop() != stack.pop()) { gt = 43; continue; } // 160 0 22 + case 24: stack.push(arg0); // 42 + case 25: stack.push(1); // 4 + case 26: stack.push(0); // 3 + case 27: stack.push(arg1); // 43 + case 28: stack.push(0); // 3 + case 29: stack.push(arg0); // 42 + case 30: stack.push(stack.pop().count); // 180 1 97 + case 33: { var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.regionMatchesZZILjava_lang_StringII(self, v0, v1, v2, v3, v4)); } // 182 1 153 + case 36: if (stack.pop() == 0) { gt = 43; continue; } // 153 0 7 + case 39: stack.push(1); // 4 + case 40: gt = 44; continue; // 167 0 4 + case 43: stack.push(0); // 3 + case 44: return stack.pop(); // 172 + } +} +function java_lang_String_compareToILjava_lang_String(arg0,arg1) { + var arg2; + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; + var arg9; + var arg10; + var arg11; + var arg12; + var arg13; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().count); // 180 1 97 + case 4: arg2 = stack.pop(); // 61 + case 5: stack.push(arg1); // 43 + case 6: stack.push(stack.pop().count); // 180 1 97 + case 9: arg3 = stack.pop(); // 62 + case 10: stack.push(arg2); // 28 + case 11: stack.push(arg3); // 29 + case 12: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Math_minIII(v0, v1)); } // 184 1 127 + case 15: arg4 = stack.pop() // 54 4 + case 17: stack.push(arg0); // 42 + case 18: stack.push(stack.pop().value); // 180 1 100 + case 21: arg5 = stack.pop() // 58 5 + case 23: stack.push(arg1); // 43 + case 24: stack.push(stack.pop().value); // 180 1 100 + case 27: arg6 = stack.pop() // 58 6 + case 29: stack.push(arg0); // 42 + case 30: stack.push(stack.pop().offset); // 180 1 99 + case 33: arg7 = stack.pop() // 54 7 + case 35: stack.push(arg1); // 43 + case 36: stack.push(stack.pop().offset); // 180 1 99 + case 39: arg8 = stack.pop() // 54 8 + case 41: stack.push(arg7); // 21 7 + case 43: stack.push(arg8); // 21 8 + case 45: if (stack.pop() != stack.pop()) { gt = 102; continue; } // 160 0 57 + case 48: stack.push(arg7); // 21 7 + case 50: arg9 = stack.pop() // 54 9 + case 52: stack.push(arg4); // 21 4 + case 54: stack.push(arg7); // 21 7 + case 56: stack.push(stack.pop() + stack.pop()); // 96 + case 57: arg10 = stack.pop() // 54 10 + case 59: stack.push(arg9); // 21 9 + case 61: stack.push(arg10); // 21 10 + case 63: if (stack.pop() <= stack.pop()) { gt = 99; continue; } // 162 0 36 + case 66: stack.push(arg5); // 25 5 + case 68: stack.push(arg9); // 21 9 + case 70: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 71: arg11 = stack.pop() // 54 11 + case 73: stack.push(arg6); // 25 6 + case 75: stack.push(arg9); // 21 9 + case 77: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 78: arg12 = stack.pop() // 54 12 + case 80: stack.push(arg11); // 21 11 + case 82: stack.push(arg12); // 21 12 + case 84: if (stack.pop() == stack.pop()) { gt = 93; continue; } // 159 0 9 + case 87: stack.push(arg11); // 21 11 + case 89: stack.push(arg12); // 21 12 + case 91: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 92: return stack.pop(); // 172 + case 93: arg9++; // 132 9 1 + case 96: gt = 59; continue; // 167 255 219 + case 99: gt = 146; continue; // 167 0 47 + case 102: stack.push(arg4); // 21 4 + case 104: arg4 += 255; // 132 4 255 + case 107: if (stack.pop() == 0) { gt = 146; continue; } // 153 0 39 + case 110: stack.push(arg5); // 25 5 + case 112: stack.push(arg7); // 21 7 + case 114: arg7++; // 132 7 1 + case 117: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 118: arg9 = stack.pop() // 54 9 + case 120: stack.push(arg6); // 25 6 + case 122: stack.push(arg8); // 21 8 + case 124: arg8++; // 132 8 1 + case 127: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 128: arg10 = stack.pop() // 54 10 + case 130: stack.push(arg9); // 21 9 + case 132: stack.push(arg10); // 21 10 + case 134: if (stack.pop() == stack.pop()) { gt = 143; continue; } // 159 0 9 + case 137: stack.push(arg9); // 21 9 + case 139: stack.push(arg10); // 21 10 + case 141: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 142: return stack.pop(); // 172 + case 143: gt = 102; continue; // 167 255 215 + case 146: stack.push(arg2); // 28 + case 147: stack.push(arg3); // 29 + case 148: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 149: return stack.pop(); // 172 + } +} +function java_lang_String_compareToIgnoreCaseILjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(java_lang_String_CASE_INSENSITIVE_ORDER); // 178 1 102 + case 3: stack.push(arg0); // 42 + case 4: stack.push(arg1); // 43 + case 5: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.compareILjava_lang_ObjectLjava_lang_Object(self, v0, v1)); } // 185 1 190 + case 8: stack.push(0); // 3 + case 9: // 0 + case 10: return stack.pop(); // 172 + } +} +function java_lang_String_regionMatchesZILjava_lang_StringII(arg0,arg1,arg2,arg3,arg4) { + var arg5; + var arg6; + var arg7; + var arg8; + var arg9; +; + var stack = new Array(6); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().value); // 180 1 100 + case 4: arg5 = stack.pop() // 58 5 + case 6: stack.push(arg0); // 42 + case 7: stack.push(stack.pop().offset); // 180 1 99 + case 10: stack.push(arg1); // 27 + case 11: stack.push(stack.pop() + stack.pop()); // 96 + case 12: arg6 = stack.pop() // 54 6 + case 14: stack.push(arg2); // 44 + case 15: stack.push(stack.pop().value); // 180 1 100 + case 18: arg7 = stack.pop() // 58 7 + case 20: stack.push(arg2); // 44 + case 21: stack.push(stack.pop().offset); // 180 1 99 + case 24: stack.push(arg3); // 29 + case 25: stack.push(stack.pop() + stack.pop()); // 96 + case 26: arg8 = stack.pop() // 54 8 + case 28: stack.push(arg3); // 29 + case 29: if (stack.pop() < 0) { gt = 66; continue; } // 155 0 37 + case 32: stack.push(arg1); // 27 + case 33: if (stack.pop() < 0) { gt = 66; continue; } // 155 0 33 + case 36: stack.push(arg1); // 27 + case 37: // number conversion // 133 + case 38: stack.push(arg0); // 42 + case 39: stack.push(stack.pop().count); // 180 1 97 + case 42: // number conversion // 133 + case 43: stack.push(arg4); // 21 4 + case 45: // number conversion // 133 + case 46: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101 + case 47: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148 + case 48: if (stack.pop() > 0) { gt = 66; continue; } // 157 0 18 + case 51: stack.push(arg3); // 29 + case 52: // number conversion // 133 + case 53: stack.push(arg2); // 44 + case 54: stack.push(stack.pop().count); // 180 1 97 + case 57: // number conversion // 133 + case 58: stack.push(arg4); // 21 4 + case 60: // number conversion // 133 + case 61: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101 + case 62: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148 + case 63: if (stack.pop() <= 0) { gt = 68; continue; } // 158 0 5 + case 66: stack.push(0); // 3 + case 67: return stack.pop(); // 172 + case 68: stack.push(arg4); // 21 4 + case 70: arg4 += 255; // 132 4 255 + case 73: if (stack.pop() <= 0) { gt = 97; continue; } // 158 0 24 + case 76: stack.push(arg5); // 25 5 + case 78: stack.push(arg6); // 21 6 + case 80: arg6++; // 132 6 1 + case 83: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 84: stack.push(arg7); // 25 7 + case 86: stack.push(arg8); // 21 8 + case 88: arg8++; // 132 8 1 + case 91: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 92: if (stack.pop() == stack.pop()) { gt = 68; continue; } // 159 255 232 + case 95: stack.push(0); // 3 + case 96: return stack.pop(); // 172 + case 97: stack.push(1); // 4 + case 98: return stack.pop(); // 172 + } +} +function java_lang_String_regionMatchesZZILjava_lang_StringII(arg0,arg1,arg2,arg3,arg4,arg5) { + var arg6; + var arg7; + var arg8; + var arg9; + var arg10; + var arg11; + var arg12; + var arg13; + var arg14; +; + var stack = new Array(6); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().value); // 180 1 100 + case 4: arg6 = stack.pop() // 58 6 + case 6: stack.push(arg0); // 42 + case 7: stack.push(stack.pop().offset); // 180 1 99 + case 10: stack.push(arg2); // 28 + case 11: stack.push(stack.pop() + stack.pop()); // 96 + case 12: arg7 = stack.pop() // 54 7 + case 14: stack.push(arg3); // 45 + case 15: stack.push(stack.pop().value); // 180 1 100 + case 18: arg8 = stack.pop() // 58 8 + case 20: stack.push(arg3); // 45 + case 21: stack.push(stack.pop().offset); // 180 1 99 + case 24: stack.push(arg4); // 21 4 + case 26: stack.push(stack.pop() + stack.pop()); // 96 + case 27: arg9 = stack.pop() // 54 9 + case 29: stack.push(arg4); // 21 4 + case 31: if (stack.pop() < 0) { gt = 69; continue; } // 155 0 38 + case 34: stack.push(arg2); // 28 + case 35: if (stack.pop() < 0) { gt = 69; continue; } // 155 0 34 + case 38: stack.push(arg2); // 28 + case 39: // number conversion // 133 + case 40: stack.push(arg0); // 42 + case 41: stack.push(stack.pop().count); // 180 1 97 + case 44: // number conversion // 133 + case 45: stack.push(arg5); // 21 5 + case 47: // number conversion // 133 + case 48: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101 + case 49: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148 + case 50: if (stack.pop() > 0) { gt = 69; continue; } // 157 0 19 + case 53: stack.push(arg4); // 21 4 + case 55: // number conversion // 133 + case 56: stack.push(arg3); // 45 + case 57: stack.push(stack.pop().count); // 180 1 97 + case 60: // number conversion // 133 + case 61: stack.push(arg5); // 21 5 + case 63: // number conversion // 133 + case 64: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101 + case 65: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148 + case 66: if (stack.pop() <= 0) { gt = 71; continue; } // 158 0 5 + case 69: stack.push(0); // 3 + case 70: return stack.pop(); // 172 + case 71: stack.push(arg5); // 21 5 + case 73: arg5 += 255; // 132 5 255 + case 76: if (stack.pop() <= 0) { gt = 155; continue; } // 158 0 79 + case 79: stack.push(arg6); // 25 6 + case 81: stack.push(arg7); // 21 7 + case 83: arg7++; // 132 7 1 + case 86: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 87: arg10 = stack.pop() // 54 10 + case 89: stack.push(arg8); // 25 8 + case 91: stack.push(arg9); // 21 9 + case 93: arg9++; // 132 9 1 + case 96: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 97: arg11 = stack.pop() // 54 11 + case 99: stack.push(arg10); // 21 10 + case 101: stack.push(arg11); // 21 11 + case 103: if (stack.pop() != stack.pop()) { gt = 109; continue; } // 160 0 6 + case 106: gt = 71; continue; // 167 255 221 + case 109: stack.push(arg1); // 27 + case 110: if (stack.pop() == 0) { gt = 153; continue; } // 153 0 43 + case 113: stack.push(arg10); // 21 10 + case 115: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseCC(v0)); } // 184 1 105 + case 118: arg12 = stack.pop() // 54 12 + case 120: stack.push(arg11); // 21 11 + case 122: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseCC(v0)); } // 184 1 105 + case 125: arg13 = stack.pop() // 54 13 + case 127: stack.push(arg12); // 21 12 + case 129: stack.push(arg13); // 21 13 + case 131: if (stack.pop() != stack.pop()) { gt = 137; continue; } // 160 0 6 + case 134: gt = 71; continue; // 167 255 193 + case 137: stack.push(arg12); // 21 12 + case 139: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseCC(v0)); } // 184 1 104 + case 142: stack.push(arg13); // 21 13 + case 144: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseCC(v0)); } // 184 1 104 + case 147: if (stack.pop() != stack.pop()) { gt = 153; continue; } // 160 0 6 + case 150: gt = 71; continue; // 167 255 177 + case 153: stack.push(0); // 3 + case 154: return stack.pop(); // 172 + case 155: stack.push(1); // 4 + case 156: return stack.pop(); // 172 + } +} +function java_lang_String_startsWithZLjava_lang_StringI(arg0,arg1,arg2) { + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().value); // 180 1 100 + case 4: arg3 = stack.pop(); // 78 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().offset); // 180 1 99 + case 9: stack.push(arg2); // 28 + case 10: stack.push(stack.pop() + stack.pop()); // 96 + case 11: arg4 = stack.pop() // 54 4 + case 13: stack.push(arg1); // 43 + case 14: stack.push(stack.pop().value); // 180 1 100 + case 17: arg5 = stack.pop() // 58 5 + case 19: stack.push(arg1); // 43 + case 20: stack.push(stack.pop().offset); // 180 1 99 + case 23: arg6 = stack.pop() // 54 6 + case 25: stack.push(arg1); // 43 + case 26: stack.push(stack.pop().count); // 180 1 97 + case 29: arg7 = stack.pop() // 54 7 + case 31: stack.push(arg2); // 28 + case 32: if (stack.pop() < 0) { gt = 46; continue; } // 155 0 14 + case 35: stack.push(arg2); // 28 + case 36: stack.push(arg0); // 42 + case 37: stack.push(stack.pop().count); // 180 1 97 + case 40: stack.push(arg7); // 21 7 + case 42: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 43: if (stack.pop() >= stack.pop()) { gt = 48; continue; } // 164 0 5 + case 46: stack.push(0); // 3 + case 47: return stack.pop(); // 172 + case 48: arg7 += 255; // 132 7 255 + case 51: stack.push(arg7); // 21 7 + case 53: if (stack.pop() < 0) { gt = 76; continue; } // 155 0 23 + case 56: stack.push(arg3); // 45 + case 57: stack.push(arg4); // 21 4 + case 59: arg4++; // 132 4 1 + case 62: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 63: stack.push(arg5); // 25 5 + case 65: stack.push(arg6); // 21 6 + case 67: arg6++; // 132 6 1 + case 70: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 71: if (stack.pop() == stack.pop()) { gt = 48; continue; } // 159 255 233 + case 74: stack.push(0); // 3 + case 75: return stack.pop(); // 172 + case 76: stack.push(1); // 4 + case 77: return stack.pop(); // 172 + } +} +function java_lang_String_startsWithZLjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(0); // 3 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.startsWithZLjava_lang_StringI(self, v0, v1)); } // 182 1 152 + case 6: return stack.pop(); // 172 + } +} +function java_lang_String_endsWithZLjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(arg0); // 42 + case 3: stack.push(stack.pop().count); // 180 1 97 + case 6: stack.push(arg1); // 43 + case 7: stack.push(stack.pop().count); // 180 1 97 + case 10: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 11: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.startsWithZLjava_lang_StringI(self, v0, v1)); } // 182 1 152 + case 14: return stack.pop(); // 172 + } +} +function java_lang_String_hashCodeI(arg0) { + var arg1; + var arg2; + var arg3; + var arg4; + var arg5; + var arg6; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().hash); // 180 1 98 + case 4: arg1 = stack.pop(); // 60 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().count); // 180 1 97 + case 9: arg2 = stack.pop(); // 61 + case 10: stack.push(arg1); // 27 + case 11: if (stack.pop() != 0) { gt = 62; continue; } // 154 0 51 + case 14: stack.push(arg2); // 28 + case 15: if (stack.pop() <= 0) { gt = 62; continue; } // 158 0 47 + case 18: stack.push(arg0); // 42 + case 19: stack.push(stack.pop().offset); // 180 1 99 + case 22: arg3 = stack.pop(); // 62 + case 23: stack.push(arg0); // 42 + case 24: stack.push(stack.pop().value); // 180 1 100 + case 27: arg4 = stack.pop() // 58 4 + case 29: stack.push(0); // 3 + case 30: arg5 = stack.pop() // 54 5 + case 32: stack.push(arg5); // 21 5 + case 34: stack.push(arg2); // 28 + case 35: if (stack.pop() <= stack.pop()) { gt = 57; continue; } // 162 0 22 + case 38: stack.push(31); // 16 31 + case 40: stack.push(arg1); // 27 + case 41: stack.push(stack.pop() * stack.pop()); // 104 + case 42: stack.push(arg4); // 25 4 + case 44: stack.push(arg3); // 29 + case 45: arg3++; // 132 3 1 + case 48: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 49: stack.push(stack.pop() + stack.pop()); // 96 + case 50: arg1 = stack.pop(); // 60 + case 51: arg5++; // 132 5 1 + case 54: gt = 32; continue; // 167 255 234 + case 57: stack.push(arg0); // 42 + case 58: stack.push(arg1); // 27 + case 59: { var v = stack.pop(); stack.pop().hash = v; } // 181 1 98 + case 62: stack.push(arg1); // 27 + case 63: return stack.pop(); // 172 + } +} +function java_lang_String_indexOfII(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 27 + case 2: stack.push(0); // 3 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.indexOfIII(self, v0, v1)); } // 182 1 135 + case 6: return stack.pop(); // 172 + } +} +function java_lang_String_indexOfIII(arg0,arg1,arg2) { + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().offset); // 180 1 99 + case 4: stack.push(arg0); // 42 + case 5: stack.push(stack.pop().count); // 180 1 97 + case 8: stack.push(stack.pop() + stack.pop()); // 96 + case 9: arg3 = stack.pop(); // 62 + case 10: stack.push(arg0); // 42 + case 11: stack.push(stack.pop().value); // 180 1 100 + case 14: arg4 = stack.pop() // 58 4 + case 16: stack.push(arg2); // 28 + case 17: if (stack.pop() >= 0) { gt = 25; continue; } // 156 0 8 + case 20: stack.push(0); // 3 + case 21: arg2 = stack.pop(); // 61 + case 22: gt = 35; continue; // 167 0 13 + case 25: stack.push(arg2); // 28 + case 26: stack.push(arg0); // 42 + case 27: stack.push(stack.pop().count); // 180 1 97 + case 30: if (stack.pop() > stack.pop()) { gt = 35; continue; } // 161 0 5 + case 33: // 2 + case 34: return stack.pop(); // 172 + case 35: stack.push(arg0); // 42 + case 36: stack.push(stack.pop().offset); // 180 1 99 + case 39: stack.push(arg2); // 28 + case 40: stack.push(stack.pop() + stack.pop()); // 96 + case 41: arg5 = stack.pop() // 54 5 + case 43: stack.push(arg1); // 27 + case 44: stack.push(65536); // 18 3 + case 46: if (stack.pop() <= stack.pop()) { gt = 80; continue; } // 162 0 34 + case 49: stack.push(arg5); // 21 5 + case 51: stack.push(arg3); // 29 + case 52: if (stack.pop() <= stack.pop()) { gt = 78; continue; } // 162 0 26 + case 55: stack.push(arg4); // 25 4 + case 57: stack.push(arg5); // 21 5 + case 59: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 60: stack.push(arg1); // 27 + case 61: if (stack.pop() != stack.pop()) { gt = 72; continue; } // 160 0 11 + case 64: stack.push(arg5); // 21 5 + case 66: stack.push(arg0); // 42 + case 67: stack.push(stack.pop().offset); // 180 1 99 + case 70: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 71: return stack.pop(); // 172 + case 72: arg5++; // 132 5 1 + case 75: gt = 49; continue; // 167 255 230 + case 78: // 2 + case 79: return stack.pop(); // 172 + case 80: stack.push(arg1); // 27 + case 81: stack.push(1114111); // 18 4 + case 83: if (stack.pop() < stack.pop()) { gt = 149; continue; } // 163 0 66 + case 86: stack.push(arg1); // 27 + case 87: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109 + case 90: arg6 = stack.pop() // 58 6 + case 92: stack.push(arg5); // 21 5 + case 94: stack.push(arg3); // 29 + case 95: if (stack.pop() <= stack.pop()) { gt = 149; continue; } // 162 0 54 + case 98: stack.push(arg4); // 25 4 + case 100: stack.push(arg5); // 21 5 + case 102: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 103: stack.push(arg6); // 25 6 + case 105: stack.push(0); // 3 + case 106: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 107: if (stack.pop() != stack.pop()) { gt = 143; continue; } // 160 0 36 + case 110: stack.push(arg5); // 21 5 + case 112: stack.push(1); // 4 + case 113: stack.push(stack.pop() + stack.pop()); // 96 + case 114: stack.push(arg3); // 29 + case 115: if (stack.pop() != stack.pop()) { gt = 121; continue; } // 160 0 6 + case 118: gt = 149; continue; // 167 0 31 + case 121: stack.push(arg4); // 25 4 + case 123: stack.push(arg5); // 21 5 + case 125: stack.push(1); // 4 + case 126: stack.push(stack.pop() + stack.pop()); // 96 + case 127: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 128: stack.push(arg6); // 25 6 + case 130: stack.push(1); // 4 + case 131: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 132: if (stack.pop() != stack.pop()) { gt = 143; continue; } // 160 0 11 + case 135: stack.push(arg5); // 21 5 + case 137: stack.push(arg0); // 42 + case 138: stack.push(stack.pop().offset); // 180 1 99 + case 141: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 142: return stack.pop(); // 172 + case 143: arg5++; // 132 5 1 + case 146: gt = 92; continue; // 167 255 202 + case 149: // 2 + case 150: return stack.pop(); // 172 + } +} +function java_lang_String_lastIndexOfII(arg0,arg1) { + var arg2; +; + var stack = new Array(4); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 27 + case 2: stack.push(arg0); // 42 + case 3: stack.push(stack.pop().count); // 180 1 97 + case 6: stack.push(1); // 4 + case 7: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 8: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.lastIndexOfIII(self, v0, v1)); } // 182 1 136 + case 11: return stack.pop(); // 172 + } +} +function java_lang_String_lastIndexOfIII(arg0,arg1,arg2) { + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().offset); // 180 1 99 + case 4: arg3 = stack.pop(); // 62 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().value); // 180 1 100 + case 9: arg4 = stack.pop() // 58 4 + case 11: stack.push(arg0); // 42 + case 12: stack.push(stack.pop().offset); // 180 1 99 + case 15: stack.push(arg2); // 28 + case 16: stack.push(arg0); // 42 + case 17: stack.push(stack.pop().count); // 180 1 97 + case 20: if (stack.pop() > stack.pop()) { gt = 32; continue; } // 161 0 12 + case 23: stack.push(arg0); // 42 + case 24: stack.push(stack.pop().count); // 180 1 97 + case 27: stack.push(1); // 4 + case 28: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 29: gt = 33; continue; // 167 0 4 + case 32: stack.push(arg2); // 28 + case 33: stack.push(stack.pop() + stack.pop()); // 96 + case 34: arg5 = stack.pop() // 54 5 + case 36: stack.push(arg1); // 27 + case 37: stack.push(65536); // 18 3 + case 39: if (stack.pop() <= stack.pop()) { gt = 73; continue; } // 162 0 34 + case 42: stack.push(arg5); // 21 5 + case 44: stack.push(arg3); // 29 + case 45: if (stack.pop() > stack.pop()) { gt = 71; continue; } // 161 0 26 + case 48: stack.push(arg4); // 25 4 + case 50: stack.push(arg5); // 21 5 + case 52: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 53: stack.push(arg1); // 27 + case 54: if (stack.pop() != stack.pop()) { gt = 65; continue; } // 160 0 11 + case 57: stack.push(arg5); // 21 5 + case 59: stack.push(arg0); // 42 + case 60: stack.push(stack.pop().offset); // 180 1 99 + case 63: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 64: return stack.pop(); // 172 + case 65: arg5 += 255; // 132 5 255 + case 68: gt = 42; continue; // 167 255 230 + case 71: // 2 + case 72: return stack.pop(); // 172 + case 73: stack.push(arg0); // 42 + case 74: stack.push(stack.pop().offset); // 180 1 99 + case 77: stack.push(arg0); // 42 + case 78: stack.push(stack.pop().count); // 180 1 97 + case 81: stack.push(stack.pop() + stack.pop()); // 96 + case 82: arg6 = stack.pop() // 54 6 + case 84: stack.push(arg1); // 27 + case 85: stack.push(1114111); // 18 4 + case 87: if (stack.pop() < stack.pop()) { gt = 154; continue; } // 163 0 67 + case 90: stack.push(arg1); // 27 + case 91: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109 + case 94: arg7 = stack.pop() // 58 7 + case 96: stack.push(arg5); // 21 5 + case 98: stack.push(arg3); // 29 + case 99: if (stack.pop() > stack.pop()) { gt = 154; continue; } // 161 0 55 + case 102: stack.push(arg4); // 25 4 + case 104: stack.push(arg5); // 21 5 + case 106: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 107: stack.push(arg7); // 25 7 + case 109: stack.push(0); // 3 + case 110: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 111: if (stack.pop() != stack.pop()) { gt = 148; continue; } // 160 0 37 + case 114: stack.push(arg5); // 21 5 + case 116: stack.push(1); // 4 + case 117: stack.push(stack.pop() + stack.pop()); // 96 + case 118: stack.push(arg6); // 21 6 + case 120: if (stack.pop() != stack.pop()) { gt = 126; continue; } // 160 0 6 + case 123: gt = 154; continue; // 167 0 31 + case 126: stack.push(arg4); // 25 4 + case 128: stack.push(arg5); // 21 5 + case 130: stack.push(1); // 4 + case 131: stack.push(stack.pop() + stack.pop()); // 96 + case 132: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 133: stack.push(arg7); // 25 7 + case 135: stack.push(1); // 4 + case 136: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 137: if (stack.pop() != stack.pop()) { gt = 148; continue; } // 160 0 11 + case 140: stack.push(arg5); // 21 5 + case 142: stack.push(arg0); // 42 + case 143: stack.push(stack.pop().offset); // 180 1 99 + case 146: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 147: return stack.pop(); // 172 + case 148: arg5 += 255; // 132 5 255 + case 151: gt = 96; continue; // 167 255 201 + case 154: // 2 + case 155: return stack.pop(); // 172 + } +} +function java_lang_String_indexOfILjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(0); // 3 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.indexOfILjava_lang_StringI(self, v0, v1)); } // 182 1 150 + case 6: return stack.pop(); // 172 + } +} +function java_lang_String_indexOfILjava_lang_StringI(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(7); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().value); // 180 1 100 + case 4: stack.push(arg0); // 42 + case 5: stack.push(stack.pop().offset); // 180 1 99 + case 8: stack.push(arg0); // 42 + case 9: stack.push(stack.pop().count); // 180 1 97 + case 12: stack.push(arg1); // 43 + case 13: stack.push(stack.pop().value); // 180 1 100 + case 16: stack.push(arg1); // 43 + case 17: stack.push(stack.pop().offset); // 180 1 99 + case 20: stack.push(arg1); // 43 + case 21: stack.push(stack.pop().count); // 180 1 97 + case 24: stack.push(arg2); // 28 + case 25: { var v6 = stack.pop(); var v5 = stack.pop(); var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_String_indexOfAIACAIAIACAIAIAI(v0, v1, v2, v3, v4, v5, v6)); } // 184 1 144 + case 28: return stack.pop(); // 172 + } +} +function java_lang_String_indexOfIACIIACIII(arg0,arg1,arg2,arg3,arg4,arg5,arg6) { + var arg7; + var arg8; + var arg9; + var arg10; + var arg11; + var arg12; + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg6); // 21 6 + case 2: stack.push(arg2); // 28 + case 3: if (stack.pop() > stack.pop()) { gt = 17; continue; } // 161 0 14 + case 6: stack.push(arg5); // 21 5 + case 8: if (stack.pop() != 0) { gt = 15; continue; } // 154 0 7 + case 11: stack.push(arg2); // 28 + case 12: gt = 16; continue; // 167 0 4 + case 15: // 2 + case 16: return stack.pop(); // 172 + case 17: stack.push(arg6); // 21 6 + case 19: if (stack.pop() >= 0) { gt = 25; continue; } // 156 0 6 + case 22: stack.push(0); // 3 + case 23: arg6 = stack.pop() // 54 6 + case 25: stack.push(arg5); // 21 5 + case 27: if (stack.pop() != 0) { gt = 33; continue; } // 154 0 6 + case 30: stack.push(arg6); // 21 6 + case 32: return stack.pop(); // 172 + case 33: stack.push(arg3); // 45 + case 34: stack.push(arg4); // 21 4 + case 36: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 37: arg7 = stack.pop() // 54 7 + case 39: stack.push(arg1); // 27 + case 40: stack.push(arg2); // 28 + case 41: stack.push(arg5); // 21 5 + case 43: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 44: stack.push(stack.pop() + stack.pop()); // 96 + case 45: arg8 = stack.pop() // 54 8 + case 47: stack.push(arg1); // 27 + case 48: stack.push(arg6); // 21 6 + case 50: stack.push(stack.pop() + stack.pop()); // 96 + case 51: arg9 = stack.pop() // 54 9 + case 53: stack.push(arg9); // 21 9 + case 55: stack.push(arg8); // 21 8 + case 57: if (stack.pop() < stack.pop()) { gt = 164; continue; } // 163 0 107 + case 60: stack.push(arg0); // 42 + case 61: stack.push(arg9); // 21 9 + case 63: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 64: stack.push(arg7); // 21 7 + case 66: if (stack.pop() == stack.pop()) { gt = 91; continue; } // 159 0 25 + case 69: arg9++; // 132 9 1 + case 72: stack.push(arg9); // 21 9 + case 74: stack.push(arg8); // 21 8 + case 76: if (stack.pop() < stack.pop()) { gt = 91; continue; } // 163 0 15 + case 79: stack.push(arg0); // 42 + case 80: stack.push(arg9); // 21 9 + case 82: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 83: stack.push(arg7); // 21 7 + case 85: if (stack.pop() == stack.pop()) { gt = 91; continue; } // 159 0 6 + case 88: gt = 69; continue; // 167 255 237 + case 91: stack.push(arg9); // 21 9 + case 93: stack.push(arg8); // 21 8 + case 95: if (stack.pop() < stack.pop()) { gt = 158; continue; } // 163 0 63 + case 98: stack.push(arg9); // 21 9 + case 100: stack.push(1); // 4 + case 101: stack.push(stack.pop() + stack.pop()); // 96 + case 102: arg10 = stack.pop() // 54 10 + case 104: stack.push(arg10); // 21 10 + case 106: stack.push(arg5); // 21 5 + case 108: stack.push(stack.pop() + stack.pop()); // 96 + case 109: stack.push(1); // 4 + case 110: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 111: arg11 = stack.pop() // 54 11 + case 113: stack.push(arg4); // 21 4 + case 115: stack.push(1); // 4 + case 116: stack.push(stack.pop() + stack.pop()); // 96 + case 117: arg12 = stack.pop() // 54 12 + case 119: stack.push(arg10); // 21 10 + case 121: stack.push(arg11); // 21 11 + case 123: if (stack.pop() <= stack.pop()) { gt = 146; continue; } // 162 0 23 + case 126: stack.push(arg0); // 42 + case 127: stack.push(arg10); // 21 10 + case 129: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 130: stack.push(arg3); // 45 + case 131: stack.push(arg12); // 21 12 + case 133: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 134: if (stack.pop() != stack.pop()) { gt = 146; continue; } // 160 0 12 + case 137: arg10++; // 132 10 1 + case 140: arg12++; // 132 12 1 + case 143: gt = 119; continue; // 167 255 232 + case 146: stack.push(arg10); // 21 10 + case 148: stack.push(arg11); // 21 11 + case 150: if (stack.pop() != stack.pop()) { gt = 158; continue; } // 160 0 8 + case 153: stack.push(arg9); // 21 9 + case 155: stack.push(arg1); // 27 + case 156: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 157: return stack.pop(); // 172 + case 158: arg9++; // 132 9 1 + case 161: gt = 53; continue; // 167 255 148 + case 164: // 2 + case 165: return stack.pop(); // 172 + } +} +function java_lang_String_lastIndexOfILjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(arg0); // 42 + case 3: stack.push(stack.pop().count); // 180 1 97 + case 6: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.lastIndexOfILjava_lang_StringI(self, v0, v1)); } // 182 1 151 + case 9: return stack.pop(); // 172 + } +} +function java_lang_String_lastIndexOfILjava_lang_StringI(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(7); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().value); // 180 1 100 + case 4: stack.push(arg0); // 42 + case 5: stack.push(stack.pop().offset); // 180 1 99 + case 8: stack.push(arg0); // 42 + case 9: stack.push(stack.pop().count); // 180 1 97 + case 12: stack.push(arg1); // 43 + case 13: stack.push(stack.pop().value); // 180 1 100 + case 16: stack.push(arg1); // 43 + case 17: stack.push(stack.pop().offset); // 180 1 99 + case 20: stack.push(arg1); // 43 + case 21: stack.push(stack.pop().count); // 180 1 97 + case 24: stack.push(arg2); // 28 + case 25: { var v6 = stack.pop(); var v5 = stack.pop(); var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_String_lastIndexOfAIACAIAIACAIAIAI(v0, v1, v2, v3, v4, v5, v6)); } // 184 1 145 + case 28: return stack.pop(); // 172 + } +} +function java_lang_String_lastIndexOfIACIIACIII(arg0,arg1,arg2,arg3,arg4,arg5,arg6) { + var arg7; + var arg8; + var arg9; + var arg10; + var arg11; + var arg12; + var arg13; + var arg14; + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg2); // 28 + case 1: stack.push(arg5); // 21 5 + case 3: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 4: arg7 = stack.pop() // 54 7 + case 6: stack.push(arg6); // 21 6 + case 8: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 5 + case 11: // 2 + case 12: return stack.pop(); // 172 + case 13: stack.push(arg6); // 21 6 + case 15: stack.push(arg7); // 21 7 + case 17: if (stack.pop() >= stack.pop()) { gt = 24; continue; } // 164 0 7 + case 20: stack.push(arg7); // 21 7 + case 22: arg6 = stack.pop() // 54 6 + case 24: stack.push(arg5); // 21 5 + case 26: if (stack.pop() != 0) { gt = 32; continue; } // 154 0 6 + case 29: stack.push(arg6); // 21 6 + case 31: return stack.pop(); // 172 + case 32: stack.push(arg4); // 21 4 + case 34: stack.push(arg5); // 21 5 + case 36: stack.push(stack.pop() + stack.pop()); // 96 + case 37: stack.push(1); // 4 + case 38: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 39: arg8 = stack.pop() // 54 8 + case 41: stack.push(arg3); // 45 + case 42: stack.push(arg8); // 21 8 + case 44: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 45: arg9 = stack.pop() // 54 9 + case 47: stack.push(arg1); // 27 + case 48: stack.push(arg5); // 21 5 + case 50: stack.push(stack.pop() + stack.pop()); // 96 + case 51: stack.push(1); // 4 + case 52: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 53: arg10 = stack.pop() // 54 10 + case 55: stack.push(arg10); // 21 10 + case 57: stack.push(arg6); // 21 6 + case 59: stack.push(stack.pop() + stack.pop()); // 96 + case 60: arg11 = stack.pop() // 54 11 + case 62: stack.push(arg11); // 21 11 + case 64: stack.push(arg10); // 21 10 + case 66: if (stack.pop() > stack.pop()) { gt = 84; continue; } // 161 0 18 + case 69: stack.push(arg0); // 42 + case 70: stack.push(arg11); // 21 11 + case 72: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 73: stack.push(arg9); // 21 9 + case 75: if (stack.pop() == stack.pop()) { gt = 84; continue; } // 159 0 9 + case 78: arg11 += 255; // 132 11 255 + case 81: gt = 62; continue; // 167 255 237 + case 84: stack.push(arg11); // 21 11 + case 86: stack.push(arg10); // 21 10 + case 88: if (stack.pop() <= stack.pop()) { gt = 93; continue; } // 162 0 5 + case 91: // 2 + case 92: return stack.pop(); // 172 + case 93: stack.push(arg11); // 21 11 + case 95: stack.push(1); // 4 + case 96: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 97: arg12 = stack.pop() // 54 12 + case 99: stack.push(arg12); // 21 12 + case 101: stack.push(arg5); // 21 5 + case 103: stack.push(1); // 4 + case 104: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 105: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 106: arg13 = stack.pop() // 54 13 + case 108: stack.push(arg8); // 21 8 + case 110: stack.push(1); // 4 + case 111: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 112: arg14 = stack.pop() // 54 14 + case 114: stack.push(arg12); // 21 12 + case 116: stack.push(arg13); // 21 13 + case 118: if (stack.pop() >= stack.pop()) { gt = 144; continue; } // 164 0 26 + case 121: stack.push(arg0); // 42 + case 122: stack.push(arg12); // 21 12 + case 124: arg12 += 255; // 132 12 255 + case 127: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 128: stack.push(arg3); // 45 + case 129: stack.push(arg14); // 21 14 + case 131: arg14 += 255; // 132 14 255 + case 134: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 135: if (stack.pop() == stack.pop()) { gt = 114; continue; } // 159 255 235 + case 138: arg11 += 255; // 132 11 255 + case 141: gt = 62; continue; // 167 255 177 + case 144: stack.push(arg13); // 21 13 + case 146: stack.push(arg1); // 27 + case 147: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 148: stack.push(1); // 4 + case 149: stack.push(stack.pop() + stack.pop()); // 96 + case 150: return stack.pop(); // 172 + } +} +function java_lang_String_substringLjava_lang_StringI(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 27 + case 2: stack.push(arg0); // 42 + case 3: stack.push(stack.pop().count); // 180 1 97 + case 6: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.substringLjava_lang_StringII(self, v0, v1)); } // 182 1 147 + case 9: return stack.pop(); // 176 + } +} +function java_lang_String_substringLjava_lang_StringII(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 12 + case 4: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 7: stack.push(stack[stack.length - 1]); // 89 + case 8: stack.push(arg1); // 27 + case 9: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 12: // 191 + case 13: stack.push(arg2); // 28 + case 14: stack.push(arg0); // 42 + case 15: stack.push(stack.pop().count); // 180 1 97 + case 18: if (stack.pop() >= stack.pop()) { gt = 30; continue; } // 164 0 12 + case 21: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 24: stack.push(stack[stack.length - 1]); // 89 + case 25: stack.push(arg2); // 28 + case 26: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 29: // 191 + case 30: stack.push(arg1); // 27 + case 31: stack.push(arg2); // 28 + case 32: if (stack.pop() >= stack.pop()) { gt = 46; continue; } // 164 0 14 + case 35: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206 + case 38: stack.push(stack[stack.length - 1]); // 89 + case 39: stack.push(arg2); // 28 + case 40: stack.push(arg1); // 27 + case 41: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 42: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169 + case 45: // 191 + case 46: stack.push(arg1); // 27 + case 47: if (stack.pop() != 0) { gt = 62; continue; } // 154 0 15 + case 50: stack.push(arg2); // 28 + case 51: stack.push(arg0); // 42 + case 52: stack.push(stack.pop().count); // 180 1 97 + case 55: if (stack.pop() != stack.pop()) { gt = 62; continue; } // 160 0 7 + case 58: stack.push(arg0); // 42 + case 59: gt = 82; continue; // 167 0 23 + case 62: stack.push(new java_lang_String); // 187 0 200 + case 65: stack.push(stack[stack.length - 1]); // 89 + case 66: stack.push(arg0); // 42 + case 67: stack.push(stack.pop().offset); // 180 1 99 + case 70: stack.push(arg1); // 27 + case 71: stack.push(stack.pop() + stack.pop()); // 96 + case 72: stack.push(arg2); // 28 + case 73: stack.push(arg1); // 27 + case 74: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 75: stack.push(arg0); // 42 + case 76: stack.push(stack.pop().value); // 180 1 100 + case 79: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVIIAC(stack.pop(), v0, v1, v2); } // 183 1 137 + case 82: return stack.pop(); // 176 + } +} +function java_lang_String_subSequenceLjava_lang_CharSequenceII(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 27 + case 2: stack.push(arg2); // 28 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.substringLjava_lang_StringII(self, v0, v1)); } // 182 1 147 + case 6: return stack.pop(); // 176 + } +} +function java_lang_String_concatLjava_lang_StringLjava_lang_String(arg0,arg1) { + var arg2; + var arg3; + var arg4; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: { var self = stack.pop(); stack.push(self.lengthI(self)); } // 182 1 133 + case 4: arg2 = stack.pop(); // 61 + case 5: stack.push(arg2); // 28 + case 6: if (stack.pop() != 0) { gt = 11; continue; } // 154 0 5 + case 9: stack.push(arg0); // 42 + case 10: return stack.pop(); // 176 + case 11: stack.push(arg0); // 42 + case 12: stack.push(stack.pop().count); // 180 1 97 + case 15: stack.push(arg2); // 28 + case 16: stack.push(stack.pop() + stack.pop()); // 96 + case 17: stack.push(new Array(stack.pop())); // 188 5 + case 19: arg3 = stack.pop(); // 78 + case 20: stack.push(arg0); // 42 + case 21: stack.push(0); // 3 + case 22: stack.push(arg0); // 42 + case 23: stack.push(stack.pop().count); // 180 1 97 + case 26: stack.push(arg3); // 45 + case 27: stack.push(0); // 3 + case 28: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); self.getCharsVIIACAI(self, v0, v1, v2, v3); } // 182 1 138 + case 31: stack.push(arg1); // 43 + case 32: stack.push(0); // 3 + case 33: stack.push(arg2); // 28 + case 34: stack.push(arg3); // 45 + case 35: stack.push(arg0); // 42 + case 36: stack.push(stack.pop().count); // 180 1 97 + case 39: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); self.getCharsVIIACAI(self, v0, v1, v2, v3); } // 182 1 138 + case 42: stack.push(new java_lang_String); // 187 0 200 + case 45: stack.push(stack[stack.length - 1]); // 89 + case 46: stack.push(0); // 3 + case 47: stack.push(arg0); // 42 + case 48: stack.push(stack.pop().count); // 180 1 97 + case 51: stack.push(arg2); // 28 + case 52: stack.push(stack.pop() + stack.pop()); // 96 + case 53: stack.push(arg3); // 45 + case 54: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVIIAC(stack.pop(), v0, v1, v2); } // 183 1 137 + case 57: return stack.pop(); // 176 + } +} +function java_lang_String_replaceLjava_lang_StringCC(arg0,arg1,arg2) { + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; + var arg9; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 27 + case 1: stack.push(arg2); // 28 + case 2: if (stack.pop() == stack.pop()) { gt = 140; continue; } // 159 0 138 + case 5: stack.push(arg0); // 42 + case 6: stack.push(stack.pop().count); // 180 1 97 + case 9: arg3 = stack.pop(); // 62 + case 10: // 2 + case 11: arg4 = stack.pop() // 54 4 + case 13: stack.push(arg0); // 42 + case 14: stack.push(stack.pop().value); // 180 1 100 + case 17: arg5 = stack.pop() // 58 5 + case 19: stack.push(arg0); // 42 + case 20: stack.push(stack.pop().offset); // 180 1 99 + case 23: arg6 = stack.pop() // 54 6 + case 25: arg4++; // 132 4 1 + case 28: stack.push(arg4); // 21 4 + case 30: stack.push(arg3); // 29 + case 31: if (stack.pop() <= stack.pop()) { gt = 49; continue; } // 162 0 18 + case 34: stack.push(arg5); // 25 5 + case 36: stack.push(arg6); // 21 6 + case 38: stack.push(arg4); // 21 4 + case 40: stack.push(stack.pop() + stack.pop()); // 96 + case 41: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 42: stack.push(arg1); // 27 + case 43: if (stack.pop() != stack.pop()) { gt = 25; continue; } // 160 255 238 + case 46: gt = 49; continue; // 167 0 3 + case 49: stack.push(arg4); // 21 4 + case 51: stack.push(arg3); // 29 + case 52: if (stack.pop() <= stack.pop()) { gt = 140; continue; } // 162 0 88 + case 55: stack.push(arg3); // 29 + case 56: stack.push(new Array(stack.pop())); // 188 5 + case 58: arg7 = stack.pop() // 58 7 + case 60: stack.push(0); // 3 + case 61: arg8 = stack.pop() // 54 8 + case 63: stack.push(arg8); // 21 8 + case 65: stack.push(arg4); // 21 4 + case 67: if (stack.pop() <= stack.pop()) { gt = 89; continue; } // 162 0 22 + case 70: stack.push(arg7); // 25 7 + case 72: stack.push(arg8); // 21 8 + case 74: stack.push(arg5); // 25 5 + case 76: stack.push(arg6); // 21 6 + case 78: stack.push(arg8); // 21 8 + case 80: stack.push(stack.pop() + stack.pop()); // 96 + case 81: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 82: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 83: arg8++; // 132 8 1 + case 86: gt = 63; continue; // 167 255 233 + case 89: stack.push(arg4); // 21 4 + case 91: stack.push(arg3); // 29 + case 92: if (stack.pop() <= stack.pop()) { gt = 128; continue; } // 162 0 36 + case 95: stack.push(arg5); // 25 5 + case 97: stack.push(arg6); // 21 6 + case 99: stack.push(arg4); // 21 4 + case 101: stack.push(stack.pop() + stack.pop()); // 96 + case 102: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 103: arg8 = stack.pop() // 54 8 + case 105: stack.push(arg7); // 25 7 + case 107: stack.push(arg4); // 21 4 + case 109: stack.push(arg8); // 21 8 + case 111: stack.push(arg1); // 27 + case 112: if (stack.pop() != stack.pop()) { gt = 119; continue; } // 160 0 7 + case 115: stack.push(arg2); // 28 + case 116: gt = 121; continue; // 167 0 5 + case 119: stack.push(arg8); // 21 8 + case 121: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 122: arg4++; // 132 4 1 + case 125: gt = 89; continue; // 167 255 220 + case 128: stack.push(new java_lang_String); // 187 0 200 + case 131: stack.push(stack[stack.length - 1]); // 89 + case 132: stack.push(0); // 3 + case 133: stack.push(arg3); // 29 + case 134: stack.push(arg7); // 25 7 + case 136: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVIIAC(stack.pop(), v0, v1, v2); } // 183 1 137 + case 139: return stack.pop(); // 176 + case 140: stack.push(arg0); // 42 + case 141: return stack.pop(); // 176 + } +} +function java_lang_String_matchesZLjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: stack.push(arg0); // 42 + case 2: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_util_regex_Pattern_matchesZLjava_lang_StringLjava_lang_CharSequence(v0, v1)); } // 184 1 183 + case 5: return stack.pop(); // 172 + } +} +function java_lang_String_containsZLjava_lang_CharSequence(arg0,arg1) { + var arg2; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.indexOfILjava_lang_String(self, v0)); } // 182 1 149 + case 8: // 2 + case 9: if (stack.pop() >= stack.pop()) { gt = 16; continue; } // 164 0 7 + case 12: stack.push(1); // 4 + case 13: gt = 17; continue; // 167 0 4 + case 16: stack.push(0); // 3 + case 17: return stack.pop(); // 172 + } +} +function java_lang_String_replaceFirstLjava_lang_StringLjava_lang_StringLjava_lang_String(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: { var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_String(v0)); } // 184 1 186 + case 4: stack.push(arg0); // 42 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.matcherLjava_util_regex_MatcherLjava_lang_CharSequence(self, v0)); } // 182 1 185 + case 8: stack.push(arg2); // 44 + case 9: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.replaceFirstLjava_lang_StringLjava_lang_String(self, v0)); } // 182 1 182 + case 12: return stack.pop(); // 176 + } +} +function java_lang_String_replaceAllLjava_lang_StringLjava_lang_StringLjava_lang_String(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: { var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_String(v0)); } // 184 1 186 + case 4: stack.push(arg0); // 42 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.matcherLjava_util_regex_MatcherLjava_lang_CharSequence(self, v0)); } // 182 1 185 + case 8: stack.push(arg2); // 44 + case 9: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.replaceAllLjava_lang_StringLjava_lang_String(self, v0)); } // 182 1 181 + case 12: return stack.pop(); // 176 + } +} +function java_lang_String_replaceLjava_lang_StringLjava_lang_CharSequenceLjava_lang_CharSequence(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132 + case 4: stack.push(16); // 16 16 + case 6: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_StringI(v0, v1)); } // 184 1 187 + case 9: stack.push(arg0); // 42 + case 10: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.matcherLjava_util_regex_MatcherLjava_lang_CharSequence(self, v0)); } // 182 1 185 + case 13: stack.push(arg2); // 44 + case 14: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132 + case 17: { var v0 = stack.pop(); stack.push(java_util_regex_Matcher_quoteReplacementLjava_lang_StringLjava_lang_String(v0)); } // 184 1 180 + case 20: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.replaceAllLjava_lang_StringLjava_lang_String(self, v0)); } // 182 1 181 + case 23: return stack.pop(); // 176 + } +} +function java_lang_String_splitALjava_lang_StringLjava_lang_StringI(arg0,arg1,arg2) { + var arg3; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: { var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_String(v0)); } // 184 1 186 + case 4: stack.push(arg0); // 42 + case 5: stack.push(arg2); // 28 + case 6: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.splitALjava_lang_StringLjava_lang_CharSequenceI(self, v0, v1)); } // 182 1 184 + case 9: return stack.pop(); // 176 + } +} +function java_lang_String_splitALjava_lang_StringLjava_lang_String(arg0,arg1) { + var arg2; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: stack.push(0); // 3 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.splitALjava_lang_StringLjava_lang_StringI(self, v0, v1)); } // 182 1 157 + case 6: return stack.pop(); // 176 + } +} +function java_lang_String_toLowerCaseLjava_lang_StringLjava_util_Locale(arg0,arg1) { + var arg2; + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; + var arg9; + var arg10; + var arg11; + var arg12; + var arg13; + var arg14; +; + var stack = new Array(6); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198 + case 7: stack.push(stack[stack.length - 1]); // 89 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128 + case 11: // 191 + case 12: stack.push(0); // 3 + case 13: arg2 = stack.pop(); // 61 + case 14: stack.push(arg2); // 28 + case 15: stack.push(arg0); // 42 + case 16: stack.push(stack.pop().count); // 180 1 97 + case 19: if (stack.pop() <= stack.pop()) { gt = 94; continue; } // 162 0 75 + case 22: stack.push(arg0); // 42 + case 23: stack.push(stack.pop().value); // 180 1 100 + case 26: stack.push(arg0); // 42 + case 27: stack.push(stack.pop().offset); // 180 1 99 + case 30: stack.push(arg2); // 28 + case 31: stack.push(stack.pop() + stack.pop()); // 96 + case 32: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 33: arg3 = stack.pop(); // 62 + case 34: stack.push(arg3); // 29 + case 35: stack.push(55296); // 18 1 + case 37: if (stack.pop() > stack.pop()) { gt = 77; continue; } // 161 0 40 + case 40: stack.push(arg3); // 29 + case 41: stack.push(56319); // 18 2 + case 43: if (stack.pop() < stack.pop()) { gt = 77; continue; } // 163 0 34 + case 46: stack.push(arg0); // 42 + case 47: stack.push(arg2); // 28 + case 48: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134 + case 51: arg4 = stack.pop() // 54 4 + case 53: stack.push(arg4); // 21 4 + case 55: stack.push(arg4); // 21 4 + case 57: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseII(v0)); } // 184 1 107 + case 60: if (stack.pop() == stack.pop()) { gt = 66; continue; } // 159 0 6 + case 63: gt = 96; continue; // 167 0 33 + case 66: stack.push(arg2); // 28 + case 67: stack.push(arg4); // 21 4 + case 69: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106 + case 72: stack.push(stack.pop() + stack.pop()); // 96 + case 73: arg2 = stack.pop(); // 61 + case 74: gt = 91; continue; // 167 0 17 + case 77: stack.push(arg3); // 29 + case 78: stack.push(arg3); // 29 + case 79: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseCC(v0)); } // 184 1 104 + case 82: if (stack.pop() == stack.pop()) { gt = 88; continue; } // 159 0 6 + case 85: gt = 96; continue; // 167 0 11 + case 88: arg2++; // 132 2 1 + case 91: gt = 14; continue; // 167 255 179 + case 94: stack.push(arg0); // 42 + case 95: return stack.pop(); // 176 + case 96: stack.push(arg0); // 42 + case 97: stack.push(stack.pop().count); // 180 1 97 + case 100: stack.push(new Array(stack.pop())); // 188 5 + case 102: arg3 = stack.pop(); // 78 + case 103: stack.push(0); // 3 + case 104: arg4 = stack.pop() // 54 4 + case 106: stack.push(arg0); // 42 + case 107: stack.push(stack.pop().value); // 180 1 100 + case 110: stack.push(arg0); // 42 + case 111: stack.push(stack.pop().offset); // 180 1 99 + case 114: stack.push(arg3); // 45 + case 115: stack.push(0); // 3 + case 116: stack.push(arg2); // 28 + case 117: { var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_System_arraycopyVLjava_lang_ObjectILjava_lang_ObjectII(v0, v1, v2, v3, v4); } // 184 1 171 + case 120: stack.push(arg1); // 43 + case 121: { var self = stack.pop(); stack.push(self.getLanguageLjava_lang_String(self)); } // 182 1 178 + case 124: arg5 = stack.pop() // 58 5 + case 126: stack.push(arg5); // 25 5 + case 128: stack.push("tr"); // 18 11 + case 130: // 165 + case 131: // 0 + case 132: stack.push(6405); // 17 25 5 + case 135: stack.push("az"); // 18 5 + case 137: // 165 + case 138: // 0 + case 139: stack.push(1); // 10 + case 140: stack.push(arg5); // 25 5 + case 142: stack.push("lt"); // 18 9 + case 144: // 166 + case 145: // 0 + case 146: stack.push(4); // 7 + case 147: stack.push(1); // 4 + case 148: gt = 152; continue; // 167 0 4 + case 151: stack.push(0); // 3 + case 152: arg6 = stack.pop() // 54 6 + case 154: stack.push(arg2); // 28 + case 155: arg11 = stack.pop() // 54 11 + case 157: stack.push(arg11); // 21 11 + case 159: stack.push(arg0); // 42 + case 160: stack.push(stack.pop().count); // 180 1 97 + case 163: if (stack.pop() <= stack.pop()) { gt = 419; continue; } // 162 1 0 + case 166: stack.push(arg0); // 42 + case 167: stack.push(stack.pop().value); // 180 1 100 + case 170: stack.push(arg0); // 42 + case 171: stack.push(stack.pop().offset); // 180 1 99 + case 174: stack.push(arg11); // 21 11 + case 176: stack.push(stack.pop() + stack.pop()); // 96 + case 177: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 178: arg9 = stack.pop() // 54 9 + case 180: stack.push(arg9); // 21 9 + case 182: // number conversion // 146 + case 183: stack.push(55296); // 18 1 + case 185: if (stack.pop() > stack.pop()) { gt = 214; continue; } // 161 0 29 + case 188: stack.push(arg9); // 21 9 + case 190: // number conversion // 146 + case 191: stack.push(56319); // 18 2 + case 193: if (stack.pop() < stack.pop()) { gt = 214; continue; } // 163 0 21 + case 196: stack.push(arg0); // 42 + case 197: stack.push(arg11); // 21 11 + case 199: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134 + case 202: arg9 = stack.pop() // 54 9 + case 204: stack.push(arg9); // 21 9 + case 206: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106 + case 209: arg10 = stack.pop() // 54 10 + case 211: gt = 217; continue; // 167 0 6 + case 214: stack.push(1); // 4 + case 215: arg10 = stack.pop() // 54 10 + case 217: stack.push(arg6); // 21 6 + case 219: if (stack.pop() != 0) { gt = 230; continue; } // 154 0 11 + case 222: stack.push(arg9); // 21 9 + case 224: stack.push(931); // 17 3 163 + case 227: if (stack.pop() != stack.pop()) { gt = 242; continue; } // 160 0 15 + case 230: stack.push(arg0); // 42 + case 231: stack.push(arg11); // 21 11 + case 233: stack.push(arg1); // 43 + case 234: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_ConditionalSpecialCasing_toLowerCaseExILjava_lang_StringILjava_util_Locale(v0, v1, v2)); } // 184 1 117 + case 237: arg8 = stack.pop() // 54 8 + case 239: gt = 249; continue; // 167 0 10 + case 242: stack.push(arg9); // 21 9 + case 244: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseII(v0)); } // 184 1 107 + case 247: arg8 = stack.pop() // 54 8 + case 249: stack.push(arg8); // 21 8 + case 251: // 2 + case 252: if (stack.pop() == stack.pop()) { gt = 262; continue; } // 159 0 10 + case 255: stack.push(arg8); // 21 8 + case 257: stack.push(65536); // 18 3 + case 259: if (stack.pop() > stack.pop()) { gt = 399; continue; } // 161 0 140 + case 262: stack.push(arg8); // 21 8 + case 264: // 2 + case 265: if (stack.pop() != stack.pop()) { gt = 280; continue; } // 160 0 15 + case 268: stack.push(arg0); // 42 + case 269: stack.push(arg11); // 21 11 + case 271: stack.push(arg1); // 43 + case 272: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_ConditionalSpecialCasing_toLowerCaseCharArrayACLjava_lang_StringILjava_util_Locale(v0, v1, v2)); } // 184 1 119 + case 275: arg7 = stack.pop() // 58 7 + case 277: gt = 315; continue; // 167 0 38 + case 280: stack.push(arg10); // 21 10 + case 282: stack.push(2); // 5 + case 283: if (stack.pop() != stack.pop()) { gt = 308; continue; } // 160 0 25 + case 286: stack.push(arg4); // 21 4 + case 288: stack.push(arg8); // 21 8 + case 290: stack.push(arg3); // 45 + case 291: stack.push(arg11); // 21 11 + case 293: stack.push(arg4); // 21 4 + case 295: stack.push(stack.pop() + stack.pop()); // 96 + case 296: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Character_toCharsAIIACAI(v0, v1, v2)); } // 184 1 111 + case 299: stack.push(arg10); // 21 10 + case 301: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 302: stack.push(stack.pop() + stack.pop()); // 96 + case 303: arg4 = stack.pop() // 54 4 + case 305: gt = 409; continue; // 167 0 104 + case 308: stack.push(arg8); // 21 8 + case 310: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109 + case 313: arg7 = stack.pop() // 58 7 + case 315: stack.push(arg7); // 25 7 + case 317: stack.push(stack.pop().length); // 190 + case 318: arg12 = stack.pop() // 54 12 + case 320: stack.push(arg12); // 21 12 + case 322: stack.push(arg10); // 21 10 + case 324: if (stack.pop() >= stack.pop()) { gt = 355; continue; } // 164 0 31 + case 327: stack.push(arg3); // 45 + case 328: stack.push(stack.pop().length); // 190 + case 329: stack.push(arg12); // 21 12 + case 331: stack.push(stack.pop() + stack.pop()); // 96 + case 332: stack.push(arg10); // 21 10 + case 334: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 335: stack.push(new Array(stack.pop())); // 188 5 + case 337: arg13 = stack.pop() // 58 13 + case 339: stack.push(arg3); // 45 + case 340: stack.push(0); // 3 + case 341: stack.push(arg13); // 25 13 + case 343: stack.push(0); // 3 + case 344: stack.push(arg11); // 21 11 + case 346: stack.push(arg4); // 21 4 + case 348: stack.push(stack.pop() + stack.pop()); // 96 + case 349: { var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_System_arraycopyVLjava_lang_ObjectILjava_lang_ObjectII(v0, v1, v2, v3, v4); } // 184 1 171 + case 352: stack.push(arg13); // 25 13 + case 354: arg3 = stack.pop(); // 78 + case 355: stack.push(0); // 3 + case 356: arg13 = stack.pop() // 54 13 + case 358: stack.push(arg13); // 21 13 + case 360: stack.push(arg12); // 21 12 + case 362: if (stack.pop() <= stack.pop()) { gt = 386; continue; } // 162 0 24 + case 365: stack.push(arg3); // 45 + case 366: stack.push(arg11); // 21 11 + case 368: stack.push(arg4); // 21 4 + case 370: stack.push(stack.pop() + stack.pop()); // 96 + case 371: stack.push(arg13); // 21 13 + case 373: stack.push(stack.pop() + stack.pop()); // 96 + case 374: stack.push(arg7); // 25 7 + case 376: stack.push(arg13); // 21 13 + case 378: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 379: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 380: arg13++; // 132 13 1 + case 383: gt = 358; continue; // 167 255 231 + case 386: stack.push(arg4); // 21 4 + case 388: stack.push(arg12); // 21 12 + case 390: stack.push(arg10); // 21 10 + case 392: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 393: stack.push(stack.pop() + stack.pop()); // 96 + case 394: arg4 = stack.pop() // 54 4 + case 396: gt = 409; continue; // 167 0 13 + case 399: stack.push(arg3); // 45 + case 400: stack.push(arg11); // 21 11 + case 402: stack.push(arg4); // 21 4 + case 404: stack.push(stack.pop() + stack.pop()); // 96 + case 405: stack.push(arg8); // 21 8 + case 407: // number conversion // 146 + case 408: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 409: stack.push(arg11); // 21 11 + case 411: stack.push(arg10); // 21 10 + case 413: stack.push(stack.pop() + stack.pop()); // 96 + case 414: arg11 = stack.pop() // 54 11 + case 416: gt = 157; continue; // 167 254 253 + case 419: stack.push(new java_lang_String); // 187 0 200 + case 422: stack.push(stack[stack.length - 1]); // 89 + case 423: stack.push(0); // 3 + case 424: stack.push(arg0); // 42 + case 425: stack.push(stack.pop().count); // 180 1 97 + case 428: stack.push(arg4); // 21 4 + case 430: stack.push(stack.pop() + stack.pop()); // 96 + case 431: stack.push(arg3); // 45 + case 432: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVIIAC(stack.pop(), v0, v1, v2); } // 183 1 137 + case 435: return stack.pop(); // 176 + } +} +function java_lang_String_toLowerCaseLjava_lang_String(arg0) { + var arg1; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { stack.push(java_util_Locale_getDefaultLjava_util_Locale()); } // 184 1 179 + case 4: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.toLowerCaseLjava_lang_StringLjava_util_Locale(self, v0)); } // 182 1 158 + case 7: return stack.pop(); // 176 + } +} +function java_lang_String_toUpperCaseLjava_lang_StringLjava_util_Locale(arg0,arg1) { + var arg2; + var arg3; + var arg4; + var arg5; + var arg6; + var arg7; + var arg8; + var arg9; + var arg10; + var arg11; + var arg12; + var arg13; + var arg14; +; + var stack = new Array(6); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg1); // 43 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198 + case 7: stack.push(stack[stack.length - 1]); // 89 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128 + case 11: // 191 + case 12: stack.push(0); // 3 + case 13: arg2 = stack.pop(); // 61 + case 14: stack.push(arg2); // 28 + case 15: stack.push(arg0); // 42 + case 16: stack.push(stack.pop().count); // 180 1 97 + case 19: if (stack.pop() <= stack.pop()) { gt = 93; continue; } // 162 0 74 + case 22: stack.push(arg0); // 42 + case 23: stack.push(stack.pop().value); // 180 1 100 + case 26: stack.push(arg0); // 42 + case 27: stack.push(stack.pop().offset); // 180 1 99 + case 30: stack.push(arg2); // 28 + case 31: stack.push(stack.pop() + stack.pop()); // 96 + case 32: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 33: arg3 = stack.pop(); // 62 + case 34: stack.push(arg3); // 29 + case 35: stack.push(55296); // 18 1 + case 37: if (stack.pop() > stack.pop()) { gt = 61; continue; } // 161 0 24 + case 40: stack.push(arg3); // 29 + case 41: stack.push(56319); // 18 2 + case 43: if (stack.pop() < stack.pop()) { gt = 61; continue; } // 163 0 18 + case 46: stack.push(arg0); // 42 + case 47: stack.push(arg2); // 28 + case 48: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134 + case 51: arg3 = stack.pop(); // 62 + case 52: stack.push(arg3); // 29 + case 53: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106 + case 56: arg4 = stack.pop() // 54 4 + case 58: gt = 64; continue; // 167 0 6 + case 61: stack.push(1); // 4 + case 62: arg4 = stack.pop() // 54 4 + case 64: stack.push(arg3); // 29 + case 65: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseExII(v0)); } // 184 1 108 + case 68: arg5 = stack.pop() // 54 5 + case 70: stack.push(arg5); // 21 5 + case 72: // 2 + case 73: if (stack.pop() == stack.pop()) { gt = 95; continue; } // 159 0 22 + case 76: stack.push(arg3); // 29 + case 77: stack.push(arg5); // 21 5 + case 79: if (stack.pop() == stack.pop()) { gt = 85; continue; } // 159 0 6 + case 82: gt = 95; continue; // 167 0 13 + case 85: stack.push(arg2); // 28 + case 86: stack.push(arg4); // 21 4 + case 88: stack.push(stack.pop() + stack.pop()); // 96 + case 89: arg2 = stack.pop(); // 61 + case 90: gt = 14; continue; // 167 255 180 + case 93: stack.push(arg0); // 42 + case 94: return stack.pop(); // 176 + case 95: stack.push(arg0); // 42 + case 96: stack.push(stack.pop().count); // 180 1 97 + case 99: stack.push(new Array(stack.pop())); // 188 5 + case 101: arg3 = stack.pop(); // 78 + case 102: stack.push(0); // 3 + case 103: arg4 = stack.pop() // 54 4 + case 105: stack.push(arg0); // 42 + case 106: stack.push(stack.pop().value); // 180 1 100 + case 109: stack.push(arg0); // 42 + case 110: stack.push(stack.pop().offset); // 180 1 99 + case 113: stack.push(arg3); // 45 + case 114: stack.push(0); // 3 + case 115: stack.push(arg2); // 28 + case 116: { var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_System_arraycopyVLjava_lang_ObjectILjava_lang_ObjectII(v0, v1, v2, v3, v4); } // 184 1 171 + case 119: stack.push(arg1); // 43 + case 120: { var self = stack.pop(); stack.push(self.getLanguageLjava_lang_String(self)); } // 182 1 178 + case 123: arg5 = stack.pop() // 58 5 + case 125: stack.push(arg5); // 25 5 + case 127: stack.push("tr"); // 18 11 + case 129: // 165 + case 130: // 0 + case 131: stack.push(6405); // 17 25 5 + case 134: stack.push("az"); // 18 5 + case 136: // 165 + case 137: // 0 + case 138: stack.push(1); // 10 + case 139: stack.push(arg5); // 25 5 + case 141: stack.push("lt"); // 18 9 + case 143: // 166 + case 144: // 0 + case 145: stack.push(4); // 7 + case 146: stack.push(1); // 4 + case 147: gt = 151; continue; // 167 0 4 + case 150: stack.push(0); // 3 + case 151: arg6 = stack.pop() // 54 6 + case 153: stack.push(arg2); // 28 + case 154: arg11 = stack.pop() // 54 11 + case 156: stack.push(arg11); // 21 11 + case 158: stack.push(arg0); // 42 + case 159: stack.push(stack.pop().count); // 180 1 97 + case 162: if (stack.pop() <= stack.pop()) { gt = 425; continue; } // 162 1 7 + case 165: stack.push(arg0); // 42 + case 166: stack.push(stack.pop().value); // 180 1 100 + case 169: stack.push(arg0); // 42 + case 170: stack.push(stack.pop().offset); // 180 1 99 + case 173: stack.push(arg11); // 21 11 + case 175: stack.push(stack.pop() + stack.pop()); // 96 + case 176: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 177: arg9 = stack.pop() // 54 9 + case 179: stack.push(arg9); // 21 9 + case 181: // number conversion // 146 + case 182: stack.push(55296); // 18 1 + case 184: if (stack.pop() > stack.pop()) { gt = 213; continue; } // 161 0 29 + case 187: stack.push(arg9); // 21 9 + case 189: // number conversion // 146 + case 190: stack.push(56319); // 18 2 + case 192: if (stack.pop() < stack.pop()) { gt = 213; continue; } // 163 0 21 + case 195: stack.push(arg0); // 42 + case 196: stack.push(arg11); // 21 11 + case 198: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134 + case 201: arg9 = stack.pop() // 54 9 + case 203: stack.push(arg9); // 21 9 + case 205: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106 + case 208: arg10 = stack.pop() // 54 10 + case 210: gt = 216; continue; // 167 0 6 + case 213: stack.push(1); // 4 + case 214: arg10 = stack.pop() // 54 10 + case 216: stack.push(arg6); // 21 6 + case 218: if (stack.pop() == 0) { gt = 233; continue; } // 153 0 15 + case 221: stack.push(arg0); // 42 + case 222: stack.push(arg11); // 21 11 + case 224: stack.push(arg1); // 43 + case 225: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_ConditionalSpecialCasing_toUpperCaseExILjava_lang_StringILjava_util_Locale(v0, v1, v2)); } // 184 1 118 + case 228: arg8 = stack.pop() // 54 8 + case 230: gt = 240; continue; // 167 0 10 + case 233: stack.push(arg9); // 21 9 + case 235: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseExII(v0)); } // 184 1 108 + case 238: arg8 = stack.pop() // 54 8 + case 240: stack.push(arg8); // 21 8 + case 242: // 2 + case 243: if (stack.pop() == stack.pop()) { gt = 253; continue; } // 159 0 10 + case 246: stack.push(arg8); // 21 8 + case 248: stack.push(65536); // 18 3 + case 250: if (stack.pop() > stack.pop()) { gt = 405; continue; } // 161 0 155 + case 253: stack.push(arg8); // 21 8 + case 255: // 2 + case 256: if (stack.pop() != stack.pop()) { gt = 286; continue; } // 160 0 30 + case 259: stack.push(arg6); // 21 6 + case 261: if (stack.pop() == 0) { gt = 276; continue; } // 153 0 15 + case 264: stack.push(arg0); // 42 + case 265: stack.push(arg11); // 21 11 + case 267: stack.push(arg1); // 43 + case 268: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_ConditionalSpecialCasing_toUpperCaseCharArrayACLjava_lang_StringILjava_util_Locale(v0, v1, v2)); } // 184 1 120 + case 271: arg7 = stack.pop() // 58 7 + case 273: gt = 321; continue; // 167 0 48 + case 276: stack.push(arg9); // 21 9 + case 278: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseCharArrayACI(v0)); } // 184 1 110 + case 281: arg7 = stack.pop() // 58 7 + case 283: gt = 321; continue; // 167 0 38 + case 286: stack.push(arg10); // 21 10 + case 288: stack.push(2); // 5 + case 289: if (stack.pop() != stack.pop()) { gt = 314; continue; } // 160 0 25 + case 292: stack.push(arg4); // 21 4 + case 294: stack.push(arg8); // 21 8 + case 296: stack.push(arg3); // 45 + case 297: stack.push(arg11); // 21 11 + case 299: stack.push(arg4); // 21 4 + case 301: stack.push(stack.pop() + stack.pop()); // 96 + case 302: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Character_toCharsAIIACAI(v0, v1, v2)); } // 184 1 111 + case 305: stack.push(arg10); // 21 10 + case 307: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 308: stack.push(stack.pop() + stack.pop()); // 96 + case 309: arg4 = stack.pop() // 54 4 + case 311: gt = 415; continue; // 167 0 104 + case 314: stack.push(arg8); // 21 8 + case 316: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109 + case 319: arg7 = stack.pop() // 58 7 + case 321: stack.push(arg7); // 25 7 + case 323: stack.push(stack.pop().length); // 190 + case 324: arg12 = stack.pop() // 54 12 + case 326: stack.push(arg12); // 21 12 + case 328: stack.push(arg10); // 21 10 + case 330: if (stack.pop() >= stack.pop()) { gt = 361; continue; } // 164 0 31 + case 333: stack.push(arg3); // 45 + case 334: stack.push(stack.pop().length); // 190 + case 335: stack.push(arg12); // 21 12 + case 337: stack.push(stack.pop() + stack.pop()); // 96 + case 338: stack.push(arg10); // 21 10 + case 340: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 341: stack.push(new Array(stack.pop())); // 188 5 + case 343: arg13 = stack.pop() // 58 13 + case 345: stack.push(arg3); // 45 + case 346: stack.push(0); // 3 + case 347: stack.push(arg13); // 25 13 + case 349: stack.push(0); // 3 + case 350: stack.push(arg11); // 21 11 + case 352: stack.push(arg4); // 21 4 + case 354: stack.push(stack.pop() + stack.pop()); // 96 + case 355: { var v4 = stack.pop(); var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_System_arraycopyVLjava_lang_ObjectILjava_lang_ObjectII(v0, v1, v2, v3, v4); } // 184 1 171 + case 358: stack.push(arg13); // 25 13 + case 360: arg3 = stack.pop(); // 78 + case 361: stack.push(0); // 3 + case 362: arg13 = stack.pop() // 54 13 + case 364: stack.push(arg13); // 21 13 + case 366: stack.push(arg12); // 21 12 + case 368: if (stack.pop() <= stack.pop()) { gt = 392; continue; } // 162 0 24 + case 371: stack.push(arg3); // 45 + case 372: stack.push(arg11); // 21 11 + case 374: stack.push(arg4); // 21 4 + case 376: stack.push(stack.pop() + stack.pop()); // 96 + case 377: stack.push(arg13); // 21 13 + case 379: stack.push(stack.pop() + stack.pop()); // 96 + case 380: stack.push(arg7); // 25 7 + case 382: stack.push(arg13); // 21 13 + case 384: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 385: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 386: arg13++; // 132 13 1 + case 389: gt = 364; continue; // 167 255 231 + case 392: stack.push(arg4); // 21 4 + case 394: stack.push(arg12); // 21 12 + case 396: stack.push(arg10); // 21 10 + case 398: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 399: stack.push(stack.pop() + stack.pop()); // 96 + case 400: arg4 = stack.pop() // 54 4 + case 402: gt = 415; continue; // 167 0 13 + case 405: stack.push(arg3); // 45 + case 406: stack.push(arg11); // 21 11 + case 408: stack.push(arg4); // 21 4 + case 410: stack.push(stack.pop() + stack.pop()); // 96 + case 411: stack.push(arg8); // 21 8 + case 413: // number conversion // 146 + case 414: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 415: stack.push(arg11); // 21 11 + case 417: stack.push(arg10); // 21 10 + case 419: stack.push(stack.pop() + stack.pop()); // 96 + case 420: arg11 = stack.pop() // 54 11 + case 422: gt = 156; continue; // 167 254 246 + case 425: stack.push(new java_lang_String); // 187 0 200 + case 428: stack.push(stack[stack.length - 1]); // 89 + case 429: stack.push(0); // 3 + case 430: stack.push(arg0); // 42 + case 431: stack.push(stack.pop().count); // 180 1 97 + case 434: stack.push(arg4); // 21 4 + case 436: stack.push(stack.pop() + stack.pop()); // 96 + case 437: stack.push(arg3); // 45 + case 438: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVIIAC(stack.pop(), v0, v1, v2); } // 183 1 137 + case 441: return stack.pop(); // 176 + } +} +function java_lang_String_toUpperCaseLjava_lang_String(arg0) { + var arg1; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: { stack.push(java_util_Locale_getDefaultLjava_util_Locale()); } // 184 1 179 + case 4: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.toUpperCaseLjava_lang_StringLjava_util_Locale(self, v0)); } // 182 1 159 + case 7: return stack.pop(); // 176 + } +} +function java_lang_String_trimLjava_lang_String(arg0) { + var arg1; + var arg2; + var arg3; + var arg4; + var arg5; +; + var stack = new Array(3); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().count); // 180 1 97 + case 4: arg1 = stack.pop(); // 60 + case 5: stack.push(0); // 3 + case 6: arg2 = stack.pop(); // 61 + case 7: stack.push(arg0); // 42 + case 8: stack.push(stack.pop().offset); // 180 1 99 + case 11: arg3 = stack.pop(); // 62 + case 12: stack.push(arg0); // 42 + case 13: stack.push(stack.pop().value); // 180 1 100 + case 16: arg4 = stack.pop() // 58 4 + case 18: stack.push(arg2); // 28 + case 19: stack.push(arg1); // 27 + case 20: if (stack.pop() <= stack.pop()) { gt = 40; continue; } // 162 0 20 + case 23: stack.push(arg4); // 25 4 + case 25: stack.push(arg3); // 29 + case 26: stack.push(arg2); // 28 + case 27: stack.push(stack.pop() + stack.pop()); // 96 + case 28: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 29: stack.push(32); // 16 32 + case 31: if (stack.pop() < stack.pop()) { gt = 40; continue; } // 163 0 9 + case 34: arg2++; // 132 2 1 + case 37: gt = 18; continue; // 167 255 237 + case 40: stack.push(arg2); // 28 + case 41: stack.push(arg1); // 27 + case 42: if (stack.pop() <= stack.pop()) { gt = 64; continue; } // 162 0 22 + case 45: stack.push(arg4); // 25 4 + case 47: stack.push(arg3); // 29 + case 48: stack.push(arg1); // 27 + case 49: stack.push(stack.pop() + stack.pop()); // 96 + case 50: stack.push(1); // 4 + case 51: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100 + case 52: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52 + case 53: stack.push(32); // 16 32 + case 55: if (stack.pop() < stack.pop()) { gt = 64; continue; } // 163 0 9 + case 58: arg1 += 255; // 132 1 255 + case 61: gt = 40; continue; // 167 255 235 + case 64: stack.push(arg2); // 28 + case 65: if (stack.pop() > 0) { gt = 76; continue; } // 157 0 11 + case 68: stack.push(arg1); // 27 + case 69: stack.push(arg0); // 42 + case 70: stack.push(stack.pop().count); // 180 1 97 + case 73: if (stack.pop() <= stack.pop()) { gt = 85; continue; } // 162 0 12 + case 76: stack.push(arg0); // 42 + case 77: stack.push(arg2); // 28 + case 78: stack.push(arg1); // 27 + case 79: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.substringLjava_lang_StringII(self, v0, v1)); } // 182 1 147 + case 82: gt = 86; continue; // 167 0 4 + case 85: stack.push(arg0); // 42 + case 86: return stack.pop(); // 176 + } +} +*/ +function java_lang_String_toStringLjava_lang_String(arg0) { + return arg0.toString(); +} +/* +function java_lang_String_toCharArrayAC(arg0) { + var arg1; + var arg2; +; + var stack = new Array(5); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(stack.pop().count); // 180 1 97 + case 4: stack.push(new Array(stack.pop())); // 188 5 + case 6: arg1 = stack.pop(); // 76 + case 7: stack.push(arg0); // 42 + case 8: stack.push(0); // 3 + case 9: stack.push(arg0); // 42 + case 10: stack.push(stack.pop().count); // 180 1 97 + case 13: stack.push(arg1); // 43 + case 14: stack.push(0); // 3 + case 15: { var v3 = stack.pop(); var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); self.getCharsVIIACAI(self, v0, v1, v2, v3); } // 182 1 138 + case 18: stack.push(arg1); // 43 + case 19: return stack.pop(); // 176 + } +} +function java_lang_String_formatLjava_lang_StringLjava_lang_StringLjava_lang_Object(arg0,arg1) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(new java_util_Formatter); // 187 0 211 + case 3: stack.push(stack[stack.length - 1]); // 89 + case 4: { java_util_Formatter_consV(stack.pop()); } // 183 1 174 + case 7: stack.push(arg0); // 42 + case 8: stack.push(arg1); // 43 + case 9: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.formatALjava_util_FormatterLjava_lang_StringALjava_lang_Object(self, v0, v1)); } // 182 1 177 + case 12: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 175 + case 15: return stack.pop(); // 176 + } +} +function java_lang_String_formatLjava_lang_StringLjava_util_LocaleLjava_lang_StringLjava_lang_Object(arg0,arg1,arg2) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(new java_util_Formatter); // 187 0 211 + case 3: stack.push(stack[stack.length - 1]); // 89 + case 4: stack.push(arg0); // 42 + case 5: { var v0 = stack.pop(); java_util_Formatter_consVLjava_util_Locale(stack.pop(), v0); } // 183 1 176 + case 8: stack.push(arg1); // 43 + case 9: stack.push(arg2); // 44 + case 10: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.formatALjava_util_FormatterLjava_lang_StringALjava_lang_Object(self, v0, v1)); } // 182 1 177 + case 13: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 175 + case 16: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringLjava_lang_Object(arg0) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: if (stack.pop()) { gt = 9; continue; } // 199 0 8 + case 4: stack.push("null"); // 18 10 + case 6: gt = 13; continue; // 167 0 7 + case 9: stack.push(arg0); // 42 + case 10: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132 + case 13: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringAC(arg0) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(new java_lang_String); // 187 0 200 + case 3: stack.push(stack[stack.length - 1]); // 89 + case 4: stack.push(arg0); // 42 + case 5: { var v0 = stack.pop(); java_lang_String_consVAC(stack.pop(), v0); } // 183 1 142 + case 8: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringACII(arg0,arg1,arg2) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(new java_lang_String); // 187 0 200 + case 3: stack.push(stack[stack.length - 1]); // 89 + case 4: stack.push(arg0); // 42 + case 5: stack.push(arg1); // 27 + case 6: stack.push(arg2); // 28 + case 7: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVACAIAI(stack.pop(), v0, v1, v2); } // 183 1 143 + case 10: return stack.pop(); // 176 + } +} +function java_lang_String_copyValueOfLjava_lang_StringACII(arg0,arg1,arg2) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(new java_lang_String); // 187 0 200 + case 3: stack.push(stack[stack.length - 1]); // 89 + case 4: stack.push(arg0); // 42 + case 5: stack.push(arg1); // 27 + case 6: stack.push(arg2); // 28 + case 7: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVACAIAI(stack.pop(), v0, v1, v2); } // 183 1 143 + case 10: return stack.pop(); // 176 + } +} +function java_lang_String_copyValueOfLjava_lang_StringAC(arg0) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(0); // 3 + case 2: stack.push(arg0); // 42 + case 3: stack.push(stack.pop().length); // 190 + case 4: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_String_copyValueOfALjava_lang_StringACAIAI(v0, v1, v2)); } // 184 1 155 + case 7: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringZ(arg0) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 26 + case 1: if (stack.pop() == 0) { gt = 9; continue; } // 153 0 8 + case 4: stack.push("true"); // 18 12 + case 6: gt = 11; continue; // 167 0 5 + case 9: stack.push("false"); // 18 8 + case 11: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringC(arg0) { + var arg1; + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(1); // 4 + case 1: stack.push(new Array(stack.pop())); // 188 5 + case 3: stack.push(stack[stack.length - 1]); // 89 + case 4: stack.push(0); // 3 + case 5: stack.push(arg0); // 26 + case 6: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85 + case 7: arg1 = stack.pop(); // 76 + case 8: stack.push(new java_lang_String); // 187 0 200 + case 11: stack.push(stack[stack.length - 1]); // 89 + case 12: stack.push(0); // 3 + case 13: stack.push(1); // 4 + case 14: stack.push(arg1); // 43 + case 15: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_consVIIAC(stack.pop(), v0, v1, v2); } // 183 1 137 + case 18: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringI(arg0) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 26 + case 1: stack.push(10); // 16 10 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Integer_toStringLjava_lang_StringII(v0, v1)); } // 184 1 125 + case 6: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringJ(arg0) { + var arg1; + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 30 + case 1: stack.push(10); // 16 10 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Long_toStringLjava_lang_StringJI(v0, v1)); } // 184 1 126 + case 6: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringF(arg0) { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 34 + case 1: { var v0 = stack.pop(); stack.push(java_lang_Float_toStringLjava_lang_StringF(v0)); } // 184 1 122 + case 4: return stack.pop(); // 176 + } +} +function java_lang_String_valueOfLjava_lang_StringD(arg0) { + var arg1; + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 38 + case 1: { var v0 = stack.pop(); stack.push(java_lang_Double_toStringLjava_lang_StringD(v0)); } // 184 1 121 + case 4: return stack.pop(); // 176 + } +} +function java_lang_String_internLjava_lang_String(arg0) { + // no code found for null +} +function java_lang_String_compareToILjava_lang_Object(arg0,arg1) { + var arg2; +; + var stack = new Array(2); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(arg0); // 42 + case 1: stack.push(arg1); // 43 + case 2: if(stack[stack.length - 1].$instOf_java_lang_String != 1) throw {}; // 192 0 200 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.compareToILjava_lang_String(self, v0)); } // 182 1 148 + case 8: return stack.pop(); // 172 + } +} +function java_lang_String_classV() { + var stack = new Array(); + var gt = 0; + for(;;) switch(gt) { + case 0: stack.push(0); // 3 + case 1: stack.push(new Array(stack.pop())); // 189 0 183 + case 4: java_lang_String_serialPersistentFields = stack.pop(); // 179 1 101 + case 7: stack.push(new java_lang_String$CaseInsensitiveComparator); // 187 0 202 + case 10: stack.push(stack[stack.length - 1]); // 89 + case 11: // 1 + case 12: { var v0 = stack.pop(); java_lang_String$CaseInsensitiveComparator_consVLjava_lang_String$1(stack.pop(), v0); } // 183 1 160 + case 15: java_lang_String_CASE_INSENSITIVE_ORDER = stack.pop(); // 179 1 102 + case 18: return; // 177 + } +} +*/ +var java_lang_String_serialVersionUID = 0; +var java_lang_String_serialPersistentFields = 0; +var java_lang_String_CASE_INSENSITIVE_ORDER = 0; +function java_lang_String() { + /** the real value of this 'string' we delegate to */ + this.r = ''; + + var self = this; + /* + this.value = 0; + this.offset = 0; + this.count = 0; + this.hash = 0; + */ + this.toString = function() { return self.r; }; +} +java_lang_String.prototype = new String; +//java_lang_String_classV(); + +/* new method for JavaScript String */ +String.prototype.charAtCI = java_lang_String_charAtCI; +String.prototype.lengthI = java_lang_String_lengthI; +String.prototype.isEmptyZ = java_lang_String_isEmptyZ; +String.prototype.getCharsVIIACAI = java_lang_String_getCharsVIIACAI; +String.prototype.toStringLjava_lang_String = java_lang_String_toStringLjava_lang_String; +String.prototype.$instOf_java_lang_String = true; +String.prototype.$instOf_java_io_Serializable = true; +String.prototype.$instOf_java_lang_Comparable = true; +String.prototype.$instOf_java_lang_CharSequence = true; + +/* + this.lengthI = java_lang_String_lengthI; + this.isEmptyZ = java_lang_String_isEmptyZ; + this.charAtCI = java_lang_String_charAtCI; + this.codePointAtII = java_lang_String_codePointAtII; + this.codePointBeforeII = java_lang_String_codePointBeforeII; + this.codePointCountIII = java_lang_String_codePointCountIII; + this.offsetByCodePointsIII = java_lang_String_offsetByCodePointsIII; + this.getCharsVACI = java_lang_String_getCharsVACI; + this.getCharsVIIACI = java_lang_String_getCharsVIIACI; + this.getBytesVIIABI = java_lang_String_getBytesVIIABI; + this.getBytesABLjava_lang_String = java_lang_String_getBytesABLjava_lang_String; + this.getBytesABLjava_nio_charset_Charset = java_lang_String_getBytesABLjava_nio_charset_Charset; + this.getBytesAB = java_lang_String_getBytesAB; + this.equalsZLjava_lang_Object = java_lang_String_equalsZLjava_lang_Object; + this.contentEqualsZLjava_lang_StringBuffer = java_lang_String_contentEqualsZLjava_lang_StringBuffer; + this.contentEqualsZLjava_lang_CharSequence = java_lang_String_contentEqualsZLjava_lang_CharSequence; + this.equalsIgnoreCaseZLjava_lang_String = java_lang_String_equalsIgnoreCaseZLjava_lang_String; + this.compareToILjava_lang_String = java_lang_String_compareToILjava_lang_String; + this.compareToIgnoreCaseILjava_lang_String = java_lang_String_compareToIgnoreCaseILjava_lang_String; + this.regionMatchesZILjava_lang_StringII = java_lang_String_regionMatchesZILjava_lang_StringII; + this.regionMatchesZZILjava_lang_StringII = java_lang_String_regionMatchesZZILjava_lang_StringII; + this.startsWithZLjava_lang_StringI = java_lang_String_startsWithZLjava_lang_StringI; + this.startsWithZLjava_lang_String = java_lang_String_startsWithZLjava_lang_String; + this.endsWithZLjava_lang_String = java_lang_String_endsWithZLjava_lang_String; + this.hashCodeI = java_lang_String_hashCodeI; + this.indexOfII = java_lang_String_indexOfII; + this.indexOfIII = java_lang_String_indexOfIII; + this.lastIndexOfII = java_lang_String_lastIndexOfII; + this.lastIndexOfIII = java_lang_String_lastIndexOfIII; + this.indexOfILjava_lang_String = java_lang_String_indexOfILjava_lang_String; + this.indexOfILjava_lang_StringI = java_lang_String_indexOfILjava_lang_StringI; + this.lastIndexOfILjava_lang_String = java_lang_String_lastIndexOfILjava_lang_String; + this.lastIndexOfILjava_lang_StringI = java_lang_String_lastIndexOfILjava_lang_StringI; + this.substringLjava_lang_StringI = java_lang_String_substringLjava_lang_StringI; + this.substringLjava_lang_StringII = java_lang_String_substringLjava_lang_StringII; + this.subSequenceLjava_lang_CharSequenceII = java_lang_String_subSequenceLjava_lang_CharSequenceII; + this.concatLjava_lang_StringLjava_lang_String = java_lang_String_concatLjava_lang_StringLjava_lang_String; + this.replaceLjava_lang_StringCC = java_lang_String_replaceLjava_lang_StringCC; + this.matchesZLjava_lang_String = java_lang_String_matchesZLjava_lang_String; + this.containsZLjava_lang_CharSequence = java_lang_String_containsZLjava_lang_CharSequence; + this.replaceFirstLjava_lang_StringLjava_lang_StringLjava_lang_String = java_lang_String_replaceFirstLjava_lang_StringLjava_lang_StringLjava_lang_String; + this.replaceAllLjava_lang_StringLjava_lang_StringLjava_lang_String = java_lang_String_replaceAllLjava_lang_StringLjava_lang_StringLjava_lang_String; + this.replaceLjava_lang_StringLjava_lang_CharSequenceLjava_lang_CharSequence = java_lang_String_replaceLjava_lang_StringLjava_lang_CharSequenceLjava_lang_CharSequence; + this.splitALjava_lang_StringLjava_lang_StringI = java_lang_String_splitALjava_lang_StringLjava_lang_StringI; + this.splitALjava_lang_StringLjava_lang_String = java_lang_String_splitALjava_lang_StringLjava_lang_String; + this.toLowerCaseLjava_lang_StringLjava_util_Locale = java_lang_String_toLowerCaseLjava_lang_StringLjava_util_Locale; + this.toLowerCaseLjava_lang_String = java_lang_String_toLowerCaseLjava_lang_String; + this.toUpperCaseLjava_lang_StringLjava_util_Locale = java_lang_String_toUpperCaseLjava_lang_StringLjava_util_Locale; + this.toUpperCaseLjava_lang_String = java_lang_String_toUpperCaseLjava_lang_String; + this.trimLjava_lang_String = java_lang_String_trimLjava_lang_String; + this.toStringLjava_lang_String = java_lang_String_toStringLjava_lang_String; + this.toCharArrayAC = java_lang_String_toCharArrayAC; + this.internLjava_lang_String = java_lang_String_internLjava_lang_String; + this.compareToILjava_lang_Object = java_lang_String_compareToILjava_lang_Object; + */ + + + diff -r 4fca8ddf46de -r ff3f0de0b8a2 vm/src/test/java/org/apidesign/vm4brwsr/InstanceSubTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/InstanceSubTest.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,15 @@ +package org.apidesign.vm4brwsr; + +/** Checks if everything works OK, when we switch the + * order of loaded classes. + * + * @author Jaroslav Tulach + */ +public class InstanceSubTest extends InstanceTest { + + @Override + protected String startCompilationWith() { + return "org/apidesign/vm4brwsr/InstanceSub"; + } + +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 vm/src/test/java/org/apidesign/vm4brwsr/InstanceTest.java --- a/vm/src/test/java/org/apidesign/vm4brwsr/InstanceTest.java Fri Sep 28 14:58:21 2012 +0200 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/InstanceTest.java Thu Oct 11 06:16:00 2012 -0700 @@ -102,11 +102,15 @@ ); } - private static void assertExec(String msg, String methodName, Object expRes, Object... args) throws Exception { + protected String startCompilationWith() { + return "org/apidesign/vm4brwsr/Instance"; + } + + private void assertExec( + String msg, String methodName, Object expRes, Object... args + ) throws Exception { StringBuilder sb = new StringBuilder(); - Invocable i = StaticMethodTest.compileClass(sb, - "org/apidesign/vm4brwsr/Instance" - ); + Invocable i = StaticMethodTest.compileClass(sb, startCompilationWith()); Object ret = null; try { diff -r 4fca8ddf46de -r ff3f0de0b8a2 vm/src/test/java/org/apidesign/vm4brwsr/StaticMethod.java --- a/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethod.java Fri Sep 28 14:58:21 2012 +0200 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethod.java Thu Oct 11 06:16:00 2012 -0700 @@ -17,6 +17,8 @@ */ package org.apidesign.vm4brwsr; +import org.apidesign.bck2brwsr.core.JavaScriptBody; + /** * * @author Jaroslav Tulach @@ -61,6 +63,16 @@ public static long orOrAnd(boolean doOr, int a, int b) { return doOr ? a | b : a & b; } + public static int shiftLeft(int what, int much) { + return what << much; + } + public static int shiftArithmRight(int what, int much, boolean signed) { + if (signed) { + return what >> much; + } else { + return what >>> much; + } + } public static long factRec(int n) { if (n <= 1) { return 1; @@ -81,4 +93,16 @@ cnt++; return cnt; } + + @JavaScriptBody( + args={"i","j"}, body="return (i + j).toString();" + ) + public static String i2s(int i, int j) { + throw new IllegalStateException(); + } + + static { + // check order of initializers + StaticUse.NON_NULL.equals(new Object()); + } } diff -r 4fca8ddf46de -r ff3f0de0b8a2 vm/src/test/java/org/apidesign/vm4brwsr/StaticMethodTest.java --- a/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethodTest.java Fri Sep 28 14:58:21 2012 +0200 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethodTest.java Thu Oct 11 06:16:00 2012 -0700 @@ -143,6 +143,56 @@ ); } + @Test public void shiftLeftInJava() throws Exception { + int res = StaticMethod.shiftLeft(1, 8); + assertEquals(res, 256); + } + + @Test public void shiftLeftInJS() throws Exception { + assertExec( + "Setting 9th bit", + "org_apidesign_vm4brwsr_StaticMethod_shiftLeftIII", + Double.valueOf(256), + 1, 8 + ); + } + + @Test public void shiftRightInJava() throws Exception { + int res = StaticMethod.shiftArithmRight(-8, 3, true); + assertEquals(res, -1); + } + + @Test public void shiftRightInJS() throws Exception { + assertExec( + "Get -1", + "org_apidesign_vm4brwsr_StaticMethod_shiftArithmRightIIIZ", + Double.valueOf(-1), + -8, 3, true + ); + } + @Test public void unsignedShiftRightInJava() throws Exception { + int res = StaticMethod.shiftArithmRight(8, 3, false); + assertEquals(res, 1); + } + + @Test public void unsignedShiftRightInJS() throws Exception { + assertExec( + "Get -1", + "org_apidesign_vm4brwsr_StaticMethod_shiftArithmRightIIIZ", + Double.valueOf(1), + 8, 3, false + ); + } + + @Test public void javaScriptBody() throws Exception { + assertExec( + "JavaScript string", + "org_apidesign_vm4brwsr_StaticMethod_i2sLjava_lang_StringII", + "333", + 330, 3 + ); + } + private static void assertExec(String msg, String methodName, Object expRes, Object... args) throws Exception { StringBuilder sb = new StringBuilder(); Invocable i = compileClass(sb, "org/apidesign/vm4brwsr/StaticMethod"); diff -r 4fca8ddf46de -r ff3f0de0b8a2 vm/src/test/java/org/apidesign/vm4brwsr/StaticUse.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/StaticUse.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,5 @@ +package org.apidesign.vm4brwsr; + +public class StaticUse { + public static final Object NON_NULL = new Object(); +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 vm/src/test/java/org/apidesign/vm4brwsr/StringSample.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/StringSample.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,38 @@ +package org.apidesign.vm4brwsr; + +/** + * + * @author Jaroslav Tulach + */ +public class StringSample { + public static final String HELLO = "Hello World!"; + private static int counter; + + private final int cnt; + public StringSample() { + cnt = ++counter; + } + + + public static char sayHello(int indx) { + return HELLO.charAt(indx); + } + + public static String fromChars(char a, char b, char c) { + char[] arr = { a, b, c }; + return new String(arr).toString(); + } + + public static String toStringTest(int howMuch) { + StringSample ss = null; + for (int i = 0; i < howMuch; i++) { + ss = new StringSample(); + } + return ss.toString().toString(); + } + + @Override + public String toString() { + return HELLO + cnt; + } +} diff -r 4fca8ddf46de -r ff3f0de0b8a2 vm/src/test/java/org/apidesign/vm4brwsr/StringTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/StringTest.java Thu Oct 11 06:16:00 2012 -0700 @@ -0,0 +1,65 @@ +package org.apidesign.vm4brwsr; + +import javax.script.Invocable; +import javax.script.ScriptException; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * + * @author Jaroslav Tulach + */ +public class StringTest { + @Test public void firstChar() throws Exception { + assertExec( + "First char in Hello is H", + "org_apidesign_vm4brwsr_StringSample_sayHelloCI", + "H", 0 + ); + } + + @Test public void fromChars() throws Exception { + assertExec( + "First char in Hello is ABC", + "org_apidesign_vm4brwsr_StringSample_fromCharsLjava_lang_StringCCC", + "ABC", 'A', 'B', 'C' + ); + } + + @Test(timeOut=10000) public void toStringConcatenation() throws Exception { + assertExec( + "Five executions should generate 5Hello World!", + "org_apidesign_vm4brwsr_StringSample_toStringTestLjava_lang_StringI", + "Hello World!5", 5 + ); + } + @Test public void toStringConcatenationJava() throws Exception { + assertEquals("Hello World!5", StringSample.toStringTest(5)); + } + + private static void assertExec(String msg, String methodName, Object expRes, Object... args) throws Exception { + StringBuilder sb = new StringBuilder(); + Invocable i = StaticMethodTest.compileClass(sb, + "org/apidesign/vm4brwsr/StringSample", + "java/lang/String" + ); + + Object ret = null; + try { + ret = i.invokeFunction(methodName, args); + } catch (ScriptException ex) { + fail("Execution failed in " + sb, ex); + } catch (NoSuchMethodException ex) { + fail("Cannot find method in " + sb, ex); + } + if (ret == null && expRes == null) { + return; + } + if (expRes.equals(ret)) { + return; + } + assertEquals(ret, expRes, msg + "was: " + ret + "\n" + sb); + + } + +}