The emulation approach turned to be working well. Let's merge it to trunk.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/.hgtags Thu Oct 11 06:16:00 2012 -0700
1.3 @@ -0,0 +1,1 @@
1.4 +0a115f1c6f3c70458fc479ae82b4d7fcdeb7e95a jdk7-b147_base
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/core/pom.xml Thu Oct 11 06:16:00 2012 -0700
2.3 @@ -0,0 +1,26 @@
2.4 +<?xml version="1.0"?>
2.5 +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
2.6 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2.7 + <modelVersion>4.0.0</modelVersion>
2.8 + <parent>
2.9 + <groupId>org.apidesign</groupId>
2.10 + <artifactId>bck2brwsr</artifactId>
2.11 + <version>1.0-SNAPSHOT</version>
2.12 + </parent>
2.13 + <groupId>org.apidesign.bck2brwsr</groupId>
2.14 + <artifactId>core</artifactId>
2.15 + <version>1.0-SNAPSHOT</version>
2.16 + <name>core</name>
2.17 + <url>http://maven.apache.org</url>
2.18 + <properties>
2.19 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2.20 + </properties>
2.21 + <dependencies>
2.22 + <dependency>
2.23 + <groupId>junit</groupId>
2.24 + <artifactId>junit</artifactId>
2.25 + <version>3.8.1</version>
2.26 + <scope>test</scope>
2.27 + </dependency>
2.28 + </dependencies>
2.29 +</project>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/core/src/main/java/org/apidesign/bck2brwsr/core/ExtraJavaScript.java Thu Oct 11 06:16:00 2012 -0700
3.3 @@ -0,0 +1,19 @@
3.4 +package org.apidesign.bck2brwsr.core;
3.5 +
3.6 +import java.lang.annotation.ElementType;
3.7 +import java.lang.annotation.Retention;
3.8 +import java.lang.annotation.RetentionPolicy;
3.9 +import java.lang.annotation.Target;
3.10 +
3.11 +/**
3.12 + *
3.13 + * @author Jaroslav Tulach <jtulach@netbeans.org>
3.14 + */
3.15 +@Retention(RetentionPolicy.CLASS)
3.16 +@Target(ElementType.TYPE)
3.17 +public @interface ExtraJavaScript {
3.18 + /** location of a script to load */
3.19 + String resource();
3.20 + /** should the class file still be processed or not? */
3.21 + boolean processByteCode() default true;
3.22 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/core/src/main/java/org/apidesign/bck2brwsr/core/JavaScriptBody.java Thu Oct 11 06:16:00 2012 -0700
4.3 @@ -0,0 +1,38 @@
4.4 +/*
4.5 + * To change this template, choose Tools | Templates
4.6 + * and open the template in the editor.
4.7 + */
4.8 +package org.apidesign.bck2brwsr.core;
4.9 +
4.10 +import java.lang.annotation.ElementType;
4.11 +import java.lang.annotation.Retention;
4.12 +import java.lang.annotation.RetentionPolicy;
4.13 +import java.lang.annotation.Target;
4.14 +
4.15 +/** Put this method on a method in case it should have a special
4.16 + * body in the <em>JavaScript</em>.
4.17 + *
4.18 + * @author Jaroslav Tulach <jtulach@netbeans.org>
4.19 + */
4.20 +@Retention(RetentionPolicy.CLASS)
4.21 +@Target({ ElementType.METHOD, ElementType.CONSTRUCTOR })
4.22 +public @interface JavaScriptBody {
4.23 + /** Names of parameters for the method.
4.24 + *
4.25 + * <!--
4.26 + * If not specified
4.27 + * it will be <code>arg0, arg1, arg2</code>. In case of
4.28 + * instance methods, the <code>arg0</code> is reference
4.29 + * to <code>this</code>.
4.30 + * -->
4.31 + *
4.32 + * @return array of the names of parameters for the method
4.33 + * in JavaScript
4.34 + */
4.35 + public String[] args();
4.36 +
4.37 + /** The actual body of the method in JavaScript. This string will be
4.38 + * put into generated header (ends with '{') and footer (ends with '}').
4.39 + */
4.40 + public String body();
4.41 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/core/src/main/java/org/apidesign/bck2brwsr/core/NoJavaScript.java Thu Oct 11 06:16:00 2012 -0700
5.3 @@ -0,0 +1,16 @@
5.4 +package org.apidesign.bck2brwsr.core;
5.5 +
5.6 +import java.lang.annotation.ElementType;
5.7 +import java.lang.annotation.Retention;
5.8 +import java.lang.annotation.RetentionPolicy;
5.9 +import java.lang.annotation.Target;
5.10 +
5.11 +/** Don't include given field or method in generated JavaScript.
5.12 + *
5.13 + * @author Jaroslav Tulach <jtulach@netbeans.org>
5.14 + */
5.15 +@Retention(RetentionPolicy.CLASS)
5.16 +@Target({ ElementType.METHOD, ElementType.FIELD })
5.17 +public @interface NoJavaScript {
5.18 +
5.19 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/emul/pom.xml Thu Oct 11 06:16:00 2012 -0700
6.3 @@ -0,0 +1,48 @@
6.4 +<?xml version="1.0"?>
6.5 +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
6.6 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
6.7 + <modelVersion>4.0.0</modelVersion>
6.8 + <parent>
6.9 + <groupId>org.apidesign</groupId>
6.10 + <artifactId>bck2brwsr</artifactId>
6.11 + <version>1.0-SNAPSHOT</version>
6.12 + </parent>
6.13 + <groupId>org.apidesign.bck2brwsr</groupId>
6.14 + <artifactId>emul</artifactId>
6.15 + <version>1.0-SNAPSHOT</version>
6.16 + <name>Java API Emulation</name>
6.17 + <url>http://maven.apache.org</url>
6.18 + <properties>
6.19 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
6.20 + </properties>
6.21 + <dependencies>
6.22 + <dependency>
6.23 + <groupId>junit</groupId>
6.24 + <artifactId>junit</artifactId>
6.25 + <version>3.8.1</version>
6.26 + <scope>test</scope>
6.27 + </dependency>
6.28 + <dependency>
6.29 + <groupId>org.apidesign.bck2brwsr</groupId>
6.30 + <artifactId>core</artifactId>
6.31 + <version>1.0-SNAPSHOT</version>
6.32 + <type>jar</type>
6.33 + </dependency>
6.34 + </dependencies>
6.35 + <build>
6.36 + <plugins>
6.37 + <plugin>
6.38 + <groupId>org.apache.maven.plugins</groupId>
6.39 + <artifactId>maven-compiler-plugin</artifactId>
6.40 + <version>2.5.1</version>
6.41 + <configuration>
6.42 + <compilerArguments>
6.43 + <bootclasspath>non-existing</bootclasspath>
6.44 + </compilerArguments>
6.45 + <source>1.7</source>
6.46 + <target>1.7</target>
6.47 + </configuration>
6.48 + </plugin>
6.49 + </plugins>
6.50 + </build>
6.51 +</project>
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/emul/src/main/java/java/io/IOException.java Thu Oct 11 06:16:00 2012 -0700
7.3 @@ -0,0 +1,101 @@
7.4 +/*
7.5 + * Copyright (c) 1994, 2006, Oracle and/or its affiliates. All rights reserved.
7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7.7 + *
7.8 + * This code is free software; you can redistribute it and/or modify it
7.9 + * under the terms of the GNU General Public License version 2 only, as
7.10 + * published by the Free Software Foundation. Oracle designates this
7.11 + * particular file as subject to the "Classpath" exception as provided
7.12 + * by Oracle in the LICENSE file that accompanied this code.
7.13 + *
7.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
7.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7.17 + * version 2 for more details (a copy is included in the LICENSE file that
7.18 + * accompanied this code).
7.19 + *
7.20 + * You should have received a copy of the GNU General Public License version
7.21 + * 2 along with this work; if not, write to the Free Software Foundation,
7.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7.23 + *
7.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7.25 + * or visit www.oracle.com if you need additional information or have any
7.26 + * questions.
7.27 + */
7.28 +
7.29 +package java.io;
7.30 +
7.31 +/**
7.32 + * Signals that an I/O exception of some sort has occurred. This
7.33 + * class is the general class of exceptions produced by failed or
7.34 + * interrupted I/O operations.
7.35 + *
7.36 + * @author unascribed
7.37 + * @see java.io.InputStream
7.38 + * @see java.io.OutputStream
7.39 + * @since JDK1.0
7.40 + */
7.41 +public
7.42 +class IOException extends Exception {
7.43 + static final long serialVersionUID = 7818375828146090155L;
7.44 +
7.45 + /**
7.46 + * Constructs an {@code IOException} with {@code null}
7.47 + * as its error detail message.
7.48 + */
7.49 + public IOException() {
7.50 + super();
7.51 + }
7.52 +
7.53 + /**
7.54 + * Constructs an {@code IOException} with the specified detail message.
7.55 + *
7.56 + * @param message
7.57 + * The detail message (which is saved for later retrieval
7.58 + * by the {@link #getMessage()} method)
7.59 + */
7.60 + public IOException(String message) {
7.61 + super(message);
7.62 + }
7.63 +
7.64 + /**
7.65 + * Constructs an {@code IOException} with the specified detail message
7.66 + * and cause.
7.67 + *
7.68 + * <p> Note that the detail message associated with {@code cause} is
7.69 + * <i>not</i> automatically incorporated into this exception's detail
7.70 + * message.
7.71 + *
7.72 + * @param message
7.73 + * The detail message (which is saved for later retrieval
7.74 + * by the {@link #getMessage()} method)
7.75 + *
7.76 + * @param cause
7.77 + * The cause (which is saved for later retrieval by the
7.78 + * {@link #getCause()} method). (A null value is permitted,
7.79 + * and indicates that the cause is nonexistent or unknown.)
7.80 + *
7.81 + * @since 1.6
7.82 + */
7.83 + public IOException(String message, Throwable cause) {
7.84 + super(message, cause);
7.85 + }
7.86 +
7.87 + /**
7.88 + * Constructs an {@code IOException} with the specified cause and a
7.89 + * detail message of {@code (cause==null ? null : cause.toString())}
7.90 + * (which typically contains the class and detail message of {@code cause}).
7.91 + * This constructor is useful for IO exceptions that are little more
7.92 + * than wrappers for other throwables.
7.93 + *
7.94 + * @param cause
7.95 + * The cause (which is saved for later retrieval by the
7.96 + * {@link #getCause()} method). (A null value is permitted,
7.97 + * and indicates that the cause is nonexistent or unknown.)
7.98 + *
7.99 + * @since 1.6
7.100 + */
7.101 + public IOException(Throwable cause) {
7.102 + super(cause);
7.103 + }
7.104 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/emul/src/main/java/java/io/Serializable.java Thu Oct 11 06:16:00 2012 -0700
8.3 @@ -0,0 +1,170 @@
8.4 +/*
8.5 + * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8.7 + *
8.8 + * This code is free software; you can redistribute it and/or modify it
8.9 + * under the terms of the GNU General Public License version 2 only, as
8.10 + * published by the Free Software Foundation. Oracle designates this
8.11 + * particular file as subject to the "Classpath" exception as provided
8.12 + * by Oracle in the LICENSE file that accompanied this code.
8.13 + *
8.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
8.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8.17 + * version 2 for more details (a copy is included in the LICENSE file that
8.18 + * accompanied this code).
8.19 + *
8.20 + * You should have received a copy of the GNU General Public License version
8.21 + * 2 along with this work; if not, write to the Free Software Foundation,
8.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8.23 + *
8.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8.25 + * or visit www.oracle.com if you need additional information or have any
8.26 + * questions.
8.27 + */
8.28 +
8.29 +package java.io;
8.30 +
8.31 +/**
8.32 + * Serializability of a class is enabled by the class implementing the
8.33 + * java.io.Serializable interface. Classes that do not implement this
8.34 + * interface will not have any of their state serialized or
8.35 + * deserialized. All subtypes of a serializable class are themselves
8.36 + * serializable. The serialization interface has no methods or fields
8.37 + * and serves only to identify the semantics of being serializable. <p>
8.38 + *
8.39 + * To allow subtypes of non-serializable classes to be serialized, the
8.40 + * subtype may assume responsibility for saving and restoring the
8.41 + * state of the supertype's public, protected, and (if accessible)
8.42 + * package fields. The subtype may assume this responsibility only if
8.43 + * the class it extends has an accessible no-arg constructor to
8.44 + * initialize the class's state. It is an error to declare a class
8.45 + * Serializable if this is not the case. The error will be detected at
8.46 + * runtime. <p>
8.47 + *
8.48 + * During deserialization, the fields of non-serializable classes will
8.49 + * be initialized using the public or protected no-arg constructor of
8.50 + * the class. A no-arg constructor must be accessible to the subclass
8.51 + * that is serializable. The fields of serializable subclasses will
8.52 + * be restored from the stream. <p>
8.53 + *
8.54 + * When traversing a graph, an object may be encountered that does not
8.55 + * support the Serializable interface. In this case the
8.56 + * NotSerializableException will be thrown and will identify the class
8.57 + * of the non-serializable object. <p>
8.58 + *
8.59 + * Classes that require special handling during the serialization and
8.60 + * deserialization process must implement special methods with these exact
8.61 + * signatures: <p>
8.62 + *
8.63 + * <PRE>
8.64 + * private void writeObject(java.io.ObjectOutputStream out)
8.65 + * throws IOException
8.66 + * private void readObject(java.io.ObjectInputStream in)
8.67 + * throws IOException, ClassNotFoundException;
8.68 + * private void readObjectNoData()
8.69 + * throws ObjectStreamException;
8.70 + * </PRE>
8.71 + *
8.72 + * <p>The writeObject method is responsible for writing the state of the
8.73 + * object for its particular class so that the corresponding
8.74 + * readObject method can restore it. The default mechanism for saving
8.75 + * the Object's fields can be invoked by calling
8.76 + * out.defaultWriteObject. The method does not need to concern
8.77 + * itself with the state belonging to its superclasses or subclasses.
8.78 + * State is saved by writing the individual fields to the
8.79 + * ObjectOutputStream using the writeObject method or by using the
8.80 + * methods for primitive data types supported by DataOutput.
8.81 + *
8.82 + * <p>The readObject method is responsible for reading from the stream and
8.83 + * restoring the classes fields. It may call in.defaultReadObject to invoke
8.84 + * the default mechanism for restoring the object's non-static and
8.85 + * non-transient fields. The defaultReadObject method uses information in
8.86 + * the stream to assign the fields of the object saved in the stream with the
8.87 + * correspondingly named fields in the current object. This handles the case
8.88 + * when the class has evolved to add new fields. The method does not need to
8.89 + * concern itself with the state belonging to its superclasses or subclasses.
8.90 + * State is saved by writing the individual fields to the
8.91 + * ObjectOutputStream using the writeObject method or by using the
8.92 + * methods for primitive data types supported by DataOutput.
8.93 + *
8.94 + * <p>The readObjectNoData method is responsible for initializing the state of
8.95 + * the object for its particular class in the event that the serialization
8.96 + * stream does not list the given class as a superclass of the object being
8.97 + * deserialized. This may occur in cases where the receiving party uses a
8.98 + * different version of the deserialized instance's class than the sending
8.99 + * party, and the receiver's version extends classes that are not extended by
8.100 + * the sender's version. This may also occur if the serialization stream has
8.101 + * been tampered; hence, readObjectNoData is useful for initializing
8.102 + * deserialized objects properly despite a "hostile" or incomplete source
8.103 + * stream.
8.104 + *
8.105 + * <p>Serializable classes that need to designate an alternative object to be
8.106 + * used when writing an object to the stream should implement this
8.107 + * special method with the exact signature: <p>
8.108 + *
8.109 + * <PRE>
8.110 + * ANY-ACCESS-MODIFIER Object writeReplace() throws ObjectStreamException;
8.111 + * </PRE><p>
8.112 + *
8.113 + * This writeReplace method is invoked by serialization if the method
8.114 + * exists and it would be accessible from a method defined within the
8.115 + * class of the object being serialized. Thus, the method can have private,
8.116 + * protected and package-private access. Subclass access to this method
8.117 + * follows java accessibility rules. <p>
8.118 + *
8.119 + * Classes that need to designate a replacement when an instance of it
8.120 + * is read from the stream should implement this special method with the
8.121 + * exact signature.<p>
8.122 + *
8.123 + * <PRE>
8.124 + * ANY-ACCESS-MODIFIER Object readResolve() throws ObjectStreamException;
8.125 + * </PRE><p>
8.126 + *
8.127 + * This readResolve method follows the same invocation rules and
8.128 + * accessibility rules as writeReplace.<p>
8.129 + *
8.130 + * The serialization runtime associates with each serializable class a version
8.131 + * number, called a serialVersionUID, which is used during deserialization to
8.132 + * verify that the sender and receiver of a serialized object have loaded
8.133 + * classes for that object that are compatible with respect to serialization.
8.134 + * If the receiver has loaded a class for the object that has a different
8.135 + * serialVersionUID than that of the corresponding sender's class, then
8.136 + * deserialization will result in an {@link InvalidClassException}. A
8.137 + * serializable class can declare its own serialVersionUID explicitly by
8.138 + * declaring a field named <code>"serialVersionUID"</code> that must be static,
8.139 + * final, and of type <code>long</code>:<p>
8.140 + *
8.141 + * <PRE>
8.142 + * ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;
8.143 + * </PRE>
8.144 + *
8.145 + * If a serializable class does not explicitly declare a serialVersionUID, then
8.146 + * the serialization runtime will calculate a default serialVersionUID value
8.147 + * for that class based on various aspects of the class, as described in the
8.148 + * Java(TM) Object Serialization Specification. However, it is <em>strongly
8.149 + * recommended</em> that all serializable classes explicitly declare
8.150 + * serialVersionUID values, since the default serialVersionUID computation is
8.151 + * highly sensitive to class details that may vary depending on compiler
8.152 + * implementations, and can thus result in unexpected
8.153 + * <code>InvalidClassException</code>s during deserialization. Therefore, to
8.154 + * guarantee a consistent serialVersionUID value across different java compiler
8.155 + * implementations, a serializable class must declare an explicit
8.156 + * serialVersionUID value. It is also strongly advised that explicit
8.157 + * serialVersionUID declarations use the <code>private</code> modifier where
8.158 + * possible, since such declarations apply only to the immediately declaring
8.159 + * class--serialVersionUID fields are not useful as inherited members. Array
8.160 + * classes cannot declare an explicit serialVersionUID, so they always have
8.161 + * the default computed value, but the requirement for matching
8.162 + * serialVersionUID values is waived for array classes.
8.163 + *
8.164 + * @author unascribed
8.165 + * @see java.io.ObjectOutputStream
8.166 + * @see java.io.ObjectInputStream
8.167 + * @see java.io.ObjectOutput
8.168 + * @see java.io.ObjectInput
8.169 + * @see java.io.Externalizable
8.170 + * @since JDK1.1
8.171 + */
8.172 +public interface Serializable {
8.173 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/emul/src/main/java/java/io/UnsupportedEncodingException.java Thu Oct 11 06:16:00 2012 -0700
9.3 @@ -0,0 +1,52 @@
9.4 +/*
9.5 + * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9.7 + *
9.8 + * This code is free software; you can redistribute it and/or modify it
9.9 + * under the terms of the GNU General Public License version 2 only, as
9.10 + * published by the Free Software Foundation. Oracle designates this
9.11 + * particular file as subject to the "Classpath" exception as provided
9.12 + * by Oracle in the LICENSE file that accompanied this code.
9.13 + *
9.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
9.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9.17 + * version 2 for more details (a copy is included in the LICENSE file that
9.18 + * accompanied this code).
9.19 + *
9.20 + * You should have received a copy of the GNU General Public License version
9.21 + * 2 along with this work; if not, write to the Free Software Foundation,
9.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9.23 + *
9.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9.25 + * or visit www.oracle.com if you need additional information or have any
9.26 + * questions.
9.27 + */
9.28 +package java.io;
9.29 +
9.30 +/**
9.31 + * The Character Encoding is not supported.
9.32 + *
9.33 + * @author Asmus Freytag
9.34 + * @since JDK1.1
9.35 + */
9.36 +public class UnsupportedEncodingException
9.37 + extends IOException
9.38 +{
9.39 + private static final long serialVersionUID = -4274276298326136670L;
9.40 +
9.41 + /**
9.42 + * Constructs an UnsupportedEncodingException without a detail message.
9.43 + */
9.44 + public UnsupportedEncodingException() {
9.45 + super();
9.46 + }
9.47 +
9.48 + /**
9.49 + * Constructs an UnsupportedEncodingException with a detail message.
9.50 + * @param s Describes the reason for the exception.
9.51 + */
9.52 + public UnsupportedEncodingException(String s) {
9.53 + super(s);
9.54 + }
9.55 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/emul/src/main/java/java/lang/AbstractStringBuilder.java Thu Oct 11 06:16:00 2012 -0700
10.3 @@ -0,0 +1,1408 @@
10.4 +/*
10.5 + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10.7 + *
10.8 + * This code is free software; you can redistribute it and/or modify it
10.9 + * under the terms of the GNU General Public License version 2 only, as
10.10 + * published by the Free Software Foundation. Oracle designates this
10.11 + * particular file as subject to the "Classpath" exception as provided
10.12 + * by Oracle in the LICENSE file that accompanied this code.
10.13 + *
10.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
10.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
10.17 + * version 2 for more details (a copy is included in the LICENSE file that
10.18 + * accompanied this code).
10.19 + *
10.20 + * You should have received a copy of the GNU General Public License version
10.21 + * 2 along with this work; if not, write to the Free Software Foundation,
10.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
10.23 + *
10.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
10.25 + * or visit www.oracle.com if you need additional information or have any
10.26 + * questions.
10.27 + */
10.28 +
10.29 +package java.lang;
10.30 +
10.31 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
10.32 +
10.33 +/**
10.34 + * A mutable sequence of characters.
10.35 + * <p>
10.36 + * Implements a modifiable string. At any point in time it contains some
10.37 + * particular sequence of characters, but the length and content of the
10.38 + * sequence can be changed through certain method calls.
10.39 + *
10.40 + * @author Michael McCloskey
10.41 + * @author Martin Buchholz
10.42 + * @author Ulf Zibis
10.43 + * @since 1.5
10.44 + */
10.45 +abstract class AbstractStringBuilder implements Appendable, CharSequence {
10.46 + /**
10.47 + * The value is used for character storage.
10.48 + */
10.49 + char[] value;
10.50 +
10.51 + /**
10.52 + * The count is the number of characters used.
10.53 + */
10.54 + int count;
10.55 +
10.56 + /**
10.57 + * This no-arg constructor is necessary for serialization of subclasses.
10.58 + */
10.59 + AbstractStringBuilder() {
10.60 + }
10.61 +
10.62 + /**
10.63 + * Creates an AbstractStringBuilder of the specified capacity.
10.64 + */
10.65 + AbstractStringBuilder(int capacity) {
10.66 + value = new char[capacity];
10.67 + }
10.68 +
10.69 + /**
10.70 + * Returns the length (character count).
10.71 + *
10.72 + * @return the length of the sequence of characters currently
10.73 + * represented by this object
10.74 + */
10.75 + public int length() {
10.76 + return count;
10.77 + }
10.78 +
10.79 + /**
10.80 + * Returns the current capacity. The capacity is the amount of storage
10.81 + * available for newly inserted characters, beyond which an allocation
10.82 + * will occur.
10.83 + *
10.84 + * @return the current capacity
10.85 + */
10.86 + public int capacity() {
10.87 + return value.length;
10.88 + }
10.89 +
10.90 + /**
10.91 + * Ensures that the capacity is at least equal to the specified minimum.
10.92 + * If the current capacity is less than the argument, then a new internal
10.93 + * array is allocated with greater capacity. The new capacity is the
10.94 + * larger of:
10.95 + * <ul>
10.96 + * <li>The <code>minimumCapacity</code> argument.
10.97 + * <li>Twice the old capacity, plus <code>2</code>.
10.98 + * </ul>
10.99 + * If the <code>minimumCapacity</code> argument is nonpositive, this
10.100 + * method takes no action and simply returns.
10.101 + *
10.102 + * @param minimumCapacity the minimum desired capacity.
10.103 + */
10.104 + public void ensureCapacity(int minimumCapacity) {
10.105 + if (minimumCapacity > 0)
10.106 + ensureCapacityInternal(minimumCapacity);
10.107 + }
10.108 +
10.109 + /**
10.110 + * This method has the same contract as ensureCapacity, but is
10.111 + * never synchronized.
10.112 + */
10.113 + private void ensureCapacityInternal(int minimumCapacity) {
10.114 + // overflow-conscious code
10.115 + if (minimumCapacity - value.length > 0)
10.116 + expandCapacity(minimumCapacity);
10.117 + }
10.118 +
10.119 + /**
10.120 + * This implements the expansion semantics of ensureCapacity with no
10.121 + * size check or synchronization.
10.122 + */
10.123 + void expandCapacity(int minimumCapacity) {
10.124 + int newCapacity = value.length * 2 + 2;
10.125 + if (newCapacity - minimumCapacity < 0)
10.126 + newCapacity = minimumCapacity;
10.127 + if (newCapacity < 0) {
10.128 + if (minimumCapacity < 0) // overflow
10.129 + throw new OutOfMemoryError();
10.130 + newCapacity = Integer.MAX_VALUE;
10.131 + }
10.132 + value = String.copyOf(value, newCapacity);
10.133 + }
10.134 +
10.135 + /**
10.136 + * Attempts to reduce storage used for the character sequence.
10.137 + * If the buffer is larger than necessary to hold its current sequence of
10.138 + * characters, then it may be resized to become more space efficient.
10.139 + * Calling this method may, but is not required to, affect the value
10.140 + * returned by a subsequent call to the {@link #capacity()} method.
10.141 + */
10.142 + public void trimToSize() {
10.143 + if (count < value.length) {
10.144 + value = String.copyOf(value, count);
10.145 + }
10.146 + }
10.147 +
10.148 + /**
10.149 + * Sets the length of the character sequence.
10.150 + * The sequence is changed to a new character sequence
10.151 + * whose length is specified by the argument. For every nonnegative
10.152 + * index <i>k</i> less than <code>newLength</code>, the character at
10.153 + * index <i>k</i> in the new character sequence is the same as the
10.154 + * character at index <i>k</i> in the old sequence if <i>k</i> is less
10.155 + * than the length of the old character sequence; otherwise, it is the
10.156 + * null character <code>'\u0000'</code>.
10.157 + *
10.158 + * In other words, if the <code>newLength</code> argument is less than
10.159 + * the current length, the length is changed to the specified length.
10.160 + * <p>
10.161 + * If the <code>newLength</code> argument is greater than or equal
10.162 + * to the current length, sufficient null characters
10.163 + * (<code>'\u0000'</code>) are appended so that
10.164 + * length becomes the <code>newLength</code> argument.
10.165 + * <p>
10.166 + * The <code>newLength</code> argument must be greater than or equal
10.167 + * to <code>0</code>.
10.168 + *
10.169 + * @param newLength the new length
10.170 + * @throws IndexOutOfBoundsException if the
10.171 + * <code>newLength</code> argument is negative.
10.172 + */
10.173 + public void setLength(int newLength) {
10.174 + if (newLength < 0)
10.175 + throw new StringIndexOutOfBoundsException(newLength);
10.176 + ensureCapacityInternal(newLength);
10.177 +
10.178 + if (count < newLength) {
10.179 + for (; count < newLength; count++)
10.180 + value[count] = '\0';
10.181 + } else {
10.182 + count = newLength;
10.183 + }
10.184 + }
10.185 +
10.186 + /**
10.187 + * Returns the <code>char</code> value in this sequence at the specified index.
10.188 + * The first <code>char</code> value is at index <code>0</code>, the next at index
10.189 + * <code>1</code>, and so on, as in array indexing.
10.190 + * <p>
10.191 + * The index argument must be greater than or equal to
10.192 + * <code>0</code>, and less than the length of this sequence.
10.193 + *
10.194 + * <p>If the <code>char</code> value specified by the index is a
10.195 + * <a href="Character.html#unicode">surrogate</a>, the surrogate
10.196 + * value is returned.
10.197 + *
10.198 + * @param index the index of the desired <code>char</code> value.
10.199 + * @return the <code>char</code> value at the specified index.
10.200 + * @throws IndexOutOfBoundsException if <code>index</code> is
10.201 + * negative or greater than or equal to <code>length()</code>.
10.202 + */
10.203 + public char charAt(int index) {
10.204 + if ((index < 0) || (index >= count))
10.205 + throw new StringIndexOutOfBoundsException(index);
10.206 + return value[index];
10.207 + }
10.208 +
10.209 + /**
10.210 + * Returns the character (Unicode code point) at the specified
10.211 + * index. The index refers to <code>char</code> values
10.212 + * (Unicode code units) and ranges from <code>0</code> to
10.213 + * {@link #length()}<code> - 1</code>.
10.214 + *
10.215 + * <p> If the <code>char</code> value specified at the given index
10.216 + * is in the high-surrogate range, the following index is less
10.217 + * than the length of this sequence, and the
10.218 + * <code>char</code> value at the following index is in the
10.219 + * low-surrogate range, then the supplementary code point
10.220 + * corresponding to this surrogate pair is returned. Otherwise,
10.221 + * the <code>char</code> value at the given index is returned.
10.222 + *
10.223 + * @param index the index to the <code>char</code> values
10.224 + * @return the code point value of the character at the
10.225 + * <code>index</code>
10.226 + * @exception IndexOutOfBoundsException if the <code>index</code>
10.227 + * argument is negative or not less than the length of this
10.228 + * sequence.
10.229 + */
10.230 + public int codePointAt(int index) {
10.231 + if ((index < 0) || (index >= count)) {
10.232 + throw new StringIndexOutOfBoundsException(index);
10.233 + }
10.234 + return Character.codePointAt(value, index);
10.235 + }
10.236 +
10.237 + /**
10.238 + * Returns the character (Unicode code point) before the specified
10.239 + * index. The index refers to <code>char</code> values
10.240 + * (Unicode code units) and ranges from <code>1</code> to {@link
10.241 + * #length()}.
10.242 + *
10.243 + * <p> If the <code>char</code> value at <code>(index - 1)</code>
10.244 + * is in the low-surrogate range, <code>(index - 2)</code> is not
10.245 + * negative, and the <code>char</code> value at <code>(index -
10.246 + * 2)</code> is in the high-surrogate range, then the
10.247 + * supplementary code point value of the surrogate pair is
10.248 + * returned. If the <code>char</code> value at <code>index -
10.249 + * 1</code> is an unpaired low-surrogate or a high-surrogate, the
10.250 + * surrogate value is returned.
10.251 + *
10.252 + * @param index the index following the code point that should be returned
10.253 + * @return the Unicode code point value before the given index.
10.254 + * @exception IndexOutOfBoundsException if the <code>index</code>
10.255 + * argument is less than 1 or greater than the length
10.256 + * of this sequence.
10.257 + */
10.258 + public int codePointBefore(int index) {
10.259 + int i = index - 1;
10.260 + if ((i < 0) || (i >= count)) {
10.261 + throw new StringIndexOutOfBoundsException(index);
10.262 + }
10.263 + return Character.codePointBefore(value, index);
10.264 + }
10.265 +
10.266 + /**
10.267 + * Returns the number of Unicode code points in the specified text
10.268 + * range of this sequence. The text range begins at the specified
10.269 + * <code>beginIndex</code> and extends to the <code>char</code> at
10.270 + * index <code>endIndex - 1</code>. Thus the length (in
10.271 + * <code>char</code>s) of the text range is
10.272 + * <code>endIndex-beginIndex</code>. Unpaired surrogates within
10.273 + * this sequence count as one code point each.
10.274 + *
10.275 + * @param beginIndex the index to the first <code>char</code> of
10.276 + * the text range.
10.277 + * @param endIndex the index after the last <code>char</code> of
10.278 + * the text range.
10.279 + * @return the number of Unicode code points in the specified text
10.280 + * range
10.281 + * @exception IndexOutOfBoundsException if the
10.282 + * <code>beginIndex</code> is negative, or <code>endIndex</code>
10.283 + * is larger than the length of this sequence, or
10.284 + * <code>beginIndex</code> is larger than <code>endIndex</code>.
10.285 + */
10.286 + public int codePointCount(int beginIndex, int endIndex) {
10.287 + if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) {
10.288 + throw new IndexOutOfBoundsException();
10.289 + }
10.290 + return Character.codePointCountImpl(value, beginIndex, endIndex-beginIndex);
10.291 + }
10.292 +
10.293 + /**
10.294 + * Returns the index within this sequence that is offset from the
10.295 + * given <code>index</code> by <code>codePointOffset</code> code
10.296 + * points. Unpaired surrogates within the text range given by
10.297 + * <code>index</code> and <code>codePointOffset</code> count as
10.298 + * one code point each.
10.299 + *
10.300 + * @param index the index to be offset
10.301 + * @param codePointOffset the offset in code points
10.302 + * @return the index within this sequence
10.303 + * @exception IndexOutOfBoundsException if <code>index</code>
10.304 + * is negative or larger then the length of this sequence,
10.305 + * or if <code>codePointOffset</code> is positive and the subsequence
10.306 + * starting with <code>index</code> has fewer than
10.307 + * <code>codePointOffset</code> code points,
10.308 + * or if <code>codePointOffset</code> is negative and the subsequence
10.309 + * before <code>index</code> has fewer than the absolute value of
10.310 + * <code>codePointOffset</code> code points.
10.311 + */
10.312 + public int offsetByCodePoints(int index, int codePointOffset) {
10.313 + if (index < 0 || index > count) {
10.314 + throw new IndexOutOfBoundsException();
10.315 + }
10.316 + return Character.offsetByCodePointsImpl(value, 0, count,
10.317 + index, codePointOffset);
10.318 + }
10.319 +
10.320 + /**
10.321 + * Characters are copied from this sequence into the
10.322 + * destination character array <code>dst</code>. The first character to
10.323 + * be copied is at index <code>srcBegin</code>; the last character to
10.324 + * be copied is at index <code>srcEnd-1</code>. The total number of
10.325 + * characters to be copied is <code>srcEnd-srcBegin</code>. The
10.326 + * characters are copied into the subarray of <code>dst</code> starting
10.327 + * at index <code>dstBegin</code> and ending at index:
10.328 + * <p><blockquote><pre>
10.329 + * dstbegin + (srcEnd-srcBegin) - 1
10.330 + * </pre></blockquote>
10.331 + *
10.332 + * @param srcBegin start copying at this offset.
10.333 + * @param srcEnd stop copying at this offset.
10.334 + * @param dst the array to copy the data into.
10.335 + * @param dstBegin offset into <code>dst</code>.
10.336 + * @throws NullPointerException if <code>dst</code> is
10.337 + * <code>null</code>.
10.338 + * @throws IndexOutOfBoundsException if any of the following is true:
10.339 + * <ul>
10.340 + * <li><code>srcBegin</code> is negative
10.341 + * <li><code>dstBegin</code> is negative
10.342 + * <li>the <code>srcBegin</code> argument is greater than
10.343 + * the <code>srcEnd</code> argument.
10.344 + * <li><code>srcEnd</code> is greater than
10.345 + * <code>this.length()</code>.
10.346 + * <li><code>dstBegin+srcEnd-srcBegin</code> is greater than
10.347 + * <code>dst.length</code>
10.348 + * </ul>
10.349 + */
10.350 + public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
10.351 + {
10.352 + if (srcBegin < 0)
10.353 + throw new StringIndexOutOfBoundsException(srcBegin);
10.354 + if ((srcEnd < 0) || (srcEnd > count))
10.355 + throw new StringIndexOutOfBoundsException(srcEnd);
10.356 + if (srcBegin > srcEnd)
10.357 + throw new StringIndexOutOfBoundsException("srcBegin > srcEnd");
10.358 + String.arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin);
10.359 + }
10.360 +
10.361 + /**
10.362 + * The character at the specified index is set to <code>ch</code>. This
10.363 + * sequence is altered to represent a new character sequence that is
10.364 + * identical to the old character sequence, except that it contains the
10.365 + * character <code>ch</code> at position <code>index</code>.
10.366 + * <p>
10.367 + * The index argument must be greater than or equal to
10.368 + * <code>0</code>, and less than the length of this sequence.
10.369 + *
10.370 + * @param index the index of the character to modify.
10.371 + * @param ch the new character.
10.372 + * @throws IndexOutOfBoundsException if <code>index</code> is
10.373 + * negative or greater than or equal to <code>length()</code>.
10.374 + */
10.375 + public void setCharAt(int index, char ch) {
10.376 + if ((index < 0) || (index >= count))
10.377 + throw new StringIndexOutOfBoundsException(index);
10.378 + value[index] = ch;
10.379 + }
10.380 +
10.381 + /**
10.382 + * Appends the string representation of the {@code Object} argument.
10.383 + * <p>
10.384 + * The overall effect is exactly as if the argument were converted
10.385 + * to a string by the method {@link String#valueOf(Object)},
10.386 + * and the characters of that string were then
10.387 + * {@link #append(String) appended} to this character sequence.
10.388 + *
10.389 + * @param obj an {@code Object}.
10.390 + * @return a reference to this object.
10.391 + */
10.392 + public AbstractStringBuilder append(Object obj) {
10.393 + return append(String.valueOf(obj));
10.394 + }
10.395 +
10.396 + /**
10.397 + * Appends the specified string to this character sequence.
10.398 + * <p>
10.399 + * The characters of the {@code String} argument are appended, in
10.400 + * order, increasing the length of this sequence by the length of the
10.401 + * argument. If {@code str} is {@code null}, then the four
10.402 + * characters {@code "null"} are appended.
10.403 + * <p>
10.404 + * Let <i>n</i> be the length of this character sequence just prior to
10.405 + * execution of the {@code append} method. Then the character at
10.406 + * index <i>k</i> in the new character sequence is equal to the character
10.407 + * at index <i>k</i> in the old character sequence, if <i>k</i> is less
10.408 + * than <i>n</i>; otherwise, it is equal to the character at index
10.409 + * <i>k-n</i> in the argument {@code str}.
10.410 + *
10.411 + * @param str a string.
10.412 + * @return a reference to this object.
10.413 + */
10.414 + public AbstractStringBuilder append(String str) {
10.415 + if (str == null) str = "null";
10.416 + int len = str.length();
10.417 + ensureCapacityInternal(count + len);
10.418 + str.getChars(0, len, value, count);
10.419 + count += len;
10.420 + return this;
10.421 + }
10.422 +
10.423 + // Documentation in subclasses because of synchro difference
10.424 + public AbstractStringBuilder append(StringBuffer sb) {
10.425 + if (sb == null)
10.426 + return append("null");
10.427 + int len = sb.length();
10.428 + ensureCapacityInternal(count + len);
10.429 + sb.getChars(0, len, value, count);
10.430 + count += len;
10.431 + return this;
10.432 + }
10.433 +
10.434 + // Documentation in subclasses because of synchro difference
10.435 + public AbstractStringBuilder append(CharSequence s) {
10.436 + if (s == null)
10.437 + s = "null";
10.438 + if (s instanceof String)
10.439 + return this.append((String)s);
10.440 + if (s instanceof StringBuffer)
10.441 + return this.append((StringBuffer)s);
10.442 + return this.append(s, 0, s.length());
10.443 + }
10.444 +
10.445 + /**
10.446 + * Appends a subsequence of the specified {@code CharSequence} to this
10.447 + * sequence.
10.448 + * <p>
10.449 + * Characters of the argument {@code s}, starting at
10.450 + * index {@code start}, are appended, in order, to the contents of
10.451 + * this sequence up to the (exclusive) index {@code end}. The length
10.452 + * of this sequence is increased by the value of {@code end - start}.
10.453 + * <p>
10.454 + * Let <i>n</i> be the length of this character sequence just prior to
10.455 + * execution of the {@code append} method. Then the character at
10.456 + * index <i>k</i> in this character sequence becomes equal to the
10.457 + * character at index <i>k</i> in this sequence, if <i>k</i> is less than
10.458 + * <i>n</i>; otherwise, it is equal to the character at index
10.459 + * <i>k+start-n</i> in the argument {@code s}.
10.460 + * <p>
10.461 + * If {@code s} is {@code null}, then this method appends
10.462 + * characters as if the s parameter was a sequence containing the four
10.463 + * characters {@code "null"}.
10.464 + *
10.465 + * @param s the sequence to append.
10.466 + * @param start the starting index of the subsequence to be appended.
10.467 + * @param end the end index of the subsequence to be appended.
10.468 + * @return a reference to this object.
10.469 + * @throws IndexOutOfBoundsException if
10.470 + * {@code start} is negative, or
10.471 + * {@code start} is greater than {@code end} or
10.472 + * {@code end} is greater than {@code s.length()}
10.473 + */
10.474 + public AbstractStringBuilder append(CharSequence s, int start, int end) {
10.475 + if (s == null)
10.476 + s = "null";
10.477 + if ((start < 0) || (start > end) || (end > s.length()))
10.478 + throw new IndexOutOfBoundsException(
10.479 + "start " + start + ", end " + end + ", s.length() "
10.480 + + s.length());
10.481 + int len = end - start;
10.482 + ensureCapacityInternal(count + len);
10.483 + for (int i = start, j = count; i < end; i++, j++)
10.484 + value[j] = s.charAt(i);
10.485 + count += len;
10.486 + return this;
10.487 + }
10.488 +
10.489 + /**
10.490 + * Appends the string representation of the {@code char} array
10.491 + * argument to this sequence.
10.492 + * <p>
10.493 + * The characters of the array argument are appended, in order, to
10.494 + * the contents of this sequence. The length of this sequence
10.495 + * increases by the length of the argument.
10.496 + * <p>
10.497 + * The overall effect is exactly as if the argument were converted
10.498 + * to a string by the method {@link String#valueOf(char[])},
10.499 + * and the characters of that string were then
10.500 + * {@link #append(String) appended} to this character sequence.
10.501 + *
10.502 + * @param str the characters to be appended.
10.503 + * @return a reference to this object.
10.504 + */
10.505 + public AbstractStringBuilder append(char[] str) {
10.506 + int len = str.length;
10.507 + ensureCapacityInternal(count + len);
10.508 + String.arraycopy(str, 0, value, count, len);
10.509 + count += len;
10.510 + return this;
10.511 + }
10.512 +
10.513 + /**
10.514 + * Appends the string representation of a subarray of the
10.515 + * {@code char} array argument to this sequence.
10.516 + * <p>
10.517 + * Characters of the {@code char} array {@code str}, starting at
10.518 + * index {@code offset}, are appended, in order, to the contents
10.519 + * of this sequence. The length of this sequence increases
10.520 + * by the value of {@code len}.
10.521 + * <p>
10.522 + * The overall effect is exactly as if the arguments were converted
10.523 + * to a string by the method {@link String#valueOf(char[],int,int)},
10.524 + * and the characters of that string were then
10.525 + * {@link #append(String) appended} to this character sequence.
10.526 + *
10.527 + * @param str the characters to be appended.
10.528 + * @param offset the index of the first {@code char} to append.
10.529 + * @param len the number of {@code char}s to append.
10.530 + * @return a reference to this object.
10.531 + * @throws IndexOutOfBoundsException
10.532 + * if {@code offset < 0} or {@code len < 0}
10.533 + * or {@code offset+len > str.length}
10.534 + */
10.535 + public AbstractStringBuilder append(char str[], int offset, int len) {
10.536 + if (len > 0) // let arraycopy report AIOOBE for len < 0
10.537 + ensureCapacityInternal(count + len);
10.538 + String.arraycopy(str, offset, value, count, len);
10.539 + count += len;
10.540 + return this;
10.541 + }
10.542 +
10.543 + /**
10.544 + * Appends the string representation of the {@code boolean}
10.545 + * argument to the sequence.
10.546 + * <p>
10.547 + * The overall effect is exactly as if the argument were converted
10.548 + * to a string by the method {@link String#valueOf(boolean)},
10.549 + * and the characters of that string were then
10.550 + * {@link #append(String) appended} to this character sequence.
10.551 + *
10.552 + * @param b a {@code boolean}.
10.553 + * @return a reference to this object.
10.554 + */
10.555 + public AbstractStringBuilder append(boolean b) {
10.556 + if (b) {
10.557 + ensureCapacityInternal(count + 4);
10.558 + value[count++] = 't';
10.559 + value[count++] = 'r';
10.560 + value[count++] = 'u';
10.561 + value[count++] = 'e';
10.562 + } else {
10.563 + ensureCapacityInternal(count + 5);
10.564 + value[count++] = 'f';
10.565 + value[count++] = 'a';
10.566 + value[count++] = 'l';
10.567 + value[count++] = 's';
10.568 + value[count++] = 'e';
10.569 + }
10.570 + return this;
10.571 + }
10.572 +
10.573 + /**
10.574 + * Appends the string representation of the {@code char}
10.575 + * argument to this sequence.
10.576 + * <p>
10.577 + * The argument is appended to the contents of this sequence.
10.578 + * The length of this sequence increases by {@code 1}.
10.579 + * <p>
10.580 + * The overall effect is exactly as if the argument were converted
10.581 + * to a string by the method {@link String#valueOf(char)},
10.582 + * and the character in that string were then
10.583 + * {@link #append(String) appended} to this character sequence.
10.584 + *
10.585 + * @param c a {@code char}.
10.586 + * @return a reference to this object.
10.587 + */
10.588 + public AbstractStringBuilder append(char c) {
10.589 + ensureCapacityInternal(count + 1);
10.590 + value[count++] = c;
10.591 + return this;
10.592 + }
10.593 +
10.594 + /**
10.595 + * Appends the string representation of the {@code int}
10.596 + * argument to this sequence.
10.597 + * <p>
10.598 + * The overall effect is exactly as if the argument were converted
10.599 + * to a string by the method {@link String#valueOf(int)},
10.600 + * and the characters of that string were then
10.601 + * {@link #append(String) appended} to this character sequence.
10.602 + *
10.603 + * @param i an {@code int}.
10.604 + * @return a reference to this object.
10.605 + */
10.606 + @JavaScriptBody(
10.607 + args={ "self", "i" },
10.608 + body="return java_lang_AbstractStringBuilder_appendLjava_lang_AbstractStringBuilderLjava_lang_String(self,i.toString());"
10.609 + )
10.610 + public AbstractStringBuilder append(int i) {
10.611 + if (i == Integer.MIN_VALUE) {
10.612 + append("-2147483648");
10.613 + return this;
10.614 + }
10.615 + int appendedLength = (i < 0) ? Integer.stringSize(-i) + 1
10.616 + : Integer.stringSize(i);
10.617 + int spaceNeeded = count + appendedLength;
10.618 + ensureCapacityInternal(spaceNeeded);
10.619 + Integer.getChars(i, spaceNeeded, value);
10.620 + count = spaceNeeded;
10.621 + return this;
10.622 + }
10.623 +
10.624 + /**
10.625 + * Appends the string representation of the {@code long}
10.626 + * argument to this sequence.
10.627 + * <p>
10.628 + * The overall effect is exactly as if the argument were converted
10.629 + * to a string by the method {@link String#valueOf(long)},
10.630 + * and the characters of that string were then
10.631 + * {@link #append(String) appended} to this character sequence.
10.632 + *
10.633 + * @param l a {@code long}.
10.634 + * @return a reference to this object.
10.635 + */
10.636 + public AbstractStringBuilder append(long l) {
10.637 + if (l == Long.MIN_VALUE) {
10.638 + append("-9223372036854775808");
10.639 + return this;
10.640 + }
10.641 + int appendedLength = (l < 0) ? Long.stringSize(-l) + 1
10.642 + : Long.stringSize(l);
10.643 + int spaceNeeded = count + appendedLength;
10.644 + ensureCapacityInternal(spaceNeeded);
10.645 + Long.getChars(l, spaceNeeded, value);
10.646 + count = spaceNeeded;
10.647 + return this;
10.648 + }
10.649 +
10.650 + /**
10.651 + * Appends the string representation of the {@code float}
10.652 + * argument to this sequence.
10.653 + * <p>
10.654 + * The overall effect is exactly as if the argument were converted
10.655 + * to a string by the method {@link String#valueOf(float)},
10.656 + * and the characters of that string were then
10.657 + * {@link #append(String) appended} to this character sequence.
10.658 + *
10.659 + * @param f a {@code float}.
10.660 + * @return a reference to this object.
10.661 + */
10.662 + public AbstractStringBuilder append(float f) {
10.663 + throw new UnsupportedOperationException();
10.664 + }
10.665 +
10.666 + /**
10.667 + * Appends the string representation of the {@code double}
10.668 + * argument to this sequence.
10.669 + * <p>
10.670 + * The overall effect is exactly as if the argument were converted
10.671 + * to a string by the method {@link String#valueOf(double)},
10.672 + * and the characters of that string were then
10.673 + * {@link #append(String) appended} to this character sequence.
10.674 + *
10.675 + * @param d a {@code double}.
10.676 + * @return a reference to this object.
10.677 + */
10.678 + public AbstractStringBuilder append(double d) {
10.679 + throw new UnsupportedOperationException();
10.680 + }
10.681 +
10.682 + /**
10.683 + * Removes the characters in a substring of this sequence.
10.684 + * The substring begins at the specified {@code start} and extends to
10.685 + * the character at index {@code end - 1} or to the end of the
10.686 + * sequence if no such character exists. If
10.687 + * {@code start} is equal to {@code end}, no changes are made.
10.688 + *
10.689 + * @param start The beginning index, inclusive.
10.690 + * @param end The ending index, exclusive.
10.691 + * @return This object.
10.692 + * @throws StringIndexOutOfBoundsException if {@code start}
10.693 + * is negative, greater than {@code length()}, or
10.694 + * greater than {@code end}.
10.695 + */
10.696 + public AbstractStringBuilder delete(int start, int end) {
10.697 + if (start < 0)
10.698 + throw new StringIndexOutOfBoundsException(start);
10.699 + if (end > count)
10.700 + end = count;
10.701 + if (start > end)
10.702 + throw new StringIndexOutOfBoundsException();
10.703 + int len = end - start;
10.704 + if (len > 0) {
10.705 + String.arraycopy(value, start+len, value, start, count-end);
10.706 + count -= len;
10.707 + }
10.708 + return this;
10.709 + }
10.710 +
10.711 + /**
10.712 + * Appends the string representation of the {@code codePoint}
10.713 + * argument to this sequence.
10.714 + *
10.715 + * <p> The argument is appended to the contents of this sequence.
10.716 + * The length of this sequence increases by
10.717 + * {@link Character#charCount(int) Character.charCount(codePoint)}.
10.718 + *
10.719 + * <p> The overall effect is exactly as if the argument were
10.720 + * converted to a {@code char} array by the method
10.721 + * {@link Character#toChars(int)} and the character in that array
10.722 + * were then {@link #append(char[]) appended} to this character
10.723 + * sequence.
10.724 + *
10.725 + * @param codePoint a Unicode code point
10.726 + * @return a reference to this object.
10.727 + * @exception IllegalArgumentException if the specified
10.728 + * {@code codePoint} isn't a valid Unicode code point
10.729 + */
10.730 + public AbstractStringBuilder appendCodePoint(int codePoint) {
10.731 + final int count = this.count;
10.732 +
10.733 + if (Character.isBmpCodePoint(codePoint)) {
10.734 + ensureCapacityInternal(count + 1);
10.735 + value[count] = (char) codePoint;
10.736 + this.count = count + 1;
10.737 + } else if (Character.isValidCodePoint(codePoint)) {
10.738 + ensureCapacityInternal(count + 2);
10.739 + Character.toSurrogates(codePoint, value, count);
10.740 + this.count = count + 2;
10.741 + } else {
10.742 + throw new IllegalArgumentException();
10.743 + }
10.744 + return this;
10.745 + }
10.746 +
10.747 + /**
10.748 + * Removes the <code>char</code> at the specified position in this
10.749 + * sequence. This sequence is shortened by one <code>char</code>.
10.750 + *
10.751 + * <p>Note: If the character at the given index is a supplementary
10.752 + * character, this method does not remove the entire character. If
10.753 + * correct handling of supplementary characters is required,
10.754 + * determine the number of <code>char</code>s to remove by calling
10.755 + * <code>Character.charCount(thisSequence.codePointAt(index))</code>,
10.756 + * where <code>thisSequence</code> is this sequence.
10.757 + *
10.758 + * @param index Index of <code>char</code> to remove
10.759 + * @return This object.
10.760 + * @throws StringIndexOutOfBoundsException if the <code>index</code>
10.761 + * is negative or greater than or equal to
10.762 + * <code>length()</code>.
10.763 + */
10.764 + public AbstractStringBuilder deleteCharAt(int index) {
10.765 + if ((index < 0) || (index >= count))
10.766 + throw new StringIndexOutOfBoundsException(index);
10.767 + String.arraycopy(value, index+1, value, index, count-index-1);
10.768 + count--;
10.769 + return this;
10.770 + }
10.771 +
10.772 + /**
10.773 + * Replaces the characters in a substring of this sequence
10.774 + * with characters in the specified <code>String</code>. The substring
10.775 + * begins at the specified <code>start</code> and extends to the character
10.776 + * at index <code>end - 1</code> or to the end of the
10.777 + * sequence if no such character exists. First the
10.778 + * characters in the substring are removed and then the specified
10.779 + * <code>String</code> is inserted at <code>start</code>. (This
10.780 + * sequence will be lengthened to accommodate the
10.781 + * specified String if necessary.)
10.782 + *
10.783 + * @param start The beginning index, inclusive.
10.784 + * @param end The ending index, exclusive.
10.785 + * @param str String that will replace previous contents.
10.786 + * @return This object.
10.787 + * @throws StringIndexOutOfBoundsException if <code>start</code>
10.788 + * is negative, greater than <code>length()</code>, or
10.789 + * greater than <code>end</code>.
10.790 + */
10.791 + public AbstractStringBuilder replace(int start, int end, String str) {
10.792 + if (start < 0)
10.793 + throw new StringIndexOutOfBoundsException(start);
10.794 + if (start > count)
10.795 + throw new StringIndexOutOfBoundsException("start > length()");
10.796 + if (start > end)
10.797 + throw new StringIndexOutOfBoundsException("start > end");
10.798 +
10.799 + if (end > count)
10.800 + end = count;
10.801 + int len = str.length();
10.802 + int newCount = count + len - (end - start);
10.803 + ensureCapacityInternal(newCount);
10.804 +
10.805 + String.arraycopy(value, end, value, start + len, count - end);
10.806 + str.getChars(value, start);
10.807 + count = newCount;
10.808 + return this;
10.809 + }
10.810 +
10.811 + /**
10.812 + * Returns a new <code>String</code> that contains a subsequence of
10.813 + * characters currently contained in this character sequence. The
10.814 + * substring begins at the specified index and extends to the end of
10.815 + * this sequence.
10.816 + *
10.817 + * @param start The beginning index, inclusive.
10.818 + * @return The new string.
10.819 + * @throws StringIndexOutOfBoundsException if <code>start</code> is
10.820 + * less than zero, or greater than the length of this object.
10.821 + */
10.822 + public String substring(int start) {
10.823 + return substring(start, count);
10.824 + }
10.825 +
10.826 + /**
10.827 + * Returns a new character sequence that is a subsequence of this sequence.
10.828 + *
10.829 + * <p> An invocation of this method of the form
10.830 + *
10.831 + * <blockquote><pre>
10.832 + * sb.subSequence(begin, end)</pre></blockquote>
10.833 + *
10.834 + * behaves in exactly the same way as the invocation
10.835 + *
10.836 + * <blockquote><pre>
10.837 + * sb.substring(begin, end)</pre></blockquote>
10.838 + *
10.839 + * This method is provided so that this class can
10.840 + * implement the {@link CharSequence} interface. </p>
10.841 + *
10.842 + * @param start the start index, inclusive.
10.843 + * @param end the end index, exclusive.
10.844 + * @return the specified subsequence.
10.845 + *
10.846 + * @throws IndexOutOfBoundsException
10.847 + * if <tt>start</tt> or <tt>end</tt> are negative,
10.848 + * if <tt>end</tt> is greater than <tt>length()</tt>,
10.849 + * or if <tt>start</tt> is greater than <tt>end</tt>
10.850 + * @spec JSR-51
10.851 + */
10.852 + public CharSequence subSequence(int start, int end) {
10.853 + return substring(start, end);
10.854 + }
10.855 +
10.856 + /**
10.857 + * Returns a new <code>String</code> that contains a subsequence of
10.858 + * characters currently contained in this sequence. The
10.859 + * substring begins at the specified <code>start</code> and
10.860 + * extends to the character at index <code>end - 1</code>.
10.861 + *
10.862 + * @param start The beginning index, inclusive.
10.863 + * @param end The ending index, exclusive.
10.864 + * @return The new string.
10.865 + * @throws StringIndexOutOfBoundsException if <code>start</code>
10.866 + * or <code>end</code> are negative or greater than
10.867 + * <code>length()</code>, or <code>start</code> is
10.868 + * greater than <code>end</code>.
10.869 + */
10.870 + public String substring(int start, int end) {
10.871 + if (start < 0)
10.872 + throw new StringIndexOutOfBoundsException(start);
10.873 + if (end > count)
10.874 + throw new StringIndexOutOfBoundsException(end);
10.875 + if (start > end)
10.876 + throw new StringIndexOutOfBoundsException(end - start);
10.877 + return new String(value, start, end - start);
10.878 + }
10.879 +
10.880 + /**
10.881 + * Inserts the string representation of a subarray of the {@code str}
10.882 + * array argument into this sequence. The subarray begins at the
10.883 + * specified {@code offset} and extends {@code len} {@code char}s.
10.884 + * The characters of the subarray are inserted into this sequence at
10.885 + * the position indicated by {@code index}. The length of this
10.886 + * sequence increases by {@code len} {@code char}s.
10.887 + *
10.888 + * @param index position at which to insert subarray.
10.889 + * @param str A {@code char} array.
10.890 + * @param offset the index of the first {@code char} in subarray to
10.891 + * be inserted.
10.892 + * @param len the number of {@code char}s in the subarray to
10.893 + * be inserted.
10.894 + * @return This object
10.895 + * @throws StringIndexOutOfBoundsException if {@code index}
10.896 + * is negative or greater than {@code length()}, or
10.897 + * {@code offset} or {@code len} are negative, or
10.898 + * {@code (offset+len)} is greater than
10.899 + * {@code str.length}.
10.900 + */
10.901 + public AbstractStringBuilder insert(int index, char[] str, int offset,
10.902 + int len)
10.903 + {
10.904 + if ((index < 0) || (index > length()))
10.905 + throw new StringIndexOutOfBoundsException(index);
10.906 + if ((offset < 0) || (len < 0) || (offset > str.length - len))
10.907 + throw new StringIndexOutOfBoundsException(
10.908 + "offset " + offset + ", len " + len + ", str.length "
10.909 + + str.length);
10.910 + ensureCapacityInternal(count + len);
10.911 + String.arraycopy(value, index, value, index + len, count - index);
10.912 + String.arraycopy(str, offset, value, index, len);
10.913 + count += len;
10.914 + return this;
10.915 + }
10.916 +
10.917 + /**
10.918 + * Inserts the string representation of the {@code Object}
10.919 + * argument into this character sequence.
10.920 + * <p>
10.921 + * The overall effect is exactly as if the second argument were
10.922 + * converted to a string by the method {@link String#valueOf(Object)},
10.923 + * and the characters of that string were then
10.924 + * {@link #insert(int,String) inserted} into this character
10.925 + * sequence at the indicated offset.
10.926 + * <p>
10.927 + * The {@code offset} argument must be greater than or equal to
10.928 + * {@code 0}, and less than or equal to the {@linkplain #length() length}
10.929 + * of this sequence.
10.930 + *
10.931 + * @param offset the offset.
10.932 + * @param obj an {@code Object}.
10.933 + * @return a reference to this object.
10.934 + * @throws StringIndexOutOfBoundsException if the offset is invalid.
10.935 + */
10.936 + public AbstractStringBuilder insert(int offset, Object obj) {
10.937 + return insert(offset, String.valueOf(obj));
10.938 + }
10.939 +
10.940 + /**
10.941 + * Inserts the string into this character sequence.
10.942 + * <p>
10.943 + * The characters of the {@code String} argument are inserted, in
10.944 + * order, into this sequence at the indicated offset, moving up any
10.945 + * characters originally above that position and increasing the length
10.946 + * of this sequence by the length of the argument. If
10.947 + * {@code str} is {@code null}, then the four characters
10.948 + * {@code "null"} are inserted into this sequence.
10.949 + * <p>
10.950 + * The character at index <i>k</i> in the new character sequence is
10.951 + * equal to:
10.952 + * <ul>
10.953 + * <li>the character at index <i>k</i> in the old character sequence, if
10.954 + * <i>k</i> is less than {@code offset}
10.955 + * <li>the character at index <i>k</i>{@code -offset} in the
10.956 + * argument {@code str}, if <i>k</i> is not less than
10.957 + * {@code offset} but is less than {@code offset+str.length()}
10.958 + * <li>the character at index <i>k</i>{@code -str.length()} in the
10.959 + * old character sequence, if <i>k</i> is not less than
10.960 + * {@code offset+str.length()}
10.961 + * </ul><p>
10.962 + * The {@code offset} argument must be greater than or equal to
10.963 + * {@code 0}, and less than or equal to the {@linkplain #length() length}
10.964 + * of this sequence.
10.965 + *
10.966 + * @param offset the offset.
10.967 + * @param str a string.
10.968 + * @return a reference to this object.
10.969 + * @throws StringIndexOutOfBoundsException if the offset is invalid.
10.970 + */
10.971 + public AbstractStringBuilder insert(int offset, String str) {
10.972 + if ((offset < 0) || (offset > length()))
10.973 + throw new StringIndexOutOfBoundsException(offset);
10.974 + if (str == null)
10.975 + str = "null";
10.976 + int len = str.length();
10.977 + ensureCapacityInternal(count + len);
10.978 + String.arraycopy(value, offset, value, offset + len, count - offset);
10.979 + str.getChars(value, offset);
10.980 + count += len;
10.981 + return this;
10.982 + }
10.983 +
10.984 + /**
10.985 + * Inserts the string representation of the {@code char} array
10.986 + * argument into this sequence.
10.987 + * <p>
10.988 + * The characters of the array argument are inserted into the
10.989 + * contents of this sequence at the position indicated by
10.990 + * {@code offset}. The length of this sequence increases by
10.991 + * the length of the argument.
10.992 + * <p>
10.993 + * The overall effect is exactly as if the second argument were
10.994 + * converted to a string by the method {@link String#valueOf(char[])},
10.995 + * and the characters of that string were then
10.996 + * {@link #insert(int,String) inserted} into this character
10.997 + * sequence at the indicated offset.
10.998 + * <p>
10.999 + * The {@code offset} argument must be greater than or equal to
10.1000 + * {@code 0}, and less than or equal to the {@linkplain #length() length}
10.1001 + * of this sequence.
10.1002 + *
10.1003 + * @param offset the offset.
10.1004 + * @param str a character array.
10.1005 + * @return a reference to this object.
10.1006 + * @throws StringIndexOutOfBoundsException if the offset is invalid.
10.1007 + */
10.1008 + public AbstractStringBuilder insert(int offset, char[] str) {
10.1009 + if ((offset < 0) || (offset > length()))
10.1010 + throw new StringIndexOutOfBoundsException(offset);
10.1011 + int len = str.length;
10.1012 + ensureCapacityInternal(count + len);
10.1013 + String.arraycopy(value, offset, value, offset + len, count - offset);
10.1014 + String.arraycopy(str, 0, value, offset, len);
10.1015 + count += len;
10.1016 + return this;
10.1017 + }
10.1018 +
10.1019 + /**
10.1020 + * Inserts the specified {@code CharSequence} into this sequence.
10.1021 + * <p>
10.1022 + * The characters of the {@code CharSequence} argument are inserted,
10.1023 + * in order, into this sequence at the indicated offset, moving up
10.1024 + * any characters originally above that position and increasing the length
10.1025 + * of this sequence by the length of the argument s.
10.1026 + * <p>
10.1027 + * The result of this method is exactly the same as if it were an
10.1028 + * invocation of this object's
10.1029 + * {@link #insert(int,CharSequence,int,int) insert}(dstOffset, s, 0, s.length())
10.1030 + * method.
10.1031 + *
10.1032 + * <p>If {@code s} is {@code null}, then the four characters
10.1033 + * {@code "null"} are inserted into this sequence.
10.1034 + *
10.1035 + * @param dstOffset the offset.
10.1036 + * @param s the sequence to be inserted
10.1037 + * @return a reference to this object.
10.1038 + * @throws IndexOutOfBoundsException if the offset is invalid.
10.1039 + */
10.1040 + public AbstractStringBuilder insert(int dstOffset, CharSequence s) {
10.1041 + if (s == null)
10.1042 + s = "null";
10.1043 + if (s instanceof String)
10.1044 + return this.insert(dstOffset, (String)s);
10.1045 + return this.insert(dstOffset, s, 0, s.length());
10.1046 + }
10.1047 +
10.1048 + /**
10.1049 + * Inserts a subsequence of the specified {@code CharSequence} into
10.1050 + * this sequence.
10.1051 + * <p>
10.1052 + * The subsequence of the argument {@code s} specified by
10.1053 + * {@code start} and {@code end} are inserted,
10.1054 + * in order, into this sequence at the specified destination offset, moving
10.1055 + * up any characters originally above that position. The length of this
10.1056 + * sequence is increased by {@code end - start}.
10.1057 + * <p>
10.1058 + * The character at index <i>k</i> in this sequence becomes equal to:
10.1059 + * <ul>
10.1060 + * <li>the character at index <i>k</i> in this sequence, if
10.1061 + * <i>k</i> is less than {@code dstOffset}
10.1062 + * <li>the character at index <i>k</i>{@code +start-dstOffset} in
10.1063 + * the argument {@code s}, if <i>k</i> is greater than or equal to
10.1064 + * {@code dstOffset} but is less than {@code dstOffset+end-start}
10.1065 + * <li>the character at index <i>k</i>{@code -(end-start)} in this
10.1066 + * sequence, if <i>k</i> is greater than or equal to
10.1067 + * {@code dstOffset+end-start}
10.1068 + * </ul><p>
10.1069 + * The {@code dstOffset} argument must be greater than or equal to
10.1070 + * {@code 0}, and less than or equal to the {@linkplain #length() length}
10.1071 + * of this sequence.
10.1072 + * <p>The start argument must be nonnegative, and not greater than
10.1073 + * {@code end}.
10.1074 + * <p>The end argument must be greater than or equal to
10.1075 + * {@code start}, and less than or equal to the length of s.
10.1076 + *
10.1077 + * <p>If {@code s} is {@code null}, then this method inserts
10.1078 + * characters as if the s parameter was a sequence containing the four
10.1079 + * characters {@code "null"}.
10.1080 + *
10.1081 + * @param dstOffset the offset in this sequence.
10.1082 + * @param s the sequence to be inserted.
10.1083 + * @param start the starting index of the subsequence to be inserted.
10.1084 + * @param end the end index of the subsequence to be inserted.
10.1085 + * @return a reference to this object.
10.1086 + * @throws IndexOutOfBoundsException if {@code dstOffset}
10.1087 + * is negative or greater than {@code this.length()}, or
10.1088 + * {@code start} or {@code end} are negative, or
10.1089 + * {@code start} is greater than {@code end} or
10.1090 + * {@code end} is greater than {@code s.length()}
10.1091 + */
10.1092 + public AbstractStringBuilder insert(int dstOffset, CharSequence s,
10.1093 + int start, int end) {
10.1094 + if (s == null)
10.1095 + s = "null";
10.1096 + if ((dstOffset < 0) || (dstOffset > this.length()))
10.1097 + throw new IndexOutOfBoundsException("dstOffset "+dstOffset);
10.1098 + if ((start < 0) || (end < 0) || (start > end) || (end > s.length()))
10.1099 + throw new IndexOutOfBoundsException(
10.1100 + "start " + start + ", end " + end + ", s.length() "
10.1101 + + s.length());
10.1102 + int len = end - start;
10.1103 + ensureCapacityInternal(count + len);
10.1104 + String.arraycopy(value, dstOffset, value, dstOffset + len,
10.1105 + count - dstOffset);
10.1106 + for (int i=start; i<end; i++)
10.1107 + value[dstOffset++] = s.charAt(i);
10.1108 + count += len;
10.1109 + return this;
10.1110 + }
10.1111 +
10.1112 + /**
10.1113 + * Inserts the string representation of the {@code boolean}
10.1114 + * argument into this sequence.
10.1115 + * <p>
10.1116 + * The overall effect is exactly as if the second argument were
10.1117 + * converted to a string by the method {@link String#valueOf(boolean)},
10.1118 + * and the characters of that string were then
10.1119 + * {@link #insert(int,String) inserted} into this character
10.1120 + * sequence at the indicated offset.
10.1121 + * <p>
10.1122 + * The {@code offset} argument must be greater than or equal to
10.1123 + * {@code 0}, and less than or equal to the {@linkplain #length() length}
10.1124 + * of this sequence.
10.1125 + *
10.1126 + * @param offset the offset.
10.1127 + * @param b a {@code boolean}.
10.1128 + * @return a reference to this object.
10.1129 + * @throws StringIndexOutOfBoundsException if the offset is invalid.
10.1130 + */
10.1131 + public AbstractStringBuilder insert(int offset, boolean b) {
10.1132 + return insert(offset, String.valueOf(b));
10.1133 + }
10.1134 +
10.1135 + /**
10.1136 + * Inserts the string representation of the {@code char}
10.1137 + * argument into this sequence.
10.1138 + * <p>
10.1139 + * The overall effect is exactly as if the second argument were
10.1140 + * converted to a string by the method {@link String#valueOf(char)},
10.1141 + * and the character in that string were then
10.1142 + * {@link #insert(int,String) inserted} into this character
10.1143 + * sequence at the indicated offset.
10.1144 + * <p>
10.1145 + * The {@code offset} argument must be greater than or equal to
10.1146 + * {@code 0}, and less than or equal to the {@linkplain #length() length}
10.1147 + * of this sequence.
10.1148 + *
10.1149 + * @param offset the offset.
10.1150 + * @param c a {@code char}.
10.1151 + * @return a reference to this object.
10.1152 + * @throws IndexOutOfBoundsException if the offset is invalid.
10.1153 + */
10.1154 + public AbstractStringBuilder insert(int offset, char c) {
10.1155 + ensureCapacityInternal(count + 1);
10.1156 + String.arraycopy(value, offset, value, offset + 1, count - offset);
10.1157 + value[offset] = c;
10.1158 + count += 1;
10.1159 + return this;
10.1160 + }
10.1161 +
10.1162 + /**
10.1163 + * Inserts the string representation of the second {@code int}
10.1164 + * argument into this sequence.
10.1165 + * <p>
10.1166 + * The overall effect is exactly as if the second argument were
10.1167 + * converted to a string by the method {@link String#valueOf(int)},
10.1168 + * and the characters of that string were then
10.1169 + * {@link #insert(int,String) inserted} into this character
10.1170 + * sequence at the indicated offset.
10.1171 + * <p>
10.1172 + * The {@code offset} argument must be greater than or equal to
10.1173 + * {@code 0}, and less than or equal to the {@linkplain #length() length}
10.1174 + * of this sequence.
10.1175 + *
10.1176 + * @param offset the offset.
10.1177 + * @param i an {@code int}.
10.1178 + * @return a reference to this object.
10.1179 + * @throws StringIndexOutOfBoundsException if the offset is invalid.
10.1180 + */
10.1181 + public AbstractStringBuilder insert(int offset, int i) {
10.1182 + return insert(offset, String.valueOf(i));
10.1183 + }
10.1184 +
10.1185 + /**
10.1186 + * Inserts the string representation of the {@code long}
10.1187 + * argument into this sequence.
10.1188 + * <p>
10.1189 + * The overall effect is exactly as if the second argument were
10.1190 + * converted to a string by the method {@link String#valueOf(long)},
10.1191 + * and the characters of that string were then
10.1192 + * {@link #insert(int,String) inserted} into this character
10.1193 + * sequence at the indicated offset.
10.1194 + * <p>
10.1195 + * The {@code offset} argument must be greater than or equal to
10.1196 + * {@code 0}, and less than or equal to the {@linkplain #length() length}
10.1197 + * of this sequence.
10.1198 + *
10.1199 + * @param offset the offset.
10.1200 + * @param l a {@code long}.
10.1201 + * @return a reference to this object.
10.1202 + * @throws StringIndexOutOfBoundsException if the offset is invalid.
10.1203 + */
10.1204 + public AbstractStringBuilder insert(int offset, long l) {
10.1205 + return insert(offset, String.valueOf(l));
10.1206 + }
10.1207 +
10.1208 + /**
10.1209 + * Inserts the string representation of the {@code float}
10.1210 + * argument into this sequence.
10.1211 + * <p>
10.1212 + * The overall effect is exactly as if the second argument were
10.1213 + * converted to a string by the method {@link String#valueOf(float)},
10.1214 + * and the characters of that string were then
10.1215 + * {@link #insert(int,String) inserted} into this character
10.1216 + * sequence at the indicated offset.
10.1217 + * <p>
10.1218 + * The {@code offset} argument must be greater than or equal to
10.1219 + * {@code 0}, and less than or equal to the {@linkplain #length() length}
10.1220 + * of this sequence.
10.1221 + *
10.1222 + * @param offset the offset.
10.1223 + * @param f a {@code float}.
10.1224 + * @return a reference to this object.
10.1225 + * @throws StringIndexOutOfBoundsException if the offset is invalid.
10.1226 + */
10.1227 + public AbstractStringBuilder insert(int offset, float f) {
10.1228 + return insert(offset, String.valueOf(f));
10.1229 + }
10.1230 +
10.1231 + /**
10.1232 + * Inserts the string representation of the {@code double}
10.1233 + * argument into this sequence.
10.1234 + * <p>
10.1235 + * The overall effect is exactly as if the second argument were
10.1236 + * converted to a string by the method {@link String#valueOf(double)},
10.1237 + * and the characters of that string were then
10.1238 + * {@link #insert(int,String) inserted} into this character
10.1239 + * sequence at the indicated offset.
10.1240 + * <p>
10.1241 + * The {@code offset} argument must be greater than or equal to
10.1242 + * {@code 0}, and less than or equal to the {@linkplain #length() length}
10.1243 + * of this sequence.
10.1244 + *
10.1245 + * @param offset the offset.
10.1246 + * @param d a {@code double}.
10.1247 + * @return a reference to this object.
10.1248 + * @throws StringIndexOutOfBoundsException if the offset is invalid.
10.1249 + */
10.1250 + public AbstractStringBuilder insert(int offset, double d) {
10.1251 + return insert(offset, String.valueOf(d));
10.1252 + }
10.1253 +
10.1254 + /**
10.1255 + * Returns the index within this string of the first occurrence of the
10.1256 + * specified substring. The integer returned is the smallest value
10.1257 + * <i>k</i> such that:
10.1258 + * <blockquote><pre>
10.1259 + * this.toString().startsWith(str, <i>k</i>)
10.1260 + * </pre></blockquote>
10.1261 + * is <code>true</code>.
10.1262 + *
10.1263 + * @param str any string.
10.1264 + * @return if the string argument occurs as a substring within this
10.1265 + * object, then the index of the first character of the first
10.1266 + * such substring is returned; if it does not occur as a
10.1267 + * substring, <code>-1</code> is returned.
10.1268 + * @throws java.lang.NullPointerException if <code>str</code> is
10.1269 + * <code>null</code>.
10.1270 + */
10.1271 + public int indexOf(String str) {
10.1272 + return indexOf(str, 0);
10.1273 + }
10.1274 +
10.1275 + /**
10.1276 + * Returns the index within this string of the first occurrence of the
10.1277 + * specified substring, starting at the specified index. The integer
10.1278 + * returned is the smallest value <tt>k</tt> for which:
10.1279 + * <blockquote><pre>
10.1280 + * k >= Math.min(fromIndex, str.length()) &&
10.1281 + * this.toString().startsWith(str, k)
10.1282 + * </pre></blockquote>
10.1283 + * If no such value of <i>k</i> exists, then -1 is returned.
10.1284 + *
10.1285 + * @param str the substring for which to search.
10.1286 + * @param fromIndex the index from which to start the search.
10.1287 + * @return the index within this string of the first occurrence of the
10.1288 + * specified substring, starting at the specified index.
10.1289 + * @throws java.lang.NullPointerException if <code>str</code> is
10.1290 + * <code>null</code>.
10.1291 + */
10.1292 + public int indexOf(String str, int fromIndex) {
10.1293 + return String.indexOf(value, 0, count,
10.1294 + str.toCharArray(), 0, str.length(), fromIndex);
10.1295 + }
10.1296 +
10.1297 + /**
10.1298 + * Returns the index within this string of the rightmost occurrence
10.1299 + * of the specified substring. The rightmost empty string "" is
10.1300 + * considered to occur at the index value <code>this.length()</code>.
10.1301 + * The returned index is the largest value <i>k</i> such that
10.1302 + * <blockquote><pre>
10.1303 + * this.toString().startsWith(str, k)
10.1304 + * </pre></blockquote>
10.1305 + * is true.
10.1306 + *
10.1307 + * @param str the substring to search for.
10.1308 + * @return if the string argument occurs one or more times as a substring
10.1309 + * within this object, then the index of the first character of
10.1310 + * the last such substring is returned. If it does not occur as
10.1311 + * a substring, <code>-1</code> is returned.
10.1312 + * @throws java.lang.NullPointerException if <code>str</code> is
10.1313 + * <code>null</code>.
10.1314 + */
10.1315 + public int lastIndexOf(String str) {
10.1316 + return lastIndexOf(str, count);
10.1317 + }
10.1318 +
10.1319 + /**
10.1320 + * Returns the index within this string of the last occurrence of the
10.1321 + * specified substring. The integer returned is the largest value <i>k</i>
10.1322 + * such that:
10.1323 + * <blockquote><pre>
10.1324 + * k <= Math.min(fromIndex, str.length()) &&
10.1325 + * this.toString().startsWith(str, k)
10.1326 + * </pre></blockquote>
10.1327 + * If no such value of <i>k</i> exists, then -1 is returned.
10.1328 + *
10.1329 + * @param str the substring to search for.
10.1330 + * @param fromIndex the index to start the search from.
10.1331 + * @return the index within this sequence of the last occurrence of the
10.1332 + * specified substring.
10.1333 + * @throws java.lang.NullPointerException if <code>str</code> is
10.1334 + * <code>null</code>.
10.1335 + */
10.1336 + public int lastIndexOf(String str, int fromIndex) {
10.1337 + return String.lastIndexOf(value, 0, count,
10.1338 + str.toCharArray(), 0, str.length(), fromIndex);
10.1339 + }
10.1340 +
10.1341 + /**
10.1342 + * Causes this character sequence to be replaced by the reverse of
10.1343 + * the sequence. If there are any surrogate pairs included in the
10.1344 + * sequence, these are treated as single characters for the
10.1345 + * reverse operation. Thus, the order of the high-low surrogates
10.1346 + * is never reversed.
10.1347 + *
10.1348 + * Let <i>n</i> be the character length of this character sequence
10.1349 + * (not the length in <code>char</code> values) just prior to
10.1350 + * execution of the <code>reverse</code> method. Then the
10.1351 + * character at index <i>k</i> in the new character sequence is
10.1352 + * equal to the character at index <i>n-k-1</i> in the old
10.1353 + * character sequence.
10.1354 + *
10.1355 + * <p>Note that the reverse operation may result in producing
10.1356 + * surrogate pairs that were unpaired low-surrogates and
10.1357 + * high-surrogates before the operation. For example, reversing
10.1358 + * "\uDC00\uD800" produces "\uD800\uDC00" which is
10.1359 + * a valid surrogate pair.
10.1360 + *
10.1361 + * @return a reference to this object.
10.1362 + */
10.1363 + public AbstractStringBuilder reverse() {
10.1364 + boolean hasSurrogate = false;
10.1365 + int n = count - 1;
10.1366 + for (int j = (n-1) >> 1; j >= 0; --j) {
10.1367 + char temp = value[j];
10.1368 + char temp2 = value[n - j];
10.1369 + if (!hasSurrogate) {
10.1370 + hasSurrogate = (temp >= Character.MIN_SURROGATE && temp <= Character.MAX_SURROGATE)
10.1371 + || (temp2 >= Character.MIN_SURROGATE && temp2 <= Character.MAX_SURROGATE);
10.1372 + }
10.1373 + value[j] = temp2;
10.1374 + value[n - j] = temp;
10.1375 + }
10.1376 + if (hasSurrogate) {
10.1377 + // Reverse back all valid surrogate pairs
10.1378 + for (int i = 0; i < count - 1; i++) {
10.1379 + char c2 = value[i];
10.1380 + if (Character.isLowSurrogate(c2)) {
10.1381 + char c1 = value[i + 1];
10.1382 + if (Character.isHighSurrogate(c1)) {
10.1383 + value[i++] = c1;
10.1384 + value[i] = c2;
10.1385 + }
10.1386 + }
10.1387 + }
10.1388 + }
10.1389 + return this;
10.1390 + }
10.1391 +
10.1392 + /**
10.1393 + * Returns a string representing the data in this sequence.
10.1394 + * A new <code>String</code> object is allocated and initialized to
10.1395 + * contain the character sequence currently represented by this
10.1396 + * object. This <code>String</code> is then returned. Subsequent
10.1397 + * changes to this sequence do not affect the contents of the
10.1398 + * <code>String</code>.
10.1399 + *
10.1400 + * @return a string representation of this sequence of characters.
10.1401 + */
10.1402 + public abstract String toString();
10.1403 +
10.1404 + /**
10.1405 + * Needed by <tt>String</tt> for the contentEquals method.
10.1406 + */
10.1407 + final char[] getValue() {
10.1408 + return value;
10.1409 + }
10.1410 +
10.1411 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/emul/src/main/java/java/lang/Appendable.java Thu Oct 11 06:16:00 2012 -0700
11.3 @@ -0,0 +1,121 @@
11.4 +/*
11.5 + * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11.7 + *
11.8 + * This code is free software; you can redistribute it and/or modify it
11.9 + * under the terms of the GNU General Public License version 2 only, as
11.10 + * published by the Free Software Foundation. Oracle designates this
11.11 + * particular file as subject to the "Classpath" exception as provided
11.12 + * by Oracle in the LICENSE file that accompanied this code.
11.13 + *
11.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
11.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11.17 + * version 2 for more details (a copy is included in the LICENSE file that
11.18 + * accompanied this code).
11.19 + *
11.20 + * You should have received a copy of the GNU General Public License version
11.21 + * 2 along with this work; if not, write to the Free Software Foundation,
11.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
11.23 + *
11.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
11.25 + * or visit www.oracle.com if you need additional information or have any
11.26 + * questions.
11.27 + */
11.28 +
11.29 +package java.lang;
11.30 +
11.31 +import java.io.IOException;
11.32 +
11.33 +/**
11.34 + * An object to which <tt>char</tt> sequences and values can be appended. The
11.35 + * <tt>Appendable</tt> interface must be implemented by any class whose
11.36 + * instances are intended to receive formatted output from a {@link
11.37 + * java.util.Formatter}.
11.38 + *
11.39 + * <p> The characters to be appended should be valid Unicode characters as
11.40 + * described in <a href="Character.html#unicode">Unicode Character
11.41 + * Representation</a>. Note that supplementary characters may be composed of
11.42 + * multiple 16-bit <tt>char</tt> values.
11.43 + *
11.44 + * <p> Appendables are not necessarily safe for multithreaded access. Thread
11.45 + * safety is the responsibility of classes that extend and implement this
11.46 + * interface.
11.47 + *
11.48 + * <p> Since this interface may be implemented by existing classes
11.49 + * with different styles of error handling there is no guarantee that
11.50 + * errors will be propagated to the invoker.
11.51 + *
11.52 + * @since 1.5
11.53 + */
11.54 +public interface Appendable {
11.55 +
11.56 + /**
11.57 + * Appends the specified character sequence to this <tt>Appendable</tt>.
11.58 + *
11.59 + * <p> Depending on which class implements the character sequence
11.60 + * <tt>csq</tt>, the entire sequence may not be appended. For
11.61 + * instance, if <tt>csq</tt> is a {@link java.nio.CharBuffer} then
11.62 + * the subsequence to append is defined by the buffer's position and limit.
11.63 + *
11.64 + * @param csq
11.65 + * The character sequence to append. If <tt>csq</tt> is
11.66 + * <tt>null</tt>, then the four characters <tt>"null"</tt> are
11.67 + * appended to this Appendable.
11.68 + *
11.69 + * @return A reference to this <tt>Appendable</tt>
11.70 + *
11.71 + * @throws IOException
11.72 + * If an I/O error occurs
11.73 + */
11.74 + Appendable append(CharSequence csq) throws IOException;
11.75 +
11.76 + /**
11.77 + * Appends a subsequence of the specified character sequence to this
11.78 + * <tt>Appendable</tt>.
11.79 + *
11.80 + * <p> An invocation of this method of the form <tt>out.append(csq, start,
11.81 + * end)</tt> when <tt>csq</tt> is not <tt>null</tt>, behaves in
11.82 + * exactly the same way as the invocation
11.83 + *
11.84 + * <pre>
11.85 + * out.append(csq.subSequence(start, end)) </pre>
11.86 + *
11.87 + * @param csq
11.88 + * The character sequence from which a subsequence will be
11.89 + * appended. If <tt>csq</tt> is <tt>null</tt>, then characters
11.90 + * will be appended as if <tt>csq</tt> contained the four
11.91 + * characters <tt>"null"</tt>.
11.92 + *
11.93 + * @param start
11.94 + * The index of the first character in the subsequence
11.95 + *
11.96 + * @param end
11.97 + * The index of the character following the last character in the
11.98 + * subsequence
11.99 + *
11.100 + * @return A reference to this <tt>Appendable</tt>
11.101 + *
11.102 + * @throws IndexOutOfBoundsException
11.103 + * If <tt>start</tt> or <tt>end</tt> are negative, <tt>start</tt>
11.104 + * is greater than <tt>end</tt>, or <tt>end</tt> is greater than
11.105 + * <tt>csq.length()</tt>
11.106 + *
11.107 + * @throws IOException
11.108 + * If an I/O error occurs
11.109 + */
11.110 + Appendable append(CharSequence csq, int start, int end) throws IOException;
11.111 +
11.112 + /**
11.113 + * Appends the specified character to this <tt>Appendable</tt>.
11.114 + *
11.115 + * @param c
11.116 + * The character to append
11.117 + *
11.118 + * @return A reference to this <tt>Appendable</tt>
11.119 + *
11.120 + * @throws IOException
11.121 + * If an I/O error occurs
11.122 + */
11.123 + Appendable append(char c) throws IOException;
11.124 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/emul/src/main/java/java/lang/ArrayIndexOutOfBoundsException.java Thu Oct 11 06:16:00 2012 -0700
12.3 @@ -0,0 +1,67 @@
12.4 +/*
12.5 + * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved.
12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
12.7 + *
12.8 + * This code is free software; you can redistribute it and/or modify it
12.9 + * under the terms of the GNU General Public License version 2 only, as
12.10 + * published by the Free Software Foundation. Oracle designates this
12.11 + * particular file as subject to the "Classpath" exception as provided
12.12 + * by Oracle in the LICENSE file that accompanied this code.
12.13 + *
12.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
12.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12.17 + * version 2 for more details (a copy is included in the LICENSE file that
12.18 + * accompanied this code).
12.19 + *
12.20 + * You should have received a copy of the GNU General Public License version
12.21 + * 2 along with this work; if not, write to the Free Software Foundation,
12.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
12.23 + *
12.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
12.25 + * or visit www.oracle.com if you need additional information or have any
12.26 + * questions.
12.27 + */
12.28 +
12.29 +package java.lang;
12.30 +
12.31 +/**
12.32 + * Thrown to indicate that an array has been accessed with an
12.33 + * illegal index. The index is either negative or greater than or
12.34 + * equal to the size of the array.
12.35 + *
12.36 + * @author unascribed
12.37 + * @since JDK1.0
12.38 + */
12.39 +public
12.40 +class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException {
12.41 + private static final long serialVersionUID = -5116101128118950844L;
12.42 +
12.43 + /**
12.44 + * Constructs an <code>ArrayIndexOutOfBoundsException</code> with no
12.45 + * detail message.
12.46 + */
12.47 + public ArrayIndexOutOfBoundsException() {
12.48 + super();
12.49 + }
12.50 +
12.51 + /**
12.52 + * Constructs a new <code>ArrayIndexOutOfBoundsException</code>
12.53 + * class with an argument indicating the illegal index.
12.54 + *
12.55 + * @param index the illegal index.
12.56 + */
12.57 + public ArrayIndexOutOfBoundsException(int index) {
12.58 + super("Array index out of range: " + index);
12.59 + }
12.60 +
12.61 + /**
12.62 + * Constructs an <code>ArrayIndexOutOfBoundsException</code> class
12.63 + * with the specified detail message.
12.64 + *
12.65 + * @param s the detail message.
12.66 + */
12.67 + public ArrayIndexOutOfBoundsException(String s) {
12.68 + super(s);
12.69 + }
12.70 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/emul/src/main/java/java/lang/AssertionError.java Thu Oct 11 06:16:00 2012 -0700
13.3 @@ -0,0 +1,167 @@
13.4 +/*
13.5 + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
13.7 + *
13.8 + * This code is free software; you can redistribute it and/or modify it
13.9 + * under the terms of the GNU General Public License version 2 only, as
13.10 + * published by the Free Software Foundation. Oracle designates this
13.11 + * particular file as subject to the "Classpath" exception as provided
13.12 + * by Oracle in the LICENSE file that accompanied this code.
13.13 + *
13.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
13.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13.17 + * version 2 for more details (a copy is included in the LICENSE file that
13.18 + * accompanied this code).
13.19 + *
13.20 + * You should have received a copy of the GNU General Public License version
13.21 + * 2 along with this work; if not, write to the Free Software Foundation,
13.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
13.23 + *
13.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
13.25 + * or visit www.oracle.com if you need additional information or have any
13.26 + * questions.
13.27 + */
13.28 +
13.29 +package java.lang;
13.30 +
13.31 +/**
13.32 + * Thrown to indicate that an assertion has failed.
13.33 + *
13.34 + * <p>The seven one-argument public constructors provided by this
13.35 + * class ensure that the assertion error returned by the invocation:
13.36 + * <pre>
13.37 + * new AssertionError(<i>expression</i>)
13.38 + * </pre>
13.39 + * has as its detail message the <i>string conversion</i> of
13.40 + * <i>expression</i> (as defined in section 15.18.1.1 of
13.41 + * <cite>The Java™ Language Specification</cite>),
13.42 + * regardless of the type of <i>expression</i>.
13.43 + *
13.44 + * @since 1.4
13.45 + */
13.46 +public class AssertionError extends Error {
13.47 + private static final long serialVersionUID = -5013299493970297370L;
13.48 +
13.49 + /**
13.50 + * Constructs an AssertionError with no detail message.
13.51 + */
13.52 + public AssertionError() {
13.53 + }
13.54 +
13.55 + /**
13.56 + * This internal constructor does no processing on its string argument,
13.57 + * even if it is a null reference. The public constructors will
13.58 + * never call this constructor with a null argument.
13.59 + */
13.60 + private AssertionError(String detailMessage) {
13.61 + super(detailMessage);
13.62 + }
13.63 +
13.64 + /**
13.65 + * Constructs an AssertionError with its detail message derived
13.66 + * from the specified object, which is converted to a string as
13.67 + * defined in section 15.18.1.1 of
13.68 + * <cite>The Java™ Language Specification</cite>.
13.69 + *<p>
13.70 + * If the specified object is an instance of {@code Throwable}, it
13.71 + * becomes the <i>cause</i> of the newly constructed assertion error.
13.72 + *
13.73 + * @param detailMessage value to be used in constructing detail message
13.74 + * @see Throwable#getCause()
13.75 + */
13.76 + public AssertionError(Object detailMessage) {
13.77 + this("" + detailMessage);
13.78 + if (detailMessage instanceof Throwable)
13.79 + initCause((Throwable) detailMessage);
13.80 + }
13.81 +
13.82 + /**
13.83 + * Constructs an AssertionError with its detail message derived
13.84 + * from the specified <code>boolean</code>, which is converted to
13.85 + * a string as defined in section 15.18.1.1 of
13.86 + * <cite>The Java™ Language Specification</cite>.
13.87 + *
13.88 + * @param detailMessage value to be used in constructing detail message
13.89 + */
13.90 + public AssertionError(boolean detailMessage) {
13.91 + this("" + detailMessage);
13.92 + }
13.93 +
13.94 + /**
13.95 + * Constructs an AssertionError with its detail message derived
13.96 + * from the specified <code>char</code>, which is converted to a
13.97 + * string as defined in section 15.18.1.1 of
13.98 + * <cite>The Java™ Language Specification</cite>.
13.99 + *
13.100 + * @param detailMessage value to be used in constructing detail message
13.101 + */
13.102 + public AssertionError(char detailMessage) {
13.103 + this("" + detailMessage);
13.104 + }
13.105 +
13.106 + /**
13.107 + * Constructs an AssertionError with its detail message derived
13.108 + * from the specified <code>int</code>, which is converted to a
13.109 + * string as defined in section 15.18.1.1 of
13.110 + * <cite>The Java™ Language Specification</cite>.
13.111 + *
13.112 + * @param detailMessage value to be used in constructing detail message
13.113 + */
13.114 + public AssertionError(int detailMessage) {
13.115 + this("" + detailMessage);
13.116 + }
13.117 +
13.118 + /**
13.119 + * Constructs an AssertionError with its detail message derived
13.120 + * from the specified <code>long</code>, which is converted to a
13.121 + * string as defined in section 15.18.1.1 of
13.122 + * <cite>The Java™ Language Specification</cite>.
13.123 + *
13.124 + * @param detailMessage value to be used in constructing detail message
13.125 + */
13.126 + public AssertionError(long detailMessage) {
13.127 + this("" + detailMessage);
13.128 + }
13.129 +
13.130 + /**
13.131 + * Constructs an AssertionError with its detail message derived
13.132 + * from the specified <code>float</code>, which is converted to a
13.133 + * string as defined in section 15.18.1.1 of
13.134 + * <cite>The Java™ Language Specification</cite>.
13.135 + *
13.136 + * @param detailMessage value to be used in constructing detail message
13.137 + */
13.138 + public AssertionError(float detailMessage) {
13.139 + this("" + detailMessage);
13.140 + }
13.141 +
13.142 + /**
13.143 + * Constructs an AssertionError with its detail message derived
13.144 + * from the specified <code>double</code>, which is converted to a
13.145 + * string as defined in section 15.18.1.1 of
13.146 + * <cite>The Java™ Language Specification</cite>.
13.147 + *
13.148 + * @param detailMessage value to be used in constructing detail message
13.149 + */
13.150 + public AssertionError(double detailMessage) {
13.151 + this("" + detailMessage);
13.152 + }
13.153 +
13.154 + /**
13.155 + * Constructs a new {@code AssertionError} with the specified
13.156 + * detail message and cause.
13.157 + *
13.158 + * <p>Note that the detail message associated with
13.159 + * {@code cause} is <i>not</i> automatically incorporated in
13.160 + * this error's detail message.
13.161 + *
13.162 + * @param message the detail message, may be {@code null}
13.163 + * @param cause the cause, may be {@code null}
13.164 + *
13.165 + * @since 1.7
13.166 + */
13.167 + public AssertionError(String message, Throwable cause) {
13.168 + super(message, cause);
13.169 + }
13.170 +}
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/emul/src/main/java/java/lang/Boolean.java Thu Oct 11 06:16:00 2012 -0700
14.3 @@ -0,0 +1,282 @@
14.4 +/*
14.5 + * Copyright (c) 1994, 2006, Oracle and/or its affiliates. All rights reserved.
14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
14.7 + *
14.8 + * This code is free software; you can redistribute it and/or modify it
14.9 + * under the terms of the GNU General Public License version 2 only, as
14.10 + * published by the Free Software Foundation. Oracle designates this
14.11 + * particular file as subject to the "Classpath" exception as provided
14.12 + * by Oracle in the LICENSE file that accompanied this code.
14.13 + *
14.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
14.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14.17 + * version 2 for more details (a copy is included in the LICENSE file that
14.18 + * accompanied this code).
14.19 + *
14.20 + * You should have received a copy of the GNU General Public License version
14.21 + * 2 along with this work; if not, write to the Free Software Foundation,
14.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
14.23 + *
14.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
14.25 + * or visit www.oracle.com if you need additional information or have any
14.26 + * questions.
14.27 + */
14.28 +
14.29 +package java.lang;
14.30 +
14.31 +/**
14.32 + * The Boolean class wraps a value of the primitive type
14.33 + * {@code boolean} in an object. An object of type
14.34 + * {@code Boolean} contains a single field whose type is
14.35 + * {@code boolean}.
14.36 + * <p>
14.37 + * In addition, this class provides many methods for
14.38 + * converting a {@code boolean} to a {@code String} and a
14.39 + * {@code String} to a {@code boolean}, as well as other
14.40 + * constants and methods useful when dealing with a
14.41 + * {@code boolean}.
14.42 + *
14.43 + * @author Arthur van Hoff
14.44 + * @since JDK1.0
14.45 + */
14.46 +public final class Boolean implements java.io.Serializable,
14.47 + Comparable<Boolean>
14.48 +{
14.49 + /**
14.50 + * The {@code Boolean} object corresponding to the primitive
14.51 + * value {@code true}.
14.52 + */
14.53 + public static final Boolean TRUE = new Boolean(true);
14.54 +
14.55 + /**
14.56 + * The {@code Boolean} object corresponding to the primitive
14.57 + * value {@code false}.
14.58 + */
14.59 + public static final Boolean FALSE = new Boolean(false);
14.60 +
14.61 + /**
14.62 + * The Class object representing the primitive type boolean.
14.63 + *
14.64 + * @since JDK1.1
14.65 + */
14.66 + public static final Class<Boolean> TYPE = Class.getPrimitiveClass("boolean");
14.67 +
14.68 + /**
14.69 + * The value of the Boolean.
14.70 + *
14.71 + * @serial
14.72 + */
14.73 + private final boolean value;
14.74 +
14.75 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
14.76 + private static final long serialVersionUID = -3665804199014368530L;
14.77 +
14.78 + /**
14.79 + * Allocates a {@code Boolean} object representing the
14.80 + * {@code value} argument.
14.81 + *
14.82 + * <p><b>Note: It is rarely appropriate to use this constructor.
14.83 + * Unless a <i>new</i> instance is required, the static factory
14.84 + * {@link #valueOf(boolean)} is generally a better choice. It is
14.85 + * likely to yield significantly better space and time performance.</b>
14.86 + *
14.87 + * @param value the value of the {@code Boolean}.
14.88 + */
14.89 + public Boolean(boolean value) {
14.90 + this.value = value;
14.91 + }
14.92 +
14.93 + /**
14.94 + * Allocates a {@code Boolean} object representing the value
14.95 + * {@code true} if the string argument is not {@code null}
14.96 + * and is equal, ignoring case, to the string {@code "true"}.
14.97 + * Otherwise, allocate a {@code Boolean} object representing the
14.98 + * value {@code false}. Examples:<p>
14.99 + * {@code new Boolean("True")} produces a {@code Boolean} object
14.100 + * that represents {@code true}.<br>
14.101 + * {@code new Boolean("yes")} produces a {@code Boolean} object
14.102 + * that represents {@code false}.
14.103 + *
14.104 + * @param s the string to be converted to a {@code Boolean}.
14.105 + */
14.106 + public Boolean(String s) {
14.107 + this(toBoolean(s));
14.108 + }
14.109 +
14.110 + /**
14.111 + * Parses the string argument as a boolean. The {@code boolean}
14.112 + * returned represents the value {@code true} if the string argument
14.113 + * is not {@code null} and is equal, ignoring case, to the string
14.114 + * {@code "true"}. <p>
14.115 + * Example: {@code Boolean.parseBoolean("True")} returns {@code true}.<br>
14.116 + * Example: {@code Boolean.parseBoolean("yes")} returns {@code false}.
14.117 + *
14.118 + * @param s the {@code String} containing the boolean
14.119 + * representation to be parsed
14.120 + * @return the boolean represented by the string argument
14.121 + * @since 1.5
14.122 + */
14.123 + public static boolean parseBoolean(String s) {
14.124 + return toBoolean(s);
14.125 + }
14.126 +
14.127 + /**
14.128 + * Returns the value of this {@code Boolean} object as a boolean
14.129 + * primitive.
14.130 + *
14.131 + * @return the primitive {@code boolean} value of this object.
14.132 + */
14.133 + public boolean booleanValue() {
14.134 + return value;
14.135 + }
14.136 +
14.137 + /**
14.138 + * Returns a {@code Boolean} instance representing the specified
14.139 + * {@code boolean} value. If the specified {@code boolean} value
14.140 + * is {@code true}, this method returns {@code Boolean.TRUE};
14.141 + * if it is {@code false}, this method returns {@code Boolean.FALSE}.
14.142 + * If a new {@code Boolean} instance is not required, this method
14.143 + * should generally be used in preference to the constructor
14.144 + * {@link #Boolean(boolean)}, as this method is likely to yield
14.145 + * significantly better space and time performance.
14.146 + *
14.147 + * @param b a boolean value.
14.148 + * @return a {@code Boolean} instance representing {@code b}.
14.149 + * @since 1.4
14.150 + */
14.151 + public static Boolean valueOf(boolean b) {
14.152 + return (b ? TRUE : FALSE);
14.153 + }
14.154 +
14.155 + /**
14.156 + * Returns a {@code Boolean} with a value represented by the
14.157 + * specified string. The {@code Boolean} returned represents a
14.158 + * true value if the string argument is not {@code null}
14.159 + * and is equal, ignoring case, to the string {@code "true"}.
14.160 + *
14.161 + * @param s a string.
14.162 + * @return the {@code Boolean} value represented by the string.
14.163 + */
14.164 + public static Boolean valueOf(String s) {
14.165 + return toBoolean(s) ? TRUE : FALSE;
14.166 + }
14.167 +
14.168 + /**
14.169 + * Returns a {@code String} object representing the specified
14.170 + * boolean. If the specified boolean is {@code true}, then
14.171 + * the string {@code "true"} will be returned, otherwise the
14.172 + * string {@code "false"} will be returned.
14.173 + *
14.174 + * @param b the boolean to be converted
14.175 + * @return the string representation of the specified {@code boolean}
14.176 + * @since 1.4
14.177 + */
14.178 + public static String toString(boolean b) {
14.179 + return b ? "true" : "false";
14.180 + }
14.181 +
14.182 + /**
14.183 + * Returns a {@code String} object representing this Boolean's
14.184 + * value. If this object represents the value {@code true},
14.185 + * a string equal to {@code "true"} is returned. Otherwise, a
14.186 + * string equal to {@code "false"} is returned.
14.187 + *
14.188 + * @return a string representation of this object.
14.189 + */
14.190 + public String toString() {
14.191 + return value ? "true" : "false";
14.192 + }
14.193 +
14.194 + /**
14.195 + * Returns a hash code for this {@code Boolean} object.
14.196 + *
14.197 + * @return the integer {@code 1231} if this object represents
14.198 + * {@code true}; returns the integer {@code 1237} if this
14.199 + * object represents {@code false}.
14.200 + */
14.201 + public int hashCode() {
14.202 + return value ? 1231 : 1237;
14.203 + }
14.204 +
14.205 + /**
14.206 + * Returns {@code true} if and only if the argument is not
14.207 + * {@code null} and is a {@code Boolean} object that
14.208 + * represents the same {@code boolean} value as this object.
14.209 + *
14.210 + * @param obj the object to compare with.
14.211 + * @return {@code true} if the Boolean objects represent the
14.212 + * same value; {@code false} otherwise.
14.213 + */
14.214 + public boolean equals(Object obj) {
14.215 + if (obj instanceof Boolean) {
14.216 + return value == ((Boolean)obj).booleanValue();
14.217 + }
14.218 + return false;
14.219 + }
14.220 +
14.221 + /**
14.222 + * Returns {@code true} if and only if the system property
14.223 + * named by the argument exists and is equal to the string
14.224 + * {@code "true"}. (Beginning with version 1.0.2 of the
14.225 + * Java<small><sup>TM</sup></small> platform, the test of
14.226 + * this string is case insensitive.) A system property is accessible
14.227 + * through {@code getProperty}, a method defined by the
14.228 + * {@code System} class.
14.229 + * <p>
14.230 + * If there is no property with the specified name, or if the specified
14.231 + * name is empty or null, then {@code false} is returned.
14.232 + *
14.233 + * @param name the system property name.
14.234 + * @return the {@code boolean} value of the system property.
14.235 + * @see java.lang.System#getProperty(java.lang.String)
14.236 + * @see java.lang.System#getProperty(java.lang.String, java.lang.String)
14.237 + */
14.238 + public static boolean getBoolean(String name) {
14.239 + boolean result = false;
14.240 + try {
14.241 + result = toBoolean(String.getProperty(name));
14.242 + } catch (IllegalArgumentException e) {
14.243 + } catch (NullPointerException e) {
14.244 + }
14.245 + return result;
14.246 + }
14.247 +
14.248 + /**
14.249 + * Compares this {@code Boolean} instance with another.
14.250 + *
14.251 + * @param b the {@code Boolean} instance to be compared
14.252 + * @return zero if this object represents the same boolean value as the
14.253 + * argument; a positive value if this object represents true
14.254 + * and the argument represents false; and a negative value if
14.255 + * this object represents false and the argument represents true
14.256 + * @throws NullPointerException if the argument is {@code null}
14.257 + * @see Comparable
14.258 + * @since 1.5
14.259 + */
14.260 + public int compareTo(Boolean b) {
14.261 + return compare(this.value, b.value);
14.262 + }
14.263 +
14.264 + /**
14.265 + * Compares two {@code boolean} values.
14.266 + * The value returned is identical to what would be returned by:
14.267 + * <pre>
14.268 + * Boolean.valueOf(x).compareTo(Boolean.valueOf(y))
14.269 + * </pre>
14.270 + *
14.271 + * @param x the first {@code boolean} to compare
14.272 + * @param y the second {@code boolean} to compare
14.273 + * @return the value {@code 0} if {@code x == y};
14.274 + * a value less than {@code 0} if {@code !x && y}; and
14.275 + * a value greater than {@code 0} if {@code x && !y}
14.276 + * @since 1.7
14.277 + */
14.278 + public static int compare(boolean x, boolean y) {
14.279 + return (x == y) ? 0 : (x ? 1 : -1);
14.280 + }
14.281 +
14.282 + private static boolean toBoolean(String name) {
14.283 + return ((name != null) && name.equalsIgnoreCase("true"));
14.284 + }
14.285 +}
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/emul/src/main/java/java/lang/Byte.java Thu Oct 11 06:16:00 2012 -0700
15.3 @@ -0,0 +1,452 @@
15.4 +/*
15.5 + * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
15.7 + *
15.8 + * This code is free software; you can redistribute it and/or modify it
15.9 + * under the terms of the GNU General Public License version 2 only, as
15.10 + * published by the Free Software Foundation. Oracle designates this
15.11 + * particular file as subject to the "Classpath" exception as provided
15.12 + * by Oracle in the LICENSE file that accompanied this code.
15.13 + *
15.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
15.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15.17 + * version 2 for more details (a copy is included in the LICENSE file that
15.18 + * accompanied this code).
15.19 + *
15.20 + * You should have received a copy of the GNU General Public License version
15.21 + * 2 along with this work; if not, write to the Free Software Foundation,
15.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
15.23 + *
15.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
15.25 + * or visit www.oracle.com if you need additional information or have any
15.26 + * questions.
15.27 + */
15.28 +
15.29 +package java.lang;
15.30 +
15.31 +/**
15.32 + *
15.33 + * The {@code Byte} class wraps a value of primitive type {@code byte}
15.34 + * in an object. An object of type {@code Byte} contains a single
15.35 + * field whose type is {@code byte}.
15.36 + *
15.37 + * <p>In addition, this class provides several methods for converting
15.38 + * a {@code byte} to a {@code String} and a {@code String} to a {@code
15.39 + * byte}, as well as other constants and methods useful when dealing
15.40 + * with a {@code byte}.
15.41 + *
15.42 + * @author Nakul Saraiya
15.43 + * @author Joseph D. Darcy
15.44 + * @see java.lang.Number
15.45 + * @since JDK1.1
15.46 + */
15.47 +public final class Byte extends Number implements Comparable<Byte> {
15.48 +
15.49 + /**
15.50 + * A constant holding the minimum value a {@code byte} can
15.51 + * have, -2<sup>7</sup>.
15.52 + */
15.53 + public static final byte MIN_VALUE = -128;
15.54 +
15.55 + /**
15.56 + * A constant holding the maximum value a {@code byte} can
15.57 + * have, 2<sup>7</sup>-1.
15.58 + */
15.59 + public static final byte MAX_VALUE = 127;
15.60 +
15.61 + /**
15.62 + * The {@code Class} instance representing the primitive type
15.63 + * {@code byte}.
15.64 + */
15.65 + public static final Class<Byte> TYPE = (Class<Byte>) Class.getPrimitiveClass("byte");
15.66 +
15.67 + /**
15.68 + * Returns a new {@code String} object representing the
15.69 + * specified {@code byte}. The radix is assumed to be 10.
15.70 + *
15.71 + * @param b the {@code byte} to be converted
15.72 + * @return the string representation of the specified {@code byte}
15.73 + * @see java.lang.Integer#toString(int)
15.74 + */
15.75 + public static String toString(byte b) {
15.76 + return Integer.toString((int)b, 10);
15.77 + }
15.78 +
15.79 + private static class ByteCache {
15.80 + private ByteCache(){}
15.81 +
15.82 + static final Byte cache[] = new Byte[-(-128) + 127 + 1];
15.83 +
15.84 + static {
15.85 + for(int i = 0; i < cache.length; i++)
15.86 + cache[i] = new Byte((byte)(i - 128));
15.87 + }
15.88 + }
15.89 +
15.90 + /**
15.91 + * Returns a {@code Byte} instance representing the specified
15.92 + * {@code byte} value.
15.93 + * If a new {@code Byte} instance is not required, this method
15.94 + * should generally be used in preference to the constructor
15.95 + * {@link #Byte(byte)}, as this method is likely to yield
15.96 + * significantly better space and time performance since
15.97 + * all byte values are cached.
15.98 + *
15.99 + * @param b a byte value.
15.100 + * @return a {@code Byte} instance representing {@code b}.
15.101 + * @since 1.5
15.102 + */
15.103 + public static Byte valueOf(byte b) {
15.104 + final int offset = 128;
15.105 + return ByteCache.cache[(int)b + offset];
15.106 + }
15.107 +
15.108 + /**
15.109 + * Parses the string argument as a signed {@code byte} in the
15.110 + * radix specified by the second argument. The characters in the
15.111 + * string must all be digits, of the specified radix (as
15.112 + * determined by whether {@link java.lang.Character#digit(char,
15.113 + * int)} returns a nonnegative value) except that the first
15.114 + * character may be an ASCII minus sign {@code '-'}
15.115 + * (<code>'\u002D'</code>) to indicate a negative value or an
15.116 + * ASCII plus sign {@code '+'} (<code>'\u002B'</code>) to
15.117 + * indicate a positive value. The resulting {@code byte} value is
15.118 + * returned.
15.119 + *
15.120 + * <p>An exception of type {@code NumberFormatException} is
15.121 + * thrown if any of the following situations occurs:
15.122 + * <ul>
15.123 + * <li> The first argument is {@code null} or is a string of
15.124 + * length zero.
15.125 + *
15.126 + * <li> The radix is either smaller than {@link
15.127 + * java.lang.Character#MIN_RADIX} or larger than {@link
15.128 + * java.lang.Character#MAX_RADIX}.
15.129 + *
15.130 + * <li> Any character of the string is not a digit of the
15.131 + * specified radix, except that the first character may be a minus
15.132 + * sign {@code '-'} (<code>'\u002D'</code>) or plus sign
15.133 + * {@code '+'} (<code>'\u002B'</code>) provided that the
15.134 + * string is longer than length 1.
15.135 + *
15.136 + * <li> The value represented by the string is not a value of type
15.137 + * {@code byte}.
15.138 + * </ul>
15.139 + *
15.140 + * @param s the {@code String} containing the
15.141 + * {@code byte}
15.142 + * representation to be parsed
15.143 + * @param radix the radix to be used while parsing {@code s}
15.144 + * @return the {@code byte} value represented by the string
15.145 + * argument in the specified radix
15.146 + * @throws NumberFormatException If the string does
15.147 + * not contain a parsable {@code byte}.
15.148 + */
15.149 + public static byte parseByte(String s, int radix)
15.150 + throws NumberFormatException {
15.151 + int i = Integer.parseInt(s, radix);
15.152 + if (i < MIN_VALUE || i > MAX_VALUE)
15.153 + throw new NumberFormatException(
15.154 + "Value out of range. Value:\"" + s + "\" Radix:" + radix);
15.155 + return (byte)i;
15.156 + }
15.157 +
15.158 + /**
15.159 + * Parses the string argument as a signed decimal {@code
15.160 + * byte}. The characters in the string must all be decimal digits,
15.161 + * except that the first character may be an ASCII minus sign
15.162 + * {@code '-'} (<code>'\u002D'</code>) to indicate a negative
15.163 + * value or an ASCII plus sign {@code '+'}
15.164 + * (<code>'\u002B'</code>) to indicate a positive value. The
15.165 + * resulting {@code byte} value is returned, exactly as if the
15.166 + * argument and the radix 10 were given as arguments to the {@link
15.167 + * #parseByte(java.lang.String, int)} method.
15.168 + *
15.169 + * @param s a {@code String} containing the
15.170 + * {@code byte} representation to be parsed
15.171 + * @return the {@code byte} value represented by the
15.172 + * argument in decimal
15.173 + * @throws NumberFormatException if the string does not
15.174 + * contain a parsable {@code byte}.
15.175 + */
15.176 + public static byte parseByte(String s) throws NumberFormatException {
15.177 + return parseByte(s, 10);
15.178 + }
15.179 +
15.180 + /**
15.181 + * Returns a {@code Byte} object holding the value
15.182 + * extracted from the specified {@code String} when parsed
15.183 + * with the radix given by the second argument. The first argument
15.184 + * is interpreted as representing a signed {@code byte} in
15.185 + * the radix specified by the second argument, exactly as if the
15.186 + * argument were given to the {@link #parseByte(java.lang.String,
15.187 + * int)} method. The result is a {@code Byte} object that
15.188 + * represents the {@code byte} value specified by the string.
15.189 + *
15.190 + * <p> In other words, this method returns a {@code Byte} object
15.191 + * equal to the value of:
15.192 + *
15.193 + * <blockquote>
15.194 + * {@code new Byte(Byte.parseByte(s, radix))}
15.195 + * </blockquote>
15.196 + *
15.197 + * @param s the string to be parsed
15.198 + * @param radix the radix to be used in interpreting {@code s}
15.199 + * @return a {@code Byte} object holding the value
15.200 + * represented by the string argument in the
15.201 + * specified radix.
15.202 + * @throws NumberFormatException If the {@code String} does
15.203 + * not contain a parsable {@code byte}.
15.204 + */
15.205 + public static Byte valueOf(String s, int radix)
15.206 + throws NumberFormatException {
15.207 + return valueOf(parseByte(s, radix));
15.208 + }
15.209 +
15.210 + /**
15.211 + * Returns a {@code Byte} object holding the value
15.212 + * given by the specified {@code String}. The argument is
15.213 + * interpreted as representing a signed decimal {@code byte},
15.214 + * exactly as if the argument were given to the {@link
15.215 + * #parseByte(java.lang.String)} method. The result is a
15.216 + * {@code Byte} object that represents the {@code byte}
15.217 + * value specified by the string.
15.218 + *
15.219 + * <p> In other words, this method returns a {@code Byte} object
15.220 + * equal to the value of:
15.221 + *
15.222 + * <blockquote>
15.223 + * {@code new Byte(Byte.parseByte(s))}
15.224 + * </blockquote>
15.225 + *
15.226 + * @param s the string to be parsed
15.227 + * @return a {@code Byte} object holding the value
15.228 + * represented by the string argument
15.229 + * @throws NumberFormatException If the {@code String} does
15.230 + * not contain a parsable {@code byte}.
15.231 + */
15.232 + public static Byte valueOf(String s) throws NumberFormatException {
15.233 + return valueOf(s, 10);
15.234 + }
15.235 +
15.236 + /**
15.237 + * Decodes a {@code String} into a {@code Byte}.
15.238 + * Accepts decimal, hexadecimal, and octal numbers given by
15.239 + * the following grammar:
15.240 + *
15.241 + * <blockquote>
15.242 + * <dl>
15.243 + * <dt><i>DecodableString:</i>
15.244 + * <dd><i>Sign<sub>opt</sub> DecimalNumeral</i>
15.245 + * <dd><i>Sign<sub>opt</sub></i> {@code 0x} <i>HexDigits</i>
15.246 + * <dd><i>Sign<sub>opt</sub></i> {@code 0X} <i>HexDigits</i>
15.247 + * <dd><i>Sign<sub>opt</sub></i> {@code #} <i>HexDigits</i>
15.248 + * <dd><i>Sign<sub>opt</sub></i> {@code 0} <i>OctalDigits</i>
15.249 + * <p>
15.250 + * <dt><i>Sign:</i>
15.251 + * <dd>{@code -}
15.252 + * <dd>{@code +}
15.253 + * </dl>
15.254 + * </blockquote>
15.255 + *
15.256 + * <i>DecimalNumeral</i>, <i>HexDigits</i>, and <i>OctalDigits</i>
15.257 + * are as defined in section 3.10.1 of
15.258 + * <cite>The Java™ Language Specification</cite>,
15.259 + * except that underscores are not accepted between digits.
15.260 + *
15.261 + * <p>The sequence of characters following an optional
15.262 + * sign and/or radix specifier ("{@code 0x}", "{@code 0X}",
15.263 + * "{@code #}", or leading zero) is parsed as by the {@code
15.264 + * Byte.parseByte} method with the indicated radix (10, 16, or 8).
15.265 + * This sequence of characters must represent a positive value or
15.266 + * a {@link NumberFormatException} will be thrown. The result is
15.267 + * negated if first character of the specified {@code String} is
15.268 + * the minus sign. No whitespace characters are permitted in the
15.269 + * {@code String}.
15.270 + *
15.271 + * @param nm the {@code String} to decode.
15.272 + * @return a {@code Byte} object holding the {@code byte}
15.273 + * value represented by {@code nm}
15.274 + * @throws NumberFormatException if the {@code String} does not
15.275 + * contain a parsable {@code byte}.
15.276 + * @see java.lang.Byte#parseByte(java.lang.String, int)
15.277 + */
15.278 + public static Byte decode(String nm) throws NumberFormatException {
15.279 + int i = Integer.decode(nm);
15.280 + if (i < MIN_VALUE || i > MAX_VALUE)
15.281 + throw new NumberFormatException(
15.282 + "Value " + i + " out of range from input " + nm);
15.283 + return valueOf((byte)i);
15.284 + }
15.285 +
15.286 + /**
15.287 + * The value of the {@code Byte}.
15.288 + *
15.289 + * @serial
15.290 + */
15.291 + private final byte value;
15.292 +
15.293 + /**
15.294 + * Constructs a newly allocated {@code Byte} object that
15.295 + * represents the specified {@code byte} value.
15.296 + *
15.297 + * @param value the value to be represented by the
15.298 + * {@code Byte}.
15.299 + */
15.300 + public Byte(byte value) {
15.301 + this.value = value;
15.302 + }
15.303 +
15.304 + /**
15.305 + * Constructs a newly allocated {@code Byte} object that
15.306 + * represents the {@code byte} value indicated by the
15.307 + * {@code String} parameter. The string is converted to a
15.308 + * {@code byte} value in exactly the manner used by the
15.309 + * {@code parseByte} method for radix 10.
15.310 + *
15.311 + * @param s the {@code String} to be converted to a
15.312 + * {@code Byte}
15.313 + * @throws NumberFormatException If the {@code String}
15.314 + * does not contain a parsable {@code byte}.
15.315 + * @see java.lang.Byte#parseByte(java.lang.String, int)
15.316 + */
15.317 + public Byte(String s) throws NumberFormatException {
15.318 + this.value = parseByte(s, 10);
15.319 + }
15.320 +
15.321 + /**
15.322 + * Returns the value of this {@code Byte} as a
15.323 + * {@code byte}.
15.324 + */
15.325 + public byte byteValue() {
15.326 + return value;
15.327 + }
15.328 +
15.329 + /**
15.330 + * Returns the value of this {@code Byte} as a
15.331 + * {@code short}.
15.332 + */
15.333 + public short shortValue() {
15.334 + return (short)value;
15.335 + }
15.336 +
15.337 + /**
15.338 + * Returns the value of this {@code Byte} as an
15.339 + * {@code int}.
15.340 + */
15.341 + public int intValue() {
15.342 + return (int)value;
15.343 + }
15.344 +
15.345 + /**
15.346 + * Returns the value of this {@code Byte} as a
15.347 + * {@code long}.
15.348 + */
15.349 + public long longValue() {
15.350 + return (long)value;
15.351 + }
15.352 +
15.353 + /**
15.354 + * Returns the value of this {@code Byte} as a
15.355 + * {@code float}.
15.356 + */
15.357 + public float floatValue() {
15.358 + return (float)value;
15.359 + }
15.360 +
15.361 + /**
15.362 + * Returns the value of this {@code Byte} as a
15.363 + * {@code double}.
15.364 + */
15.365 + public double doubleValue() {
15.366 + return (double)value;
15.367 + }
15.368 +
15.369 + /**
15.370 + * Returns a {@code String} object representing this
15.371 + * {@code Byte}'s value. The value is converted to signed
15.372 + * decimal representation and returned as a string, exactly as if
15.373 + * the {@code byte} value were given as an argument to the
15.374 + * {@link java.lang.Byte#toString(byte)} method.
15.375 + *
15.376 + * @return a string representation of the value of this object in
15.377 + * base 10.
15.378 + */
15.379 + public String toString() {
15.380 + return Integer.toString((int)value);
15.381 + }
15.382 +
15.383 + /**
15.384 + * Returns a hash code for this {@code Byte}; equal to the result
15.385 + * of invoking {@code intValue()}.
15.386 + *
15.387 + * @return a hash code value for this {@code Byte}
15.388 + */
15.389 + public int hashCode() {
15.390 + return (int)value;
15.391 + }
15.392 +
15.393 + /**
15.394 + * Compares this object to the specified object. The result is
15.395 + * {@code true} if and only if the argument is not
15.396 + * {@code null} and is a {@code Byte} object that
15.397 + * contains the same {@code byte} value as this object.
15.398 + *
15.399 + * @param obj the object to compare with
15.400 + * @return {@code true} if the objects are the same;
15.401 + * {@code false} otherwise.
15.402 + */
15.403 + public boolean equals(Object obj) {
15.404 + if (obj instanceof Byte) {
15.405 + return value == ((Byte)obj).byteValue();
15.406 + }
15.407 + return false;
15.408 + }
15.409 +
15.410 + /**
15.411 + * Compares two {@code Byte} objects numerically.
15.412 + *
15.413 + * @param anotherByte the {@code Byte} to be compared.
15.414 + * @return the value {@code 0} if this {@code Byte} is
15.415 + * equal to the argument {@code Byte}; a value less than
15.416 + * {@code 0} if this {@code Byte} is numerically less
15.417 + * than the argument {@code Byte}; and a value greater than
15.418 + * {@code 0} if this {@code Byte} is numerically
15.419 + * greater than the argument {@code Byte} (signed
15.420 + * comparison).
15.421 + * @since 1.2
15.422 + */
15.423 + public int compareTo(Byte anotherByte) {
15.424 + return compare(this.value, anotherByte.value);
15.425 + }
15.426 +
15.427 + /**
15.428 + * Compares two {@code byte} values numerically.
15.429 + * The value returned is identical to what would be returned by:
15.430 + * <pre>
15.431 + * Byte.valueOf(x).compareTo(Byte.valueOf(y))
15.432 + * </pre>
15.433 + *
15.434 + * @param x the first {@code byte} to compare
15.435 + * @param y the second {@code byte} to compare
15.436 + * @return the value {@code 0} if {@code x == y};
15.437 + * a value less than {@code 0} if {@code x < y}; and
15.438 + * a value greater than {@code 0} if {@code x > y}
15.439 + * @since 1.7
15.440 + */
15.441 + public static int compare(byte x, byte y) {
15.442 + return x - y;
15.443 + }
15.444 +
15.445 + /**
15.446 + * The number of bits used to represent a {@code byte} value in two's
15.447 + * complement binary form.
15.448 + *
15.449 + * @since 1.5
15.450 + */
15.451 + public static final int SIZE = 8;
15.452 +
15.453 + /** use serialVersionUID from JDK 1.1. for interoperability */
15.454 + private static final long serialVersionUID = -7183698231559129828L;
15.455 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/emul/src/main/java/java/lang/CharSequence.java Thu Oct 11 06:16:00 2012 -0700
16.3 @@ -0,0 +1,111 @@
16.4 +/*
16.5 + * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
16.7 + *
16.8 + * This code is free software; you can redistribute it and/or modify it
16.9 + * under the terms of the GNU General Public License version 2 only, as
16.10 + * published by the Free Software Foundation. Oracle designates this
16.11 + * particular file as subject to the "Classpath" exception as provided
16.12 + * by Oracle in the LICENSE file that accompanied this code.
16.13 + *
16.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
16.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16.17 + * version 2 for more details (a copy is included in the LICENSE file that
16.18 + * accompanied this code).
16.19 + *
16.20 + * You should have received a copy of the GNU General Public License version
16.21 + * 2 along with this work; if not, write to the Free Software Foundation,
16.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
16.23 + *
16.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
16.25 + * or visit www.oracle.com if you need additional information or have any
16.26 + * questions.
16.27 + */
16.28 +
16.29 +package java.lang;
16.30 +
16.31 +
16.32 +/**
16.33 + * A <tt>CharSequence</tt> is a readable sequence of <code>char</code> values. This
16.34 + * interface provides uniform, read-only access to many different kinds of
16.35 + * <code>char</code> sequences.
16.36 + * A <code>char</code> value represents a character in the <i>Basic
16.37 + * Multilingual Plane (BMP)</i> or a surrogate. Refer to <a
16.38 + * href="Character.html#unicode">Unicode Character Representation</a> for details.
16.39 + *
16.40 + * <p> This interface does not refine the general contracts of the {@link
16.41 + * java.lang.Object#equals(java.lang.Object) equals} and {@link
16.42 + * java.lang.Object#hashCode() hashCode} methods. The result of comparing two
16.43 + * objects that implement <tt>CharSequence</tt> is therefore, in general,
16.44 + * undefined. Each object may be implemented by a different class, and there
16.45 + * is no guarantee that each class will be capable of testing its instances
16.46 + * for equality with those of the other. It is therefore inappropriate to use
16.47 + * arbitrary <tt>CharSequence</tt> instances as elements in a set or as keys in
16.48 + * a map. </p>
16.49 + *
16.50 + * @author Mike McCloskey
16.51 + * @since 1.4
16.52 + * @spec JSR-51
16.53 + */
16.54 +
16.55 +public interface CharSequence {
16.56 +
16.57 + /**
16.58 + * Returns the length of this character sequence. The length is the number
16.59 + * of 16-bit <code>char</code>s in the sequence.</p>
16.60 + *
16.61 + * @return the number of <code>char</code>s in this sequence
16.62 + */
16.63 + int length();
16.64 +
16.65 + /**
16.66 + * Returns the <code>char</code> value at the specified index. An index ranges from zero
16.67 + * to <tt>length() - 1</tt>. The first <code>char</code> value of the sequence is at
16.68 + * index zero, the next at index one, and so on, as for array
16.69 + * indexing. </p>
16.70 + *
16.71 + * <p>If the <code>char</code> value specified by the index is a
16.72 + * <a href="{@docRoot}/java/lang/Character.html#unicode">surrogate</a>, the surrogate
16.73 + * value is returned.
16.74 + *
16.75 + * @param index the index of the <code>char</code> value to be returned
16.76 + *
16.77 + * @return the specified <code>char</code> value
16.78 + *
16.79 + * @throws IndexOutOfBoundsException
16.80 + * if the <tt>index</tt> argument is negative or not less than
16.81 + * <tt>length()</tt>
16.82 + */
16.83 + char charAt(int index);
16.84 +
16.85 + /**
16.86 + * Returns a new <code>CharSequence</code> that is a subsequence of this sequence.
16.87 + * The subsequence starts with the <code>char</code> value at the specified index and
16.88 + * ends with the <code>char</code> value at index <tt>end - 1</tt>. The length
16.89 + * (in <code>char</code>s) of the
16.90 + * returned sequence is <tt>end - start</tt>, so if <tt>start == end</tt>
16.91 + * then an empty sequence is returned. </p>
16.92 + *
16.93 + * @param start the start index, inclusive
16.94 + * @param end the end index, exclusive
16.95 + *
16.96 + * @return the specified subsequence
16.97 + *
16.98 + * @throws IndexOutOfBoundsException
16.99 + * if <tt>start</tt> or <tt>end</tt> are negative,
16.100 + * if <tt>end</tt> is greater than <tt>length()</tt>,
16.101 + * or if <tt>start</tt> is greater than <tt>end</tt>
16.102 + */
16.103 + CharSequence subSequence(int start, int end);
16.104 +
16.105 + /**
16.106 + * Returns a string containing the characters in this sequence in the same
16.107 + * order as this sequence. The length of the string will be the length of
16.108 + * this sequence. </p>
16.109 + *
16.110 + * @return a string consisting of exactly this sequence of characters
16.111 + */
16.112 + public String toString();
16.113 +
16.114 +}
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
17.2 +++ b/emul/src/main/java/java/lang/Character.java Thu Oct 11 06:16:00 2012 -0700
17.3 @@ -0,0 +1,2388 @@
17.4 +/*
17.5 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
17.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
17.7 + *
17.8 + * This code is free software; you can redistribute it and/or modify it
17.9 + * under the terms of the GNU General Public License version 2 only, as
17.10 + * published by the Free Software Foundation. Oracle designates this
17.11 + * particular file as subject to the "Classpath" exception as provided
17.12 + * by Oracle in the LICENSE file that accompanied this code.
17.13 + *
17.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
17.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17.17 + * version 2 for more details (a copy is included in the LICENSE file that
17.18 + * accompanied this code).
17.19 + *
17.20 + * You should have received a copy of the GNU General Public License version
17.21 + * 2 along with this work; if not, write to the Free Software Foundation,
17.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17.23 + *
17.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
17.25 + * or visit www.oracle.com if you need additional information or have any
17.26 + * questions.
17.27 + */
17.28 +
17.29 +package java.lang;
17.30 +
17.31 +/**
17.32 + * The {@code Character} class wraps a value of the primitive
17.33 + * type {@code char} in an object. An object of type
17.34 + * {@code Character} contains a single field whose type is
17.35 + * {@code char}.
17.36 + * <p>
17.37 + * In addition, this class provides several methods for determining
17.38 + * a character's category (lowercase letter, digit, etc.) and for converting
17.39 + * characters from uppercase to lowercase and vice versa.
17.40 + * <p>
17.41 + * Character information is based on the Unicode Standard, version 6.0.0.
17.42 + * <p>
17.43 + * The methods and data of class {@code Character} are defined by
17.44 + * the information in the <i>UnicodeData</i> file that is part of the
17.45 + * Unicode Character Database maintained by the Unicode
17.46 + * Consortium. This file specifies various properties including name
17.47 + * and general category for every defined Unicode code point or
17.48 + * character range.
17.49 + * <p>
17.50 + * The file and its description are available from the Unicode Consortium at:
17.51 + * <ul>
17.52 + * <li><a href="http://www.unicode.org">http://www.unicode.org</a>
17.53 + * </ul>
17.54 + *
17.55 + * <h4><a name="unicode">Unicode Character Representations</a></h4>
17.56 + *
17.57 + * <p>The {@code char} data type (and therefore the value that a
17.58 + * {@code Character} object encapsulates) are based on the
17.59 + * original Unicode specification, which defined characters as
17.60 + * fixed-width 16-bit entities. The Unicode Standard has since been
17.61 + * changed to allow for characters whose representation requires more
17.62 + * than 16 bits. The range of legal <em>code point</em>s is now
17.63 + * U+0000 to U+10FFFF, known as <em>Unicode scalar value</em>.
17.64 + * (Refer to the <a
17.65 + * href="http://www.unicode.org/reports/tr27/#notation"><i>
17.66 + * definition</i></a> of the U+<i>n</i> notation in the Unicode
17.67 + * Standard.)
17.68 + *
17.69 + * <p><a name="BMP">The set of characters from U+0000 to U+FFFF is
17.70 + * sometimes referred to as the <em>Basic Multilingual Plane (BMP)</em>.
17.71 + * <a name="supplementary">Characters</a> whose code points are greater
17.72 + * than U+FFFF are called <em>supplementary character</em>s. The Java
17.73 + * platform uses the UTF-16 representation in {@code char} arrays and
17.74 + * in the {@code String} and {@code StringBuffer} classes. In
17.75 + * this representation, supplementary characters are represented as a pair
17.76 + * of {@code char} values, the first from the <em>high-surrogates</em>
17.77 + * range, (\uD800-\uDBFF), the second from the
17.78 + * <em>low-surrogates</em> range (\uDC00-\uDFFF).
17.79 + *
17.80 + * <p>A {@code char} value, therefore, represents Basic
17.81 + * Multilingual Plane (BMP) code points, including the surrogate
17.82 + * code points, or code units of the UTF-16 encoding. An
17.83 + * {@code int} value represents all Unicode code points,
17.84 + * including supplementary code points. The lower (least significant)
17.85 + * 21 bits of {@code int} are used to represent Unicode code
17.86 + * points and the upper (most significant) 11 bits must be zero.
17.87 + * Unless otherwise specified, the behavior with respect to
17.88 + * supplementary characters and surrogate {@code char} values is
17.89 + * as follows:
17.90 + *
17.91 + * <ul>
17.92 + * <li>The methods that only accept a {@code char} value cannot support
17.93 + * supplementary characters. They treat {@code char} values from the
17.94 + * surrogate ranges as undefined characters. For example,
17.95 + * {@code Character.isLetter('\u005CuD840')} returns {@code false}, even though
17.96 + * this specific value if followed by any low-surrogate value in a string
17.97 + * would represent a letter.
17.98 + *
17.99 + * <li>The methods that accept an {@code int} value support all
17.100 + * Unicode characters, including supplementary characters. For
17.101 + * example, {@code Character.isLetter(0x2F81A)} returns
17.102 + * {@code true} because the code point value represents a letter
17.103 + * (a CJK ideograph).
17.104 + * </ul>
17.105 + *
17.106 + * <p>In the Java SE API documentation, <em>Unicode code point</em> is
17.107 + * used for character values in the range between U+0000 and U+10FFFF,
17.108 + * and <em>Unicode code unit</em> is used for 16-bit
17.109 + * {@code char} values that are code units of the <em>UTF-16</em>
17.110 + * encoding. For more information on Unicode terminology, refer to the
17.111 + * <a href="http://www.unicode.org/glossary/">Unicode Glossary</a>.
17.112 + *
17.113 + * @author Lee Boynton
17.114 + * @author Guy Steele
17.115 + * @author Akira Tanaka
17.116 + * @author Martin Buchholz
17.117 + * @author Ulf Zibis
17.118 + * @since 1.0
17.119 + */
17.120 +public final
17.121 +class Character implements java.io.Serializable, Comparable<Character> {
17.122 + /**
17.123 + * The minimum radix available for conversion to and from strings.
17.124 + * The constant value of this field is the smallest value permitted
17.125 + * for the radix argument in radix-conversion methods such as the
17.126 + * {@code digit} method, the {@code forDigit} method, and the
17.127 + * {@code toString} method of class {@code Integer}.
17.128 + *
17.129 + * @see Character#digit(char, int)
17.130 + * @see Character#forDigit(int, int)
17.131 + * @see Integer#toString(int, int)
17.132 + * @see Integer#valueOf(String)
17.133 + */
17.134 + public static final int MIN_RADIX = 2;
17.135 +
17.136 + /**
17.137 + * The maximum radix available for conversion to and from strings.
17.138 + * The constant value of this field is the largest value permitted
17.139 + * for the radix argument in radix-conversion methods such as the
17.140 + * {@code digit} method, the {@code forDigit} method, and the
17.141 + * {@code toString} method of class {@code Integer}.
17.142 + *
17.143 + * @see Character#digit(char, int)
17.144 + * @see Character#forDigit(int, int)
17.145 + * @see Integer#toString(int, int)
17.146 + * @see Integer#valueOf(String)
17.147 + */
17.148 + public static final int MAX_RADIX = 36;
17.149 +
17.150 + /**
17.151 + * The constant value of this field is the smallest value of type
17.152 + * {@code char}, {@code '\u005Cu0000'}.
17.153 + *
17.154 + * @since 1.0.2
17.155 + */
17.156 + public static final char MIN_VALUE = '\u0000';
17.157 +
17.158 + /**
17.159 + * The constant value of this field is the largest value of type
17.160 + * {@code char}, {@code '\u005CuFFFF'}.
17.161 + *
17.162 + * @since 1.0.2
17.163 + */
17.164 + public static final char MAX_VALUE = '\uFFFF';
17.165 +
17.166 + /**
17.167 + * The {@code Class} instance representing the primitive type
17.168 + * {@code char}.
17.169 + *
17.170 + * @since 1.1
17.171 + */
17.172 + public static final Class<Character> TYPE = Class.getPrimitiveClass("char");
17.173 +
17.174 + /*
17.175 + * Normative general types
17.176 + */
17.177 +
17.178 + /*
17.179 + * General character types
17.180 + */
17.181 +
17.182 + /**
17.183 + * General category "Cn" in the Unicode specification.
17.184 + * @since 1.1
17.185 + */
17.186 + public static final byte UNASSIGNED = 0;
17.187 +
17.188 + /**
17.189 + * General category "Lu" in the Unicode specification.
17.190 + * @since 1.1
17.191 + */
17.192 + public static final byte UPPERCASE_LETTER = 1;
17.193 +
17.194 + /**
17.195 + * General category "Ll" in the Unicode specification.
17.196 + * @since 1.1
17.197 + */
17.198 + public static final byte LOWERCASE_LETTER = 2;
17.199 +
17.200 + /**
17.201 + * General category "Lt" in the Unicode specification.
17.202 + * @since 1.1
17.203 + */
17.204 + public static final byte TITLECASE_LETTER = 3;
17.205 +
17.206 + /**
17.207 + * General category "Lm" in the Unicode specification.
17.208 + * @since 1.1
17.209 + */
17.210 + public static final byte MODIFIER_LETTER = 4;
17.211 +
17.212 + /**
17.213 + * General category "Lo" in the Unicode specification.
17.214 + * @since 1.1
17.215 + */
17.216 + public static final byte OTHER_LETTER = 5;
17.217 +
17.218 + /**
17.219 + * General category "Mn" in the Unicode specification.
17.220 + * @since 1.1
17.221 + */
17.222 + public static final byte NON_SPACING_MARK = 6;
17.223 +
17.224 + /**
17.225 + * General category "Me" in the Unicode specification.
17.226 + * @since 1.1
17.227 + */
17.228 + public static final byte ENCLOSING_MARK = 7;
17.229 +
17.230 + /**
17.231 + * General category "Mc" in the Unicode specification.
17.232 + * @since 1.1
17.233 + */
17.234 + public static final byte COMBINING_SPACING_MARK = 8;
17.235 +
17.236 + /**
17.237 + * General category "Nd" in the Unicode specification.
17.238 + * @since 1.1
17.239 + */
17.240 + public static final byte DECIMAL_DIGIT_NUMBER = 9;
17.241 +
17.242 + /**
17.243 + * General category "Nl" in the Unicode specification.
17.244 + * @since 1.1
17.245 + */
17.246 + public static final byte LETTER_NUMBER = 10;
17.247 +
17.248 + /**
17.249 + * General category "No" in the Unicode specification.
17.250 + * @since 1.1
17.251 + */
17.252 + public static final byte OTHER_NUMBER = 11;
17.253 +
17.254 + /**
17.255 + * General category "Zs" in the Unicode specification.
17.256 + * @since 1.1
17.257 + */
17.258 + public static final byte SPACE_SEPARATOR = 12;
17.259 +
17.260 + /**
17.261 + * General category "Zl" in the Unicode specification.
17.262 + * @since 1.1
17.263 + */
17.264 + public static final byte LINE_SEPARATOR = 13;
17.265 +
17.266 + /**
17.267 + * General category "Zp" in the Unicode specification.
17.268 + * @since 1.1
17.269 + */
17.270 + public static final byte PARAGRAPH_SEPARATOR = 14;
17.271 +
17.272 + /**
17.273 + * General category "Cc" in the Unicode specification.
17.274 + * @since 1.1
17.275 + */
17.276 + public static final byte CONTROL = 15;
17.277 +
17.278 + /**
17.279 + * General category "Cf" in the Unicode specification.
17.280 + * @since 1.1
17.281 + */
17.282 + public static final byte FORMAT = 16;
17.283 +
17.284 + /**
17.285 + * General category "Co" in the Unicode specification.
17.286 + * @since 1.1
17.287 + */
17.288 + public static final byte PRIVATE_USE = 18;
17.289 +
17.290 + /**
17.291 + * General category "Cs" in the Unicode specification.
17.292 + * @since 1.1
17.293 + */
17.294 + public static final byte SURROGATE = 19;
17.295 +
17.296 + /**
17.297 + * General category "Pd" in the Unicode specification.
17.298 + * @since 1.1
17.299 + */
17.300 + public static final byte DASH_PUNCTUATION = 20;
17.301 +
17.302 + /**
17.303 + * General category "Ps" in the Unicode specification.
17.304 + * @since 1.1
17.305 + */
17.306 + public static final byte START_PUNCTUATION = 21;
17.307 +
17.308 + /**
17.309 + * General category "Pe" in the Unicode specification.
17.310 + * @since 1.1
17.311 + */
17.312 + public static final byte END_PUNCTUATION = 22;
17.313 +
17.314 + /**
17.315 + * General category "Pc" in the Unicode specification.
17.316 + * @since 1.1
17.317 + */
17.318 + public static final byte CONNECTOR_PUNCTUATION = 23;
17.319 +
17.320 + /**
17.321 + * General category "Po" in the Unicode specification.
17.322 + * @since 1.1
17.323 + */
17.324 + public static final byte OTHER_PUNCTUATION = 24;
17.325 +
17.326 + /**
17.327 + * General category "Sm" in the Unicode specification.
17.328 + * @since 1.1
17.329 + */
17.330 + public static final byte MATH_SYMBOL = 25;
17.331 +
17.332 + /**
17.333 + * General category "Sc" in the Unicode specification.
17.334 + * @since 1.1
17.335 + */
17.336 + public static final byte CURRENCY_SYMBOL = 26;
17.337 +
17.338 + /**
17.339 + * General category "Sk" in the Unicode specification.
17.340 + * @since 1.1
17.341 + */
17.342 + public static final byte MODIFIER_SYMBOL = 27;
17.343 +
17.344 + /**
17.345 + * General category "So" in the Unicode specification.
17.346 + * @since 1.1
17.347 + */
17.348 + public static final byte OTHER_SYMBOL = 28;
17.349 +
17.350 + /**
17.351 + * General category "Pi" in the Unicode specification.
17.352 + * @since 1.4
17.353 + */
17.354 + public static final byte INITIAL_QUOTE_PUNCTUATION = 29;
17.355 +
17.356 + /**
17.357 + * General category "Pf" in the Unicode specification.
17.358 + * @since 1.4
17.359 + */
17.360 + public static final byte FINAL_QUOTE_PUNCTUATION = 30;
17.361 +
17.362 + /**
17.363 + * Error flag. Use int (code point) to avoid confusion with U+FFFF.
17.364 + */
17.365 + static final int ERROR = 0xFFFFFFFF;
17.366 +
17.367 +
17.368 + /**
17.369 + * Undefined bidirectional character type. Undefined {@code char}
17.370 + * values have undefined directionality in the Unicode specification.
17.371 + * @since 1.4
17.372 + */
17.373 + public static final byte DIRECTIONALITY_UNDEFINED = -1;
17.374 +
17.375 + /**
17.376 + * Strong bidirectional character type "L" in the Unicode specification.
17.377 + * @since 1.4
17.378 + */
17.379 + public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = 0;
17.380 +
17.381 + /**
17.382 + * Strong bidirectional character type "R" in the Unicode specification.
17.383 + * @since 1.4
17.384 + */
17.385 + public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = 1;
17.386 +
17.387 + /**
17.388 + * Strong bidirectional character type "AL" in the Unicode specification.
17.389 + * @since 1.4
17.390 + */
17.391 + public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = 2;
17.392 +
17.393 + /**
17.394 + * Weak bidirectional character type "EN" in the Unicode specification.
17.395 + * @since 1.4
17.396 + */
17.397 + public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = 3;
17.398 +
17.399 + /**
17.400 + * Weak bidirectional character type "ES" in the Unicode specification.
17.401 + * @since 1.4
17.402 + */
17.403 + public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = 4;
17.404 +
17.405 + /**
17.406 + * Weak bidirectional character type "ET" in the Unicode specification.
17.407 + * @since 1.4
17.408 + */
17.409 + public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = 5;
17.410 +
17.411 + /**
17.412 + * Weak bidirectional character type "AN" in the Unicode specification.
17.413 + * @since 1.4
17.414 + */
17.415 + public static final byte DIRECTIONALITY_ARABIC_NUMBER = 6;
17.416 +
17.417 + /**
17.418 + * Weak bidirectional character type "CS" in the Unicode specification.
17.419 + * @since 1.4
17.420 + */
17.421 + public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = 7;
17.422 +
17.423 + /**
17.424 + * Weak bidirectional character type "NSM" in the Unicode specification.
17.425 + * @since 1.4
17.426 + */
17.427 + public static final byte DIRECTIONALITY_NONSPACING_MARK = 8;
17.428 +
17.429 + /**
17.430 + * Weak bidirectional character type "BN" in the Unicode specification.
17.431 + * @since 1.4
17.432 + */
17.433 + public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL = 9;
17.434 +
17.435 + /**
17.436 + * Neutral bidirectional character type "B" in the Unicode specification.
17.437 + * @since 1.4
17.438 + */
17.439 + public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR = 10;
17.440 +
17.441 + /**
17.442 + * Neutral bidirectional character type "S" in the Unicode specification.
17.443 + * @since 1.4
17.444 + */
17.445 + public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR = 11;
17.446 +
17.447 + /**
17.448 + * Neutral bidirectional character type "WS" in the Unicode specification.
17.449 + * @since 1.4
17.450 + */
17.451 + public static final byte DIRECTIONALITY_WHITESPACE = 12;
17.452 +
17.453 + /**
17.454 + * Neutral bidirectional character type "ON" in the Unicode specification.
17.455 + * @since 1.4
17.456 + */
17.457 + public static final byte DIRECTIONALITY_OTHER_NEUTRALS = 13;
17.458 +
17.459 + /**
17.460 + * Strong bidirectional character type "LRE" in the Unicode specification.
17.461 + * @since 1.4
17.462 + */
17.463 + public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = 14;
17.464 +
17.465 + /**
17.466 + * Strong bidirectional character type "LRO" in the Unicode specification.
17.467 + * @since 1.4
17.468 + */
17.469 + public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = 15;
17.470 +
17.471 + /**
17.472 + * Strong bidirectional character type "RLE" in the Unicode specification.
17.473 + * @since 1.4
17.474 + */
17.475 + public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = 16;
17.476 +
17.477 + /**
17.478 + * Strong bidirectional character type "RLO" in the Unicode specification.
17.479 + * @since 1.4
17.480 + */
17.481 + public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = 17;
17.482 +
17.483 + /**
17.484 + * Weak bidirectional character type "PDF" in the Unicode specification.
17.485 + * @since 1.4
17.486 + */
17.487 + public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = 18;
17.488 +
17.489 + /**
17.490 + * The minimum value of a
17.491 + * <a href="http://www.unicode.org/glossary/#high_surrogate_code_unit">
17.492 + * Unicode high-surrogate code unit</a>
17.493 + * in the UTF-16 encoding, constant {@code '\u005CuD800'}.
17.494 + * A high-surrogate is also known as a <i>leading-surrogate</i>.
17.495 + *
17.496 + * @since 1.5
17.497 + */
17.498 + public static final char MIN_HIGH_SURROGATE = '\uD800';
17.499 +
17.500 + /**
17.501 + * The maximum value of a
17.502 + * <a href="http://www.unicode.org/glossary/#high_surrogate_code_unit">
17.503 + * Unicode high-surrogate code unit</a>
17.504 + * in the UTF-16 encoding, constant {@code '\u005CuDBFF'}.
17.505 + * A high-surrogate is also known as a <i>leading-surrogate</i>.
17.506 + *
17.507 + * @since 1.5
17.508 + */
17.509 + public static final char MAX_HIGH_SURROGATE = '\uDBFF';
17.510 +
17.511 + /**
17.512 + * The minimum value of a
17.513 + * <a href="http://www.unicode.org/glossary/#low_surrogate_code_unit">
17.514 + * Unicode low-surrogate code unit</a>
17.515 + * in the UTF-16 encoding, constant {@code '\u005CuDC00'}.
17.516 + * A low-surrogate is also known as a <i>trailing-surrogate</i>.
17.517 + *
17.518 + * @since 1.5
17.519 + */
17.520 + public static final char MIN_LOW_SURROGATE = '\uDC00';
17.521 +
17.522 + /**
17.523 + * The maximum value of a
17.524 + * <a href="http://www.unicode.org/glossary/#low_surrogate_code_unit">
17.525 + * Unicode low-surrogate code unit</a>
17.526 + * in the UTF-16 encoding, constant {@code '\u005CuDFFF'}.
17.527 + * A low-surrogate is also known as a <i>trailing-surrogate</i>.
17.528 + *
17.529 + * @since 1.5
17.530 + */
17.531 + public static final char MAX_LOW_SURROGATE = '\uDFFF';
17.532 +
17.533 + /**
17.534 + * The minimum value of a Unicode surrogate code unit in the
17.535 + * UTF-16 encoding, constant {@code '\u005CuD800'}.
17.536 + *
17.537 + * @since 1.5
17.538 + */
17.539 + public static final char MIN_SURROGATE = MIN_HIGH_SURROGATE;
17.540 +
17.541 + /**
17.542 + * The maximum value of a Unicode surrogate code unit in the
17.543 + * UTF-16 encoding, constant {@code '\u005CuDFFF'}.
17.544 + *
17.545 + * @since 1.5
17.546 + */
17.547 + public static final char MAX_SURROGATE = MAX_LOW_SURROGATE;
17.548 +
17.549 + /**
17.550 + * The minimum value of a
17.551 + * <a href="http://www.unicode.org/glossary/#supplementary_code_point">
17.552 + * Unicode supplementary code point</a>, constant {@code U+10000}.
17.553 + *
17.554 + * @since 1.5
17.555 + */
17.556 + public static final int MIN_SUPPLEMENTARY_CODE_POINT = 0x010000;
17.557 +
17.558 + /**
17.559 + * The minimum value of a
17.560 + * <a href="http://www.unicode.org/glossary/#code_point">
17.561 + * Unicode code point</a>, constant {@code U+0000}.
17.562 + *
17.563 + * @since 1.5
17.564 + */
17.565 + public static final int MIN_CODE_POINT = 0x000000;
17.566 +
17.567 + /**
17.568 + * The maximum value of a
17.569 + * <a href="http://www.unicode.org/glossary/#code_point">
17.570 + * Unicode code point</a>, constant {@code U+10FFFF}.
17.571 + *
17.572 + * @since 1.5
17.573 + */
17.574 + public static final int MAX_CODE_POINT = 0X10FFFF;
17.575 +
17.576 +
17.577 + /**
17.578 + * Instances of this class represent particular subsets of the Unicode
17.579 + * character set. The only family of subsets defined in the
17.580 + * {@code Character} class is {@link Character.UnicodeBlock}.
17.581 + * Other portions of the Java API may define other subsets for their
17.582 + * own purposes.
17.583 + *
17.584 + * @since 1.2
17.585 + */
17.586 + public static class Subset {
17.587 +
17.588 + private String name;
17.589 +
17.590 + /**
17.591 + * Constructs a new {@code Subset} instance.
17.592 + *
17.593 + * @param name The name of this subset
17.594 + * @exception NullPointerException if name is {@code null}
17.595 + */
17.596 + protected Subset(String name) {
17.597 + if (name == null) {
17.598 + throw new NullPointerException("name");
17.599 + }
17.600 + this.name = name;
17.601 + }
17.602 +
17.603 + /**
17.604 + * Compares two {@code Subset} objects for equality.
17.605 + * This method returns {@code true} if and only if
17.606 + * {@code this} and the argument refer to the same
17.607 + * object; since this method is {@code final}, this
17.608 + * guarantee holds for all subclasses.
17.609 + */
17.610 + public final boolean equals(Object obj) {
17.611 + return (this == obj);
17.612 + }
17.613 +
17.614 + /**
17.615 + * Returns the standard hash code as defined by the
17.616 + * {@link Object#hashCode} method. This method
17.617 + * is {@code final} in order to ensure that the
17.618 + * {@code equals} and {@code hashCode} methods will
17.619 + * be consistent in all subclasses.
17.620 + */
17.621 + public final int hashCode() {
17.622 + return super.hashCode();
17.623 + }
17.624 +
17.625 + /**
17.626 + * Returns the name of this subset.
17.627 + */
17.628 + public final String toString() {
17.629 + return name;
17.630 + }
17.631 + }
17.632 +
17.633 + // See http://www.unicode.org/Public/UNIDATA/Blocks.txt
17.634 + // for the latest specification of Unicode Blocks.
17.635 +
17.636 +
17.637 + /**
17.638 + * The value of the {@code Character}.
17.639 + *
17.640 + * @serial
17.641 + */
17.642 + private final char value;
17.643 +
17.644 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
17.645 + private static final long serialVersionUID = 3786198910865385080L;
17.646 +
17.647 + /**
17.648 + * Constructs a newly allocated {@code Character} object that
17.649 + * represents the specified {@code char} value.
17.650 + *
17.651 + * @param value the value to be represented by the
17.652 + * {@code Character} object.
17.653 + */
17.654 + public Character(char value) {
17.655 + this.value = value;
17.656 + }
17.657 +
17.658 + private static class CharacterCache {
17.659 + private CharacterCache(){}
17.660 +
17.661 + static final Character cache[] = new Character[127 + 1];
17.662 +
17.663 + static {
17.664 + for (int i = 0; i < cache.length; i++)
17.665 + cache[i] = new Character((char)i);
17.666 + }
17.667 + }
17.668 +
17.669 + /**
17.670 + * Returns a <tt>Character</tt> instance representing the specified
17.671 + * <tt>char</tt> value.
17.672 + * If a new <tt>Character</tt> instance is not required, this method
17.673 + * should generally be used in preference to the constructor
17.674 + * {@link #Character(char)}, as this method is likely to yield
17.675 + * significantly better space and time performance by caching
17.676 + * frequently requested values.
17.677 + *
17.678 + * This method will always cache values in the range {@code
17.679 + * '\u005Cu0000'} to {@code '\u005Cu007F'}, inclusive, and may
17.680 + * cache other values outside of this range.
17.681 + *
17.682 + * @param c a char value.
17.683 + * @return a <tt>Character</tt> instance representing <tt>c</tt>.
17.684 + * @since 1.5
17.685 + */
17.686 + public static Character valueOf(char c) {
17.687 + if (c <= 127) { // must cache
17.688 + return CharacterCache.cache[(int)c];
17.689 + }
17.690 + return new Character(c);
17.691 + }
17.692 +
17.693 + /**
17.694 + * Returns the value of this {@code Character} object.
17.695 + * @return the primitive {@code char} value represented by
17.696 + * this object.
17.697 + */
17.698 + public char charValue() {
17.699 + return value;
17.700 + }
17.701 +
17.702 + /**
17.703 + * Returns a hash code for this {@code Character}; equal to the result
17.704 + * of invoking {@code charValue()}.
17.705 + *
17.706 + * @return a hash code value for this {@code Character}
17.707 + */
17.708 + public int hashCode() {
17.709 + return (int)value;
17.710 + }
17.711 +
17.712 + /**
17.713 + * Compares this object against the specified object.
17.714 + * The result is {@code true} if and only if the argument is not
17.715 + * {@code null} and is a {@code Character} object that
17.716 + * represents the same {@code char} value as this object.
17.717 + *
17.718 + * @param obj the object to compare with.
17.719 + * @return {@code true} if the objects are the same;
17.720 + * {@code false} otherwise.
17.721 + */
17.722 + public boolean equals(Object obj) {
17.723 + if (obj instanceof Character) {
17.724 + return value == ((Character)obj).charValue();
17.725 + }
17.726 + return false;
17.727 + }
17.728 +
17.729 + /**
17.730 + * Returns a {@code String} object representing this
17.731 + * {@code Character}'s value. The result is a string of
17.732 + * length 1 whose sole component is the primitive
17.733 + * {@code char} value represented by this
17.734 + * {@code Character} object.
17.735 + *
17.736 + * @return a string representation of this object.
17.737 + */
17.738 + public String toString() {
17.739 + char buf[] = {value};
17.740 + return String.valueOf(buf);
17.741 + }
17.742 +
17.743 + /**
17.744 + * Returns a {@code String} object representing the
17.745 + * specified {@code char}. The result is a string of length
17.746 + * 1 consisting solely of the specified {@code char}.
17.747 + *
17.748 + * @param c the {@code char} to be converted
17.749 + * @return the string representation of the specified {@code char}
17.750 + * @since 1.4
17.751 + */
17.752 + public static String toString(char c) {
17.753 + return String.valueOf(c);
17.754 + }
17.755 +
17.756 + /**
17.757 + * Determines whether the specified code point is a valid
17.758 + * <a href="http://www.unicode.org/glossary/#code_point">
17.759 + * Unicode code point value</a>.
17.760 + *
17.761 + * @param codePoint the Unicode code point to be tested
17.762 + * @return {@code true} if the specified code point value is between
17.763 + * {@link #MIN_CODE_POINT} and
17.764 + * {@link #MAX_CODE_POINT} inclusive;
17.765 + * {@code false} otherwise.
17.766 + * @since 1.5
17.767 + */
17.768 + public static boolean isValidCodePoint(int codePoint) {
17.769 + // Optimized form of:
17.770 + // codePoint >= MIN_CODE_POINT && codePoint <= MAX_CODE_POINT
17.771 + int plane = codePoint >>> 16;
17.772 + return plane < ((MAX_CODE_POINT + 1) >>> 16);
17.773 + }
17.774 +
17.775 + /**
17.776 + * Determines whether the specified character (Unicode code point)
17.777 + * is in the <a href="#BMP">Basic Multilingual Plane (BMP)</a>.
17.778 + * Such code points can be represented using a single {@code char}.
17.779 + *
17.780 + * @param codePoint the character (Unicode code point) to be tested
17.781 + * @return {@code true} if the specified code point is between
17.782 + * {@link #MIN_VALUE} and {@link #MAX_VALUE} inclusive;
17.783 + * {@code false} otherwise.
17.784 + * @since 1.7
17.785 + */
17.786 + public static boolean isBmpCodePoint(int codePoint) {
17.787 + return codePoint >>> 16 == 0;
17.788 + // Optimized form of:
17.789 + // codePoint >= MIN_VALUE && codePoint <= MAX_VALUE
17.790 + // We consistently use logical shift (>>>) to facilitate
17.791 + // additional runtime optimizations.
17.792 + }
17.793 +
17.794 + /**
17.795 + * Determines whether the specified character (Unicode code point)
17.796 + * is in the <a href="#supplementary">supplementary character</a> range.
17.797 + *
17.798 + * @param codePoint the character (Unicode code point) to be tested
17.799 + * @return {@code true} if the specified code point is between
17.800 + * {@link #MIN_SUPPLEMENTARY_CODE_POINT} and
17.801 + * {@link #MAX_CODE_POINT} inclusive;
17.802 + * {@code false} otherwise.
17.803 + * @since 1.5
17.804 + */
17.805 + public static boolean isSupplementaryCodePoint(int codePoint) {
17.806 + return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT
17.807 + && codePoint < MAX_CODE_POINT + 1;
17.808 + }
17.809 +
17.810 + /**
17.811 + * Determines if the given {@code char} value is a
17.812 + * <a href="http://www.unicode.org/glossary/#high_surrogate_code_unit">
17.813 + * Unicode high-surrogate code unit</a>
17.814 + * (also known as <i>leading-surrogate code unit</i>).
17.815 + *
17.816 + * <p>Such values do not represent characters by themselves,
17.817 + * but are used in the representation of
17.818 + * <a href="#supplementary">supplementary characters</a>
17.819 + * in the UTF-16 encoding.
17.820 + *
17.821 + * @param ch the {@code char} value to be tested.
17.822 + * @return {@code true} if the {@code char} value is between
17.823 + * {@link #MIN_HIGH_SURROGATE} and
17.824 + * {@link #MAX_HIGH_SURROGATE} inclusive;
17.825 + * {@code false} otherwise.
17.826 + * @see Character#isLowSurrogate(char)
17.827 + * @see Character.UnicodeBlock#of(int)
17.828 + * @since 1.5
17.829 + */
17.830 + public static boolean isHighSurrogate(char ch) {
17.831 + // Help VM constant-fold; MAX_HIGH_SURROGATE + 1 == MIN_LOW_SURROGATE
17.832 + return ch >= MIN_HIGH_SURROGATE && ch < (MAX_HIGH_SURROGATE + 1);
17.833 + }
17.834 +
17.835 + /**
17.836 + * Determines if the given {@code char} value is a
17.837 + * <a href="http://www.unicode.org/glossary/#low_surrogate_code_unit">
17.838 + * Unicode low-surrogate code unit</a>
17.839 + * (also known as <i>trailing-surrogate code unit</i>).
17.840 + *
17.841 + * <p>Such values do not represent characters by themselves,
17.842 + * but are used in the representation of
17.843 + * <a href="#supplementary">supplementary characters</a>
17.844 + * in the UTF-16 encoding.
17.845 + *
17.846 + * @param ch the {@code char} value to be tested.
17.847 + * @return {@code true} if the {@code char} value is between
17.848 + * {@link #MIN_LOW_SURROGATE} and
17.849 + * {@link #MAX_LOW_SURROGATE} inclusive;
17.850 + * {@code false} otherwise.
17.851 + * @see Character#isHighSurrogate(char)
17.852 + * @since 1.5
17.853 + */
17.854 + public static boolean isLowSurrogate(char ch) {
17.855 + return ch >= MIN_LOW_SURROGATE && ch < (MAX_LOW_SURROGATE + 1);
17.856 + }
17.857 +
17.858 + /**
17.859 + * Determines if the given {@code char} value is a Unicode
17.860 + * <i>surrogate code unit</i>.
17.861 + *
17.862 + * <p>Such values do not represent characters by themselves,
17.863 + * but are used in the representation of
17.864 + * <a href="#supplementary">supplementary characters</a>
17.865 + * in the UTF-16 encoding.
17.866 + *
17.867 + * <p>A char value is a surrogate code unit if and only if it is either
17.868 + * a {@linkplain #isLowSurrogate(char) low-surrogate code unit} or
17.869 + * a {@linkplain #isHighSurrogate(char) high-surrogate code unit}.
17.870 + *
17.871 + * @param ch the {@code char} value to be tested.
17.872 + * @return {@code true} if the {@code char} value is between
17.873 + * {@link #MIN_SURROGATE} and
17.874 + * {@link #MAX_SURROGATE} inclusive;
17.875 + * {@code false} otherwise.
17.876 + * @since 1.7
17.877 + */
17.878 + public static boolean isSurrogate(char ch) {
17.879 + return ch >= MIN_SURROGATE && ch < (MAX_SURROGATE + 1);
17.880 + }
17.881 +
17.882 + /**
17.883 + * Determines whether the specified pair of {@code char}
17.884 + * values is a valid
17.885 + * <a href="http://www.unicode.org/glossary/#surrogate_pair">
17.886 + * Unicode surrogate pair</a>.
17.887 +
17.888 + * <p>This method is equivalent to the expression:
17.889 + * <blockquote><pre>
17.890 + * isHighSurrogate(high) && isLowSurrogate(low)
17.891 + * </pre></blockquote>
17.892 + *
17.893 + * @param high the high-surrogate code value to be tested
17.894 + * @param low the low-surrogate code value to be tested
17.895 + * @return {@code true} if the specified high and
17.896 + * low-surrogate code values represent a valid surrogate pair;
17.897 + * {@code false} otherwise.
17.898 + * @since 1.5
17.899 + */
17.900 + public static boolean isSurrogatePair(char high, char low) {
17.901 + return isHighSurrogate(high) && isLowSurrogate(low);
17.902 + }
17.903 +
17.904 + /**
17.905 + * Determines the number of {@code char} values needed to
17.906 + * represent the specified character (Unicode code point). If the
17.907 + * specified character is equal to or greater than 0x10000, then
17.908 + * the method returns 2. Otherwise, the method returns 1.
17.909 + *
17.910 + * <p>This method doesn't validate the specified character to be a
17.911 + * valid Unicode code point. The caller must validate the
17.912 + * character value using {@link #isValidCodePoint(int) isValidCodePoint}
17.913 + * if necessary.
17.914 + *
17.915 + * @param codePoint the character (Unicode code point) to be tested.
17.916 + * @return 2 if the character is a valid supplementary character; 1 otherwise.
17.917 + * @see Character#isSupplementaryCodePoint(int)
17.918 + * @since 1.5
17.919 + */
17.920 + public static int charCount(int codePoint) {
17.921 + return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT ? 2 : 1;
17.922 + }
17.923 +
17.924 + /**
17.925 + * Converts the specified surrogate pair to its supplementary code
17.926 + * point value. This method does not validate the specified
17.927 + * surrogate pair. The caller must validate it using {@link
17.928 + * #isSurrogatePair(char, char) isSurrogatePair} if necessary.
17.929 + *
17.930 + * @param high the high-surrogate code unit
17.931 + * @param low the low-surrogate code unit
17.932 + * @return the supplementary code point composed from the
17.933 + * specified surrogate pair.
17.934 + * @since 1.5
17.935 + */
17.936 + public static int toCodePoint(char high, char low) {
17.937 + // Optimized form of:
17.938 + // return ((high - MIN_HIGH_SURROGATE) << 10)
17.939 + // + (low - MIN_LOW_SURROGATE)
17.940 + // + MIN_SUPPLEMENTARY_CODE_POINT;
17.941 + return ((high << 10) + low) + (MIN_SUPPLEMENTARY_CODE_POINT
17.942 + - (MIN_HIGH_SURROGATE << 10)
17.943 + - MIN_LOW_SURROGATE);
17.944 + }
17.945 +
17.946 + /**
17.947 + * Returns the code point at the given index of the
17.948 + * {@code CharSequence}. If the {@code char} value at
17.949 + * the given index in the {@code CharSequence} is in the
17.950 + * high-surrogate range, the following index is less than the
17.951 + * length of the {@code CharSequence}, and the
17.952 + * {@code char} value at the following index is in the
17.953 + * low-surrogate range, then the supplementary code point
17.954 + * corresponding to this surrogate pair is returned. Otherwise,
17.955 + * the {@code char} value at the given index is returned.
17.956 + *
17.957 + * @param seq a sequence of {@code char} values (Unicode code
17.958 + * units)
17.959 + * @param index the index to the {@code char} values (Unicode
17.960 + * code units) in {@code seq} to be converted
17.961 + * @return the Unicode code point at the given index
17.962 + * @exception NullPointerException if {@code seq} is null.
17.963 + * @exception IndexOutOfBoundsException if the value
17.964 + * {@code index} is negative or not less than
17.965 + * {@link CharSequence#length() seq.length()}.
17.966 + * @since 1.5
17.967 + */
17.968 + public static int codePointAt(CharSequence seq, int index) {
17.969 + char c1 = seq.charAt(index++);
17.970 + if (isHighSurrogate(c1)) {
17.971 + if (index < seq.length()) {
17.972 + char c2 = seq.charAt(index);
17.973 + if (isLowSurrogate(c2)) {
17.974 + return toCodePoint(c1, c2);
17.975 + }
17.976 + }
17.977 + }
17.978 + return c1;
17.979 + }
17.980 +
17.981 + /**
17.982 + * Returns the code point at the given index of the
17.983 + * {@code char} array. If the {@code char} value at
17.984 + * the given index in the {@code char} array is in the
17.985 + * high-surrogate range, the following index is less than the
17.986 + * length of the {@code char} array, and the
17.987 + * {@code char} value at the following index is in the
17.988 + * low-surrogate range, then the supplementary code point
17.989 + * corresponding to this surrogate pair is returned. Otherwise,
17.990 + * the {@code char} value at the given index is returned.
17.991 + *
17.992 + * @param a the {@code char} array
17.993 + * @param index the index to the {@code char} values (Unicode
17.994 + * code units) in the {@code char} array to be converted
17.995 + * @return the Unicode code point at the given index
17.996 + * @exception NullPointerException if {@code a} is null.
17.997 + * @exception IndexOutOfBoundsException if the value
17.998 + * {@code index} is negative or not less than
17.999 + * the length of the {@code char} array.
17.1000 + * @since 1.5
17.1001 + */
17.1002 + public static int codePointAt(char[] a, int index) {
17.1003 + return codePointAtImpl(a, index, a.length);
17.1004 + }
17.1005 +
17.1006 + /**
17.1007 + * Returns the code point at the given index of the
17.1008 + * {@code char} array, where only array elements with
17.1009 + * {@code index} less than {@code limit} can be used. If
17.1010 + * the {@code char} value at the given index in the
17.1011 + * {@code char} array is in the high-surrogate range, the
17.1012 + * following index is less than the {@code limit}, and the
17.1013 + * {@code char} value at the following index is in the
17.1014 + * low-surrogate range, then the supplementary code point
17.1015 + * corresponding to this surrogate pair is returned. Otherwise,
17.1016 + * the {@code char} value at the given index is returned.
17.1017 + *
17.1018 + * @param a the {@code char} array
17.1019 + * @param index the index to the {@code char} values (Unicode
17.1020 + * code units) in the {@code char} array to be converted
17.1021 + * @param limit the index after the last array element that
17.1022 + * can be used in the {@code char} array
17.1023 + * @return the Unicode code point at the given index
17.1024 + * @exception NullPointerException if {@code a} is null.
17.1025 + * @exception IndexOutOfBoundsException if the {@code index}
17.1026 + * argument is negative or not less than the {@code limit}
17.1027 + * argument, or if the {@code limit} argument is negative or
17.1028 + * greater than the length of the {@code char} array.
17.1029 + * @since 1.5
17.1030 + */
17.1031 + public static int codePointAt(char[] a, int index, int limit) {
17.1032 + if (index >= limit || limit < 0 || limit > a.length) {
17.1033 + throw new IndexOutOfBoundsException();
17.1034 + }
17.1035 + return codePointAtImpl(a, index, limit);
17.1036 + }
17.1037 +
17.1038 + // throws ArrayIndexOutofBoundsException if index out of bounds
17.1039 + static int codePointAtImpl(char[] a, int index, int limit) {
17.1040 + char c1 = a[index++];
17.1041 + if (isHighSurrogate(c1)) {
17.1042 + if (index < limit) {
17.1043 + char c2 = a[index];
17.1044 + if (isLowSurrogate(c2)) {
17.1045 + return toCodePoint(c1, c2);
17.1046 + }
17.1047 + }
17.1048 + }
17.1049 + return c1;
17.1050 + }
17.1051 +
17.1052 + /**
17.1053 + * Returns the code point preceding the given index of the
17.1054 + * {@code CharSequence}. If the {@code char} value at
17.1055 + * {@code (index - 1)} in the {@code CharSequence} is in
17.1056 + * the low-surrogate range, {@code (index - 2)} is not
17.1057 + * negative, and the {@code char} value at {@code (index - 2)}
17.1058 + * in the {@code CharSequence} is in the
17.1059 + * high-surrogate range, then the supplementary code point
17.1060 + * corresponding to this surrogate pair is returned. Otherwise,
17.1061 + * the {@code char} value at {@code (index - 1)} is
17.1062 + * returned.
17.1063 + *
17.1064 + * @param seq the {@code CharSequence} instance
17.1065 + * @param index the index following the code point that should be returned
17.1066 + * @return the Unicode code point value before the given index.
17.1067 + * @exception NullPointerException if {@code seq} is null.
17.1068 + * @exception IndexOutOfBoundsException if the {@code index}
17.1069 + * argument is less than 1 or greater than {@link
17.1070 + * CharSequence#length() seq.length()}.
17.1071 + * @since 1.5
17.1072 + */
17.1073 + public static int codePointBefore(CharSequence seq, int index) {
17.1074 + char c2 = seq.charAt(--index);
17.1075 + if (isLowSurrogate(c2)) {
17.1076 + if (index > 0) {
17.1077 + char c1 = seq.charAt(--index);
17.1078 + if (isHighSurrogate(c1)) {
17.1079 + return toCodePoint(c1, c2);
17.1080 + }
17.1081 + }
17.1082 + }
17.1083 + return c2;
17.1084 + }
17.1085 +
17.1086 + /**
17.1087 + * Returns the code point preceding the given index of the
17.1088 + * {@code char} array. If the {@code char} value at
17.1089 + * {@code (index - 1)} in the {@code char} array is in
17.1090 + * the low-surrogate range, {@code (index - 2)} is not
17.1091 + * negative, and the {@code char} value at {@code (index - 2)}
17.1092 + * in the {@code char} array is in the
17.1093 + * high-surrogate range, then the supplementary code point
17.1094 + * corresponding to this surrogate pair is returned. Otherwise,
17.1095 + * the {@code char} value at {@code (index - 1)} is
17.1096 + * returned.
17.1097 + *
17.1098 + * @param a the {@code char} array
17.1099 + * @param index the index following the code point that should be returned
17.1100 + * @return the Unicode code point value before the given index.
17.1101 + * @exception NullPointerException if {@code a} is null.
17.1102 + * @exception IndexOutOfBoundsException if the {@code index}
17.1103 + * argument is less than 1 or greater than the length of the
17.1104 + * {@code char} array
17.1105 + * @since 1.5
17.1106 + */
17.1107 + public static int codePointBefore(char[] a, int index) {
17.1108 + return codePointBeforeImpl(a, index, 0);
17.1109 + }
17.1110 +
17.1111 + /**
17.1112 + * Returns the code point preceding the given index of the
17.1113 + * {@code char} array, where only array elements with
17.1114 + * {@code index} greater than or equal to {@code start}
17.1115 + * can be used. If the {@code char} value at {@code (index - 1)}
17.1116 + * in the {@code char} array is in the
17.1117 + * low-surrogate range, {@code (index - 2)} is not less than
17.1118 + * {@code start}, and the {@code char} value at
17.1119 + * {@code (index - 2)} in the {@code char} array is in
17.1120 + * the high-surrogate range, then the supplementary code point
17.1121 + * corresponding to this surrogate pair is returned. Otherwise,
17.1122 + * the {@code char} value at {@code (index - 1)} is
17.1123 + * returned.
17.1124 + *
17.1125 + * @param a the {@code char} array
17.1126 + * @param index the index following the code point that should be returned
17.1127 + * @param start the index of the first array element in the
17.1128 + * {@code char} array
17.1129 + * @return the Unicode code point value before the given index.
17.1130 + * @exception NullPointerException if {@code a} is null.
17.1131 + * @exception IndexOutOfBoundsException if the {@code index}
17.1132 + * argument is not greater than the {@code start} argument or
17.1133 + * is greater than the length of the {@code char} array, or
17.1134 + * if the {@code start} argument is negative or not less than
17.1135 + * the length of the {@code char} array.
17.1136 + * @since 1.5
17.1137 + */
17.1138 + public static int codePointBefore(char[] a, int index, int start) {
17.1139 + if (index <= start || start < 0 || start >= a.length) {
17.1140 + throw new IndexOutOfBoundsException();
17.1141 + }
17.1142 + return codePointBeforeImpl(a, index, start);
17.1143 + }
17.1144 +
17.1145 + // throws ArrayIndexOutofBoundsException if index-1 out of bounds
17.1146 + static int codePointBeforeImpl(char[] a, int index, int start) {
17.1147 + char c2 = a[--index];
17.1148 + if (isLowSurrogate(c2)) {
17.1149 + if (index > start) {
17.1150 + char c1 = a[--index];
17.1151 + if (isHighSurrogate(c1)) {
17.1152 + return toCodePoint(c1, c2);
17.1153 + }
17.1154 + }
17.1155 + }
17.1156 + return c2;
17.1157 + }
17.1158 +
17.1159 + /**
17.1160 + * Returns the leading surrogate (a
17.1161 + * <a href="http://www.unicode.org/glossary/#high_surrogate_code_unit">
17.1162 + * high surrogate code unit</a>) of the
17.1163 + * <a href="http://www.unicode.org/glossary/#surrogate_pair">
17.1164 + * surrogate pair</a>
17.1165 + * representing the specified supplementary character (Unicode
17.1166 + * code point) in the UTF-16 encoding. If the specified character
17.1167 + * is not a
17.1168 + * <a href="Character.html#supplementary">supplementary character</a>,
17.1169 + * an unspecified {@code char} is returned.
17.1170 + *
17.1171 + * <p>If
17.1172 + * {@link #isSupplementaryCodePoint isSupplementaryCodePoint(x)}
17.1173 + * is {@code true}, then
17.1174 + * {@link #isHighSurrogate isHighSurrogate}{@code (highSurrogate(x))} and
17.1175 + * {@link #toCodePoint toCodePoint}{@code (highSurrogate(x), }{@link #lowSurrogate lowSurrogate}{@code (x)) == x}
17.1176 + * are also always {@code true}.
17.1177 + *
17.1178 + * @param codePoint a supplementary character (Unicode code point)
17.1179 + * @return the leading surrogate code unit used to represent the
17.1180 + * character in the UTF-16 encoding
17.1181 + * @since 1.7
17.1182 + */
17.1183 + public static char highSurrogate(int codePoint) {
17.1184 + return (char) ((codePoint >>> 10)
17.1185 + + (MIN_HIGH_SURROGATE - (MIN_SUPPLEMENTARY_CODE_POINT >>> 10)));
17.1186 + }
17.1187 +
17.1188 + /**
17.1189 + * Returns the trailing surrogate (a
17.1190 + * <a href="http://www.unicode.org/glossary/#low_surrogate_code_unit">
17.1191 + * low surrogate code unit</a>) of the
17.1192 + * <a href="http://www.unicode.org/glossary/#surrogate_pair">
17.1193 + * surrogate pair</a>
17.1194 + * representing the specified supplementary character (Unicode
17.1195 + * code point) in the UTF-16 encoding. If the specified character
17.1196 + * is not a
17.1197 + * <a href="Character.html#supplementary">supplementary character</a>,
17.1198 + * an unspecified {@code char} is returned.
17.1199 + *
17.1200 + * <p>If
17.1201 + * {@link #isSupplementaryCodePoint isSupplementaryCodePoint(x)}
17.1202 + * is {@code true}, then
17.1203 + * {@link #isLowSurrogate isLowSurrogate}{@code (lowSurrogate(x))} and
17.1204 + * {@link #toCodePoint toCodePoint}{@code (}{@link #highSurrogate highSurrogate}{@code (x), lowSurrogate(x)) == x}
17.1205 + * are also always {@code true}.
17.1206 + *
17.1207 + * @param codePoint a supplementary character (Unicode code point)
17.1208 + * @return the trailing surrogate code unit used to represent the
17.1209 + * character in the UTF-16 encoding
17.1210 + * @since 1.7
17.1211 + */
17.1212 + public static char lowSurrogate(int codePoint) {
17.1213 + return (char) ((codePoint & 0x3ff) + MIN_LOW_SURROGATE);
17.1214 + }
17.1215 +
17.1216 + /**
17.1217 + * Converts the specified character (Unicode code point) to its
17.1218 + * UTF-16 representation. If the specified code point is a BMP
17.1219 + * (Basic Multilingual Plane or Plane 0) value, the same value is
17.1220 + * stored in {@code dst[dstIndex]}, and 1 is returned. If the
17.1221 + * specified code point is a supplementary character, its
17.1222 + * surrogate values are stored in {@code dst[dstIndex]}
17.1223 + * (high-surrogate) and {@code dst[dstIndex+1]}
17.1224 + * (low-surrogate), and 2 is returned.
17.1225 + *
17.1226 + * @param codePoint the character (Unicode code point) to be converted.
17.1227 + * @param dst an array of {@code char} in which the
17.1228 + * {@code codePoint}'s UTF-16 value is stored.
17.1229 + * @param dstIndex the start index into the {@code dst}
17.1230 + * array where the converted value is stored.
17.1231 + * @return 1 if the code point is a BMP code point, 2 if the
17.1232 + * code point is a supplementary code point.
17.1233 + * @exception IllegalArgumentException if the specified
17.1234 + * {@code codePoint} is not a valid Unicode code point.
17.1235 + * @exception NullPointerException if the specified {@code dst} is null.
17.1236 + * @exception IndexOutOfBoundsException if {@code dstIndex}
17.1237 + * is negative or not less than {@code dst.length}, or if
17.1238 + * {@code dst} at {@code dstIndex} doesn't have enough
17.1239 + * array element(s) to store the resulting {@code char}
17.1240 + * value(s). (If {@code dstIndex} is equal to
17.1241 + * {@code dst.length-1} and the specified
17.1242 + * {@code codePoint} is a supplementary character, the
17.1243 + * high-surrogate value is not stored in
17.1244 + * {@code dst[dstIndex]}.)
17.1245 + * @since 1.5
17.1246 + */
17.1247 + public static int toChars(int codePoint, char[] dst, int dstIndex) {
17.1248 + if (isBmpCodePoint(codePoint)) {
17.1249 + dst[dstIndex] = (char) codePoint;
17.1250 + return 1;
17.1251 + } else if (isValidCodePoint(codePoint)) {
17.1252 + toSurrogates(codePoint, dst, dstIndex);
17.1253 + return 2;
17.1254 + } else {
17.1255 + throw new IllegalArgumentException();
17.1256 + }
17.1257 + }
17.1258 +
17.1259 + /**
17.1260 + * Converts the specified character (Unicode code point) to its
17.1261 + * UTF-16 representation stored in a {@code char} array. If
17.1262 + * the specified code point is a BMP (Basic Multilingual Plane or
17.1263 + * Plane 0) value, the resulting {@code char} array has
17.1264 + * the same value as {@code codePoint}. If the specified code
17.1265 + * point is a supplementary code point, the resulting
17.1266 + * {@code char} array has the corresponding surrogate pair.
17.1267 + *
17.1268 + * @param codePoint a Unicode code point
17.1269 + * @return a {@code char} array having
17.1270 + * {@code codePoint}'s UTF-16 representation.
17.1271 + * @exception IllegalArgumentException if the specified
17.1272 + * {@code codePoint} is not a valid Unicode code point.
17.1273 + * @since 1.5
17.1274 + */
17.1275 + public static char[] toChars(int codePoint) {
17.1276 + if (isBmpCodePoint(codePoint)) {
17.1277 + return new char[] { (char) codePoint };
17.1278 + } else if (isValidCodePoint(codePoint)) {
17.1279 + char[] result = new char[2];
17.1280 + toSurrogates(codePoint, result, 0);
17.1281 + return result;
17.1282 + } else {
17.1283 + throw new IllegalArgumentException();
17.1284 + }
17.1285 + }
17.1286 +
17.1287 + static void toSurrogates(int codePoint, char[] dst, int index) {
17.1288 + // We write elements "backwards" to guarantee all-or-nothing
17.1289 + dst[index+1] = lowSurrogate(codePoint);
17.1290 + dst[index] = highSurrogate(codePoint);
17.1291 + }
17.1292 +
17.1293 + /**
17.1294 + * Returns the number of Unicode code points in the text range of
17.1295 + * the specified char sequence. The text range begins at the
17.1296 + * specified {@code beginIndex} and extends to the
17.1297 + * {@code char} at index {@code endIndex - 1}. Thus the
17.1298 + * length (in {@code char}s) of the text range is
17.1299 + * {@code endIndex-beginIndex}. Unpaired surrogates within
17.1300 + * the text range count as one code point each.
17.1301 + *
17.1302 + * @param seq the char sequence
17.1303 + * @param beginIndex the index to the first {@code char} of
17.1304 + * the text range.
17.1305 + * @param endIndex the index after the last {@code char} of
17.1306 + * the text range.
17.1307 + * @return the number of Unicode code points in the specified text
17.1308 + * range
17.1309 + * @exception NullPointerException if {@code seq} is null.
17.1310 + * @exception IndexOutOfBoundsException if the
17.1311 + * {@code beginIndex} is negative, or {@code endIndex}
17.1312 + * is larger than the length of the given sequence, or
17.1313 + * {@code beginIndex} is larger than {@code endIndex}.
17.1314 + * @since 1.5
17.1315 + */
17.1316 + public static int codePointCount(CharSequence seq, int beginIndex, int endIndex) {
17.1317 + int length = seq.length();
17.1318 + if (beginIndex < 0 || endIndex > length || beginIndex > endIndex) {
17.1319 + throw new IndexOutOfBoundsException();
17.1320 + }
17.1321 + int n = endIndex - beginIndex;
17.1322 + for (int i = beginIndex; i < endIndex; ) {
17.1323 + if (isHighSurrogate(seq.charAt(i++)) && i < endIndex &&
17.1324 + isLowSurrogate(seq.charAt(i))) {
17.1325 + n--;
17.1326 + i++;
17.1327 + }
17.1328 + }
17.1329 + return n;
17.1330 + }
17.1331 +
17.1332 + /**
17.1333 + * Returns the number of Unicode code points in a subarray of the
17.1334 + * {@code char} array argument. The {@code offset}
17.1335 + * argument is the index of the first {@code char} of the
17.1336 + * subarray and the {@code count} argument specifies the
17.1337 + * length of the subarray in {@code char}s. Unpaired
17.1338 + * surrogates within the subarray count as one code point each.
17.1339 + *
17.1340 + * @param a the {@code char} array
17.1341 + * @param offset the index of the first {@code char} in the
17.1342 + * given {@code char} array
17.1343 + * @param count the length of the subarray in {@code char}s
17.1344 + * @return the number of Unicode code points in the specified subarray
17.1345 + * @exception NullPointerException if {@code a} is null.
17.1346 + * @exception IndexOutOfBoundsException if {@code offset} or
17.1347 + * {@code count} is negative, or if {@code offset +
17.1348 + * count} is larger than the length of the given array.
17.1349 + * @since 1.5
17.1350 + */
17.1351 + public static int codePointCount(char[] a, int offset, int count) {
17.1352 + if (count > a.length - offset || offset < 0 || count < 0) {
17.1353 + throw new IndexOutOfBoundsException();
17.1354 + }
17.1355 + return codePointCountImpl(a, offset, count);
17.1356 + }
17.1357 +
17.1358 + static int codePointCountImpl(char[] a, int offset, int count) {
17.1359 + int endIndex = offset + count;
17.1360 + int n = count;
17.1361 + for (int i = offset; i < endIndex; ) {
17.1362 + if (isHighSurrogate(a[i++]) && i < endIndex &&
17.1363 + isLowSurrogate(a[i])) {
17.1364 + n--;
17.1365 + i++;
17.1366 + }
17.1367 + }
17.1368 + return n;
17.1369 + }
17.1370 +
17.1371 + /**
17.1372 + * Returns the index within the given char sequence that is offset
17.1373 + * from the given {@code index} by {@code codePointOffset}
17.1374 + * code points. Unpaired surrogates within the text range given by
17.1375 + * {@code index} and {@code codePointOffset} count as
17.1376 + * one code point each.
17.1377 + *
17.1378 + * @param seq the char sequence
17.1379 + * @param index the index to be offset
17.1380 + * @param codePointOffset the offset in code points
17.1381 + * @return the index within the char sequence
17.1382 + * @exception NullPointerException if {@code seq} is null.
17.1383 + * @exception IndexOutOfBoundsException if {@code index}
17.1384 + * is negative or larger then the length of the char sequence,
17.1385 + * or if {@code codePointOffset} is positive and the
17.1386 + * subsequence starting with {@code index} has fewer than
17.1387 + * {@code codePointOffset} code points, or if
17.1388 + * {@code codePointOffset} is negative and the subsequence
17.1389 + * before {@code index} has fewer than the absolute value
17.1390 + * of {@code codePointOffset} code points.
17.1391 + * @since 1.5
17.1392 + */
17.1393 + public static int offsetByCodePoints(CharSequence seq, int index,
17.1394 + int codePointOffset) {
17.1395 + int length = seq.length();
17.1396 + if (index < 0 || index > length) {
17.1397 + throw new IndexOutOfBoundsException();
17.1398 + }
17.1399 +
17.1400 + int x = index;
17.1401 + if (codePointOffset >= 0) {
17.1402 + int i;
17.1403 + for (i = 0; x < length && i < codePointOffset; i++) {
17.1404 + if (isHighSurrogate(seq.charAt(x++)) && x < length &&
17.1405 + isLowSurrogate(seq.charAt(x))) {
17.1406 + x++;
17.1407 + }
17.1408 + }
17.1409 + if (i < codePointOffset) {
17.1410 + throw new IndexOutOfBoundsException();
17.1411 + }
17.1412 + } else {
17.1413 + int i;
17.1414 + for (i = codePointOffset; x > 0 && i < 0; i++) {
17.1415 + if (isLowSurrogate(seq.charAt(--x)) && x > 0 &&
17.1416 + isHighSurrogate(seq.charAt(x-1))) {
17.1417 + x--;
17.1418 + }
17.1419 + }
17.1420 + if (i < 0) {
17.1421 + throw new IndexOutOfBoundsException();
17.1422 + }
17.1423 + }
17.1424 + return x;
17.1425 + }
17.1426 +
17.1427 + /**
17.1428 + * Returns the index within the given {@code char} subarray
17.1429 + * that is offset from the given {@code index} by
17.1430 + * {@code codePointOffset} code points. The
17.1431 + * {@code start} and {@code count} arguments specify a
17.1432 + * subarray of the {@code char} array. Unpaired surrogates
17.1433 + * within the text range given by {@code index} and
17.1434 + * {@code codePointOffset} count as one code point each.
17.1435 + *
17.1436 + * @param a the {@code char} array
17.1437 + * @param start the index of the first {@code char} of the
17.1438 + * subarray
17.1439 + * @param count the length of the subarray in {@code char}s
17.1440 + * @param index the index to be offset
17.1441 + * @param codePointOffset the offset in code points
17.1442 + * @return the index within the subarray
17.1443 + * @exception NullPointerException if {@code a} is null.
17.1444 + * @exception IndexOutOfBoundsException
17.1445 + * if {@code start} or {@code count} is negative,
17.1446 + * or if {@code start + count} is larger than the length of
17.1447 + * the given array,
17.1448 + * or if {@code index} is less than {@code start} or
17.1449 + * larger then {@code start + count},
17.1450 + * or if {@code codePointOffset} is positive and the text range
17.1451 + * starting with {@code index} and ending with {@code start + count - 1}
17.1452 + * has fewer than {@code codePointOffset} code
17.1453 + * points,
17.1454 + * or if {@code codePointOffset} is negative and the text range
17.1455 + * starting with {@code start} and ending with {@code index - 1}
17.1456 + * has fewer than the absolute value of
17.1457 + * {@code codePointOffset} code points.
17.1458 + * @since 1.5
17.1459 + */
17.1460 + public static int offsetByCodePoints(char[] a, int start, int count,
17.1461 + int index, int codePointOffset) {
17.1462 + if (count > a.length-start || start < 0 || count < 0
17.1463 + || index < start || index > start+count) {
17.1464 + throw new IndexOutOfBoundsException();
17.1465 + }
17.1466 + return offsetByCodePointsImpl(a, start, count, index, codePointOffset);
17.1467 + }
17.1468 +
17.1469 + static int offsetByCodePointsImpl(char[]a, int start, int count,
17.1470 + int index, int codePointOffset) {
17.1471 + int x = index;
17.1472 + if (codePointOffset >= 0) {
17.1473 + int limit = start + count;
17.1474 + int i;
17.1475 + for (i = 0; x < limit && i < codePointOffset; i++) {
17.1476 + if (isHighSurrogate(a[x++]) && x < limit &&
17.1477 + isLowSurrogate(a[x])) {
17.1478 + x++;
17.1479 + }
17.1480 + }
17.1481 + if (i < codePointOffset) {
17.1482 + throw new IndexOutOfBoundsException();
17.1483 + }
17.1484 + } else {
17.1485 + int i;
17.1486 + for (i = codePointOffset; x > start && i < 0; i++) {
17.1487 + if (isLowSurrogate(a[--x]) && x > start &&
17.1488 + isHighSurrogate(a[x-1])) {
17.1489 + x--;
17.1490 + }
17.1491 + }
17.1492 + if (i < 0) {
17.1493 + throw new IndexOutOfBoundsException();
17.1494 + }
17.1495 + }
17.1496 + return x;
17.1497 + }
17.1498 +
17.1499 + /**
17.1500 + * Determines if the specified character is a lowercase character.
17.1501 + * <p>
17.1502 + * A character is lowercase if its general category type, provided
17.1503 + * by {@code Character.getType(ch)}, is
17.1504 + * {@code LOWERCASE_LETTER}, or it has contributory property
17.1505 + * Other_Lowercase as defined by the Unicode Standard.
17.1506 + * <p>
17.1507 + * The following are examples of lowercase characters:
17.1508 + * <p><blockquote><pre>
17.1509 + * 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
17.1510 + * '\u00DF' '\u00E0' '\u00E1' '\u00E2' '\u00E3' '\u00E4' '\u00E5' '\u00E6'
17.1511 + * '\u00E7' '\u00E8' '\u00E9' '\u00EA' '\u00EB' '\u00EC' '\u00ED' '\u00EE'
17.1512 + * '\u00EF' '\u00F0' '\u00F1' '\u00F2' '\u00F3' '\u00F4' '\u00F5' '\u00F6'
17.1513 + * '\u00F8' '\u00F9' '\u00FA' '\u00FB' '\u00FC' '\u00FD' '\u00FE' '\u00FF'
17.1514 + * </pre></blockquote>
17.1515 + * <p> Many other Unicode characters are lowercase too.
17.1516 + *
17.1517 + * <p><b>Note:</b> This method cannot handle <a
17.1518 + * href="#supplementary"> supplementary characters</a>. To support
17.1519 + * all Unicode characters, including supplementary characters, use
17.1520 + * the {@link #isLowerCase(int)} method.
17.1521 + *
17.1522 + * @param ch the character to be tested.
17.1523 + * @return {@code true} if the character is lowercase;
17.1524 + * {@code false} otherwise.
17.1525 + * @see Character#isLowerCase(char)
17.1526 + * @see Character#isTitleCase(char)
17.1527 + * @see Character#toLowerCase(char)
17.1528 + * @see Character#getType(char)
17.1529 + */
17.1530 + public static boolean isLowerCase(char ch) {
17.1531 + throw new UnsupportedOperationException();
17.1532 + }
17.1533 +
17.1534 + /**
17.1535 + * Determines if the specified character is an uppercase character.
17.1536 + * <p>
17.1537 + * A character is uppercase if its general category type, provided by
17.1538 + * {@code Character.getType(ch)}, is {@code UPPERCASE_LETTER}.
17.1539 + * or it has contributory property Other_Uppercase as defined by the Unicode Standard.
17.1540 + * <p>
17.1541 + * The following are examples of uppercase characters:
17.1542 + * <p><blockquote><pre>
17.1543 + * 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
17.1544 + * '\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7'
17.1545 + * '\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF'
17.1546 + * '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8'
17.1547 + * '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'
17.1548 + * </pre></blockquote>
17.1549 + * <p> Many other Unicode characters are uppercase too.<p>
17.1550 + *
17.1551 + * <p><b>Note:</b> This method cannot handle <a
17.1552 + * href="#supplementary"> supplementary characters</a>. To support
17.1553 + * all Unicode characters, including supplementary characters, use
17.1554 + * the {@link #isUpperCase(int)} method.
17.1555 + *
17.1556 + * @param ch the character to be tested.
17.1557 + * @return {@code true} if the character is uppercase;
17.1558 + * {@code false} otherwise.
17.1559 + * @see Character#isLowerCase(char)
17.1560 + * @see Character#isTitleCase(char)
17.1561 + * @see Character#toUpperCase(char)
17.1562 + * @see Character#getType(char)
17.1563 + * @since 1.0
17.1564 + */
17.1565 + public static boolean isUpperCase(char ch) {
17.1566 + throw new UnsupportedOperationException();
17.1567 + }
17.1568 +
17.1569 + /**
17.1570 + * Determines if the specified character is a titlecase character.
17.1571 + * <p>
17.1572 + * A character is a titlecase character if its general
17.1573 + * category type, provided by {@code Character.getType(ch)},
17.1574 + * is {@code TITLECASE_LETTER}.
17.1575 + * <p>
17.1576 + * Some characters look like pairs of Latin letters. For example, there
17.1577 + * is an uppercase letter that looks like "LJ" and has a corresponding
17.1578 + * lowercase letter that looks like "lj". A third form, which looks like "Lj",
17.1579 + * is the appropriate form to use when rendering a word in lowercase
17.1580 + * with initial capitals, as for a book title.
17.1581 + * <p>
17.1582 + * These are some of the Unicode characters for which this method returns
17.1583 + * {@code true}:
17.1584 + * <ul>
17.1585 + * <li>{@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON}
17.1586 + * <li>{@code LATIN CAPITAL LETTER L WITH SMALL LETTER J}
17.1587 + * <li>{@code LATIN CAPITAL LETTER N WITH SMALL LETTER J}
17.1588 + * <li>{@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z}
17.1589 + * </ul>
17.1590 + * <p> Many other Unicode characters are titlecase too.<p>
17.1591 + *
17.1592 + * <p><b>Note:</b> This method cannot handle <a
17.1593 + * href="#supplementary"> supplementary characters</a>. To support
17.1594 + * all Unicode characters, including supplementary characters, use
17.1595 + * the {@link #isTitleCase(int)} method.
17.1596 + *
17.1597 + * @param ch the character to be tested.
17.1598 + * @return {@code true} if the character is titlecase;
17.1599 + * {@code false} otherwise.
17.1600 + * @see Character#isLowerCase(char)
17.1601 + * @see Character#isUpperCase(char)
17.1602 + * @see Character#toTitleCase(char)
17.1603 + * @see Character#getType(char)
17.1604 + * @since 1.0.2
17.1605 + */
17.1606 + public static boolean isTitleCase(char ch) {
17.1607 + return isTitleCase((int)ch);
17.1608 + }
17.1609 +
17.1610 + /**
17.1611 + * Determines if the specified character (Unicode code point) is a titlecase character.
17.1612 + * <p>
17.1613 + * A character is a titlecase character if its general
17.1614 + * category type, provided by {@link Character#getType(int) getType(codePoint)},
17.1615 + * is {@code TITLECASE_LETTER}.
17.1616 + * <p>
17.1617 + * Some characters look like pairs of Latin letters. For example, there
17.1618 + * is an uppercase letter that looks like "LJ" and has a corresponding
17.1619 + * lowercase letter that looks like "lj". A third form, which looks like "Lj",
17.1620 + * is the appropriate form to use when rendering a word in lowercase
17.1621 + * with initial capitals, as for a book title.
17.1622 + * <p>
17.1623 + * These are some of the Unicode characters for which this method returns
17.1624 + * {@code true}:
17.1625 + * <ul>
17.1626 + * <li>{@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON}
17.1627 + * <li>{@code LATIN CAPITAL LETTER L WITH SMALL LETTER J}
17.1628 + * <li>{@code LATIN CAPITAL LETTER N WITH SMALL LETTER J}
17.1629 + * <li>{@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z}
17.1630 + * </ul>
17.1631 + * <p> Many other Unicode characters are titlecase too.<p>
17.1632 + *
17.1633 + * @param codePoint the character (Unicode code point) to be tested.
17.1634 + * @return {@code true} if the character is titlecase;
17.1635 + * {@code false} otherwise.
17.1636 + * @see Character#isLowerCase(int)
17.1637 + * @see Character#isUpperCase(int)
17.1638 + * @see Character#toTitleCase(int)
17.1639 + * @see Character#getType(int)
17.1640 + * @since 1.5
17.1641 + */
17.1642 + public static boolean isTitleCase(int codePoint) {
17.1643 + return getType(codePoint) == Character.TITLECASE_LETTER;
17.1644 + }
17.1645 +
17.1646 + /**
17.1647 + * Determines if the specified character is a digit.
17.1648 + * <p>
17.1649 + * A character is a digit if its general category type, provided
17.1650 + * by {@code Character.getType(ch)}, is
17.1651 + * {@code DECIMAL_DIGIT_NUMBER}.
17.1652 + * <p>
17.1653 + * Some Unicode character ranges that contain digits:
17.1654 + * <ul>
17.1655 + * <li>{@code '\u005Cu0030'} through {@code '\u005Cu0039'},
17.1656 + * ISO-LATIN-1 digits ({@code '0'} through {@code '9'})
17.1657 + * <li>{@code '\u005Cu0660'} through {@code '\u005Cu0669'},
17.1658 + * Arabic-Indic digits
17.1659 + * <li>{@code '\u005Cu06F0'} through {@code '\u005Cu06F9'},
17.1660 + * Extended Arabic-Indic digits
17.1661 + * <li>{@code '\u005Cu0966'} through {@code '\u005Cu096F'},
17.1662 + * Devanagari digits
17.1663 + * <li>{@code '\u005CuFF10'} through {@code '\u005CuFF19'},
17.1664 + * Fullwidth digits
17.1665 + * </ul>
17.1666 + *
17.1667 + * Many other character ranges contain digits as well.
17.1668 + *
17.1669 + * <p><b>Note:</b> This method cannot handle <a
17.1670 + * href="#supplementary"> supplementary characters</a>. To support
17.1671 + * all Unicode characters, including supplementary characters, use
17.1672 + * the {@link #isDigit(int)} method.
17.1673 + *
17.1674 + * @param ch the character to be tested.
17.1675 + * @return {@code true} if the character is a digit;
17.1676 + * {@code false} otherwise.
17.1677 + * @see Character#digit(char, int)
17.1678 + * @see Character#forDigit(int, int)
17.1679 + * @see Character#getType(char)
17.1680 + */
17.1681 + public static boolean isDigit(char ch) {
17.1682 + return isDigit((int)ch);
17.1683 + }
17.1684 +
17.1685 + /**
17.1686 + * Determines if the specified character (Unicode code point) is a digit.
17.1687 + * <p>
17.1688 + * A character is a digit if its general category type, provided
17.1689 + * by {@link Character#getType(int) getType(codePoint)}, is
17.1690 + * {@code DECIMAL_DIGIT_NUMBER}.
17.1691 + * <p>
17.1692 + * Some Unicode character ranges that contain digits:
17.1693 + * <ul>
17.1694 + * <li>{@code '\u005Cu0030'} through {@code '\u005Cu0039'},
17.1695 + * ISO-LATIN-1 digits ({@code '0'} through {@code '9'})
17.1696 + * <li>{@code '\u005Cu0660'} through {@code '\u005Cu0669'},
17.1697 + * Arabic-Indic digits
17.1698 + * <li>{@code '\u005Cu06F0'} through {@code '\u005Cu06F9'},
17.1699 + * Extended Arabic-Indic digits
17.1700 + * <li>{@code '\u005Cu0966'} through {@code '\u005Cu096F'},
17.1701 + * Devanagari digits
17.1702 + * <li>{@code '\u005CuFF10'} through {@code '\u005CuFF19'},
17.1703 + * Fullwidth digits
17.1704 + * </ul>
17.1705 + *
17.1706 + * Many other character ranges contain digits as well.
17.1707 + *
17.1708 + * @param codePoint the character (Unicode code point) to be tested.
17.1709 + * @return {@code true} if the character is a digit;
17.1710 + * {@code false} otherwise.
17.1711 + * @see Character#forDigit(int, int)
17.1712 + * @see Character#getType(int)
17.1713 + * @since 1.5
17.1714 + */
17.1715 + public static boolean isDigit(int codePoint) {
17.1716 + return getType(codePoint) == Character.DECIMAL_DIGIT_NUMBER;
17.1717 + }
17.1718 +
17.1719 + /**
17.1720 + * Determines if a character is defined in Unicode.
17.1721 + * <p>
17.1722 + * A character is defined if at least one of the following is true:
17.1723 + * <ul>
17.1724 + * <li>It has an entry in the UnicodeData file.
17.1725 + * <li>It has a value in a range defined by the UnicodeData file.
17.1726 + * </ul>
17.1727 + *
17.1728 + * <p><b>Note:</b> This method cannot handle <a
17.1729 + * href="#supplementary"> supplementary characters</a>. To support
17.1730 + * all Unicode characters, including supplementary characters, use
17.1731 + * the {@link #isDefined(int)} method.
17.1732 + *
17.1733 + * @param ch the character to be tested
17.1734 + * @return {@code true} if the character has a defined meaning
17.1735 + * in Unicode; {@code false} otherwise.
17.1736 + * @see Character#isDigit(char)
17.1737 + * @see Character#isLetter(char)
17.1738 + * @see Character#isLetterOrDigit(char)
17.1739 + * @see Character#isLowerCase(char)
17.1740 + * @see Character#isTitleCase(char)
17.1741 + * @see Character#isUpperCase(char)
17.1742 + * @since 1.0.2
17.1743 + */
17.1744 + public static boolean isDefined(char ch) {
17.1745 + return isDefined((int)ch);
17.1746 + }
17.1747 +
17.1748 + /**
17.1749 + * Determines if a character (Unicode code point) is defined in Unicode.
17.1750 + * <p>
17.1751 + * A character is defined if at least one of the following is true:
17.1752 + * <ul>
17.1753 + * <li>It has an entry in the UnicodeData file.
17.1754 + * <li>It has a value in a range defined by the UnicodeData file.
17.1755 + * </ul>
17.1756 + *
17.1757 + * @param codePoint the character (Unicode code point) to be tested.
17.1758 + * @return {@code true} if the character has a defined meaning
17.1759 + * in Unicode; {@code false} otherwise.
17.1760 + * @see Character#isDigit(int)
17.1761 + * @see Character#isLetter(int)
17.1762 + * @see Character#isLetterOrDigit(int)
17.1763 + * @see Character#isLowerCase(int)
17.1764 + * @see Character#isTitleCase(int)
17.1765 + * @see Character#isUpperCase(int)
17.1766 + * @since 1.5
17.1767 + */
17.1768 + public static boolean isDefined(int codePoint) {
17.1769 + return getType(codePoint) != Character.UNASSIGNED;
17.1770 + }
17.1771 +
17.1772 + /**
17.1773 + * Determines if the specified character is a letter.
17.1774 + * <p>
17.1775 + * A character is considered to be a letter if its general
17.1776 + * category type, provided by {@code Character.getType(ch)},
17.1777 + * is any of the following:
17.1778 + * <ul>
17.1779 + * <li> {@code UPPERCASE_LETTER}
17.1780 + * <li> {@code LOWERCASE_LETTER}
17.1781 + * <li> {@code TITLECASE_LETTER}
17.1782 + * <li> {@code MODIFIER_LETTER}
17.1783 + * <li> {@code OTHER_LETTER}
17.1784 + * </ul>
17.1785 + *
17.1786 + * Not all letters have case. Many characters are
17.1787 + * letters but are neither uppercase nor lowercase nor titlecase.
17.1788 + *
17.1789 + * <p><b>Note:</b> This method cannot handle <a
17.1790 + * href="#supplementary"> supplementary characters</a>. To support
17.1791 + * all Unicode characters, including supplementary characters, use
17.1792 + * the {@link #isLetter(int)} method.
17.1793 + *
17.1794 + * @param ch the character to be tested.
17.1795 + * @return {@code true} if the character is a letter;
17.1796 + * {@code false} otherwise.
17.1797 + * @see Character#isDigit(char)
17.1798 + * @see Character#isJavaIdentifierStart(char)
17.1799 + * @see Character#isJavaLetter(char)
17.1800 + * @see Character#isJavaLetterOrDigit(char)
17.1801 + * @see Character#isLetterOrDigit(char)
17.1802 + * @see Character#isLowerCase(char)
17.1803 + * @see Character#isTitleCase(char)
17.1804 + * @see Character#isUnicodeIdentifierStart(char)
17.1805 + * @see Character#isUpperCase(char)
17.1806 + */
17.1807 + public static boolean isLetter(char ch) {
17.1808 + return isLetter((int)ch);
17.1809 + }
17.1810 +
17.1811 + /**
17.1812 + * Determines if the specified character (Unicode code point) is a letter.
17.1813 + * <p>
17.1814 + * A character is considered to be a letter if its general
17.1815 + * category type, provided by {@link Character#getType(int) getType(codePoint)},
17.1816 + * is any of the following:
17.1817 + * <ul>
17.1818 + * <li> {@code UPPERCASE_LETTER}
17.1819 + * <li> {@code LOWERCASE_LETTER}
17.1820 + * <li> {@code TITLECASE_LETTER}
17.1821 + * <li> {@code MODIFIER_LETTER}
17.1822 + * <li> {@code OTHER_LETTER}
17.1823 + * </ul>
17.1824 + *
17.1825 + * Not all letters have case. Many characters are
17.1826 + * letters but are neither uppercase nor lowercase nor titlecase.
17.1827 + *
17.1828 + * @param codePoint the character (Unicode code point) to be tested.
17.1829 + * @return {@code true} if the character is a letter;
17.1830 + * {@code false} otherwise.
17.1831 + * @see Character#isDigit(int)
17.1832 + * @see Character#isJavaIdentifierStart(int)
17.1833 + * @see Character#isLetterOrDigit(int)
17.1834 + * @see Character#isLowerCase(int)
17.1835 + * @see Character#isTitleCase(int)
17.1836 + * @see Character#isUnicodeIdentifierStart(int)
17.1837 + * @see Character#isUpperCase(int)
17.1838 + * @since 1.5
17.1839 + */
17.1840 + public static boolean isLetter(int codePoint) {
17.1841 + return ((((1 << Character.UPPERCASE_LETTER) |
17.1842 + (1 << Character.LOWERCASE_LETTER) |
17.1843 + (1 << Character.TITLECASE_LETTER) |
17.1844 + (1 << Character.MODIFIER_LETTER) |
17.1845 + (1 << Character.OTHER_LETTER)) >> getType(codePoint)) & 1)
17.1846 + != 0;
17.1847 + }
17.1848 +
17.1849 + /**
17.1850 + * Determines if the specified character is a letter or digit.
17.1851 + * <p>
17.1852 + * A character is considered to be a letter or digit if either
17.1853 + * {@code Character.isLetter(char ch)} or
17.1854 + * {@code Character.isDigit(char ch)} returns
17.1855 + * {@code true} for the character.
17.1856 + *
17.1857 + * <p><b>Note:</b> This method cannot handle <a
17.1858 + * href="#supplementary"> supplementary characters</a>. To support
17.1859 + * all Unicode characters, including supplementary characters, use
17.1860 + * the {@link #isLetterOrDigit(int)} method.
17.1861 + *
17.1862 + * @param ch the character to be tested.
17.1863 + * @return {@code true} if the character is a letter or digit;
17.1864 + * {@code false} otherwise.
17.1865 + * @see Character#isDigit(char)
17.1866 + * @see Character#isJavaIdentifierPart(char)
17.1867 + * @see Character#isJavaLetter(char)
17.1868 + * @see Character#isJavaLetterOrDigit(char)
17.1869 + * @see Character#isLetter(char)
17.1870 + * @see Character#isUnicodeIdentifierPart(char)
17.1871 + * @since 1.0.2
17.1872 + */
17.1873 + public static boolean isLetterOrDigit(char ch) {
17.1874 + return isLetterOrDigit((int)ch);
17.1875 + }
17.1876 +
17.1877 + /**
17.1878 + * Determines if the specified character (Unicode code point) is a letter or digit.
17.1879 + * <p>
17.1880 + * A character is considered to be a letter or digit if either
17.1881 + * {@link #isLetter(int) isLetter(codePoint)} or
17.1882 + * {@link #isDigit(int) isDigit(codePoint)} returns
17.1883 + * {@code true} for the character.
17.1884 + *
17.1885 + * @param codePoint the character (Unicode code point) to be tested.
17.1886 + * @return {@code true} if the character is a letter or digit;
17.1887 + * {@code false} otherwise.
17.1888 + * @see Character#isDigit(int)
17.1889 + * @see Character#isJavaIdentifierPart(int)
17.1890 + * @see Character#isLetter(int)
17.1891 + * @see Character#isUnicodeIdentifierPart(int)
17.1892 + * @since 1.5
17.1893 + */
17.1894 + public static boolean isLetterOrDigit(int codePoint) {
17.1895 + return ((((1 << Character.UPPERCASE_LETTER) |
17.1896 + (1 << Character.LOWERCASE_LETTER) |
17.1897 + (1 << Character.TITLECASE_LETTER) |
17.1898 + (1 << Character.MODIFIER_LETTER) |
17.1899 + (1 << Character.OTHER_LETTER) |
17.1900 + (1 << Character.DECIMAL_DIGIT_NUMBER)) >> getType(codePoint)) & 1)
17.1901 + != 0;
17.1902 + }
17.1903 +
17.1904 + static int getType(int x) {
17.1905 + throw new UnsupportedOperationException();
17.1906 + }
17.1907 +
17.1908 + /**
17.1909 + * Converts the character argument to lowercase using case
17.1910 + * mapping information from the UnicodeData file.
17.1911 + * <p>
17.1912 + * Note that
17.1913 + * {@code Character.isLowerCase(Character.toLowerCase(ch))}
17.1914 + * does not always return {@code true} for some ranges of
17.1915 + * characters, particularly those that are symbols or ideographs.
17.1916 + *
17.1917 + * <p>In general, {@link String#toLowerCase()} should be used to map
17.1918 + * characters to lowercase. {@code String} case mapping methods
17.1919 + * have several benefits over {@code Character} case mapping methods.
17.1920 + * {@code String} case mapping methods can perform locale-sensitive
17.1921 + * mappings, context-sensitive mappings, and 1:M character mappings, whereas
17.1922 + * the {@code Character} case mapping methods cannot.
17.1923 + *
17.1924 + * <p><b>Note:</b> This method cannot handle <a
17.1925 + * href="#supplementary"> supplementary characters</a>. To support
17.1926 + * all Unicode characters, including supplementary characters, use
17.1927 + * the {@link #toLowerCase(int)} method.
17.1928 + *
17.1929 + * @param ch the character to be converted.
17.1930 + * @return the lowercase equivalent of the character, if any;
17.1931 + * otherwise, the character itself.
17.1932 + * @see Character#isLowerCase(char)
17.1933 + * @see String#toLowerCase()
17.1934 + */
17.1935 + public static char toLowerCase(char ch) {
17.1936 + throw new UnsupportedOperationException();
17.1937 + }
17.1938 +
17.1939 + /**
17.1940 + * Converts the character argument to uppercase using case mapping
17.1941 + * information from the UnicodeData file.
17.1942 + * <p>
17.1943 + * Note that
17.1944 + * {@code Character.isUpperCase(Character.toUpperCase(ch))}
17.1945 + * does not always return {@code true} for some ranges of
17.1946 + * characters, particularly those that are symbols or ideographs.
17.1947 + *
17.1948 + * <p>In general, {@link String#toUpperCase()} should be used to map
17.1949 + * characters to uppercase. {@code String} case mapping methods
17.1950 + * have several benefits over {@code Character} case mapping methods.
17.1951 + * {@code String} case mapping methods can perform locale-sensitive
17.1952 + * mappings, context-sensitive mappings, and 1:M character mappings, whereas
17.1953 + * the {@code Character} case mapping methods cannot.
17.1954 + *
17.1955 + * <p><b>Note:</b> This method cannot handle <a
17.1956 + * href="#supplementary"> supplementary characters</a>. To support
17.1957 + * all Unicode characters, including supplementary characters, use
17.1958 + * the {@link #toUpperCase(int)} method.
17.1959 + *
17.1960 + * @param ch the character to be converted.
17.1961 + * @return the uppercase equivalent of the character, if any;
17.1962 + * otherwise, the character itself.
17.1963 + * @see Character#isUpperCase(char)
17.1964 + * @see String#toUpperCase()
17.1965 + */
17.1966 + public static char toUpperCase(char ch) {
17.1967 + throw new UnsupportedOperationException();
17.1968 + }
17.1969 +
17.1970 + /**
17.1971 + * Returns the numeric value of the character {@code ch} in the
17.1972 + * specified radix.
17.1973 + * <p>
17.1974 + * If the radix is not in the range {@code MIN_RADIX} ≤
17.1975 + * {@code radix} ≤ {@code MAX_RADIX} or if the
17.1976 + * value of {@code ch} is not a valid digit in the specified
17.1977 + * radix, {@code -1} is returned. A character is a valid digit
17.1978 + * if at least one of the following is true:
17.1979 + * <ul>
17.1980 + * <li>The method {@code isDigit} is {@code true} of the character
17.1981 + * and the Unicode decimal digit value of the character (or its
17.1982 + * single-character decomposition) is less than the specified radix.
17.1983 + * In this case the decimal digit value is returned.
17.1984 + * <li>The character is one of the uppercase Latin letters
17.1985 + * {@code 'A'} through {@code 'Z'} and its code is less than
17.1986 + * {@code radix + 'A' - 10}.
17.1987 + * In this case, {@code ch - 'A' + 10}
17.1988 + * is returned.
17.1989 + * <li>The character is one of the lowercase Latin letters
17.1990 + * {@code 'a'} through {@code 'z'} and its code is less than
17.1991 + * {@code radix + 'a' - 10}.
17.1992 + * In this case, {@code ch - 'a' + 10}
17.1993 + * is returned.
17.1994 + * <li>The character is one of the fullwidth uppercase Latin letters A
17.1995 + * ({@code '\u005CuFF21'}) through Z ({@code '\u005CuFF3A'})
17.1996 + * and its code is less than
17.1997 + * {@code radix + '\u005CuFF21' - 10}.
17.1998 + * In this case, {@code ch - '\u005CuFF21' + 10}
17.1999 + * is returned.
17.2000 + * <li>The character is one of the fullwidth lowercase Latin letters a
17.2001 + * ({@code '\u005CuFF41'}) through z ({@code '\u005CuFF5A'})
17.2002 + * and its code is less than
17.2003 + * {@code radix + '\u005CuFF41' - 10}.
17.2004 + * In this case, {@code ch - '\u005CuFF41' + 10}
17.2005 + * is returned.
17.2006 + * </ul>
17.2007 + *
17.2008 + * <p><b>Note:</b> This method cannot handle <a
17.2009 + * href="#supplementary"> supplementary characters</a>. To support
17.2010 + * all Unicode characters, including supplementary characters, use
17.2011 + * the {@link #digit(int, int)} method.
17.2012 + *
17.2013 + * @param ch the character to be converted.
17.2014 + * @param radix the radix.
17.2015 + * @return the numeric value represented by the character in the
17.2016 + * specified radix.
17.2017 + * @see Character#forDigit(int, int)
17.2018 + * @see Character#isDigit(char)
17.2019 + */
17.2020 + public static int digit(char ch, int radix) {
17.2021 + return digit((int)ch, radix);
17.2022 + }
17.2023 +
17.2024 + /**
17.2025 + * Returns the numeric value of the specified character (Unicode
17.2026 + * code point) in the specified radix.
17.2027 + *
17.2028 + * <p>If the radix is not in the range {@code MIN_RADIX} ≤
17.2029 + * {@code radix} ≤ {@code MAX_RADIX} or if the
17.2030 + * character is not a valid digit in the specified
17.2031 + * radix, {@code -1} is returned. A character is a valid digit
17.2032 + * if at least one of the following is true:
17.2033 + * <ul>
17.2034 + * <li>The method {@link #isDigit(int) isDigit(codePoint)} is {@code true} of the character
17.2035 + * and the Unicode decimal digit value of the character (or its
17.2036 + * single-character decomposition) is less than the specified radix.
17.2037 + * In this case the decimal digit value is returned.
17.2038 + * <li>The character is one of the uppercase Latin letters
17.2039 + * {@code 'A'} through {@code 'Z'} and its code is less than
17.2040 + * {@code radix + 'A' - 10}.
17.2041 + * In this case, {@code codePoint - 'A' + 10}
17.2042 + * is returned.
17.2043 + * <li>The character is one of the lowercase Latin letters
17.2044 + * {@code 'a'} through {@code 'z'} and its code is less than
17.2045 + * {@code radix + 'a' - 10}.
17.2046 + * In this case, {@code codePoint - 'a' + 10}
17.2047 + * is returned.
17.2048 + * <li>The character is one of the fullwidth uppercase Latin letters A
17.2049 + * ({@code '\u005CuFF21'}) through Z ({@code '\u005CuFF3A'})
17.2050 + * and its code is less than
17.2051 + * {@code radix + '\u005CuFF21' - 10}.
17.2052 + * In this case,
17.2053 + * {@code codePoint - '\u005CuFF21' + 10}
17.2054 + * is returned.
17.2055 + * <li>The character is one of the fullwidth lowercase Latin letters a
17.2056 + * ({@code '\u005CuFF41'}) through z ({@code '\u005CuFF5A'})
17.2057 + * and its code is less than
17.2058 + * {@code radix + '\u005CuFF41'- 10}.
17.2059 + * In this case,
17.2060 + * {@code codePoint - '\u005CuFF41' + 10}
17.2061 + * is returned.
17.2062 + * </ul>
17.2063 + *
17.2064 + * @param codePoint the character (Unicode code point) to be converted.
17.2065 + * @param radix the radix.
17.2066 + * @return the numeric value represented by the character in the
17.2067 + * specified radix.
17.2068 + * @see Character#forDigit(int, int)
17.2069 + * @see Character#isDigit(int)
17.2070 + * @since 1.5
17.2071 + */
17.2072 + public static int digit(int codePoint, int radix) {
17.2073 + throw new UnsupportedOperationException();
17.2074 + }
17.2075 +
17.2076 + /**
17.2077 + * Returns the {@code int} value that the specified Unicode
17.2078 + * character represents. For example, the character
17.2079 + * {@code '\u005Cu216C'} (the roman numeral fifty) will return
17.2080 + * an int with a value of 50.
17.2081 + * <p>
17.2082 + * The letters A-Z in their uppercase ({@code '\u005Cu0041'} through
17.2083 + * {@code '\u005Cu005A'}), lowercase
17.2084 + * ({@code '\u005Cu0061'} through {@code '\u005Cu007A'}), and
17.2085 + * full width variant ({@code '\u005CuFF21'} through
17.2086 + * {@code '\u005CuFF3A'} and {@code '\u005CuFF41'} through
17.2087 + * {@code '\u005CuFF5A'}) forms have numeric values from 10
17.2088 + * through 35. This is independent of the Unicode specification,
17.2089 + * which does not assign numeric values to these {@code char}
17.2090 + * values.
17.2091 + * <p>
17.2092 + * If the character does not have a numeric value, then -1 is returned.
17.2093 + * If the character has a numeric value that cannot be represented as a
17.2094 + * nonnegative integer (for example, a fractional value), then -2
17.2095 + * is returned.
17.2096 + *
17.2097 + * <p><b>Note:</b> This method cannot handle <a
17.2098 + * href="#supplementary"> supplementary characters</a>. To support
17.2099 + * all Unicode characters, including supplementary characters, use
17.2100 + * the {@link #getNumericValue(int)} method.
17.2101 + *
17.2102 + * @param ch the character to be converted.
17.2103 + * @return the numeric value of the character, as a nonnegative {@code int}
17.2104 + * value; -2 if the character has a numeric value that is not a
17.2105 + * nonnegative integer; -1 if the character has no numeric value.
17.2106 + * @see Character#forDigit(int, int)
17.2107 + * @see Character#isDigit(char)
17.2108 + * @since 1.1
17.2109 + */
17.2110 + public static int getNumericValue(char ch) {
17.2111 + return getNumericValue((int)ch);
17.2112 + }
17.2113 +
17.2114 + /**
17.2115 + * Returns the {@code int} value that the specified
17.2116 + * character (Unicode code point) represents. For example, the character
17.2117 + * {@code '\u005Cu216C'} (the Roman numeral fifty) will return
17.2118 + * an {@code int} with a value of 50.
17.2119 + * <p>
17.2120 + * The letters A-Z in their uppercase ({@code '\u005Cu0041'} through
17.2121 + * {@code '\u005Cu005A'}), lowercase
17.2122 + * ({@code '\u005Cu0061'} through {@code '\u005Cu007A'}), and
17.2123 + * full width variant ({@code '\u005CuFF21'} through
17.2124 + * {@code '\u005CuFF3A'} and {@code '\u005CuFF41'} through
17.2125 + * {@code '\u005CuFF5A'}) forms have numeric values from 10
17.2126 + * through 35. This is independent of the Unicode specification,
17.2127 + * which does not assign numeric values to these {@code char}
17.2128 + * values.
17.2129 + * <p>
17.2130 + * If the character does not have a numeric value, then -1 is returned.
17.2131 + * If the character has a numeric value that cannot be represented as a
17.2132 + * nonnegative integer (for example, a fractional value), then -2
17.2133 + * is returned.
17.2134 + *
17.2135 + * @param codePoint the character (Unicode code point) to be converted.
17.2136 + * @return the numeric value of the character, as a nonnegative {@code int}
17.2137 + * value; -2 if the character has a numeric value that is not a
17.2138 + * nonnegative integer; -1 if the character has no numeric value.
17.2139 + * @see Character#forDigit(int, int)
17.2140 + * @see Character#isDigit(int)
17.2141 + * @since 1.5
17.2142 + */
17.2143 + public static int getNumericValue(int codePoint) {
17.2144 + throw new UnsupportedOperationException();
17.2145 + }
17.2146 +
17.2147 + /**
17.2148 + * Determines if the specified character is ISO-LATIN-1 white space.
17.2149 + * This method returns {@code true} for the following five
17.2150 + * characters only:
17.2151 + * <table>
17.2152 + * <tr><td>{@code '\t'}</td> <td>{@code U+0009}</td>
17.2153 + * <td>{@code HORIZONTAL TABULATION}</td></tr>
17.2154 + * <tr><td>{@code '\n'}</td> <td>{@code U+000A}</td>
17.2155 + * <td>{@code NEW LINE}</td></tr>
17.2156 + * <tr><td>{@code '\f'}</td> <td>{@code U+000C}</td>
17.2157 + * <td>{@code FORM FEED}</td></tr>
17.2158 + * <tr><td>{@code '\r'}</td> <td>{@code U+000D}</td>
17.2159 + * <td>{@code CARRIAGE RETURN}</td></tr>
17.2160 + * <tr><td>{@code ' '}</td> <td>{@code U+0020}</td>
17.2161 + * <td>{@code SPACE}</td></tr>
17.2162 + * </table>
17.2163 + *
17.2164 + * @param ch the character to be tested.
17.2165 + * @return {@code true} if the character is ISO-LATIN-1 white
17.2166 + * space; {@code false} otherwise.
17.2167 + * @see Character#isSpaceChar(char)
17.2168 + * @see Character#isWhitespace(char)
17.2169 + * @deprecated Replaced by isWhitespace(char).
17.2170 + */
17.2171 + @Deprecated
17.2172 + public static boolean isSpace(char ch) {
17.2173 + return (ch <= 0x0020) &&
17.2174 + (((((1L << 0x0009) |
17.2175 + (1L << 0x000A) |
17.2176 + (1L << 0x000C) |
17.2177 + (1L << 0x000D) |
17.2178 + (1L << 0x0020)) >> ch) & 1L) != 0);
17.2179 + }
17.2180 +
17.2181 +
17.2182 +
17.2183 + /**
17.2184 + * Determines if the specified character is white space according to Java.
17.2185 + * A character is a Java whitespace character if and only if it satisfies
17.2186 + * one of the following criteria:
17.2187 + * <ul>
17.2188 + * <li> It is a Unicode space character ({@code SPACE_SEPARATOR},
17.2189 + * {@code LINE_SEPARATOR}, or {@code PARAGRAPH_SEPARATOR})
17.2190 + * but is not also a non-breaking space ({@code '\u005Cu00A0'},
17.2191 + * {@code '\u005Cu2007'}, {@code '\u005Cu202F'}).
17.2192 + * <li> It is {@code '\u005Ct'}, U+0009 HORIZONTAL TABULATION.
17.2193 + * <li> It is {@code '\u005Cn'}, U+000A LINE FEED.
17.2194 + * <li> It is {@code '\u005Cu000B'}, U+000B VERTICAL TABULATION.
17.2195 + * <li> It is {@code '\u005Cf'}, U+000C FORM FEED.
17.2196 + * <li> It is {@code '\u005Cr'}, U+000D CARRIAGE RETURN.
17.2197 + * <li> It is {@code '\u005Cu001C'}, U+001C FILE SEPARATOR.
17.2198 + * <li> It is {@code '\u005Cu001D'}, U+001D GROUP SEPARATOR.
17.2199 + * <li> It is {@code '\u005Cu001E'}, U+001E RECORD SEPARATOR.
17.2200 + * <li> It is {@code '\u005Cu001F'}, U+001F UNIT SEPARATOR.
17.2201 + * </ul>
17.2202 + *
17.2203 + * <p><b>Note:</b> This method cannot handle <a
17.2204 + * href="#supplementary"> supplementary characters</a>. To support
17.2205 + * all Unicode characters, including supplementary characters, use
17.2206 + * the {@link #isWhitespace(int)} method.
17.2207 + *
17.2208 + * @param ch the character to be tested.
17.2209 + * @return {@code true} if the character is a Java whitespace
17.2210 + * character; {@code false} otherwise.
17.2211 + * @see Character#isSpaceChar(char)
17.2212 + * @since 1.1
17.2213 + */
17.2214 + public static boolean isWhitespace(char ch) {
17.2215 + return isWhitespace((int)ch);
17.2216 + }
17.2217 +
17.2218 + /**
17.2219 + * Determines if the specified character (Unicode code point) is
17.2220 + * white space according to Java. A character is a Java
17.2221 + * whitespace character if and only if it satisfies one of the
17.2222 + * following criteria:
17.2223 + * <ul>
17.2224 + * <li> It is a Unicode space character ({@link #SPACE_SEPARATOR},
17.2225 + * {@link #LINE_SEPARATOR}, or {@link #PARAGRAPH_SEPARATOR})
17.2226 + * but is not also a non-breaking space ({@code '\u005Cu00A0'},
17.2227 + * {@code '\u005Cu2007'}, {@code '\u005Cu202F'}).
17.2228 + * <li> It is {@code '\u005Ct'}, U+0009 HORIZONTAL TABULATION.
17.2229 + * <li> It is {@code '\u005Cn'}, U+000A LINE FEED.
17.2230 + * <li> It is {@code '\u005Cu000B'}, U+000B VERTICAL TABULATION.
17.2231 + * <li> It is {@code '\u005Cf'}, U+000C FORM FEED.
17.2232 + * <li> It is {@code '\u005Cr'}, U+000D CARRIAGE RETURN.
17.2233 + * <li> It is {@code '\u005Cu001C'}, U+001C FILE SEPARATOR.
17.2234 + * <li> It is {@code '\u005Cu001D'}, U+001D GROUP SEPARATOR.
17.2235 + * <li> It is {@code '\u005Cu001E'}, U+001E RECORD SEPARATOR.
17.2236 + * <li> It is {@code '\u005Cu001F'}, U+001F UNIT SEPARATOR.
17.2237 + * </ul>
17.2238 + * <p>
17.2239 + *
17.2240 + * @param codePoint the character (Unicode code point) to be tested.
17.2241 + * @return {@code true} if the character is a Java whitespace
17.2242 + * character; {@code false} otherwise.
17.2243 + * @see Character#isSpaceChar(int)
17.2244 + * @since 1.5
17.2245 + */
17.2246 + public static boolean isWhitespace(int codePoint) {
17.2247 + throw new UnsupportedOperationException();
17.2248 + }
17.2249 +
17.2250 + /**
17.2251 + * Determines if the specified character is an ISO control
17.2252 + * character. A character is considered to be an ISO control
17.2253 + * character if its code is in the range {@code '\u005Cu0000'}
17.2254 + * through {@code '\u005Cu001F'} or in the range
17.2255 + * {@code '\u005Cu007F'} through {@code '\u005Cu009F'}.
17.2256 + *
17.2257 + * <p><b>Note:</b> This method cannot handle <a
17.2258 + * href="#supplementary"> supplementary characters</a>. To support
17.2259 + * all Unicode characters, including supplementary characters, use
17.2260 + * the {@link #isISOControl(int)} method.
17.2261 + *
17.2262 + * @param ch the character to be tested.
17.2263 + * @return {@code true} if the character is an ISO control character;
17.2264 + * {@code false} otherwise.
17.2265 + *
17.2266 + * @see Character#isSpaceChar(char)
17.2267 + * @see Character#isWhitespace(char)
17.2268 + * @since 1.1
17.2269 + */
17.2270 + public static boolean isISOControl(char ch) {
17.2271 + return isISOControl((int)ch);
17.2272 + }
17.2273 +
17.2274 + /**
17.2275 + * Determines if the referenced character (Unicode code point) is an ISO control
17.2276 + * character. A character is considered to be an ISO control
17.2277 + * character if its code is in the range {@code '\u005Cu0000'}
17.2278 + * through {@code '\u005Cu001F'} or in the range
17.2279 + * {@code '\u005Cu007F'} through {@code '\u005Cu009F'}.
17.2280 + *
17.2281 + * @param codePoint the character (Unicode code point) to be tested.
17.2282 + * @return {@code true} if the character is an ISO control character;
17.2283 + * {@code false} otherwise.
17.2284 + * @see Character#isSpaceChar(int)
17.2285 + * @see Character#isWhitespace(int)
17.2286 + * @since 1.5
17.2287 + */
17.2288 + public static boolean isISOControl(int codePoint) {
17.2289 + // Optimized form of:
17.2290 + // (codePoint >= 0x00 && codePoint <= 0x1F) ||
17.2291 + // (codePoint >= 0x7F && codePoint <= 0x9F);
17.2292 + return codePoint <= 0x9F &&
17.2293 + (codePoint >= 0x7F || (codePoint >>> 5 == 0));
17.2294 + }
17.2295 +
17.2296 + /**
17.2297 + * Determines the character representation for a specific digit in
17.2298 + * the specified radix. If the value of {@code radix} is not a
17.2299 + * valid radix, or the value of {@code digit} is not a valid
17.2300 + * digit in the specified radix, the null character
17.2301 + * ({@code '\u005Cu0000'}) is returned.
17.2302 + * <p>
17.2303 + * The {@code radix} argument is valid if it is greater than or
17.2304 + * equal to {@code MIN_RADIX} and less than or equal to
17.2305 + * {@code MAX_RADIX}. The {@code digit} argument is valid if
17.2306 + * {@code 0 <= digit < radix}.
17.2307 + * <p>
17.2308 + * If the digit is less than 10, then
17.2309 + * {@code '0' + digit} is returned. Otherwise, the value
17.2310 + * {@code 'a' + digit - 10} is returned.
17.2311 + *
17.2312 + * @param digit the number to convert to a character.
17.2313 + * @param radix the radix.
17.2314 + * @return the {@code char} representation of the specified digit
17.2315 + * in the specified radix.
17.2316 + * @see Character#MIN_RADIX
17.2317 + * @see Character#MAX_RADIX
17.2318 + * @see Character#digit(char, int)
17.2319 + */
17.2320 + public static char forDigit(int digit, int radix) {
17.2321 + if ((digit >= radix) || (digit < 0)) {
17.2322 + return '\0';
17.2323 + }
17.2324 + if ((radix < Character.MIN_RADIX) || (radix > Character.MAX_RADIX)) {
17.2325 + return '\0';
17.2326 + }
17.2327 + if (digit < 10) {
17.2328 + return (char)('0' + digit);
17.2329 + }
17.2330 + return (char)('a' - 10 + digit);
17.2331 + }
17.2332 +
17.2333 + /**
17.2334 + * Compares two {@code Character} objects numerically.
17.2335 + *
17.2336 + * @param anotherCharacter the {@code Character} to be compared.
17.2337 +
17.2338 + * @return the value {@code 0} if the argument {@code Character}
17.2339 + * is equal to this {@code Character}; a value less than
17.2340 + * {@code 0} if this {@code Character} is numerically less
17.2341 + * than the {@code Character} argument; and a value greater than
17.2342 + * {@code 0} if this {@code Character} is numerically greater
17.2343 + * than the {@code Character} argument (unsigned comparison).
17.2344 + * Note that this is strictly a numerical comparison; it is not
17.2345 + * locale-dependent.
17.2346 + * @since 1.2
17.2347 + */
17.2348 + public int compareTo(Character anotherCharacter) {
17.2349 + return compare(this.value, anotherCharacter.value);
17.2350 + }
17.2351 +
17.2352 + /**
17.2353 + * Compares two {@code char} values numerically.
17.2354 + * The value returned is identical to what would be returned by:
17.2355 + * <pre>
17.2356 + * Character.valueOf(x).compareTo(Character.valueOf(y))
17.2357 + * </pre>
17.2358 + *
17.2359 + * @param x the first {@code char} to compare
17.2360 + * @param y the second {@code char} to compare
17.2361 + * @return the value {@code 0} if {@code x == y};
17.2362 + * a value less than {@code 0} if {@code x < y}; and
17.2363 + * a value greater than {@code 0} if {@code x > y}
17.2364 + * @since 1.7
17.2365 + */
17.2366 + public static int compare(char x, char y) {
17.2367 + return x - y;
17.2368 + }
17.2369 +
17.2370 +
17.2371 + /**
17.2372 + * The number of bits used to represent a <tt>char</tt> value in unsigned
17.2373 + * binary form, constant {@code 16}.
17.2374 + *
17.2375 + * @since 1.5
17.2376 + */
17.2377 + public static final int SIZE = 16;
17.2378 +
17.2379 + /**
17.2380 + * Returns the value obtained by reversing the order of the bytes in the
17.2381 + * specified <tt>char</tt> value.
17.2382 + *
17.2383 + * @return the value obtained by reversing (or, equivalently, swapping)
17.2384 + * the bytes in the specified <tt>char</tt> value.
17.2385 + * @since 1.5
17.2386 + */
17.2387 + public static char reverseBytes(char ch) {
17.2388 + return (char) (((ch & 0xFF00) >> 8) | (ch << 8));
17.2389 + }
17.2390 +
17.2391 +}
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
18.2 +++ b/emul/src/main/java/java/lang/Class.java Thu Oct 11 06:16:00 2012 -0700
18.3 @@ -0,0 +1,720 @@
18.4 +/*
18.5 + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
18.7 + *
18.8 + * This code is free software; you can redistribute it and/or modify it
18.9 + * under the terms of the GNU General Public License version 2 only, as
18.10 + * published by the Free Software Foundation. Oracle designates this
18.11 + * particular file as subject to the "Classpath" exception as provided
18.12 + * by Oracle in the LICENSE file that accompanied this code.
18.13 + *
18.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
18.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18.17 + * version 2 for more details (a copy is included in the LICENSE file that
18.18 + * accompanied this code).
18.19 + *
18.20 + * You should have received a copy of the GNU General Public License version
18.21 + * 2 along with this work; if not, write to the Free Software Foundation,
18.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18.23 + *
18.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
18.25 + * or visit www.oracle.com if you need additional information or have any
18.26 + * questions.
18.27 + */
18.28 +
18.29 +package java.lang;
18.30 +
18.31 +import java.lang.annotation.Annotation;
18.32 +
18.33 +/**
18.34 + * Instances of the class {@code Class} represent classes and
18.35 + * interfaces in a running Java application. An enum is a kind of
18.36 + * class and an annotation is a kind of interface. Every array also
18.37 + * belongs to a class that is reflected as a {@code Class} object
18.38 + * that is shared by all arrays with the same element type and number
18.39 + * of dimensions. The primitive Java types ({@code boolean},
18.40 + * {@code byte}, {@code char}, {@code short},
18.41 + * {@code int}, {@code long}, {@code float}, and
18.42 + * {@code double}), and the keyword {@code void} are also
18.43 + * represented as {@code Class} objects.
18.44 + *
18.45 + * <p> {@code Class} has no public constructor. Instead {@code Class}
18.46 + * objects are constructed automatically by the Java Virtual Machine as classes
18.47 + * are loaded and by calls to the {@code defineClass} method in the class
18.48 + * loader.
18.49 + *
18.50 + * <p> The following example uses a {@code Class} object to print the
18.51 + * class name of an object:
18.52 + *
18.53 + * <p> <blockquote><pre>
18.54 + * void printClassName(Object obj) {
18.55 + * System.out.println("The class of " + obj +
18.56 + * " is " + obj.getClass().getName());
18.57 + * }
18.58 + * </pre></blockquote>
18.59 + *
18.60 + * <p> It is also possible to get the {@code Class} object for a named
18.61 + * type (or for void) using a class literal. See Section 15.8.2 of
18.62 + * <cite>The Java™ Language Specification</cite>.
18.63 + * For example:
18.64 + *
18.65 + * <p> <blockquote>
18.66 + * {@code System.out.println("The name of class Foo is: "+Foo.class.getName());}
18.67 + * </blockquote>
18.68 + *
18.69 + * @param <T> the type of the class modeled by this {@code Class}
18.70 + * object. For example, the type of {@code String.class} is {@code
18.71 + * Class<String>}. Use {@code Class<?>} if the class being modeled is
18.72 + * unknown.
18.73 + *
18.74 + * @author unascribed
18.75 + * @see java.lang.ClassLoader#defineClass(byte[], int, int)
18.76 + * @since JDK1.0
18.77 + */
18.78 +public final
18.79 + class Class<T> implements java.io.Serializable {
18.80 +// java.lang.reflect.GenericDeclaration,
18.81 +// java.lang.reflect.Type,
18.82 +// java.lang.reflect.AnnotatedElement {
18.83 + private static final int ANNOTATION= 0x00002000;
18.84 + private static final int ENUM = 0x00004000;
18.85 + private static final int SYNTHETIC = 0x00001000;
18.86 +
18.87 + /*
18.88 + * Constructor. Only the Java Virtual Machine creates Class
18.89 + * objects.
18.90 + */
18.91 + private Class() {}
18.92 +
18.93 +
18.94 + /**
18.95 + * Converts the object to a string. The string representation is the
18.96 + * string "class" or "interface", followed by a space, and then by the
18.97 + * fully qualified name of the class in the format returned by
18.98 + * {@code getName}. If this {@code Class} object represents a
18.99 + * primitive type, this method returns the name of the primitive type. If
18.100 + * this {@code Class} object represents void this method returns
18.101 + * "void".
18.102 + *
18.103 + * @return a string representation of this class object.
18.104 + */
18.105 + public String toString() {
18.106 + return (isInterface() ? "interface " : (isPrimitive() ? "" : "class "))
18.107 + + getName();
18.108 + }
18.109 +
18.110 +
18.111 + /**
18.112 + * Returns the {@code Class} object associated with the class or
18.113 + * interface with the given string name. Invoking this method is
18.114 + * equivalent to:
18.115 + *
18.116 + * <blockquote>
18.117 + * {@code Class.forName(className, true, currentLoader)}
18.118 + * </blockquote>
18.119 + *
18.120 + * where {@code currentLoader} denotes the defining class loader of
18.121 + * the current class.
18.122 + *
18.123 + * <p> For example, the following code fragment returns the
18.124 + * runtime {@code Class} descriptor for the class named
18.125 + * {@code java.lang.Thread}:
18.126 + *
18.127 + * <blockquote>
18.128 + * {@code Class t = Class.forName("java.lang.Thread")}
18.129 + * </blockquote>
18.130 + * <p>
18.131 + * A call to {@code forName("X")} causes the class named
18.132 + * {@code X} to be initialized.
18.133 + *
18.134 + * @param className the fully qualified name of the desired class.
18.135 + * @return the {@code Class} object for the class with the
18.136 + * specified name.
18.137 + * @exception LinkageError if the linkage fails
18.138 + * @exception ExceptionInInitializerError if the initialization provoked
18.139 + * by this method fails
18.140 + * @exception ClassNotFoundException if the class cannot be located
18.141 + */
18.142 + public static Class<?> forName(String className)
18.143 + throws ClassNotFoundException {
18.144 + throw new UnsupportedOperationException();
18.145 + }
18.146 +
18.147 +
18.148 + /**
18.149 + * Creates a new instance of the class represented by this {@code Class}
18.150 + * object. The class is instantiated as if by a {@code new}
18.151 + * expression with an empty argument list. The class is initialized if it
18.152 + * has not already been initialized.
18.153 + *
18.154 + * <p>Note that this method propagates any exception thrown by the
18.155 + * nullary constructor, including a checked exception. Use of
18.156 + * this method effectively bypasses the compile-time exception
18.157 + * checking that would otherwise be performed by the compiler.
18.158 + * The {@link
18.159 + * java.lang.reflect.Constructor#newInstance(java.lang.Object...)
18.160 + * Constructor.newInstance} method avoids this problem by wrapping
18.161 + * any exception thrown by the constructor in a (checked) {@link
18.162 + * java.lang.reflect.InvocationTargetException}.
18.163 + *
18.164 + * @return a newly allocated instance of the class represented by this
18.165 + * object.
18.166 + * @exception IllegalAccessException if the class or its nullary
18.167 + * constructor is not accessible.
18.168 + * @exception InstantiationException
18.169 + * if this {@code Class} represents an abstract class,
18.170 + * an interface, an array class, a primitive type, or void;
18.171 + * or if the class has no nullary constructor;
18.172 + * or if the instantiation fails for some other reason.
18.173 + * @exception ExceptionInInitializerError if the initialization
18.174 + * provoked by this method fails.
18.175 + * @exception SecurityException
18.176 + * If a security manager, <i>s</i>, is present and any of the
18.177 + * following conditions is met:
18.178 + *
18.179 + * <ul>
18.180 + *
18.181 + * <li> invocation of
18.182 + * {@link SecurityManager#checkMemberAccess
18.183 + * s.checkMemberAccess(this, Member.PUBLIC)} denies
18.184 + * creation of new instances of this class
18.185 + *
18.186 + * <li> the caller's class loader is not the same as or an
18.187 + * ancestor of the class loader for the current class and
18.188 + * invocation of {@link SecurityManager#checkPackageAccess
18.189 + * s.checkPackageAccess()} denies access to the package
18.190 + * of this class
18.191 + *
18.192 + * </ul>
18.193 + *
18.194 + */
18.195 + public T newInstance()
18.196 + throws InstantiationException, IllegalAccessException
18.197 + {
18.198 + throw new UnsupportedOperationException("Should be somehow supported");
18.199 + }
18.200 +
18.201 + /**
18.202 + * Determines if the specified {@code Object} is assignment-compatible
18.203 + * with the object represented by this {@code Class}. This method is
18.204 + * the dynamic equivalent of the Java language {@code instanceof}
18.205 + * operator. The method returns {@code true} if the specified
18.206 + * {@code Object} argument is non-null and can be cast to the
18.207 + * reference type represented by this {@code Class} object without
18.208 + * raising a {@code ClassCastException.} It returns {@code false}
18.209 + * otherwise.
18.210 + *
18.211 + * <p> Specifically, if this {@code Class} object represents a
18.212 + * declared class, this method returns {@code true} if the specified
18.213 + * {@code Object} argument is an instance of the represented class (or
18.214 + * of any of its subclasses); it returns {@code false} otherwise. If
18.215 + * this {@code Class} object represents an array class, this method
18.216 + * returns {@code true} if the specified {@code Object} argument
18.217 + * can be converted to an object of the array class by an identity
18.218 + * conversion or by a widening reference conversion; it returns
18.219 + * {@code false} otherwise. If this {@code Class} object
18.220 + * represents an interface, this method returns {@code true} if the
18.221 + * class or any superclass of the specified {@code Object} argument
18.222 + * implements this interface; it returns {@code false} otherwise. If
18.223 + * this {@code Class} object represents a primitive type, this method
18.224 + * returns {@code false}.
18.225 + *
18.226 + * @param obj the object to check
18.227 + * @return true if {@code obj} is an instance of this class
18.228 + *
18.229 + * @since JDK1.1
18.230 + */
18.231 + public native boolean isInstance(Object obj);
18.232 +
18.233 +
18.234 + /**
18.235 + * Determines if the class or interface represented by this
18.236 + * {@code Class} object is either the same as, or is a superclass or
18.237 + * superinterface of, the class or interface represented by the specified
18.238 + * {@code Class} parameter. It returns {@code true} if so;
18.239 + * otherwise it returns {@code false}. If this {@code Class}
18.240 + * object represents a primitive type, this method returns
18.241 + * {@code true} if the specified {@code Class} parameter is
18.242 + * exactly this {@code Class} object; otherwise it returns
18.243 + * {@code false}.
18.244 + *
18.245 + * <p> Specifically, this method tests whether the type represented by the
18.246 + * specified {@code Class} parameter can be converted to the type
18.247 + * represented by this {@code Class} object via an identity conversion
18.248 + * or via a widening reference conversion. See <em>The Java Language
18.249 + * Specification</em>, sections 5.1.1 and 5.1.4 , for details.
18.250 + *
18.251 + * @param cls the {@code Class} object to be checked
18.252 + * @return the {@code boolean} value indicating whether objects of the
18.253 + * type {@code cls} can be assigned to objects of this class
18.254 + * @exception NullPointerException if the specified Class parameter is
18.255 + * null.
18.256 + * @since JDK1.1
18.257 + */
18.258 + public native boolean isAssignableFrom(Class<?> cls);
18.259 +
18.260 +
18.261 + /**
18.262 + * Determines if the specified {@code Class} object represents an
18.263 + * interface type.
18.264 + *
18.265 + * @return {@code true} if this object represents an interface;
18.266 + * {@code false} otherwise.
18.267 + */
18.268 + public native boolean isInterface();
18.269 +
18.270 +
18.271 + /**
18.272 + * Determines if this {@code Class} object represents an array class.
18.273 + *
18.274 + * @return {@code true} if this object represents an array class;
18.275 + * {@code false} otherwise.
18.276 + * @since JDK1.1
18.277 + */
18.278 + public native boolean isArray();
18.279 +
18.280 +
18.281 + /**
18.282 + * Determines if the specified {@code Class} object represents a
18.283 + * primitive type.
18.284 + *
18.285 + * <p> There are nine predefined {@code Class} objects to represent
18.286 + * the eight primitive types and void. These are created by the Java
18.287 + * Virtual Machine, and have the same names as the primitive types that
18.288 + * they represent, namely {@code boolean}, {@code byte},
18.289 + * {@code char}, {@code short}, {@code int},
18.290 + * {@code long}, {@code float}, and {@code double}.
18.291 + *
18.292 + * <p> These objects may only be accessed via the following public static
18.293 + * final variables, and are the only {@code Class} objects for which
18.294 + * this method returns {@code true}.
18.295 + *
18.296 + * @return true if and only if this class represents a primitive type
18.297 + *
18.298 + * @see java.lang.Boolean#TYPE
18.299 + * @see java.lang.Character#TYPE
18.300 + * @see java.lang.Byte#TYPE
18.301 + * @see java.lang.Short#TYPE
18.302 + * @see java.lang.Integer#TYPE
18.303 + * @see java.lang.Long#TYPE
18.304 + * @see java.lang.Float#TYPE
18.305 + * @see java.lang.Double#TYPE
18.306 + * @see java.lang.Void#TYPE
18.307 + * @since JDK1.1
18.308 + */
18.309 + public native boolean isPrimitive();
18.310 +
18.311 + /**
18.312 + * Returns true if this {@code Class} object represents an annotation
18.313 + * type. Note that if this method returns true, {@link #isInterface()}
18.314 + * would also return true, as all annotation types are also interfaces.
18.315 + *
18.316 + * @return {@code true} if this class object represents an annotation
18.317 + * type; {@code false} otherwise
18.318 + * @since 1.5
18.319 + */
18.320 + public boolean isAnnotation() {
18.321 + return (getModifiers() & ANNOTATION) != 0;
18.322 + }
18.323 +
18.324 + /**
18.325 + * Returns {@code true} if this class is a synthetic class;
18.326 + * returns {@code false} otherwise.
18.327 + * @return {@code true} if and only if this class is a synthetic class as
18.328 + * defined by the Java Language Specification.
18.329 + * @since 1.5
18.330 + */
18.331 + public boolean isSynthetic() {
18.332 + return (getModifiers() & SYNTHETIC) != 0;
18.333 + }
18.334 +
18.335 + /**
18.336 + * Returns the name of the entity (class, interface, array class,
18.337 + * primitive type, or void) represented by this {@code Class} object,
18.338 + * as a {@code String}.
18.339 + *
18.340 + * <p> If this class object represents a reference type that is not an
18.341 + * array type then the binary name of the class is returned, as specified
18.342 + * by
18.343 + * <cite>The Java™ Language Specification</cite>.
18.344 + *
18.345 + * <p> If this class object represents a primitive type or void, then the
18.346 + * name returned is a {@code String} equal to the Java language
18.347 + * keyword corresponding to the primitive type or void.
18.348 + *
18.349 + * <p> If this class object represents a class of arrays, then the internal
18.350 + * form of the name consists of the name of the element type preceded by
18.351 + * one or more '{@code [}' characters representing the depth of the array
18.352 + * nesting. The encoding of element type names is as follows:
18.353 + *
18.354 + * <blockquote><table summary="Element types and encodings">
18.355 + * <tr><th> Element Type <th> <th> Encoding
18.356 + * <tr><td> boolean <td> <td align=center> Z
18.357 + * <tr><td> byte <td> <td align=center> B
18.358 + * <tr><td> char <td> <td align=center> C
18.359 + * <tr><td> class or interface
18.360 + * <td> <td align=center> L<i>classname</i>;
18.361 + * <tr><td> double <td> <td align=center> D
18.362 + * <tr><td> float <td> <td align=center> F
18.363 + * <tr><td> int <td> <td align=center> I
18.364 + * <tr><td> long <td> <td align=center> J
18.365 + * <tr><td> short <td> <td align=center> S
18.366 + * </table></blockquote>
18.367 + *
18.368 + * <p> The class or interface name <i>classname</i> is the binary name of
18.369 + * the class specified above.
18.370 + *
18.371 + * <p> Examples:
18.372 + * <blockquote><pre>
18.373 + * String.class.getName()
18.374 + * returns "java.lang.String"
18.375 + * byte.class.getName()
18.376 + * returns "byte"
18.377 + * (new Object[3]).getClass().getName()
18.378 + * returns "[Ljava.lang.Object;"
18.379 + * (new int[3][4][5][6][7][8][9]).getClass().getName()
18.380 + * returns "[[[[[[[I"
18.381 + * </pre></blockquote>
18.382 + *
18.383 + * @return the name of the class or interface
18.384 + * represented by this object.
18.385 + */
18.386 + public String getName() {
18.387 + throw new UnsupportedOperationException();
18.388 +// String name = this.name;
18.389 +// if (name == null)
18.390 +// this.name = name = getName0();
18.391 +// return name;
18.392 + }
18.393 +
18.394 + /**
18.395 + * Returns the {@code Class} representing the superclass of the entity
18.396 + * (class, interface, primitive type or void) represented by this
18.397 + * {@code Class}. If this {@code Class} represents either the
18.398 + * {@code Object} class, an interface, a primitive type, or void, then
18.399 + * null is returned. If this object represents an array class then the
18.400 + * {@code Class} object representing the {@code Object} class is
18.401 + * returned.
18.402 + *
18.403 + * @return the superclass of the class represented by this object.
18.404 + */
18.405 + public native Class<? super T> getSuperclass();
18.406 +
18.407 + /**
18.408 + * Returns the Java language modifiers for this class or interface, encoded
18.409 + * in an integer. The modifiers consist of the Java Virtual Machine's
18.410 + * constants for {@code public}, {@code protected},
18.411 + * {@code private}, {@code final}, {@code static},
18.412 + * {@code abstract} and {@code interface}; they should be decoded
18.413 + * using the methods of class {@code Modifier}.
18.414 + *
18.415 + * <p> If the underlying class is an array class, then its
18.416 + * {@code public}, {@code private} and {@code protected}
18.417 + * modifiers are the same as those of its component type. If this
18.418 + * {@code Class} represents a primitive type or void, its
18.419 + * {@code public} modifier is always {@code true}, and its
18.420 + * {@code protected} and {@code private} modifiers are always
18.421 + * {@code false}. If this object represents an array class, a
18.422 + * primitive type or void, then its {@code final} modifier is always
18.423 + * {@code true} and its interface modifier is always
18.424 + * {@code false}. The values of its other modifiers are not determined
18.425 + * by this specification.
18.426 + *
18.427 + * <p> The modifier encodings are defined in <em>The Java Virtual Machine
18.428 + * Specification</em>, table 4.1.
18.429 + *
18.430 + * @return the {@code int} representing the modifiers for this class
18.431 + * @see java.lang.reflect.Modifier
18.432 + * @since JDK1.1
18.433 + */
18.434 + public native int getModifiers();
18.435 +
18.436 +
18.437 + /**
18.438 + * Returns the simple name of the underlying class as given in the
18.439 + * source code. Returns an empty string if the underlying class is
18.440 + * anonymous.
18.441 + *
18.442 + * <p>The simple name of an array is the simple name of the
18.443 + * component type with "[]" appended. In particular the simple
18.444 + * name of an array whose component type is anonymous is "[]".
18.445 + *
18.446 + * @return the simple name of the underlying class
18.447 + * @since 1.5
18.448 + */
18.449 + public String getSimpleName() {
18.450 + throw new UnsupportedOperationException();
18.451 +//// if (isArray())
18.452 +//// return getComponentType().getSimpleName()+"[]";
18.453 +////
18.454 +//// String simpleName = getSimpleBinaryName();
18.455 +//// if (simpleName == null) { // top level class
18.456 +//// simpleName = getName();
18.457 +//// return simpleName.substring(simpleName.lastIndexOf(".")+1); // strip the package name
18.458 +//// }
18.459 +//// // According to JLS3 "Binary Compatibility" (13.1) the binary
18.460 +//// // name of non-package classes (not top level) is the binary
18.461 +//// // name of the immediately enclosing class followed by a '$' followed by:
18.462 +//// // (for nested and inner classes): the simple name.
18.463 +//// // (for local classes): 1 or more digits followed by the simple name.
18.464 +//// // (for anonymous classes): 1 or more digits.
18.465 +////
18.466 +//// // Since getSimpleBinaryName() will strip the binary name of
18.467 +//// // the immediatly enclosing class, we are now looking at a
18.468 +//// // string that matches the regular expression "\$[0-9]*"
18.469 +//// // followed by a simple name (considering the simple of an
18.470 +//// // anonymous class to be the empty string).
18.471 +////
18.472 +//// // Remove leading "\$[0-9]*" from the name
18.473 +//// int length = simpleName.length();
18.474 +//// if (length < 1 || simpleName.charAt(0) != '$')
18.475 +//// throw new InternalError("Malformed class name");
18.476 +//// int index = 1;
18.477 +//// while (index < length && isAsciiDigit(simpleName.charAt(index)))
18.478 +//// index++;
18.479 +//// // Eventually, this is the empty string iff this is an anonymous class
18.480 +//// return simpleName.substring(index);
18.481 + }
18.482 +
18.483 + /**
18.484 + * Character.isDigit answers {@code true} to some non-ascii
18.485 + * digits. This one does not.
18.486 + */
18.487 + private static boolean isAsciiDigit(char c) {
18.488 + return '0' <= c && c <= '9';
18.489 + }
18.490 +
18.491 + /**
18.492 + * Returns the canonical name of the underlying class as
18.493 + * defined by the Java Language Specification. Returns null if
18.494 + * the underlying class does not have a canonical name (i.e., if
18.495 + * it is a local or anonymous class or an array whose component
18.496 + * type does not have a canonical name).
18.497 + * @return the canonical name of the underlying class if it exists, and
18.498 + * {@code null} otherwise.
18.499 + * @since 1.5
18.500 + */
18.501 + public String getCanonicalName() {
18.502 + throw new UnsupportedOperationException();
18.503 +// if (isArray()) {
18.504 +// String canonicalName = getComponentType().getCanonicalName();
18.505 +// if (canonicalName != null)
18.506 +// return canonicalName + "[]";
18.507 +// else
18.508 +// return null;
18.509 +// }
18.510 +// if (isLocalOrAnonymousClass())
18.511 +// return null;
18.512 +// Class<?> enclosingClass = getEnclosingClass();
18.513 +// if (enclosingClass == null) { // top level class
18.514 +// return getName();
18.515 +// } else {
18.516 +// String enclosingName = enclosingClass.getCanonicalName();
18.517 +// if (enclosingName == null)
18.518 +// return null;
18.519 +// return enclosingName + "." + getSimpleName();
18.520 +// }
18.521 + }
18.522 +
18.523 + /**
18.524 + * Finds a resource with a given name. The rules for searching resources
18.525 + * associated with a given class are implemented by the defining
18.526 + * {@linkplain ClassLoader class loader} of the class. This method
18.527 + * delegates to this object's class loader. If this object was loaded by
18.528 + * the bootstrap class loader, the method delegates to {@link
18.529 + * ClassLoader#getSystemResourceAsStream}.
18.530 + *
18.531 + * <p> Before delegation, an absolute resource name is constructed from the
18.532 + * given resource name using this algorithm:
18.533 + *
18.534 + * <ul>
18.535 + *
18.536 + * <li> If the {@code name} begins with a {@code '/'}
18.537 + * (<tt>'\u002f'</tt>), then the absolute name of the resource is the
18.538 + * portion of the {@code name} following the {@code '/'}.
18.539 + *
18.540 + * <li> Otherwise, the absolute name is of the following form:
18.541 + *
18.542 + * <blockquote>
18.543 + * {@code modified_package_name/name}
18.544 + * </blockquote>
18.545 + *
18.546 + * <p> Where the {@code modified_package_name} is the package name of this
18.547 + * object with {@code '/'} substituted for {@code '.'}
18.548 + * (<tt>'\u002e'</tt>).
18.549 + *
18.550 + * </ul>
18.551 + *
18.552 + * @param name name of the desired resource
18.553 + * @return A {@link java.io.InputStream} object or {@code null} if
18.554 + * no resource with this name is found
18.555 + * @throws NullPointerException If {@code name} is {@code null}
18.556 + * @since JDK1.1
18.557 + */
18.558 +// public InputStream getResourceAsStream(String name) {
18.559 +// name = resolveName(name);
18.560 +// ClassLoader cl = getClassLoader0();
18.561 +// if (cl==null) {
18.562 +// // A system class.
18.563 +// return ClassLoader.getSystemResourceAsStream(name);
18.564 +// }
18.565 +// return cl.getResourceAsStream(name);
18.566 +// }
18.567 +
18.568 + /**
18.569 + * Finds a resource with a given name. The rules for searching resources
18.570 + * associated with a given class are implemented by the defining
18.571 + * {@linkplain ClassLoader class loader} of the class. This method
18.572 + * delegates to this object's class loader. If this object was loaded by
18.573 + * the bootstrap class loader, the method delegates to {@link
18.574 + * ClassLoader#getSystemResource}.
18.575 + *
18.576 + * <p> Before delegation, an absolute resource name is constructed from the
18.577 + * given resource name using this algorithm:
18.578 + *
18.579 + * <ul>
18.580 + *
18.581 + * <li> If the {@code name} begins with a {@code '/'}
18.582 + * (<tt>'\u002f'</tt>), then the absolute name of the resource is the
18.583 + * portion of the {@code name} following the {@code '/'}.
18.584 + *
18.585 + * <li> Otherwise, the absolute name is of the following form:
18.586 + *
18.587 + * <blockquote>
18.588 + * {@code modified_package_name/name}
18.589 + * </blockquote>
18.590 + *
18.591 + * <p> Where the {@code modified_package_name} is the package name of this
18.592 + * object with {@code '/'} substituted for {@code '.'}
18.593 + * (<tt>'\u002e'</tt>).
18.594 + *
18.595 + * </ul>
18.596 + *
18.597 + * @param name name of the desired resource
18.598 + * @return A {@link java.net.URL} object or {@code null} if no
18.599 + * resource with this name is found
18.600 + * @since JDK1.1
18.601 + */
18.602 +// public java.net.URL getResource(String name) {
18.603 +// name = resolveName(name);
18.604 +// ClassLoader cl = getClassLoader0();
18.605 +// if (cl==null) {
18.606 +// // A system class.
18.607 +// return ClassLoader.getSystemResource(name);
18.608 +// }
18.609 +// return cl.getResource(name);
18.610 +// }
18.611 +
18.612 +
18.613 +
18.614 +
18.615 + /**
18.616 + * Returns true if and only if this class was declared as an enum in the
18.617 + * source code.
18.618 + *
18.619 + * @return true if and only if this class was declared as an enum in the
18.620 + * source code
18.621 + * @since 1.5
18.622 + */
18.623 + public boolean isEnum() {
18.624 + // An enum must both directly extend java.lang.Enum and have
18.625 + // the ENUM bit set; classes for specialized enum constants
18.626 + // don't do the former.
18.627 + return (this.getModifiers() & ENUM) != 0 &&
18.628 + this.getSuperclass() == java.lang.Enum.class;
18.629 + }
18.630 +
18.631 + /**
18.632 + * Casts an object to the class or interface represented
18.633 + * by this {@code Class} object.
18.634 + *
18.635 + * @param obj the object to be cast
18.636 + * @return the object after casting, or null if obj is null
18.637 + *
18.638 + * @throws ClassCastException if the object is not
18.639 + * null and is not assignable to the type T.
18.640 + *
18.641 + * @since 1.5
18.642 + */
18.643 + public T cast(Object obj) {
18.644 + if (obj != null && !isInstance(obj))
18.645 + throw new ClassCastException(cannotCastMsg(obj));
18.646 + return (T) obj;
18.647 + }
18.648 +
18.649 + private String cannotCastMsg(Object obj) {
18.650 + return "Cannot cast " + obj.getClass().getName() + " to " + getName();
18.651 + }
18.652 +
18.653 + /**
18.654 + * Casts this {@code Class} object to represent a subclass of the class
18.655 + * represented by the specified class object. Checks that that the cast
18.656 + * is valid, and throws a {@code ClassCastException} if it is not. If
18.657 + * this method succeeds, it always returns a reference to this class object.
18.658 + *
18.659 + * <p>This method is useful when a client needs to "narrow" the type of
18.660 + * a {@code Class} object to pass it to an API that restricts the
18.661 + * {@code Class} objects that it is willing to accept. A cast would
18.662 + * generate a compile-time warning, as the correctness of the cast
18.663 + * could not be checked at runtime (because generic types are implemented
18.664 + * by erasure).
18.665 + *
18.666 + * @return this {@code Class} object, cast to represent a subclass of
18.667 + * the specified class object.
18.668 + * @throws ClassCastException if this {@code Class} object does not
18.669 + * represent a subclass of the specified class (here "subclass" includes
18.670 + * the class itself).
18.671 + * @since 1.5
18.672 + */
18.673 + public <U> Class<? extends U> asSubclass(Class<U> clazz) {
18.674 + if (clazz.isAssignableFrom(this))
18.675 + return (Class<? extends U>) this;
18.676 + else
18.677 + throw new ClassCastException(this.toString());
18.678 + }
18.679 +
18.680 + /**
18.681 + * @throws NullPointerException {@inheritDoc}
18.682 + * @since 1.5
18.683 + */
18.684 + public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
18.685 + throw new UnsupportedOperationException();
18.686 + }
18.687 +
18.688 + /**
18.689 + * @throws NullPointerException {@inheritDoc}
18.690 + * @since 1.5
18.691 + */
18.692 + public boolean isAnnotationPresent(
18.693 + Class<? extends Annotation> annotationClass) {
18.694 + if (annotationClass == null)
18.695 + throw new NullPointerException();
18.696 +
18.697 + return getAnnotation(annotationClass) != null;
18.698 + }
18.699 +
18.700 +
18.701 + /**
18.702 + * @since 1.5
18.703 + */
18.704 + public Annotation[] getAnnotations() {
18.705 + throw new UnsupportedOperationException();
18.706 + }
18.707 +
18.708 + /**
18.709 + * @since 1.5
18.710 + */
18.711 + public Annotation[] getDeclaredAnnotations() {
18.712 + throw new UnsupportedOperationException();
18.713 + }
18.714 +
18.715 + static Class getPrimitiveClass(String type) {
18.716 + // XXX
18.717 + return Object.class;
18.718 + }
18.719 +
18.720 + public boolean desiredAssertionStatus() {
18.721 + return false;
18.722 + }
18.723 +}
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
19.2 +++ b/emul/src/main/java/java/lang/ClassCastException.java Thu Oct 11 06:16:00 2012 -0700
19.3 @@ -0,0 +1,60 @@
19.4 +/*
19.5 + * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved.
19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
19.7 + *
19.8 + * This code is free software; you can redistribute it and/or modify it
19.9 + * under the terms of the GNU General Public License version 2 only, as
19.10 + * published by the Free Software Foundation. Oracle designates this
19.11 + * particular file as subject to the "Classpath" exception as provided
19.12 + * by Oracle in the LICENSE file that accompanied this code.
19.13 + *
19.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
19.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19.17 + * version 2 for more details (a copy is included in the LICENSE file that
19.18 + * accompanied this code).
19.19 + *
19.20 + * You should have received a copy of the GNU General Public License version
19.21 + * 2 along with this work; if not, write to the Free Software Foundation,
19.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19.23 + *
19.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19.25 + * or visit www.oracle.com if you need additional information or have any
19.26 + * questions.
19.27 + */
19.28 +
19.29 +package java.lang;
19.30 +
19.31 +/**
19.32 + * Thrown to indicate that the code has attempted to cast an object
19.33 + * to a subclass of which it is not an instance. For example, the
19.34 + * following code generates a <code>ClassCastException</code>:
19.35 + * <p><blockquote><pre>
19.36 + * Object x = new Integer(0);
19.37 + * System.out.println((String)x);
19.38 + * </pre></blockquote>
19.39 + *
19.40 + * @author unascribed
19.41 + * @since JDK1.0
19.42 + */
19.43 +public
19.44 +class ClassCastException extends RuntimeException {
19.45 + private static final long serialVersionUID = -9223365651070458532L;
19.46 +
19.47 + /**
19.48 + * Constructs a <code>ClassCastException</code> with no detail message.
19.49 + */
19.50 + public ClassCastException() {
19.51 + super();
19.52 + }
19.53 +
19.54 + /**
19.55 + * Constructs a <code>ClassCastException</code> with the specified
19.56 + * detail message.
19.57 + *
19.58 + * @param s the detail message.
19.59 + */
19.60 + public ClassCastException(String s) {
19.61 + super(s);
19.62 + }
19.63 +}
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/emul/src/main/java/java/lang/ClassNotFoundException.java Thu Oct 11 06:16:00 2012 -0700
20.3 @@ -0,0 +1,125 @@
20.4 +/*
20.5 + * Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved.
20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
20.7 + *
20.8 + * This code is free software; you can redistribute it and/or modify it
20.9 + * under the terms of the GNU General Public License version 2 only, as
20.10 + * published by the Free Software Foundation. Oracle designates this
20.11 + * particular file as subject to the "Classpath" exception as provided
20.12 + * by Oracle in the LICENSE file that accompanied this code.
20.13 + *
20.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
20.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20.17 + * version 2 for more details (a copy is included in the LICENSE file that
20.18 + * accompanied this code).
20.19 + *
20.20 + * You should have received a copy of the GNU General Public License version
20.21 + * 2 along with this work; if not, write to the Free Software Foundation,
20.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20.23 + *
20.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20.25 + * or visit www.oracle.com if you need additional information or have any
20.26 + * questions.
20.27 + */
20.28 +
20.29 +package java.lang;
20.30 +
20.31 +/**
20.32 + * Thrown when an application tries to load in a class through its
20.33 + * string name using:
20.34 + * <ul>
20.35 + * <li>The <code>forName</code> method in class <code>Class</code>.
20.36 + * <li>The <code>findSystemClass</code> method in class
20.37 + * <code>ClassLoader</code> .
20.38 + * <li>The <code>loadClass</code> method in class <code>ClassLoader</code>.
20.39 + * </ul>
20.40 + * <p>
20.41 + * but no definition for the class with the specified name could be found.
20.42 + *
20.43 + * <p>As of release 1.4, this exception has been retrofitted to conform to
20.44 + * the general purpose exception-chaining mechanism. The "optional exception
20.45 + * that was raised while loading the class" that may be provided at
20.46 + * construction time and accessed via the {@link #getException()} method is
20.47 + * now known as the <i>cause</i>, and may be accessed via the {@link
20.48 + * Throwable#getCause()} method, as well as the aforementioned "legacy method."
20.49 + *
20.50 + * @author unascribed
20.51 + * @see java.lang.Class#forName(java.lang.String)
20.52 + * @see java.lang.ClassLoader#findSystemClass(java.lang.String)
20.53 + * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean)
20.54 + * @since JDK1.0
20.55 + */
20.56 +public class ClassNotFoundException extends ReflectiveOperationException {
20.57 + /**
20.58 + * use serialVersionUID from JDK 1.1.X for interoperability
20.59 + */
20.60 + private static final long serialVersionUID = 9176873029745254542L;
20.61 +
20.62 + /**
20.63 + * This field holds the exception ex if the
20.64 + * ClassNotFoundException(String s, Throwable ex) constructor was
20.65 + * used to instantiate the object
20.66 + * @serial
20.67 + * @since 1.2
20.68 + */
20.69 + private Throwable ex;
20.70 +
20.71 + /**
20.72 + * Constructs a <code>ClassNotFoundException</code> with no detail message.
20.73 + */
20.74 + public ClassNotFoundException() {
20.75 + super((Throwable)null); // Disallow initCause
20.76 + }
20.77 +
20.78 + /**
20.79 + * Constructs a <code>ClassNotFoundException</code> with the
20.80 + * specified detail message.
20.81 + *
20.82 + * @param s the detail message.
20.83 + */
20.84 + public ClassNotFoundException(String s) {
20.85 + super(s, null); // Disallow initCause
20.86 + }
20.87 +
20.88 + /**
20.89 + * Constructs a <code>ClassNotFoundException</code> with the
20.90 + * specified detail message and optional exception that was
20.91 + * raised while loading the class.
20.92 + *
20.93 + * @param s the detail message
20.94 + * @param ex the exception that was raised while loading the class
20.95 + * @since 1.2
20.96 + */
20.97 + public ClassNotFoundException(String s, Throwable ex) {
20.98 + super(s, null); // Disallow initCause
20.99 + this.ex = ex;
20.100 + }
20.101 +
20.102 + /**
20.103 + * Returns the exception that was raised if an error occurred while
20.104 + * attempting to load the class. Otherwise, returns <tt>null</tt>.
20.105 + *
20.106 + * <p>This method predates the general-purpose exception chaining facility.
20.107 + * The {@link Throwable#getCause()} method is now the preferred means of
20.108 + * obtaining this information.
20.109 + *
20.110 + * @return the <code>Exception</code> that was raised while loading a class
20.111 + * @since 1.2
20.112 + */
20.113 + public Throwable getException() {
20.114 + return ex;
20.115 + }
20.116 +
20.117 + /**
20.118 + * Returns the cause of this exception (the exception that was raised
20.119 + * if an error occurred while attempting to load the class; otherwise
20.120 + * <tt>null</tt>).
20.121 + *
20.122 + * @return the cause of this exception.
20.123 + * @since 1.4
20.124 + */
20.125 + public Throwable getCause() {
20.126 + return ex;
20.127 + }
20.128 +}
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
21.2 +++ b/emul/src/main/java/java/lang/CloneNotSupportedException.java Thu Oct 11 06:16:00 2012 -0700
21.3 @@ -0,0 +1,65 @@
21.4 +/*
21.5 + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
21.7 + *
21.8 + * This code is free software; you can redistribute it and/or modify it
21.9 + * under the terms of the GNU General Public License version 2 only, as
21.10 + * published by the Free Software Foundation. Oracle designates this
21.11 + * particular file as subject to the "Classpath" exception as provided
21.12 + * by Oracle in the LICENSE file that accompanied this code.
21.13 + *
21.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
21.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21.17 + * version 2 for more details (a copy is included in the LICENSE file that
21.18 + * accompanied this code).
21.19 + *
21.20 + * You should have received a copy of the GNU General Public License version
21.21 + * 2 along with this work; if not, write to the Free Software Foundation,
21.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21.23 + *
21.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21.25 + * or visit www.oracle.com if you need additional information or have any
21.26 + * questions.
21.27 + */
21.28 +
21.29 +package java.lang;
21.30 +
21.31 +/**
21.32 + * Thrown to indicate that the <code>clone</code> method in class
21.33 + * <code>Object</code> has been called to clone an object, but that
21.34 + * the object's class does not implement the <code>Cloneable</code>
21.35 + * interface.
21.36 + * <p>
21.37 + * Applications that override the <code>clone</code> method can also
21.38 + * throw this exception to indicate that an object could not or
21.39 + * should not be cloned.
21.40 + *
21.41 + * @author unascribed
21.42 + * @see java.lang.Cloneable
21.43 + * @see java.lang.Object#clone()
21.44 + * @since JDK1.0
21.45 + */
21.46 +
21.47 +public
21.48 +class CloneNotSupportedException extends Exception {
21.49 + private static final long serialVersionUID = 5195511250079656443L;
21.50 +
21.51 + /**
21.52 + * Constructs a <code>CloneNotSupportedException</code> with no
21.53 + * detail message.
21.54 + */
21.55 + public CloneNotSupportedException() {
21.56 + super();
21.57 + }
21.58 +
21.59 + /**
21.60 + * Constructs a <code>CloneNotSupportedException</code> with the
21.61 + * specified detail message.
21.62 + *
21.63 + * @param s the detail message.
21.64 + */
21.65 + public CloneNotSupportedException(String s) {
21.66 + super(s);
21.67 + }
21.68 +}
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22.2 +++ b/emul/src/main/java/java/lang/Comparable.java Thu Oct 11 06:16:00 2012 -0700
22.3 @@ -0,0 +1,137 @@
22.4 +/*
22.5 + * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
22.7 + *
22.8 + * This code is free software; you can redistribute it and/or modify it
22.9 + * under the terms of the GNU General Public License version 2 only, as
22.10 + * published by the Free Software Foundation. Oracle designates this
22.11 + * particular file as subject to the "Classpath" exception as provided
22.12 + * by Oracle in the LICENSE file that accompanied this code.
22.13 + *
22.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
22.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22.17 + * version 2 for more details (a copy is included in the LICENSE file that
22.18 + * accompanied this code).
22.19 + *
22.20 + * You should have received a copy of the GNU General Public License version
22.21 + * 2 along with this work; if not, write to the Free Software Foundation,
22.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22.23 + *
22.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22.25 + * or visit www.oracle.com if you need additional information or have any
22.26 + * questions.
22.27 + */
22.28 +
22.29 +package java.lang;
22.30 +
22.31 +/**
22.32 + * This interface imposes a total ordering on the objects of each class that
22.33 + * implements it. This ordering is referred to as the class's <i>natural
22.34 + * ordering</i>, and the class's <tt>compareTo</tt> method is referred to as
22.35 + * its <i>natural comparison method</i>.<p>
22.36 + *
22.37 + * Lists (and arrays) of objects that implement this interface can be sorted
22.38 + * automatically by {@link Collections#sort(List) Collections.sort} (and
22.39 + * {@link Arrays#sort(Object[]) Arrays.sort}). Objects that implement this
22.40 + * interface can be used as keys in a {@linkplain SortedMap sorted map} or as
22.41 + * elements in a {@linkplain SortedSet sorted set}, without the need to
22.42 + * specify a {@linkplain Comparator comparator}.<p>
22.43 + *
22.44 + * The natural ordering for a class <tt>C</tt> is said to be <i>consistent
22.45 + * with equals</i> if and only if <tt>e1.compareTo(e2) == 0</tt> has
22.46 + * the same boolean value as <tt>e1.equals(e2)</tt> for every
22.47 + * <tt>e1</tt> and <tt>e2</tt> of class <tt>C</tt>. Note that <tt>null</tt>
22.48 + * is not an instance of any class, and <tt>e.compareTo(null)</tt> should
22.49 + * throw a <tt>NullPointerException</tt> even though <tt>e.equals(null)</tt>
22.50 + * returns <tt>false</tt>.<p>
22.51 + *
22.52 + * It is strongly recommended (though not required) that natural orderings be
22.53 + * consistent with equals. This is so because sorted sets (and sorted maps)
22.54 + * without explicit comparators behave "strangely" when they are used with
22.55 + * elements (or keys) whose natural ordering is inconsistent with equals. In
22.56 + * particular, such a sorted set (or sorted map) violates the general contract
22.57 + * for set (or map), which is defined in terms of the <tt>equals</tt>
22.58 + * method.<p>
22.59 + *
22.60 + * For example, if one adds two keys <tt>a</tt> and <tt>b</tt> such that
22.61 + * <tt>(!a.equals(b) && a.compareTo(b) == 0)</tt> to a sorted
22.62 + * set that does not use an explicit comparator, the second <tt>add</tt>
22.63 + * operation returns false (and the size of the sorted set does not increase)
22.64 + * because <tt>a</tt> and <tt>b</tt> are equivalent from the sorted set's
22.65 + * perspective.<p>
22.66 + *
22.67 + * Virtually all Java core classes that implement <tt>Comparable</tt> have natural
22.68 + * orderings that are consistent with equals. One exception is
22.69 + * <tt>java.math.BigDecimal</tt>, whose natural ordering equates
22.70 + * <tt>BigDecimal</tt> objects with equal values and different precisions
22.71 + * (such as 4.0 and 4.00).<p>
22.72 + *
22.73 + * For the mathematically inclined, the <i>relation</i> that defines
22.74 + * the natural ordering on a given class C is:<pre>
22.75 + * {(x, y) such that x.compareTo(y) <= 0}.
22.76 + * </pre> The <i>quotient</i> for this total order is: <pre>
22.77 + * {(x, y) such that x.compareTo(y) == 0}.
22.78 + * </pre>
22.79 + *
22.80 + * It follows immediately from the contract for <tt>compareTo</tt> that the
22.81 + * quotient is an <i>equivalence relation</i> on <tt>C</tt>, and that the
22.82 + * natural ordering is a <i>total order</i> on <tt>C</tt>. When we say that a
22.83 + * class's natural ordering is <i>consistent with equals</i>, we mean that the
22.84 + * quotient for the natural ordering is the equivalence relation defined by
22.85 + * the class's {@link Object#equals(Object) equals(Object)} method:<pre>
22.86 + * {(x, y) such that x.equals(y)}. </pre><p>
22.87 + *
22.88 + * This interface is a member of the
22.89 + * <a href="{@docRoot}/../technotes/guides/collections/index.html">
22.90 + * Java Collections Framework</a>.
22.91 + *
22.92 + * @param <T> the type of objects that this object may be compared to
22.93 + *
22.94 + * @author Josh Bloch
22.95 + * @see java.util.Comparator
22.96 + * @since 1.2
22.97 + */
22.98 +
22.99 +public interface Comparable<T> {
22.100 + /**
22.101 + * Compares this object with the specified object for order. Returns a
22.102 + * negative integer, zero, or a positive integer as this object is less
22.103 + * than, equal to, or greater than the specified object.
22.104 + *
22.105 + * <p>The implementor must ensure <tt>sgn(x.compareTo(y)) ==
22.106 + * -sgn(y.compareTo(x))</tt> for all <tt>x</tt> and <tt>y</tt>. (This
22.107 + * implies that <tt>x.compareTo(y)</tt> must throw an exception iff
22.108 + * <tt>y.compareTo(x)</tt> throws an exception.)
22.109 + *
22.110 + * <p>The implementor must also ensure that the relation is transitive:
22.111 + * <tt>(x.compareTo(y)>0 && y.compareTo(z)>0)</tt> implies
22.112 + * <tt>x.compareTo(z)>0</tt>.
22.113 + *
22.114 + * <p>Finally, the implementor must ensure that <tt>x.compareTo(y)==0</tt>
22.115 + * implies that <tt>sgn(x.compareTo(z)) == sgn(y.compareTo(z))</tt>, for
22.116 + * all <tt>z</tt>.
22.117 + *
22.118 + * <p>It is strongly recommended, but <i>not</i> strictly required that
22.119 + * <tt>(x.compareTo(y)==0) == (x.equals(y))</tt>. Generally speaking, any
22.120 + * class that implements the <tt>Comparable</tt> interface and violates
22.121 + * this condition should clearly indicate this fact. The recommended
22.122 + * language is "Note: this class has a natural ordering that is
22.123 + * inconsistent with equals."
22.124 + *
22.125 + * <p>In the foregoing description, the notation
22.126 + * <tt>sgn(</tt><i>expression</i><tt>)</tt> designates the mathematical
22.127 + * <i>signum</i> function, which is defined to return one of <tt>-1</tt>,
22.128 + * <tt>0</tt>, or <tt>1</tt> according to whether the value of
22.129 + * <i>expression</i> is negative, zero or positive.
22.130 + *
22.131 + * @param o the object to be compared.
22.132 + * @return a negative integer, zero, or a positive integer as this object
22.133 + * is less than, equal to, or greater than the specified object.
22.134 + *
22.135 + * @throws NullPointerException if the specified object is null
22.136 + * @throws ClassCastException if the specified object's type prevents it
22.137 + * from being compared to this object.
22.138 + */
22.139 + public int compareTo(T o);
22.140 +}
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
23.2 +++ b/emul/src/main/java/java/lang/Deprecated.java Thu Oct 11 06:16:00 2012 -0700
23.3 @@ -0,0 +1,44 @@
23.4 +/*
23.5 + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
23.7 + *
23.8 + * This code is free software; you can redistribute it and/or modify it
23.9 + * under the terms of the GNU General Public License version 2 only, as
23.10 + * published by the Free Software Foundation. Oracle designates this
23.11 + * particular file as subject to the "Classpath" exception as provided
23.12 + * by Oracle in the LICENSE file that accompanied this code.
23.13 + *
23.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
23.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23.17 + * version 2 for more details (a copy is included in the LICENSE file that
23.18 + * accompanied this code).
23.19 + *
23.20 + * You should have received a copy of the GNU General Public License version
23.21 + * 2 along with this work; if not, write to the Free Software Foundation,
23.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23.23 + *
23.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23.25 + * or visit www.oracle.com if you need additional information or have any
23.26 + * questions.
23.27 + */
23.28 +
23.29 +package java.lang;
23.30 +
23.31 +import java.lang.annotation.*;
23.32 +import static java.lang.annotation.ElementType.*;
23.33 +
23.34 +/**
23.35 + * A program element annotated @Deprecated is one that programmers
23.36 + * are discouraged from using, typically because it is dangerous,
23.37 + * or because a better alternative exists. Compilers warn when a
23.38 + * deprecated program element is used or overridden in non-deprecated code.
23.39 + *
23.40 + * @author Neal Gafter
23.41 + * @since 1.5
23.42 + */
23.43 +@Documented
23.44 +@Retention(RetentionPolicy.RUNTIME)
23.45 +@Target(value={CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE})
23.46 +public @interface Deprecated {
23.47 +}
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
24.2 +++ b/emul/src/main/java/java/lang/Double.java Thu Oct 11 06:16:00 2012 -0700
24.3 @@ -0,0 +1,988 @@
24.4 +/*
24.5 + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
24.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24.7 + *
24.8 + * This code is free software; you can redistribute it and/or modify it
24.9 + * under the terms of the GNU General Public License version 2 only, as
24.10 + * published by the Free Software Foundation. Oracle designates this
24.11 + * particular file as subject to the "Classpath" exception as provided
24.12 + * by Oracle in the LICENSE file that accompanied this code.
24.13 + *
24.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
24.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24.17 + * version 2 for more details (a copy is included in the LICENSE file that
24.18 + * accompanied this code).
24.19 + *
24.20 + * You should have received a copy of the GNU General Public License version
24.21 + * 2 along with this work; if not, write to the Free Software Foundation,
24.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24.23 + *
24.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24.25 + * or visit www.oracle.com if you need additional information or have any
24.26 + * questions.
24.27 + */
24.28 +
24.29 +package java.lang;
24.30 +
24.31 +/**
24.32 + * The {@code Double} class wraps a value of the primitive type
24.33 + * {@code double} in an object. An object of type
24.34 + * {@code Double} contains a single field whose type is
24.35 + * {@code double}.
24.36 + *
24.37 + * <p>In addition, this class provides several methods for converting a
24.38 + * {@code double} to a {@code String} and a
24.39 + * {@code String} to a {@code double}, as well as other
24.40 + * constants and methods useful when dealing with a
24.41 + * {@code double}.
24.42 + *
24.43 + * @author Lee Boynton
24.44 + * @author Arthur van Hoff
24.45 + * @author Joseph D. Darcy
24.46 + * @since JDK1.0
24.47 + */
24.48 +public final class Double extends Number implements Comparable<Double> {
24.49 + /**
24.50 + * A constant holding the positive infinity of type
24.51 + * {@code double}. It is equal to the value returned by
24.52 + * {@code Double.longBitsToDouble(0x7ff0000000000000L)}.
24.53 + */
24.54 + public static final double POSITIVE_INFINITY = 1.0 / 0.0;
24.55 +
24.56 + /**
24.57 + * A constant holding the negative infinity of type
24.58 + * {@code double}. It is equal to the value returned by
24.59 + * {@code Double.longBitsToDouble(0xfff0000000000000L)}.
24.60 + */
24.61 + public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
24.62 +
24.63 + /**
24.64 + * A constant holding a Not-a-Number (NaN) value of type
24.65 + * {@code double}. It is equivalent to the value returned by
24.66 + * {@code Double.longBitsToDouble(0x7ff8000000000000L)}.
24.67 + */
24.68 + public static final double NaN = 0.0d / 0.0;
24.69 +
24.70 + /**
24.71 + * A constant holding the largest positive finite value of type
24.72 + * {@code double},
24.73 + * (2-2<sup>-52</sup>)·2<sup>1023</sup>. It is equal to
24.74 + * the hexadecimal floating-point literal
24.75 + * {@code 0x1.fffffffffffffP+1023} and also equal to
24.76 + * {@code Double.longBitsToDouble(0x7fefffffffffffffL)}.
24.77 + */
24.78 + public static final double MAX_VALUE = 0x1.fffffffffffffP+1023; // 1.7976931348623157e+308
24.79 +
24.80 + /**
24.81 + * A constant holding the smallest positive normal value of type
24.82 + * {@code double}, 2<sup>-1022</sup>. It is equal to the
24.83 + * hexadecimal floating-point literal {@code 0x1.0p-1022} and also
24.84 + * equal to {@code Double.longBitsToDouble(0x0010000000000000L)}.
24.85 + *
24.86 + * @since 1.6
24.87 + */
24.88 + public static final double MIN_NORMAL = 0x1.0p-1022; // 2.2250738585072014E-308
24.89 +
24.90 + /**
24.91 + * A constant holding the smallest positive nonzero value of type
24.92 + * {@code double}, 2<sup>-1074</sup>. It is equal to the
24.93 + * hexadecimal floating-point literal
24.94 + * {@code 0x0.0000000000001P-1022} and also equal to
24.95 + * {@code Double.longBitsToDouble(0x1L)}.
24.96 + */
24.97 + public static final double MIN_VALUE = 0x0.0000000000001P-1022; // 4.9e-324
24.98 +
24.99 + /**
24.100 + * Maximum exponent a finite {@code double} variable may have.
24.101 + * It is equal to the value returned by
24.102 + * {@code Math.getExponent(Double.MAX_VALUE)}.
24.103 + *
24.104 + * @since 1.6
24.105 + */
24.106 + public static final int MAX_EXPONENT = 1023;
24.107 +
24.108 + /**
24.109 + * Minimum exponent a normalized {@code double} variable may
24.110 + * have. It is equal to the value returned by
24.111 + * {@code Math.getExponent(Double.MIN_NORMAL)}.
24.112 + *
24.113 + * @since 1.6
24.114 + */
24.115 + public static final int MIN_EXPONENT = -1022;
24.116 +
24.117 + /**
24.118 + * The number of bits used to represent a {@code double} value.
24.119 + *
24.120 + * @since 1.5
24.121 + */
24.122 + public static final int SIZE = 64;
24.123 +
24.124 + /**
24.125 + * The {@code Class} instance representing the primitive type
24.126 + * {@code double}.
24.127 + *
24.128 + * @since JDK1.1
24.129 + */
24.130 + public static final Class<Double> TYPE = (Class<Double>) Class.getPrimitiveClass("double");
24.131 +
24.132 + /**
24.133 + * Returns a string representation of the {@code double}
24.134 + * argument. All characters mentioned below are ASCII characters.
24.135 + * <ul>
24.136 + * <li>If the argument is NaN, the result is the string
24.137 + * "{@code NaN}".
24.138 + * <li>Otherwise, the result is a string that represents the sign and
24.139 + * magnitude (absolute value) of the argument. If the sign is negative,
24.140 + * the first character of the result is '{@code -}'
24.141 + * (<code>'\u002D'</code>); if the sign is positive, no sign character
24.142 + * appears in the result. As for the magnitude <i>m</i>:
24.143 + * <ul>
24.144 + * <li>If <i>m</i> is infinity, it is represented by the characters
24.145 + * {@code "Infinity"}; thus, positive infinity produces the result
24.146 + * {@code "Infinity"} and negative infinity produces the result
24.147 + * {@code "-Infinity"}.
24.148 + *
24.149 + * <li>If <i>m</i> is zero, it is represented by the characters
24.150 + * {@code "0.0"}; thus, negative zero produces the result
24.151 + * {@code "-0.0"} and positive zero produces the result
24.152 + * {@code "0.0"}.
24.153 + *
24.154 + * <li>If <i>m</i> is greater than or equal to 10<sup>-3</sup> but less
24.155 + * than 10<sup>7</sup>, then it is represented as the integer part of
24.156 + * <i>m</i>, in decimal form with no leading zeroes, followed by
24.157 + * '{@code .}' (<code>'\u002E'</code>), followed by one or
24.158 + * more decimal digits representing the fractional part of <i>m</i>.
24.159 + *
24.160 + * <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or
24.161 + * equal to 10<sup>7</sup>, then it is represented in so-called
24.162 + * "computerized scientific notation." Let <i>n</i> be the unique
24.163 + * integer such that 10<sup><i>n</i></sup> ≤ <i>m</i> {@literal <}
24.164 + * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the
24.165 + * mathematically exact quotient of <i>m</i> and
24.166 + * 10<sup><i>n</i></sup> so that 1 ≤ <i>a</i> {@literal <} 10. The
24.167 + * magnitude is then represented as the integer part of <i>a</i>,
24.168 + * as a single decimal digit, followed by '{@code .}'
24.169 + * (<code>'\u002E'</code>), followed by decimal digits
24.170 + * representing the fractional part of <i>a</i>, followed by the
24.171 + * letter '{@code E}' (<code>'\u0045'</code>), followed
24.172 + * by a representation of <i>n</i> as a decimal integer, as
24.173 + * produced by the method {@link Integer#toString(int)}.
24.174 + * </ul>
24.175 + * </ul>
24.176 + * How many digits must be printed for the fractional part of
24.177 + * <i>m</i> or <i>a</i>? There must be at least one digit to represent
24.178 + * the fractional part, and beyond that as many, but only as many, more
24.179 + * digits as are needed to uniquely distinguish the argument value from
24.180 + * adjacent values of type {@code double}. That is, suppose that
24.181 + * <i>x</i> is the exact mathematical value represented by the decimal
24.182 + * representation produced by this method for a finite nonzero argument
24.183 + * <i>d</i>. Then <i>d</i> must be the {@code double} value nearest
24.184 + * to <i>x</i>; or if two {@code double} values are equally close
24.185 + * to <i>x</i>, then <i>d</i> must be one of them and the least
24.186 + * significant bit of the significand of <i>d</i> must be {@code 0}.
24.187 + *
24.188 + * <p>To create localized string representations of a floating-point
24.189 + * value, use subclasses of {@link java.text.NumberFormat}.
24.190 + *
24.191 + * @param d the {@code double} to be converted.
24.192 + * @return a string representation of the argument.
24.193 + */
24.194 + public static String toString(double d) {
24.195 + throw new UnsupportedOperationException();
24.196 + }
24.197 +
24.198 + /**
24.199 + * Returns a hexadecimal string representation of the
24.200 + * {@code double} argument. All characters mentioned below
24.201 + * are ASCII characters.
24.202 + *
24.203 + * <ul>
24.204 + * <li>If the argument is NaN, the result is the string
24.205 + * "{@code NaN}".
24.206 + * <li>Otherwise, the result is a string that represents the sign
24.207 + * and magnitude of the argument. If the sign is negative, the
24.208 + * first character of the result is '{@code -}'
24.209 + * (<code>'\u002D'</code>); if the sign is positive, no sign
24.210 + * character appears in the result. As for the magnitude <i>m</i>:
24.211 + *
24.212 + * <ul>
24.213 + * <li>If <i>m</i> is infinity, it is represented by the string
24.214 + * {@code "Infinity"}; thus, positive infinity produces the
24.215 + * result {@code "Infinity"} and negative infinity produces
24.216 + * the result {@code "-Infinity"}.
24.217 + *
24.218 + * <li>If <i>m</i> is zero, it is represented by the string
24.219 + * {@code "0x0.0p0"}; thus, negative zero produces the result
24.220 + * {@code "-0x0.0p0"} and positive zero produces the result
24.221 + * {@code "0x0.0p0"}.
24.222 + *
24.223 + * <li>If <i>m</i> is a {@code double} value with a
24.224 + * normalized representation, substrings are used to represent the
24.225 + * significand and exponent fields. The significand is
24.226 + * represented by the characters {@code "0x1."}
24.227 + * followed by a lowercase hexadecimal representation of the rest
24.228 + * of the significand as a fraction. Trailing zeros in the
24.229 + * hexadecimal representation are removed unless all the digits
24.230 + * are zero, in which case a single zero is used. Next, the
24.231 + * exponent is represented by {@code "p"} followed
24.232 + * by a decimal string of the unbiased exponent as if produced by
24.233 + * a call to {@link Integer#toString(int) Integer.toString} on the
24.234 + * exponent value.
24.235 + *
24.236 + * <li>If <i>m</i> is a {@code double} value with a subnormal
24.237 + * representation, the significand is represented by the
24.238 + * characters {@code "0x0."} followed by a
24.239 + * hexadecimal representation of the rest of the significand as a
24.240 + * fraction. Trailing zeros in the hexadecimal representation are
24.241 + * removed. Next, the exponent is represented by
24.242 + * {@code "p-1022"}. Note that there must be at
24.243 + * least one nonzero digit in a subnormal significand.
24.244 + *
24.245 + * </ul>
24.246 + *
24.247 + * </ul>
24.248 + *
24.249 + * <table border>
24.250 + * <caption><h3>Examples</h3></caption>
24.251 + * <tr><th>Floating-point Value</th><th>Hexadecimal String</th>
24.252 + * <tr><td>{@code 1.0}</td> <td>{@code 0x1.0p0}</td>
24.253 + * <tr><td>{@code -1.0}</td> <td>{@code -0x1.0p0}</td>
24.254 + * <tr><td>{@code 2.0}</td> <td>{@code 0x1.0p1}</td>
24.255 + * <tr><td>{@code 3.0}</td> <td>{@code 0x1.8p1}</td>
24.256 + * <tr><td>{@code 0.5}</td> <td>{@code 0x1.0p-1}</td>
24.257 + * <tr><td>{@code 0.25}</td> <td>{@code 0x1.0p-2}</td>
24.258 + * <tr><td>{@code Double.MAX_VALUE}</td>
24.259 + * <td>{@code 0x1.fffffffffffffp1023}</td>
24.260 + * <tr><td>{@code Minimum Normal Value}</td>
24.261 + * <td>{@code 0x1.0p-1022}</td>
24.262 + * <tr><td>{@code Maximum Subnormal Value}</td>
24.263 + * <td>{@code 0x0.fffffffffffffp-1022}</td>
24.264 + * <tr><td>{@code Double.MIN_VALUE}</td>
24.265 + * <td>{@code 0x0.0000000000001p-1022}</td>
24.266 + * </table>
24.267 + * @param d the {@code double} to be converted.
24.268 + * @return a hex string representation of the argument.
24.269 + * @since 1.5
24.270 + * @author Joseph D. Darcy
24.271 + */
24.272 + public static String toHexString(double d) {
24.273 + throw new UnsupportedOperationException();
24.274 +// /*
24.275 +// * Modeled after the "a" conversion specifier in C99, section
24.276 +// * 7.19.6.1; however, the output of this method is more
24.277 +// * tightly specified.
24.278 +// */
24.279 +// if (!FpUtils.isFinite(d) )
24.280 +// // For infinity and NaN, use the decimal output.
24.281 +// return Double.toString(d);
24.282 +// else {
24.283 +// // Initialized to maximum size of output.
24.284 +// StringBuffer answer = new StringBuffer(24);
24.285 +//
24.286 +// if (FpUtils.rawCopySign(1.0, d) == -1.0) // value is negative,
24.287 +// answer.append("-"); // so append sign info
24.288 +//
24.289 +// answer.append("0x");
24.290 +//
24.291 +// d = Math.abs(d);
24.292 +//
24.293 +// if(d == 0.0) {
24.294 +// answer.append("0.0p0");
24.295 +// }
24.296 +// else {
24.297 +// boolean subnormal = (d < DoubleConsts.MIN_NORMAL);
24.298 +//
24.299 +// // Isolate significand bits and OR in a high-order bit
24.300 +// // so that the string representation has a known
24.301 +// // length.
24.302 +// long signifBits = (Double.doubleToLongBits(d)
24.303 +// & DoubleConsts.SIGNIF_BIT_MASK) |
24.304 +// 0x1000000000000000L;
24.305 +//
24.306 +// // Subnormal values have a 0 implicit bit; normal
24.307 +// // values have a 1 implicit bit.
24.308 +// answer.append(subnormal ? "0." : "1.");
24.309 +//
24.310 +// // Isolate the low-order 13 digits of the hex
24.311 +// // representation. If all the digits are zero,
24.312 +// // replace with a single 0; otherwise, remove all
24.313 +// // trailing zeros.
24.314 +// String signif = Long.toHexString(signifBits).substring(3,16);
24.315 +// answer.append(signif.equals("0000000000000") ? // 13 zeros
24.316 +// "0":
24.317 +// signif.replaceFirst("0{1,12}$", ""));
24.318 +//
24.319 +// // If the value is subnormal, use the E_min exponent
24.320 +// // value for double; otherwise, extract and report d's
24.321 +// // exponent (the representation of a subnormal uses
24.322 +// // E_min -1).
24.323 +// answer.append("p" + (subnormal ?
24.324 +// DoubleConsts.MIN_EXPONENT:
24.325 +// FpUtils.getExponent(d) ));
24.326 +// }
24.327 +// return answer.toString();
24.328 +// }
24.329 + }
24.330 +
24.331 + /**
24.332 + * Returns a {@code Double} object holding the
24.333 + * {@code double} value represented by the argument string
24.334 + * {@code s}.
24.335 + *
24.336 + * <p>If {@code s} is {@code null}, then a
24.337 + * {@code NullPointerException} is thrown.
24.338 + *
24.339 + * <p>Leading and trailing whitespace characters in {@code s}
24.340 + * are ignored. Whitespace is removed as if by the {@link
24.341 + * String#trim} method; that is, both ASCII space and control
24.342 + * characters are removed. The rest of {@code s} should
24.343 + * constitute a <i>FloatValue</i> as described by the lexical
24.344 + * syntax rules:
24.345 + *
24.346 + * <blockquote>
24.347 + * <dl>
24.348 + * <dt><i>FloatValue:</i>
24.349 + * <dd><i>Sign<sub>opt</sub></i> {@code NaN}
24.350 + * <dd><i>Sign<sub>opt</sub></i> {@code Infinity}
24.351 + * <dd><i>Sign<sub>opt</sub> FloatingPointLiteral</i>
24.352 + * <dd><i>Sign<sub>opt</sub> HexFloatingPointLiteral</i>
24.353 + * <dd><i>SignedInteger</i>
24.354 + * </dl>
24.355 + *
24.356 + * <p>
24.357 + *
24.358 + * <dl>
24.359 + * <dt><i>HexFloatingPointLiteral</i>:
24.360 + * <dd> <i>HexSignificand BinaryExponent FloatTypeSuffix<sub>opt</sub></i>
24.361 + * </dl>
24.362 + *
24.363 + * <p>
24.364 + *
24.365 + * <dl>
24.366 + * <dt><i>HexSignificand:</i>
24.367 + * <dd><i>HexNumeral</i>
24.368 + * <dd><i>HexNumeral</i> {@code .}
24.369 + * <dd>{@code 0x} <i>HexDigits<sub>opt</sub>
24.370 + * </i>{@code .}<i> HexDigits</i>
24.371 + * <dd>{@code 0X}<i> HexDigits<sub>opt</sub>
24.372 + * </i>{@code .} <i>HexDigits</i>
24.373 + * </dl>
24.374 + *
24.375 + * <p>
24.376 + *
24.377 + * <dl>
24.378 + * <dt><i>BinaryExponent:</i>
24.379 + * <dd><i>BinaryExponentIndicator SignedInteger</i>
24.380 + * </dl>
24.381 + *
24.382 + * <p>
24.383 + *
24.384 + * <dl>
24.385 + * <dt><i>BinaryExponentIndicator:</i>
24.386 + * <dd>{@code p}
24.387 + * <dd>{@code P}
24.388 + * </dl>
24.389 + *
24.390 + * </blockquote>
24.391 + *
24.392 + * where <i>Sign</i>, <i>FloatingPointLiteral</i>,
24.393 + * <i>HexNumeral</i>, <i>HexDigits</i>, <i>SignedInteger</i> and
24.394 + * <i>FloatTypeSuffix</i> are as defined in the lexical structure
24.395 + * sections of
24.396 + * <cite>The Java™ Language Specification</cite>,
24.397 + * except that underscores are not accepted between digits.
24.398 + * If {@code s} does not have the form of
24.399 + * a <i>FloatValue</i>, then a {@code NumberFormatException}
24.400 + * is thrown. Otherwise, {@code s} is regarded as
24.401 + * representing an exact decimal value in the usual
24.402 + * "computerized scientific notation" or as an exact
24.403 + * hexadecimal value; this exact numerical value is then
24.404 + * conceptually converted to an "infinitely precise"
24.405 + * binary value that is then rounded to type {@code double}
24.406 + * by the usual round-to-nearest rule of IEEE 754 floating-point
24.407 + * arithmetic, which includes preserving the sign of a zero
24.408 + * value.
24.409 + *
24.410 + * Note that the round-to-nearest rule also implies overflow and
24.411 + * underflow behaviour; if the exact value of {@code s} is large
24.412 + * enough in magnitude (greater than or equal to ({@link
24.413 + * #MAX_VALUE} + {@link Math#ulp(double) ulp(MAX_VALUE)}/2),
24.414 + * rounding to {@code double} will result in an infinity and if the
24.415 + * exact value of {@code s} is small enough in magnitude (less
24.416 + * than or equal to {@link #MIN_VALUE}/2), rounding to float will
24.417 + * result in a zero.
24.418 + *
24.419 + * Finally, after rounding a {@code Double} object representing
24.420 + * this {@code double} value is returned.
24.421 + *
24.422 + * <p> To interpret localized string representations of a
24.423 + * floating-point value, use subclasses of {@link
24.424 + * java.text.NumberFormat}.
24.425 + *
24.426 + * <p>Note that trailing format specifiers, specifiers that
24.427 + * determine the type of a floating-point literal
24.428 + * ({@code 1.0f} is a {@code float} value;
24.429 + * {@code 1.0d} is a {@code double} value), do
24.430 + * <em>not</em> influence the results of this method. In other
24.431 + * words, the numerical value of the input string is converted
24.432 + * directly to the target floating-point type. The two-step
24.433 + * sequence of conversions, string to {@code float} followed
24.434 + * by {@code float} to {@code double}, is <em>not</em>
24.435 + * equivalent to converting a string directly to
24.436 + * {@code double}. For example, the {@code float}
24.437 + * literal {@code 0.1f} is equal to the {@code double}
24.438 + * value {@code 0.10000000149011612}; the {@code float}
24.439 + * literal {@code 0.1f} represents a different numerical
24.440 + * value than the {@code double} literal
24.441 + * {@code 0.1}. (The numerical value 0.1 cannot be exactly
24.442 + * represented in a binary floating-point number.)
24.443 + *
24.444 + * <p>To avoid calling this method on an invalid string and having
24.445 + * a {@code NumberFormatException} be thrown, the regular
24.446 + * expression below can be used to screen the input string:
24.447 + *
24.448 + * <code>
24.449 + * <pre>
24.450 + * final String Digits = "(\\p{Digit}+)";
24.451 + * final String HexDigits = "(\\p{XDigit}+)";
24.452 + * // an exponent is 'e' or 'E' followed by an optionally
24.453 + * // signed decimal integer.
24.454 + * final String Exp = "[eE][+-]?"+Digits;
24.455 + * final String fpRegex =
24.456 + * ("[\\x00-\\x20]*"+ // Optional leading "whitespace"
24.457 + * "[+-]?(" + // Optional sign character
24.458 + * "NaN|" + // "NaN" string
24.459 + * "Infinity|" + // "Infinity" string
24.460 + *
24.461 + * // A decimal floating-point string representing a finite positive
24.462 + * // number without a leading sign has at most five basic pieces:
24.463 + * // Digits . Digits ExponentPart FloatTypeSuffix
24.464 + * //
24.465 + * // Since this method allows integer-only strings as input
24.466 + * // in addition to strings of floating-point literals, the
24.467 + * // two sub-patterns below are simplifications of the grammar
24.468 + * // productions from section 3.10.2 of
24.469 + * // <cite>The Java™ Language Specification</cite>.
24.470 + *
24.471 + * // Digits ._opt Digits_opt ExponentPart_opt FloatTypeSuffix_opt
24.472 + * "((("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+
24.473 + *
24.474 + * // . Digits ExponentPart_opt FloatTypeSuffix_opt
24.475 + * "(\\.("+Digits+")("+Exp+")?)|"+
24.476 + *
24.477 + * // Hexadecimal strings
24.478 + * "((" +
24.479 + * // 0[xX] HexDigits ._opt BinaryExponent FloatTypeSuffix_opt
24.480 + * "(0[xX]" + HexDigits + "(\\.)?)|" +
24.481 + *
24.482 + * // 0[xX] HexDigits_opt . HexDigits BinaryExponent FloatTypeSuffix_opt
24.483 + * "(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" +
24.484 + *
24.485 + * ")[pP][+-]?" + Digits + "))" +
24.486 + * "[fFdD]?))" +
24.487 + * "[\\x00-\\x20]*");// Optional trailing "whitespace"
24.488 + *
24.489 + * if (Pattern.matches(fpRegex, myString))
24.490 + * Double.valueOf(myString); // Will not throw NumberFormatException
24.491 + * else {
24.492 + * // Perform suitable alternative action
24.493 + * }
24.494 + * </pre>
24.495 + * </code>
24.496 + *
24.497 + * @param s the string to be parsed.
24.498 + * @return a {@code Double} object holding the value
24.499 + * represented by the {@code String} argument.
24.500 + * @throws NumberFormatException if the string does not contain a
24.501 + * parsable number.
24.502 + */
24.503 + public static Double valueOf(String s) throws NumberFormatException {
24.504 + throw new UnsupportedOperationException();
24.505 +// return new Double(FloatingDecimal.readJavaFormatString(s).doubleValue());
24.506 + }
24.507 +
24.508 + /**
24.509 + * Returns a {@code Double} instance representing the specified
24.510 + * {@code double} value.
24.511 + * If a new {@code Double} instance is not required, this method
24.512 + * should generally be used in preference to the constructor
24.513 + * {@link #Double(double)}, as this method is likely to yield
24.514 + * significantly better space and time performance by caching
24.515 + * frequently requested values.
24.516 + *
24.517 + * @param d a double value.
24.518 + * @return a {@code Double} instance representing {@code d}.
24.519 + * @since 1.5
24.520 + */
24.521 + public static Double valueOf(double d) {
24.522 + return new Double(d);
24.523 + }
24.524 +
24.525 + /**
24.526 + * Returns a new {@code double} initialized to the value
24.527 + * represented by the specified {@code String}, as performed
24.528 + * by the {@code valueOf} method of class
24.529 + * {@code Double}.
24.530 + *
24.531 + * @param s the string to be parsed.
24.532 + * @return the {@code double} value represented by the string
24.533 + * argument.
24.534 + * @throws NullPointerException if the string is null
24.535 + * @throws NumberFormatException if the string does not contain
24.536 + * a parsable {@code double}.
24.537 + * @see java.lang.Double#valueOf(String)
24.538 + * @since 1.2
24.539 + */
24.540 + public static double parseDouble(String s) throws NumberFormatException {
24.541 + throw new UnsupportedOperationException();
24.542 +// return FloatingDecimal.readJavaFormatString(s).doubleValue();
24.543 + }
24.544 +
24.545 + /**
24.546 + * Returns {@code true} if the specified number is a
24.547 + * Not-a-Number (NaN) value, {@code false} otherwise.
24.548 + *
24.549 + * @param v the value to be tested.
24.550 + * @return {@code true} if the value of the argument is NaN;
24.551 + * {@code false} otherwise.
24.552 + */
24.553 + static public boolean isNaN(double v) {
24.554 + return (v != v);
24.555 + }
24.556 +
24.557 + /**
24.558 + * Returns {@code true} if the specified number is infinitely
24.559 + * large in magnitude, {@code false} otherwise.
24.560 + *
24.561 + * @param v the value to be tested.
24.562 + * @return {@code true} if the value of the argument is positive
24.563 + * infinity or negative infinity; {@code false} otherwise.
24.564 + */
24.565 + static public boolean isInfinite(double v) {
24.566 + return (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY);
24.567 + }
24.568 +
24.569 + /**
24.570 + * The value of the Double.
24.571 + *
24.572 + * @serial
24.573 + */
24.574 + private final double value;
24.575 +
24.576 + /**
24.577 + * Constructs a newly allocated {@code Double} object that
24.578 + * represents the primitive {@code double} argument.
24.579 + *
24.580 + * @param value the value to be represented by the {@code Double}.
24.581 + */
24.582 + public Double(double value) {
24.583 + this.value = value;
24.584 + }
24.585 +
24.586 + /**
24.587 + * Constructs a newly allocated {@code Double} object that
24.588 + * represents the floating-point value of type {@code double}
24.589 + * represented by the string. The string is converted to a
24.590 + * {@code double} value as if by the {@code valueOf} method.
24.591 + *
24.592 + * @param s a string to be converted to a {@code Double}.
24.593 + * @throws NumberFormatException if the string does not contain a
24.594 + * parsable number.
24.595 + * @see java.lang.Double#valueOf(java.lang.String)
24.596 + */
24.597 + public Double(String s) throws NumberFormatException {
24.598 + // REMIND: this is inefficient
24.599 + this(valueOf(s).doubleValue());
24.600 + }
24.601 +
24.602 + /**
24.603 + * Returns {@code true} if this {@code Double} value is
24.604 + * a Not-a-Number (NaN), {@code false} otherwise.
24.605 + *
24.606 + * @return {@code true} if the value represented by this object is
24.607 + * NaN; {@code false} otherwise.
24.608 + */
24.609 + public boolean isNaN() {
24.610 + return isNaN(value);
24.611 + }
24.612 +
24.613 + /**
24.614 + * Returns {@code true} if this {@code Double} value is
24.615 + * infinitely large in magnitude, {@code false} otherwise.
24.616 + *
24.617 + * @return {@code true} if the value represented by this object is
24.618 + * positive infinity or negative infinity;
24.619 + * {@code false} otherwise.
24.620 + */
24.621 + public boolean isInfinite() {
24.622 + return isInfinite(value);
24.623 + }
24.624 +
24.625 + /**
24.626 + * Returns a string representation of this {@code Double} object.
24.627 + * The primitive {@code double} value represented by this
24.628 + * object is converted to a string exactly as if by the method
24.629 + * {@code toString} of one argument.
24.630 + *
24.631 + * @return a {@code String} representation of this object.
24.632 + * @see java.lang.Double#toString(double)
24.633 + */
24.634 + public String toString() {
24.635 + return toString(value);
24.636 + }
24.637 +
24.638 + /**
24.639 + * Returns the value of this {@code Double} as a {@code byte} (by
24.640 + * casting to a {@code byte}).
24.641 + *
24.642 + * @return the {@code double} value represented by this object
24.643 + * converted to type {@code byte}
24.644 + * @since JDK1.1
24.645 + */
24.646 + public byte byteValue() {
24.647 + return (byte)value;
24.648 + }
24.649 +
24.650 + /**
24.651 + * Returns the value of this {@code Double} as a
24.652 + * {@code short} (by casting to a {@code short}).
24.653 + *
24.654 + * @return the {@code double} value represented by this object
24.655 + * converted to type {@code short}
24.656 + * @since JDK1.1
24.657 + */
24.658 + public short shortValue() {
24.659 + return (short)value;
24.660 + }
24.661 +
24.662 + /**
24.663 + * Returns the value of this {@code Double} as an
24.664 + * {@code int} (by casting to type {@code int}).
24.665 + *
24.666 + * @return the {@code double} value represented by this object
24.667 + * converted to type {@code int}
24.668 + */
24.669 + public int intValue() {
24.670 + return (int)value;
24.671 + }
24.672 +
24.673 + /**
24.674 + * Returns the value of this {@code Double} as a
24.675 + * {@code long} (by casting to type {@code long}).
24.676 + *
24.677 + * @return the {@code double} value represented by this object
24.678 + * converted to type {@code long}
24.679 + */
24.680 + public long longValue() {
24.681 + return (long)value;
24.682 + }
24.683 +
24.684 + /**
24.685 + * Returns the {@code float} value of this
24.686 + * {@code Double} object.
24.687 + *
24.688 + * @return the {@code double} value represented by this object
24.689 + * converted to type {@code float}
24.690 + * @since JDK1.0
24.691 + */
24.692 + public float floatValue() {
24.693 + return (float)value;
24.694 + }
24.695 +
24.696 + /**
24.697 + * Returns the {@code double} value of this
24.698 + * {@code Double} object.
24.699 + *
24.700 + * @return the {@code double} value represented by this object
24.701 + */
24.702 + public double doubleValue() {
24.703 + return (double)value;
24.704 + }
24.705 +
24.706 + /**
24.707 + * Returns a hash code for this {@code Double} object. The
24.708 + * result is the exclusive OR of the two halves of the
24.709 + * {@code long} integer bit representation, exactly as
24.710 + * produced by the method {@link #doubleToLongBits(double)}, of
24.711 + * the primitive {@code double} value represented by this
24.712 + * {@code Double} object. That is, the hash code is the value
24.713 + * of the expression:
24.714 + *
24.715 + * <blockquote>
24.716 + * {@code (int)(v^(v>>>32))}
24.717 + * </blockquote>
24.718 + *
24.719 + * where {@code v} is defined by:
24.720 + *
24.721 + * <blockquote>
24.722 + * {@code long v = Double.doubleToLongBits(this.doubleValue());}
24.723 + * </blockquote>
24.724 + *
24.725 + * @return a {@code hash code} value for this object.
24.726 + */
24.727 + public int hashCode() {
24.728 + long bits = doubleToLongBits(value);
24.729 + return (int)(bits ^ (bits >>> 32));
24.730 + }
24.731 +
24.732 + /**
24.733 + * Compares this object against the specified object. The result
24.734 + * is {@code true} if and only if the argument is not
24.735 + * {@code null} and is a {@code Double} object that
24.736 + * represents a {@code double} that has the same value as the
24.737 + * {@code double} represented by this object. For this
24.738 + * purpose, two {@code double} values are considered to be
24.739 + * the same if and only if the method {@link
24.740 + * #doubleToLongBits(double)} returns the identical
24.741 + * {@code long} value when applied to each.
24.742 + *
24.743 + * <p>Note that in most cases, for two instances of class
24.744 + * {@code Double}, {@code d1} and {@code d2}, the
24.745 + * value of {@code d1.equals(d2)} is {@code true} if and
24.746 + * only if
24.747 + *
24.748 + * <blockquote>
24.749 + * {@code d1.doubleValue() == d2.doubleValue()}
24.750 + * </blockquote>
24.751 + *
24.752 + * <p>also has the value {@code true}. However, there are two
24.753 + * exceptions:
24.754 + * <ul>
24.755 + * <li>If {@code d1} and {@code d2} both represent
24.756 + * {@code Double.NaN}, then the {@code equals} method
24.757 + * returns {@code true}, even though
24.758 + * {@code Double.NaN==Double.NaN} has the value
24.759 + * {@code false}.
24.760 + * <li>If {@code d1} represents {@code +0.0} while
24.761 + * {@code d2} represents {@code -0.0}, or vice versa,
24.762 + * the {@code equal} test has the value {@code false},
24.763 + * even though {@code +0.0==-0.0} has the value {@code true}.
24.764 + * </ul>
24.765 + * This definition allows hash tables to operate properly.
24.766 + * @param obj the object to compare with.
24.767 + * @return {@code true} if the objects are the same;
24.768 + * {@code false} otherwise.
24.769 + * @see java.lang.Double#doubleToLongBits(double)
24.770 + */
24.771 + public boolean equals(Object obj) {
24.772 + return (obj instanceof Double)
24.773 + && (doubleToLongBits(((Double)obj).value) ==
24.774 + doubleToLongBits(value));
24.775 + }
24.776 +
24.777 + /**
24.778 + * Returns a representation of the specified floating-point value
24.779 + * according to the IEEE 754 floating-point "double
24.780 + * format" bit layout.
24.781 + *
24.782 + * <p>Bit 63 (the bit that is selected by the mask
24.783 + * {@code 0x8000000000000000L}) represents the sign of the
24.784 + * floating-point number. Bits
24.785 + * 62-52 (the bits that are selected by the mask
24.786 + * {@code 0x7ff0000000000000L}) represent the exponent. Bits 51-0
24.787 + * (the bits that are selected by the mask
24.788 + * {@code 0x000fffffffffffffL}) represent the significand
24.789 + * (sometimes called the mantissa) of the floating-point number.
24.790 + *
24.791 + * <p>If the argument is positive infinity, the result is
24.792 + * {@code 0x7ff0000000000000L}.
24.793 + *
24.794 + * <p>If the argument is negative infinity, the result is
24.795 + * {@code 0xfff0000000000000L}.
24.796 + *
24.797 + * <p>If the argument is NaN, the result is
24.798 + * {@code 0x7ff8000000000000L}.
24.799 + *
24.800 + * <p>In all cases, the result is a {@code long} integer that, when
24.801 + * given to the {@link #longBitsToDouble(long)} method, will produce a
24.802 + * floating-point value the same as the argument to
24.803 + * {@code doubleToLongBits} (except all NaN values are
24.804 + * collapsed to a single "canonical" NaN value).
24.805 + *
24.806 + * @param value a {@code double} precision floating-point number.
24.807 + * @return the bits that represent the floating-point number.
24.808 + */
24.809 + public static long doubleToLongBits(double value) {
24.810 + throw new UnsupportedOperationException();
24.811 +// long result = doubleToRawLongBits(value);
24.812 +// // Check for NaN based on values of bit fields, maximum
24.813 +// // exponent and nonzero significand.
24.814 +// if ( ((result & DoubleConsts.EXP_BIT_MASK) ==
24.815 +// DoubleConsts.EXP_BIT_MASK) &&
24.816 +// (result & DoubleConsts.SIGNIF_BIT_MASK) != 0L)
24.817 +// result = 0x7ff8000000000000L;
24.818 +// return result;
24.819 + }
24.820 +
24.821 + /**
24.822 + * Returns a representation of the specified floating-point value
24.823 + * according to the IEEE 754 floating-point "double
24.824 + * format" bit layout, preserving Not-a-Number (NaN) values.
24.825 + *
24.826 + * <p>Bit 63 (the bit that is selected by the mask
24.827 + * {@code 0x8000000000000000L}) represents the sign of the
24.828 + * floating-point number. Bits
24.829 + * 62-52 (the bits that are selected by the mask
24.830 + * {@code 0x7ff0000000000000L}) represent the exponent. Bits 51-0
24.831 + * (the bits that are selected by the mask
24.832 + * {@code 0x000fffffffffffffL}) represent the significand
24.833 + * (sometimes called the mantissa) of the floating-point number.
24.834 + *
24.835 + * <p>If the argument is positive infinity, the result is
24.836 + * {@code 0x7ff0000000000000L}.
24.837 + *
24.838 + * <p>If the argument is negative infinity, the result is
24.839 + * {@code 0xfff0000000000000L}.
24.840 + *
24.841 + * <p>If the argument is NaN, the result is the {@code long}
24.842 + * integer representing the actual NaN value. Unlike the
24.843 + * {@code doubleToLongBits} method,
24.844 + * {@code doubleToRawLongBits} does not collapse all the bit
24.845 + * patterns encoding a NaN to a single "canonical" NaN
24.846 + * value.
24.847 + *
24.848 + * <p>In all cases, the result is a {@code long} integer that,
24.849 + * when given to the {@link #longBitsToDouble(long)} method, will
24.850 + * produce a floating-point value the same as the argument to
24.851 + * {@code doubleToRawLongBits}.
24.852 + *
24.853 + * @param value a {@code double} precision floating-point number.
24.854 + * @return the bits that represent the floating-point number.
24.855 + * @since 1.3
24.856 + */
24.857 + public static native long doubleToRawLongBits(double value);
24.858 +
24.859 + /**
24.860 + * Returns the {@code double} value corresponding to a given
24.861 + * bit representation.
24.862 + * The argument is considered to be a representation of a
24.863 + * floating-point value according to the IEEE 754 floating-point
24.864 + * "double format" bit layout.
24.865 + *
24.866 + * <p>If the argument is {@code 0x7ff0000000000000L}, the result
24.867 + * is positive infinity.
24.868 + *
24.869 + * <p>If the argument is {@code 0xfff0000000000000L}, the result
24.870 + * is negative infinity.
24.871 + *
24.872 + * <p>If the argument is any value in the range
24.873 + * {@code 0x7ff0000000000001L} through
24.874 + * {@code 0x7fffffffffffffffL} or in the range
24.875 + * {@code 0xfff0000000000001L} through
24.876 + * {@code 0xffffffffffffffffL}, the result is a NaN. No IEEE
24.877 + * 754 floating-point operation provided by Java can distinguish
24.878 + * between two NaN values of the same type with different bit
24.879 + * patterns. Distinct values of NaN are only distinguishable by
24.880 + * use of the {@code Double.doubleToRawLongBits} method.
24.881 + *
24.882 + * <p>In all other cases, let <i>s</i>, <i>e</i>, and <i>m</i> be three
24.883 + * values that can be computed from the argument:
24.884 + *
24.885 + * <blockquote><pre>
24.886 + * int s = ((bits >> 63) == 0) ? 1 : -1;
24.887 + * int e = (int)((bits >> 52) & 0x7ffL);
24.888 + * long m = (e == 0) ?
24.889 + * (bits & 0xfffffffffffffL) << 1 :
24.890 + * (bits & 0xfffffffffffffL) | 0x10000000000000L;
24.891 + * </pre></blockquote>
24.892 + *
24.893 + * Then the floating-point result equals the value of the mathematical
24.894 + * expression <i>s</i>·<i>m</i>·2<sup><i>e</i>-1075</sup>.
24.895 + *
24.896 + * <p>Note that this method may not be able to return a
24.897 + * {@code double} NaN with exactly same bit pattern as the
24.898 + * {@code long} argument. IEEE 754 distinguishes between two
24.899 + * kinds of NaNs, quiet NaNs and <i>signaling NaNs</i>. The
24.900 + * differences between the two kinds of NaN are generally not
24.901 + * visible in Java. Arithmetic operations on signaling NaNs turn
24.902 + * them into quiet NaNs with a different, but often similar, bit
24.903 + * pattern. However, on some processors merely copying a
24.904 + * signaling NaN also performs that conversion. In particular,
24.905 + * copying a signaling NaN to return it to the calling method
24.906 + * may perform this conversion. So {@code longBitsToDouble}
24.907 + * may not be able to return a {@code double} with a
24.908 + * signaling NaN bit pattern. Consequently, for some
24.909 + * {@code long} values,
24.910 + * {@code doubleToRawLongBits(longBitsToDouble(start))} may
24.911 + * <i>not</i> equal {@code start}. Moreover, which
24.912 + * particular bit patterns represent signaling NaNs is platform
24.913 + * dependent; although all NaN bit patterns, quiet or signaling,
24.914 + * must be in the NaN range identified above.
24.915 + *
24.916 + * @param bits any {@code long} integer.
24.917 + * @return the {@code double} floating-point value with the same
24.918 + * bit pattern.
24.919 + */
24.920 + public static native double longBitsToDouble(long bits);
24.921 +
24.922 + /**
24.923 + * Compares two {@code Double} objects numerically. There
24.924 + * are two ways in which comparisons performed by this method
24.925 + * differ from those performed by the Java language numerical
24.926 + * comparison operators ({@code <, <=, ==, >=, >})
24.927 + * when applied to primitive {@code double} values:
24.928 + * <ul><li>
24.929 + * {@code Double.NaN} is considered by this method
24.930 + * to be equal to itself and greater than all other
24.931 + * {@code double} values (including
24.932 + * {@code Double.POSITIVE_INFINITY}).
24.933 + * <li>
24.934 + * {@code 0.0d} is considered by this method to be greater
24.935 + * than {@code -0.0d}.
24.936 + * </ul>
24.937 + * This ensures that the <i>natural ordering</i> of
24.938 + * {@code Double} objects imposed by this method is <i>consistent
24.939 + * with equals</i>.
24.940 + *
24.941 + * @param anotherDouble the {@code Double} to be compared.
24.942 + * @return the value {@code 0} if {@code anotherDouble} is
24.943 + * numerically equal to this {@code Double}; a value
24.944 + * less than {@code 0} if this {@code Double}
24.945 + * is numerically less than {@code anotherDouble};
24.946 + * and a value greater than {@code 0} if this
24.947 + * {@code Double} is numerically greater than
24.948 + * {@code anotherDouble}.
24.949 + *
24.950 + * @since 1.2
24.951 + */
24.952 + public int compareTo(Double anotherDouble) {
24.953 + return Double.compare(value, anotherDouble.value);
24.954 + }
24.955 +
24.956 + /**
24.957 + * Compares the two specified {@code double} values. The sign
24.958 + * of the integer value returned is the same as that of the
24.959 + * integer that would be returned by the call:
24.960 + * <pre>
24.961 + * new Double(d1).compareTo(new Double(d2))
24.962 + * </pre>
24.963 + *
24.964 + * @param d1 the first {@code double} to compare
24.965 + * @param d2 the second {@code double} to compare
24.966 + * @return the value {@code 0} if {@code d1} is
24.967 + * numerically equal to {@code d2}; a value less than
24.968 + * {@code 0} if {@code d1} is numerically less than
24.969 + * {@code d2}; and a value greater than {@code 0}
24.970 + * if {@code d1} is numerically greater than
24.971 + * {@code d2}.
24.972 + * @since 1.4
24.973 + */
24.974 + public static int compare(double d1, double d2) {
24.975 + if (d1 < d2)
24.976 + return -1; // Neither val is NaN, thisVal is smaller
24.977 + if (d1 > d2)
24.978 + return 1; // Neither val is NaN, thisVal is larger
24.979 +
24.980 + // Cannot use doubleToRawLongBits because of possibility of NaNs.
24.981 + long thisBits = Double.doubleToLongBits(d1);
24.982 + long anotherBits = Double.doubleToLongBits(d2);
24.983 +
24.984 + return (thisBits == anotherBits ? 0 : // Values are equal
24.985 + (thisBits < anotherBits ? -1 : // (-0.0, 0.0) or (!NaN, NaN)
24.986 + 1)); // (0.0, -0.0) or (NaN, !NaN)
24.987 + }
24.988 +
24.989 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
24.990 + private static final long serialVersionUID = -9172774392245257468L;
24.991 +}
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
25.2 +++ b/emul/src/main/java/java/lang/Enum.java Thu Oct 11 06:16:00 2012 -0700
25.3 @@ -0,0 +1,254 @@
25.4 +/*
25.5 + * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
25.7 + *
25.8 + * This code is free software; you can redistribute it and/or modify it
25.9 + * under the terms of the GNU General Public License version 2 only, as
25.10 + * published by the Free Software Foundation. Oracle designates this
25.11 + * particular file as subject to the "Classpath" exception as provided
25.12 + * by Oracle in the LICENSE file that accompanied this code.
25.13 + *
25.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
25.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25.17 + * version 2 for more details (a copy is included in the LICENSE file that
25.18 + * accompanied this code).
25.19 + *
25.20 + * You should have received a copy of the GNU General Public License version
25.21 + * 2 along with this work; if not, write to the Free Software Foundation,
25.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25.23 + *
25.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
25.25 + * or visit www.oracle.com if you need additional information or have any
25.26 + * questions.
25.27 + */
25.28 +
25.29 +package java.lang;
25.30 +
25.31 +import java.io.Serializable;
25.32 +import java.io.IOException;
25.33 +
25.34 +/**
25.35 + * This is the common base class of all Java language enumeration types.
25.36 + *
25.37 + * More information about enums, including descriptions of the
25.38 + * implicitly declared methods synthesized by the compiler, can be
25.39 + * found in section 8.9 of
25.40 + * <cite>The Java™ Language Specification</cite>.
25.41 + *
25.42 + * <p> Note that when using an enumeration type as the type of a set
25.43 + * or as the type of the keys in a map, specialized and efficient
25.44 + * {@linkplain java.util.EnumSet set} and {@linkplain
25.45 + * java.util.EnumMap map} implementations are available.
25.46 + *
25.47 + * @param <E> The enum type subclass
25.48 + * @author Josh Bloch
25.49 + * @author Neal Gafter
25.50 + * @see Class#getEnumConstants()
25.51 + * @see java.util.EnumSet
25.52 + * @see java.util.EnumMap
25.53 + * @since 1.5
25.54 + */
25.55 +public abstract class Enum<E extends Enum<E>>
25.56 + implements Comparable<E>, Serializable {
25.57 + /**
25.58 + * The name of this enum constant, as declared in the enum declaration.
25.59 + * Most programmers should use the {@link #toString} method rather than
25.60 + * accessing this field.
25.61 + */
25.62 + private final String name;
25.63 +
25.64 + /**
25.65 + * Returns the name of this enum constant, exactly as declared in its
25.66 + * enum declaration.
25.67 + *
25.68 + * <b>Most programmers should use the {@link #toString} method in
25.69 + * preference to this one, as the toString method may return
25.70 + * a more user-friendly name.</b> This method is designed primarily for
25.71 + * use in specialized situations where correctness depends on getting the
25.72 + * exact name, which will not vary from release to release.
25.73 + *
25.74 + * @return the name of this enum constant
25.75 + */
25.76 + public final String name() {
25.77 + return name;
25.78 + }
25.79 +
25.80 + /**
25.81 + * The ordinal of this enumeration constant (its position
25.82 + * in the enum declaration, where the initial constant is assigned
25.83 + * an ordinal of zero).
25.84 + *
25.85 + * Most programmers will have no use for this field. It is designed
25.86 + * for use by sophisticated enum-based data structures, such as
25.87 + * {@link java.util.EnumSet} and {@link java.util.EnumMap}.
25.88 + */
25.89 + private final int ordinal;
25.90 +
25.91 + /**
25.92 + * Returns the ordinal of this enumeration constant (its position
25.93 + * in its enum declaration, where the initial constant is assigned
25.94 + * an ordinal of zero).
25.95 + *
25.96 + * Most programmers will have no use for this method. It is
25.97 + * designed for use by sophisticated enum-based data structures, such
25.98 + * as {@link java.util.EnumSet} and {@link java.util.EnumMap}.
25.99 + *
25.100 + * @return the ordinal of this enumeration constant
25.101 + */
25.102 + public final int ordinal() {
25.103 + return ordinal;
25.104 + }
25.105 +
25.106 + /**
25.107 + * Sole constructor. Programmers cannot invoke this constructor.
25.108 + * It is for use by code emitted by the compiler in response to
25.109 + * enum type declarations.
25.110 + *
25.111 + * @param name - The name of this enum constant, which is the identifier
25.112 + * used to declare it.
25.113 + * @param ordinal - The ordinal of this enumeration constant (its position
25.114 + * in the enum declaration, where the initial constant is assigned
25.115 + * an ordinal of zero).
25.116 + */
25.117 + protected Enum(String name, int ordinal) {
25.118 + this.name = name;
25.119 + this.ordinal = ordinal;
25.120 + }
25.121 +
25.122 + /**
25.123 + * Returns the name of this enum constant, as contained in the
25.124 + * declaration. This method may be overridden, though it typically
25.125 + * isn't necessary or desirable. An enum type should override this
25.126 + * method when a more "programmer-friendly" string form exists.
25.127 + *
25.128 + * @return the name of this enum constant
25.129 + */
25.130 + public String toString() {
25.131 + return name;
25.132 + }
25.133 +
25.134 + /**
25.135 + * Returns true if the specified object is equal to this
25.136 + * enum constant.
25.137 + *
25.138 + * @param other the object to be compared for equality with this object.
25.139 + * @return true if the specified object is equal to this
25.140 + * enum constant.
25.141 + */
25.142 + public final boolean equals(Object other) {
25.143 + return this==other;
25.144 + }
25.145 +
25.146 + /**
25.147 + * Returns a hash code for this enum constant.
25.148 + *
25.149 + * @return a hash code for this enum constant.
25.150 + */
25.151 + public final int hashCode() {
25.152 + return super.hashCode();
25.153 + }
25.154 +
25.155 + /**
25.156 + * Throws CloneNotSupportedException. This guarantees that enums
25.157 + * are never cloned, which is necessary to preserve their "singleton"
25.158 + * status.
25.159 + *
25.160 + * @return (never returns)
25.161 + */
25.162 + protected final Object clone() throws CloneNotSupportedException {
25.163 + throw new CloneNotSupportedException();
25.164 + }
25.165 +
25.166 + /**
25.167 + * Compares this enum with the specified object for order. Returns a
25.168 + * negative integer, zero, or a positive integer as this object is less
25.169 + * than, equal to, or greater than the specified object.
25.170 + *
25.171 + * Enum constants are only comparable to other enum constants of the
25.172 + * same enum type. The natural order implemented by this
25.173 + * method is the order in which the constants are declared.
25.174 + */
25.175 + public final int compareTo(E o) {
25.176 + Enum other = (Enum)o;
25.177 + Enum self = this;
25.178 + if (self.getClass() != other.getClass() && // optimization
25.179 + self.getDeclaringClass() != other.getDeclaringClass())
25.180 + throw new ClassCastException();
25.181 + return self.ordinal - other.ordinal;
25.182 + }
25.183 +
25.184 + /**
25.185 + * Returns the Class object corresponding to this enum constant's
25.186 + * enum type. Two enum constants e1 and e2 are of the
25.187 + * same enum type if and only if
25.188 + * e1.getDeclaringClass() == e2.getDeclaringClass().
25.189 + * (The value returned by this method may differ from the one returned
25.190 + * by the {@link Object#getClass} method for enum constants with
25.191 + * constant-specific class bodies.)
25.192 + *
25.193 + * @return the Class object corresponding to this enum constant's
25.194 + * enum type
25.195 + */
25.196 + public final Class<E> getDeclaringClass() {
25.197 + Class clazz = getClass();
25.198 + Class zuper = clazz.getSuperclass();
25.199 + return (zuper == Enum.class) ? clazz : zuper;
25.200 + }
25.201 +
25.202 + /**
25.203 + * Returns the enum constant of the specified enum type with the
25.204 + * specified name. The name must match exactly an identifier used
25.205 + * to declare an enum constant in this type. (Extraneous whitespace
25.206 + * characters are not permitted.)
25.207 + *
25.208 + * <p>Note that for a particular enum type {@code T}, the
25.209 + * implicitly declared {@code public static T valueOf(String)}
25.210 + * method on that enum may be used instead of this method to map
25.211 + * from a name to the corresponding enum constant. All the
25.212 + * constants of an enum type can be obtained by calling the
25.213 + * implicit {@code public static T[] values()} method of that
25.214 + * type.
25.215 + *
25.216 + * @param <T> The enum type whose constant is to be returned
25.217 + * @param enumType the {@code Class} object of the enum type from which
25.218 + * to return a constant
25.219 + * @param name the name of the constant to return
25.220 + * @return the enum constant of the specified enum type with the
25.221 + * specified name
25.222 + * @throws IllegalArgumentException if the specified enum type has
25.223 + * no constant with the specified name, or the specified
25.224 + * class object does not represent an enum type
25.225 + * @throws NullPointerException if {@code enumType} or {@code name}
25.226 + * is null
25.227 + * @since 1.5
25.228 + */
25.229 + public static <T extends Enum<T>> T valueOf(Class<T> enumType,
25.230 + String name) {
25.231 + throw new UnsupportedOperationException();
25.232 +// T result = enumType.enumConstantDirectory().get(name);
25.233 +// if (result != null)
25.234 +// return result;
25.235 +// if (name == null)
25.236 +// throw new NullPointerException("Name is null");
25.237 +// throw new IllegalArgumentException(
25.238 +// "No enum constant " + enumType.getCanonicalName() + "." + name);
25.239 + }
25.240 +
25.241 + /**
25.242 + * enum classes cannot have finalize methods.
25.243 + */
25.244 + protected final void finalize() { }
25.245 +
25.246 + /**
25.247 + * prevent default deserialization
25.248 + */
25.249 +// private void readObject(ObjectInputStream in) throws IOException,
25.250 +// ClassNotFoundException {
25.251 +// throw new InvalidObjectException("can't deserialize enum");
25.252 +// }
25.253 +//
25.254 +// private void readObjectNoData() throws ObjectStreamException {
25.255 +// throw new InvalidObjectException("can't deserialize enum");
25.256 +// }
25.257 +}
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/emul/src/main/java/java/lang/Error.java Thu Oct 11 06:16:00 2012 -0700
26.3 @@ -0,0 +1,128 @@
26.4 +/*
26.5 + * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
26.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
26.7 + *
26.8 + * This code is free software; you can redistribute it and/or modify it
26.9 + * under the terms of the GNU General Public License version 2 only, as
26.10 + * published by the Free Software Foundation. Oracle designates this
26.11 + * particular file as subject to the "Classpath" exception as provided
26.12 + * by Oracle in the LICENSE file that accompanied this code.
26.13 + *
26.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
26.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26.17 + * version 2 for more details (a copy is included in the LICENSE file that
26.18 + * accompanied this code).
26.19 + *
26.20 + * You should have received a copy of the GNU General Public License version
26.21 + * 2 along with this work; if not, write to the Free Software Foundation,
26.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26.23 + *
26.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
26.25 + * or visit www.oracle.com if you need additional information or have any
26.26 + * questions.
26.27 + */
26.28 +
26.29 +package java.lang;
26.30 +
26.31 +/**
26.32 + * An {@code Error} is a subclass of {@code Throwable}
26.33 + * that indicates serious problems that a reasonable application
26.34 + * should not try to catch. Most such errors are abnormal conditions.
26.35 + * The {@code ThreadDeath} error, though a "normal" condition,
26.36 + * is also a subclass of {@code Error} because most applications
26.37 + * should not try to catch it.
26.38 + * <p>
26.39 + * A method is not required to declare in its {@code throws}
26.40 + * clause any subclasses of {@code Error} that might be thrown
26.41 + * during the execution of the method but not caught, since these
26.42 + * errors are abnormal conditions that should never occur.
26.43 + *
26.44 + * That is, {@code Error} and its subclasses are regarded as unchecked
26.45 + * exceptions for the purposes of compile-time checking of exceptions.
26.46 + *
26.47 + * @author Frank Yellin
26.48 + * @see java.lang.ThreadDeath
26.49 + * @jls 11.2 Compile-Time Checking of Exceptions
26.50 + * @since JDK1.0
26.51 + */
26.52 +public class Error extends Throwable {
26.53 + static final long serialVersionUID = 4980196508277280342L;
26.54 +
26.55 + /**
26.56 + * Constructs a new error with {@code null} as its detail message.
26.57 + * The cause is not initialized, and may subsequently be initialized by a
26.58 + * call to {@link #initCause}.
26.59 + */
26.60 + public Error() {
26.61 + super();
26.62 + }
26.63 +
26.64 + /**
26.65 + * Constructs a new error with the specified detail message. The
26.66 + * cause is not initialized, and may subsequently be initialized by
26.67 + * a call to {@link #initCause}.
26.68 + *
26.69 + * @param message the detail message. The detail message is saved for
26.70 + * later retrieval by the {@link #getMessage()} method.
26.71 + */
26.72 + public Error(String message) {
26.73 + super(message);
26.74 + }
26.75 +
26.76 + /**
26.77 + * Constructs a new error with the specified detail message and
26.78 + * cause. <p>Note that the detail message associated with
26.79 + * {@code cause} is <i>not</i> automatically incorporated in
26.80 + * this error's detail message.
26.81 + *
26.82 + * @param message the detail message (which is saved for later retrieval
26.83 + * by the {@link #getMessage()} method).
26.84 + * @param cause the cause (which is saved for later retrieval by the
26.85 + * {@link #getCause()} method). (A {@code null} value is
26.86 + * permitted, and indicates that the cause is nonexistent or
26.87 + * unknown.)
26.88 + * @since 1.4
26.89 + */
26.90 + public Error(String message, Throwable cause) {
26.91 + super(message, cause);
26.92 + }
26.93 +
26.94 + /**
26.95 + * Constructs a new error with the specified cause and a detail
26.96 + * message of {@code (cause==null ? null : cause.toString())} (which
26.97 + * typically contains the class and detail message of {@code cause}).
26.98 + * This constructor is useful for errors that are little more than
26.99 + * wrappers for other throwables.
26.100 + *
26.101 + * @param cause the cause (which is saved for later retrieval by the
26.102 + * {@link #getCause()} method). (A {@code null} value is
26.103 + * permitted, and indicates that the cause is nonexistent or
26.104 + * unknown.)
26.105 + * @since 1.4
26.106 + */
26.107 + public Error(Throwable cause) {
26.108 + super(cause);
26.109 + }
26.110 +
26.111 + /**
26.112 + * Constructs a new error with the specified detail message,
26.113 + * cause, suppression enabled or disabled, and writable stack
26.114 + * trace enabled or disabled.
26.115 + *
26.116 + * @param message the detail message.
26.117 + * @param cause the cause. (A {@code null} value is permitted,
26.118 + * and indicates that the cause is nonexistent or unknown.)
26.119 + * @param enableSuppression whether or not suppression is enabled
26.120 + * or disabled
26.121 + * @param writableStackTrace whether or not the stack trace should
26.122 + * be writable
26.123 + *
26.124 + * @since 1.7
26.125 + */
26.126 + protected Error(String message, Throwable cause,
26.127 + boolean enableSuppression,
26.128 + boolean writableStackTrace) {
26.129 + super(message, cause, enableSuppression, writableStackTrace);
26.130 + }
26.131 +}
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
27.2 +++ b/emul/src/main/java/java/lang/Exception.java Thu Oct 11 06:16:00 2012 -0700
27.3 @@ -0,0 +1,124 @@
27.4 +/*
27.5 + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
27.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
27.7 + *
27.8 + * This code is free software; you can redistribute it and/or modify it
27.9 + * under the terms of the GNU General Public License version 2 only, as
27.10 + * published by the Free Software Foundation. Oracle designates this
27.11 + * particular file as subject to the "Classpath" exception as provided
27.12 + * by Oracle in the LICENSE file that accompanied this code.
27.13 + *
27.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
27.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
27.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27.17 + * version 2 for more details (a copy is included in the LICENSE file that
27.18 + * accompanied this code).
27.19 + *
27.20 + * You should have received a copy of the GNU General Public License version
27.21 + * 2 along with this work; if not, write to the Free Software Foundation,
27.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27.23 + *
27.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
27.25 + * or visit www.oracle.com if you need additional information or have any
27.26 + * questions.
27.27 + */
27.28 +
27.29 +package java.lang;
27.30 +
27.31 +/**
27.32 + * The class {@code Exception} and its subclasses are a form of
27.33 + * {@code Throwable} that indicates conditions that a reasonable
27.34 + * application might want to catch.
27.35 + *
27.36 + * <p>The class {@code Exception} and any subclasses that are not also
27.37 + * subclasses of {@link RuntimeException} are <em>checked
27.38 + * exceptions</em>. Checked exceptions need to be declared in a
27.39 + * method or constructor's {@code throws} clause if they can be thrown
27.40 + * by the execution of the method or constructor and propagate outside
27.41 + * the method or constructor boundary.
27.42 + *
27.43 + * @author Frank Yellin
27.44 + * @see java.lang.Error
27.45 + * @jls 11.2 Compile-Time Checking of Exceptions
27.46 + * @since JDK1.0
27.47 + */
27.48 +public class Exception extends Throwable {
27.49 + static final long serialVersionUID = -3387516993124229948L;
27.50 +
27.51 + /**
27.52 + * Constructs a new exception with {@code null} as its detail message.
27.53 + * The cause is not initialized, and may subsequently be initialized by a
27.54 + * call to {@link #initCause}.
27.55 + */
27.56 + public Exception() {
27.57 + super();
27.58 + }
27.59 +
27.60 + /**
27.61 + * Constructs a new exception with the specified detail message. The
27.62 + * cause is not initialized, and may subsequently be initialized by
27.63 + * a call to {@link #initCause}.
27.64 + *
27.65 + * @param message the detail message. The detail message is saved for
27.66 + * later retrieval by the {@link #getMessage()} method.
27.67 + */
27.68 + public Exception(String message) {
27.69 + super(message);
27.70 + }
27.71 +
27.72 + /**
27.73 + * Constructs a new exception with the specified detail message and
27.74 + * cause. <p>Note that the detail message associated with
27.75 + * {@code cause} is <i>not</i> automatically incorporated in
27.76 + * this exception's detail message.
27.77 + *
27.78 + * @param message the detail message (which is saved for later retrieval
27.79 + * by the {@link #getMessage()} method).
27.80 + * @param cause the cause (which is saved for later retrieval by the
27.81 + * {@link #getCause()} method). (A <tt>null</tt> value is
27.82 + * permitted, and indicates that the cause is nonexistent or
27.83 + * unknown.)
27.84 + * @since 1.4
27.85 + */
27.86 + public Exception(String message, Throwable cause) {
27.87 + super(message, cause);
27.88 + }
27.89 +
27.90 + /**
27.91 + * Constructs a new exception with the specified cause and a detail
27.92 + * message of <tt>(cause==null ? null : cause.toString())</tt> (which
27.93 + * typically contains the class and detail message of <tt>cause</tt>).
27.94 + * This constructor is useful for exceptions that are little more than
27.95 + * wrappers for other throwables (for example, {@link
27.96 + * java.security.PrivilegedActionException}).
27.97 + *
27.98 + * @param cause the cause (which is saved for later retrieval by the
27.99 + * {@link #getCause()} method). (A <tt>null</tt> value is
27.100 + * permitted, and indicates that the cause is nonexistent or
27.101 + * unknown.)
27.102 + * @since 1.4
27.103 + */
27.104 + public Exception(Throwable cause) {
27.105 + super(cause);
27.106 + }
27.107 +
27.108 + /**
27.109 + * Constructs a new exception with the specified detail message,
27.110 + * cause, suppression enabled or disabled, and writable stack
27.111 + * trace enabled or disabled.
27.112 + *
27.113 + * @param message the detail message.
27.114 + * @param cause the cause. (A {@code null} value is permitted,
27.115 + * and indicates that the cause is nonexistent or unknown.)
27.116 + * @param enableSuppression whether or not suppression is enabled
27.117 + * or disabled
27.118 + * @param writableStackTrace whether or not the stack trace should
27.119 + * be writable
27.120 + * @since 1.7
27.121 + */
27.122 + protected Exception(String message, Throwable cause,
27.123 + boolean enableSuppression,
27.124 + boolean writableStackTrace) {
27.125 + super(message, cause, enableSuppression, writableStackTrace);
27.126 + }
27.127 +}
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
28.2 +++ b/emul/src/main/java/java/lang/Float.java Thu Oct 11 06:16:00 2012 -0700
28.3 @@ -0,0 +1,892 @@
28.4 +/*
28.5 + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
28.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28.7 + *
28.8 + * This code is free software; you can redistribute it and/or modify it
28.9 + * under the terms of the GNU General Public License version 2 only, as
28.10 + * published by the Free Software Foundation. Oracle designates this
28.11 + * particular file as subject to the "Classpath" exception as provided
28.12 + * by Oracle in the LICENSE file that accompanied this code.
28.13 + *
28.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
28.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28.17 + * version 2 for more details (a copy is included in the LICENSE file that
28.18 + * accompanied this code).
28.19 + *
28.20 + * You should have received a copy of the GNU General Public License version
28.21 + * 2 along with this work; if not, write to the Free Software Foundation,
28.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28.23 + *
28.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28.25 + * or visit www.oracle.com if you need additional information or have any
28.26 + * questions.
28.27 + */
28.28 +
28.29 +package java.lang;
28.30 +
28.31 +/**
28.32 + * The {@code Float} class wraps a value of primitive type
28.33 + * {@code float} in an object. An object of type
28.34 + * {@code Float} contains a single field whose type is
28.35 + * {@code float}.
28.36 + *
28.37 + * <p>In addition, this class provides several methods for converting a
28.38 + * {@code float} to a {@code String} and a
28.39 + * {@code String} to a {@code float}, as well as other
28.40 + * constants and methods useful when dealing with a
28.41 + * {@code float}.
28.42 + *
28.43 + * @author Lee Boynton
28.44 + * @author Arthur van Hoff
28.45 + * @author Joseph D. Darcy
28.46 + * @since JDK1.0
28.47 + */
28.48 +public final class Float extends Number implements Comparable<Float> {
28.49 + /**
28.50 + * A constant holding the positive infinity of type
28.51 + * {@code float}. It is equal to the value returned by
28.52 + * {@code Float.intBitsToFloat(0x7f800000)}.
28.53 + */
28.54 + public static final float POSITIVE_INFINITY = 1.0f / 0.0f;
28.55 +
28.56 + /**
28.57 + * A constant holding the negative infinity of type
28.58 + * {@code float}. It is equal to the value returned by
28.59 + * {@code Float.intBitsToFloat(0xff800000)}.
28.60 + */
28.61 + public static final float NEGATIVE_INFINITY = -1.0f / 0.0f;
28.62 +
28.63 + /**
28.64 + * A constant holding a Not-a-Number (NaN) value of type
28.65 + * {@code float}. It is equivalent to the value returned by
28.66 + * {@code Float.intBitsToFloat(0x7fc00000)}.
28.67 + */
28.68 + public static final float NaN = 0.0f / 0.0f;
28.69 +
28.70 + /**
28.71 + * A constant holding the largest positive finite value of type
28.72 + * {@code float}, (2-2<sup>-23</sup>)·2<sup>127</sup>.
28.73 + * It is equal to the hexadecimal floating-point literal
28.74 + * {@code 0x1.fffffeP+127f} and also equal to
28.75 + * {@code Float.intBitsToFloat(0x7f7fffff)}.
28.76 + */
28.77 + public static final float MAX_VALUE = 0x1.fffffeP+127f; // 3.4028235e+38f
28.78 +
28.79 + /**
28.80 + * A constant holding the smallest positive normal value of type
28.81 + * {@code float}, 2<sup>-126</sup>. It is equal to the
28.82 + * hexadecimal floating-point literal {@code 0x1.0p-126f} and also
28.83 + * equal to {@code Float.intBitsToFloat(0x00800000)}.
28.84 + *
28.85 + * @since 1.6
28.86 + */
28.87 + public static final float MIN_NORMAL = 0x1.0p-126f; // 1.17549435E-38f
28.88 +
28.89 + /**
28.90 + * A constant holding the smallest positive nonzero value of type
28.91 + * {@code float}, 2<sup>-149</sup>. It is equal to the
28.92 + * hexadecimal floating-point literal {@code 0x0.000002P-126f}
28.93 + * and also equal to {@code Float.intBitsToFloat(0x1)}.
28.94 + */
28.95 + public static final float MIN_VALUE = 0x0.000002P-126f; // 1.4e-45f
28.96 +
28.97 + /**
28.98 + * Maximum exponent a finite {@code float} variable may have. It
28.99 + * is equal to the value returned by {@code
28.100 + * Math.getExponent(Float.MAX_VALUE)}.
28.101 + *
28.102 + * @since 1.6
28.103 + */
28.104 + public static final int MAX_EXPONENT = 127;
28.105 +
28.106 + /**
28.107 + * Minimum exponent a normalized {@code float} variable may have.
28.108 + * It is equal to the value returned by {@code
28.109 + * Math.getExponent(Float.MIN_NORMAL)}.
28.110 + *
28.111 + * @since 1.6
28.112 + */
28.113 + public static final int MIN_EXPONENT = -126;
28.114 +
28.115 + /**
28.116 + * The number of bits used to represent a {@code float} value.
28.117 + *
28.118 + * @since 1.5
28.119 + */
28.120 + public static final int SIZE = 32;
28.121 +
28.122 + /**
28.123 + * The {@code Class} instance representing the primitive type
28.124 + * {@code float}.
28.125 + *
28.126 + * @since JDK1.1
28.127 + */
28.128 + public static final Class<Float> TYPE = Class.getPrimitiveClass("float");
28.129 +
28.130 + /**
28.131 + * Returns a string representation of the {@code float}
28.132 + * argument. All characters mentioned below are ASCII characters.
28.133 + * <ul>
28.134 + * <li>If the argument is NaN, the result is the string
28.135 + * "{@code NaN}".
28.136 + * <li>Otherwise, the result is a string that represents the sign and
28.137 + * magnitude (absolute value) of the argument. If the sign is
28.138 + * negative, the first character of the result is
28.139 + * '{@code -}' (<code>'\u002D'</code>); if the sign is
28.140 + * positive, no sign character appears in the result. As for
28.141 + * the magnitude <i>m</i>:
28.142 + * <ul>
28.143 + * <li>If <i>m</i> is infinity, it is represented by the characters
28.144 + * {@code "Infinity"}; thus, positive infinity produces
28.145 + * the result {@code "Infinity"} and negative infinity
28.146 + * produces the result {@code "-Infinity"}.
28.147 + * <li>If <i>m</i> is zero, it is represented by the characters
28.148 + * {@code "0.0"}; thus, negative zero produces the result
28.149 + * {@code "-0.0"} and positive zero produces the result
28.150 + * {@code "0.0"}.
28.151 + * <li> If <i>m</i> is greater than or equal to 10<sup>-3</sup> but
28.152 + * less than 10<sup>7</sup>, then it is represented as the
28.153 + * integer part of <i>m</i>, in decimal form with no leading
28.154 + * zeroes, followed by '{@code .}'
28.155 + * (<code>'\u002E'</code>), followed by one or more
28.156 + * decimal digits representing the fractional part of
28.157 + * <i>m</i>.
28.158 + * <li> If <i>m</i> is less than 10<sup>-3</sup> or greater than or
28.159 + * equal to 10<sup>7</sup>, then it is represented in
28.160 + * so-called "computerized scientific notation." Let <i>n</i>
28.161 + * be the unique integer such that 10<sup><i>n</i> </sup>≤
28.162 + * <i>m</i> {@literal <} 10<sup><i>n</i>+1</sup>; then let <i>a</i>
28.163 + * be the mathematically exact quotient of <i>m</i> and
28.164 + * 10<sup><i>n</i></sup> so that 1 ≤ <i>a</i> {@literal <} 10.
28.165 + * The magnitude is then represented as the integer part of
28.166 + * <i>a</i>, as a single decimal digit, followed by
28.167 + * '{@code .}' (<code>'\u002E'</code>), followed by
28.168 + * decimal digits representing the fractional part of
28.169 + * <i>a</i>, followed by the letter '{@code E}'
28.170 + * (<code>'\u0045'</code>), followed by a representation
28.171 + * of <i>n</i> as a decimal integer, as produced by the
28.172 + * method {@link java.lang.Integer#toString(int)}.
28.173 + *
28.174 + * </ul>
28.175 + * </ul>
28.176 + * How many digits must be printed for the fractional part of
28.177 + * <i>m</i> or <i>a</i>? There must be at least one digit
28.178 + * to represent the fractional part, and beyond that as many, but
28.179 + * only as many, more digits as are needed to uniquely distinguish
28.180 + * the argument value from adjacent values of type
28.181 + * {@code float}. That is, suppose that <i>x</i> is the
28.182 + * exact mathematical value represented by the decimal
28.183 + * representation produced by this method for a finite nonzero
28.184 + * argument <i>f</i>. Then <i>f</i> must be the {@code float}
28.185 + * value nearest to <i>x</i>; or, if two {@code float} values are
28.186 + * equally close to <i>x</i>, then <i>f</i> must be one of
28.187 + * them and the least significant bit of the significand of
28.188 + * <i>f</i> must be {@code 0}.
28.189 + *
28.190 + * <p>To create localized string representations of a floating-point
28.191 + * value, use subclasses of {@link java.text.NumberFormat}.
28.192 + *
28.193 + * @param f the float to be converted.
28.194 + * @return a string representation of the argument.
28.195 + */
28.196 + public static String toString(float f) {
28.197 + throw new UnsupportedOperationException();
28.198 +// return new FloatingDecimal(f).toJavaFormatString();
28.199 + }
28.200 +
28.201 + /**
28.202 + * Returns a hexadecimal string representation of the
28.203 + * {@code float} argument. All characters mentioned below are
28.204 + * ASCII characters.
28.205 + *
28.206 + * <ul>
28.207 + * <li>If the argument is NaN, the result is the string
28.208 + * "{@code NaN}".
28.209 + * <li>Otherwise, the result is a string that represents the sign and
28.210 + * magnitude (absolute value) of the argument. If the sign is negative,
28.211 + * the first character of the result is '{@code -}'
28.212 + * (<code>'\u002D'</code>); if the sign is positive, no sign character
28.213 + * appears in the result. As for the magnitude <i>m</i>:
28.214 + *
28.215 + * <ul>
28.216 + * <li>If <i>m</i> is infinity, it is represented by the string
28.217 + * {@code "Infinity"}; thus, positive infinity produces the
28.218 + * result {@code "Infinity"} and negative infinity produces
28.219 + * the result {@code "-Infinity"}.
28.220 + *
28.221 + * <li>If <i>m</i> is zero, it is represented by the string
28.222 + * {@code "0x0.0p0"}; thus, negative zero produces the result
28.223 + * {@code "-0x0.0p0"} and positive zero produces the result
28.224 + * {@code "0x0.0p0"}.
28.225 + *
28.226 + * <li>If <i>m</i> is a {@code float} value with a
28.227 + * normalized representation, substrings are used to represent the
28.228 + * significand and exponent fields. The significand is
28.229 + * represented by the characters {@code "0x1."}
28.230 + * followed by a lowercase hexadecimal representation of the rest
28.231 + * of the significand as a fraction. Trailing zeros in the
28.232 + * hexadecimal representation are removed unless all the digits
28.233 + * are zero, in which case a single zero is used. Next, the
28.234 + * exponent is represented by {@code "p"} followed
28.235 + * by a decimal string of the unbiased exponent as if produced by
28.236 + * a call to {@link Integer#toString(int) Integer.toString} on the
28.237 + * exponent value.
28.238 + *
28.239 + * <li>If <i>m</i> is a {@code float} value with a subnormal
28.240 + * representation, the significand is represented by the
28.241 + * characters {@code "0x0."} followed by a
28.242 + * hexadecimal representation of the rest of the significand as a
28.243 + * fraction. Trailing zeros in the hexadecimal representation are
28.244 + * removed. Next, the exponent is represented by
28.245 + * {@code "p-126"}. Note that there must be at
28.246 + * least one nonzero digit in a subnormal significand.
28.247 + *
28.248 + * </ul>
28.249 + *
28.250 + * </ul>
28.251 + *
28.252 + * <table border>
28.253 + * <caption><h3>Examples</h3></caption>
28.254 + * <tr><th>Floating-point Value</th><th>Hexadecimal String</th>
28.255 + * <tr><td>{@code 1.0}</td> <td>{@code 0x1.0p0}</td>
28.256 + * <tr><td>{@code -1.0}</td> <td>{@code -0x1.0p0}</td>
28.257 + * <tr><td>{@code 2.0}</td> <td>{@code 0x1.0p1}</td>
28.258 + * <tr><td>{@code 3.0}</td> <td>{@code 0x1.8p1}</td>
28.259 + * <tr><td>{@code 0.5}</td> <td>{@code 0x1.0p-1}</td>
28.260 + * <tr><td>{@code 0.25}</td> <td>{@code 0x1.0p-2}</td>
28.261 + * <tr><td>{@code Float.MAX_VALUE}</td>
28.262 + * <td>{@code 0x1.fffffep127}</td>
28.263 + * <tr><td>{@code Minimum Normal Value}</td>
28.264 + * <td>{@code 0x1.0p-126}</td>
28.265 + * <tr><td>{@code Maximum Subnormal Value}</td>
28.266 + * <td>{@code 0x0.fffffep-126}</td>
28.267 + * <tr><td>{@code Float.MIN_VALUE}</td>
28.268 + * <td>{@code 0x0.000002p-126}</td>
28.269 + * </table>
28.270 + * @param f the {@code float} to be converted.
28.271 + * @return a hex string representation of the argument.
28.272 + * @since 1.5
28.273 + * @author Joseph D. Darcy
28.274 + */
28.275 + public static String toHexString(float f) {
28.276 + throw new UnsupportedOperationException();
28.277 +// if (Math.abs(f) < FloatConsts.MIN_NORMAL
28.278 +// && f != 0.0f ) {// float subnormal
28.279 +// // Adjust exponent to create subnormal double, then
28.280 +// // replace subnormal double exponent with subnormal float
28.281 +// // exponent
28.282 +// String s = Double.toHexString(FpUtils.scalb((double)f,
28.283 +// /* -1022+126 */
28.284 +// DoubleConsts.MIN_EXPONENT-
28.285 +// FloatConsts.MIN_EXPONENT));
28.286 +// return s.replaceFirst("p-1022$", "p-126");
28.287 +// }
28.288 +// else // double string will be the same as float string
28.289 +// return Double.toHexString(f);
28.290 + }
28.291 +
28.292 + /**
28.293 + * Returns a {@code Float} object holding the
28.294 + * {@code float} value represented by the argument string
28.295 + * {@code s}.
28.296 + *
28.297 + * <p>If {@code s} is {@code null}, then a
28.298 + * {@code NullPointerException} is thrown.
28.299 + *
28.300 + * <p>Leading and trailing whitespace characters in {@code s}
28.301 + * are ignored. Whitespace is removed as if by the {@link
28.302 + * String#trim} method; that is, both ASCII space and control
28.303 + * characters are removed. The rest of {@code s} should
28.304 + * constitute a <i>FloatValue</i> as described by the lexical
28.305 + * syntax rules:
28.306 + *
28.307 + * <blockquote>
28.308 + * <dl>
28.309 + * <dt><i>FloatValue:</i>
28.310 + * <dd><i>Sign<sub>opt</sub></i> {@code NaN}
28.311 + * <dd><i>Sign<sub>opt</sub></i> {@code Infinity}
28.312 + * <dd><i>Sign<sub>opt</sub> FloatingPointLiteral</i>
28.313 + * <dd><i>Sign<sub>opt</sub> HexFloatingPointLiteral</i>
28.314 + * <dd><i>SignedInteger</i>
28.315 + * </dl>
28.316 + *
28.317 + * <p>
28.318 + *
28.319 + * <dl>
28.320 + * <dt><i>HexFloatingPointLiteral</i>:
28.321 + * <dd> <i>HexSignificand BinaryExponent FloatTypeSuffix<sub>opt</sub></i>
28.322 + * </dl>
28.323 + *
28.324 + * <p>
28.325 + *
28.326 + * <dl>
28.327 + * <dt><i>HexSignificand:</i>
28.328 + * <dd><i>HexNumeral</i>
28.329 + * <dd><i>HexNumeral</i> {@code .}
28.330 + * <dd>{@code 0x} <i>HexDigits<sub>opt</sub>
28.331 + * </i>{@code .}<i> HexDigits</i>
28.332 + * <dd>{@code 0X}<i> HexDigits<sub>opt</sub>
28.333 + * </i>{@code .} <i>HexDigits</i>
28.334 + * </dl>
28.335 + *
28.336 + * <p>
28.337 + *
28.338 + * <dl>
28.339 + * <dt><i>BinaryExponent:</i>
28.340 + * <dd><i>BinaryExponentIndicator SignedInteger</i>
28.341 + * </dl>
28.342 + *
28.343 + * <p>
28.344 + *
28.345 + * <dl>
28.346 + * <dt><i>BinaryExponentIndicator:</i>
28.347 + * <dd>{@code p}
28.348 + * <dd>{@code P}
28.349 + * </dl>
28.350 + *
28.351 + * </blockquote>
28.352 + *
28.353 + * where <i>Sign</i>, <i>FloatingPointLiteral</i>,
28.354 + * <i>HexNumeral</i>, <i>HexDigits</i>, <i>SignedInteger</i> and
28.355 + * <i>FloatTypeSuffix</i> are as defined in the lexical structure
28.356 + * sections of
28.357 + * <cite>The Java™ Language Specification</cite>,
28.358 + * except that underscores are not accepted between digits.
28.359 + * If {@code s} does not have the form of
28.360 + * a <i>FloatValue</i>, then a {@code NumberFormatException}
28.361 + * is thrown. Otherwise, {@code s} is regarded as
28.362 + * representing an exact decimal value in the usual
28.363 + * "computerized scientific notation" or as an exact
28.364 + * hexadecimal value; this exact numerical value is then
28.365 + * conceptually converted to an "infinitely precise"
28.366 + * binary value that is then rounded to type {@code float}
28.367 + * by the usual round-to-nearest rule of IEEE 754 floating-point
28.368 + * arithmetic, which includes preserving the sign of a zero
28.369 + * value.
28.370 + *
28.371 + * Note that the round-to-nearest rule also implies overflow and
28.372 + * underflow behaviour; if the exact value of {@code s} is large
28.373 + * enough in magnitude (greater than or equal to ({@link
28.374 + * #MAX_VALUE} + {@link Math#ulp(float) ulp(MAX_VALUE)}/2),
28.375 + * rounding to {@code float} will result in an infinity and if the
28.376 + * exact value of {@code s} is small enough in magnitude (less
28.377 + * than or equal to {@link #MIN_VALUE}/2), rounding to float will
28.378 + * result in a zero.
28.379 + *
28.380 + * Finally, after rounding a {@code Float} object representing
28.381 + * this {@code float} value is returned.
28.382 + *
28.383 + * <p>To interpret localized string representations of a
28.384 + * floating-point value, use subclasses of {@link
28.385 + * java.text.NumberFormat}.
28.386 + *
28.387 + * <p>Note that trailing format specifiers, specifiers that
28.388 + * determine the type of a floating-point literal
28.389 + * ({@code 1.0f} is a {@code float} value;
28.390 + * {@code 1.0d} is a {@code double} value), do
28.391 + * <em>not</em> influence the results of this method. In other
28.392 + * words, the numerical value of the input string is converted
28.393 + * directly to the target floating-point type. In general, the
28.394 + * two-step sequence of conversions, string to {@code double}
28.395 + * followed by {@code double} to {@code float}, is
28.396 + * <em>not</em> equivalent to converting a string directly to
28.397 + * {@code float}. For example, if first converted to an
28.398 + * intermediate {@code double} and then to
28.399 + * {@code float}, the string<br>
28.400 + * {@code "1.00000017881393421514957253748434595763683319091796875001d"}<br>
28.401 + * results in the {@code float} value
28.402 + * {@code 1.0000002f}; if the string is converted directly to
28.403 + * {@code float}, <code>1.000000<b>1</b>f</code> results.
28.404 + *
28.405 + * <p>To avoid calling this method on an invalid string and having
28.406 + * a {@code NumberFormatException} be thrown, the documentation
28.407 + * for {@link Double#valueOf Double.valueOf} lists a regular
28.408 + * expression which can be used to screen the input.
28.409 + *
28.410 + * @param s the string to be parsed.
28.411 + * @return a {@code Float} object holding the value
28.412 + * represented by the {@code String} argument.
28.413 + * @throws NumberFormatException if the string does not contain a
28.414 + * parsable number.
28.415 + */
28.416 + public static Float valueOf(String s) throws NumberFormatException {
28.417 + throw new UnsupportedOperationException();
28.418 +// return new Float(FloatingDecimal.readJavaFormatString(s).floatValue());
28.419 + }
28.420 +
28.421 + /**
28.422 + * Returns a {@code Float} instance representing the specified
28.423 + * {@code float} value.
28.424 + * If a new {@code Float} instance is not required, this method
28.425 + * should generally be used in preference to the constructor
28.426 + * {@link #Float(float)}, as this method is likely to yield
28.427 + * significantly better space and time performance by caching
28.428 + * frequently requested values.
28.429 + *
28.430 + * @param f a float value.
28.431 + * @return a {@code Float} instance representing {@code f}.
28.432 + * @since 1.5
28.433 + */
28.434 + public static Float valueOf(float f) {
28.435 + return new Float(f);
28.436 + }
28.437 +
28.438 + /**
28.439 + * Returns a new {@code float} initialized to the value
28.440 + * represented by the specified {@code String}, as performed
28.441 + * by the {@code valueOf} method of class {@code Float}.
28.442 + *
28.443 + * @param s the string to be parsed.
28.444 + * @return the {@code float} value represented by the string
28.445 + * argument.
28.446 + * @throws NullPointerException if the string is null
28.447 + * @throws NumberFormatException if the string does not contain a
28.448 + * parsable {@code float}.
28.449 + * @see java.lang.Float#valueOf(String)
28.450 + * @since 1.2
28.451 + */
28.452 + public static float parseFloat(String s) throws NumberFormatException {
28.453 + throw new UnsupportedOperationException();
28.454 +// return FloatingDecimal.readJavaFormatString(s).floatValue();
28.455 + }
28.456 +
28.457 + /**
28.458 + * Returns {@code true} if the specified number is a
28.459 + * Not-a-Number (NaN) value, {@code false} otherwise.
28.460 + *
28.461 + * @param v the value to be tested.
28.462 + * @return {@code true} if the argument is NaN;
28.463 + * {@code false} otherwise.
28.464 + */
28.465 + static public boolean isNaN(float v) {
28.466 + return (v != v);
28.467 + }
28.468 +
28.469 + /**
28.470 + * Returns {@code true} if the specified number is infinitely
28.471 + * large in magnitude, {@code false} otherwise.
28.472 + *
28.473 + * @param v the value to be tested.
28.474 + * @return {@code true} if the argument is positive infinity or
28.475 + * negative infinity; {@code false} otherwise.
28.476 + */
28.477 + static public boolean isInfinite(float v) {
28.478 + return (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY);
28.479 + }
28.480 +
28.481 + /**
28.482 + * The value of the Float.
28.483 + *
28.484 + * @serial
28.485 + */
28.486 + private final float value;
28.487 +
28.488 + /**
28.489 + * Constructs a newly allocated {@code Float} object that
28.490 + * represents the primitive {@code float} argument.
28.491 + *
28.492 + * @param value the value to be represented by the {@code Float}.
28.493 + */
28.494 + public Float(float value) {
28.495 + this.value = value;
28.496 + }
28.497 +
28.498 + /**
28.499 + * Constructs a newly allocated {@code Float} object that
28.500 + * represents the argument converted to type {@code float}.
28.501 + *
28.502 + * @param value the value to be represented by the {@code Float}.
28.503 + */
28.504 + public Float(double value) {
28.505 + this.value = (float)value;
28.506 + }
28.507 +
28.508 + /**
28.509 + * Constructs a newly allocated {@code Float} object that
28.510 + * represents the floating-point value of type {@code float}
28.511 + * represented by the string. The string is converted to a
28.512 + * {@code float} value as if by the {@code valueOf} method.
28.513 + *
28.514 + * @param s a string to be converted to a {@code Float}.
28.515 + * @throws NumberFormatException if the string does not contain a
28.516 + * parsable number.
28.517 + * @see java.lang.Float#valueOf(java.lang.String)
28.518 + */
28.519 + public Float(String s) throws NumberFormatException {
28.520 + // REMIND: this is inefficient
28.521 + this(valueOf(s).floatValue());
28.522 + }
28.523 +
28.524 + /**
28.525 + * Returns {@code true} if this {@code Float} value is a
28.526 + * Not-a-Number (NaN), {@code false} otherwise.
28.527 + *
28.528 + * @return {@code true} if the value represented by this object is
28.529 + * NaN; {@code false} otherwise.
28.530 + */
28.531 + public boolean isNaN() {
28.532 + return isNaN(value);
28.533 + }
28.534 +
28.535 + /**
28.536 + * Returns {@code true} if this {@code Float} value is
28.537 + * infinitely large in magnitude, {@code false} otherwise.
28.538 + *
28.539 + * @return {@code true} if the value represented by this object is
28.540 + * positive infinity or negative infinity;
28.541 + * {@code false} otherwise.
28.542 + */
28.543 + public boolean isInfinite() {
28.544 + return isInfinite(value);
28.545 + }
28.546 +
28.547 + /**
28.548 + * Returns a string representation of this {@code Float} object.
28.549 + * The primitive {@code float} value represented by this object
28.550 + * is converted to a {@code String} exactly as if by the method
28.551 + * {@code toString} of one argument.
28.552 + *
28.553 + * @return a {@code String} representation of this object.
28.554 + * @see java.lang.Float#toString(float)
28.555 + */
28.556 + public String toString() {
28.557 + return Float.toString(value);
28.558 + }
28.559 +
28.560 + /**
28.561 + * Returns the value of this {@code Float} as a {@code byte} (by
28.562 + * casting to a {@code byte}).
28.563 + *
28.564 + * @return the {@code float} value represented by this object
28.565 + * converted to type {@code byte}
28.566 + */
28.567 + public byte byteValue() {
28.568 + return (byte)value;
28.569 + }
28.570 +
28.571 + /**
28.572 + * Returns the value of this {@code Float} as a {@code short} (by
28.573 + * casting to a {@code short}).
28.574 + *
28.575 + * @return the {@code float} value represented by this object
28.576 + * converted to type {@code short}
28.577 + * @since JDK1.1
28.578 + */
28.579 + public short shortValue() {
28.580 + return (short)value;
28.581 + }
28.582 +
28.583 + /**
28.584 + * Returns the value of this {@code Float} as an {@code int} (by
28.585 + * casting to type {@code int}).
28.586 + *
28.587 + * @return the {@code float} value represented by this object
28.588 + * converted to type {@code int}
28.589 + */
28.590 + public int intValue() {
28.591 + return (int)value;
28.592 + }
28.593 +
28.594 + /**
28.595 + * Returns value of this {@code Float} as a {@code long} (by
28.596 + * casting to type {@code long}).
28.597 + *
28.598 + * @return the {@code float} value represented by this object
28.599 + * converted to type {@code long}
28.600 + */
28.601 + public long longValue() {
28.602 + return (long)value;
28.603 + }
28.604 +
28.605 + /**
28.606 + * Returns the {@code float} value of this {@code Float} object.
28.607 + *
28.608 + * @return the {@code float} value represented by this object
28.609 + */
28.610 + public float floatValue() {
28.611 + return value;
28.612 + }
28.613 +
28.614 + /**
28.615 + * Returns the {@code double} value of this {@code Float} object.
28.616 + *
28.617 + * @return the {@code float} value represented by this
28.618 + * object is converted to type {@code double} and the
28.619 + * result of the conversion is returned.
28.620 + */
28.621 + public double doubleValue() {
28.622 + return (double)value;
28.623 + }
28.624 +
28.625 + /**
28.626 + * Returns a hash code for this {@code Float} object. The
28.627 + * result is the integer bit representation, exactly as produced
28.628 + * by the method {@link #floatToIntBits(float)}, of the primitive
28.629 + * {@code float} value represented by this {@code Float}
28.630 + * object.
28.631 + *
28.632 + * @return a hash code value for this object.
28.633 + */
28.634 + public int hashCode() {
28.635 + return floatToIntBits(value);
28.636 + }
28.637 +
28.638 + /**
28.639 +
28.640 + * Compares this object against the specified object. The result
28.641 + * is {@code true} if and only if the argument is not
28.642 + * {@code null} and is a {@code Float} object that
28.643 + * represents a {@code float} with the same value as the
28.644 + * {@code float} represented by this object. For this
28.645 + * purpose, two {@code float} values are considered to be the
28.646 + * same if and only if the method {@link #floatToIntBits(float)}
28.647 + * returns the identical {@code int} value when applied to
28.648 + * each.
28.649 + *
28.650 + * <p>Note that in most cases, for two instances of class
28.651 + * {@code Float}, {@code f1} and {@code f2}, the value
28.652 + * of {@code f1.equals(f2)} is {@code true} if and only if
28.653 + *
28.654 + * <blockquote><pre>
28.655 + * f1.floatValue() == f2.floatValue()
28.656 + * </pre></blockquote>
28.657 + *
28.658 + * <p>also has the value {@code true}. However, there are two exceptions:
28.659 + * <ul>
28.660 + * <li>If {@code f1} and {@code f2} both represent
28.661 + * {@code Float.NaN}, then the {@code equals} method returns
28.662 + * {@code true}, even though {@code Float.NaN==Float.NaN}
28.663 + * has the value {@code false}.
28.664 + * <li>If {@code f1} represents {@code +0.0f} while
28.665 + * {@code f2} represents {@code -0.0f}, or vice
28.666 + * versa, the {@code equal} test has the value
28.667 + * {@code false}, even though {@code 0.0f==-0.0f}
28.668 + * has the value {@code true}.
28.669 + * </ul>
28.670 + *
28.671 + * This definition allows hash tables to operate properly.
28.672 + *
28.673 + * @param obj the object to be compared
28.674 + * @return {@code true} if the objects are the same;
28.675 + * {@code false} otherwise.
28.676 + * @see java.lang.Float#floatToIntBits(float)
28.677 + */
28.678 + public boolean equals(Object obj) {
28.679 + return (obj instanceof Float)
28.680 + && (floatToIntBits(((Float)obj).value) == floatToIntBits(value));
28.681 + }
28.682 +
28.683 + /**
28.684 + * Returns a representation of the specified floating-point value
28.685 + * according to the IEEE 754 floating-point "single format" bit
28.686 + * layout.
28.687 + *
28.688 + * <p>Bit 31 (the bit that is selected by the mask
28.689 + * {@code 0x80000000}) represents the sign of the floating-point
28.690 + * number.
28.691 + * Bits 30-23 (the bits that are selected by the mask
28.692 + * {@code 0x7f800000}) represent the exponent.
28.693 + * Bits 22-0 (the bits that are selected by the mask
28.694 + * {@code 0x007fffff}) represent the significand (sometimes called
28.695 + * the mantissa) of the floating-point number.
28.696 + *
28.697 + * <p>If the argument is positive infinity, the result is
28.698 + * {@code 0x7f800000}.
28.699 + *
28.700 + * <p>If the argument is negative infinity, the result is
28.701 + * {@code 0xff800000}.
28.702 + *
28.703 + * <p>If the argument is NaN, the result is {@code 0x7fc00000}.
28.704 + *
28.705 + * <p>In all cases, the result is an integer that, when given to the
28.706 + * {@link #intBitsToFloat(int)} method, will produce a floating-point
28.707 + * value the same as the argument to {@code floatToIntBits}
28.708 + * (except all NaN values are collapsed to a single
28.709 + * "canonical" NaN value).
28.710 + *
28.711 + * @param value a floating-point number.
28.712 + * @return the bits that represent the floating-point number.
28.713 + */
28.714 + public static int floatToIntBits(float value) {
28.715 + throw new UnsupportedOperationException();
28.716 +// int result = floatToRawIntBits(value);
28.717 +// // Check for NaN based on values of bit fields, maximum
28.718 +// // exponent and nonzero significand.
28.719 +// if ( ((result & FloatConsts.EXP_BIT_MASK) ==
28.720 +// FloatConsts.EXP_BIT_MASK) &&
28.721 +// (result & FloatConsts.SIGNIF_BIT_MASK) != 0)
28.722 +// result = 0x7fc00000;
28.723 +// return result;
28.724 + }
28.725 +
28.726 + /**
28.727 + * Returns a representation of the specified floating-point value
28.728 + * according to the IEEE 754 floating-point "single format" bit
28.729 + * layout, preserving Not-a-Number (NaN) values.
28.730 + *
28.731 + * <p>Bit 31 (the bit that is selected by the mask
28.732 + * {@code 0x80000000}) represents the sign of the floating-point
28.733 + * number.
28.734 + * Bits 30-23 (the bits that are selected by the mask
28.735 + * {@code 0x7f800000}) represent the exponent.
28.736 + * Bits 22-0 (the bits that are selected by the mask
28.737 + * {@code 0x007fffff}) represent the significand (sometimes called
28.738 + * the mantissa) of the floating-point number.
28.739 + *
28.740 + * <p>If the argument is positive infinity, the result is
28.741 + * {@code 0x7f800000}.
28.742 + *
28.743 + * <p>If the argument is negative infinity, the result is
28.744 + * {@code 0xff800000}.
28.745 + *
28.746 + * <p>If the argument is NaN, the result is the integer representing
28.747 + * the actual NaN value. Unlike the {@code floatToIntBits}
28.748 + * method, {@code floatToRawIntBits} does not collapse all the
28.749 + * bit patterns encoding a NaN to a single "canonical"
28.750 + * NaN value.
28.751 + *
28.752 + * <p>In all cases, the result is an integer that, when given to the
28.753 + * {@link #intBitsToFloat(int)} method, will produce a
28.754 + * floating-point value the same as the argument to
28.755 + * {@code floatToRawIntBits}.
28.756 + *
28.757 + * @param value a floating-point number.
28.758 + * @return the bits that represent the floating-point number.
28.759 + * @since 1.3
28.760 + */
28.761 + public static native int floatToRawIntBits(float value);
28.762 +
28.763 + /**
28.764 + * Returns the {@code float} value corresponding to a given
28.765 + * bit representation.
28.766 + * The argument is considered to be a representation of a
28.767 + * floating-point value according to the IEEE 754 floating-point
28.768 + * "single format" bit layout.
28.769 + *
28.770 + * <p>If the argument is {@code 0x7f800000}, the result is positive
28.771 + * infinity.
28.772 + *
28.773 + * <p>If the argument is {@code 0xff800000}, the result is negative
28.774 + * infinity.
28.775 + *
28.776 + * <p>If the argument is any value in the range
28.777 + * {@code 0x7f800001} through {@code 0x7fffffff} or in
28.778 + * the range {@code 0xff800001} through
28.779 + * {@code 0xffffffff}, the result is a NaN. No IEEE 754
28.780 + * floating-point operation provided by Java can distinguish
28.781 + * between two NaN values of the same type with different bit
28.782 + * patterns. Distinct values of NaN are only distinguishable by
28.783 + * use of the {@code Float.floatToRawIntBits} method.
28.784 + *
28.785 + * <p>In all other cases, let <i>s</i>, <i>e</i>, and <i>m</i> be three
28.786 + * values that can be computed from the argument:
28.787 + *
28.788 + * <blockquote><pre>
28.789 + * int s = ((bits >> 31) == 0) ? 1 : -1;
28.790 + * int e = ((bits >> 23) & 0xff);
28.791 + * int m = (e == 0) ?
28.792 + * (bits & 0x7fffff) << 1 :
28.793 + * (bits & 0x7fffff) | 0x800000;
28.794 + * </pre></blockquote>
28.795 + *
28.796 + * Then the floating-point result equals the value of the mathematical
28.797 + * expression <i>s</i>·<i>m</i>·2<sup><i>e</i>-150</sup>.
28.798 + *
28.799 + * <p>Note that this method may not be able to return a
28.800 + * {@code float} NaN with exactly same bit pattern as the
28.801 + * {@code int} argument. IEEE 754 distinguishes between two
28.802 + * kinds of NaNs, quiet NaNs and <i>signaling NaNs</i>. The
28.803 + * differences between the two kinds of NaN are generally not
28.804 + * visible in Java. Arithmetic operations on signaling NaNs turn
28.805 + * them into quiet NaNs with a different, but often similar, bit
28.806 + * pattern. However, on some processors merely copying a
28.807 + * signaling NaN also performs that conversion. In particular,
28.808 + * copying a signaling NaN to return it to the calling method may
28.809 + * perform this conversion. So {@code intBitsToFloat} may
28.810 + * not be able to return a {@code float} with a signaling NaN
28.811 + * bit pattern. Consequently, for some {@code int} values,
28.812 + * {@code floatToRawIntBits(intBitsToFloat(start))} may
28.813 + * <i>not</i> equal {@code start}. Moreover, which
28.814 + * particular bit patterns represent signaling NaNs is platform
28.815 + * dependent; although all NaN bit patterns, quiet or signaling,
28.816 + * must be in the NaN range identified above.
28.817 + *
28.818 + * @param bits an integer.
28.819 + * @return the {@code float} floating-point value with the same bit
28.820 + * pattern.
28.821 + */
28.822 + public static native float intBitsToFloat(int bits);
28.823 +
28.824 + /**
28.825 + * Compares two {@code Float} objects numerically. There are
28.826 + * two ways in which comparisons performed by this method differ
28.827 + * from those performed by the Java language numerical comparison
28.828 + * operators ({@code <, <=, ==, >=, >}) when
28.829 + * applied to primitive {@code float} values:
28.830 + *
28.831 + * <ul><li>
28.832 + * {@code Float.NaN} is considered by this method to
28.833 + * be equal to itself and greater than all other
28.834 + * {@code float} values
28.835 + * (including {@code Float.POSITIVE_INFINITY}).
28.836 + * <li>
28.837 + * {@code 0.0f} is considered by this method to be greater
28.838 + * than {@code -0.0f}.
28.839 + * </ul>
28.840 + *
28.841 + * This ensures that the <i>natural ordering</i> of {@code Float}
28.842 + * objects imposed by this method is <i>consistent with equals</i>.
28.843 + *
28.844 + * @param anotherFloat the {@code Float} to be compared.
28.845 + * @return the value {@code 0} if {@code anotherFloat} is
28.846 + * numerically equal to this {@code Float}; a value
28.847 + * less than {@code 0} if this {@code Float}
28.848 + * is numerically less than {@code anotherFloat};
28.849 + * and a value greater than {@code 0} if this
28.850 + * {@code Float} is numerically greater than
28.851 + * {@code anotherFloat}.
28.852 + *
28.853 + * @since 1.2
28.854 + * @see Comparable#compareTo(Object)
28.855 + */
28.856 + public int compareTo(Float anotherFloat) {
28.857 + return Float.compare(value, anotherFloat.value);
28.858 + }
28.859 +
28.860 + /**
28.861 + * Compares the two specified {@code float} values. The sign
28.862 + * of the integer value returned is the same as that of the
28.863 + * integer that would be returned by the call:
28.864 + * <pre>
28.865 + * new Float(f1).compareTo(new Float(f2))
28.866 + * </pre>
28.867 + *
28.868 + * @param f1 the first {@code float} to compare.
28.869 + * @param f2 the second {@code float} to compare.
28.870 + * @return the value {@code 0} if {@code f1} is
28.871 + * numerically equal to {@code f2}; a value less than
28.872 + * {@code 0} if {@code f1} is numerically less than
28.873 + * {@code f2}; and a value greater than {@code 0}
28.874 + * if {@code f1} is numerically greater than
28.875 + * {@code f2}.
28.876 + * @since 1.4
28.877 + */
28.878 + public static int compare(float f1, float f2) {
28.879 + if (f1 < f2)
28.880 + return -1; // Neither val is NaN, thisVal is smaller
28.881 + if (f1 > f2)
28.882 + return 1; // Neither val is NaN, thisVal is larger
28.883 +
28.884 + // Cannot use floatToRawIntBits because of possibility of NaNs.
28.885 + int thisBits = Float.floatToIntBits(f1);
28.886 + int anotherBits = Float.floatToIntBits(f2);
28.887 +
28.888 + return (thisBits == anotherBits ? 0 : // Values are equal
28.889 + (thisBits < anotherBits ? -1 : // (-0.0, 0.0) or (!NaN, NaN)
28.890 + 1)); // (0.0, -0.0) or (NaN, !NaN)
28.891 + }
28.892 +
28.893 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
28.894 + private static final long serialVersionUID = -2671257302660747028L;
28.895 +}
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
29.2 +++ b/emul/src/main/java/java/lang/IllegalAccessException.java Thu Oct 11 06:16:00 2012 -0700
29.3 @@ -0,0 +1,78 @@
29.4 +/*
29.5 + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
29.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
29.7 + *
29.8 + * This code is free software; you can redistribute it and/or modify it
29.9 + * under the terms of the GNU General Public License version 2 only, as
29.10 + * published by the Free Software Foundation. Oracle designates this
29.11 + * particular file as subject to the "Classpath" exception as provided
29.12 + * by Oracle in the LICENSE file that accompanied this code.
29.13 + *
29.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
29.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
29.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
29.17 + * version 2 for more details (a copy is included in the LICENSE file that
29.18 + * accompanied this code).
29.19 + *
29.20 + * You should have received a copy of the GNU General Public License version
29.21 + * 2 along with this work; if not, write to the Free Software Foundation,
29.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
29.23 + *
29.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
29.25 + * or visit www.oracle.com if you need additional information or have any
29.26 + * questions.
29.27 + */
29.28 +
29.29 +package java.lang;
29.30 +
29.31 +/**
29.32 + * An IllegalAccessException is thrown when an application tries
29.33 + * to reflectively create an instance (other than an array),
29.34 + * set or get a field, or invoke a method, but the currently
29.35 + * executing method does not have access to the definition of
29.36 + * the specified class, field, method or constructor.
29.37 + *
29.38 + * @author unascribed
29.39 + * @see Class#newInstance()
29.40 + * @see java.lang.reflect.Field#set(Object, Object)
29.41 + * @see java.lang.reflect.Field#setBoolean(Object, boolean)
29.42 + * @see java.lang.reflect.Field#setByte(Object, byte)
29.43 + * @see java.lang.reflect.Field#setShort(Object, short)
29.44 + * @see java.lang.reflect.Field#setChar(Object, char)
29.45 + * @see java.lang.reflect.Field#setInt(Object, int)
29.46 + * @see java.lang.reflect.Field#setLong(Object, long)
29.47 + * @see java.lang.reflect.Field#setFloat(Object, float)
29.48 + * @see java.lang.reflect.Field#setDouble(Object, double)
29.49 + * @see java.lang.reflect.Field#get(Object)
29.50 + * @see java.lang.reflect.Field#getBoolean(Object)
29.51 + * @see java.lang.reflect.Field#getByte(Object)
29.52 + * @see java.lang.reflect.Field#getShort(Object)
29.53 + * @see java.lang.reflect.Field#getChar(Object)
29.54 + * @see java.lang.reflect.Field#getInt(Object)
29.55 + * @see java.lang.reflect.Field#getLong(Object)
29.56 + * @see java.lang.reflect.Field#getFloat(Object)
29.57 + * @see java.lang.reflect.Field#getDouble(Object)
29.58 + * @see java.lang.reflect.Method#invoke(Object, Object[])
29.59 + * @see java.lang.reflect.Constructor#newInstance(Object[])
29.60 + * @since JDK1.0
29.61 + */
29.62 +public class IllegalAccessException extends ReflectiveOperationException {
29.63 + private static final long serialVersionUID = 6616958222490762034L;
29.64 +
29.65 + /**
29.66 + * Constructs an <code>IllegalAccessException</code> without a
29.67 + * detail message.
29.68 + */
29.69 + public IllegalAccessException() {
29.70 + super();
29.71 + }
29.72 +
29.73 + /**
29.74 + * Constructs an <code>IllegalAccessException</code> with a detail message.
29.75 + *
29.76 + * @param s the detail message.
29.77 + */
29.78 + public IllegalAccessException(String s) {
29.79 + super(s);
29.80 + }
29.81 +}
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2 +++ b/emul/src/main/java/java/lang/IllegalArgumentException.java Thu Oct 11 06:16:00 2012 -0700
30.3 @@ -0,0 +1,95 @@
30.4 +/*
30.5 + * Copyright (c) 1994, 2003, Oracle and/or its affiliates. All rights reserved.
30.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
30.7 + *
30.8 + * This code is free software; you can redistribute it and/or modify it
30.9 + * under the terms of the GNU General Public License version 2 only, as
30.10 + * published by the Free Software Foundation. Oracle designates this
30.11 + * particular file as subject to the "Classpath" exception as provided
30.12 + * by Oracle in the LICENSE file that accompanied this code.
30.13 + *
30.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
30.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
30.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
30.17 + * version 2 for more details (a copy is included in the LICENSE file that
30.18 + * accompanied this code).
30.19 + *
30.20 + * You should have received a copy of the GNU General Public License version
30.21 + * 2 along with this work; if not, write to the Free Software Foundation,
30.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
30.23 + *
30.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
30.25 + * or visit www.oracle.com if you need additional information or have any
30.26 + * questions.
30.27 + */
30.28 +
30.29 +package java.lang;
30.30 +
30.31 +/**
30.32 + * Thrown to indicate that a method has been passed an illegal or
30.33 + * inappropriate argument.
30.34 + *
30.35 + * @author unascribed
30.36 + * @see java.lang.Thread#setPriority(int)
30.37 + * @since JDK1.0
30.38 + */
30.39 +public
30.40 +class IllegalArgumentException extends RuntimeException {
30.41 + /**
30.42 + * Constructs an <code>IllegalArgumentException</code> with no
30.43 + * detail message.
30.44 + */
30.45 + public IllegalArgumentException() {
30.46 + super();
30.47 + }
30.48 +
30.49 + /**
30.50 + * Constructs an <code>IllegalArgumentException</code> with the
30.51 + * specified detail message.
30.52 + *
30.53 + * @param s the detail message.
30.54 + */
30.55 + public IllegalArgumentException(String s) {
30.56 + super(s);
30.57 + }
30.58 +
30.59 + /**
30.60 + * Constructs a new exception with the specified detail message and
30.61 + * cause.
30.62 + *
30.63 + * <p>Note that the detail message associated with <code>cause</code> is
30.64 + * <i>not</i> automatically incorporated in this exception's detail
30.65 + * message.
30.66 + *
30.67 + * @param message the detail message (which is saved for later retrieval
30.68 + * by the {@link Throwable#getMessage()} method).
30.69 + * @param cause the cause (which is saved for later retrieval by the
30.70 + * {@link Throwable#getCause()} method). (A <tt>null</tt> value
30.71 + * is permitted, and indicates that the cause is nonexistent or
30.72 + * unknown.)
30.73 + * @since 1.5
30.74 + */
30.75 + public IllegalArgumentException(String message, Throwable cause) {
30.76 + super(message, cause);
30.77 + }
30.78 +
30.79 + /**
30.80 + * Constructs a new exception with the specified cause and a detail
30.81 + * message of <tt>(cause==null ? null : cause.toString())</tt> (which
30.82 + * typically contains the class and detail message of <tt>cause</tt>).
30.83 + * This constructor is useful for exceptions that are little more than
30.84 + * wrappers for other throwables (for example, {@link
30.85 + * java.security.PrivilegedActionException}).
30.86 + *
30.87 + * @param cause the cause (which is saved for later retrieval by the
30.88 + * {@link Throwable#getCause()} method). (A <tt>null</tt> value is
30.89 + * permitted, and indicates that the cause is nonexistent or
30.90 + * unknown.)
30.91 + * @since 1.5
30.92 + */
30.93 + public IllegalArgumentException(Throwable cause) {
30.94 + super(cause);
30.95 + }
30.96 +
30.97 + private static final long serialVersionUID = -5365630128856068164L;
30.98 +}
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
31.2 +++ b/emul/src/main/java/java/lang/IllegalStateException.java Thu Oct 11 06:16:00 2012 -0700
31.3 @@ -0,0 +1,97 @@
31.4 +/*
31.5 + * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.
31.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
31.7 + *
31.8 + * This code is free software; you can redistribute it and/or modify it
31.9 + * under the terms of the GNU General Public License version 2 only, as
31.10 + * published by the Free Software Foundation. Oracle designates this
31.11 + * particular file as subject to the "Classpath" exception as provided
31.12 + * by Oracle in the LICENSE file that accompanied this code.
31.13 + *
31.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
31.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
31.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
31.17 + * version 2 for more details (a copy is included in the LICENSE file that
31.18 + * accompanied this code).
31.19 + *
31.20 + * You should have received a copy of the GNU General Public License version
31.21 + * 2 along with this work; if not, write to the Free Software Foundation,
31.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
31.23 + *
31.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
31.25 + * or visit www.oracle.com if you need additional information or have any
31.26 + * questions.
31.27 + */
31.28 +
31.29 +package java.lang;
31.30 +
31.31 +/**
31.32 + * Signals that a method has been invoked at an illegal or
31.33 + * inappropriate time. In other words, the Java environment or
31.34 + * Java application is not in an appropriate state for the requested
31.35 + * operation.
31.36 + *
31.37 + * @author Jonni Kanerva
31.38 + * @since JDK1.1
31.39 + */
31.40 +public
31.41 +class IllegalStateException extends RuntimeException {
31.42 + /**
31.43 + * Constructs an IllegalStateException with no detail message.
31.44 + * A detail message is a String that describes this particular exception.
31.45 + */
31.46 + public IllegalStateException() {
31.47 + super();
31.48 + }
31.49 +
31.50 + /**
31.51 + * Constructs an IllegalStateException with the specified detail
31.52 + * message. A detail message is a String that describes this particular
31.53 + * exception.
31.54 + *
31.55 + * @param s the String that contains a detailed message
31.56 + */
31.57 + public IllegalStateException(String s) {
31.58 + super(s);
31.59 + }
31.60 +
31.61 + /**
31.62 + * Constructs a new exception with the specified detail message and
31.63 + * cause.
31.64 + *
31.65 + * <p>Note that the detail message associated with <code>cause</code> is
31.66 + * <i>not</i> automatically incorporated in this exception's detail
31.67 + * message.
31.68 + *
31.69 + * @param message the detail message (which is saved for later retrieval
31.70 + * by the {@link Throwable#getMessage()} method).
31.71 + * @param cause the cause (which is saved for later retrieval by the
31.72 + * {@link Throwable#getCause()} method). (A <tt>null</tt> value
31.73 + * is permitted, and indicates that the cause is nonexistent or
31.74 + * unknown.)
31.75 + * @since 1.5
31.76 + */
31.77 + public IllegalStateException(String message, Throwable cause) {
31.78 + super(message, cause);
31.79 + }
31.80 +
31.81 + /**
31.82 + * Constructs a new exception with the specified cause and a detail
31.83 + * message of <tt>(cause==null ? null : cause.toString())</tt> (which
31.84 + * typically contains the class and detail message of <tt>cause</tt>).
31.85 + * This constructor is useful for exceptions that are little more than
31.86 + * wrappers for other throwables (for example, {@link
31.87 + * java.security.PrivilegedActionException}).
31.88 + *
31.89 + * @param cause the cause (which is saved for later retrieval by the
31.90 + * {@link Throwable#getCause()} method). (A <tt>null</tt> value is
31.91 + * permitted, and indicates that the cause is nonexistent or
31.92 + * unknown.)
31.93 + * @since 1.5
31.94 + */
31.95 + public IllegalStateException(Throwable cause) {
31.96 + super(cause);
31.97 + }
31.98 +
31.99 + static final long serialVersionUID = -1848914673093119416L;
31.100 +}
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
32.2 +++ b/emul/src/main/java/java/lang/IndexOutOfBoundsException.java Thu Oct 11 06:16:00 2012 -0700
32.3 @@ -0,0 +1,58 @@
32.4 +/*
32.5 + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
32.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
32.7 + *
32.8 + * This code is free software; you can redistribute it and/or modify it
32.9 + * under the terms of the GNU General Public License version 2 only, as
32.10 + * published by the Free Software Foundation. Oracle designates this
32.11 + * particular file as subject to the "Classpath" exception as provided
32.12 + * by Oracle in the LICENSE file that accompanied this code.
32.13 + *
32.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
32.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
32.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
32.17 + * version 2 for more details (a copy is included in the LICENSE file that
32.18 + * accompanied this code).
32.19 + *
32.20 + * You should have received a copy of the GNU General Public License version
32.21 + * 2 along with this work; if not, write to the Free Software Foundation,
32.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
32.23 + *
32.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
32.25 + * or visit www.oracle.com if you need additional information or have any
32.26 + * questions.
32.27 + */
32.28 +
32.29 +package java.lang;
32.30 +
32.31 +/**
32.32 + * Thrown to indicate that an index of some sort (such as to an array, to a
32.33 + * string, or to a vector) is out of range.
32.34 + * <p>
32.35 + * Applications can subclass this class to indicate similar exceptions.
32.36 + *
32.37 + * @author Frank Yellin
32.38 + * @since JDK1.0
32.39 + */
32.40 +public
32.41 +class IndexOutOfBoundsException extends RuntimeException {
32.42 + private static final long serialVersionUID = 234122996006267687L;
32.43 +
32.44 + /**
32.45 + * Constructs an <code>IndexOutOfBoundsException</code> with no
32.46 + * detail message.
32.47 + */
32.48 + public IndexOutOfBoundsException() {
32.49 + super();
32.50 + }
32.51 +
32.52 + /**
32.53 + * Constructs an <code>IndexOutOfBoundsException</code> with the
32.54 + * specified detail message.
32.55 + *
32.56 + * @param s the detail message.
32.57 + */
32.58 + public IndexOutOfBoundsException(String s) {
32.59 + super(s);
32.60 + }
32.61 +}
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
33.2 +++ b/emul/src/main/java/java/lang/InstantiationException.java Thu Oct 11 06:16:00 2012 -0700
33.3 @@ -0,0 +1,65 @@
33.4 +/*
33.5 + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
33.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33.7 + *
33.8 + * This code is free software; you can redistribute it and/or modify it
33.9 + * under the terms of the GNU General Public License version 2 only, as
33.10 + * published by the Free Software Foundation. Oracle designates this
33.11 + * particular file as subject to the "Classpath" exception as provided
33.12 + * by Oracle in the LICENSE file that accompanied this code.
33.13 + *
33.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
33.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
33.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
33.17 + * version 2 for more details (a copy is included in the LICENSE file that
33.18 + * accompanied this code).
33.19 + *
33.20 + * You should have received a copy of the GNU General Public License version
33.21 + * 2 along with this work; if not, write to the Free Software Foundation,
33.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
33.23 + *
33.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
33.25 + * or visit www.oracle.com if you need additional information or have any
33.26 + * questions.
33.27 + */
33.28 +
33.29 +package java.lang;
33.30 +
33.31 +/**
33.32 + * Thrown when an application tries to create an instance of a class
33.33 + * using the {@code newInstance} method in class
33.34 + * {@code Class}, but the specified class object cannot be
33.35 + * instantiated. The instantiation can fail for a variety of
33.36 + * reasons including but not limited to:
33.37 + *
33.38 + * <ul>
33.39 + * <li> the class object represents an abstract class, an interface,
33.40 + * an array class, a primitive type, or {@code void}
33.41 + * <li> the class has no nullary constructor
33.42 + *</ul>
33.43 + *
33.44 + * @author unascribed
33.45 + * @see java.lang.Class#newInstance()
33.46 + * @since JDK1.0
33.47 + */
33.48 +public
33.49 +class InstantiationException extends ReflectiveOperationException {
33.50 + private static final long serialVersionUID = -8441929162975509110L;
33.51 +
33.52 + /**
33.53 + * Constructs an {@code InstantiationException} with no detail message.
33.54 + */
33.55 + public InstantiationException() {
33.56 + super();
33.57 + }
33.58 +
33.59 + /**
33.60 + * Constructs an {@code InstantiationException} with the
33.61 + * specified detail message.
33.62 + *
33.63 + * @param s the detail message.
33.64 + */
33.65 + public InstantiationException(String s) {
33.66 + super(s);
33.67 + }
33.68 +}
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
34.2 +++ b/emul/src/main/java/java/lang/Integer.java Thu Oct 11 06:16:00 2012 -0700
34.3 @@ -0,0 +1,1242 @@
34.4 +/*
34.5 + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
34.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
34.7 + *
34.8 + * This code is free software; you can redistribute it and/or modify it
34.9 + * under the terms of the GNU General Public License version 2 only, as
34.10 + * published by the Free Software Foundation. Oracle designates this
34.11 + * particular file as subject to the "Classpath" exception as provided
34.12 + * by Oracle in the LICENSE file that accompanied this code.
34.13 + *
34.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
34.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
34.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
34.17 + * version 2 for more details (a copy is included in the LICENSE file that
34.18 + * accompanied this code).
34.19 + *
34.20 + * You should have received a copy of the GNU General Public License version
34.21 + * 2 along with this work; if not, write to the Free Software Foundation,
34.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
34.23 + *
34.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
34.25 + * or visit www.oracle.com if you need additional information or have any
34.26 + * questions.
34.27 + */
34.28 +
34.29 +package java.lang;
34.30 +
34.31 +/**
34.32 + * The {@code Integer} class wraps a value of the primitive type
34.33 + * {@code int} in an object. An object of type {@code Integer}
34.34 + * contains a single field whose type is {@code int}.
34.35 + *
34.36 + * <p>In addition, this class provides several methods for converting
34.37 + * an {@code int} to a {@code String} and a {@code String} to an
34.38 + * {@code int}, as well as other constants and methods useful when
34.39 + * dealing with an {@code int}.
34.40 + *
34.41 + * <p>Implementation note: The implementations of the "bit twiddling"
34.42 + * methods (such as {@link #highestOneBit(int) highestOneBit} and
34.43 + * {@link #numberOfTrailingZeros(int) numberOfTrailingZeros}) are
34.44 + * based on material from Henry S. Warren, Jr.'s <i>Hacker's
34.45 + * Delight</i>, (Addison Wesley, 2002).
34.46 + *
34.47 + * @author Lee Boynton
34.48 + * @author Arthur van Hoff
34.49 + * @author Josh Bloch
34.50 + * @author Joseph D. Darcy
34.51 + * @since JDK1.0
34.52 + */
34.53 +public final class Integer extends Number implements Comparable<Integer> {
34.54 + /**
34.55 + * A constant holding the minimum value an {@code int} can
34.56 + * have, -2<sup>31</sup>.
34.57 + */
34.58 + public static final int MIN_VALUE = 0x80000000;
34.59 +
34.60 + /**
34.61 + * A constant holding the maximum value an {@code int} can
34.62 + * have, 2<sup>31</sup>-1.
34.63 + */
34.64 + public static final int MAX_VALUE = 0x7fffffff;
34.65 +
34.66 + /**
34.67 + * The {@code Class} instance representing the primitive type
34.68 + * {@code int}.
34.69 + *
34.70 + * @since JDK1.1
34.71 + */
34.72 + public static final Class<Integer> TYPE = (Class<Integer>) Class.getPrimitiveClass("int");
34.73 +
34.74 + /**
34.75 + * All possible chars for representing a number as a String
34.76 + */
34.77 + final static char[] digits = {
34.78 + '0' , '1' , '2' , '3' , '4' , '5' ,
34.79 + '6' , '7' , '8' , '9' , 'a' , 'b' ,
34.80 + 'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
34.81 + 'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
34.82 + 'o' , 'p' , 'q' , 'r' , 's' , 't' ,
34.83 + 'u' , 'v' , 'w' , 'x' , 'y' , 'z'
34.84 + };
34.85 +
34.86 + /**
34.87 + * Returns a string representation of the first argument in the
34.88 + * radix specified by the second argument.
34.89 + *
34.90 + * <p>If the radix is smaller than {@code Character.MIN_RADIX}
34.91 + * or larger than {@code Character.MAX_RADIX}, then the radix
34.92 + * {@code 10} is used instead.
34.93 + *
34.94 + * <p>If the first argument is negative, the first element of the
34.95 + * result is the ASCII minus character {@code '-'}
34.96 + * (<code>'\u002D'</code>). If the first argument is not
34.97 + * negative, no sign character appears in the result.
34.98 + *
34.99 + * <p>The remaining characters of the result represent the magnitude
34.100 + * of the first argument. If the magnitude is zero, it is
34.101 + * represented by a single zero character {@code '0'}
34.102 + * (<code>'\u0030'</code>); otherwise, the first character of
34.103 + * the representation of the magnitude will not be the zero
34.104 + * character. The following ASCII characters are used as digits:
34.105 + *
34.106 + * <blockquote>
34.107 + * {@code 0123456789abcdefghijklmnopqrstuvwxyz}
34.108 + * </blockquote>
34.109 + *
34.110 + * These are <code>'\u0030'</code> through
34.111 + * <code>'\u0039'</code> and <code>'\u0061'</code> through
34.112 + * <code>'\u007A'</code>. If {@code radix} is
34.113 + * <var>N</var>, then the first <var>N</var> of these characters
34.114 + * are used as radix-<var>N</var> digits in the order shown. Thus,
34.115 + * the digits for hexadecimal (radix 16) are
34.116 + * {@code 0123456789abcdef}. If uppercase letters are
34.117 + * desired, the {@link java.lang.String#toUpperCase()} method may
34.118 + * be called on the result:
34.119 + *
34.120 + * <blockquote>
34.121 + * {@code Integer.toString(n, 16).toUpperCase()}
34.122 + * </blockquote>
34.123 + *
34.124 + * @param i an integer to be converted to a string.
34.125 + * @param radix the radix to use in the string representation.
34.126 + * @return a string representation of the argument in the specified radix.
34.127 + * @see java.lang.Character#MAX_RADIX
34.128 + * @see java.lang.Character#MIN_RADIX
34.129 + */
34.130 + public static String toString(int i, int radix) {
34.131 +
34.132 + if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
34.133 + radix = 10;
34.134 +
34.135 + /* Use the faster version */
34.136 + if (radix == 10) {
34.137 + return toString(i);
34.138 + }
34.139 +
34.140 + char buf[] = new char[33];
34.141 + boolean negative = (i < 0);
34.142 + int charPos = 32;
34.143 +
34.144 + if (!negative) {
34.145 + i = -i;
34.146 + }
34.147 +
34.148 + while (i <= -radix) {
34.149 + buf[charPos--] = digits[-(i % radix)];
34.150 + i = i / radix;
34.151 + }
34.152 + buf[charPos] = digits[-i];
34.153 +
34.154 + if (negative) {
34.155 + buf[--charPos] = '-';
34.156 + }
34.157 +
34.158 + return new String(buf, charPos, (33 - charPos));
34.159 + }
34.160 +
34.161 + /**
34.162 + * Returns a string representation of the integer argument as an
34.163 + * unsigned integer in base 16.
34.164 + *
34.165 + * <p>The unsigned integer value is the argument plus 2<sup>32</sup>
34.166 + * if the argument is negative; otherwise, it is equal to the
34.167 + * argument. This value is converted to a string of ASCII digits
34.168 + * in hexadecimal (base 16) with no extra leading
34.169 + * {@code 0}s. If the unsigned magnitude is zero, it is
34.170 + * represented by a single zero character {@code '0'}
34.171 + * (<code>'\u0030'</code>); otherwise, the first character of
34.172 + * the representation of the unsigned magnitude will not be the
34.173 + * zero character. The following characters are used as
34.174 + * hexadecimal digits:
34.175 + *
34.176 + * <blockquote>
34.177 + * {@code 0123456789abcdef}
34.178 + * </blockquote>
34.179 + *
34.180 + * These are the characters <code>'\u0030'</code> through
34.181 + * <code>'\u0039'</code> and <code>'\u0061'</code> through
34.182 + * <code>'\u0066'</code>. If uppercase letters are
34.183 + * desired, the {@link java.lang.String#toUpperCase()} method may
34.184 + * be called on the result:
34.185 + *
34.186 + * <blockquote>
34.187 + * {@code Integer.toHexString(n).toUpperCase()}
34.188 + * </blockquote>
34.189 + *
34.190 + * @param i an integer to be converted to a string.
34.191 + * @return the string representation of the unsigned integer value
34.192 + * represented by the argument in hexadecimal (base 16).
34.193 + * @since JDK1.0.2
34.194 + */
34.195 + public static String toHexString(int i) {
34.196 + return toUnsignedString(i, 4);
34.197 + }
34.198 +
34.199 + /**
34.200 + * Returns a string representation of the integer argument as an
34.201 + * unsigned integer in base 8.
34.202 + *
34.203 + * <p>The unsigned integer value is the argument plus 2<sup>32</sup>
34.204 + * if the argument is negative; otherwise, it is equal to the
34.205 + * argument. This value is converted to a string of ASCII digits
34.206 + * in octal (base 8) with no extra leading {@code 0}s.
34.207 + *
34.208 + * <p>If the unsigned magnitude is zero, it is represented by a
34.209 + * single zero character {@code '0'}
34.210 + * (<code>'\u0030'</code>); otherwise, the first character of
34.211 + * the representation of the unsigned magnitude will not be the
34.212 + * zero character. The following characters are used as octal
34.213 + * digits:
34.214 + *
34.215 + * <blockquote>
34.216 + * {@code 01234567}
34.217 + * </blockquote>
34.218 + *
34.219 + * These are the characters <code>'\u0030'</code> through
34.220 + * <code>'\u0037'</code>.
34.221 + *
34.222 + * @param i an integer to be converted to a string.
34.223 + * @return the string representation of the unsigned integer value
34.224 + * represented by the argument in octal (base 8).
34.225 + * @since JDK1.0.2
34.226 + */
34.227 + public static String toOctalString(int i) {
34.228 + return toUnsignedString(i, 3);
34.229 + }
34.230 +
34.231 + /**
34.232 + * Returns a string representation of the integer argument as an
34.233 + * unsigned integer in base 2.
34.234 + *
34.235 + * <p>The unsigned integer value is the argument plus 2<sup>32</sup>
34.236 + * if the argument is negative; otherwise it is equal to the
34.237 + * argument. This value is converted to a string of ASCII digits
34.238 + * in binary (base 2) with no extra leading {@code 0}s.
34.239 + * If the unsigned magnitude is zero, it is represented by a
34.240 + * single zero character {@code '0'}
34.241 + * (<code>'\u0030'</code>); otherwise, the first character of
34.242 + * the representation of the unsigned magnitude will not be the
34.243 + * zero character. The characters {@code '0'}
34.244 + * (<code>'\u0030'</code>) and {@code '1'}
34.245 + * (<code>'\u0031'</code>) are used as binary digits.
34.246 + *
34.247 + * @param i an integer to be converted to a string.
34.248 + * @return the string representation of the unsigned integer value
34.249 + * represented by the argument in binary (base 2).
34.250 + * @since JDK1.0.2
34.251 + */
34.252 + public static String toBinaryString(int i) {
34.253 + return toUnsignedString(i, 1);
34.254 + }
34.255 +
34.256 + /**
34.257 + * Convert the integer to an unsigned number.
34.258 + */
34.259 + private static String toUnsignedString(int i, int shift) {
34.260 + char[] buf = new char[32];
34.261 + int charPos = 32;
34.262 + int radix = 1 << shift;
34.263 + int mask = radix - 1;
34.264 + do {
34.265 + buf[--charPos] = digits[i & mask];
34.266 + i >>>= shift;
34.267 + } while (i != 0);
34.268 +
34.269 + return new String(buf, charPos, (32 - charPos));
34.270 + }
34.271 +
34.272 +
34.273 + final static char [] DigitTens = {
34.274 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
34.275 + '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
34.276 + '2', '2', '2', '2', '2', '2', '2', '2', '2', '2',
34.277 + '3', '3', '3', '3', '3', '3', '3', '3', '3', '3',
34.278 + '4', '4', '4', '4', '4', '4', '4', '4', '4', '4',
34.279 + '5', '5', '5', '5', '5', '5', '5', '5', '5', '5',
34.280 + '6', '6', '6', '6', '6', '6', '6', '6', '6', '6',
34.281 + '7', '7', '7', '7', '7', '7', '7', '7', '7', '7',
34.282 + '8', '8', '8', '8', '8', '8', '8', '8', '8', '8',
34.283 + '9', '9', '9', '9', '9', '9', '9', '9', '9', '9',
34.284 + } ;
34.285 +
34.286 + final static char [] DigitOnes = {
34.287 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
34.288 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
34.289 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
34.290 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
34.291 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
34.292 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
34.293 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
34.294 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
34.295 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
34.296 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
34.297 + } ;
34.298 +
34.299 + // I use the "invariant division by multiplication" trick to
34.300 + // accelerate Integer.toString. In particular we want to
34.301 + // avoid division by 10.
34.302 + //
34.303 + // The "trick" has roughly the same performance characteristics
34.304 + // as the "classic" Integer.toString code on a non-JIT VM.
34.305 + // The trick avoids .rem and .div calls but has a longer code
34.306 + // path and is thus dominated by dispatch overhead. In the
34.307 + // JIT case the dispatch overhead doesn't exist and the
34.308 + // "trick" is considerably faster than the classic code.
34.309 + //
34.310 + // TODO-FIXME: convert (x * 52429) into the equiv shift-add
34.311 + // sequence.
34.312 + //
34.313 + // RE: Division by Invariant Integers using Multiplication
34.314 + // T Gralund, P Montgomery
34.315 + // ACM PLDI 1994
34.316 + //
34.317 +
34.318 + /**
34.319 + * Returns a {@code String} object representing the
34.320 + * specified integer. The argument is converted to signed decimal
34.321 + * representation and returned as a string, exactly as if the
34.322 + * argument and radix 10 were given as arguments to the {@link
34.323 + * #toString(int, int)} method.
34.324 + *
34.325 + * @param i an integer to be converted.
34.326 + * @return a string representation of the argument in base 10.
34.327 + */
34.328 + public static String toString(int i) {
34.329 + if (i == Integer.MIN_VALUE)
34.330 + return "-2147483648";
34.331 + int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
34.332 + char[] buf = new char[size];
34.333 + getChars(i, size, buf);
34.334 + return new String(0, size, buf);
34.335 + }
34.336 +
34.337 + /**
34.338 + * Places characters representing the integer i into the
34.339 + * character array buf. The characters are placed into
34.340 + * the buffer backwards starting with the least significant
34.341 + * digit at the specified index (exclusive), and working
34.342 + * backwards from there.
34.343 + *
34.344 + * Will fail if i == Integer.MIN_VALUE
34.345 + */
34.346 + static void getChars(int i, int index, char[] buf) {
34.347 + int q, r;
34.348 + int charPos = index;
34.349 + char sign = 0;
34.350 +
34.351 + if (i < 0) {
34.352 + sign = '-';
34.353 + i = -i;
34.354 + }
34.355 +
34.356 + // Generate two digits per iteration
34.357 + while (i >= 65536) {
34.358 + q = i / 100;
34.359 + // really: r = i - (q * 100);
34.360 + r = i - ((q << 6) + (q << 5) + (q << 2));
34.361 + i = q;
34.362 + buf [--charPos] = DigitOnes[r];
34.363 + buf [--charPos] = DigitTens[r];
34.364 + }
34.365 +
34.366 + // Fall thru to fast mode for smaller numbers
34.367 + // assert(i <= 65536, i);
34.368 + for (;;) {
34.369 + q = (i * 52429) >>> (16+3);
34.370 + r = i - ((q << 3) + (q << 1)); // r = i-(q*10) ...
34.371 + buf [--charPos] = digits [r];
34.372 + i = q;
34.373 + if (i == 0) break;
34.374 + }
34.375 + if (sign != 0) {
34.376 + buf [--charPos] = sign;
34.377 + }
34.378 + }
34.379 +
34.380 + final static int [] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999,
34.381 + 99999999, 999999999, Integer.MAX_VALUE };
34.382 +
34.383 + // Requires positive x
34.384 + static int stringSize(int x) {
34.385 + for (int i=0; ; i++)
34.386 + if (x <= sizeTable[i])
34.387 + return i+1;
34.388 + }
34.389 +
34.390 + /**
34.391 + * Parses the string argument as a signed integer in the radix
34.392 + * specified by the second argument. The characters in the string
34.393 + * must all be digits of the specified radix (as determined by
34.394 + * whether {@link java.lang.Character#digit(char, int)} returns a
34.395 + * nonnegative value), except that the first character may be an
34.396 + * ASCII minus sign {@code '-'} (<code>'\u002D'</code>) to
34.397 + * indicate a negative value or an ASCII plus sign {@code '+'}
34.398 + * (<code>'\u002B'</code>) to indicate a positive value. The
34.399 + * resulting integer value is returned.
34.400 + *
34.401 + * <p>An exception of type {@code NumberFormatException} is
34.402 + * thrown if any of the following situations occurs:
34.403 + * <ul>
34.404 + * <li>The first argument is {@code null} or is a string of
34.405 + * length zero.
34.406 + *
34.407 + * <li>The radix is either smaller than
34.408 + * {@link java.lang.Character#MIN_RADIX} or
34.409 + * larger than {@link java.lang.Character#MAX_RADIX}.
34.410 + *
34.411 + * <li>Any character of the string is not a digit of the specified
34.412 + * radix, except that the first character may be a minus sign
34.413 + * {@code '-'} (<code>'\u002D'</code>) or plus sign
34.414 + * {@code '+'} (<code>'\u002B'</code>) provided that the
34.415 + * string is longer than length 1.
34.416 + *
34.417 + * <li>The value represented by the string is not a value of type
34.418 + * {@code int}.
34.419 + * </ul>
34.420 + *
34.421 + * <p>Examples:
34.422 + * <blockquote><pre>
34.423 + * parseInt("0", 10) returns 0
34.424 + * parseInt("473", 10) returns 473
34.425 + * parseInt("+42", 10) returns 42
34.426 + * parseInt("-0", 10) returns 0
34.427 + * parseInt("-FF", 16) returns -255
34.428 + * parseInt("1100110", 2) returns 102
34.429 + * parseInt("2147483647", 10) returns 2147483647
34.430 + * parseInt("-2147483648", 10) returns -2147483648
34.431 + * parseInt("2147483648", 10) throws a NumberFormatException
34.432 + * parseInt("99", 8) throws a NumberFormatException
34.433 + * parseInt("Kona", 10) throws a NumberFormatException
34.434 + * parseInt("Kona", 27) returns 411787
34.435 + * </pre></blockquote>
34.436 + *
34.437 + * @param s the {@code String} containing the integer
34.438 + * representation to be parsed
34.439 + * @param radix the radix to be used while parsing {@code s}.
34.440 + * @return the integer represented by the string argument in the
34.441 + * specified radix.
34.442 + * @exception NumberFormatException if the {@code String}
34.443 + * does not contain a parsable {@code int}.
34.444 + */
34.445 + public static int parseInt(String s, int radix)
34.446 + throws NumberFormatException
34.447 + {
34.448 + /*
34.449 + * WARNING: This method may be invoked early during VM initialization
34.450 + * before IntegerCache is initialized. Care must be taken to not use
34.451 + * the valueOf method.
34.452 + */
34.453 +
34.454 + if (s == null) {
34.455 + throw new NumberFormatException("null");
34.456 + }
34.457 +
34.458 + if (radix < Character.MIN_RADIX) {
34.459 + throw new NumberFormatException("radix " + radix +
34.460 + " less than Character.MIN_RADIX");
34.461 + }
34.462 +
34.463 + if (radix > Character.MAX_RADIX) {
34.464 + throw new NumberFormatException("radix " + radix +
34.465 + " greater than Character.MAX_RADIX");
34.466 + }
34.467 +
34.468 + int result = 0;
34.469 + boolean negative = false;
34.470 + int i = 0, len = s.length();
34.471 + int limit = -Integer.MAX_VALUE;
34.472 + int multmin;
34.473 + int digit;
34.474 +
34.475 + if (len > 0) {
34.476 + char firstChar = s.charAt(0);
34.477 + if (firstChar < '0') { // Possible leading "+" or "-"
34.478 + if (firstChar == '-') {
34.479 + negative = true;
34.480 + limit = Integer.MIN_VALUE;
34.481 + } else if (firstChar != '+')
34.482 + throw NumberFormatException.forInputString(s);
34.483 +
34.484 + if (len == 1) // Cannot have lone "+" or "-"
34.485 + throw NumberFormatException.forInputString(s);
34.486 + i++;
34.487 + }
34.488 + multmin = limit / radix;
34.489 + while (i < len) {
34.490 + // Accumulating negatively avoids surprises near MAX_VALUE
34.491 + digit = Character.digit(s.charAt(i++),radix);
34.492 + if (digit < 0) {
34.493 + throw NumberFormatException.forInputString(s);
34.494 + }
34.495 + if (result < multmin) {
34.496 + throw NumberFormatException.forInputString(s);
34.497 + }
34.498 + result *= radix;
34.499 + if (result < limit + digit) {
34.500 + throw NumberFormatException.forInputString(s);
34.501 + }
34.502 + result -= digit;
34.503 + }
34.504 + } else {
34.505 + throw NumberFormatException.forInputString(s);
34.506 + }
34.507 + return negative ? result : -result;
34.508 + }
34.509 +
34.510 + /**
34.511 + * Parses the string argument as a signed decimal integer. The
34.512 + * characters in the string must all be decimal digits, except
34.513 + * that the first character may be an ASCII minus sign {@code '-'}
34.514 + * (<code>'\u002D'</code>) to indicate a negative value or an
34.515 + * ASCII plus sign {@code '+'} (<code>'\u002B'</code>) to
34.516 + * indicate a positive value. The resulting integer value is
34.517 + * returned, exactly as if the argument and the radix 10 were
34.518 + * given as arguments to the {@link #parseInt(java.lang.String,
34.519 + * int)} method.
34.520 + *
34.521 + * @param s a {@code String} containing the {@code int}
34.522 + * representation to be parsed
34.523 + * @return the integer value represented by the argument in decimal.
34.524 + * @exception NumberFormatException if the string does not contain a
34.525 + * parsable integer.
34.526 + */
34.527 + public static int parseInt(String s) throws NumberFormatException {
34.528 + return parseInt(s,10);
34.529 + }
34.530 +
34.531 + /**
34.532 + * Returns an {@code Integer} object holding the value
34.533 + * extracted from the specified {@code String} when parsed
34.534 + * with the radix given by the second argument. The first argument
34.535 + * is interpreted as representing a signed integer in the radix
34.536 + * specified by the second argument, exactly as if the arguments
34.537 + * were given to the {@link #parseInt(java.lang.String, int)}
34.538 + * method. The result is an {@code Integer} object that
34.539 + * represents the integer value specified by the string.
34.540 + *
34.541 + * <p>In other words, this method returns an {@code Integer}
34.542 + * object equal to the value of:
34.543 + *
34.544 + * <blockquote>
34.545 + * {@code new Integer(Integer.parseInt(s, radix))}
34.546 + * </blockquote>
34.547 + *
34.548 + * @param s the string to be parsed.
34.549 + * @param radix the radix to be used in interpreting {@code s}
34.550 + * @return an {@code Integer} object holding the value
34.551 + * represented by the string argument in the specified
34.552 + * radix.
34.553 + * @exception NumberFormatException if the {@code String}
34.554 + * does not contain a parsable {@code int}.
34.555 + */
34.556 + public static Integer valueOf(String s, int radix) throws NumberFormatException {
34.557 + return Integer.valueOf(parseInt(s,radix));
34.558 + }
34.559 +
34.560 + /**
34.561 + * Returns an {@code Integer} object holding the
34.562 + * value of the specified {@code String}. The argument is
34.563 + * interpreted as representing a signed decimal integer, exactly
34.564 + * as if the argument were given to the {@link
34.565 + * #parseInt(java.lang.String)} method. The result is an
34.566 + * {@code Integer} object that represents the integer value
34.567 + * specified by the string.
34.568 + *
34.569 + * <p>In other words, this method returns an {@code Integer}
34.570 + * object equal to the value of:
34.571 + *
34.572 + * <blockquote>
34.573 + * {@code new Integer(Integer.parseInt(s))}
34.574 + * </blockquote>
34.575 + *
34.576 + * @param s the string to be parsed.
34.577 + * @return an {@code Integer} object holding the value
34.578 + * represented by the string argument.
34.579 + * @exception NumberFormatException if the string cannot be parsed
34.580 + * as an integer.
34.581 + */
34.582 + public static Integer valueOf(String s) throws NumberFormatException {
34.583 + return Integer.valueOf(parseInt(s, 10));
34.584 + }
34.585 +
34.586 + /**
34.587 + * Cache to support the object identity semantics of autoboxing for values between
34.588 + * -128 and 127 (inclusive) as required by JLS.
34.589 + *
34.590 + * The cache is initialized on first usage. The size of the cache
34.591 + * may be controlled by the -XX:AutoBoxCacheMax=<size> option.
34.592 + * During VM initialization, java.lang.Integer.IntegerCache.high property
34.593 + * may be set and saved in the private system properties in the
34.594 + * sun.misc.VM class.
34.595 + */
34.596 +
34.597 + private static class IntegerCache {
34.598 + static final int low = -128;
34.599 + static final int high;
34.600 + static final Integer cache[];
34.601 +
34.602 + static {
34.603 + // high value may be configured by property
34.604 + int h = 127;
34.605 + String integerCacheHighPropValue =
34.606 + String.getProperty("java.lang.Integer.IntegerCache.high");
34.607 + if (integerCacheHighPropValue != null) {
34.608 + int i = parseInt(integerCacheHighPropValue);
34.609 + i = Math.max(i, 127);
34.610 + // Maximum array size is Integer.MAX_VALUE
34.611 + h = Math.min(i, Integer.MAX_VALUE - (-low));
34.612 + }
34.613 + high = h;
34.614 +
34.615 + cache = new Integer[(high - low) + 1];
34.616 + int j = low;
34.617 + for(int k = 0; k < cache.length; k++)
34.618 + cache[k] = new Integer(j++);
34.619 + }
34.620 +
34.621 + private IntegerCache() {}
34.622 + }
34.623 +
34.624 + /**
34.625 + * Returns an {@code Integer} instance representing the specified
34.626 + * {@code int} value. If a new {@code Integer} instance is not
34.627 + * required, this method should generally be used in preference to
34.628 + * the constructor {@link #Integer(int)}, as this method is likely
34.629 + * to yield significantly better space and time performance by
34.630 + * caching frequently requested values.
34.631 + *
34.632 + * This method will always cache values in the range -128 to 127,
34.633 + * inclusive, and may cache other values outside of this range.
34.634 + *
34.635 + * @param i an {@code int} value.
34.636 + * @return an {@code Integer} instance representing {@code i}.
34.637 + * @since 1.5
34.638 + */
34.639 + public static Integer valueOf(int i) {
34.640 + //assert IntegerCache.high >= 127;
34.641 + if (i >= IntegerCache.low && i <= IntegerCache.high)
34.642 + return IntegerCache.cache[i + (-IntegerCache.low)];
34.643 + return new Integer(i);
34.644 + }
34.645 +
34.646 + /**
34.647 + * The value of the {@code Integer}.
34.648 + *
34.649 + * @serial
34.650 + */
34.651 + private final int value;
34.652 +
34.653 + /**
34.654 + * Constructs a newly allocated {@code Integer} object that
34.655 + * represents the specified {@code int} value.
34.656 + *
34.657 + * @param value the value to be represented by the
34.658 + * {@code Integer} object.
34.659 + */
34.660 + public Integer(int value) {
34.661 + this.value = value;
34.662 + }
34.663 +
34.664 + /**
34.665 + * Constructs a newly allocated {@code Integer} object that
34.666 + * represents the {@code int} value indicated by the
34.667 + * {@code String} parameter. The string is converted to an
34.668 + * {@code int} value in exactly the manner used by the
34.669 + * {@code parseInt} method for radix 10.
34.670 + *
34.671 + * @param s the {@code String} to be converted to an
34.672 + * {@code Integer}.
34.673 + * @exception NumberFormatException if the {@code String} does not
34.674 + * contain a parsable integer.
34.675 + * @see java.lang.Integer#parseInt(java.lang.String, int)
34.676 + */
34.677 + public Integer(String s) throws NumberFormatException {
34.678 + this.value = parseInt(s, 10);
34.679 + }
34.680 +
34.681 + /**
34.682 + * Returns the value of this {@code Integer} as a
34.683 + * {@code byte}.
34.684 + */
34.685 + public byte byteValue() {
34.686 + return (byte)value;
34.687 + }
34.688 +
34.689 + /**
34.690 + * Returns the value of this {@code Integer} as a
34.691 + * {@code short}.
34.692 + */
34.693 + public short shortValue() {
34.694 + return (short)value;
34.695 + }
34.696 +
34.697 + /**
34.698 + * Returns the value of this {@code Integer} as an
34.699 + * {@code int}.
34.700 + */
34.701 + public int intValue() {
34.702 + return value;
34.703 + }
34.704 +
34.705 + /**
34.706 + * Returns the value of this {@code Integer} as a
34.707 + * {@code long}.
34.708 + */
34.709 + public long longValue() {
34.710 + return (long)value;
34.711 + }
34.712 +
34.713 + /**
34.714 + * Returns the value of this {@code Integer} as a
34.715 + * {@code float}.
34.716 + */
34.717 + public float floatValue() {
34.718 + return (float)value;
34.719 + }
34.720 +
34.721 + /**
34.722 + * Returns the value of this {@code Integer} as a
34.723 + * {@code double}.
34.724 + */
34.725 + public double doubleValue() {
34.726 + return (double)value;
34.727 + }
34.728 +
34.729 + /**
34.730 + * Returns a {@code String} object representing this
34.731 + * {@code Integer}'s value. The value is converted to signed
34.732 + * decimal representation and returned as a string, exactly as if
34.733 + * the integer value were given as an argument to the {@link
34.734 + * java.lang.Integer#toString(int)} method.
34.735 + *
34.736 + * @return a string representation of the value of this object in
34.737 + * base 10.
34.738 + */
34.739 + public String toString() {
34.740 + return toString(value);
34.741 + }
34.742 +
34.743 + /**
34.744 + * Returns a hash code for this {@code Integer}.
34.745 + *
34.746 + * @return a hash code value for this object, equal to the
34.747 + * primitive {@code int} value represented by this
34.748 + * {@code Integer} object.
34.749 + */
34.750 + public int hashCode() {
34.751 + return value;
34.752 + }
34.753 +
34.754 + /**
34.755 + * Compares this object to the specified object. The result is
34.756 + * {@code true} if and only if the argument is not
34.757 + * {@code null} and is an {@code Integer} object that
34.758 + * contains the same {@code int} value as this object.
34.759 + *
34.760 + * @param obj the object to compare with.
34.761 + * @return {@code true} if the objects are the same;
34.762 + * {@code false} otherwise.
34.763 + */
34.764 + public boolean equals(Object obj) {
34.765 + if (obj instanceof Integer) {
34.766 + return value == ((Integer)obj).intValue();
34.767 + }
34.768 + return false;
34.769 + }
34.770 +
34.771 + /**
34.772 + * Determines the integer value of the system property with the
34.773 + * specified name.
34.774 + *
34.775 + * <p>The first argument is treated as the name of a system property.
34.776 + * System properties are accessible through the
34.777 + * {@link java.lang.System#getProperty(java.lang.String)} method. The
34.778 + * string value of this property is then interpreted as an integer
34.779 + * value and an {@code Integer} object representing this value is
34.780 + * returned. Details of possible numeric formats can be found with
34.781 + * the definition of {@code getProperty}.
34.782 + *
34.783 + * <p>If there is no property with the specified name, if the specified name
34.784 + * is empty or {@code null}, or if the property does not have
34.785 + * the correct numeric format, then {@code null} is returned.
34.786 + *
34.787 + * <p>In other words, this method returns an {@code Integer}
34.788 + * object equal to the value of:
34.789 + *
34.790 + * <blockquote>
34.791 + * {@code getInteger(nm, null)}
34.792 + * </blockquote>
34.793 + *
34.794 + * @param nm property name.
34.795 + * @return the {@code Integer} value of the property.
34.796 + * @see java.lang.System#getProperty(java.lang.String)
34.797 + * @see java.lang.System#getProperty(java.lang.String, java.lang.String)
34.798 + */
34.799 + public static Integer getInteger(String nm) {
34.800 + return getInteger(nm, null);
34.801 + }
34.802 +
34.803 + /**
34.804 + * Determines the integer value of the system property with the
34.805 + * specified name.
34.806 + *
34.807 + * <p>The first argument is treated as the name of a system property.
34.808 + * System properties are accessible through the {@link
34.809 + * java.lang.System#getProperty(java.lang.String)} method. The
34.810 + * string value of this property is then interpreted as an integer
34.811 + * value and an {@code Integer} object representing this value is
34.812 + * returned. Details of possible numeric formats can be found with
34.813 + * the definition of {@code getProperty}.
34.814 + *
34.815 + * <p>The second argument is the default value. An {@code Integer} object
34.816 + * that represents the value of the second argument is returned if there
34.817 + * is no property of the specified name, if the property does not have
34.818 + * the correct numeric format, or if the specified name is empty or
34.819 + * {@code null}.
34.820 + *
34.821 + * <p>In other words, this method returns an {@code Integer} object
34.822 + * equal to the value of:
34.823 + *
34.824 + * <blockquote>
34.825 + * {@code getInteger(nm, new Integer(val))}
34.826 + * </blockquote>
34.827 + *
34.828 + * but in practice it may be implemented in a manner such as:
34.829 + *
34.830 + * <blockquote><pre>
34.831 + * Integer result = getInteger(nm, null);
34.832 + * return (result == null) ? new Integer(val) : result;
34.833 + * </pre></blockquote>
34.834 + *
34.835 + * to avoid the unnecessary allocation of an {@code Integer}
34.836 + * object when the default value is not needed.
34.837 + *
34.838 + * @param nm property name.
34.839 + * @param val default value.
34.840 + * @return the {@code Integer} value of the property.
34.841 + * @see java.lang.System#getProperty(java.lang.String)
34.842 + * @see java.lang.System#getProperty(java.lang.String, java.lang.String)
34.843 + */
34.844 + public static Integer getInteger(String nm, int val) {
34.845 + Integer result = getInteger(nm, null);
34.846 + return (result == null) ? Integer.valueOf(val) : result;
34.847 + }
34.848 +
34.849 + /**
34.850 + * Returns the integer value of the system property with the
34.851 + * specified name. The first argument is treated as the name of a
34.852 + * system property. System properties are accessible through the
34.853 + * {@link java.lang.System#getProperty(java.lang.String)} method.
34.854 + * The string value of this property is then interpreted as an
34.855 + * integer value, as per the {@code Integer.decode} method,
34.856 + * and an {@code Integer} object representing this value is
34.857 + * returned.
34.858 + *
34.859 + * <ul><li>If the property value begins with the two ASCII characters
34.860 + * {@code 0x} or the ASCII character {@code #}, not
34.861 + * followed by a minus sign, then the rest of it is parsed as a
34.862 + * hexadecimal integer exactly as by the method
34.863 + * {@link #valueOf(java.lang.String, int)} with radix 16.
34.864 + * <li>If the property value begins with the ASCII character
34.865 + * {@code 0} followed by another character, it is parsed as an
34.866 + * octal integer exactly as by the method
34.867 + * {@link #valueOf(java.lang.String, int)} with radix 8.
34.868 + * <li>Otherwise, the property value is parsed as a decimal integer
34.869 + * exactly as by the method {@link #valueOf(java.lang.String, int)}
34.870 + * with radix 10.
34.871 + * </ul>
34.872 + *
34.873 + * <p>The second argument is the default value. The default value is
34.874 + * returned if there is no property of the specified name, if the
34.875 + * property does not have the correct numeric format, or if the
34.876 + * specified name is empty or {@code null}.
34.877 + *
34.878 + * @param nm property name.
34.879 + * @param val default value.
34.880 + * @return the {@code Integer} value of the property.
34.881 + * @see java.lang.System#getProperty(java.lang.String)
34.882 + * @see java.lang.System#getProperty(java.lang.String, java.lang.String)
34.883 + * @see java.lang.Integer#decode
34.884 + */
34.885 + public static Integer getInteger(String nm, Integer val) {
34.886 + String v = null;
34.887 + try {
34.888 + v = String.getProperty(nm);
34.889 + } catch (IllegalArgumentException e) {
34.890 + } catch (NullPointerException e) {
34.891 + }
34.892 + if (v != null) {
34.893 + try {
34.894 + return Integer.decode(v);
34.895 + } catch (NumberFormatException e) {
34.896 + }
34.897 + }
34.898 + return val;
34.899 + }
34.900 +
34.901 + /**
34.902 + * Decodes a {@code String} into an {@code Integer}.
34.903 + * Accepts decimal, hexadecimal, and octal numbers given
34.904 + * by the following grammar:
34.905 + *
34.906 + * <blockquote>
34.907 + * <dl>
34.908 + * <dt><i>DecodableString:</i>
34.909 + * <dd><i>Sign<sub>opt</sub> DecimalNumeral</i>
34.910 + * <dd><i>Sign<sub>opt</sub></i> {@code 0x} <i>HexDigits</i>
34.911 + * <dd><i>Sign<sub>opt</sub></i> {@code 0X} <i>HexDigits</i>
34.912 + * <dd><i>Sign<sub>opt</sub></i> {@code #} <i>HexDigits</i>
34.913 + * <dd><i>Sign<sub>opt</sub></i> {@code 0} <i>OctalDigits</i>
34.914 + * <p>
34.915 + * <dt><i>Sign:</i>
34.916 + * <dd>{@code -}
34.917 + * <dd>{@code +}
34.918 + * </dl>
34.919 + * </blockquote>
34.920 + *
34.921 + * <i>DecimalNumeral</i>, <i>HexDigits</i>, and <i>OctalDigits</i>
34.922 + * are as defined in section 3.10.1 of
34.923 + * <cite>The Java™ Language Specification</cite>,
34.924 + * except that underscores are not accepted between digits.
34.925 + *
34.926 + * <p>The sequence of characters following an optional
34.927 + * sign and/or radix specifier ("{@code 0x}", "{@code 0X}",
34.928 + * "{@code #}", or leading zero) is parsed as by the {@code
34.929 + * Integer.parseInt} method with the indicated radix (10, 16, or
34.930 + * 8). This sequence of characters must represent a positive
34.931 + * value or a {@link NumberFormatException} will be thrown. The
34.932 + * result is negated if first character of the specified {@code
34.933 + * String} is the minus sign. No whitespace characters are
34.934 + * permitted in the {@code String}.
34.935 + *
34.936 + * @param nm the {@code String} to decode.
34.937 + * @return an {@code Integer} object holding the {@code int}
34.938 + * value represented by {@code nm}
34.939 + * @exception NumberFormatException if the {@code String} does not
34.940 + * contain a parsable integer.
34.941 + * @see java.lang.Integer#parseInt(java.lang.String, int)
34.942 + */
34.943 + public static Integer decode(String nm) throws NumberFormatException {
34.944 + int radix = 10;
34.945 + int index = 0;
34.946 + boolean negative = false;
34.947 + Integer result;
34.948 +
34.949 + if (nm.length() == 0)
34.950 + throw new NumberFormatException("Zero length string");
34.951 + char firstChar = nm.charAt(0);
34.952 + // Handle sign, if present
34.953 + if (firstChar == '-') {
34.954 + negative = true;
34.955 + index++;
34.956 + } else if (firstChar == '+')
34.957 + index++;
34.958 +
34.959 + // Handle radix specifier, if present
34.960 + if (nm.startsWith("0x", index) || nm.startsWith("0X", index)) {
34.961 + index += 2;
34.962 + radix = 16;
34.963 + }
34.964 + else if (nm.startsWith("#", index)) {
34.965 + index ++;
34.966 + radix = 16;
34.967 + }
34.968 + else if (nm.startsWith("0", index) && nm.length() > 1 + index) {
34.969 + index ++;
34.970 + radix = 8;
34.971 + }
34.972 +
34.973 + if (nm.startsWith("-", index) || nm.startsWith("+", index))
34.974 + throw new NumberFormatException("Sign character in wrong position");
34.975 +
34.976 + try {
34.977 + result = Integer.valueOf(nm.substring(index), radix);
34.978 + result = negative ? Integer.valueOf(-result.intValue()) : result;
34.979 + } catch (NumberFormatException e) {
34.980 + // If number is Integer.MIN_VALUE, we'll end up here. The next line
34.981 + // handles this case, and causes any genuine format error to be
34.982 + // rethrown.
34.983 + String constant = negative ? ("-" + nm.substring(index))
34.984 + : nm.substring(index);
34.985 + result = Integer.valueOf(constant, radix);
34.986 + }
34.987 + return result;
34.988 + }
34.989 +
34.990 + /**
34.991 + * Compares two {@code Integer} objects numerically.
34.992 + *
34.993 + * @param anotherInteger the {@code Integer} to be compared.
34.994 + * @return the value {@code 0} if this {@code Integer} is
34.995 + * equal to the argument {@code Integer}; a value less than
34.996 + * {@code 0} if this {@code Integer} is numerically less
34.997 + * than the argument {@code Integer}; and a value greater
34.998 + * than {@code 0} if this {@code Integer} is numerically
34.999 + * greater than the argument {@code Integer} (signed
34.1000 + * comparison).
34.1001 + * @since 1.2
34.1002 + */
34.1003 + public int compareTo(Integer anotherInteger) {
34.1004 + return compare(this.value, anotherInteger.value);
34.1005 + }
34.1006 +
34.1007 + /**
34.1008 + * Compares two {@code int} values numerically.
34.1009 + * The value returned is identical to what would be returned by:
34.1010 + * <pre>
34.1011 + * Integer.valueOf(x).compareTo(Integer.valueOf(y))
34.1012 + * </pre>
34.1013 + *
34.1014 + * @param x the first {@code int} to compare
34.1015 + * @param y the second {@code int} to compare
34.1016 + * @return the value {@code 0} if {@code x == y};
34.1017 + * a value less than {@code 0} if {@code x < y}; and
34.1018 + * a value greater than {@code 0} if {@code x > y}
34.1019 + * @since 1.7
34.1020 + */
34.1021 + public static int compare(int x, int y) {
34.1022 + return (x < y) ? -1 : ((x == y) ? 0 : 1);
34.1023 + }
34.1024 +
34.1025 +
34.1026 + // Bit twiddling
34.1027 +
34.1028 + /**
34.1029 + * The number of bits used to represent an {@code int} value in two's
34.1030 + * complement binary form.
34.1031 + *
34.1032 + * @since 1.5
34.1033 + */
34.1034 + public static final int SIZE = 32;
34.1035 +
34.1036 + /**
34.1037 + * Returns an {@code int} value with at most a single one-bit, in the
34.1038 + * position of the highest-order ("leftmost") one-bit in the specified
34.1039 + * {@code int} value. Returns zero if the specified value has no
34.1040 + * one-bits in its two's complement binary representation, that is, if it
34.1041 + * is equal to zero.
34.1042 + *
34.1043 + * @return an {@code int} value with a single one-bit, in the position
34.1044 + * of the highest-order one-bit in the specified value, or zero if
34.1045 + * the specified value is itself equal to zero.
34.1046 + * @since 1.5
34.1047 + */
34.1048 + public static int highestOneBit(int i) {
34.1049 + // HD, Figure 3-1
34.1050 + i |= (i >> 1);
34.1051 + i |= (i >> 2);
34.1052 + i |= (i >> 4);
34.1053 + i |= (i >> 8);
34.1054 + i |= (i >> 16);
34.1055 + return i - (i >>> 1);
34.1056 + }
34.1057 +
34.1058 + /**
34.1059 + * Returns an {@code int} value with at most a single one-bit, in the
34.1060 + * position of the lowest-order ("rightmost") one-bit in the specified
34.1061 + * {@code int} value. Returns zero if the specified value has no
34.1062 + * one-bits in its two's complement binary representation, that is, if it
34.1063 + * is equal to zero.
34.1064 + *
34.1065 + * @return an {@code int} value with a single one-bit, in the position
34.1066 + * of the lowest-order one-bit in the specified value, or zero if
34.1067 + * the specified value is itself equal to zero.
34.1068 + * @since 1.5
34.1069 + */
34.1070 + public static int lowestOneBit(int i) {
34.1071 + // HD, Section 2-1
34.1072 + return i & -i;
34.1073 + }
34.1074 +
34.1075 + /**
34.1076 + * Returns the number of zero bits preceding the highest-order
34.1077 + * ("leftmost") one-bit in the two's complement binary representation
34.1078 + * of the specified {@code int} value. Returns 32 if the
34.1079 + * specified value has no one-bits in its two's complement representation,
34.1080 + * in other words if it is equal to zero.
34.1081 + *
34.1082 + * <p>Note that this method is closely related to the logarithm base 2.
34.1083 + * For all positive {@code int} values x:
34.1084 + * <ul>
34.1085 + * <li>floor(log<sub>2</sub>(x)) = {@code 31 - numberOfLeadingZeros(x)}
34.1086 + * <li>ceil(log<sub>2</sub>(x)) = {@code 32 - numberOfLeadingZeros(x - 1)}
34.1087 + * </ul>
34.1088 + *
34.1089 + * @return the number of zero bits preceding the highest-order
34.1090 + * ("leftmost") one-bit in the two's complement binary representation
34.1091 + * of the specified {@code int} value, or 32 if the value
34.1092 + * is equal to zero.
34.1093 + * @since 1.5
34.1094 + */
34.1095 + public static int numberOfLeadingZeros(int i) {
34.1096 + // HD, Figure 5-6
34.1097 + if (i == 0)
34.1098 + return 32;
34.1099 + int n = 1;
34.1100 + if (i >>> 16 == 0) { n += 16; i <<= 16; }
34.1101 + if (i >>> 24 == 0) { n += 8; i <<= 8; }
34.1102 + if (i >>> 28 == 0) { n += 4; i <<= 4; }
34.1103 + if (i >>> 30 == 0) { n += 2; i <<= 2; }
34.1104 + n -= i >>> 31;
34.1105 + return n;
34.1106 + }
34.1107 +
34.1108 + /**
34.1109 + * Returns the number of zero bits following the lowest-order ("rightmost")
34.1110 + * one-bit in the two's complement binary representation of the specified
34.1111 + * {@code int} value. Returns 32 if the specified value has no
34.1112 + * one-bits in its two's complement representation, in other words if it is
34.1113 + * equal to zero.
34.1114 + *
34.1115 + * @return the number of zero bits following the lowest-order ("rightmost")
34.1116 + * one-bit in the two's complement binary representation of the
34.1117 + * specified {@code int} value, or 32 if the value is equal
34.1118 + * to zero.
34.1119 + * @since 1.5
34.1120 + */
34.1121 + public static int numberOfTrailingZeros(int i) {
34.1122 + // HD, Figure 5-14
34.1123 + int y;
34.1124 + if (i == 0) return 32;
34.1125 + int n = 31;
34.1126 + y = i <<16; if (y != 0) { n = n -16; i = y; }
34.1127 + y = i << 8; if (y != 0) { n = n - 8; i = y; }
34.1128 + y = i << 4; if (y != 0) { n = n - 4; i = y; }
34.1129 + y = i << 2; if (y != 0) { n = n - 2; i = y; }
34.1130 + return n - ((i << 1) >>> 31);
34.1131 + }
34.1132 +
34.1133 + /**
34.1134 + * Returns the number of one-bits in the two's complement binary
34.1135 + * representation of the specified {@code int} value. This function is
34.1136 + * sometimes referred to as the <i>population count</i>.
34.1137 + *
34.1138 + * @return the number of one-bits in the two's complement binary
34.1139 + * representation of the specified {@code int} value.
34.1140 + * @since 1.5
34.1141 + */
34.1142 + public static int bitCount(int i) {
34.1143 + // HD, Figure 5-2
34.1144 + i = i - ((i >>> 1) & 0x55555555);
34.1145 + i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);
34.1146 + i = (i + (i >>> 4)) & 0x0f0f0f0f;
34.1147 + i = i + (i >>> 8);
34.1148 + i = i + (i >>> 16);
34.1149 + return i & 0x3f;
34.1150 + }
34.1151 +
34.1152 + /**
34.1153 + * Returns the value obtained by rotating the two's complement binary
34.1154 + * representation of the specified {@code int} value left by the
34.1155 + * specified number of bits. (Bits shifted out of the left hand, or
34.1156 + * high-order, side reenter on the right, or low-order.)
34.1157 + *
34.1158 + * <p>Note that left rotation with a negative distance is equivalent to
34.1159 + * right rotation: {@code rotateLeft(val, -distance) == rotateRight(val,
34.1160 + * distance)}. Note also that rotation by any multiple of 32 is a
34.1161 + * no-op, so all but the last five bits of the rotation distance can be
34.1162 + * ignored, even if the distance is negative: {@code rotateLeft(val,
34.1163 + * distance) == rotateLeft(val, distance & 0x1F)}.
34.1164 + *
34.1165 + * @return the value obtained by rotating the two's complement binary
34.1166 + * representation of the specified {@code int} value left by the
34.1167 + * specified number of bits.
34.1168 + * @since 1.5
34.1169 + */
34.1170 + public static int rotateLeft(int i, int distance) {
34.1171 + return (i << distance) | (i >>> -distance);
34.1172 + }
34.1173 +
34.1174 + /**
34.1175 + * Returns the value obtained by rotating the two's complement binary
34.1176 + * representation of the specified {@code int} value right by the
34.1177 + * specified number of bits. (Bits shifted out of the right hand, or
34.1178 + * low-order, side reenter on the left, or high-order.)
34.1179 + *
34.1180 + * <p>Note that right rotation with a negative distance is equivalent to
34.1181 + * left rotation: {@code rotateRight(val, -distance) == rotateLeft(val,
34.1182 + * distance)}. Note also that rotation by any multiple of 32 is a
34.1183 + * no-op, so all but the last five bits of the rotation distance can be
34.1184 + * ignored, even if the distance is negative: {@code rotateRight(val,
34.1185 + * distance) == rotateRight(val, distance & 0x1F)}.
34.1186 + *
34.1187 + * @return the value obtained by rotating the two's complement binary
34.1188 + * representation of the specified {@code int} value right by the
34.1189 + * specified number of bits.
34.1190 + * @since 1.5
34.1191 + */
34.1192 + public static int rotateRight(int i, int distance) {
34.1193 + return (i >>> distance) | (i << -distance);
34.1194 + }
34.1195 +
34.1196 + /**
34.1197 + * Returns the value obtained by reversing the order of the bits in the
34.1198 + * two's complement binary representation of the specified {@code int}
34.1199 + * value.
34.1200 + *
34.1201 + * @return the value obtained by reversing order of the bits in the
34.1202 + * specified {@code int} value.
34.1203 + * @since 1.5
34.1204 + */
34.1205 + public static int reverse(int i) {
34.1206 + // HD, Figure 7-1
34.1207 + i = (i & 0x55555555) << 1 | (i >>> 1) & 0x55555555;
34.1208 + i = (i & 0x33333333) << 2 | (i >>> 2) & 0x33333333;
34.1209 + i = (i & 0x0f0f0f0f) << 4 | (i >>> 4) & 0x0f0f0f0f;
34.1210 + i = (i << 24) | ((i & 0xff00) << 8) |
34.1211 + ((i >>> 8) & 0xff00) | (i >>> 24);
34.1212 + return i;
34.1213 + }
34.1214 +
34.1215 + /**
34.1216 + * Returns the signum function of the specified {@code int} value. (The
34.1217 + * return value is -1 if the specified value is negative; 0 if the
34.1218 + * specified value is zero; and 1 if the specified value is positive.)
34.1219 + *
34.1220 + * @return the signum function of the specified {@code int} value.
34.1221 + * @since 1.5
34.1222 + */
34.1223 + public static int signum(int i) {
34.1224 + // HD, Section 2-7
34.1225 + return (i >> 31) | (-i >>> 31);
34.1226 + }
34.1227 +
34.1228 + /**
34.1229 + * Returns the value obtained by reversing the order of the bytes in the
34.1230 + * two's complement representation of the specified {@code int} value.
34.1231 + *
34.1232 + * @return the value obtained by reversing the bytes in the specified
34.1233 + * {@code int} value.
34.1234 + * @since 1.5
34.1235 + */
34.1236 + public static int reverseBytes(int i) {
34.1237 + return ((i >>> 24) ) |
34.1238 + ((i >> 8) & 0xFF00) |
34.1239 + ((i << 8) & 0xFF0000) |
34.1240 + ((i << 24));
34.1241 + }
34.1242 +
34.1243 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
34.1244 + private static final long serialVersionUID = 1360826667806852920L;
34.1245 +}
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
35.2 +++ b/emul/src/main/java/java/lang/InterruptedException.java Thu Oct 11 06:16:00 2012 -0700
35.3 @@ -0,0 +1,69 @@
35.4 +/*
35.5 + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
35.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
35.7 + *
35.8 + * This code is free software; you can redistribute it and/or modify it
35.9 + * under the terms of the GNU General Public License version 2 only, as
35.10 + * published by the Free Software Foundation. Oracle designates this
35.11 + * particular file as subject to the "Classpath" exception as provided
35.12 + * by Oracle in the LICENSE file that accompanied this code.
35.13 + *
35.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
35.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
35.17 + * version 2 for more details (a copy is included in the LICENSE file that
35.18 + * accompanied this code).
35.19 + *
35.20 + * You should have received a copy of the GNU General Public License version
35.21 + * 2 along with this work; if not, write to the Free Software Foundation,
35.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
35.23 + *
35.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
35.25 + * or visit www.oracle.com if you need additional information or have any
35.26 + * questions.
35.27 + */
35.28 +
35.29 +package java.lang;
35.30 +
35.31 +/**
35.32 + * Thrown when a thread is waiting, sleeping, or otherwise occupied,
35.33 + * and the thread is interrupted, either before or during the activity.
35.34 + * Occasionally a method may wish to test whether the current
35.35 + * thread has been interrupted, and if so, to immediately throw
35.36 + * this exception. The following code can be used to achieve
35.37 + * this effect:
35.38 + * <pre>
35.39 + * if (Thread.interrupted()) // Clears interrupted status!
35.40 + * throw new InterruptedException();
35.41 + * </pre>
35.42 + *
35.43 + * @author Frank Yellin
35.44 + * @see java.lang.Object#wait()
35.45 + * @see java.lang.Object#wait(long)
35.46 + * @see java.lang.Object#wait(long, int)
35.47 + * @see java.lang.Thread#sleep(long)
35.48 + * @see java.lang.Thread#interrupt()
35.49 + * @see java.lang.Thread#interrupted()
35.50 + * @since JDK1.0
35.51 + */
35.52 +public
35.53 +class InterruptedException extends Exception {
35.54 + private static final long serialVersionUID = 6700697376100628473L;
35.55 +
35.56 + /**
35.57 + * Constructs an <code>InterruptedException</code> with no detail message.
35.58 + */
35.59 + public InterruptedException() {
35.60 + super();
35.61 + }
35.62 +
35.63 + /**
35.64 + * Constructs an <code>InterruptedException</code> with the
35.65 + * specified detail message.
35.66 + *
35.67 + * @param s the detail message.
35.68 + */
35.69 + public InterruptedException(String s) {
35.70 + super(s);
35.71 + }
35.72 +}
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
36.2 +++ b/emul/src/main/java/java/lang/Long.java Thu Oct 11 06:16:00 2012 -0700
36.3 @@ -0,0 +1,1199 @@
36.4 +/*
36.5 + * Copyright (c) 1994, 2009, Oracle and/or its affiliates. All rights reserved.
36.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
36.7 + *
36.8 + * This code is free software; you can redistribute it and/or modify it
36.9 + * under the terms of the GNU General Public License version 2 only, as
36.10 + * published by the Free Software Foundation. Oracle designates this
36.11 + * particular file as subject to the "Classpath" exception as provided
36.12 + * by Oracle in the LICENSE file that accompanied this code.
36.13 + *
36.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
36.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
36.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
36.17 + * version 2 for more details (a copy is included in the LICENSE file that
36.18 + * accompanied this code).
36.19 + *
36.20 + * You should have received a copy of the GNU General Public License version
36.21 + * 2 along with this work; if not, write to the Free Software Foundation,
36.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
36.23 + *
36.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
36.25 + * or visit www.oracle.com if you need additional information or have any
36.26 + * questions.
36.27 + */
36.28 +
36.29 +package java.lang;
36.30 +
36.31 +/**
36.32 + * The {@code Long} class wraps a value of the primitive type {@code
36.33 + * long} in an object. An object of type {@code Long} contains a
36.34 + * single field whose type is {@code long}.
36.35 + *
36.36 + * <p> In addition, this class provides several methods for converting
36.37 + * a {@code long} to a {@code String} and a {@code String} to a {@code
36.38 + * long}, as well as other constants and methods useful when dealing
36.39 + * with a {@code long}.
36.40 + *
36.41 + * <p>Implementation note: The implementations of the "bit twiddling"
36.42 + * methods (such as {@link #highestOneBit(long) highestOneBit} and
36.43 + * {@link #numberOfTrailingZeros(long) numberOfTrailingZeros}) are
36.44 + * based on material from Henry S. Warren, Jr.'s <i>Hacker's
36.45 + * Delight</i>, (Addison Wesley, 2002).
36.46 + *
36.47 + * @author Lee Boynton
36.48 + * @author Arthur van Hoff
36.49 + * @author Josh Bloch
36.50 + * @author Joseph D. Darcy
36.51 + * @since JDK1.0
36.52 + */
36.53 +public final class Long extends Number implements Comparable<Long> {
36.54 + /**
36.55 + * A constant holding the minimum value a {@code long} can
36.56 + * have, -2<sup>63</sup>.
36.57 + */
36.58 + public static final long MIN_VALUE = 0x8000000000000000L;
36.59 +
36.60 + /**
36.61 + * A constant holding the maximum value a {@code long} can
36.62 + * have, 2<sup>63</sup>-1.
36.63 + */
36.64 + public static final long MAX_VALUE = 0x7fffffffffffffffL;
36.65 +
36.66 + /**
36.67 + * The {@code Class} instance representing the primitive type
36.68 + * {@code long}.
36.69 + *
36.70 + * @since JDK1.1
36.71 + */
36.72 + public static final Class<Long> TYPE = (Class<Long>) Class.getPrimitiveClass("long");
36.73 +
36.74 + /**
36.75 + * Returns a string representation of the first argument in the
36.76 + * radix specified by the second argument.
36.77 + *
36.78 + * <p>If the radix is smaller than {@code Character.MIN_RADIX}
36.79 + * or larger than {@code Character.MAX_RADIX}, then the radix
36.80 + * {@code 10} is used instead.
36.81 + *
36.82 + * <p>If the first argument is negative, the first element of the
36.83 + * result is the ASCII minus sign {@code '-'}
36.84 + * (<code>'\u002d'</code>). If the first argument is not
36.85 + * negative, no sign character appears in the result.
36.86 + *
36.87 + * <p>The remaining characters of the result represent the magnitude
36.88 + * of the first argument. If the magnitude is zero, it is
36.89 + * represented by a single zero character {@code '0'}
36.90 + * (<code>'\u0030'</code>); otherwise, the first character of
36.91 + * the representation of the magnitude will not be the zero
36.92 + * character. The following ASCII characters are used as digits:
36.93 + *
36.94 + * <blockquote>
36.95 + * {@code 0123456789abcdefghijklmnopqrstuvwxyz}
36.96 + * </blockquote>
36.97 + *
36.98 + * These are <code>'\u0030'</code> through
36.99 + * <code>'\u0039'</code> and <code>'\u0061'</code> through
36.100 + * <code>'\u007a'</code>. If {@code radix} is
36.101 + * <var>N</var>, then the first <var>N</var> of these characters
36.102 + * are used as radix-<var>N</var> digits in the order shown. Thus,
36.103 + * the digits for hexadecimal (radix 16) are
36.104 + * {@code 0123456789abcdef}. If uppercase letters are
36.105 + * desired, the {@link java.lang.String#toUpperCase()} method may
36.106 + * be called on the result:
36.107 + *
36.108 + * <blockquote>
36.109 + * {@code Long.toString(n, 16).toUpperCase()}
36.110 + * </blockquote>
36.111 + *
36.112 + * @param i a {@code long} to be converted to a string.
36.113 + * @param radix the radix to use in the string representation.
36.114 + * @return a string representation of the argument in the specified radix.
36.115 + * @see java.lang.Character#MAX_RADIX
36.116 + * @see java.lang.Character#MIN_RADIX
36.117 + */
36.118 + public static String toString(long i, int radix) {
36.119 + if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
36.120 + radix = 10;
36.121 + if (radix == 10)
36.122 + return toString(i);
36.123 + char[] buf = new char[65];
36.124 + int charPos = 64;
36.125 + boolean negative = (i < 0);
36.126 +
36.127 + if (!negative) {
36.128 + i = -i;
36.129 + }
36.130 +
36.131 + while (i <= -radix) {
36.132 + buf[charPos--] = Integer.digits[(int)(-(i % radix))];
36.133 + i = i / radix;
36.134 + }
36.135 + buf[charPos] = Integer.digits[(int)(-i)];
36.136 +
36.137 + if (negative) {
36.138 + buf[--charPos] = '-';
36.139 + }
36.140 +
36.141 + return new String(buf, charPos, (65 - charPos));
36.142 + }
36.143 +
36.144 + /**
36.145 + * Returns a string representation of the {@code long}
36.146 + * argument as an unsigned integer in base 16.
36.147 + *
36.148 + * <p>The unsigned {@code long} value is the argument plus
36.149 + * 2<sup>64</sup> if the argument is negative; otherwise, it is
36.150 + * equal to the argument. This value is converted to a string of
36.151 + * ASCII digits in hexadecimal (base 16) with no extra
36.152 + * leading {@code 0}s. If the unsigned magnitude is zero, it
36.153 + * is represented by a single zero character {@code '0'}
36.154 + * (<code>'\u0030'</code>); otherwise, the first character of
36.155 + * the representation of the unsigned magnitude will not be the
36.156 + * zero character. The following characters are used as
36.157 + * hexadecimal digits:
36.158 + *
36.159 + * <blockquote>
36.160 + * {@code 0123456789abcdef}
36.161 + * </blockquote>
36.162 + *
36.163 + * These are the characters <code>'\u0030'</code> through
36.164 + * <code>'\u0039'</code> and <code>'\u0061'</code> through
36.165 + * <code>'\u0066'</code>. If uppercase letters are desired,
36.166 + * the {@link java.lang.String#toUpperCase()} method may be called
36.167 + * on the result:
36.168 + *
36.169 + * <blockquote>
36.170 + * {@code Long.toHexString(n).toUpperCase()}
36.171 + * </blockquote>
36.172 + *
36.173 + * @param i a {@code long} to be converted to a string.
36.174 + * @return the string representation of the unsigned {@code long}
36.175 + * value represented by the argument in hexadecimal
36.176 + * (base 16).
36.177 + * @since JDK 1.0.2
36.178 + */
36.179 + public static String toHexString(long i) {
36.180 + return toUnsignedString(i, 4);
36.181 + }
36.182 +
36.183 + /**
36.184 + * Returns a string representation of the {@code long}
36.185 + * argument as an unsigned integer in base 8.
36.186 + *
36.187 + * <p>The unsigned {@code long} value is the argument plus
36.188 + * 2<sup>64</sup> if the argument is negative; otherwise, it is
36.189 + * equal to the argument. This value is converted to a string of
36.190 + * ASCII digits in octal (base 8) with no extra leading
36.191 + * {@code 0}s.
36.192 + *
36.193 + * <p>If the unsigned magnitude is zero, it is represented by a
36.194 + * single zero character {@code '0'}
36.195 + * (<code>'\u0030'</code>); otherwise, the first character of
36.196 + * the representation of the unsigned magnitude will not be the
36.197 + * zero character. The following characters are used as octal
36.198 + * digits:
36.199 + *
36.200 + * <blockquote>
36.201 + * {@code 01234567}
36.202 + * </blockquote>
36.203 + *
36.204 + * These are the characters <code>'\u0030'</code> through
36.205 + * <code>'\u0037'</code>.
36.206 + *
36.207 + * @param i a {@code long} to be converted to a string.
36.208 + * @return the string representation of the unsigned {@code long}
36.209 + * value represented by the argument in octal (base 8).
36.210 + * @since JDK 1.0.2
36.211 + */
36.212 + public static String toOctalString(long i) {
36.213 + return toUnsignedString(i, 3);
36.214 + }
36.215 +
36.216 + /**
36.217 + * Returns a string representation of the {@code long}
36.218 + * argument as an unsigned integer in base 2.
36.219 + *
36.220 + * <p>The unsigned {@code long} value is the argument plus
36.221 + * 2<sup>64</sup> if the argument is negative; otherwise, it is
36.222 + * equal to the argument. This value is converted to a string of
36.223 + * ASCII digits in binary (base 2) with no extra leading
36.224 + * {@code 0}s. If the unsigned magnitude is zero, it is
36.225 + * represented by a single zero character {@code '0'}
36.226 + * (<code>'\u0030'</code>); otherwise, the first character of
36.227 + * the representation of the unsigned magnitude will not be the
36.228 + * zero character. The characters {@code '0'}
36.229 + * (<code>'\u0030'</code>) and {@code '1'}
36.230 + * (<code>'\u0031'</code>) are used as binary digits.
36.231 + *
36.232 + * @param i a {@code long} to be converted to a string.
36.233 + * @return the string representation of the unsigned {@code long}
36.234 + * value represented by the argument in binary (base 2).
36.235 + * @since JDK 1.0.2
36.236 + */
36.237 + public static String toBinaryString(long i) {
36.238 + return toUnsignedString(i, 1);
36.239 + }
36.240 +
36.241 + /**
36.242 + * Convert the integer to an unsigned number.
36.243 + */
36.244 + private static String toUnsignedString(long i, int shift) {
36.245 + char[] buf = new char[64];
36.246 + int charPos = 64;
36.247 + int radix = 1 << shift;
36.248 + long mask = radix - 1;
36.249 + do {
36.250 + buf[--charPos] = Integer.digits[(int)(i & mask)];
36.251 + i >>>= shift;
36.252 + } while (i != 0);
36.253 + return new String(buf, charPos, (64 - charPos));
36.254 + }
36.255 +
36.256 + /**
36.257 + * Returns a {@code String} object representing the specified
36.258 + * {@code long}. The argument is converted to signed decimal
36.259 + * representation and returned as a string, exactly as if the
36.260 + * argument and the radix 10 were given as arguments to the {@link
36.261 + * #toString(long, int)} method.
36.262 + *
36.263 + * @param i a {@code long} to be converted.
36.264 + * @return a string representation of the argument in base 10.
36.265 + */
36.266 + public static String toString(long i) {
36.267 + if (i == Long.MIN_VALUE)
36.268 + return "-9223372036854775808";
36.269 + int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
36.270 + char[] buf = new char[size];
36.271 + getChars(i, size, buf);
36.272 + return new String(0, size, buf);
36.273 + }
36.274 +
36.275 + /**
36.276 + * Places characters representing the integer i into the
36.277 + * character array buf. The characters are placed into
36.278 + * the buffer backwards starting with the least significant
36.279 + * digit at the specified index (exclusive), and working
36.280 + * backwards from there.
36.281 + *
36.282 + * Will fail if i == Long.MIN_VALUE
36.283 + */
36.284 + static void getChars(long i, int index, char[] buf) {
36.285 + long q;
36.286 + int r;
36.287 + int charPos = index;
36.288 + char sign = 0;
36.289 +
36.290 + if (i < 0) {
36.291 + sign = '-';
36.292 + i = -i;
36.293 + }
36.294 +
36.295 + // Get 2 digits/iteration using longs until quotient fits into an int
36.296 + while (i > Integer.MAX_VALUE) {
36.297 + q = i / 100;
36.298 + // really: r = i - (q * 100);
36.299 + r = (int)(i - ((q << 6) + (q << 5) + (q << 2)));
36.300 + i = q;
36.301 + buf[--charPos] = Integer.DigitOnes[r];
36.302 + buf[--charPos] = Integer.DigitTens[r];
36.303 + }
36.304 +
36.305 + // Get 2 digits/iteration using ints
36.306 + int q2;
36.307 + int i2 = (int)i;
36.308 + while (i2 >= 65536) {
36.309 + q2 = i2 / 100;
36.310 + // really: r = i2 - (q * 100);
36.311 + r = i2 - ((q2 << 6) + (q2 << 5) + (q2 << 2));
36.312 + i2 = q2;
36.313 + buf[--charPos] = Integer.DigitOnes[r];
36.314 + buf[--charPos] = Integer.DigitTens[r];
36.315 + }
36.316 +
36.317 + // Fall thru to fast mode for smaller numbers
36.318 + // assert(i2 <= 65536, i2);
36.319 + for (;;) {
36.320 + q2 = (i2 * 52429) >>> (16+3);
36.321 + r = i2 - ((q2 << 3) + (q2 << 1)); // r = i2-(q2*10) ...
36.322 + buf[--charPos] = Integer.digits[r];
36.323 + i2 = q2;
36.324 + if (i2 == 0) break;
36.325 + }
36.326 + if (sign != 0) {
36.327 + buf[--charPos] = sign;
36.328 + }
36.329 + }
36.330 +
36.331 + // Requires positive x
36.332 + static int stringSize(long x) {
36.333 + long p = 10;
36.334 + for (int i=1; i<19; i++) {
36.335 + if (x < p)
36.336 + return i;
36.337 + p = 10*p;
36.338 + }
36.339 + return 19;
36.340 + }
36.341 +
36.342 + /**
36.343 + * Parses the string argument as a signed {@code long} in the
36.344 + * radix specified by the second argument. The characters in the
36.345 + * string must all be digits of the specified radix (as determined
36.346 + * by whether {@link java.lang.Character#digit(char, int)} returns
36.347 + * a nonnegative value), except that the first character may be an
36.348 + * ASCII minus sign {@code '-'} (<code>'\u002D'</code>) to
36.349 + * indicate a negative value or an ASCII plus sign {@code '+'}
36.350 + * (<code>'\u002B'</code>) to indicate a positive value. The
36.351 + * resulting {@code long} value is returned.
36.352 + *
36.353 + * <p>Note that neither the character {@code L}
36.354 + * (<code>'\u004C'</code>) nor {@code l}
36.355 + * (<code>'\u006C'</code>) is permitted to appear at the end
36.356 + * of the string as a type indicator, as would be permitted in
36.357 + * Java programming language source code - except that either
36.358 + * {@code L} or {@code l} may appear as a digit for a
36.359 + * radix greater than 22.
36.360 + *
36.361 + * <p>An exception of type {@code NumberFormatException} is
36.362 + * thrown if any of the following situations occurs:
36.363 + * <ul>
36.364 + *
36.365 + * <li>The first argument is {@code null} or is a string of
36.366 + * length zero.
36.367 + *
36.368 + * <li>The {@code radix} is either smaller than {@link
36.369 + * java.lang.Character#MIN_RADIX} or larger than {@link
36.370 + * java.lang.Character#MAX_RADIX}.
36.371 + *
36.372 + * <li>Any character of the string is not a digit of the specified
36.373 + * radix, except that the first character may be a minus sign
36.374 + * {@code '-'} (<code>'\u002d'</code>) or plus sign {@code
36.375 + * '+'} (<code>'\u002B'</code>) provided that the string is
36.376 + * longer than length 1.
36.377 + *
36.378 + * <li>The value represented by the string is not a value of type
36.379 + * {@code long}.
36.380 + * </ul>
36.381 + *
36.382 + * <p>Examples:
36.383 + * <blockquote><pre>
36.384 + * parseLong("0", 10) returns 0L
36.385 + * parseLong("473", 10) returns 473L
36.386 + * parseLong("+42", 10) returns 42L
36.387 + * parseLong("-0", 10) returns 0L
36.388 + * parseLong("-FF", 16) returns -255L
36.389 + * parseLong("1100110", 2) returns 102L
36.390 + * parseLong("99", 8) throws a NumberFormatException
36.391 + * parseLong("Hazelnut", 10) throws a NumberFormatException
36.392 + * parseLong("Hazelnut", 36) returns 1356099454469L
36.393 + * </pre></blockquote>
36.394 + *
36.395 + * @param s the {@code String} containing the
36.396 + * {@code long} representation to be parsed.
36.397 + * @param radix the radix to be used while parsing {@code s}.
36.398 + * @return the {@code long} represented by the string argument in
36.399 + * the specified radix.
36.400 + * @throws NumberFormatException if the string does not contain a
36.401 + * parsable {@code long}.
36.402 + */
36.403 + public static long parseLong(String s, int radix)
36.404 + throws NumberFormatException
36.405 + {
36.406 + if (s == null) {
36.407 + throw new NumberFormatException("null");
36.408 + }
36.409 +
36.410 + if (radix < Character.MIN_RADIX) {
36.411 + throw new NumberFormatException("radix " + radix +
36.412 + " less than Character.MIN_RADIX");
36.413 + }
36.414 + if (radix > Character.MAX_RADIX) {
36.415 + throw new NumberFormatException("radix " + radix +
36.416 + " greater than Character.MAX_RADIX");
36.417 + }
36.418 +
36.419 + long result = 0;
36.420 + boolean negative = false;
36.421 + int i = 0, len = s.length();
36.422 + long limit = -Long.MAX_VALUE;
36.423 + long multmin;
36.424 + int digit;
36.425 +
36.426 + if (len > 0) {
36.427 + char firstChar = s.charAt(0);
36.428 + if (firstChar < '0') { // Possible leading "+" or "-"
36.429 + if (firstChar == '-') {
36.430 + negative = true;
36.431 + limit = Long.MIN_VALUE;
36.432 + } else if (firstChar != '+')
36.433 + throw NumberFormatException.forInputString(s);
36.434 +
36.435 + if (len == 1) // Cannot have lone "+" or "-"
36.436 + throw NumberFormatException.forInputString(s);
36.437 + i++;
36.438 + }
36.439 + multmin = limit / radix;
36.440 + while (i < len) {
36.441 + // Accumulating negatively avoids surprises near MAX_VALUE
36.442 + digit = Character.digit(s.charAt(i++),radix);
36.443 + if (digit < 0) {
36.444 + throw NumberFormatException.forInputString(s);
36.445 + }
36.446 + if (result < multmin) {
36.447 + throw NumberFormatException.forInputString(s);
36.448 + }
36.449 + result *= radix;
36.450 + if (result < limit + digit) {
36.451 + throw NumberFormatException.forInputString(s);
36.452 + }
36.453 + result -= digit;
36.454 + }
36.455 + } else {
36.456 + throw NumberFormatException.forInputString(s);
36.457 + }
36.458 + return negative ? result : -result;
36.459 + }
36.460 +
36.461 + /**
36.462 + * Parses the string argument as a signed decimal {@code long}.
36.463 + * The characters in the string must all be decimal digits, except
36.464 + * that the first character may be an ASCII minus sign {@code '-'}
36.465 + * (<code>\u002D'</code>) to indicate a negative value or an
36.466 + * ASCII plus sign {@code '+'} (<code>'\u002B'</code>) to
36.467 + * indicate a positive value. The resulting {@code long} value is
36.468 + * returned, exactly as if the argument and the radix {@code 10}
36.469 + * were given as arguments to the {@link
36.470 + * #parseLong(java.lang.String, int)} method.
36.471 + *
36.472 + * <p>Note that neither the character {@code L}
36.473 + * (<code>'\u004C'</code>) nor {@code l}
36.474 + * (<code>'\u006C'</code>) is permitted to appear at the end
36.475 + * of the string as a type indicator, as would be permitted in
36.476 + * Java programming language source code.
36.477 + *
36.478 + * @param s a {@code String} containing the {@code long}
36.479 + * representation to be parsed
36.480 + * @return the {@code long} represented by the argument in
36.481 + * decimal.
36.482 + * @throws NumberFormatException if the string does not contain a
36.483 + * parsable {@code long}.
36.484 + */
36.485 + public static long parseLong(String s) throws NumberFormatException {
36.486 + return parseLong(s, 10);
36.487 + }
36.488 +
36.489 + /**
36.490 + * Returns a {@code Long} object holding the value
36.491 + * extracted from the specified {@code String} when parsed
36.492 + * with the radix given by the second argument. The first
36.493 + * argument is interpreted as representing a signed
36.494 + * {@code long} in the radix specified by the second
36.495 + * argument, exactly as if the arguments were given to the {@link
36.496 + * #parseLong(java.lang.String, int)} method. The result is a
36.497 + * {@code Long} object that represents the {@code long}
36.498 + * value specified by the string.
36.499 + *
36.500 + * <p>In other words, this method returns a {@code Long} object equal
36.501 + * to the value of:
36.502 + *
36.503 + * <blockquote>
36.504 + * {@code new Long(Long.parseLong(s, radix))}
36.505 + * </blockquote>
36.506 + *
36.507 + * @param s the string to be parsed
36.508 + * @param radix the radix to be used in interpreting {@code s}
36.509 + * @return a {@code Long} object holding the value
36.510 + * represented by the string argument in the specified
36.511 + * radix.
36.512 + * @throws NumberFormatException If the {@code String} does not
36.513 + * contain a parsable {@code long}.
36.514 + */
36.515 + public static Long valueOf(String s, int radix) throws NumberFormatException {
36.516 + return Long.valueOf(parseLong(s, radix));
36.517 + }
36.518 +
36.519 + /**
36.520 + * Returns a {@code Long} object holding the value
36.521 + * of the specified {@code String}. The argument is
36.522 + * interpreted as representing a signed decimal {@code long},
36.523 + * exactly as if the argument were given to the {@link
36.524 + * #parseLong(java.lang.String)} method. The result is a
36.525 + * {@code Long} object that represents the integer value
36.526 + * specified by the string.
36.527 + *
36.528 + * <p>In other words, this method returns a {@code Long} object
36.529 + * equal to the value of:
36.530 + *
36.531 + * <blockquote>
36.532 + * {@code new Long(Long.parseLong(s))}
36.533 + * </blockquote>
36.534 + *
36.535 + * @param s the string to be parsed.
36.536 + * @return a {@code Long} object holding the value
36.537 + * represented by the string argument.
36.538 + * @throws NumberFormatException If the string cannot be parsed
36.539 + * as a {@code long}.
36.540 + */
36.541 + public static Long valueOf(String s) throws NumberFormatException
36.542 + {
36.543 + return Long.valueOf(parseLong(s, 10));
36.544 + }
36.545 +
36.546 + private static class LongCache {
36.547 + private LongCache(){}
36.548 +
36.549 + static final Long cache[] = new Long[-(-128) + 127 + 1];
36.550 +
36.551 + static {
36.552 + for(int i = 0; i < cache.length; i++)
36.553 + cache[i] = new Long(i - 128);
36.554 + }
36.555 + }
36.556 +
36.557 + /**
36.558 + * Returns a {@code Long} instance representing the specified
36.559 + * {@code long} value.
36.560 + * If a new {@code Long} instance is not required, this method
36.561 + * should generally be used in preference to the constructor
36.562 + * {@link #Long(long)}, as this method is likely to yield
36.563 + * significantly better space and time performance by caching
36.564 + * frequently requested values.
36.565 + *
36.566 + * Note that unlike the {@linkplain Integer#valueOf(int)
36.567 + * corresponding method} in the {@code Integer} class, this method
36.568 + * is <em>not</em> required to cache values within a particular
36.569 + * range.
36.570 + *
36.571 + * @param l a long value.
36.572 + * @return a {@code Long} instance representing {@code l}.
36.573 + * @since 1.5
36.574 + */
36.575 + public static Long valueOf(long l) {
36.576 + final int offset = 128;
36.577 + if (l >= -128 && l <= 127) { // will cache
36.578 + return LongCache.cache[(int)l + offset];
36.579 + }
36.580 + return new Long(l);
36.581 + }
36.582 +
36.583 + /**
36.584 + * Decodes a {@code String} into a {@code Long}.
36.585 + * Accepts decimal, hexadecimal, and octal numbers given by the
36.586 + * following grammar:
36.587 + *
36.588 + * <blockquote>
36.589 + * <dl>
36.590 + * <dt><i>DecodableString:</i>
36.591 + * <dd><i>Sign<sub>opt</sub> DecimalNumeral</i>
36.592 + * <dd><i>Sign<sub>opt</sub></i> {@code 0x} <i>HexDigits</i>
36.593 + * <dd><i>Sign<sub>opt</sub></i> {@code 0X} <i>HexDigits</i>
36.594 + * <dd><i>Sign<sub>opt</sub></i> {@code #} <i>HexDigits</i>
36.595 + * <dd><i>Sign<sub>opt</sub></i> {@code 0} <i>OctalDigits</i>
36.596 + * <p>
36.597 + * <dt><i>Sign:</i>
36.598 + * <dd>{@code -}
36.599 + * <dd>{@code +}
36.600 + * </dl>
36.601 + * </blockquote>
36.602 + *
36.603 + * <i>DecimalNumeral</i>, <i>HexDigits</i>, and <i>OctalDigits</i>
36.604 + * are as defined in section 3.10.1 of
36.605 + * <cite>The Java™ Language Specification</cite>,
36.606 + * except that underscores are not accepted between digits.
36.607 + *
36.608 + * <p>The sequence of characters following an optional
36.609 + * sign and/or radix specifier ("{@code 0x}", "{@code 0X}",
36.610 + * "{@code #}", or leading zero) is parsed as by the {@code
36.611 + * Long.parseLong} method with the indicated radix (10, 16, or 8).
36.612 + * This sequence of characters must represent a positive value or
36.613 + * a {@link NumberFormatException} will be thrown. The result is
36.614 + * negated if first character of the specified {@code String} is
36.615 + * the minus sign. No whitespace characters are permitted in the
36.616 + * {@code String}.
36.617 + *
36.618 + * @param nm the {@code String} to decode.
36.619 + * @return a {@code Long} object holding the {@code long}
36.620 + * value represented by {@code nm}
36.621 + * @throws NumberFormatException if the {@code String} does not
36.622 + * contain a parsable {@code long}.
36.623 + * @see java.lang.Long#parseLong(String, int)
36.624 + * @since 1.2
36.625 + */
36.626 + public static Long decode(String nm) throws NumberFormatException {
36.627 + int radix = 10;
36.628 + int index = 0;
36.629 + boolean negative = false;
36.630 + Long result;
36.631 +
36.632 + if (nm.length() == 0)
36.633 + throw new NumberFormatException("Zero length string");
36.634 + char firstChar = nm.charAt(0);
36.635 + // Handle sign, if present
36.636 + if (firstChar == '-') {
36.637 + negative = true;
36.638 + index++;
36.639 + } else if (firstChar == '+')
36.640 + index++;
36.641 +
36.642 + // Handle radix specifier, if present
36.643 + if (nm.startsWith("0x", index) || nm.startsWith("0X", index)) {
36.644 + index += 2;
36.645 + radix = 16;
36.646 + }
36.647 + else if (nm.startsWith("#", index)) {
36.648 + index ++;
36.649 + radix = 16;
36.650 + }
36.651 + else if (nm.startsWith("0", index) && nm.length() > 1 + index) {
36.652 + index ++;
36.653 + radix = 8;
36.654 + }
36.655 +
36.656 + if (nm.startsWith("-", index) || nm.startsWith("+", index))
36.657 + throw new NumberFormatException("Sign character in wrong position");
36.658 +
36.659 + try {
36.660 + result = Long.valueOf(nm.substring(index), radix);
36.661 + result = negative ? Long.valueOf(-result.longValue()) : result;
36.662 + } catch (NumberFormatException e) {
36.663 + // If number is Long.MIN_VALUE, we'll end up here. The next line
36.664 + // handles this case, and causes any genuine format error to be
36.665 + // rethrown.
36.666 + String constant = negative ? ("-" + nm.substring(index))
36.667 + : nm.substring(index);
36.668 + result = Long.valueOf(constant, radix);
36.669 + }
36.670 + return result;
36.671 + }
36.672 +
36.673 + /**
36.674 + * The value of the {@code Long}.
36.675 + *
36.676 + * @serial
36.677 + */
36.678 + private final long value;
36.679 +
36.680 + /**
36.681 + * Constructs a newly allocated {@code Long} object that
36.682 + * represents the specified {@code long} argument.
36.683 + *
36.684 + * @param value the value to be represented by the
36.685 + * {@code Long} object.
36.686 + */
36.687 + public Long(long value) {
36.688 + this.value = value;
36.689 + }
36.690 +
36.691 + /**
36.692 + * Constructs a newly allocated {@code Long} object that
36.693 + * represents the {@code long} value indicated by the
36.694 + * {@code String} parameter. The string is converted to a
36.695 + * {@code long} value in exactly the manner used by the
36.696 + * {@code parseLong} method for radix 10.
36.697 + *
36.698 + * @param s the {@code String} to be converted to a
36.699 + * {@code Long}.
36.700 + * @throws NumberFormatException if the {@code String} does not
36.701 + * contain a parsable {@code long}.
36.702 + * @see java.lang.Long#parseLong(java.lang.String, int)
36.703 + */
36.704 + public Long(String s) throws NumberFormatException {
36.705 + this.value = parseLong(s, 10);
36.706 + }
36.707 +
36.708 + /**
36.709 + * Returns the value of this {@code Long} as a
36.710 + * {@code byte}.
36.711 + */
36.712 + public byte byteValue() {
36.713 + return (byte)value;
36.714 + }
36.715 +
36.716 + /**
36.717 + * Returns the value of this {@code Long} as a
36.718 + * {@code short}.
36.719 + */
36.720 + public short shortValue() {
36.721 + return (short)value;
36.722 + }
36.723 +
36.724 + /**
36.725 + * Returns the value of this {@code Long} as an
36.726 + * {@code int}.
36.727 + */
36.728 + public int intValue() {
36.729 + return (int)value;
36.730 + }
36.731 +
36.732 + /**
36.733 + * Returns the value of this {@code Long} as a
36.734 + * {@code long} value.
36.735 + */
36.736 + public long longValue() {
36.737 + return (long)value;
36.738 + }
36.739 +
36.740 + /**
36.741 + * Returns the value of this {@code Long} as a
36.742 + * {@code float}.
36.743 + */
36.744 + public float floatValue() {
36.745 + return (float)value;
36.746 + }
36.747 +
36.748 + /**
36.749 + * Returns the value of this {@code Long} as a
36.750 + * {@code double}.
36.751 + */
36.752 + public double doubleValue() {
36.753 + return (double)value;
36.754 + }
36.755 +
36.756 + /**
36.757 + * Returns a {@code String} object representing this
36.758 + * {@code Long}'s value. The value is converted to signed
36.759 + * decimal representation and returned as a string, exactly as if
36.760 + * the {@code long} value were given as an argument to the
36.761 + * {@link java.lang.Long#toString(long)} method.
36.762 + *
36.763 + * @return a string representation of the value of this object in
36.764 + * base 10.
36.765 + */
36.766 + public String toString() {
36.767 + return toString(value);
36.768 + }
36.769 +
36.770 + /**
36.771 + * Returns a hash code for this {@code Long}. The result is
36.772 + * the exclusive OR of the two halves of the primitive
36.773 + * {@code long} value held by this {@code Long}
36.774 + * object. That is, the hashcode is the value of the expression:
36.775 + *
36.776 + * <blockquote>
36.777 + * {@code (int)(this.longValue()^(this.longValue()>>>32))}
36.778 + * </blockquote>
36.779 + *
36.780 + * @return a hash code value for this object.
36.781 + */
36.782 + public int hashCode() {
36.783 + return (int)(value ^ (value >>> 32));
36.784 + }
36.785 +
36.786 + /**
36.787 + * Compares this object to the specified object. The result is
36.788 + * {@code true} if and only if the argument is not
36.789 + * {@code null} and is a {@code Long} object that
36.790 + * contains the same {@code long} value as this object.
36.791 + *
36.792 + * @param obj the object to compare with.
36.793 + * @return {@code true} if the objects are the same;
36.794 + * {@code false} otherwise.
36.795 + */
36.796 + public boolean equals(Object obj) {
36.797 + if (obj instanceof Long) {
36.798 + return value == ((Long)obj).longValue();
36.799 + }
36.800 + return false;
36.801 + }
36.802 +
36.803 + /**
36.804 + * Determines the {@code long} value of the system property
36.805 + * with the specified name.
36.806 + *
36.807 + * <p>The first argument is treated as the name of a system property.
36.808 + * System properties are accessible through the {@link
36.809 + * java.lang.System#getProperty(java.lang.String)} method. The
36.810 + * string value of this property is then interpreted as a
36.811 + * {@code long} value and a {@code Long} object
36.812 + * representing this value is returned. Details of possible
36.813 + * numeric formats can be found with the definition of
36.814 + * {@code getProperty}.
36.815 + *
36.816 + * <p>If there is no property with the specified name, if the
36.817 + * specified name is empty or {@code null}, or if the
36.818 + * property does not have the correct numeric format, then
36.819 + * {@code null} is returned.
36.820 + *
36.821 + * <p>In other words, this method returns a {@code Long} object equal to
36.822 + * the value of:
36.823 + *
36.824 + * <blockquote>
36.825 + * {@code getLong(nm, null)}
36.826 + * </blockquote>
36.827 + *
36.828 + * @param nm property name.
36.829 + * @return the {@code Long} value of the property.
36.830 + * @see java.lang.System#getProperty(java.lang.String)
36.831 + * @see java.lang.System#getProperty(java.lang.String, java.lang.String)
36.832 + */
36.833 + public static Long getLong(String nm) {
36.834 + return getLong(nm, null);
36.835 + }
36.836 +
36.837 + /**
36.838 + * Determines the {@code long} value of the system property
36.839 + * with the specified name.
36.840 + *
36.841 + * <p>The first argument is treated as the name of a system property.
36.842 + * System properties are accessible through the {@link
36.843 + * java.lang.System#getProperty(java.lang.String)} method. The
36.844 + * string value of this property is then interpreted as a
36.845 + * {@code long} value and a {@code Long} object
36.846 + * representing this value is returned. Details of possible
36.847 + * numeric formats can be found with the definition of
36.848 + * {@code getProperty}.
36.849 + *
36.850 + * <p>The second argument is the default value. A {@code Long} object
36.851 + * that represents the value of the second argument is returned if there
36.852 + * is no property of the specified name, if the property does not have
36.853 + * the correct numeric format, or if the specified name is empty or null.
36.854 + *
36.855 + * <p>In other words, this method returns a {@code Long} object equal
36.856 + * to the value of:
36.857 + *
36.858 + * <blockquote>
36.859 + * {@code getLong(nm, new Long(val))}
36.860 + * </blockquote>
36.861 + *
36.862 + * but in practice it may be implemented in a manner such as:
36.863 + *
36.864 + * <blockquote><pre>
36.865 + * Long result = getLong(nm, null);
36.866 + * return (result == null) ? new Long(val) : result;
36.867 + * </pre></blockquote>
36.868 + *
36.869 + * to avoid the unnecessary allocation of a {@code Long} object when
36.870 + * the default value is not needed.
36.871 + *
36.872 + * @param nm property name.
36.873 + * @param val default value.
36.874 + * @return the {@code Long} value of the property.
36.875 + * @see java.lang.System#getProperty(java.lang.String)
36.876 + * @see java.lang.System#getProperty(java.lang.String, java.lang.String)
36.877 + */
36.878 + public static Long getLong(String nm, long val) {
36.879 + Long result = Long.getLong(nm, null);
36.880 + return (result == null) ? Long.valueOf(val) : result;
36.881 + }
36.882 +
36.883 + /**
36.884 + * Returns the {@code long} value of the system property with
36.885 + * the specified name. The first argument is treated as the name
36.886 + * of a system property. System properties are accessible through
36.887 + * the {@link java.lang.System#getProperty(java.lang.String)}
36.888 + * method. The string value of this property is then interpreted
36.889 + * as a {@code long} value, as per the
36.890 + * {@code Long.decode} method, and a {@code Long} object
36.891 + * representing this value is returned.
36.892 + *
36.893 + * <ul>
36.894 + * <li>If the property value begins with the two ASCII characters
36.895 + * {@code 0x} or the ASCII character {@code #}, not followed by
36.896 + * a minus sign, then the rest of it is parsed as a hexadecimal integer
36.897 + * exactly as for the method {@link #valueOf(java.lang.String, int)}
36.898 + * with radix 16.
36.899 + * <li>If the property value begins with the ASCII character
36.900 + * {@code 0} followed by another character, it is parsed as
36.901 + * an octal integer exactly as by the method {@link
36.902 + * #valueOf(java.lang.String, int)} with radix 8.
36.903 + * <li>Otherwise the property value is parsed as a decimal
36.904 + * integer exactly as by the method
36.905 + * {@link #valueOf(java.lang.String, int)} with radix 10.
36.906 + * </ul>
36.907 + *
36.908 + * <p>Note that, in every case, neither {@code L}
36.909 + * (<code>'\u004C'</code>) nor {@code l}
36.910 + * (<code>'\u006C'</code>) is permitted to appear at the end
36.911 + * of the property value as a type indicator, as would be
36.912 + * permitted in Java programming language source code.
36.913 + *
36.914 + * <p>The second argument is the default value. The default value is
36.915 + * returned if there is no property of the specified name, if the
36.916 + * property does not have the correct numeric format, or if the
36.917 + * specified name is empty or {@code null}.
36.918 + *
36.919 + * @param nm property name.
36.920 + * @param val default value.
36.921 + * @return the {@code Long} value of the property.
36.922 + * @see java.lang.System#getProperty(java.lang.String)
36.923 + * @see java.lang.System#getProperty(java.lang.String, java.lang.String)
36.924 + * @see java.lang.Long#decode
36.925 + */
36.926 + public static Long getLong(String nm, Long val) {
36.927 + String v = null;
36.928 + try {
36.929 + v = String.getProperty(nm);
36.930 + } catch (IllegalArgumentException e) {
36.931 + } catch (NullPointerException e) {
36.932 + }
36.933 + if (v != null) {
36.934 + try {
36.935 + return Long.decode(v);
36.936 + } catch (NumberFormatException e) {
36.937 + }
36.938 + }
36.939 + return val;
36.940 + }
36.941 +
36.942 + /**
36.943 + * Compares two {@code Long} objects numerically.
36.944 + *
36.945 + * @param anotherLong the {@code Long} to be compared.
36.946 + * @return the value {@code 0} if this {@code Long} is
36.947 + * equal to the argument {@code Long}; a value less than
36.948 + * {@code 0} if this {@code Long} is numerically less
36.949 + * than the argument {@code Long}; and a value greater
36.950 + * than {@code 0} if this {@code Long} is numerically
36.951 + * greater than the argument {@code Long} (signed
36.952 + * comparison).
36.953 + * @since 1.2
36.954 + */
36.955 + public int compareTo(Long anotherLong) {
36.956 + return compare(this.value, anotherLong.value);
36.957 + }
36.958 +
36.959 + /**
36.960 + * Compares two {@code long} values numerically.
36.961 + * The value returned is identical to what would be returned by:
36.962 + * <pre>
36.963 + * Long.valueOf(x).compareTo(Long.valueOf(y))
36.964 + * </pre>
36.965 + *
36.966 + * @param x the first {@code long} to compare
36.967 + * @param y the second {@code long} to compare
36.968 + * @return the value {@code 0} if {@code x == y};
36.969 + * a value less than {@code 0} if {@code x < y}; and
36.970 + * a value greater than {@code 0} if {@code x > y}
36.971 + * @since 1.7
36.972 + */
36.973 + public static int compare(long x, long y) {
36.974 + return (x < y) ? -1 : ((x == y) ? 0 : 1);
36.975 + }
36.976 +
36.977 +
36.978 + // Bit Twiddling
36.979 +
36.980 + /**
36.981 + * The number of bits used to represent a {@code long} value in two's
36.982 + * complement binary form.
36.983 + *
36.984 + * @since 1.5
36.985 + */
36.986 + public static final int SIZE = 64;
36.987 +
36.988 + /**
36.989 + * Returns a {@code long} value with at most a single one-bit, in the
36.990 + * position of the highest-order ("leftmost") one-bit in the specified
36.991 + * {@code long} value. Returns zero if the specified value has no
36.992 + * one-bits in its two's complement binary representation, that is, if it
36.993 + * is equal to zero.
36.994 + *
36.995 + * @return a {@code long} value with a single one-bit, in the position
36.996 + * of the highest-order one-bit in the specified value, or zero if
36.997 + * the specified value is itself equal to zero.
36.998 + * @since 1.5
36.999 + */
36.1000 + public static long highestOneBit(long i) {
36.1001 + // HD, Figure 3-1
36.1002 + i |= (i >> 1);
36.1003 + i |= (i >> 2);
36.1004 + i |= (i >> 4);
36.1005 + i |= (i >> 8);
36.1006 + i |= (i >> 16);
36.1007 + i |= (i >> 32);
36.1008 + return i - (i >>> 1);
36.1009 + }
36.1010 +
36.1011 + /**
36.1012 + * Returns a {@code long} value with at most a single one-bit, in the
36.1013 + * position of the lowest-order ("rightmost") one-bit in the specified
36.1014 + * {@code long} value. Returns zero if the specified value has no
36.1015 + * one-bits in its two's complement binary representation, that is, if it
36.1016 + * is equal to zero.
36.1017 + *
36.1018 + * @return a {@code long} value with a single one-bit, in the position
36.1019 + * of the lowest-order one-bit in the specified value, or zero if
36.1020 + * the specified value is itself equal to zero.
36.1021 + * @since 1.5
36.1022 + */
36.1023 + public static long lowestOneBit(long i) {
36.1024 + // HD, Section 2-1
36.1025 + return i & -i;
36.1026 + }
36.1027 +
36.1028 + /**
36.1029 + * Returns the number of zero bits preceding the highest-order
36.1030 + * ("leftmost") one-bit in the two's complement binary representation
36.1031 + * of the specified {@code long} value. Returns 64 if the
36.1032 + * specified value has no one-bits in its two's complement representation,
36.1033 + * in other words if it is equal to zero.
36.1034 + *
36.1035 + * <p>Note that this method is closely related to the logarithm base 2.
36.1036 + * For all positive {@code long} values x:
36.1037 + * <ul>
36.1038 + * <li>floor(log<sub>2</sub>(x)) = {@code 63 - numberOfLeadingZeros(x)}
36.1039 + * <li>ceil(log<sub>2</sub>(x)) = {@code 64 - numberOfLeadingZeros(x - 1)}
36.1040 + * </ul>
36.1041 + *
36.1042 + * @return the number of zero bits preceding the highest-order
36.1043 + * ("leftmost") one-bit in the two's complement binary representation
36.1044 + * of the specified {@code long} value, or 64 if the value
36.1045 + * is equal to zero.
36.1046 + * @since 1.5
36.1047 + */
36.1048 + public static int numberOfLeadingZeros(long i) {
36.1049 + // HD, Figure 5-6
36.1050 + if (i == 0)
36.1051 + return 64;
36.1052 + int n = 1;
36.1053 + int x = (int)(i >>> 32);
36.1054 + if (x == 0) { n += 32; x = (int)i; }
36.1055 + if (x >>> 16 == 0) { n += 16; x <<= 16; }
36.1056 + if (x >>> 24 == 0) { n += 8; x <<= 8; }
36.1057 + if (x >>> 28 == 0) { n += 4; x <<= 4; }
36.1058 + if (x >>> 30 == 0) { n += 2; x <<= 2; }
36.1059 + n -= x >>> 31;
36.1060 + return n;
36.1061 + }
36.1062 +
36.1063 + /**
36.1064 + * Returns the number of zero bits following the lowest-order ("rightmost")
36.1065 + * one-bit in the two's complement binary representation of the specified
36.1066 + * {@code long} value. Returns 64 if the specified value has no
36.1067 + * one-bits in its two's complement representation, in other words if it is
36.1068 + * equal to zero.
36.1069 + *
36.1070 + * @return the number of zero bits following the lowest-order ("rightmost")
36.1071 + * one-bit in the two's complement binary representation of the
36.1072 + * specified {@code long} value, or 64 if the value is equal
36.1073 + * to zero.
36.1074 + * @since 1.5
36.1075 + */
36.1076 + public static int numberOfTrailingZeros(long i) {
36.1077 + // HD, Figure 5-14
36.1078 + int x, y;
36.1079 + if (i == 0) return 64;
36.1080 + int n = 63;
36.1081 + y = (int)i; if (y != 0) { n = n -32; x = y; } else x = (int)(i>>>32);
36.1082 + y = x <<16; if (y != 0) { n = n -16; x = y; }
36.1083 + y = x << 8; if (y != 0) { n = n - 8; x = y; }
36.1084 + y = x << 4; if (y != 0) { n = n - 4; x = y; }
36.1085 + y = x << 2; if (y != 0) { n = n - 2; x = y; }
36.1086 + return n - ((x << 1) >>> 31);
36.1087 + }
36.1088 +
36.1089 + /**
36.1090 + * Returns the number of one-bits in the two's complement binary
36.1091 + * representation of the specified {@code long} value. This function is
36.1092 + * sometimes referred to as the <i>population count</i>.
36.1093 + *
36.1094 + * @return the number of one-bits in the two's complement binary
36.1095 + * representation of the specified {@code long} value.
36.1096 + * @since 1.5
36.1097 + */
36.1098 + public static int bitCount(long i) {
36.1099 + // HD, Figure 5-14
36.1100 + i = i - ((i >>> 1) & 0x5555555555555555L);
36.1101 + i = (i & 0x3333333333333333L) + ((i >>> 2) & 0x3333333333333333L);
36.1102 + i = (i + (i >>> 4)) & 0x0f0f0f0f0f0f0f0fL;
36.1103 + i = i + (i >>> 8);
36.1104 + i = i + (i >>> 16);
36.1105 + i = i + (i >>> 32);
36.1106 + return (int)i & 0x7f;
36.1107 + }
36.1108 +
36.1109 + /**
36.1110 + * Returns the value obtained by rotating the two's complement binary
36.1111 + * representation of the specified {@code long} value left by the
36.1112 + * specified number of bits. (Bits shifted out of the left hand, or
36.1113 + * high-order, side reenter on the right, or low-order.)
36.1114 + *
36.1115 + * <p>Note that left rotation with a negative distance is equivalent to
36.1116 + * right rotation: {@code rotateLeft(val, -distance) == rotateRight(val,
36.1117 + * distance)}. Note also that rotation by any multiple of 64 is a
36.1118 + * no-op, so all but the last six bits of the rotation distance can be
36.1119 + * ignored, even if the distance is negative: {@code rotateLeft(val,
36.1120 + * distance) == rotateLeft(val, distance & 0x3F)}.
36.1121 + *
36.1122 + * @return the value obtained by rotating the two's complement binary
36.1123 + * representation of the specified {@code long} value left by the
36.1124 + * specified number of bits.
36.1125 + * @since 1.5
36.1126 + */
36.1127 + public static long rotateLeft(long i, int distance) {
36.1128 + return (i << distance) | (i >>> -distance);
36.1129 + }
36.1130 +
36.1131 + /**
36.1132 + * Returns the value obtained by rotating the two's complement binary
36.1133 + * representation of the specified {@code long} value right by the
36.1134 + * specified number of bits. (Bits shifted out of the right hand, or
36.1135 + * low-order, side reenter on the left, or high-order.)
36.1136 + *
36.1137 + * <p>Note that right rotation with a negative distance is equivalent to
36.1138 + * left rotation: {@code rotateRight(val, -distance) == rotateLeft(val,
36.1139 + * distance)}. Note also that rotation by any multiple of 64 is a
36.1140 + * no-op, so all but the last six bits of the rotation distance can be
36.1141 + * ignored, even if the distance is negative: {@code rotateRight(val,
36.1142 + * distance) == rotateRight(val, distance & 0x3F)}.
36.1143 + *
36.1144 + * @return the value obtained by rotating the two's complement binary
36.1145 + * representation of the specified {@code long} value right by the
36.1146 + * specified number of bits.
36.1147 + * @since 1.5
36.1148 + */
36.1149 + public static long rotateRight(long i, int distance) {
36.1150 + return (i >>> distance) | (i << -distance);
36.1151 + }
36.1152 +
36.1153 + /**
36.1154 + * Returns the value obtained by reversing the order of the bits in the
36.1155 + * two's complement binary representation of the specified {@code long}
36.1156 + * value.
36.1157 + *
36.1158 + * @return the value obtained by reversing order of the bits in the
36.1159 + * specified {@code long} value.
36.1160 + * @since 1.5
36.1161 + */
36.1162 + public static long reverse(long i) {
36.1163 + // HD, Figure 7-1
36.1164 + i = (i & 0x5555555555555555L) << 1 | (i >>> 1) & 0x5555555555555555L;
36.1165 + i = (i & 0x3333333333333333L) << 2 | (i >>> 2) & 0x3333333333333333L;
36.1166 + i = (i & 0x0f0f0f0f0f0f0f0fL) << 4 | (i >>> 4) & 0x0f0f0f0f0f0f0f0fL;
36.1167 + i = (i & 0x00ff00ff00ff00ffL) << 8 | (i >>> 8) & 0x00ff00ff00ff00ffL;
36.1168 + i = (i << 48) | ((i & 0xffff0000L) << 16) |
36.1169 + ((i >>> 16) & 0xffff0000L) | (i >>> 48);
36.1170 + return i;
36.1171 + }
36.1172 +
36.1173 + /**
36.1174 + * Returns the signum function of the specified {@code long} value. (The
36.1175 + * return value is -1 if the specified value is negative; 0 if the
36.1176 + * specified value is zero; and 1 if the specified value is positive.)
36.1177 + *
36.1178 + * @return the signum function of the specified {@code long} value.
36.1179 + * @since 1.5
36.1180 + */
36.1181 + public static int signum(long i) {
36.1182 + // HD, Section 2-7
36.1183 + return (int) ((i >> 63) | (-i >>> 63));
36.1184 + }
36.1185 +
36.1186 + /**
36.1187 + * Returns the value obtained by reversing the order of the bytes in the
36.1188 + * two's complement representation of the specified {@code long} value.
36.1189 + *
36.1190 + * @return the value obtained by reversing the bytes in the specified
36.1191 + * {@code long} value.
36.1192 + * @since 1.5
36.1193 + */
36.1194 + public static long reverseBytes(long i) {
36.1195 + i = (i & 0x00ff00ff00ff00ffL) << 8 | (i >>> 8) & 0x00ff00ff00ff00ffL;
36.1196 + return (i << 48) | ((i & 0xffff0000L) << 16) |
36.1197 + ((i >>> 16) & 0xffff0000L) | (i >>> 48);
36.1198 + }
36.1199 +
36.1200 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
36.1201 + private static final long serialVersionUID = 4290774380558885855L;
36.1202 +}
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
37.2 +++ b/emul/src/main/java/java/lang/Math.java Thu Oct 11 06:16:00 2012 -0700
37.3 @@ -0,0 +1,1523 @@
37.4 +/*
37.5 + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
37.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37.7 + *
37.8 + * This code is free software; you can redistribute it and/or modify it
37.9 + * under the terms of the GNU General Public License version 2 only, as
37.10 + * published by the Free Software Foundation. Oracle designates this
37.11 + * particular file as subject to the "Classpath" exception as provided
37.12 + * by Oracle in the LICENSE file that accompanied this code.
37.13 + *
37.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
37.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
37.17 + * version 2 for more details (a copy is included in the LICENSE file that
37.18 + * accompanied this code).
37.19 + *
37.20 + * You should have received a copy of the GNU General Public License version
37.21 + * 2 along with this work; if not, write to the Free Software Foundation,
37.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37.23 + *
37.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
37.25 + * or visit www.oracle.com if you need additional information or have any
37.26 + * questions.
37.27 + */
37.28 +
37.29 +package java.lang;
37.30 +
37.31 +
37.32 +/**
37.33 + * The class {@code Math} contains methods for performing basic
37.34 + * numeric operations such as the elementary exponential, logarithm,
37.35 + * square root, and trigonometric functions.
37.36 + *
37.37 + * <p>Unlike some of the numeric methods of class
37.38 + * {@code StrictMath}, all implementations of the equivalent
37.39 + * functions of class {@code Math} are not defined to return the
37.40 + * bit-for-bit same results. This relaxation permits
37.41 + * better-performing implementations where strict reproducibility is
37.42 + * not required.
37.43 + *
37.44 + * <p>By default many of the {@code Math} methods simply call
37.45 + * the equivalent method in {@code StrictMath} for their
37.46 + * implementation. Code generators are encouraged to use
37.47 + * platform-specific native libraries or microprocessor instructions,
37.48 + * where available, to provide higher-performance implementations of
37.49 + * {@code Math} methods. Such higher-performance
37.50 + * implementations still must conform to the specification for
37.51 + * {@code Math}.
37.52 + *
37.53 + * <p>The quality of implementation specifications concern two
37.54 + * properties, accuracy of the returned result and monotonicity of the
37.55 + * method. Accuracy of the floating-point {@code Math} methods
37.56 + * is measured in terms of <i>ulps</i>, units in the last place. For
37.57 + * a given floating-point format, an ulp of a specific real number
37.58 + * value is the distance between the two floating-point values
37.59 + * bracketing that numerical value. When discussing the accuracy of a
37.60 + * method as a whole rather than at a specific argument, the number of
37.61 + * ulps cited is for the worst-case error at any argument. If a
37.62 + * method always has an error less than 0.5 ulps, the method always
37.63 + * returns the floating-point number nearest the exact result; such a
37.64 + * method is <i>correctly rounded</i>. A correctly rounded method is
37.65 + * generally the best a floating-point approximation can be; however,
37.66 + * it is impractical for many floating-point methods to be correctly
37.67 + * rounded. Instead, for the {@code Math} class, a larger error
37.68 + * bound of 1 or 2 ulps is allowed for certain methods. Informally,
37.69 + * with a 1 ulp error bound, when the exact result is a representable
37.70 + * number, the exact result should be returned as the computed result;
37.71 + * otherwise, either of the two floating-point values which bracket
37.72 + * the exact result may be returned. For exact results large in
37.73 + * magnitude, one of the endpoints of the bracket may be infinite.
37.74 + * Besides accuracy at individual arguments, maintaining proper
37.75 + * relations between the method at different arguments is also
37.76 + * important. Therefore, most methods with more than 0.5 ulp errors
37.77 + * are required to be <i>semi-monotonic</i>: whenever the mathematical
37.78 + * function is non-decreasing, so is the floating-point approximation,
37.79 + * likewise, whenever the mathematical function is non-increasing, so
37.80 + * is the floating-point approximation. Not all approximations that
37.81 + * have 1 ulp accuracy will automatically meet the monotonicity
37.82 + * requirements.
37.83 + *
37.84 + * @author unascribed
37.85 + * @author Joseph D. Darcy
37.86 + * @since JDK1.0
37.87 + */
37.88 +
37.89 +public final class Math {
37.90 +
37.91 + /**
37.92 + * Don't let anyone instantiate this class.
37.93 + */
37.94 + private Math() {}
37.95 +
37.96 + /**
37.97 + * The {@code double} value that is closer than any other to
37.98 + * <i>e</i>, the base of the natural logarithms.
37.99 + */
37.100 + public static final double E = 2.7182818284590452354;
37.101 +
37.102 + /**
37.103 + * The {@code double} value that is closer than any other to
37.104 + * <i>pi</i>, the ratio of the circumference of a circle to its
37.105 + * diameter.
37.106 + */
37.107 + public static final double PI = 3.14159265358979323846;
37.108 +
37.109 + /**
37.110 + * Returns the trigonometric sine of an angle. Special cases:
37.111 + * <ul><li>If the argument is NaN or an infinity, then the
37.112 + * result is NaN.
37.113 + * <li>If the argument is zero, then the result is a zero with the
37.114 + * same sign as the argument.</ul>
37.115 + *
37.116 + * <p>The computed result must be within 1 ulp of the exact result.
37.117 + * Results must be semi-monotonic.
37.118 + *
37.119 + * @param a an angle, in radians.
37.120 + * @return the sine of the argument.
37.121 + */
37.122 + public static double sin(double a) {
37.123 + return StrictMath.sin(a); // default impl. delegates to StrictMath
37.124 + }
37.125 +
37.126 + /**
37.127 + * Returns the trigonometric cosine of an angle. Special cases:
37.128 + * <ul><li>If the argument is NaN or an infinity, then the
37.129 + * result is NaN.</ul>
37.130 + *
37.131 + * <p>The computed result must be within 1 ulp of the exact result.
37.132 + * Results must be semi-monotonic.
37.133 + *
37.134 + * @param a an angle, in radians.
37.135 + * @return the cosine of the argument.
37.136 + */
37.137 + public static double cos(double a) {
37.138 + return StrictMath.cos(a); // default impl. delegates to StrictMath
37.139 + }
37.140 +
37.141 + /**
37.142 + * Returns the trigonometric tangent of an angle. Special cases:
37.143 + * <ul><li>If the argument is NaN or an infinity, then the result
37.144 + * is NaN.
37.145 + * <li>If the argument is zero, then the result is a zero with the
37.146 + * same sign as the argument.</ul>
37.147 + *
37.148 + * <p>The computed result must be within 1 ulp of the exact result.
37.149 + * Results must be semi-monotonic.
37.150 + *
37.151 + * @param a an angle, in radians.
37.152 + * @return the tangent of the argument.
37.153 + */
37.154 + public static double tan(double a) {
37.155 + return StrictMath.tan(a); // default impl. delegates to StrictMath
37.156 + }
37.157 +
37.158 + /**
37.159 + * Returns the arc sine of a value; the returned angle is in the
37.160 + * range -<i>pi</i>/2 through <i>pi</i>/2. Special cases:
37.161 + * <ul><li>If the argument is NaN or its absolute value is greater
37.162 + * than 1, then the result is NaN.
37.163 + * <li>If the argument is zero, then the result is a zero with the
37.164 + * same sign as the argument.</ul>
37.165 + *
37.166 + * <p>The computed result must be within 1 ulp of the exact result.
37.167 + * Results must be semi-monotonic.
37.168 + *
37.169 + * @param a the value whose arc sine is to be returned.
37.170 + * @return the arc sine of the argument.
37.171 + */
37.172 + public static double asin(double a) {
37.173 + return StrictMath.asin(a); // default impl. delegates to StrictMath
37.174 + }
37.175 +
37.176 + /**
37.177 + * Returns the arc cosine of a value; the returned angle is in the
37.178 + * range 0.0 through <i>pi</i>. Special case:
37.179 + * <ul><li>If the argument is NaN or its absolute value is greater
37.180 + * than 1, then the result is NaN.</ul>
37.181 + *
37.182 + * <p>The computed result must be within 1 ulp of the exact result.
37.183 + * Results must be semi-monotonic.
37.184 + *
37.185 + * @param a the value whose arc cosine is to be returned.
37.186 + * @return the arc cosine of the argument.
37.187 + */
37.188 + public static double acos(double a) {
37.189 + return StrictMath.acos(a); // default impl. delegates to StrictMath
37.190 + }
37.191 +
37.192 + /**
37.193 + * Returns the arc tangent of a value; the returned angle is in the
37.194 + * range -<i>pi</i>/2 through <i>pi</i>/2. Special cases:
37.195 + * <ul><li>If the argument is NaN, then the result is NaN.
37.196 + * <li>If the argument is zero, then the result is a zero with the
37.197 + * same sign as the argument.</ul>
37.198 + *
37.199 + * <p>The computed result must be within 1 ulp of the exact result.
37.200 + * Results must be semi-monotonic.
37.201 + *
37.202 + * @param a the value whose arc tangent is to be returned.
37.203 + * @return the arc tangent of the argument.
37.204 + */
37.205 + public static double atan(double a) {
37.206 + return StrictMath.atan(a); // default impl. delegates to StrictMath
37.207 + }
37.208 +
37.209 + /**
37.210 + * Converts an angle measured in degrees to an approximately
37.211 + * equivalent angle measured in radians. The conversion from
37.212 + * degrees to radians is generally inexact.
37.213 + *
37.214 + * @param angdeg an angle, in degrees
37.215 + * @return the measurement of the angle {@code angdeg}
37.216 + * in radians.
37.217 + * @since 1.2
37.218 + */
37.219 + public static double toRadians(double angdeg) {
37.220 + return angdeg / 180.0 * PI;
37.221 + }
37.222 +
37.223 + /**
37.224 + * Converts an angle measured in radians to an approximately
37.225 + * equivalent angle measured in degrees. The conversion from
37.226 + * radians to degrees is generally inexact; users should
37.227 + * <i>not</i> expect {@code cos(toRadians(90.0))} to exactly
37.228 + * equal {@code 0.0}.
37.229 + *
37.230 + * @param angrad an angle, in radians
37.231 + * @return the measurement of the angle {@code angrad}
37.232 + * in degrees.
37.233 + * @since 1.2
37.234 + */
37.235 + public static double toDegrees(double angrad) {
37.236 + return angrad * 180.0 / PI;
37.237 + }
37.238 +
37.239 + /**
37.240 + * Returns Euler's number <i>e</i> raised to the power of a
37.241 + * {@code double} value. Special cases:
37.242 + * <ul><li>If the argument is NaN, the result is NaN.
37.243 + * <li>If the argument is positive infinity, then the result is
37.244 + * positive infinity.
37.245 + * <li>If the argument is negative infinity, then the result is
37.246 + * positive zero.</ul>
37.247 + *
37.248 + * <p>The computed result must be within 1 ulp of the exact result.
37.249 + * Results must be semi-monotonic.
37.250 + *
37.251 + * @param a the exponent to raise <i>e</i> to.
37.252 + * @return the value <i>e</i><sup>{@code a}</sup>,
37.253 + * where <i>e</i> is the base of the natural logarithms.
37.254 + */
37.255 + public static double exp(double a) {
37.256 + return StrictMath.exp(a); // default impl. delegates to StrictMath
37.257 + }
37.258 +
37.259 + /**
37.260 + * Returns the natural logarithm (base <i>e</i>) of a {@code double}
37.261 + * value. Special cases:
37.262 + * <ul><li>If the argument is NaN or less than zero, then the result
37.263 + * is NaN.
37.264 + * <li>If the argument is positive infinity, then the result is
37.265 + * positive infinity.
37.266 + * <li>If the argument is positive zero or negative zero, then the
37.267 + * result is negative infinity.</ul>
37.268 + *
37.269 + * <p>The computed result must be within 1 ulp of the exact result.
37.270 + * Results must be semi-monotonic.
37.271 + *
37.272 + * @param a a value
37.273 + * @return the value ln {@code a}, the natural logarithm of
37.274 + * {@code a}.
37.275 + */
37.276 + public static double log(double a) {
37.277 + return StrictMath.log(a); // default impl. delegates to StrictMath
37.278 + }
37.279 +
37.280 + /**
37.281 + * Returns the base 10 logarithm of a {@code double} value.
37.282 + * Special cases:
37.283 + *
37.284 + * <ul><li>If the argument is NaN or less than zero, then the result
37.285 + * is NaN.
37.286 + * <li>If the argument is positive infinity, then the result is
37.287 + * positive infinity.
37.288 + * <li>If the argument is positive zero or negative zero, then the
37.289 + * result is negative infinity.
37.290 + * <li> If the argument is equal to 10<sup><i>n</i></sup> for
37.291 + * integer <i>n</i>, then the result is <i>n</i>.
37.292 + * </ul>
37.293 + *
37.294 + * <p>The computed result must be within 1 ulp of the exact result.
37.295 + * Results must be semi-monotonic.
37.296 + *
37.297 + * @param a a value
37.298 + * @return the base 10 logarithm of {@code a}.
37.299 + * @since 1.5
37.300 + */
37.301 + public static double log10(double a) {
37.302 + return StrictMath.log10(a); // default impl. delegates to StrictMath
37.303 + }
37.304 +
37.305 + /**
37.306 + * Returns the correctly rounded positive square root of a
37.307 + * {@code double} value.
37.308 + * Special cases:
37.309 + * <ul><li>If the argument is NaN or less than zero, then the result
37.310 + * is NaN.
37.311 + * <li>If the argument is positive infinity, then the result is positive
37.312 + * infinity.
37.313 + * <li>If the argument is positive zero or negative zero, then the
37.314 + * result is the same as the argument.</ul>
37.315 + * Otherwise, the result is the {@code double} value closest to
37.316 + * the true mathematical square root of the argument value.
37.317 + *
37.318 + * @param a a value.
37.319 + * @return the positive square root of {@code a}.
37.320 + * If the argument is NaN or less than zero, the result is NaN.
37.321 + */
37.322 + public static double sqrt(double a) {
37.323 + return StrictMath.sqrt(a); // default impl. delegates to StrictMath
37.324 + // Note that hardware sqrt instructions
37.325 + // frequently can be directly used by JITs
37.326 + // and should be much faster than doing
37.327 + // Math.sqrt in software.
37.328 + }
37.329 +
37.330 +
37.331 + /**
37.332 + * Returns the cube root of a {@code double} value. For
37.333 + * positive finite {@code x}, {@code cbrt(-x) ==
37.334 + * -cbrt(x)}; that is, the cube root of a negative value is
37.335 + * the negative of the cube root of that value's magnitude.
37.336 + *
37.337 + * Special cases:
37.338 + *
37.339 + * <ul>
37.340 + *
37.341 + * <li>If the argument is NaN, then the result is NaN.
37.342 + *
37.343 + * <li>If the argument is infinite, then the result is an infinity
37.344 + * with the same sign as the argument.
37.345 + *
37.346 + * <li>If the argument is zero, then the result is a zero with the
37.347 + * same sign as the argument.
37.348 + *
37.349 + * </ul>
37.350 + *
37.351 + * <p>The computed result must be within 1 ulp of the exact result.
37.352 + *
37.353 + * @param a a value.
37.354 + * @return the cube root of {@code a}.
37.355 + * @since 1.5
37.356 + */
37.357 + public static double cbrt(double a) {
37.358 + return StrictMath.cbrt(a);
37.359 + }
37.360 +
37.361 + /**
37.362 + * Computes the remainder operation on two arguments as prescribed
37.363 + * by the IEEE 754 standard.
37.364 + * The remainder value is mathematically equal to
37.365 + * <code>f1 - f2</code> × <i>n</i>,
37.366 + * where <i>n</i> is the mathematical integer closest to the exact
37.367 + * mathematical value of the quotient {@code f1/f2}, and if two
37.368 + * mathematical integers are equally close to {@code f1/f2},
37.369 + * then <i>n</i> is the integer that is even. If the remainder is
37.370 + * zero, its sign is the same as the sign of the first argument.
37.371 + * Special cases:
37.372 + * <ul><li>If either argument is NaN, or the first argument is infinite,
37.373 + * or the second argument is positive zero or negative zero, then the
37.374 + * result is NaN.
37.375 + * <li>If the first argument is finite and the second argument is
37.376 + * infinite, then the result is the same as the first argument.</ul>
37.377 + *
37.378 + * @param f1 the dividend.
37.379 + * @param f2 the divisor.
37.380 + * @return the remainder when {@code f1} is divided by
37.381 + * {@code f2}.
37.382 + */
37.383 + public static double IEEEremainder(double f1, double f2) {
37.384 + return StrictMath.IEEEremainder(f1, f2); // delegate to StrictMath
37.385 + }
37.386 +
37.387 + /**
37.388 + * Returns the smallest (closest to negative infinity)
37.389 + * {@code double} value that is greater than or equal to the
37.390 + * argument and is equal to a mathematical integer. Special cases:
37.391 + * <ul><li>If the argument value is already equal to a
37.392 + * mathematical integer, then the result is the same as the
37.393 + * argument. <li>If the argument is NaN or an infinity or
37.394 + * positive zero or negative zero, then the result is the same as
37.395 + * the argument. <li>If the argument value is less than zero but
37.396 + * greater than -1.0, then the result is negative zero.</ul> Note
37.397 + * that the value of {@code Math.ceil(x)} is exactly the
37.398 + * value of {@code -Math.floor(-x)}.
37.399 + *
37.400 + *
37.401 + * @param a a value.
37.402 + * @return the smallest (closest to negative infinity)
37.403 + * floating-point value that is greater than or equal to
37.404 + * the argument and is equal to a mathematical integer.
37.405 + */
37.406 + public static double ceil(double a) {
37.407 + return StrictMath.ceil(a); // default impl. delegates to StrictMath
37.408 + }
37.409 +
37.410 + /**
37.411 + * Returns the largest (closest to positive infinity)
37.412 + * {@code double} value that is less than or equal to the
37.413 + * argument and is equal to a mathematical integer. Special cases:
37.414 + * <ul><li>If the argument value is already equal to a
37.415 + * mathematical integer, then the result is the same as the
37.416 + * argument. <li>If the argument is NaN or an infinity or
37.417 + * positive zero or negative zero, then the result is the same as
37.418 + * the argument.</ul>
37.419 + *
37.420 + * @param a a value.
37.421 + * @return the largest (closest to positive infinity)
37.422 + * floating-point value that less than or equal to the argument
37.423 + * and is equal to a mathematical integer.
37.424 + */
37.425 + public static double floor(double a) {
37.426 + return StrictMath.floor(a); // default impl. delegates to StrictMath
37.427 + }
37.428 +
37.429 + /**
37.430 + * Returns the {@code double} value that is closest in value
37.431 + * to the argument and is equal to a mathematical integer. If two
37.432 + * {@code double} values that are mathematical integers are
37.433 + * equally close, the result is the integer value that is
37.434 + * even. Special cases:
37.435 + * <ul><li>If the argument value is already equal to a mathematical
37.436 + * integer, then the result is the same as the argument.
37.437 + * <li>If the argument is NaN or an infinity or positive zero or negative
37.438 + * zero, then the result is the same as the argument.</ul>
37.439 + *
37.440 + * @param a a {@code double} value.
37.441 + * @return the closest floating-point value to {@code a} that is
37.442 + * equal to a mathematical integer.
37.443 + */
37.444 + public static double rint(double a) {
37.445 + return StrictMath.rint(a); // default impl. delegates to StrictMath
37.446 + }
37.447 +
37.448 + /**
37.449 + * Returns the angle <i>theta</i> from the conversion of rectangular
37.450 + * coordinates ({@code x}, {@code y}) to polar
37.451 + * coordinates (r, <i>theta</i>).
37.452 + * This method computes the phase <i>theta</i> by computing an arc tangent
37.453 + * of {@code y/x} in the range of -<i>pi</i> to <i>pi</i>. Special
37.454 + * cases:
37.455 + * <ul><li>If either argument is NaN, then the result is NaN.
37.456 + * <li>If the first argument is positive zero and the second argument
37.457 + * is positive, or the first argument is positive and finite and the
37.458 + * second argument is positive infinity, then the result is positive
37.459 + * zero.
37.460 + * <li>If the first argument is negative zero and the second argument
37.461 + * is positive, or the first argument is negative and finite and the
37.462 + * second argument is positive infinity, then the result is negative zero.
37.463 + * <li>If the first argument is positive zero and the second argument
37.464 + * is negative, or the first argument is positive and finite and the
37.465 + * second argument is negative infinity, then the result is the
37.466 + * {@code double} value closest to <i>pi</i>.
37.467 + * <li>If the first argument is negative zero and the second argument
37.468 + * is negative, or the first argument is negative and finite and the
37.469 + * second argument is negative infinity, then the result is the
37.470 + * {@code double} value closest to -<i>pi</i>.
37.471 + * <li>If the first argument is positive and the second argument is
37.472 + * positive zero or negative zero, or the first argument is positive
37.473 + * infinity and the second argument is finite, then the result is the
37.474 + * {@code double} value closest to <i>pi</i>/2.
37.475 + * <li>If the first argument is negative and the second argument is
37.476 + * positive zero or negative zero, or the first argument is negative
37.477 + * infinity and the second argument is finite, then the result is the
37.478 + * {@code double} value closest to -<i>pi</i>/2.
37.479 + * <li>If both arguments are positive infinity, then the result is the
37.480 + * {@code double} value closest to <i>pi</i>/4.
37.481 + * <li>If the first argument is positive infinity and the second argument
37.482 + * is negative infinity, then the result is the {@code double}
37.483 + * value closest to 3*<i>pi</i>/4.
37.484 + * <li>If the first argument is negative infinity and the second argument
37.485 + * is positive infinity, then the result is the {@code double} value
37.486 + * closest to -<i>pi</i>/4.
37.487 + * <li>If both arguments are negative infinity, then the result is the
37.488 + * {@code double} value closest to -3*<i>pi</i>/4.</ul>
37.489 + *
37.490 + * <p>The computed result must be within 2 ulps of the exact result.
37.491 + * Results must be semi-monotonic.
37.492 + *
37.493 + * @param y the ordinate coordinate
37.494 + * @param x the abscissa coordinate
37.495 + * @return the <i>theta</i> component of the point
37.496 + * (<i>r</i>, <i>theta</i>)
37.497 + * in polar coordinates that corresponds to the point
37.498 + * (<i>x</i>, <i>y</i>) in Cartesian coordinates.
37.499 + */
37.500 + public static double atan2(double y, double x) {
37.501 + return StrictMath.atan2(y, x); // default impl. delegates to StrictMath
37.502 + }
37.503 +
37.504 + /**
37.505 + * Returns the value of the first argument raised to the power of the
37.506 + * second argument. Special cases:
37.507 + *
37.508 + * <ul><li>If the second argument is positive or negative zero, then the
37.509 + * result is 1.0.
37.510 + * <li>If the second argument is 1.0, then the result is the same as the
37.511 + * first argument.
37.512 + * <li>If the second argument is NaN, then the result is NaN.
37.513 + * <li>If the first argument is NaN and the second argument is nonzero,
37.514 + * then the result is NaN.
37.515 + *
37.516 + * <li>If
37.517 + * <ul>
37.518 + * <li>the absolute value of the first argument is greater than 1
37.519 + * and the second argument is positive infinity, or
37.520 + * <li>the absolute value of the first argument is less than 1 and
37.521 + * the second argument is negative infinity,
37.522 + * </ul>
37.523 + * then the result is positive infinity.
37.524 + *
37.525 + * <li>If
37.526 + * <ul>
37.527 + * <li>the absolute value of the first argument is greater than 1 and
37.528 + * the second argument is negative infinity, or
37.529 + * <li>the absolute value of the
37.530 + * first argument is less than 1 and the second argument is positive
37.531 + * infinity,
37.532 + * </ul>
37.533 + * then the result is positive zero.
37.534 + *
37.535 + * <li>If the absolute value of the first argument equals 1 and the
37.536 + * second argument is infinite, then the result is NaN.
37.537 + *
37.538 + * <li>If
37.539 + * <ul>
37.540 + * <li>the first argument is positive zero and the second argument
37.541 + * is greater than zero, or
37.542 + * <li>the first argument is positive infinity and the second
37.543 + * argument is less than zero,
37.544 + * </ul>
37.545 + * then the result is positive zero.
37.546 + *
37.547 + * <li>If
37.548 + * <ul>
37.549 + * <li>the first argument is positive zero and the second argument
37.550 + * is less than zero, or
37.551 + * <li>the first argument is positive infinity and the second
37.552 + * argument is greater than zero,
37.553 + * </ul>
37.554 + * then the result is positive infinity.
37.555 + *
37.556 + * <li>If
37.557 + * <ul>
37.558 + * <li>the first argument is negative zero and the second argument
37.559 + * is greater than zero but not a finite odd integer, or
37.560 + * <li>the first argument is negative infinity and the second
37.561 + * argument is less than zero but not a finite odd integer,
37.562 + * </ul>
37.563 + * then the result is positive zero.
37.564 + *
37.565 + * <li>If
37.566 + * <ul>
37.567 + * <li>the first argument is negative zero and the second argument
37.568 + * is a positive finite odd integer, or
37.569 + * <li>the first argument is negative infinity and the second
37.570 + * argument is a negative finite odd integer,
37.571 + * </ul>
37.572 + * then the result is negative zero.
37.573 + *
37.574 + * <li>If
37.575 + * <ul>
37.576 + * <li>the first argument is negative zero and the second argument
37.577 + * is less than zero but not a finite odd integer, or
37.578 + * <li>the first argument is negative infinity and the second
37.579 + * argument is greater than zero but not a finite odd integer,
37.580 + * </ul>
37.581 + * then the result is positive infinity.
37.582 + *
37.583 + * <li>If
37.584 + * <ul>
37.585 + * <li>the first argument is negative zero and the second argument
37.586 + * is a negative finite odd integer, or
37.587 + * <li>the first argument is negative infinity and the second
37.588 + * argument is a positive finite odd integer,
37.589 + * </ul>
37.590 + * then the result is negative infinity.
37.591 + *
37.592 + * <li>If the first argument is finite and less than zero
37.593 + * <ul>
37.594 + * <li> if the second argument is a finite even integer, the
37.595 + * result is equal to the result of raising the absolute value of
37.596 + * the first argument to the power of the second argument
37.597 + *
37.598 + * <li>if the second argument is a finite odd integer, the result
37.599 + * is equal to the negative of the result of raising the absolute
37.600 + * value of the first argument to the power of the second
37.601 + * argument
37.602 + *
37.603 + * <li>if the second argument is finite and not an integer, then
37.604 + * the result is NaN.
37.605 + * </ul>
37.606 + *
37.607 + * <li>If both arguments are integers, then the result is exactly equal
37.608 + * to the mathematical result of raising the first argument to the power
37.609 + * of the second argument if that result can in fact be represented
37.610 + * exactly as a {@code double} value.</ul>
37.611 + *
37.612 + * <p>(In the foregoing descriptions, a floating-point value is
37.613 + * considered to be an integer if and only if it is finite and a
37.614 + * fixed point of the method {@link #ceil ceil} or,
37.615 + * equivalently, a fixed point of the method {@link #floor
37.616 + * floor}. A value is a fixed point of a one-argument
37.617 + * method if and only if the result of applying the method to the
37.618 + * value is equal to the value.)
37.619 + *
37.620 + * <p>The computed result must be within 1 ulp of the exact result.
37.621 + * Results must be semi-monotonic.
37.622 + *
37.623 + * @param a the base.
37.624 + * @param b the exponent.
37.625 + * @return the value {@code a}<sup>{@code b}</sup>.
37.626 + */
37.627 + public static double pow(double a, double b) {
37.628 + return StrictMath.pow(a, b); // default impl. delegates to StrictMath
37.629 + }
37.630 +
37.631 + /**
37.632 + * Returns the closest {@code int} to the argument, with ties
37.633 + * rounding up.
37.634 + *
37.635 + * <p>
37.636 + * Special cases:
37.637 + * <ul><li>If the argument is NaN, the result is 0.
37.638 + * <li>If the argument is negative infinity or any value less than or
37.639 + * equal to the value of {@code Integer.MIN_VALUE}, the result is
37.640 + * equal to the value of {@code Integer.MIN_VALUE}.
37.641 + * <li>If the argument is positive infinity or any value greater than or
37.642 + * equal to the value of {@code Integer.MAX_VALUE}, the result is
37.643 + * equal to the value of {@code Integer.MAX_VALUE}.</ul>
37.644 + *
37.645 + * @param a a floating-point value to be rounded to an integer.
37.646 + * @return the value of the argument rounded to the nearest
37.647 + * {@code int} value.
37.648 + * @see java.lang.Integer#MAX_VALUE
37.649 + * @see java.lang.Integer#MIN_VALUE
37.650 + */
37.651 + public static int round(float a) {
37.652 + if (a != 0x1.fffffep-2f) // greatest float value less than 0.5
37.653 + return (int)floor(a + 0.5f);
37.654 + else
37.655 + return 0;
37.656 + }
37.657 +
37.658 + /**
37.659 + * Returns the closest {@code long} to the argument, with ties
37.660 + * rounding up.
37.661 + *
37.662 + * <p>Special cases:
37.663 + * <ul><li>If the argument is NaN, the result is 0.
37.664 + * <li>If the argument is negative infinity or any value less than or
37.665 + * equal to the value of {@code Long.MIN_VALUE}, the result is
37.666 + * equal to the value of {@code Long.MIN_VALUE}.
37.667 + * <li>If the argument is positive infinity or any value greater than or
37.668 + * equal to the value of {@code Long.MAX_VALUE}, the result is
37.669 + * equal to the value of {@code Long.MAX_VALUE}.</ul>
37.670 + *
37.671 + * @param a a floating-point value to be rounded to a
37.672 + * {@code long}.
37.673 + * @return the value of the argument rounded to the nearest
37.674 + * {@code long} value.
37.675 + * @see java.lang.Long#MAX_VALUE
37.676 + * @see java.lang.Long#MIN_VALUE
37.677 + */
37.678 + public static long round(double a) {
37.679 + if (a != 0x1.fffffffffffffp-2) // greatest double value less than 0.5
37.680 + return (long)floor(a + 0.5d);
37.681 + else
37.682 + return 0;
37.683 + }
37.684 +
37.685 +// private static Random randomNumberGenerator;
37.686 +//
37.687 +// private static synchronized Random initRNG() {
37.688 +// Random rnd = randomNumberGenerator;
37.689 +// return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd;
37.690 +// }
37.691 +
37.692 + /**
37.693 + * Returns a {@code double} value with a positive sign, greater
37.694 + * than or equal to {@code 0.0} and less than {@code 1.0}.
37.695 + * Returned values are chosen pseudorandomly with (approximately)
37.696 + * uniform distribution from that range.
37.697 + *
37.698 + * <p>When this method is first called, it creates a single new
37.699 + * pseudorandom-number generator, exactly as if by the expression
37.700 + *
37.701 + * <blockquote>{@code new java.util.Random()}</blockquote>
37.702 + *
37.703 + * This new pseudorandom-number generator is used thereafter for
37.704 + * all calls to this method and is used nowhere else.
37.705 + *
37.706 + * <p>This method is properly synchronized to allow correct use by
37.707 + * more than one thread. However, if many threads need to generate
37.708 + * pseudorandom numbers at a great rate, it may reduce contention
37.709 + * for each thread to have its own pseudorandom-number generator.
37.710 + *
37.711 + * @return a pseudorandom {@code double} greater than or equal
37.712 + * to {@code 0.0} and less than {@code 1.0}.
37.713 + * @see Random#nextDouble()
37.714 + */
37.715 + public static double random() {
37.716 + throw new UnsupportedOperationException();
37.717 + }
37.718 +
37.719 + /**
37.720 + * Returns the absolute value of an {@code int} value.
37.721 + * If the argument is not negative, the argument is returned.
37.722 + * If the argument is negative, the negation of the argument is returned.
37.723 + *
37.724 + * <p>Note that if the argument is equal to the value of
37.725 + * {@link Integer#MIN_VALUE}, the most negative representable
37.726 + * {@code int} value, the result is that same value, which is
37.727 + * negative.
37.728 + *
37.729 + * @param a the argument whose absolute value is to be determined
37.730 + * @return the absolute value of the argument.
37.731 + */
37.732 + public static int abs(int a) {
37.733 + return (a < 0) ? -a : a;
37.734 + }
37.735 +
37.736 + /**
37.737 + * Returns the absolute value of a {@code long} value.
37.738 + * If the argument is not negative, the argument is returned.
37.739 + * If the argument is negative, the negation of the argument is returned.
37.740 + *
37.741 + * <p>Note that if the argument is equal to the value of
37.742 + * {@link Long#MIN_VALUE}, the most negative representable
37.743 + * {@code long} value, the result is that same value, which
37.744 + * is negative.
37.745 + *
37.746 + * @param a the argument whose absolute value is to be determined
37.747 + * @return the absolute value of the argument.
37.748 + */
37.749 + public static long abs(long a) {
37.750 + return (a < 0) ? -a : a;
37.751 + }
37.752 +
37.753 + /**
37.754 + * Returns the absolute value of a {@code float} value.
37.755 + * If the argument is not negative, the argument is returned.
37.756 + * If the argument is negative, the negation of the argument is returned.
37.757 + * Special cases:
37.758 + * <ul><li>If the argument is positive zero or negative zero, the
37.759 + * result is positive zero.
37.760 + * <li>If the argument is infinite, the result is positive infinity.
37.761 + * <li>If the argument is NaN, the result is NaN.</ul>
37.762 + * In other words, the result is the same as the value of the expression:
37.763 + * <p>{@code Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))}
37.764 + *
37.765 + * @param a the argument whose absolute value is to be determined
37.766 + * @return the absolute value of the argument.
37.767 + */
37.768 + public static float abs(float a) {
37.769 + return (a <= 0.0F) ? 0.0F - a : a;
37.770 + }
37.771 +
37.772 + /**
37.773 + * Returns the absolute value of a {@code double} value.
37.774 + * If the argument is not negative, the argument is returned.
37.775 + * If the argument is negative, the negation of the argument is returned.
37.776 + * Special cases:
37.777 + * <ul><li>If the argument is positive zero or negative zero, the result
37.778 + * is positive zero.
37.779 + * <li>If the argument is infinite, the result is positive infinity.
37.780 + * <li>If the argument is NaN, the result is NaN.</ul>
37.781 + * In other words, the result is the same as the value of the expression:
37.782 + * <p>{@code Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)}
37.783 + *
37.784 + * @param a the argument whose absolute value is to be determined
37.785 + * @return the absolute value of the argument.
37.786 + */
37.787 + public static double abs(double a) {
37.788 + return (a <= 0.0D) ? 0.0D - a : a;
37.789 + }
37.790 +
37.791 + /**
37.792 + * Returns the greater of two {@code int} values. That is, the
37.793 + * result is the argument closer to the value of
37.794 + * {@link Integer#MAX_VALUE}. If the arguments have the same value,
37.795 + * the result is that same value.
37.796 + *
37.797 + * @param a an argument.
37.798 + * @param b another argument.
37.799 + * @return the larger of {@code a} and {@code b}.
37.800 + */
37.801 + public static int max(int a, int b) {
37.802 + return (a >= b) ? a : b;
37.803 + }
37.804 +
37.805 + /**
37.806 + * Returns the greater of two {@code long} values. That is, the
37.807 + * result is the argument closer to the value of
37.808 + * {@link Long#MAX_VALUE}. If the arguments have the same value,
37.809 + * the result is that same value.
37.810 + *
37.811 + * @param a an argument.
37.812 + * @param b another argument.
37.813 + * @return the larger of {@code a} and {@code b}.
37.814 + */
37.815 + public static long max(long a, long b) {
37.816 + return (a >= b) ? a : b;
37.817 + }
37.818 +
37.819 + private static long negativeZeroFloatBits = Float.floatToIntBits(-0.0f);
37.820 + private static long negativeZeroDoubleBits = Double.doubleToLongBits(-0.0d);
37.821 +
37.822 + /**
37.823 + * Returns the greater of two {@code float} values. That is,
37.824 + * the result is the argument closer to positive infinity. If the
37.825 + * arguments have the same value, the result is that same
37.826 + * value. If either value is NaN, then the result is NaN. Unlike
37.827 + * the numerical comparison operators, this method considers
37.828 + * negative zero to be strictly smaller than positive zero. If one
37.829 + * argument is positive zero and the other negative zero, the
37.830 + * result is positive zero.
37.831 + *
37.832 + * @param a an argument.
37.833 + * @param b another argument.
37.834 + * @return the larger of {@code a} and {@code b}.
37.835 + */
37.836 + public static float max(float a, float b) {
37.837 + if (a != a) return a; // a is NaN
37.838 + if ((a == 0.0f) && (b == 0.0f)
37.839 + && (Float.floatToIntBits(a) == negativeZeroFloatBits)) {
37.840 + return b;
37.841 + }
37.842 + return (a >= b) ? a : b;
37.843 + }
37.844 +
37.845 + /**
37.846 + * Returns the greater of two {@code double} values. That
37.847 + * is, the result is the argument closer to positive infinity. If
37.848 + * the arguments have the same value, the result is that same
37.849 + * value. If either value is NaN, then the result is NaN. Unlike
37.850 + * the numerical comparison operators, this method considers
37.851 + * negative zero to be strictly smaller than positive zero. If one
37.852 + * argument is positive zero and the other negative zero, the
37.853 + * result is positive zero.
37.854 + *
37.855 + * @param a an argument.
37.856 + * @param b another argument.
37.857 + * @return the larger of {@code a} and {@code b}.
37.858 + */
37.859 + public static double max(double a, double b) {
37.860 + if (a != a) return a; // a is NaN
37.861 + if ((a == 0.0d) && (b == 0.0d)
37.862 + && (Double.doubleToLongBits(a) == negativeZeroDoubleBits)) {
37.863 + return b;
37.864 + }
37.865 + return (a >= b) ? a : b;
37.866 + }
37.867 +
37.868 + /**
37.869 + * Returns the smaller of two {@code int} values. That is,
37.870 + * the result the argument closer to the value of
37.871 + * {@link Integer#MIN_VALUE}. If the arguments have the same
37.872 + * value, the result is that same value.
37.873 + *
37.874 + * @param a an argument.
37.875 + * @param b another argument.
37.876 + * @return the smaller of {@code a} and {@code b}.
37.877 + */
37.878 + public static int min(int a, int b) {
37.879 + return (a <= b) ? a : b;
37.880 + }
37.881 +
37.882 + /**
37.883 + * Returns the smaller of two {@code long} values. That is,
37.884 + * the result is the argument closer to the value of
37.885 + * {@link Long#MIN_VALUE}. If the arguments have the same
37.886 + * value, the result is that same value.
37.887 + *
37.888 + * @param a an argument.
37.889 + * @param b another argument.
37.890 + * @return the smaller of {@code a} and {@code b}.
37.891 + */
37.892 + public static long min(long a, long b) {
37.893 + return (a <= b) ? a : b;
37.894 + }
37.895 +
37.896 + /**
37.897 + * Returns the smaller of two {@code float} values. That is,
37.898 + * the result is the value closer to negative infinity. If the
37.899 + * arguments have the same value, the result is that same
37.900 + * value. If either value is NaN, then the result is NaN. Unlike
37.901 + * the numerical comparison operators, this method considers
37.902 + * negative zero to be strictly smaller than positive zero. If
37.903 + * one argument is positive zero and the other is negative zero,
37.904 + * the result is negative zero.
37.905 + *
37.906 + * @param a an argument.
37.907 + * @param b another argument.
37.908 + * @return the smaller of {@code a} and {@code b}.
37.909 + */
37.910 + public static float min(float a, float b) {
37.911 + if (a != a) return a; // a is NaN
37.912 + if ((a == 0.0f) && (b == 0.0f)
37.913 + && (Float.floatToIntBits(b) == negativeZeroFloatBits)) {
37.914 + return b;
37.915 + }
37.916 + return (a <= b) ? a : b;
37.917 + }
37.918 +
37.919 + /**
37.920 + * Returns the smaller of two {@code double} values. That
37.921 + * is, the result is the value closer to negative infinity. If the
37.922 + * arguments have the same value, the result is that same
37.923 + * value. If either value is NaN, then the result is NaN. Unlike
37.924 + * the numerical comparison operators, this method considers
37.925 + * negative zero to be strictly smaller than positive zero. If one
37.926 + * argument is positive zero and the other is negative zero, the
37.927 + * result is negative zero.
37.928 + *
37.929 + * @param a an argument.
37.930 + * @param b another argument.
37.931 + * @return the smaller of {@code a} and {@code b}.
37.932 + */
37.933 + public static double min(double a, double b) {
37.934 + if (a != a) return a; // a is NaN
37.935 + if ((a == 0.0d) && (b == 0.0d)
37.936 + && (Double.doubleToLongBits(b) == negativeZeroDoubleBits)) {
37.937 + return b;
37.938 + }
37.939 + return (a <= b) ? a : b;
37.940 + }
37.941 +
37.942 + /**
37.943 + * Returns the size of an ulp of the argument. An ulp of a
37.944 + * {@code double} value is the positive distance between this
37.945 + * floating-point value and the {@code double} value next
37.946 + * larger in magnitude. Note that for non-NaN <i>x</i>,
37.947 + * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
37.948 + *
37.949 + * <p>Special Cases:
37.950 + * <ul>
37.951 + * <li> If the argument is NaN, then the result is NaN.
37.952 + * <li> If the argument is positive or negative infinity, then the
37.953 + * result is positive infinity.
37.954 + * <li> If the argument is positive or negative zero, then the result is
37.955 + * {@code Double.MIN_VALUE}.
37.956 + * <li> If the argument is ±{@code Double.MAX_VALUE}, then
37.957 + * the result is equal to 2<sup>971</sup>.
37.958 + * </ul>
37.959 + *
37.960 + * @param d the floating-point value whose ulp is to be returned
37.961 + * @return the size of an ulp of the argument
37.962 + * @author Joseph D. Darcy
37.963 + * @since 1.5
37.964 + */
37.965 +// public static double ulp(double d) {
37.966 +// return sun.misc.FpUtils.ulp(d);
37.967 +// }
37.968 +
37.969 + /**
37.970 + * Returns the size of an ulp of the argument. An ulp of a
37.971 + * {@code float} value is the positive distance between this
37.972 + * floating-point value and the {@code float} value next
37.973 + * larger in magnitude. Note that for non-NaN <i>x</i>,
37.974 + * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
37.975 + *
37.976 + * <p>Special Cases:
37.977 + * <ul>
37.978 + * <li> If the argument is NaN, then the result is NaN.
37.979 + * <li> If the argument is positive or negative infinity, then the
37.980 + * result is positive infinity.
37.981 + * <li> If the argument is positive or negative zero, then the result is
37.982 + * {@code Float.MIN_VALUE}.
37.983 + * <li> If the argument is ±{@code Float.MAX_VALUE}, then
37.984 + * the result is equal to 2<sup>104</sup>.
37.985 + * </ul>
37.986 + *
37.987 + * @param f the floating-point value whose ulp is to be returned
37.988 + * @return the size of an ulp of the argument
37.989 + * @author Joseph D. Darcy
37.990 + * @since 1.5
37.991 + */
37.992 +// public static float ulp(float f) {
37.993 +// return sun.misc.FpUtils.ulp(f);
37.994 +// }
37.995 +
37.996 + /**
37.997 + * Returns the signum function of the argument; zero if the argument
37.998 + * is zero, 1.0 if the argument is greater than zero, -1.0 if the
37.999 + * argument is less than zero.
37.1000 + *
37.1001 + * <p>Special Cases:
37.1002 + * <ul>
37.1003 + * <li> If the argument is NaN, then the result is NaN.
37.1004 + * <li> If the argument is positive zero or negative zero, then the
37.1005 + * result is the same as the argument.
37.1006 + * </ul>
37.1007 + *
37.1008 + * @param d the floating-point value whose signum is to be returned
37.1009 + * @return the signum function of the argument
37.1010 + * @author Joseph D. Darcy
37.1011 + * @since 1.5
37.1012 + */
37.1013 +// public static double signum(double d) {
37.1014 +// return sun.misc.FpUtils.signum(d);
37.1015 +// }
37.1016 +
37.1017 + /**
37.1018 + * Returns the signum function of the argument; zero if the argument
37.1019 + * is zero, 1.0f if the argument is greater than zero, -1.0f if the
37.1020 + * argument is less than zero.
37.1021 + *
37.1022 + * <p>Special Cases:
37.1023 + * <ul>
37.1024 + * <li> If the argument is NaN, then the result is NaN.
37.1025 + * <li> If the argument is positive zero or negative zero, then the
37.1026 + * result is the same as the argument.
37.1027 + * </ul>
37.1028 + *
37.1029 + * @param f the floating-point value whose signum is to be returned
37.1030 + * @return the signum function of the argument
37.1031 + * @author Joseph D. Darcy
37.1032 + * @since 1.5
37.1033 + */
37.1034 +// public static float signum(float f) {
37.1035 +// return sun.misc.FpUtils.signum(f);
37.1036 +// }
37.1037 +
37.1038 + /**
37.1039 + * Returns the hyperbolic sine of a {@code double} value.
37.1040 + * The hyperbolic sine of <i>x</i> is defined to be
37.1041 + * (<i>e<sup>x</sup> - e<sup>-x</sup></i>)/2
37.1042 + * where <i>e</i> is {@linkplain Math#E Euler's number}.
37.1043 + *
37.1044 + * <p>Special cases:
37.1045 + * <ul>
37.1046 + *
37.1047 + * <li>If the argument is NaN, then the result is NaN.
37.1048 + *
37.1049 + * <li>If the argument is infinite, then the result is an infinity
37.1050 + * with the same sign as the argument.
37.1051 + *
37.1052 + * <li>If the argument is zero, then the result is a zero with the
37.1053 + * same sign as the argument.
37.1054 + *
37.1055 + * </ul>
37.1056 + *
37.1057 + * <p>The computed result must be within 2.5 ulps of the exact result.
37.1058 + *
37.1059 + * @param x The number whose hyperbolic sine is to be returned.
37.1060 + * @return The hyperbolic sine of {@code x}.
37.1061 + * @since 1.5
37.1062 + */
37.1063 + public static double sinh(double x) {
37.1064 + return StrictMath.sinh(x);
37.1065 + }
37.1066 +
37.1067 + /**
37.1068 + * Returns the hyperbolic cosine of a {@code double} value.
37.1069 + * The hyperbolic cosine of <i>x</i> is defined to be
37.1070 + * (<i>e<sup>x</sup> + e<sup>-x</sup></i>)/2
37.1071 + * where <i>e</i> is {@linkplain Math#E Euler's number}.
37.1072 + *
37.1073 + * <p>Special cases:
37.1074 + * <ul>
37.1075 + *
37.1076 + * <li>If the argument is NaN, then the result is NaN.
37.1077 + *
37.1078 + * <li>If the argument is infinite, then the result is positive
37.1079 + * infinity.
37.1080 + *
37.1081 + * <li>If the argument is zero, then the result is {@code 1.0}.
37.1082 + *
37.1083 + * </ul>
37.1084 + *
37.1085 + * <p>The computed result must be within 2.5 ulps of the exact result.
37.1086 + *
37.1087 + * @param x The number whose hyperbolic cosine is to be returned.
37.1088 + * @return The hyperbolic cosine of {@code x}.
37.1089 + * @since 1.5
37.1090 + */
37.1091 + public static double cosh(double x) {
37.1092 + return StrictMath.cosh(x);
37.1093 + }
37.1094 +
37.1095 + /**
37.1096 + * Returns the hyperbolic tangent of a {@code double} value.
37.1097 + * The hyperbolic tangent of <i>x</i> is defined to be
37.1098 + * (<i>e<sup>x</sup> - e<sup>-x</sup></i>)/(<i>e<sup>x</sup> + e<sup>-x</sup></i>),
37.1099 + * in other words, {@linkplain Math#sinh
37.1100 + * sinh(<i>x</i>)}/{@linkplain Math#cosh cosh(<i>x</i>)}. Note
37.1101 + * that the absolute value of the exact tanh is always less than
37.1102 + * 1.
37.1103 + *
37.1104 + * <p>Special cases:
37.1105 + * <ul>
37.1106 + *
37.1107 + * <li>If the argument is NaN, then the result is NaN.
37.1108 + *
37.1109 + * <li>If the argument is zero, then the result is a zero with the
37.1110 + * same sign as the argument.
37.1111 + *
37.1112 + * <li>If the argument is positive infinity, then the result is
37.1113 + * {@code +1.0}.
37.1114 + *
37.1115 + * <li>If the argument is negative infinity, then the result is
37.1116 + * {@code -1.0}.
37.1117 + *
37.1118 + * </ul>
37.1119 + *
37.1120 + * <p>The computed result must be within 2.5 ulps of the exact result.
37.1121 + * The result of {@code tanh} for any finite input must have
37.1122 + * an absolute value less than or equal to 1. Note that once the
37.1123 + * exact result of tanh is within 1/2 of an ulp of the limit value
37.1124 + * of ±1, correctly signed ±{@code 1.0} should
37.1125 + * be returned.
37.1126 + *
37.1127 + * @param x The number whose hyperbolic tangent is to be returned.
37.1128 + * @return The hyperbolic tangent of {@code x}.
37.1129 + * @since 1.5
37.1130 + */
37.1131 + public static double tanh(double x) {
37.1132 + return StrictMath.tanh(x);
37.1133 + }
37.1134 +
37.1135 + /**
37.1136 + * Returns sqrt(<i>x</i><sup>2</sup> +<i>y</i><sup>2</sup>)
37.1137 + * without intermediate overflow or underflow.
37.1138 + *
37.1139 + * <p>Special cases:
37.1140 + * <ul>
37.1141 + *
37.1142 + * <li> If either argument is infinite, then the result
37.1143 + * is positive infinity.
37.1144 + *
37.1145 + * <li> If either argument is NaN and neither argument is infinite,
37.1146 + * then the result is NaN.
37.1147 + *
37.1148 + * </ul>
37.1149 + *
37.1150 + * <p>The computed result must be within 1 ulp of the exact
37.1151 + * result. If one parameter is held constant, the results must be
37.1152 + * semi-monotonic in the other parameter.
37.1153 + *
37.1154 + * @param x a value
37.1155 + * @param y a value
37.1156 + * @return sqrt(<i>x</i><sup>2</sup> +<i>y</i><sup>2</sup>)
37.1157 + * without intermediate overflow or underflow
37.1158 + * @since 1.5
37.1159 + */
37.1160 + public static double hypot(double x, double y) {
37.1161 + return StrictMath.hypot(x, y);
37.1162 + }
37.1163 +
37.1164 + /**
37.1165 + * Returns <i>e</i><sup>x</sup> -1. Note that for values of
37.1166 + * <i>x</i> near 0, the exact sum of
37.1167 + * {@code expm1(x)} + 1 is much closer to the true
37.1168 + * result of <i>e</i><sup>x</sup> than {@code exp(x)}.
37.1169 + *
37.1170 + * <p>Special cases:
37.1171 + * <ul>
37.1172 + * <li>If the argument is NaN, the result is NaN.
37.1173 + *
37.1174 + * <li>If the argument is positive infinity, then the result is
37.1175 + * positive infinity.
37.1176 + *
37.1177 + * <li>If the argument is negative infinity, then the result is
37.1178 + * -1.0.
37.1179 + *
37.1180 + * <li>If the argument is zero, then the result is a zero with the
37.1181 + * same sign as the argument.
37.1182 + *
37.1183 + * </ul>
37.1184 + *
37.1185 + * <p>The computed result must be within 1 ulp of the exact result.
37.1186 + * Results must be semi-monotonic. The result of
37.1187 + * {@code expm1} for any finite input must be greater than or
37.1188 + * equal to {@code -1.0}. Note that once the exact result of
37.1189 + * <i>e</i><sup>{@code x}</sup> - 1 is within 1/2
37.1190 + * ulp of the limit value -1, {@code -1.0} should be
37.1191 + * returned.
37.1192 + *
37.1193 + * @param x the exponent to raise <i>e</i> to in the computation of
37.1194 + * <i>e</i><sup>{@code x}</sup> -1.
37.1195 + * @return the value <i>e</i><sup>{@code x}</sup> - 1.
37.1196 + * @since 1.5
37.1197 + */
37.1198 + public static double expm1(double x) {
37.1199 + return StrictMath.expm1(x);
37.1200 + }
37.1201 +
37.1202 + /**
37.1203 + * Returns the natural logarithm of the sum of the argument and 1.
37.1204 + * Note that for small values {@code x}, the result of
37.1205 + * {@code log1p(x)} is much closer to the true result of ln(1
37.1206 + * + {@code x}) than the floating-point evaluation of
37.1207 + * {@code log(1.0+x)}.
37.1208 + *
37.1209 + * <p>Special cases:
37.1210 + *
37.1211 + * <ul>
37.1212 + *
37.1213 + * <li>If the argument is NaN or less than -1, then the result is
37.1214 + * NaN.
37.1215 + *
37.1216 + * <li>If the argument is positive infinity, then the result is
37.1217 + * positive infinity.
37.1218 + *
37.1219 + * <li>If the argument is negative one, then the result is
37.1220 + * negative infinity.
37.1221 + *
37.1222 + * <li>If the argument is zero, then the result is a zero with the
37.1223 + * same sign as the argument.
37.1224 + *
37.1225 + * </ul>
37.1226 + *
37.1227 + * <p>The computed result must be within 1 ulp of the exact result.
37.1228 + * Results must be semi-monotonic.
37.1229 + *
37.1230 + * @param x a value
37.1231 + * @return the value ln({@code x} + 1), the natural
37.1232 + * log of {@code x} + 1
37.1233 + * @since 1.5
37.1234 + */
37.1235 + public static double log1p(double x) {
37.1236 + return StrictMath.log1p(x);
37.1237 + }
37.1238 +
37.1239 + /**
37.1240 + * Returns the first floating-point argument with the sign of the
37.1241 + * second floating-point argument. Note that unlike the {@link
37.1242 + * StrictMath#copySign(double, double) StrictMath.copySign}
37.1243 + * method, this method does not require NaN {@code sign}
37.1244 + * arguments to be treated as positive values; implementations are
37.1245 + * permitted to treat some NaN arguments as positive and other NaN
37.1246 + * arguments as negative to allow greater performance.
37.1247 + *
37.1248 + * @param magnitude the parameter providing the magnitude of the result
37.1249 + * @param sign the parameter providing the sign of the result
37.1250 + * @return a value with the magnitude of {@code magnitude}
37.1251 + * and the sign of {@code sign}.
37.1252 + * @since 1.6
37.1253 + */
37.1254 +// public static double copySign(double magnitude, double sign) {
37.1255 +// return sun.misc.FpUtils.rawCopySign(magnitude, sign);
37.1256 +// }
37.1257 +
37.1258 + /**
37.1259 + * Returns the first floating-point argument with the sign of the
37.1260 + * second floating-point argument. Note that unlike the {@link
37.1261 + * StrictMath#copySign(float, float) StrictMath.copySign}
37.1262 + * method, this method does not require NaN {@code sign}
37.1263 + * arguments to be treated as positive values; implementations are
37.1264 + * permitted to treat some NaN arguments as positive and other NaN
37.1265 + * arguments as negative to allow greater performance.
37.1266 + *
37.1267 + * @param magnitude the parameter providing the magnitude of the result
37.1268 + * @param sign the parameter providing the sign of the result
37.1269 + * @return a value with the magnitude of {@code magnitude}
37.1270 + * and the sign of {@code sign}.
37.1271 + * @since 1.6
37.1272 + */
37.1273 +// public static float copySign(float magnitude, float sign) {
37.1274 +// return sun.misc.FpUtils.rawCopySign(magnitude, sign);
37.1275 +// }
37.1276 +
37.1277 + /**
37.1278 + * Returns the unbiased exponent used in the representation of a
37.1279 + * {@code float}. Special cases:
37.1280 + *
37.1281 + * <ul>
37.1282 + * <li>If the argument is NaN or infinite, then the result is
37.1283 + * {@link Float#MAX_EXPONENT} + 1.
37.1284 + * <li>If the argument is zero or subnormal, then the result is
37.1285 + * {@link Float#MIN_EXPONENT} -1.
37.1286 + * </ul>
37.1287 + * @param f a {@code float} value
37.1288 + * @return the unbiased exponent of the argument
37.1289 + * @since 1.6
37.1290 + */
37.1291 +// public static int getExponent(float f) {
37.1292 +// return sun.misc.FpUtils.getExponent(f);
37.1293 +// }
37.1294 +
37.1295 + /**
37.1296 + * Returns the unbiased exponent used in the representation of a
37.1297 + * {@code double}. Special cases:
37.1298 + *
37.1299 + * <ul>
37.1300 + * <li>If the argument is NaN or infinite, then the result is
37.1301 + * {@link Double#MAX_EXPONENT} + 1.
37.1302 + * <li>If the argument is zero or subnormal, then the result is
37.1303 + * {@link Double#MIN_EXPONENT} -1.
37.1304 + * </ul>
37.1305 + * @param d a {@code double} value
37.1306 + * @return the unbiased exponent of the argument
37.1307 + * @since 1.6
37.1308 + */
37.1309 +// public static int getExponent(double d) {
37.1310 +// return sun.misc.FpUtils.getExponent(d);
37.1311 +// }
37.1312 +
37.1313 + /**
37.1314 + * Returns the floating-point number adjacent to the first
37.1315 + * argument in the direction of the second argument. If both
37.1316 + * arguments compare as equal the second argument is returned.
37.1317 + *
37.1318 + * <p>
37.1319 + * Special cases:
37.1320 + * <ul>
37.1321 + * <li> If either argument is a NaN, then NaN is returned.
37.1322 + *
37.1323 + * <li> If both arguments are signed zeros, {@code direction}
37.1324 + * is returned unchanged (as implied by the requirement of
37.1325 + * returning the second argument if the arguments compare as
37.1326 + * equal).
37.1327 + *
37.1328 + * <li> If {@code start} is
37.1329 + * ±{@link Double#MIN_VALUE} and {@code direction}
37.1330 + * has a value such that the result should have a smaller
37.1331 + * magnitude, then a zero with the same sign as {@code start}
37.1332 + * is returned.
37.1333 + *
37.1334 + * <li> If {@code start} is infinite and
37.1335 + * {@code direction} has a value such that the result should
37.1336 + * have a smaller magnitude, {@link Double#MAX_VALUE} with the
37.1337 + * same sign as {@code start} is returned.
37.1338 + *
37.1339 + * <li> If {@code start} is equal to ±
37.1340 + * {@link Double#MAX_VALUE} and {@code direction} has a
37.1341 + * value such that the result should have a larger magnitude, an
37.1342 + * infinity with same sign as {@code start} is returned.
37.1343 + * </ul>
37.1344 + *
37.1345 + * @param start starting floating-point value
37.1346 + * @param direction value indicating which of
37.1347 + * {@code start}'s neighbors or {@code start} should
37.1348 + * be returned
37.1349 + * @return The floating-point number adjacent to {@code start} in the
37.1350 + * direction of {@code direction}.
37.1351 + * @since 1.6
37.1352 + */
37.1353 +// public static double nextAfter(double start, double direction) {
37.1354 +// return sun.misc.FpUtils.nextAfter(start, direction);
37.1355 +// }
37.1356 +
37.1357 + /**
37.1358 + * Returns the floating-point number adjacent to the first
37.1359 + * argument in the direction of the second argument. If both
37.1360 + * arguments compare as equal a value equivalent to the second argument
37.1361 + * is returned.
37.1362 + *
37.1363 + * <p>
37.1364 + * Special cases:
37.1365 + * <ul>
37.1366 + * <li> If either argument is a NaN, then NaN is returned.
37.1367 + *
37.1368 + * <li> If both arguments are signed zeros, a value equivalent
37.1369 + * to {@code direction} is returned.
37.1370 + *
37.1371 + * <li> If {@code start} is
37.1372 + * ±{@link Float#MIN_VALUE} and {@code direction}
37.1373 + * has a value such that the result should have a smaller
37.1374 + * magnitude, then a zero with the same sign as {@code start}
37.1375 + * is returned.
37.1376 + *
37.1377 + * <li> If {@code start} is infinite and
37.1378 + * {@code direction} has a value such that the result should
37.1379 + * have a smaller magnitude, {@link Float#MAX_VALUE} with the
37.1380 + * same sign as {@code start} is returned.
37.1381 + *
37.1382 + * <li> If {@code start} is equal to ±
37.1383 + * {@link Float#MAX_VALUE} and {@code direction} has a
37.1384 + * value such that the result should have a larger magnitude, an
37.1385 + * infinity with same sign as {@code start} is returned.
37.1386 + * </ul>
37.1387 + *
37.1388 + * @param start starting floating-point value
37.1389 + * @param direction value indicating which of
37.1390 + * {@code start}'s neighbors or {@code start} should
37.1391 + * be returned
37.1392 + * @return The floating-point number adjacent to {@code start} in the
37.1393 + * direction of {@code direction}.
37.1394 + * @since 1.6
37.1395 + */
37.1396 +// public static float nextAfter(float start, double direction) {
37.1397 +// return sun.misc.FpUtils.nextAfter(start, direction);
37.1398 +// }
37.1399 +
37.1400 + /**
37.1401 + * Returns the floating-point value adjacent to {@code d} in
37.1402 + * the direction of positive infinity. This method is
37.1403 + * semantically equivalent to {@code nextAfter(d,
37.1404 + * Double.POSITIVE_INFINITY)}; however, a {@code nextUp}
37.1405 + * implementation may run faster than its equivalent
37.1406 + * {@code nextAfter} call.
37.1407 + *
37.1408 + * <p>Special Cases:
37.1409 + * <ul>
37.1410 + * <li> If the argument is NaN, the result is NaN.
37.1411 + *
37.1412 + * <li> If the argument is positive infinity, the result is
37.1413 + * positive infinity.
37.1414 + *
37.1415 + * <li> If the argument is zero, the result is
37.1416 + * {@link Double#MIN_VALUE}
37.1417 + *
37.1418 + * </ul>
37.1419 + *
37.1420 + * @param d starting floating-point value
37.1421 + * @return The adjacent floating-point value closer to positive
37.1422 + * infinity.
37.1423 + * @since 1.6
37.1424 + */
37.1425 +// public static double nextUp(double d) {
37.1426 +// return sun.misc.FpUtils.nextUp(d);
37.1427 +// }
37.1428 +
37.1429 + /**
37.1430 + * Returns the floating-point value adjacent to {@code f} in
37.1431 + * the direction of positive infinity. This method is
37.1432 + * semantically equivalent to {@code nextAfter(f,
37.1433 + * Float.POSITIVE_INFINITY)}; however, a {@code nextUp}
37.1434 + * implementation may run faster than its equivalent
37.1435 + * {@code nextAfter} call.
37.1436 + *
37.1437 + * <p>Special Cases:
37.1438 + * <ul>
37.1439 + * <li> If the argument is NaN, the result is NaN.
37.1440 + *
37.1441 + * <li> If the argument is positive infinity, the result is
37.1442 + * positive infinity.
37.1443 + *
37.1444 + * <li> If the argument is zero, the result is
37.1445 + * {@link Float#MIN_VALUE}
37.1446 + *
37.1447 + * </ul>
37.1448 + *
37.1449 + * @param f starting floating-point value
37.1450 + * @return The adjacent floating-point value closer to positive
37.1451 + * infinity.
37.1452 + * @since 1.6
37.1453 + */
37.1454 +// public static float nextUp(float f) {
37.1455 +// return sun.misc.FpUtils.nextUp(f);
37.1456 +// }
37.1457 +
37.1458 +
37.1459 + /**
37.1460 + * Return {@code d} ×
37.1461 + * 2<sup>{@code scaleFactor}</sup> rounded as if performed
37.1462 + * by a single correctly rounded floating-point multiply to a
37.1463 + * member of the double value set. See the Java
37.1464 + * Language Specification for a discussion of floating-point
37.1465 + * value sets. If the exponent of the result is between {@link
37.1466 + * Double#MIN_EXPONENT} and {@link Double#MAX_EXPONENT}, the
37.1467 + * answer is calculated exactly. If the exponent of the result
37.1468 + * would be larger than {@code Double.MAX_EXPONENT}, an
37.1469 + * infinity is returned. Note that if the result is subnormal,
37.1470 + * precision may be lost; that is, when {@code scalb(x, n)}
37.1471 + * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
37.1472 + * <i>x</i>. When the result is non-NaN, the result has the same
37.1473 + * sign as {@code d}.
37.1474 + *
37.1475 + * <p>Special cases:
37.1476 + * <ul>
37.1477 + * <li> If the first argument is NaN, NaN is returned.
37.1478 + * <li> If the first argument is infinite, then an infinity of the
37.1479 + * same sign is returned.
37.1480 + * <li> If the first argument is zero, then a zero of the same
37.1481 + * sign is returned.
37.1482 + * </ul>
37.1483 + *
37.1484 + * @param d number to be scaled by a power of two.
37.1485 + * @param scaleFactor power of 2 used to scale {@code d}
37.1486 + * @return {@code d} × 2<sup>{@code scaleFactor}</sup>
37.1487 + * @since 1.6
37.1488 + */
37.1489 +// public static double scalb(double d, int scaleFactor) {
37.1490 +// return sun.misc.FpUtils.scalb(d, scaleFactor);
37.1491 +// }
37.1492 +
37.1493 + /**
37.1494 + * Return {@code f} ×
37.1495 + * 2<sup>{@code scaleFactor}</sup> rounded as if performed
37.1496 + * by a single correctly rounded floating-point multiply to a
37.1497 + * member of the float value set. See the Java
37.1498 + * Language Specification for a discussion of floating-point
37.1499 + * value sets. If the exponent of the result is between {@link
37.1500 + * Float#MIN_EXPONENT} and {@link Float#MAX_EXPONENT}, the
37.1501 + * answer is calculated exactly. If the exponent of the result
37.1502 + * would be larger than {@code Float.MAX_EXPONENT}, an
37.1503 + * infinity is returned. Note that if the result is subnormal,
37.1504 + * precision may be lost; that is, when {@code scalb(x, n)}
37.1505 + * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
37.1506 + * <i>x</i>. When the result is non-NaN, the result has the same
37.1507 + * sign as {@code f}.
37.1508 + *
37.1509 + * <p>Special cases:
37.1510 + * <ul>
37.1511 + * <li> If the first argument is NaN, NaN is returned.
37.1512 + * <li> If the first argument is infinite, then an infinity of the
37.1513 + * same sign is returned.
37.1514 + * <li> If the first argument is zero, then a zero of the same
37.1515 + * sign is returned.
37.1516 + * </ul>
37.1517 + *
37.1518 + * @param f number to be scaled by a power of two.
37.1519 + * @param scaleFactor power of 2 used to scale {@code f}
37.1520 + * @return {@code f} × 2<sup>{@code scaleFactor}</sup>
37.1521 + * @since 1.6
37.1522 + */
37.1523 +// public static float scalb(float f, int scaleFactor) {
37.1524 +// return sun.misc.FpUtils.scalb(f, scaleFactor);
37.1525 +// }
37.1526 +}
38.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
38.2 +++ b/emul/src/main/java/java/lang/NullPointerException.java Thu Oct 11 06:16:00 2012 -0700
38.3 @@ -0,0 +1,72 @@
38.4 +/*
38.5 + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
38.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
38.7 + *
38.8 + * This code is free software; you can redistribute it and/or modify it
38.9 + * under the terms of the GNU General Public License version 2 only, as
38.10 + * published by the Free Software Foundation. Oracle designates this
38.11 + * particular file as subject to the "Classpath" exception as provided
38.12 + * by Oracle in the LICENSE file that accompanied this code.
38.13 + *
38.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
38.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
38.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
38.17 + * version 2 for more details (a copy is included in the LICENSE file that
38.18 + * accompanied this code).
38.19 + *
38.20 + * You should have received a copy of the GNU General Public License version
38.21 + * 2 along with this work; if not, write to the Free Software Foundation,
38.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
38.23 + *
38.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
38.25 + * or visit www.oracle.com if you need additional information or have any
38.26 + * questions.
38.27 + */
38.28 +
38.29 +package java.lang;
38.30 +
38.31 +/**
38.32 + * Thrown when an application attempts to use {@code null} in a
38.33 + * case where an object is required. These include:
38.34 + * <ul>
38.35 + * <li>Calling the instance method of a {@code null} object.
38.36 + * <li>Accessing or modifying the field of a {@code null} object.
38.37 + * <li>Taking the length of {@code null} as if it were an array.
38.38 + * <li>Accessing or modifying the slots of {@code null} as if it
38.39 + * were an array.
38.40 + * <li>Throwing {@code null} as if it were a {@code Throwable}
38.41 + * value.
38.42 + * </ul>
38.43 + * <p>
38.44 + * Applications should throw instances of this class to indicate
38.45 + * other illegal uses of the {@code null} object.
38.46 + *
38.47 + * {@code NullPointerException} objects may be constructed by the
38.48 + * virtual machine as if {@linkplain Throwable#Throwable(String,
38.49 + * Throwable, boolean, boolean) suppression were disabled and/or the
38.50 + * stack trace was not writable}.
38.51 + *
38.52 + * @author unascribed
38.53 + * @since JDK1.0
38.54 + */
38.55 +public
38.56 +class NullPointerException extends RuntimeException {
38.57 + private static final long serialVersionUID = 5162710183389028792L;
38.58 +
38.59 + /**
38.60 + * Constructs a {@code NullPointerException} with no detail message.
38.61 + */
38.62 + public NullPointerException() {
38.63 + super();
38.64 + }
38.65 +
38.66 + /**
38.67 + * Constructs a {@code NullPointerException} with the specified
38.68 + * detail message.
38.69 + *
38.70 + * @param s the detail message.
38.71 + */
38.72 + public NullPointerException(String s) {
38.73 + super(s);
38.74 + }
38.75 +}
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
39.2 +++ b/emul/src/main/java/java/lang/Number.java Thu Oct 11 06:16:00 2012 -0700
39.3 @@ -0,0 +1,112 @@
39.4 +/*
39.5 + * Copyright (c) 1994, 2001, Oracle and/or its affiliates. All rights reserved.
39.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
39.7 + *
39.8 + * This code is free software; you can redistribute it and/or modify it
39.9 + * under the terms of the GNU General Public License version 2 only, as
39.10 + * published by the Free Software Foundation. Oracle designates this
39.11 + * particular file as subject to the "Classpath" exception as provided
39.12 + * by Oracle in the LICENSE file that accompanied this code.
39.13 + *
39.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
39.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
39.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
39.17 + * version 2 for more details (a copy is included in the LICENSE file that
39.18 + * accompanied this code).
39.19 + *
39.20 + * You should have received a copy of the GNU General Public License version
39.21 + * 2 along with this work; if not, write to the Free Software Foundation,
39.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
39.23 + *
39.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
39.25 + * or visit www.oracle.com if you need additional information or have any
39.26 + * questions.
39.27 + */
39.28 +
39.29 +package java.lang;
39.30 +
39.31 +/**
39.32 + * The abstract class <code>Number</code> is the superclass of classes
39.33 + * <code>BigDecimal</code>, <code>BigInteger</code>,
39.34 + * <code>Byte</code>, <code>Double</code>, <code>Float</code>,
39.35 + * <code>Integer</code>, <code>Long</code>, and <code>Short</code>.
39.36 + * <p>
39.37 + * Subclasses of <code>Number</code> must provide methods to convert
39.38 + * the represented numeric value to <code>byte</code>, <code>double</code>,
39.39 + * <code>float</code>, <code>int</code>, <code>long</code>, and
39.40 + * <code>short</code>.
39.41 + *
39.42 + * @author Lee Boynton
39.43 + * @author Arthur van Hoff
39.44 + * @see java.lang.Byte
39.45 + * @see java.lang.Double
39.46 + * @see java.lang.Float
39.47 + * @see java.lang.Integer
39.48 + * @see java.lang.Long
39.49 + * @see java.lang.Short
39.50 + * @since JDK1.0
39.51 + */
39.52 +public abstract class Number implements java.io.Serializable {
39.53 + /**
39.54 + * Returns the value of the specified number as an <code>int</code>.
39.55 + * This may involve rounding or truncation.
39.56 + *
39.57 + * @return the numeric value represented by this object after conversion
39.58 + * to type <code>int</code>.
39.59 + */
39.60 + public abstract int intValue();
39.61 +
39.62 + /**
39.63 + * Returns the value of the specified number as a <code>long</code>.
39.64 + * This may involve rounding or truncation.
39.65 + *
39.66 + * @return the numeric value represented by this object after conversion
39.67 + * to type <code>long</code>.
39.68 + */
39.69 + public abstract long longValue();
39.70 +
39.71 + /**
39.72 + * Returns the value of the specified number as a <code>float</code>.
39.73 + * This may involve rounding.
39.74 + *
39.75 + * @return the numeric value represented by this object after conversion
39.76 + * to type <code>float</code>.
39.77 + */
39.78 + public abstract float floatValue();
39.79 +
39.80 + /**
39.81 + * Returns the value of the specified number as a <code>double</code>.
39.82 + * This may involve rounding.
39.83 + *
39.84 + * @return the numeric value represented by this object after conversion
39.85 + * to type <code>double</code>.
39.86 + */
39.87 + public abstract double doubleValue();
39.88 +
39.89 + /**
39.90 + * Returns the value of the specified number as a <code>byte</code>.
39.91 + * This may involve rounding or truncation.
39.92 + *
39.93 + * @return the numeric value represented by this object after conversion
39.94 + * to type <code>byte</code>.
39.95 + * @since JDK1.1
39.96 + */
39.97 + public byte byteValue() {
39.98 + return (byte)intValue();
39.99 + }
39.100 +
39.101 + /**
39.102 + * Returns the value of the specified number as a <code>short</code>.
39.103 + * This may involve rounding or truncation.
39.104 + *
39.105 + * @return the numeric value represented by this object after conversion
39.106 + * to type <code>short</code>.
39.107 + * @since JDK1.1
39.108 + */
39.109 + public short shortValue() {
39.110 + return (short)intValue();
39.111 + }
39.112 +
39.113 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
39.114 + private static final long serialVersionUID = -8742448824652078965L;
39.115 +}
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
40.2 +++ b/emul/src/main/java/java/lang/NumberFormatException.java Thu Oct 11 06:16:00 2012 -0700
40.3 @@ -0,0 +1,67 @@
40.4 +/*
40.5 + * Copyright (c) 1994, 2001, Oracle and/or its affiliates. All rights reserved.
40.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
40.7 + *
40.8 + * This code is free software; you can redistribute it and/or modify it
40.9 + * under the terms of the GNU General Public License version 2 only, as
40.10 + * published by the Free Software Foundation. Oracle designates this
40.11 + * particular file as subject to the "Classpath" exception as provided
40.12 + * by Oracle in the LICENSE file that accompanied this code.
40.13 + *
40.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
40.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
40.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
40.17 + * version 2 for more details (a copy is included in the LICENSE file that
40.18 + * accompanied this code).
40.19 + *
40.20 + * You should have received a copy of the GNU General Public License version
40.21 + * 2 along with this work; if not, write to the Free Software Foundation,
40.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
40.23 + *
40.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
40.25 + * or visit www.oracle.com if you need additional information or have any
40.26 + * questions.
40.27 + */
40.28 +
40.29 +package java.lang;
40.30 +
40.31 +/**
40.32 + * Thrown to indicate that the application has attempted to convert
40.33 + * a string to one of the numeric types, but that the string does not
40.34 + * have the appropriate format.
40.35 + *
40.36 + * @author unascribed
40.37 + * @see java.lang.Integer#toString()
40.38 + * @since JDK1.0
40.39 + */
40.40 +public
40.41 +class NumberFormatException extends IllegalArgumentException {
40.42 + static final long serialVersionUID = -2848938806368998894L;
40.43 +
40.44 + /**
40.45 + * Constructs a <code>NumberFormatException</code> with no detail message.
40.46 + */
40.47 + public NumberFormatException () {
40.48 + super();
40.49 + }
40.50 +
40.51 + /**
40.52 + * Constructs a <code>NumberFormatException</code> with the
40.53 + * specified detail message.
40.54 + *
40.55 + * @param s the detail message.
40.56 + */
40.57 + public NumberFormatException (String s) {
40.58 + super (s);
40.59 + }
40.60 +
40.61 + /**
40.62 + * Factory method for making a <code>NumberFormatException</code>
40.63 + * given the specified input which caused the error.
40.64 + *
40.65 + * @param s the input causing the error
40.66 + */
40.67 + static NumberFormatException forInputString(String s) {
40.68 + return new NumberFormatException("For input string: \"" + s + "\"");
40.69 + }
40.70 +}
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
41.2 +++ b/emul/src/main/java/java/lang/Object.java Thu Oct 11 06:16:00 2012 -0700
41.3 @@ -0,0 +1,554 @@
41.4 +/*
41.5 + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
41.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41.7 + *
41.8 + * This code is free software; you can redistribute it and/or modify it
41.9 + * under the terms of the GNU General Public License version 2 only, as
41.10 + * published by the Free Software Foundation. Oracle designates this
41.11 + * particular file as subject to the "Classpath" exception as provided
41.12 + * by Oracle in the LICENSE file that accompanied this code.
41.13 + *
41.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
41.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
41.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
41.17 + * version 2 for more details (a copy is included in the LICENSE file that
41.18 + * accompanied this code).
41.19 + *
41.20 + * You should have received a copy of the GNU General Public License version
41.21 + * 2 along with this work; if not, write to the Free Software Foundation,
41.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
41.23 + *
41.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
41.25 + * or visit www.oracle.com if you need additional information or have any
41.26 + * questions.
41.27 + */
41.28 +
41.29 +package java.lang;
41.30 +
41.31 +/**
41.32 + * Class {@code Object} is the root of the class hierarchy.
41.33 + * Every class has {@code Object} as a superclass. All objects,
41.34 + * including arrays, implement the methods of this class.
41.35 + *
41.36 + * @author unascribed
41.37 + * @see java.lang.Class
41.38 + * @since JDK1.0
41.39 + */
41.40 +public class Object {
41.41 +
41.42 + private static native void registerNatives();
41.43 + static {
41.44 + registerNatives();
41.45 + }
41.46 +
41.47 + /**
41.48 + * Returns the runtime class of this {@code Object}. The returned
41.49 + * {@code Class} object is the object that is locked by {@code
41.50 + * static synchronized} methods of the represented class.
41.51 + *
41.52 + * <p><b>The actual result type is {@code Class<? extends |X|>}
41.53 + * where {@code |X|} is the erasure of the static type of the
41.54 + * expression on which {@code getClass} is called.</b> For
41.55 + * example, no cast is required in this code fragment:</p>
41.56 + *
41.57 + * <p>
41.58 + * {@code Number n = 0; }<br>
41.59 + * {@code Class<? extends Number> c = n.getClass(); }
41.60 + * </p>
41.61 + *
41.62 + * @return The {@code Class} object that represents the runtime
41.63 + * class of this object.
41.64 + * @see Class Literals, section 15.8.2 of
41.65 + * <cite>The Java™ Language Specification</cite>.
41.66 + */
41.67 + public final native Class<?> getClass();
41.68 +
41.69 + /**
41.70 + * Returns a hash code value for the object. This method is
41.71 + * supported for the benefit of hash tables such as those provided by
41.72 + * {@link java.util.HashMap}.
41.73 + * <p>
41.74 + * The general contract of {@code hashCode} is:
41.75 + * <ul>
41.76 + * <li>Whenever it is invoked on the same object more than once during
41.77 + * an execution of a Java application, the {@code hashCode} method
41.78 + * must consistently return the same integer, provided no information
41.79 + * used in {@code equals} comparisons on the object is modified.
41.80 + * This integer need not remain consistent from one execution of an
41.81 + * application to another execution of the same application.
41.82 + * <li>If two objects are equal according to the {@code equals(Object)}
41.83 + * method, then calling the {@code hashCode} method on each of
41.84 + * the two objects must produce the same integer result.
41.85 + * <li>It is <em>not</em> required that if two objects are unequal
41.86 + * according to the {@link java.lang.Object#equals(java.lang.Object)}
41.87 + * method, then calling the {@code hashCode} method on each of the
41.88 + * two objects must produce distinct integer results. However, the
41.89 + * programmer should be aware that producing distinct integer results
41.90 + * for unequal objects may improve the performance of hash tables.
41.91 + * </ul>
41.92 + * <p>
41.93 + * As much as is reasonably practical, the hashCode method defined by
41.94 + * class {@code Object} does return distinct integers for distinct
41.95 + * objects. (This is typically implemented by converting the internal
41.96 + * address of the object into an integer, but this implementation
41.97 + * technique is not required by the
41.98 + * Java<font size="-2"><sup>TM</sup></font> programming language.)
41.99 + *
41.100 + * @return a hash code value for this object.
41.101 + * @see java.lang.Object#equals(java.lang.Object)
41.102 + * @see java.lang.System#identityHashCode
41.103 + */
41.104 + public native int hashCode();
41.105 +
41.106 + /**
41.107 + * Indicates whether some other object is "equal to" this one.
41.108 + * <p>
41.109 + * The {@code equals} method implements an equivalence relation
41.110 + * on non-null object references:
41.111 + * <ul>
41.112 + * <li>It is <i>reflexive</i>: for any non-null reference value
41.113 + * {@code x}, {@code x.equals(x)} should return
41.114 + * {@code true}.
41.115 + * <li>It is <i>symmetric</i>: for any non-null reference values
41.116 + * {@code x} and {@code y}, {@code x.equals(y)}
41.117 + * should return {@code true} if and only if
41.118 + * {@code y.equals(x)} returns {@code true}.
41.119 + * <li>It is <i>transitive</i>: for any non-null reference values
41.120 + * {@code x}, {@code y}, and {@code z}, if
41.121 + * {@code x.equals(y)} returns {@code true} and
41.122 + * {@code y.equals(z)} returns {@code true}, then
41.123 + * {@code x.equals(z)} should return {@code true}.
41.124 + * <li>It is <i>consistent</i>: for any non-null reference values
41.125 + * {@code x} and {@code y}, multiple invocations of
41.126 + * {@code x.equals(y)} consistently return {@code true}
41.127 + * or consistently return {@code false}, provided no
41.128 + * information used in {@code equals} comparisons on the
41.129 + * objects is modified.
41.130 + * <li>For any non-null reference value {@code x},
41.131 + * {@code x.equals(null)} should return {@code false}.
41.132 + * </ul>
41.133 + * <p>
41.134 + * The {@code equals} method for class {@code Object} implements
41.135 + * the most discriminating possible equivalence relation on objects;
41.136 + * that is, for any non-null reference values {@code x} and
41.137 + * {@code y}, this method returns {@code true} if and only
41.138 + * if {@code x} and {@code y} refer to the same object
41.139 + * ({@code x == y} has the value {@code true}).
41.140 + * <p>
41.141 + * Note that it is generally necessary to override the {@code hashCode}
41.142 + * method whenever this method is overridden, so as to maintain the
41.143 + * general contract for the {@code hashCode} method, which states
41.144 + * that equal objects must have equal hash codes.
41.145 + *
41.146 + * @param obj the reference object with which to compare.
41.147 + * @return {@code true} if this object is the same as the obj
41.148 + * argument; {@code false} otherwise.
41.149 + * @see #hashCode()
41.150 + * @see java.util.HashMap
41.151 + */
41.152 + public boolean equals(Object obj) {
41.153 + return (this == obj);
41.154 + }
41.155 +
41.156 + /**
41.157 + * Creates and returns a copy of this object. The precise meaning
41.158 + * of "copy" may depend on the class of the object. The general
41.159 + * intent is that, for any object {@code x}, the expression:
41.160 + * <blockquote>
41.161 + * <pre>
41.162 + * x.clone() != x</pre></blockquote>
41.163 + * will be true, and that the expression:
41.164 + * <blockquote>
41.165 + * <pre>
41.166 + * x.clone().getClass() == x.getClass()</pre></blockquote>
41.167 + * will be {@code true}, but these are not absolute requirements.
41.168 + * While it is typically the case that:
41.169 + * <blockquote>
41.170 + * <pre>
41.171 + * x.clone().equals(x)</pre></blockquote>
41.172 + * will be {@code true}, this is not an absolute requirement.
41.173 + * <p>
41.174 + * By convention, the returned object should be obtained by calling
41.175 + * {@code super.clone}. If a class and all of its superclasses (except
41.176 + * {@code Object}) obey this convention, it will be the case that
41.177 + * {@code x.clone().getClass() == x.getClass()}.
41.178 + * <p>
41.179 + * By convention, the object returned by this method should be independent
41.180 + * of this object (which is being cloned). To achieve this independence,
41.181 + * it may be necessary to modify one or more fields of the object returned
41.182 + * by {@code super.clone} before returning it. Typically, this means
41.183 + * copying any mutable objects that comprise the internal "deep structure"
41.184 + * of the object being cloned and replacing the references to these
41.185 + * objects with references to the copies. If a class contains only
41.186 + * primitive fields or references to immutable objects, then it is usually
41.187 + * the case that no fields in the object returned by {@code super.clone}
41.188 + * need to be modified.
41.189 + * <p>
41.190 + * The method {@code clone} for class {@code Object} performs a
41.191 + * specific cloning operation. First, if the class of this object does
41.192 + * not implement the interface {@code Cloneable}, then a
41.193 + * {@code CloneNotSupportedException} is thrown. Note that all arrays
41.194 + * are considered to implement the interface {@code Cloneable} and that
41.195 + * the return type of the {@code clone} method of an array type {@code T[]}
41.196 + * is {@code T[]} where T is any reference or primitive type.
41.197 + * Otherwise, this method creates a new instance of the class of this
41.198 + * object and initializes all its fields with exactly the contents of
41.199 + * the corresponding fields of this object, as if by assignment; the
41.200 + * contents of the fields are not themselves cloned. Thus, this method
41.201 + * performs a "shallow copy" of this object, not a "deep copy" operation.
41.202 + * <p>
41.203 + * The class {@code Object} does not itself implement the interface
41.204 + * {@code Cloneable}, so calling the {@code clone} method on an object
41.205 + * whose class is {@code Object} will result in throwing an
41.206 + * exception at run time.
41.207 + *
41.208 + * @return a clone of this instance.
41.209 + * @exception CloneNotSupportedException if the object's class does not
41.210 + * support the {@code Cloneable} interface. Subclasses
41.211 + * that override the {@code clone} method can also
41.212 + * throw this exception to indicate that an instance cannot
41.213 + * be cloned.
41.214 + * @see java.lang.Cloneable
41.215 + */
41.216 + protected native Object clone() throws CloneNotSupportedException;
41.217 +
41.218 + /**
41.219 + * Returns a string representation of the object. In general, the
41.220 + * {@code toString} method returns a string that
41.221 + * "textually represents" this object. The result should
41.222 + * be a concise but informative representation that is easy for a
41.223 + * person to read.
41.224 + * It is recommended that all subclasses override this method.
41.225 + * <p>
41.226 + * The {@code toString} method for class {@code Object}
41.227 + * returns a string consisting of the name of the class of which the
41.228 + * object is an instance, the at-sign character `{@code @}', and
41.229 + * the unsigned hexadecimal representation of the hash code of the
41.230 + * object. In other words, this method returns a string equal to the
41.231 + * value of:
41.232 + * <blockquote>
41.233 + * <pre>
41.234 + * getClass().getName() + '@' + Integer.toHexString(hashCode())
41.235 + * </pre></blockquote>
41.236 + *
41.237 + * @return a string representation of the object.
41.238 + */
41.239 + public String toString() {
41.240 + return getClass().getName() + "@" + Integer.toHexString(hashCode());
41.241 + }
41.242 +
41.243 + /**
41.244 + * Wakes up a single thread that is waiting on this object's
41.245 + * monitor. If any threads are waiting on this object, one of them
41.246 + * is chosen to be awakened. The choice is arbitrary and occurs at
41.247 + * the discretion of the implementation. A thread waits on an object's
41.248 + * monitor by calling one of the {@code wait} methods.
41.249 + * <p>
41.250 + * The awakened thread will not be able to proceed until the current
41.251 + * thread relinquishes the lock on this object. The awakened thread will
41.252 + * compete in the usual manner with any other threads that might be
41.253 + * actively competing to synchronize on this object; for example, the
41.254 + * awakened thread enjoys no reliable privilege or disadvantage in being
41.255 + * the next thread to lock this object.
41.256 + * <p>
41.257 + * This method should only be called by a thread that is the owner
41.258 + * of this object's monitor. A thread becomes the owner of the
41.259 + * object's monitor in one of three ways:
41.260 + * <ul>
41.261 + * <li>By executing a synchronized instance method of that object.
41.262 + * <li>By executing the body of a {@code synchronized} statement
41.263 + * that synchronizes on the object.
41.264 + * <li>For objects of type {@code Class,} by executing a
41.265 + * synchronized static method of that class.
41.266 + * </ul>
41.267 + * <p>
41.268 + * Only one thread at a time can own an object's monitor.
41.269 + *
41.270 + * @exception IllegalMonitorStateException if the current thread is not
41.271 + * the owner of this object's monitor.
41.272 + * @see java.lang.Object#notifyAll()
41.273 + * @see java.lang.Object#wait()
41.274 + */
41.275 + public final native void notify();
41.276 +
41.277 + /**
41.278 + * Wakes up all threads that are waiting on this object's monitor. A
41.279 + * thread waits on an object's monitor by calling one of the
41.280 + * {@code wait} methods.
41.281 + * <p>
41.282 + * The awakened threads will not be able to proceed until the current
41.283 + * thread relinquishes the lock on this object. The awakened threads
41.284 + * will compete in the usual manner with any other threads that might
41.285 + * be actively competing to synchronize on this object; for example,
41.286 + * the awakened threads enjoy no reliable privilege or disadvantage in
41.287 + * being the next thread to lock this object.
41.288 + * <p>
41.289 + * This method should only be called by a thread that is the owner
41.290 + * of this object's monitor. See the {@code notify} method for a
41.291 + * description of the ways in which a thread can become the owner of
41.292 + * a monitor.
41.293 + *
41.294 + * @exception IllegalMonitorStateException if the current thread is not
41.295 + * the owner of this object's monitor.
41.296 + * @see java.lang.Object#notify()
41.297 + * @see java.lang.Object#wait()
41.298 + */
41.299 + public final native void notifyAll();
41.300 +
41.301 + /**
41.302 + * Causes the current thread to wait until either another thread invokes the
41.303 + * {@link java.lang.Object#notify()} method or the
41.304 + * {@link java.lang.Object#notifyAll()} method for this object, or a
41.305 + * specified amount of time has elapsed.
41.306 + * <p>
41.307 + * The current thread must own this object's monitor.
41.308 + * <p>
41.309 + * This method causes the current thread (call it <var>T</var>) to
41.310 + * place itself in the wait set for this object and then to relinquish
41.311 + * any and all synchronization claims on this object. Thread <var>T</var>
41.312 + * becomes disabled for thread scheduling purposes and lies dormant
41.313 + * until one of four things happens:
41.314 + * <ul>
41.315 + * <li>Some other thread invokes the {@code notify} method for this
41.316 + * object and thread <var>T</var> happens to be arbitrarily chosen as
41.317 + * the thread to be awakened.
41.318 + * <li>Some other thread invokes the {@code notifyAll} method for this
41.319 + * object.
41.320 + * <li>Some other thread {@linkplain Thread#interrupt() interrupts}
41.321 + * thread <var>T</var>.
41.322 + * <li>The specified amount of real time has elapsed, more or less. If
41.323 + * {@code timeout} is zero, however, then real time is not taken into
41.324 + * consideration and the thread simply waits until notified.
41.325 + * </ul>
41.326 + * The thread <var>T</var> is then removed from the wait set for this
41.327 + * object and re-enabled for thread scheduling. It then competes in the
41.328 + * usual manner with other threads for the right to synchronize on the
41.329 + * object; once it has gained control of the object, all its
41.330 + * synchronization claims on the object are restored to the status quo
41.331 + * ante - that is, to the situation as of the time that the {@code wait}
41.332 + * method was invoked. Thread <var>T</var> then returns from the
41.333 + * invocation of the {@code wait} method. Thus, on return from the
41.334 + * {@code wait} method, the synchronization state of the object and of
41.335 + * thread {@code T} is exactly as it was when the {@code wait} method
41.336 + * was invoked.
41.337 + * <p>
41.338 + * A thread can also wake up without being notified, interrupted, or
41.339 + * timing out, a so-called <i>spurious wakeup</i>. While this will rarely
41.340 + * occur in practice, applications must guard against it by testing for
41.341 + * the condition that should have caused the thread to be awakened, and
41.342 + * continuing to wait if the condition is not satisfied. In other words,
41.343 + * waits should always occur in loops, like this one:
41.344 + * <pre>
41.345 + * synchronized (obj) {
41.346 + * while (<condition does not hold>)
41.347 + * obj.wait(timeout);
41.348 + * ... // Perform action appropriate to condition
41.349 + * }
41.350 + * </pre>
41.351 + * (For more information on this topic, see Section 3.2.3 in Doug Lea's
41.352 + * "Concurrent Programming in Java (Second Edition)" (Addison-Wesley,
41.353 + * 2000), or Item 50 in Joshua Bloch's "Effective Java Programming
41.354 + * Language Guide" (Addison-Wesley, 2001).
41.355 + *
41.356 + * <p>If the current thread is {@linkplain java.lang.Thread#interrupt()
41.357 + * interrupted} by any thread before or while it is waiting, then an
41.358 + * {@code InterruptedException} is thrown. This exception is not
41.359 + * thrown until the lock status of this object has been restored as
41.360 + * described above.
41.361 + *
41.362 + * <p>
41.363 + * Note that the {@code wait} method, as it places the current thread
41.364 + * into the wait set for this object, unlocks only this object; any
41.365 + * other objects on which the current thread may be synchronized remain
41.366 + * locked while the thread waits.
41.367 + * <p>
41.368 + * This method should only be called by a thread that is the owner
41.369 + * of this object's monitor. See the {@code notify} method for a
41.370 + * description of the ways in which a thread can become the owner of
41.371 + * a monitor.
41.372 + *
41.373 + * @param timeout the maximum time to wait in milliseconds.
41.374 + * @exception IllegalArgumentException if the value of timeout is
41.375 + * negative.
41.376 + * @exception IllegalMonitorStateException if the current thread is not
41.377 + * the owner of the object's monitor.
41.378 + * @exception InterruptedException if any thread interrupted the
41.379 + * current thread before or while the current thread
41.380 + * was waiting for a notification. The <i>interrupted
41.381 + * status</i> of the current thread is cleared when
41.382 + * this exception is thrown.
41.383 + * @see java.lang.Object#notify()
41.384 + * @see java.lang.Object#notifyAll()
41.385 + */
41.386 + public final native void wait(long timeout) throws InterruptedException;
41.387 +
41.388 + /**
41.389 + * Causes the current thread to wait until another thread invokes the
41.390 + * {@link java.lang.Object#notify()} method or the
41.391 + * {@link java.lang.Object#notifyAll()} method for this object, or
41.392 + * some other thread interrupts the current thread, or a certain
41.393 + * amount of real time has elapsed.
41.394 + * <p>
41.395 + * This method is similar to the {@code wait} method of one
41.396 + * argument, but it allows finer control over the amount of time to
41.397 + * wait for a notification before giving up. The amount of real time,
41.398 + * measured in nanoseconds, is given by:
41.399 + * <blockquote>
41.400 + * <pre>
41.401 + * 1000000*timeout+nanos</pre></blockquote>
41.402 + * <p>
41.403 + * In all other respects, this method does the same thing as the
41.404 + * method {@link #wait(long)} of one argument. In particular,
41.405 + * {@code wait(0, 0)} means the same thing as {@code wait(0)}.
41.406 + * <p>
41.407 + * The current thread must own this object's monitor. The thread
41.408 + * releases ownership of this monitor and waits until either of the
41.409 + * following two conditions has occurred:
41.410 + * <ul>
41.411 + * <li>Another thread notifies threads waiting on this object's monitor
41.412 + * to wake up either through a call to the {@code notify} method
41.413 + * or the {@code notifyAll} method.
41.414 + * <li>The timeout period, specified by {@code timeout}
41.415 + * milliseconds plus {@code nanos} nanoseconds arguments, has
41.416 + * elapsed.
41.417 + * </ul>
41.418 + * <p>
41.419 + * The thread then waits until it can re-obtain ownership of the
41.420 + * monitor and resumes execution.
41.421 + * <p>
41.422 + * As in the one argument version, interrupts and spurious wakeups are
41.423 + * possible, and this method should always be used in a loop:
41.424 + * <pre>
41.425 + * synchronized (obj) {
41.426 + * while (<condition does not hold>)
41.427 + * obj.wait(timeout, nanos);
41.428 + * ... // Perform action appropriate to condition
41.429 + * }
41.430 + * </pre>
41.431 + * This method should only be called by a thread that is the owner
41.432 + * of this object's monitor. See the {@code notify} method for a
41.433 + * description of the ways in which a thread can become the owner of
41.434 + * a monitor.
41.435 + *
41.436 + * @param timeout the maximum time to wait in milliseconds.
41.437 + * @param nanos additional time, in nanoseconds range
41.438 + * 0-999999.
41.439 + * @exception IllegalArgumentException if the value of timeout is
41.440 + * negative or the value of nanos is
41.441 + * not in the range 0-999999.
41.442 + * @exception IllegalMonitorStateException if the current thread is not
41.443 + * the owner of this object's monitor.
41.444 + * @exception InterruptedException if any thread interrupted the
41.445 + * current thread before or while the current thread
41.446 + * was waiting for a notification. The <i>interrupted
41.447 + * status</i> of the current thread is cleared when
41.448 + * this exception is thrown.
41.449 + */
41.450 + public final void wait(long timeout, int nanos) throws InterruptedException {
41.451 + if (timeout < 0) {
41.452 + throw new IllegalArgumentException("timeout value is negative");
41.453 + }
41.454 +
41.455 + if (nanos < 0 || nanos > 999999) {
41.456 + throw new IllegalArgumentException(
41.457 + "nanosecond timeout value out of range");
41.458 + }
41.459 +
41.460 + if (nanos >= 500000 || (nanos != 0 && timeout == 0)) {
41.461 + timeout++;
41.462 + }
41.463 +
41.464 + wait(timeout);
41.465 + }
41.466 +
41.467 + /**
41.468 + * Causes the current thread to wait until another thread invokes the
41.469 + * {@link java.lang.Object#notify()} method or the
41.470 + * {@link java.lang.Object#notifyAll()} method for this object.
41.471 + * In other words, this method behaves exactly as if it simply
41.472 + * performs the call {@code wait(0)}.
41.473 + * <p>
41.474 + * The current thread must own this object's monitor. The thread
41.475 + * releases ownership of this monitor and waits until another thread
41.476 + * notifies threads waiting on this object's monitor to wake up
41.477 + * either through a call to the {@code notify} method or the
41.478 + * {@code notifyAll} method. The thread then waits until it can
41.479 + * re-obtain ownership of the monitor and resumes execution.
41.480 + * <p>
41.481 + * As in the one argument version, interrupts and spurious wakeups are
41.482 + * possible, and this method should always be used in a loop:
41.483 + * <pre>
41.484 + * synchronized (obj) {
41.485 + * while (<condition does not hold>)
41.486 + * obj.wait();
41.487 + * ... // Perform action appropriate to condition
41.488 + * }
41.489 + * </pre>
41.490 + * This method should only be called by a thread that is the owner
41.491 + * of this object's monitor. See the {@code notify} method for a
41.492 + * description of the ways in which a thread can become the owner of
41.493 + * a monitor.
41.494 + *
41.495 + * @exception IllegalMonitorStateException if the current thread is not
41.496 + * the owner of the object's monitor.
41.497 + * @exception InterruptedException if any thread interrupted the
41.498 + * current thread before or while the current thread
41.499 + * was waiting for a notification. The <i>interrupted
41.500 + * status</i> of the current thread is cleared when
41.501 + * this exception is thrown.
41.502 + * @see java.lang.Object#notify()
41.503 + * @see java.lang.Object#notifyAll()
41.504 + */
41.505 + public final void wait() throws InterruptedException {
41.506 + wait(0);
41.507 + }
41.508 +
41.509 + /**
41.510 + * Called by the garbage collector on an object when garbage collection
41.511 + * determines that there are no more references to the object.
41.512 + * A subclass overrides the {@code finalize} method to dispose of
41.513 + * system resources or to perform other cleanup.
41.514 + * <p>
41.515 + * The general contract of {@code finalize} is that it is invoked
41.516 + * if and when the Java<font size="-2"><sup>TM</sup></font> virtual
41.517 + * machine has determined that there is no longer any
41.518 + * means by which this object can be accessed by any thread that has
41.519 + * not yet died, except as a result of an action taken by the
41.520 + * finalization of some other object or class which is ready to be
41.521 + * finalized. The {@code finalize} method may take any action, including
41.522 + * making this object available again to other threads; the usual purpose
41.523 + * of {@code finalize}, however, is to perform cleanup actions before
41.524 + * the object is irrevocably discarded. For example, the finalize method
41.525 + * for an object that represents an input/output connection might perform
41.526 + * explicit I/O transactions to break the connection before the object is
41.527 + * permanently discarded.
41.528 + * <p>
41.529 + * The {@code finalize} method of class {@code Object} performs no
41.530 + * special action; it simply returns normally. Subclasses of
41.531 + * {@code Object} may override this definition.
41.532 + * <p>
41.533 + * The Java programming language does not guarantee which thread will
41.534 + * invoke the {@code finalize} method for any given object. It is
41.535 + * guaranteed, however, that the thread that invokes finalize will not
41.536 + * be holding any user-visible synchronization locks when finalize is
41.537 + * invoked. If an uncaught exception is thrown by the finalize method,
41.538 + * the exception is ignored and finalization of that object terminates.
41.539 + * <p>
41.540 + * After the {@code finalize} method has been invoked for an object, no
41.541 + * further action is taken until the Java virtual machine has again
41.542 + * determined that there is no longer any means by which this object can
41.543 + * be accessed by any thread that has not yet died, including possible
41.544 + * actions by other objects or classes which are ready to be finalized,
41.545 + * at which point the object may be discarded.
41.546 + * <p>
41.547 + * The {@code finalize} method is never invoked more than once by a Java
41.548 + * virtual machine for any given object.
41.549 + * <p>
41.550 + * Any exception thrown by the {@code finalize} method causes
41.551 + * the finalization of this object to be halted, but is otherwise
41.552 + * ignored.
41.553 + *
41.554 + * @throws Throwable the {@code Exception} raised by this method
41.555 + */
41.556 + protected void finalize() throws Throwable { }
41.557 +}
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
42.2 +++ b/emul/src/main/java/java/lang/OutOfMemoryError.java Thu Oct 11 06:16:00 2012 -0700
42.3 @@ -0,0 +1,60 @@
42.4 +/*
42.5 + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
42.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
42.7 + *
42.8 + * This code is free software; you can redistribute it and/or modify it
42.9 + * under the terms of the GNU General Public License version 2 only, as
42.10 + * published by the Free Software Foundation. Oracle designates this
42.11 + * particular file as subject to the "Classpath" exception as provided
42.12 + * by Oracle in the LICENSE file that accompanied this code.
42.13 + *
42.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
42.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
42.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
42.17 + * version 2 for more details (a copy is included in the LICENSE file that
42.18 + * accompanied this code).
42.19 + *
42.20 + * You should have received a copy of the GNU General Public License version
42.21 + * 2 along with this work; if not, write to the Free Software Foundation,
42.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
42.23 + *
42.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
42.25 + * or visit www.oracle.com if you need additional information or have any
42.26 + * questions.
42.27 + */
42.28 +
42.29 +package java.lang;
42.30 +
42.31 +/**
42.32 + * Thrown when the Java Virtual Machine cannot allocate an object
42.33 + * because it is out of memory, and no more memory could be made
42.34 + * available by the garbage collector.
42.35 + *
42.36 + * {@code OutOfMemoryError} objects may be constructed by the virtual
42.37 + * machine as if {@linkplain Throwable#Throwable(String, Throwable,
42.38 + * boolean, boolean) suppression were disabled and/or the stack trace was not
42.39 + * writable}.
42.40 + *
42.41 + * @author unascribed
42.42 + * @since JDK1.0
42.43 + */
42.44 +public class OutOfMemoryError extends VirtualMachineError {
42.45 + private static final long serialVersionUID = 8228564086184010517L;
42.46 +
42.47 + /**
42.48 + * Constructs an {@code OutOfMemoryError} with no detail message.
42.49 + */
42.50 + public OutOfMemoryError() {
42.51 + super();
42.52 + }
42.53 +
42.54 + /**
42.55 + * Constructs an {@code OutOfMemoryError} with the specified
42.56 + * detail message.
42.57 + *
42.58 + * @param s the detail message.
42.59 + */
42.60 + public OutOfMemoryError(String s) {
42.61 + super(s);
42.62 + }
42.63 +}
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
43.2 +++ b/emul/src/main/java/java/lang/ReflectiveOperationException.java Thu Oct 11 06:16:00 2012 -0700
43.3 @@ -0,0 +1,91 @@
43.4 +/*
43.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
43.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
43.7 + *
43.8 + * This code is free software; you can redistribute it and/or modify it
43.9 + * under the terms of the GNU General Public License version 2 only, as
43.10 + * published by the Free Software Foundation. Oracle designates this
43.11 + * particular file as subject to the "Classpath" exception as provided
43.12 + * by Oracle in the LICENSE file that accompanied this code.
43.13 + *
43.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
43.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
43.17 + * version 2 for more details (a copy is included in the LICENSE file that
43.18 + * accompanied this code).
43.19 + *
43.20 + * You should have received a copy of the GNU General Public License version
43.21 + * 2 along with this work; if not, write to the Free Software Foundation,
43.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
43.23 + *
43.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
43.25 + * or visit www.oracle.com if you need additional information or have any
43.26 + * questions.
43.27 + */
43.28 +
43.29 +package java.lang;
43.30 +
43.31 +/**
43.32 + * Common superclass of exceptions thrown by reflective operations in
43.33 + * core reflection.
43.34 + *
43.35 + * @see LinkageError
43.36 + * @since 1.7
43.37 + */
43.38 +public class ReflectiveOperationException extends Exception {
43.39 + static final long serialVersionUID = 123456789L;
43.40 +
43.41 + /**
43.42 + * Constructs a new exception with {@code null} as its detail
43.43 + * message. The cause is not initialized, and may subsequently be
43.44 + * initialized by a call to {@link #initCause}.
43.45 + */
43.46 + public ReflectiveOperationException() {
43.47 + super();
43.48 + }
43.49 +
43.50 + /**
43.51 + * Constructs a new exception with the specified detail message.
43.52 + * The cause is not initialized, and may subsequently be
43.53 + * initialized by a call to {@link #initCause}.
43.54 + *
43.55 + * @param message the detail message. The detail message is saved for
43.56 + * later retrieval by the {@link #getMessage()} method.
43.57 + */
43.58 + public ReflectiveOperationException(String message) {
43.59 + super(message);
43.60 + }
43.61 +
43.62 + /**
43.63 + * Constructs a new exception with the specified detail message
43.64 + * and cause.
43.65 + *
43.66 + * <p>Note that the detail message associated with
43.67 + * {@code cause} is <em>not</em> automatically incorporated in
43.68 + * this exception's detail message.
43.69 + *
43.70 + * @param message the detail message (which is saved for later retrieval
43.71 + * by the {@link #getMessage()} method).
43.72 + * @param cause the cause (which is saved for later retrieval by the
43.73 + * {@link #getCause()} method). (A {@code null} value is
43.74 + * permitted, and indicates that the cause is nonexistent or
43.75 + * unknown.)
43.76 + */
43.77 + public ReflectiveOperationException(String message, Throwable cause) {
43.78 + super(message, cause);
43.79 + }
43.80 +
43.81 + /**
43.82 + * Constructs a new exception with the specified cause and a detail
43.83 + * message of {@code (cause==null ? null : cause.toString())} (which
43.84 + * typically contains the class and detail message of {@code cause}).
43.85 + *
43.86 + * @param cause the cause (which is saved for later retrieval by the
43.87 + * {@link #getCause()} method). (A {@code null} value is
43.88 + * permitted, and indicates that the cause is nonexistent or
43.89 + * unknown.)
43.90 + */
43.91 + public ReflectiveOperationException(Throwable cause) {
43.92 + super(cause);
43.93 + }
43.94 +}
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
44.2 +++ b/emul/src/main/java/java/lang/RuntimeException.java Thu Oct 11 06:16:00 2012 -0700
44.3 @@ -0,0 +1,119 @@
44.4 +/*
44.5 + * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
44.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44.7 + *
44.8 + * This code is free software; you can redistribute it and/or modify it
44.9 + * under the terms of the GNU General Public License version 2 only, as
44.10 + * published by the Free Software Foundation. Oracle designates this
44.11 + * particular file as subject to the "Classpath" exception as provided
44.12 + * by Oracle in the LICENSE file that accompanied this code.
44.13 + *
44.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
44.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
44.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
44.17 + * version 2 for more details (a copy is included in the LICENSE file that
44.18 + * accompanied this code).
44.19 + *
44.20 + * You should have received a copy of the GNU General Public License version
44.21 + * 2 along with this work; if not, write to the Free Software Foundation,
44.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
44.23 + *
44.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
44.25 + * or visit www.oracle.com if you need additional information or have any
44.26 + * questions.
44.27 + */
44.28 +
44.29 +package java.lang;
44.30 +
44.31 +/**
44.32 + * {@code RuntimeException} is the superclass of those
44.33 + * exceptions that can be thrown during the normal operation of the
44.34 + * Java Virtual Machine.
44.35 + *
44.36 + * <p>{@code RuntimeException} and its subclasses are <em>unchecked
44.37 + * exceptions</em>. Unchecked exceptions do <em>not</em> need to be
44.38 + * declared in a method or constructor's {@code throws} clause if they
44.39 + * can be thrown by the execution of the method or constructor and
44.40 + * propagate outside the method or constructor boundary.
44.41 + *
44.42 + * @author Frank Yellin
44.43 + * @jls 11.2 Compile-Time Checking of Exceptions
44.44 + * @since JDK1.0
44.45 + */
44.46 +public class RuntimeException extends Exception {
44.47 + static final long serialVersionUID = -7034897190745766939L;
44.48 +
44.49 + /** Constructs a new runtime exception with {@code null} as its
44.50 + * detail message. The cause is not initialized, and may subsequently be
44.51 + * initialized by a call to {@link #initCause}.
44.52 + */
44.53 + public RuntimeException() {
44.54 + super();
44.55 + }
44.56 +
44.57 + /** Constructs a new runtime exception with the specified detail message.
44.58 + * The cause is not initialized, and may subsequently be initialized by a
44.59 + * call to {@link #initCause}.
44.60 + *
44.61 + * @param message the detail message. The detail message is saved for
44.62 + * later retrieval by the {@link #getMessage()} method.
44.63 + */
44.64 + public RuntimeException(String message) {
44.65 + super(message);
44.66 + }
44.67 +
44.68 + /**
44.69 + * Constructs a new runtime exception with the specified detail message and
44.70 + * cause. <p>Note that the detail message associated with
44.71 + * {@code cause} is <i>not</i> automatically incorporated in
44.72 + * this runtime exception's detail message.
44.73 + *
44.74 + * @param message the detail message (which is saved for later retrieval
44.75 + * by the {@link #getMessage()} method).
44.76 + * @param cause the cause (which is saved for later retrieval by the
44.77 + * {@link #getCause()} method). (A <tt>null</tt> value is
44.78 + * permitted, and indicates that the cause is nonexistent or
44.79 + * unknown.)
44.80 + * @since 1.4
44.81 + */
44.82 + public RuntimeException(String message, Throwable cause) {
44.83 + super(message, cause);
44.84 + }
44.85 +
44.86 + /** Constructs a new runtime exception with the specified cause and a
44.87 + * detail message of <tt>(cause==null ? null : cause.toString())</tt>
44.88 + * (which typically contains the class and detail message of
44.89 + * <tt>cause</tt>). This constructor is useful for runtime exceptions
44.90 + * that are little more than wrappers for other throwables.
44.91 + *
44.92 + * @param cause the cause (which is saved for later retrieval by the
44.93 + * {@link #getCause()} method). (A <tt>null</tt> value is
44.94 + * permitted, and indicates that the cause is nonexistent or
44.95 + * unknown.)
44.96 + * @since 1.4
44.97 + */
44.98 + public RuntimeException(Throwable cause) {
44.99 + super(cause);
44.100 + }
44.101 +
44.102 + /**
44.103 + * Constructs a new runtime exception with the specified detail
44.104 + * message, cause, suppression enabled or disabled, and writable
44.105 + * stack trace enabled or disabled.
44.106 + *
44.107 + * @param message the detail message.
44.108 + * @param cause the cause. (A {@code null} value is permitted,
44.109 + * and indicates that the cause is nonexistent or unknown.)
44.110 + * @param enableSuppression whether or not suppression is enabled
44.111 + * or disabled
44.112 + * @param writableStackTrace whether or not the stack trace should
44.113 + * be writable
44.114 + *
44.115 + * @since 1.7
44.116 + */
44.117 + protected RuntimeException(String message, Throwable cause,
44.118 + boolean enableSuppression,
44.119 + boolean writableStackTrace) {
44.120 + super(message, cause, enableSuppression, writableStackTrace);
44.121 + }
44.122 +}
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
45.2 +++ b/emul/src/main/java/java/lang/Short.java Thu Oct 11 06:16:00 2012 -0700
45.3 @@ -0,0 +1,468 @@
45.4 +/*
45.5 + * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
45.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45.7 + *
45.8 + * This code is free software; you can redistribute it and/or modify it
45.9 + * under the terms of the GNU General Public License version 2 only, as
45.10 + * published by the Free Software Foundation. Oracle designates this
45.11 + * particular file as subject to the "Classpath" exception as provided
45.12 + * by Oracle in the LICENSE file that accompanied this code.
45.13 + *
45.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
45.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
45.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
45.17 + * version 2 for more details (a copy is included in the LICENSE file that
45.18 + * accompanied this code).
45.19 + *
45.20 + * You should have received a copy of the GNU General Public License version
45.21 + * 2 along with this work; if not, write to the Free Software Foundation,
45.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
45.23 + *
45.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
45.25 + * or visit www.oracle.com if you need additional information or have any
45.26 + * questions.
45.27 + */
45.28 +
45.29 +package java.lang;
45.30 +
45.31 +/**
45.32 + * The {@code Short} class wraps a value of primitive type {@code
45.33 + * short} in an object. An object of type {@code Short} contains a
45.34 + * single field whose type is {@code short}.
45.35 + *
45.36 + * <p>In addition, this class provides several methods for converting
45.37 + * a {@code short} to a {@code String} and a {@code String} to a
45.38 + * {@code short}, as well as other constants and methods useful when
45.39 + * dealing with a {@code short}.
45.40 + *
45.41 + * @author Nakul Saraiya
45.42 + * @author Joseph D. Darcy
45.43 + * @see java.lang.Number
45.44 + * @since JDK1.1
45.45 + */
45.46 +public final class Short extends Number implements Comparable<Short> {
45.47 +
45.48 + /**
45.49 + * A constant holding the minimum value a {@code short} can
45.50 + * have, -2<sup>15</sup>.
45.51 + */
45.52 + public static final short MIN_VALUE = -32768;
45.53 +
45.54 + /**
45.55 + * A constant holding the maximum value a {@code short} can
45.56 + * have, 2<sup>15</sup>-1.
45.57 + */
45.58 + public static final short MAX_VALUE = 32767;
45.59 +
45.60 + /**
45.61 + * The {@code Class} instance representing the primitive type
45.62 + * {@code short}.
45.63 + */
45.64 + public static final Class<Short> TYPE = (Class<Short>) Class.getPrimitiveClass("short");
45.65 +
45.66 + /**
45.67 + * Returns a new {@code String} object representing the
45.68 + * specified {@code short}. The radix is assumed to be 10.
45.69 + *
45.70 + * @param s the {@code short} to be converted
45.71 + * @return the string representation of the specified {@code short}
45.72 + * @see java.lang.Integer#toString(int)
45.73 + */
45.74 + public static String toString(short s) {
45.75 + return Integer.toString((int)s, 10);
45.76 + }
45.77 +
45.78 + /**
45.79 + * Parses the string argument as a signed {@code short} in the
45.80 + * radix specified by the second argument. The characters in the
45.81 + * string must all be digits, of the specified radix (as
45.82 + * determined by whether {@link java.lang.Character#digit(char,
45.83 + * int)} returns a nonnegative value) except that the first
45.84 + * character may be an ASCII minus sign {@code '-'}
45.85 + * (<code>'\u002D'</code>) to indicate a negative value or an
45.86 + * ASCII plus sign {@code '+'} (<code>'\u002B'</code>) to
45.87 + * indicate a positive value. The resulting {@code short} value
45.88 + * is returned.
45.89 + *
45.90 + * <p>An exception of type {@code NumberFormatException} is
45.91 + * thrown if any of the following situations occurs:
45.92 + * <ul>
45.93 + * <li> The first argument is {@code null} or is a string of
45.94 + * length zero.
45.95 + *
45.96 + * <li> The radix is either smaller than {@link
45.97 + * java.lang.Character#MIN_RADIX} or larger than {@link
45.98 + * java.lang.Character#MAX_RADIX}.
45.99 + *
45.100 + * <li> Any character of the string is not a digit of the
45.101 + * specified radix, except that the first character may be a minus
45.102 + * sign {@code '-'} (<code>'\u002D'</code>) or plus sign
45.103 + * {@code '+'} (<code>'\u002B'</code>) provided that the
45.104 + * string is longer than length 1.
45.105 + *
45.106 + * <li> The value represented by the string is not a value of type
45.107 + * {@code short}.
45.108 + * </ul>
45.109 + *
45.110 + * @param s the {@code String} containing the
45.111 + * {@code short} representation to be parsed
45.112 + * @param radix the radix to be used while parsing {@code s}
45.113 + * @return the {@code short} represented by the string
45.114 + * argument in the specified radix.
45.115 + * @throws NumberFormatException If the {@code String}
45.116 + * does not contain a parsable {@code short}.
45.117 + */
45.118 + public static short parseShort(String s, int radix)
45.119 + throws NumberFormatException {
45.120 + int i = Integer.parseInt(s, radix);
45.121 + if (i < MIN_VALUE || i > MAX_VALUE)
45.122 + throw new NumberFormatException(
45.123 + "Value out of range. Value:\"" + s + "\" Radix:" + radix);
45.124 + return (short)i;
45.125 + }
45.126 +
45.127 + /**
45.128 + * Parses the string argument as a signed decimal {@code
45.129 + * short}. The characters in the string must all be decimal
45.130 + * digits, except that the first character may be an ASCII minus
45.131 + * sign {@code '-'} (<code>'\u002D'</code>) to indicate a
45.132 + * negative value or an ASCII plus sign {@code '+'}
45.133 + * (<code>'\u002B'</code>) to indicate a positive value. The
45.134 + * resulting {@code short} value is returned, exactly as if the
45.135 + * argument and the radix 10 were given as arguments to the {@link
45.136 + * #parseShort(java.lang.String, int)} method.
45.137 + *
45.138 + * @param s a {@code String} containing the {@code short}
45.139 + * representation to be parsed
45.140 + * @return the {@code short} value represented by the
45.141 + * argument in decimal.
45.142 + * @throws NumberFormatException If the string does not
45.143 + * contain a parsable {@code short}.
45.144 + */
45.145 + public static short parseShort(String s) throws NumberFormatException {
45.146 + return parseShort(s, 10);
45.147 + }
45.148 +
45.149 + /**
45.150 + * Returns a {@code Short} object holding the value
45.151 + * extracted from the specified {@code String} when parsed
45.152 + * with the radix given by the second argument. The first argument
45.153 + * is interpreted as representing a signed {@code short} in
45.154 + * the radix specified by the second argument, exactly as if the
45.155 + * argument were given to the {@link #parseShort(java.lang.String,
45.156 + * int)} method. The result is a {@code Short} object that
45.157 + * represents the {@code short} value specified by the string.
45.158 + *
45.159 + * <p>In other words, this method returns a {@code Short} object
45.160 + * equal to the value of:
45.161 + *
45.162 + * <blockquote>
45.163 + * {@code new Short(Short.parseShort(s, radix))}
45.164 + * </blockquote>
45.165 + *
45.166 + * @param s the string to be parsed
45.167 + * @param radix the radix to be used in interpreting {@code s}
45.168 + * @return a {@code Short} object holding the value
45.169 + * represented by the string argument in the
45.170 + * specified radix.
45.171 + * @throws NumberFormatException If the {@code String} does
45.172 + * not contain a parsable {@code short}.
45.173 + */
45.174 + public static Short valueOf(String s, int radix)
45.175 + throws NumberFormatException {
45.176 + return valueOf(parseShort(s, radix));
45.177 + }
45.178 +
45.179 + /**
45.180 + * Returns a {@code Short} object holding the
45.181 + * value given by the specified {@code String}. The argument
45.182 + * is interpreted as representing a signed decimal
45.183 + * {@code short}, exactly as if the argument were given to
45.184 + * the {@link #parseShort(java.lang.String)} method. The result is
45.185 + * a {@code Short} object that represents the
45.186 + * {@code short} value specified by the string.
45.187 + *
45.188 + * <p>In other words, this method returns a {@code Short} object
45.189 + * equal to the value of:
45.190 + *
45.191 + * <blockquote>
45.192 + * {@code new Short(Short.parseShort(s))}
45.193 + * </blockquote>
45.194 + *
45.195 + * @param s the string to be parsed
45.196 + * @return a {@code Short} object holding the value
45.197 + * represented by the string argument
45.198 + * @throws NumberFormatException If the {@code String} does
45.199 + * not contain a parsable {@code short}.
45.200 + */
45.201 + public static Short valueOf(String s) throws NumberFormatException {
45.202 + return valueOf(s, 10);
45.203 + }
45.204 +
45.205 + private static class ShortCache {
45.206 + private ShortCache(){}
45.207 +
45.208 + static final Short cache[] = new Short[-(-128) + 127 + 1];
45.209 +
45.210 + static {
45.211 + for(int i = 0; i < cache.length; i++)
45.212 + cache[i] = new Short((short)(i - 128));
45.213 + }
45.214 + }
45.215 +
45.216 + /**
45.217 + * Returns a {@code Short} instance representing the specified
45.218 + * {@code short} value.
45.219 + * If a new {@code Short} instance is not required, this method
45.220 + * should generally be used in preference to the constructor
45.221 + * {@link #Short(short)}, as this method is likely to yield
45.222 + * significantly better space and time performance by caching
45.223 + * frequently requested values.
45.224 + *
45.225 + * This method will always cache values in the range -128 to 127,
45.226 + * inclusive, and may cache other values outside of this range.
45.227 + *
45.228 + * @param s a short value.
45.229 + * @return a {@code Short} instance representing {@code s}.
45.230 + * @since 1.5
45.231 + */
45.232 + public static Short valueOf(short s) {
45.233 + final int offset = 128;
45.234 + int sAsInt = s;
45.235 + if (sAsInt >= -128 && sAsInt <= 127) { // must cache
45.236 + return ShortCache.cache[sAsInt + offset];
45.237 + }
45.238 + return new Short(s);
45.239 + }
45.240 +
45.241 + /**
45.242 + * Decodes a {@code String} into a {@code Short}.
45.243 + * Accepts decimal, hexadecimal, and octal numbers given by
45.244 + * the following grammar:
45.245 + *
45.246 + * <blockquote>
45.247 + * <dl>
45.248 + * <dt><i>DecodableString:</i>
45.249 + * <dd><i>Sign<sub>opt</sub> DecimalNumeral</i>
45.250 + * <dd><i>Sign<sub>opt</sub></i> {@code 0x} <i>HexDigits</i>
45.251 + * <dd><i>Sign<sub>opt</sub></i> {@code 0X} <i>HexDigits</i>
45.252 + * <dd><i>Sign<sub>opt</sub></i> {@code #} <i>HexDigits</i>
45.253 + * <dd><i>Sign<sub>opt</sub></i> {@code 0} <i>OctalDigits</i>
45.254 + * <p>
45.255 + * <dt><i>Sign:</i>
45.256 + * <dd>{@code -}
45.257 + * <dd>{@code +}
45.258 + * </dl>
45.259 + * </blockquote>
45.260 + *
45.261 + * <i>DecimalNumeral</i>, <i>HexDigits</i>, and <i>OctalDigits</i>
45.262 + * are as defined in section 3.10.1 of
45.263 + * <cite>The Java™ Language Specification</cite>,
45.264 + * except that underscores are not accepted between digits.
45.265 + *
45.266 + * <p>The sequence of characters following an optional
45.267 + * sign and/or radix specifier ("{@code 0x}", "{@code 0X}",
45.268 + * "{@code #}", or leading zero) is parsed as by the {@code
45.269 + * Short.parseShort} method with the indicated radix (10, 16, or
45.270 + * 8). This sequence of characters must represent a positive
45.271 + * value or a {@link NumberFormatException} will be thrown. The
45.272 + * result is negated if first character of the specified {@code
45.273 + * String} is the minus sign. No whitespace characters are
45.274 + * permitted in the {@code String}.
45.275 + *
45.276 + * @param nm the {@code String} to decode.
45.277 + * @return a {@code Short} object holding the {@code short}
45.278 + * value represented by {@code nm}
45.279 + * @throws NumberFormatException if the {@code String} does not
45.280 + * contain a parsable {@code short}.
45.281 + * @see java.lang.Short#parseShort(java.lang.String, int)
45.282 + */
45.283 + public static Short decode(String nm) throws NumberFormatException {
45.284 + int i = Integer.decode(nm);
45.285 + if (i < MIN_VALUE || i > MAX_VALUE)
45.286 + throw new NumberFormatException(
45.287 + "Value " + i + " out of range from input " + nm);
45.288 + return valueOf((short)i);
45.289 + }
45.290 +
45.291 + /**
45.292 + * The value of the {@code Short}.
45.293 + *
45.294 + * @serial
45.295 + */
45.296 + private final short value;
45.297 +
45.298 + /**
45.299 + * Constructs a newly allocated {@code Short} object that
45.300 + * represents the specified {@code short} value.
45.301 + *
45.302 + * @param value the value to be represented by the
45.303 + * {@code Short}.
45.304 + */
45.305 + public Short(short value) {
45.306 + this.value = value;
45.307 + }
45.308 +
45.309 + /**
45.310 + * Constructs a newly allocated {@code Short} object that
45.311 + * represents the {@code short} value indicated by the
45.312 + * {@code String} parameter. The string is converted to a
45.313 + * {@code short} value in exactly the manner used by the
45.314 + * {@code parseShort} method for radix 10.
45.315 + *
45.316 + * @param s the {@code String} to be converted to a
45.317 + * {@code Short}
45.318 + * @throws NumberFormatException If the {@code String}
45.319 + * does not contain a parsable {@code short}.
45.320 + * @see java.lang.Short#parseShort(java.lang.String, int)
45.321 + */
45.322 + public Short(String s) throws NumberFormatException {
45.323 + this.value = parseShort(s, 10);
45.324 + }
45.325 +
45.326 + /**
45.327 + * Returns the value of this {@code Short} as a
45.328 + * {@code byte}.
45.329 + */
45.330 + public byte byteValue() {
45.331 + return (byte)value;
45.332 + }
45.333 +
45.334 + /**
45.335 + * Returns the value of this {@code Short} as a
45.336 + * {@code short}.
45.337 + */
45.338 + public short shortValue() {
45.339 + return value;
45.340 + }
45.341 +
45.342 + /**
45.343 + * Returns the value of this {@code Short} as an
45.344 + * {@code int}.
45.345 + */
45.346 + public int intValue() {
45.347 + return (int)value;
45.348 + }
45.349 +
45.350 + /**
45.351 + * Returns the value of this {@code Short} as a
45.352 + * {@code long}.
45.353 + */
45.354 + public long longValue() {
45.355 + return (long)value;
45.356 + }
45.357 +
45.358 + /**
45.359 + * Returns the value of this {@code Short} as a
45.360 + * {@code float}.
45.361 + */
45.362 + public float floatValue() {
45.363 + return (float)value;
45.364 + }
45.365 +
45.366 + /**
45.367 + * Returns the value of this {@code Short} as a
45.368 + * {@code double}.
45.369 + */
45.370 + public double doubleValue() {
45.371 + return (double)value;
45.372 + }
45.373 +
45.374 + /**
45.375 + * Returns a {@code String} object representing this
45.376 + * {@code Short}'s value. The value is converted to signed
45.377 + * decimal representation and returned as a string, exactly as if
45.378 + * the {@code short} value were given as an argument to the
45.379 + * {@link java.lang.Short#toString(short)} method.
45.380 + *
45.381 + * @return a string representation of the value of this object in
45.382 + * base 10.
45.383 + */
45.384 + public String toString() {
45.385 + return Integer.toString((int)value);
45.386 + }
45.387 +
45.388 + /**
45.389 + * Returns a hash code for this {@code Short}; equal to the result
45.390 + * of invoking {@code intValue()}.
45.391 + *
45.392 + * @return a hash code value for this {@code Short}
45.393 + */
45.394 + public int hashCode() {
45.395 + return (int)value;
45.396 + }
45.397 +
45.398 + /**
45.399 + * Compares this object to the specified object. The result is
45.400 + * {@code true} if and only if the argument is not
45.401 + * {@code null} and is a {@code Short} object that
45.402 + * contains the same {@code short} value as this object.
45.403 + *
45.404 + * @param obj the object to compare with
45.405 + * @return {@code true} if the objects are the same;
45.406 + * {@code false} otherwise.
45.407 + */
45.408 + public boolean equals(Object obj) {
45.409 + if (obj instanceof Short) {
45.410 + return value == ((Short)obj).shortValue();
45.411 + }
45.412 + return false;
45.413 + }
45.414 +
45.415 + /**
45.416 + * Compares two {@code Short} objects numerically.
45.417 + *
45.418 + * @param anotherShort the {@code Short} to be compared.
45.419 + * @return the value {@code 0} if this {@code Short} is
45.420 + * equal to the argument {@code Short}; a value less than
45.421 + * {@code 0} if this {@code Short} is numerically less
45.422 + * than the argument {@code Short}; and a value greater than
45.423 + * {@code 0} if this {@code Short} is numerically
45.424 + * greater than the argument {@code Short} (signed
45.425 + * comparison).
45.426 + * @since 1.2
45.427 + */
45.428 + public int compareTo(Short anotherShort) {
45.429 + return compare(this.value, anotherShort.value);
45.430 + }
45.431 +
45.432 + /**
45.433 + * Compares two {@code short} values numerically.
45.434 + * The value returned is identical to what would be returned by:
45.435 + * <pre>
45.436 + * Short.valueOf(x).compareTo(Short.valueOf(y))
45.437 + * </pre>
45.438 + *
45.439 + * @param x the first {@code short} to compare
45.440 + * @param y the second {@code short} to compare
45.441 + * @return the value {@code 0} if {@code x == y};
45.442 + * a value less than {@code 0} if {@code x < y}; and
45.443 + * a value greater than {@code 0} if {@code x > y}
45.444 + * @since 1.7
45.445 + */
45.446 + public static int compare(short x, short y) {
45.447 + return x - y;
45.448 + }
45.449 +
45.450 + /**
45.451 + * The number of bits used to represent a {@code short} value in two's
45.452 + * complement binary form.
45.453 + * @since 1.5
45.454 + */
45.455 + public static final int SIZE = 16;
45.456 +
45.457 + /**
45.458 + * Returns the value obtained by reversing the order of the bytes in the
45.459 + * two's complement representation of the specified {@code short} value.
45.460 + *
45.461 + * @return the value obtained by reversing (or, equivalently, swapping)
45.462 + * the bytes in the specified {@code short} value.
45.463 + * @since 1.5
45.464 + */
45.465 + public static short reverseBytes(short i) {
45.466 + return (short) (((i & 0xFF00) >> 8) | (i << 8));
45.467 + }
45.468 +
45.469 + /** use serialVersionUID from JDK 1.1. for interoperability */
45.470 + private static final long serialVersionUID = 7515723908773894738L;
45.471 +}
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
46.2 +++ b/emul/src/main/java/java/lang/StackTraceElement.java Thu Oct 11 06:16:00 2012 -0700
46.3 @@ -0,0 +1,223 @@
46.4 +/*
46.5 + * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
46.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
46.7 + *
46.8 + * This code is free software; you can redistribute it and/or modify it
46.9 + * under the terms of the GNU General Public License version 2 only, as
46.10 + * published by the Free Software Foundation. Oracle designates this
46.11 + * particular file as subject to the "Classpath" exception as provided
46.12 + * by Oracle in the LICENSE file that accompanied this code.
46.13 + *
46.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
46.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
46.17 + * version 2 for more details (a copy is included in the LICENSE file that
46.18 + * accompanied this code).
46.19 + *
46.20 + * You should have received a copy of the GNU General Public License version
46.21 + * 2 along with this work; if not, write to the Free Software Foundation,
46.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
46.23 + *
46.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
46.25 + * or visit www.oracle.com if you need additional information or have any
46.26 + * questions.
46.27 + */
46.28 +
46.29 +package java.lang;
46.30 +
46.31 +/**
46.32 + * An element in a stack trace, as returned by {@link
46.33 + * Throwable#getStackTrace()}. Each element represents a single stack frame.
46.34 + * All stack frames except for the one at the top of the stack represent
46.35 + * a method invocation. The frame at the top of the stack represents the
46.36 + * execution point at which the stack trace was generated. Typically,
46.37 + * this is the point at which the throwable corresponding to the stack trace
46.38 + * was created.
46.39 + *
46.40 + * @since 1.4
46.41 + * @author Josh Bloch
46.42 + */
46.43 +public final class StackTraceElement implements java.io.Serializable {
46.44 + // Normally initialized by VM (public constructor added in 1.5)
46.45 + private String declaringClass;
46.46 + private String methodName;
46.47 + private String fileName;
46.48 + private int lineNumber;
46.49 +
46.50 + /**
46.51 + * Creates a stack trace element representing the specified execution
46.52 + * point.
46.53 + *
46.54 + * @param declaringClass the fully qualified name of the class containing
46.55 + * the execution point represented by the stack trace element
46.56 + * @param methodName the name of the method containing the execution point
46.57 + * represented by the stack trace element
46.58 + * @param fileName the name of the file containing the execution point
46.59 + * represented by the stack trace element, or {@code null} if
46.60 + * this information is unavailable
46.61 + * @param lineNumber the line number of the source line containing the
46.62 + * execution point represented by this stack trace element, or
46.63 + * a negative number if this information is unavailable. A value
46.64 + * of -2 indicates that the method containing the execution point
46.65 + * is a native method
46.66 + * @throws NullPointerException if {@code declaringClass} or
46.67 + * {@code methodName} is null
46.68 + * @since 1.5
46.69 + */
46.70 + public StackTraceElement(String declaringClass, String methodName,
46.71 + String fileName, int lineNumber) {
46.72 + this.declaringClass = declaringClass;
46.73 + this.methodName = methodName;
46.74 + this.fileName = fileName;
46.75 + this.lineNumber = lineNumber;
46.76 + }
46.77 +
46.78 + /**
46.79 + * Returns the name of the source file containing the execution point
46.80 + * represented by this stack trace element. Generally, this corresponds
46.81 + * to the {@code SourceFile} attribute of the relevant {@code class}
46.82 + * file (as per <i>The Java Virtual Machine Specification</i>, Section
46.83 + * 4.7.7). In some systems, the name may refer to some source code unit
46.84 + * other than a file, such as an entry in source repository.
46.85 + *
46.86 + * @return the name of the file containing the execution point
46.87 + * represented by this stack trace element, or {@code null} if
46.88 + * this information is unavailable.
46.89 + */
46.90 + public String getFileName() {
46.91 + return fileName;
46.92 + }
46.93 +
46.94 + /**
46.95 + * Returns the line number of the source line containing the execution
46.96 + * point represented by this stack trace element. Generally, this is
46.97 + * derived from the {@code LineNumberTable} attribute of the relevant
46.98 + * {@code class} file (as per <i>The Java Virtual Machine
46.99 + * Specification</i>, Section 4.7.8).
46.100 + *
46.101 + * @return the line number of the source line containing the execution
46.102 + * point represented by this stack trace element, or a negative
46.103 + * number if this information is unavailable.
46.104 + */
46.105 + public int getLineNumber() {
46.106 + return lineNumber;
46.107 + }
46.108 +
46.109 + /**
46.110 + * Returns the fully qualified name of the class containing the
46.111 + * execution point represented by this stack trace element.
46.112 + *
46.113 + * @return the fully qualified name of the {@code Class} containing
46.114 + * the execution point represented by this stack trace element.
46.115 + */
46.116 + public String getClassName() {
46.117 + return declaringClass;
46.118 + }
46.119 +
46.120 + /**
46.121 + * Returns the name of the method containing the execution point
46.122 + * represented by this stack trace element. If the execution point is
46.123 + * contained in an instance or class initializer, this method will return
46.124 + * the appropriate <i>special method name</i>, {@code <init>} or
46.125 + * {@code <clinit>}, as per Section 3.9 of <i>The Java Virtual
46.126 + * Machine Specification</i>.
46.127 + *
46.128 + * @return the name of the method containing the execution point
46.129 + * represented by this stack trace element.
46.130 + */
46.131 + public String getMethodName() {
46.132 + return methodName;
46.133 + }
46.134 +
46.135 + /**
46.136 + * Returns true if the method containing the execution point
46.137 + * represented by this stack trace element is a native method.
46.138 + *
46.139 + * @return {@code true} if the method containing the execution point
46.140 + * represented by this stack trace element is a native method.
46.141 + */
46.142 + public boolean isNativeMethod() {
46.143 + return lineNumber == -2;
46.144 + }
46.145 +
46.146 + /**
46.147 + * Returns a string representation of this stack trace element. The
46.148 + * format of this string depends on the implementation, but the following
46.149 + * examples may be regarded as typical:
46.150 + * <ul>
46.151 + * <li>
46.152 + * {@code "MyClass.mash(MyClass.java:9)"} - Here, {@code "MyClass"}
46.153 + * is the <i>fully-qualified name</i> of the class containing the
46.154 + * execution point represented by this stack trace element,
46.155 + * {@code "mash"} is the name of the method containing the execution
46.156 + * point, {@code "MyClass.java"} is the source file containing the
46.157 + * execution point, and {@code "9"} is the line number of the source
46.158 + * line containing the execution point.
46.159 + * <li>
46.160 + * {@code "MyClass.mash(MyClass.java)"} - As above, but the line
46.161 + * number is unavailable.
46.162 + * <li>
46.163 + * {@code "MyClass.mash(Unknown Source)"} - As above, but neither
46.164 + * the file name nor the line number are available.
46.165 + * <li>
46.166 + * {@code "MyClass.mash(Native Method)"} - As above, but neither
46.167 + * the file name nor the line number are available, and the method
46.168 + * containing the execution point is known to be a native method.
46.169 + * </ul>
46.170 + * @see Throwable#printStackTrace()
46.171 + */
46.172 + public String toString() {
46.173 + return getClassName() + "." + methodName +
46.174 + (isNativeMethod() ? "(Native Method)" :
46.175 + (fileName != null && lineNumber >= 0 ?
46.176 + "(" + fileName + ":" + lineNumber + ")" :
46.177 + (fileName != null ? "("+fileName+")" : "(Unknown Source)")));
46.178 + }
46.179 +
46.180 + /**
46.181 + * Returns true if the specified object is another
46.182 + * {@code StackTraceElement} instance representing the same execution
46.183 + * point as this instance. Two stack trace elements {@code a} and
46.184 + * {@code b} are equal if and only if:
46.185 + * <pre>
46.186 + * equals(a.getFileName(), b.getFileName()) &&
46.187 + * a.getLineNumber() == b.getLineNumber()) &&
46.188 + * equals(a.getClassName(), b.getClassName()) &&
46.189 + * equals(a.getMethodName(), b.getMethodName())
46.190 + * </pre>
46.191 + * where {@code equals} has the semantics of {@link
46.192 + * java.util.Objects#equals(Object, Object) Objects.equals}.
46.193 + *
46.194 + * @param obj the object to be compared with this stack trace element.
46.195 + * @return true if the specified object is another
46.196 + * {@code StackTraceElement} instance representing the same
46.197 + * execution point as this instance.
46.198 + */
46.199 + public boolean equals(Object obj) {
46.200 + if (obj==this)
46.201 + return true;
46.202 + if (!(obj instanceof StackTraceElement))
46.203 + return false;
46.204 + StackTraceElement e = (StackTraceElement)obj;
46.205 + return e.declaringClass.equals(declaringClass) &&
46.206 + e.lineNumber == lineNumber &&
46.207 + equals(methodName, e.methodName) &&
46.208 + equals(fileName, e.fileName);
46.209 + }
46.210 +
46.211 + /**
46.212 + * Returns a hash code value for this stack trace element.
46.213 + */
46.214 + public int hashCode() {
46.215 + int result = 31*declaringClass.hashCode() + methodName.hashCode();
46.216 + result = 31*result + (fileName == null ? 0 : fileName.hashCode());
46.217 + result = 31*result + lineNumber;
46.218 + return result;
46.219 + }
46.220 +
46.221 + private static boolean equals(Object a, Object b) {
46.222 + return (a == b) || (a != null && a.equals(b));
46.223 + }
46.224 +
46.225 + private static final long serialVersionUID = 6992337162326171013L;
46.226 +}
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
47.2 +++ b/emul/src/main/java/java/lang/StrictMath.java Thu Oct 11 06:16:00 2012 -0700
47.3 @@ -0,0 +1,1457 @@
47.4 +/*
47.5 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
47.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
47.7 + *
47.8 + * This code is free software; you can redistribute it and/or modify it
47.9 + * under the terms of the GNU General Public License version 2 only, as
47.10 + * published by the Free Software Foundation. Oracle designates this
47.11 + * particular file as subject to the "Classpath" exception as provided
47.12 + * by Oracle in the LICENSE file that accompanied this code.
47.13 + *
47.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
47.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
47.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
47.17 + * version 2 for more details (a copy is included in the LICENSE file that
47.18 + * accompanied this code).
47.19 + *
47.20 + * You should have received a copy of the GNU General Public License version
47.21 + * 2 along with this work; if not, write to the Free Software Foundation,
47.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
47.23 + *
47.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
47.25 + * or visit www.oracle.com if you need additional information or have any
47.26 + * questions.
47.27 + */
47.28 +
47.29 +package java.lang;
47.30 +
47.31 +/**
47.32 + * The class {@code StrictMath} contains methods for performing basic
47.33 + * numeric operations such as the elementary exponential, logarithm,
47.34 + * square root, and trigonometric functions.
47.35 + *
47.36 + * <p>To help ensure portability of Java programs, the definitions of
47.37 + * some of the numeric functions in this package require that they
47.38 + * produce the same results as certain published algorithms. These
47.39 + * algorithms are available from the well-known network library
47.40 + * {@code netlib} as the package "Freely Distributable Math
47.41 + * Library," <a
47.42 + * href="ftp://ftp.netlib.org/fdlibm.tar">{@code fdlibm}</a>. These
47.43 + * algorithms, which are written in the C programming language, are
47.44 + * then to be understood as executed with all floating-point
47.45 + * operations following the rules of Java floating-point arithmetic.
47.46 + *
47.47 + * <p>The Java math library is defined with respect to
47.48 + * {@code fdlibm} version 5.3. Where {@code fdlibm} provides
47.49 + * more than one definition for a function (such as
47.50 + * {@code acos}), use the "IEEE 754 core function" version
47.51 + * (residing in a file whose name begins with the letter
47.52 + * {@code e}). The methods which require {@code fdlibm}
47.53 + * semantics are {@code sin}, {@code cos}, {@code tan},
47.54 + * {@code asin}, {@code acos}, {@code atan},
47.55 + * {@code exp}, {@code log}, {@code log10},
47.56 + * {@code cbrt}, {@code atan2}, {@code pow},
47.57 + * {@code sinh}, {@code cosh}, {@code tanh},
47.58 + * {@code hypot}, {@code expm1}, and {@code log1p}.
47.59 + *
47.60 + * @author unascribed
47.61 + * @author Joseph D. Darcy
47.62 + * @since 1.3
47.63 + */
47.64 +
47.65 +public final class StrictMath {
47.66 +
47.67 + /**
47.68 + * Don't let anyone instantiate this class.
47.69 + */
47.70 + private StrictMath() {}
47.71 +
47.72 + /**
47.73 + * The {@code double} value that is closer than any other to
47.74 + * <i>e</i>, the base of the natural logarithms.
47.75 + */
47.76 + public static final double E = 2.7182818284590452354;
47.77 +
47.78 + /**
47.79 + * The {@code double} value that is closer than any other to
47.80 + * <i>pi</i>, the ratio of the circumference of a circle to its
47.81 + * diameter.
47.82 + */
47.83 + public static final double PI = 3.14159265358979323846;
47.84 +
47.85 + /**
47.86 + * Returns the trigonometric sine of an angle. Special cases:
47.87 + * <ul><li>If the argument is NaN or an infinity, then the
47.88 + * result is NaN.
47.89 + * <li>If the argument is zero, then the result is a zero with the
47.90 + * same sign as the argument.</ul>
47.91 + *
47.92 + * @param a an angle, in radians.
47.93 + * @return the sine of the argument.
47.94 + */
47.95 + public static native double sin(double a);
47.96 +
47.97 + /**
47.98 + * Returns the trigonometric cosine of an angle. Special cases:
47.99 + * <ul><li>If the argument is NaN or an infinity, then the
47.100 + * result is NaN.</ul>
47.101 + *
47.102 + * @param a an angle, in radians.
47.103 + * @return the cosine of the argument.
47.104 + */
47.105 + public static native double cos(double a);
47.106 +
47.107 + /**
47.108 + * Returns the trigonometric tangent of an angle. Special cases:
47.109 + * <ul><li>If the argument is NaN or an infinity, then the result
47.110 + * is NaN.
47.111 + * <li>If the argument is zero, then the result is a zero with the
47.112 + * same sign as the argument.</ul>
47.113 + *
47.114 + * @param a an angle, in radians.
47.115 + * @return the tangent of the argument.
47.116 + */
47.117 + public static native double tan(double a);
47.118 +
47.119 + /**
47.120 + * Returns the arc sine of a value; the returned angle is in the
47.121 + * range -<i>pi</i>/2 through <i>pi</i>/2. Special cases:
47.122 + * <ul><li>If the argument is NaN or its absolute value is greater
47.123 + * than 1, then the result is NaN.
47.124 + * <li>If the argument is zero, then the result is a zero with the
47.125 + * same sign as the argument.</ul>
47.126 + *
47.127 + * @param a the value whose arc sine is to be returned.
47.128 + * @return the arc sine of the argument.
47.129 + */
47.130 + public static native double asin(double a);
47.131 +
47.132 + /**
47.133 + * Returns the arc cosine of a value; the returned angle is in the
47.134 + * range 0.0 through <i>pi</i>. Special case:
47.135 + * <ul><li>If the argument is NaN or its absolute value is greater
47.136 + * than 1, then the result is NaN.</ul>
47.137 + *
47.138 + * @param a the value whose arc cosine is to be returned.
47.139 + * @return the arc cosine of the argument.
47.140 + */
47.141 + public static native double acos(double a);
47.142 +
47.143 + /**
47.144 + * Returns the arc tangent of a value; the returned angle is in the
47.145 + * range -<i>pi</i>/2 through <i>pi</i>/2. Special cases:
47.146 + * <ul><li>If the argument is NaN, then the result is NaN.
47.147 + * <li>If the argument is zero, then the result is a zero with the
47.148 + * same sign as the argument.</ul>
47.149 + *
47.150 + * @param a the value whose arc tangent is to be returned.
47.151 + * @return the arc tangent of the argument.
47.152 + */
47.153 + public static native double atan(double a);
47.154 +
47.155 + /**
47.156 + * Converts an angle measured in degrees to an approximately
47.157 + * equivalent angle measured in radians. The conversion from
47.158 + * degrees to radians is generally inexact.
47.159 + *
47.160 + * @param angdeg an angle, in degrees
47.161 + * @return the measurement of the angle {@code angdeg}
47.162 + * in radians.
47.163 + */
47.164 + public static strictfp double toRadians(double angdeg) {
47.165 + return angdeg / 180.0 * PI;
47.166 + }
47.167 +
47.168 + /**
47.169 + * Converts an angle measured in radians to an approximately
47.170 + * equivalent angle measured in degrees. The conversion from
47.171 + * radians to degrees is generally inexact; users should
47.172 + * <i>not</i> expect {@code cos(toRadians(90.0))} to exactly
47.173 + * equal {@code 0.0}.
47.174 + *
47.175 + * @param angrad an angle, in radians
47.176 + * @return the measurement of the angle {@code angrad}
47.177 + * in degrees.
47.178 + */
47.179 + public static strictfp double toDegrees(double angrad) {
47.180 + return angrad * 180.0 / PI;
47.181 + }
47.182 +
47.183 + /**
47.184 + * Returns Euler's number <i>e</i> raised to the power of a
47.185 + * {@code double} value. Special cases:
47.186 + * <ul><li>If the argument is NaN, the result is NaN.
47.187 + * <li>If the argument is positive infinity, then the result is
47.188 + * positive infinity.
47.189 + * <li>If the argument is negative infinity, then the result is
47.190 + * positive zero.</ul>
47.191 + *
47.192 + * @param a the exponent to raise <i>e</i> to.
47.193 + * @return the value <i>e</i><sup>{@code a}</sup>,
47.194 + * where <i>e</i> is the base of the natural logarithms.
47.195 + */
47.196 + public static native double exp(double a);
47.197 +
47.198 + /**
47.199 + * Returns the natural logarithm (base <i>e</i>) of a {@code double}
47.200 + * value. Special cases:
47.201 + * <ul><li>If the argument is NaN or less than zero, then the result
47.202 + * is NaN.
47.203 + * <li>If the argument is positive infinity, then the result is
47.204 + * positive infinity.
47.205 + * <li>If the argument is positive zero or negative zero, then the
47.206 + * result is negative infinity.</ul>
47.207 + *
47.208 + * @param a a value
47.209 + * @return the value ln {@code a}, the natural logarithm of
47.210 + * {@code a}.
47.211 + */
47.212 + public static native double log(double a);
47.213 +
47.214 +
47.215 + /**
47.216 + * Returns the base 10 logarithm of a {@code double} value.
47.217 + * Special cases:
47.218 + *
47.219 + * <ul><li>If the argument is NaN or less than zero, then the result
47.220 + * is NaN.
47.221 + * <li>If the argument is positive infinity, then the result is
47.222 + * positive infinity.
47.223 + * <li>If the argument is positive zero or negative zero, then the
47.224 + * result is negative infinity.
47.225 + * <li> If the argument is equal to 10<sup><i>n</i></sup> for
47.226 + * integer <i>n</i>, then the result is <i>n</i>.
47.227 + * </ul>
47.228 + *
47.229 + * @param a a value
47.230 + * @return the base 10 logarithm of {@code a}.
47.231 + * @since 1.5
47.232 + */
47.233 + public static native double log10(double a);
47.234 +
47.235 + /**
47.236 + * Returns the correctly rounded positive square root of a
47.237 + * {@code double} value.
47.238 + * Special cases:
47.239 + * <ul><li>If the argument is NaN or less than zero, then the result
47.240 + * is NaN.
47.241 + * <li>If the argument is positive infinity, then the result is positive
47.242 + * infinity.
47.243 + * <li>If the argument is positive zero or negative zero, then the
47.244 + * result is the same as the argument.</ul>
47.245 + * Otherwise, the result is the {@code double} value closest to
47.246 + * the true mathematical square root of the argument value.
47.247 + *
47.248 + * @param a a value.
47.249 + * @return the positive square root of {@code a}.
47.250 + */
47.251 + public static native double sqrt(double a);
47.252 +
47.253 + /**
47.254 + * Returns the cube root of a {@code double} value. For
47.255 + * positive finite {@code x}, {@code cbrt(-x) ==
47.256 + * -cbrt(x)}; that is, the cube root of a negative value is
47.257 + * the negative of the cube root of that value's magnitude.
47.258 + * Special cases:
47.259 + *
47.260 + * <ul>
47.261 + *
47.262 + * <li>If the argument is NaN, then the result is NaN.
47.263 + *
47.264 + * <li>If the argument is infinite, then the result is an infinity
47.265 + * with the same sign as the argument.
47.266 + *
47.267 + * <li>If the argument is zero, then the result is a zero with the
47.268 + * same sign as the argument.
47.269 + *
47.270 + * </ul>
47.271 + *
47.272 + * @param a a value.
47.273 + * @return the cube root of {@code a}.
47.274 + * @since 1.5
47.275 + */
47.276 + public static native double cbrt(double a);
47.277 +
47.278 + /**
47.279 + * Computes the remainder operation on two arguments as prescribed
47.280 + * by the IEEE 754 standard.
47.281 + * The remainder value is mathematically equal to
47.282 + * <code>f1 - f2</code> × <i>n</i>,
47.283 + * where <i>n</i> is the mathematical integer closest to the exact
47.284 + * mathematical value of the quotient {@code f1/f2}, and if two
47.285 + * mathematical integers are equally close to {@code f1/f2},
47.286 + * then <i>n</i> is the integer that is even. If the remainder is
47.287 + * zero, its sign is the same as the sign of the first argument.
47.288 + * Special cases:
47.289 + * <ul><li>If either argument is NaN, or the first argument is infinite,
47.290 + * or the second argument is positive zero or negative zero, then the
47.291 + * result is NaN.
47.292 + * <li>If the first argument is finite and the second argument is
47.293 + * infinite, then the result is the same as the first argument.</ul>
47.294 + *
47.295 + * @param f1 the dividend.
47.296 + * @param f2 the divisor.
47.297 + * @return the remainder when {@code f1} is divided by
47.298 + * {@code f2}.
47.299 + */
47.300 + public static native double IEEEremainder(double f1, double f2);
47.301 +
47.302 + /**
47.303 + * Returns the smallest (closest to negative infinity)
47.304 + * {@code double} value that is greater than or equal to the
47.305 + * argument and is equal to a mathematical integer. Special cases:
47.306 + * <ul><li>If the argument value is already equal to a
47.307 + * mathematical integer, then the result is the same as the
47.308 + * argument. <li>If the argument is NaN or an infinity or
47.309 + * positive zero or negative zero, then the result is the same as
47.310 + * the argument. <li>If the argument value is less than zero but
47.311 + * greater than -1.0, then the result is negative zero.</ul> Note
47.312 + * that the value of {@code StrictMath.ceil(x)} is exactly the
47.313 + * value of {@code -StrictMath.floor(-x)}.
47.314 + *
47.315 + * @param a a value.
47.316 + * @return the smallest (closest to negative infinity)
47.317 + * floating-point value that is greater than or equal to
47.318 + * the argument and is equal to a mathematical integer.
47.319 + */
47.320 + public static double ceil(double a) {
47.321 + return floorOrCeil(a, -0.0, 1.0, 1.0);
47.322 + }
47.323 +
47.324 + /**
47.325 + * Returns the largest (closest to positive infinity)
47.326 + * {@code double} value that is less than or equal to the
47.327 + * argument and is equal to a mathematical integer. Special cases:
47.328 + * <ul><li>If the argument value is already equal to a
47.329 + * mathematical integer, then the result is the same as the
47.330 + * argument. <li>If the argument is NaN or an infinity or
47.331 + * positive zero or negative zero, then the result is the same as
47.332 + * the argument.</ul>
47.333 + *
47.334 + * @param a a value.
47.335 + * @return the largest (closest to positive infinity)
47.336 + * floating-point value that less than or equal to the argument
47.337 + * and is equal to a mathematical integer.
47.338 + */
47.339 + public static double floor(double a) {
47.340 + return floorOrCeil(a, -1.0, 0.0, -1.0);
47.341 + }
47.342 +
47.343 + /**
47.344 + * Internal method to share logic between floor and ceil.
47.345 + *
47.346 + * @param a the value to be floored or ceiled
47.347 + * @param negativeBoundary result for values in (-1, 0)
47.348 + * @param positiveBoundary result for values in (0, 1)
47.349 + * @param increment value to add when the argument is non-integral
47.350 + */
47.351 + private static double floorOrCeil(double a,
47.352 + double negativeBoundary,
47.353 + double positiveBoundary,
47.354 + double sign) {
47.355 + int exponent = getExponent(a);
47.356 +
47.357 + if (exponent < 0) {
47.358 + /*
47.359 + * Absolute value of argument is less than 1.
47.360 + * floorOrceil(-0.0) => -0.0
47.361 + * floorOrceil(+0.0) => +0.0
47.362 + */
47.363 + return ((a == 0.0) ? a :
47.364 + ( (a < 0.0) ? negativeBoundary : positiveBoundary) );
47.365 + } else if (exponent >= 52) {
47.366 + /*
47.367 + * Infinity, NaN, or a value so large it must be integral.
47.368 + */
47.369 + return a;
47.370 + }
47.371 + // Else the argument is either an integral value already XOR it
47.372 + // has to be rounded to one.
47.373 + assert exponent >= 0 && exponent <= 51;
47.374 +
47.375 + long doppel = Double.doubleToRawLongBits(a);
47.376 + long mask = 0; // DoubleConsts.SIGNIF_BIT_MASK >> exponent;
47.377 +
47.378 + if ( (mask & doppel) == 0L )
47.379 + return a; // integral value
47.380 + else {
47.381 + double result = Double.longBitsToDouble(doppel & (~mask));
47.382 + if (sign*a > 0.0)
47.383 + result = result + sign;
47.384 + return result;
47.385 + }
47.386 + }
47.387 +
47.388 + /**
47.389 + * Returns the {@code double} value that is closest in value
47.390 + * to the argument and is equal to a mathematical integer. If two
47.391 + * {@code double} values that are mathematical integers are
47.392 + * equally close to the value of the argument, the result is the
47.393 + * integer value that is even. Special cases:
47.394 + * <ul><li>If the argument value is already equal to a mathematical
47.395 + * integer, then the result is the same as the argument.
47.396 + * <li>If the argument is NaN or an infinity or positive zero or negative
47.397 + * zero, then the result is the same as the argument.</ul>
47.398 + *
47.399 + * @param a a value.
47.400 + * @return the closest floating-point value to {@code a} that is
47.401 + * equal to a mathematical integer.
47.402 + * @author Joseph D. Darcy
47.403 + */
47.404 + public static double rint(double a) {
47.405 + throw new UnsupportedOperationException();
47.406 + /*
47.407 + * If the absolute value of a is not less than 2^52, it
47.408 + * is either a finite integer (the double format does not have
47.409 + * enough significand bits for a number that large to have any
47.410 + * fractional portion), an infinity, or a NaN. In any of
47.411 + * these cases, rint of the argument is the argument.
47.412 + *
47.413 + * Otherwise, the sum (twoToThe52 + a ) will properly round
47.414 + * away any fractional portion of a since ulp(twoToThe52) ==
47.415 + * 1.0; subtracting out twoToThe52 from this sum will then be
47.416 + * exact and leave the rounded integer portion of a.
47.417 + *
47.418 + * This method does *not* need to be declared strictfp to get
47.419 + * fully reproducible results. Whether or not a method is
47.420 + * declared strictfp can only make a difference in the
47.421 + * returned result if some operation would overflow or
47.422 + * underflow with strictfp semantics. The operation
47.423 + * (twoToThe52 + a ) cannot overflow since large values of a
47.424 + * are screened out; the add cannot underflow since twoToThe52
47.425 + * is too large. The subtraction ((twoToThe52 + a ) -
47.426 + * twoToThe52) will be exact as discussed above and thus
47.427 + * cannot overflow or meaningfully underflow. Finally, the
47.428 + * last multiply in the return statement is by plus or minus
47.429 + * 1.0, which is exact too.
47.430 + */
47.431 +// double twoToThe52 = (double)(1L << 52); // 2^52
47.432 +// double sign = FpUtils.rawCopySign(1.0, a); // preserve sign info
47.433 +// a = Math.abs(a);
47.434 +//
47.435 +// if (a < twoToThe52) { // E_min <= ilogb(a) <= 51
47.436 +// a = ((twoToThe52 + a ) - twoToThe52);
47.437 +// }
47.438 +//
47.439 +// return sign * a; // restore original sign
47.440 + }
47.441 +
47.442 + /**
47.443 + * Returns the angle <i>theta</i> from the conversion of rectangular
47.444 + * coordinates ({@code x}, {@code y}) to polar
47.445 + * coordinates (r, <i>theta</i>).
47.446 + * This method computes the phase <i>theta</i> by computing an arc tangent
47.447 + * of {@code y/x} in the range of -<i>pi</i> to <i>pi</i>. Special
47.448 + * cases:
47.449 + * <ul><li>If either argument is NaN, then the result is NaN.
47.450 + * <li>If the first argument is positive zero and the second argument
47.451 + * is positive, or the first argument is positive and finite and the
47.452 + * second argument is positive infinity, then the result is positive
47.453 + * zero.
47.454 + * <li>If the first argument is negative zero and the second argument
47.455 + * is positive, or the first argument is negative and finite and the
47.456 + * second argument is positive infinity, then the result is negative zero.
47.457 + * <li>If the first argument is positive zero and the second argument
47.458 + * is negative, or the first argument is positive and finite and the
47.459 + * second argument is negative infinity, then the result is the
47.460 + * {@code double} value closest to <i>pi</i>.
47.461 + * <li>If the first argument is negative zero and the second argument
47.462 + * is negative, or the first argument is negative and finite and the
47.463 + * second argument is negative infinity, then the result is the
47.464 + * {@code double} value closest to -<i>pi</i>.
47.465 + * <li>If the first argument is positive and the second argument is
47.466 + * positive zero or negative zero, or the first argument is positive
47.467 + * infinity and the second argument is finite, then the result is the
47.468 + * {@code double} value closest to <i>pi</i>/2.
47.469 + * <li>If the first argument is negative and the second argument is
47.470 + * positive zero or negative zero, or the first argument is negative
47.471 + * infinity and the second argument is finite, then the result is the
47.472 + * {@code double} value closest to -<i>pi</i>/2.
47.473 + * <li>If both arguments are positive infinity, then the result is the
47.474 + * {@code double} value closest to <i>pi</i>/4.
47.475 + * <li>If the first argument is positive infinity and the second argument
47.476 + * is negative infinity, then the result is the {@code double}
47.477 + * value closest to 3*<i>pi</i>/4.
47.478 + * <li>If the first argument is negative infinity and the second argument
47.479 + * is positive infinity, then the result is the {@code double} value
47.480 + * closest to -<i>pi</i>/4.
47.481 + * <li>If both arguments are negative infinity, then the result is the
47.482 + * {@code double} value closest to -3*<i>pi</i>/4.</ul>
47.483 + *
47.484 + * @param y the ordinate coordinate
47.485 + * @param x the abscissa coordinate
47.486 + * @return the <i>theta</i> component of the point
47.487 + * (<i>r</i>, <i>theta</i>)
47.488 + * in polar coordinates that corresponds to the point
47.489 + * (<i>x</i>, <i>y</i>) in Cartesian coordinates.
47.490 + */
47.491 + public static native double atan2(double y, double x);
47.492 +
47.493 +
47.494 + /**
47.495 + * Returns the value of the first argument raised to the power of the
47.496 + * second argument. Special cases:
47.497 + *
47.498 + * <ul><li>If the second argument is positive or negative zero, then the
47.499 + * result is 1.0.
47.500 + * <li>If the second argument is 1.0, then the result is the same as the
47.501 + * first argument.
47.502 + * <li>If the second argument is NaN, then the result is NaN.
47.503 + * <li>If the first argument is NaN and the second argument is nonzero,
47.504 + * then the result is NaN.
47.505 + *
47.506 + * <li>If
47.507 + * <ul>
47.508 + * <li>the absolute value of the first argument is greater than 1
47.509 + * and the second argument is positive infinity, or
47.510 + * <li>the absolute value of the first argument is less than 1 and
47.511 + * the second argument is negative infinity,
47.512 + * </ul>
47.513 + * then the result is positive infinity.
47.514 + *
47.515 + * <li>If
47.516 + * <ul>
47.517 + * <li>the absolute value of the first argument is greater than 1 and
47.518 + * the second argument is negative infinity, or
47.519 + * <li>the absolute value of the
47.520 + * first argument is less than 1 and the second argument is positive
47.521 + * infinity,
47.522 + * </ul>
47.523 + * then the result is positive zero.
47.524 + *
47.525 + * <li>If the absolute value of the first argument equals 1 and the
47.526 + * second argument is infinite, then the result is NaN.
47.527 + *
47.528 + * <li>If
47.529 + * <ul>
47.530 + * <li>the first argument is positive zero and the second argument
47.531 + * is greater than zero, or
47.532 + * <li>the first argument is positive infinity and the second
47.533 + * argument is less than zero,
47.534 + * </ul>
47.535 + * then the result is positive zero.
47.536 + *
47.537 + * <li>If
47.538 + * <ul>
47.539 + * <li>the first argument is positive zero and the second argument
47.540 + * is less than zero, or
47.541 + * <li>the first argument is positive infinity and the second
47.542 + * argument is greater than zero,
47.543 + * </ul>
47.544 + * then the result is positive infinity.
47.545 + *
47.546 + * <li>If
47.547 + * <ul>
47.548 + * <li>the first argument is negative zero and the second argument
47.549 + * is greater than zero but not a finite odd integer, or
47.550 + * <li>the first argument is negative infinity and the second
47.551 + * argument is less than zero but not a finite odd integer,
47.552 + * </ul>
47.553 + * then the result is positive zero.
47.554 + *
47.555 + * <li>If
47.556 + * <ul>
47.557 + * <li>the first argument is negative zero and the second argument
47.558 + * is a positive finite odd integer, or
47.559 + * <li>the first argument is negative infinity and the second
47.560 + * argument is a negative finite odd integer,
47.561 + * </ul>
47.562 + * then the result is negative zero.
47.563 + *
47.564 + * <li>If
47.565 + * <ul>
47.566 + * <li>the first argument is negative zero and the second argument
47.567 + * is less than zero but not a finite odd integer, or
47.568 + * <li>the first argument is negative infinity and the second
47.569 + * argument is greater than zero but not a finite odd integer,
47.570 + * </ul>
47.571 + * then the result is positive infinity.
47.572 + *
47.573 + * <li>If
47.574 + * <ul>
47.575 + * <li>the first argument is negative zero and the second argument
47.576 + * is a negative finite odd integer, or
47.577 + * <li>the first argument is negative infinity and the second
47.578 + * argument is a positive finite odd integer,
47.579 + * </ul>
47.580 + * then the result is negative infinity.
47.581 + *
47.582 + * <li>If the first argument is finite and less than zero
47.583 + * <ul>
47.584 + * <li> if the second argument is a finite even integer, the
47.585 + * result is equal to the result of raising the absolute value of
47.586 + * the first argument to the power of the second argument
47.587 + *
47.588 + * <li>if the second argument is a finite odd integer, the result
47.589 + * is equal to the negative of the result of raising the absolute
47.590 + * value of the first argument to the power of the second
47.591 + * argument
47.592 + *
47.593 + * <li>if the second argument is finite and not an integer, then
47.594 + * the result is NaN.
47.595 + * </ul>
47.596 + *
47.597 + * <li>If both arguments are integers, then the result is exactly equal
47.598 + * to the mathematical result of raising the first argument to the power
47.599 + * of the second argument if that result can in fact be represented
47.600 + * exactly as a {@code double} value.</ul>
47.601 + *
47.602 + * <p>(In the foregoing descriptions, a floating-point value is
47.603 + * considered to be an integer if and only if it is finite and a
47.604 + * fixed point of the method {@link #ceil ceil} or,
47.605 + * equivalently, a fixed point of the method {@link #floor
47.606 + * floor}. A value is a fixed point of a one-argument
47.607 + * method if and only if the result of applying the method to the
47.608 + * value is equal to the value.)
47.609 + *
47.610 + * @param a base.
47.611 + * @param b the exponent.
47.612 + * @return the value {@code a}<sup>{@code b}</sup>.
47.613 + */
47.614 + public static native double pow(double a, double b);
47.615 +
47.616 + /**
47.617 + * Returns the closest {@code int} to the argument, with ties
47.618 + * rounding up.
47.619 + *
47.620 + * <p>Special cases:
47.621 + * <ul><li>If the argument is NaN, the result is 0.
47.622 + * <li>If the argument is negative infinity or any value less than or
47.623 + * equal to the value of {@code Integer.MIN_VALUE}, the result is
47.624 + * equal to the value of {@code Integer.MIN_VALUE}.
47.625 + * <li>If the argument is positive infinity or any value greater than or
47.626 + * equal to the value of {@code Integer.MAX_VALUE}, the result is
47.627 + * equal to the value of {@code Integer.MAX_VALUE}.</ul>
47.628 + *
47.629 + * @param a a floating-point value to be rounded to an integer.
47.630 + * @return the value of the argument rounded to the nearest
47.631 + * {@code int} value.
47.632 + * @see java.lang.Integer#MAX_VALUE
47.633 + * @see java.lang.Integer#MIN_VALUE
47.634 + */
47.635 + public static int round(float a) {
47.636 + return Math.round(a);
47.637 + }
47.638 +
47.639 + /**
47.640 + * Returns the closest {@code long} to the argument, with ties
47.641 + * rounding up.
47.642 + *
47.643 + * <p>Special cases:
47.644 + * <ul><li>If the argument is NaN, the result is 0.
47.645 + * <li>If the argument is negative infinity or any value less than or
47.646 + * equal to the value of {@code Long.MIN_VALUE}, the result is
47.647 + * equal to the value of {@code Long.MIN_VALUE}.
47.648 + * <li>If the argument is positive infinity or any value greater than or
47.649 + * equal to the value of {@code Long.MAX_VALUE}, the result is
47.650 + * equal to the value of {@code Long.MAX_VALUE}.</ul>
47.651 + *
47.652 + * @param a a floating-point value to be rounded to a
47.653 + * {@code long}.
47.654 + * @return the value of the argument rounded to the nearest
47.655 + * {@code long} value.
47.656 + * @see java.lang.Long#MAX_VALUE
47.657 + * @see java.lang.Long#MIN_VALUE
47.658 + */
47.659 + public static long round(double a) {
47.660 + return Math.round(a);
47.661 + }
47.662 +
47.663 + /**
47.664 + * Returns a {@code double} value with a positive sign, greater
47.665 + * than or equal to {@code 0.0} and less than {@code 1.0}.
47.666 + * Returned values are chosen pseudorandomly with (approximately)
47.667 + * uniform distribution from that range.
47.668 + *
47.669 + * <p>When this method is first called, it creates a single new
47.670 + * pseudorandom-number generator, exactly as if by the expression
47.671 + *
47.672 + * <blockquote>{@code new java.util.Random()}</blockquote>
47.673 + *
47.674 + * This new pseudorandom-number generator is used thereafter for
47.675 + * all calls to this method and is used nowhere else.
47.676 + *
47.677 + * <p>This method is properly synchronized to allow correct use by
47.678 + * more than one thread. However, if many threads need to generate
47.679 + * pseudorandom numbers at a great rate, it may reduce contention
47.680 + * for each thread to have its own pseudorandom number generator.
47.681 + *
47.682 + * @return a pseudorandom {@code double} greater than or equal
47.683 + * to {@code 0.0} and less than {@code 1.0}.
47.684 + * @see Random#nextDouble()
47.685 + */
47.686 + public static double random() {
47.687 + throw new UnsupportedOperationException();
47.688 + }
47.689 +
47.690 + /**
47.691 + * Returns the absolute value of an {@code int} value..
47.692 + * If the argument is not negative, the argument is returned.
47.693 + * If the argument is negative, the negation of the argument is returned.
47.694 + *
47.695 + * <p>Note that if the argument is equal to the value of
47.696 + * {@link Integer#MIN_VALUE}, the most negative representable
47.697 + * {@code int} value, the result is that same value, which is
47.698 + * negative.
47.699 + *
47.700 + * @param a the argument whose absolute value is to be determined.
47.701 + * @return the absolute value of the argument.
47.702 + */
47.703 + public static int abs(int a) {
47.704 + return (a < 0) ? -a : a;
47.705 + }
47.706 +
47.707 + /**
47.708 + * Returns the absolute value of a {@code long} value.
47.709 + * If the argument is not negative, the argument is returned.
47.710 + * If the argument is negative, the negation of the argument is returned.
47.711 + *
47.712 + * <p>Note that if the argument is equal to the value of
47.713 + * {@link Long#MIN_VALUE}, the most negative representable
47.714 + * {@code long} value, the result is that same value, which
47.715 + * is negative.
47.716 + *
47.717 + * @param a the argument whose absolute value is to be determined.
47.718 + * @return the absolute value of the argument.
47.719 + */
47.720 + public static long abs(long a) {
47.721 + return (a < 0) ? -a : a;
47.722 + }
47.723 +
47.724 + /**
47.725 + * Returns the absolute value of a {@code float} value.
47.726 + * If the argument is not negative, the argument is returned.
47.727 + * If the argument is negative, the negation of the argument is returned.
47.728 + * Special cases:
47.729 + * <ul><li>If the argument is positive zero or negative zero, the
47.730 + * result is positive zero.
47.731 + * <li>If the argument is infinite, the result is positive infinity.
47.732 + * <li>If the argument is NaN, the result is NaN.</ul>
47.733 + * In other words, the result is the same as the value of the expression:
47.734 + * <p>{@code Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))}
47.735 + *
47.736 + * @param a the argument whose absolute value is to be determined
47.737 + * @return the absolute value of the argument.
47.738 + */
47.739 + public static float abs(float a) {
47.740 + return (a <= 0.0F) ? 0.0F - a : a;
47.741 + }
47.742 +
47.743 + /**
47.744 + * Returns the absolute value of a {@code double} value.
47.745 + * If the argument is not negative, the argument is returned.
47.746 + * If the argument is negative, the negation of the argument is returned.
47.747 + * Special cases:
47.748 + * <ul><li>If the argument is positive zero or negative zero, the result
47.749 + * is positive zero.
47.750 + * <li>If the argument is infinite, the result is positive infinity.
47.751 + * <li>If the argument is NaN, the result is NaN.</ul>
47.752 + * In other words, the result is the same as the value of the expression:
47.753 + * <p>{@code Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)}
47.754 + *
47.755 + * @param a the argument whose absolute value is to be determined
47.756 + * @return the absolute value of the argument.
47.757 + */
47.758 + public static double abs(double a) {
47.759 + return (a <= 0.0D) ? 0.0D - a : a;
47.760 + }
47.761 +
47.762 + /**
47.763 + * Returns the greater of two {@code int} values. That is, the
47.764 + * result is the argument closer to the value of
47.765 + * {@link Integer#MAX_VALUE}. If the arguments have the same value,
47.766 + * the result is that same value.
47.767 + *
47.768 + * @param a an argument.
47.769 + * @param b another argument.
47.770 + * @return the larger of {@code a} and {@code b}.
47.771 + */
47.772 + public static int max(int a, int b) {
47.773 + return (a >= b) ? a : b;
47.774 + }
47.775 +
47.776 + /**
47.777 + * Returns the greater of two {@code long} values. That is, the
47.778 + * result is the argument closer to the value of
47.779 + * {@link Long#MAX_VALUE}. If the arguments have the same value,
47.780 + * the result is that same value.
47.781 + *
47.782 + * @param a an argument.
47.783 + * @param b another argument.
47.784 + * @return the larger of {@code a} and {@code b}.
47.785 + */
47.786 + public static long max(long a, long b) {
47.787 + return (a >= b) ? a : b;
47.788 + }
47.789 +
47.790 + // Use raw bit-wise conversions on guaranteed non-NaN arguments.
47.791 + private static long negativeZeroFloatBits = Float.floatToRawIntBits(-0.0f);
47.792 + private static long negativeZeroDoubleBits = Double.doubleToRawLongBits(-0.0d);
47.793 +
47.794 + /**
47.795 + * Returns the greater of two {@code float} values. That is,
47.796 + * the result is the argument closer to positive infinity. If the
47.797 + * arguments have the same value, the result is that same
47.798 + * value. If either value is NaN, then the result is NaN. Unlike
47.799 + * the numerical comparison operators, this method considers
47.800 + * negative zero to be strictly smaller than positive zero. If one
47.801 + * argument is positive zero and the other negative zero, the
47.802 + * result is positive zero.
47.803 + *
47.804 + * @param a an argument.
47.805 + * @param b another argument.
47.806 + * @return the larger of {@code a} and {@code b}.
47.807 + */
47.808 + public static float max(float a, float b) {
47.809 + if (a != a)
47.810 + return a; // a is NaN
47.811 + if ((a == 0.0f) &&
47.812 + (b == 0.0f) &&
47.813 + (Float.floatToRawIntBits(a) == negativeZeroFloatBits)) {
47.814 + // Raw conversion ok since NaN can't map to -0.0.
47.815 + return b;
47.816 + }
47.817 + return (a >= b) ? a : b;
47.818 + }
47.819 +
47.820 + /**
47.821 + * Returns the greater of two {@code double} values. That
47.822 + * is, the result is the argument closer to positive infinity. If
47.823 + * the arguments have the same value, the result is that same
47.824 + * value. If either value is NaN, then the result is NaN. Unlike
47.825 + * the numerical comparison operators, this method considers
47.826 + * negative zero to be strictly smaller than positive zero. If one
47.827 + * argument is positive zero and the other negative zero, the
47.828 + * result is positive zero.
47.829 + *
47.830 + * @param a an argument.
47.831 + * @param b another argument.
47.832 + * @return the larger of {@code a} and {@code b}.
47.833 + */
47.834 + public static double max(double a, double b) {
47.835 + if (a != a)
47.836 + return a; // a is NaN
47.837 + if ((a == 0.0d) &&
47.838 + (b == 0.0d) &&
47.839 + (Double.doubleToRawLongBits(a) == negativeZeroDoubleBits)) {
47.840 + // Raw conversion ok since NaN can't map to -0.0.
47.841 + return b;
47.842 + }
47.843 + return (a >= b) ? a : b;
47.844 + }
47.845 +
47.846 + /**
47.847 + * Returns the smaller of two {@code int} values. That is,
47.848 + * the result the argument closer to the value of
47.849 + * {@link Integer#MIN_VALUE}. If the arguments have the same
47.850 + * value, the result is that same value.
47.851 + *
47.852 + * @param a an argument.
47.853 + * @param b another argument.
47.854 + * @return the smaller of {@code a} and {@code b}.
47.855 + */
47.856 + public static int min(int a, int b) {
47.857 + return (a <= b) ? a : b;
47.858 + }
47.859 +
47.860 + /**
47.861 + * Returns the smaller of two {@code long} values. That is,
47.862 + * the result is the argument closer to the value of
47.863 + * {@link Long#MIN_VALUE}. If the arguments have the same
47.864 + * value, the result is that same value.
47.865 + *
47.866 + * @param a an argument.
47.867 + * @param b another argument.
47.868 + * @return the smaller of {@code a} and {@code b}.
47.869 + */
47.870 + public static long min(long a, long b) {
47.871 + return (a <= b) ? a : b;
47.872 + }
47.873 +
47.874 + /**
47.875 + * Returns the smaller of two {@code float} values. That is,
47.876 + * the result is the value closer to negative infinity. If the
47.877 + * arguments have the same value, the result is that same
47.878 + * value. If either value is NaN, then the result is NaN. Unlike
47.879 + * the numerical comparison operators, this method considers
47.880 + * negative zero to be strictly smaller than positive zero. If
47.881 + * one argument is positive zero and the other is negative zero,
47.882 + * the result is negative zero.
47.883 + *
47.884 + * @param a an argument.
47.885 + * @param b another argument.
47.886 + * @return the smaller of {@code a} and {@code b.}
47.887 + */
47.888 + public static float min(float a, float b) {
47.889 + if (a != a)
47.890 + return a; // a is NaN
47.891 + if ((a == 0.0f) &&
47.892 + (b == 0.0f) &&
47.893 + (Float.floatToRawIntBits(b) == negativeZeroFloatBits)) {
47.894 + // Raw conversion ok since NaN can't map to -0.0.
47.895 + return b;
47.896 + }
47.897 + return (a <= b) ? a : b;
47.898 + }
47.899 +
47.900 + /**
47.901 + * Returns the smaller of two {@code double} values. That
47.902 + * is, the result is the value closer to negative infinity. If the
47.903 + * arguments have the same value, the result is that same
47.904 + * value. If either value is NaN, then the result is NaN. Unlike
47.905 + * the numerical comparison operators, this method considers
47.906 + * negative zero to be strictly smaller than positive zero. If one
47.907 + * argument is positive zero and the other is negative zero, the
47.908 + * result is negative zero.
47.909 + *
47.910 + * @param a an argument.
47.911 + * @param b another argument.
47.912 + * @return the smaller of {@code a} and {@code b}.
47.913 + */
47.914 + public static double min(double a, double b) {
47.915 + if (a != a)
47.916 + return a; // a is NaN
47.917 + if ((a == 0.0d) &&
47.918 + (b == 0.0d) &&
47.919 + (Double.doubleToRawLongBits(b) == negativeZeroDoubleBits)) {
47.920 + // Raw conversion ok since NaN can't map to -0.0.
47.921 + return b;
47.922 + }
47.923 + return (a <= b) ? a : b;
47.924 + }
47.925 +
47.926 + /**
47.927 + * Returns the size of an ulp of the argument. An ulp of a
47.928 + * {@code double} value is the positive distance between this
47.929 + * floating-point value and the {@code double} value next
47.930 + * larger in magnitude. Note that for non-NaN <i>x</i>,
47.931 + * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
47.932 + *
47.933 + * <p>Special Cases:
47.934 + * <ul>
47.935 + * <li> If the argument is NaN, then the result is NaN.
47.936 + * <li> If the argument is positive or negative infinity, then the
47.937 + * result is positive infinity.
47.938 + * <li> If the argument is positive or negative zero, then the result is
47.939 + * {@code Double.MIN_VALUE}.
47.940 + * <li> If the argument is ±{@code Double.MAX_VALUE}, then
47.941 + * the result is equal to 2<sup>971</sup>.
47.942 + * </ul>
47.943 + *
47.944 + * @param d the floating-point value whose ulp is to be returned
47.945 + * @return the size of an ulp of the argument
47.946 + * @author Joseph D. Darcy
47.947 + * @since 1.5
47.948 + */
47.949 + public static double ulp(double d) {
47.950 + throw new UnsupportedOperationException();
47.951 + }
47.952 +
47.953 + /**
47.954 + * Returns the size of an ulp of the argument. An ulp of a
47.955 + * {@code float} value is the positive distance between this
47.956 + * floating-point value and the {@code float} value next
47.957 + * larger in magnitude. Note that for non-NaN <i>x</i>,
47.958 + * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
47.959 + *
47.960 + * <p>Special Cases:
47.961 + * <ul>
47.962 + * <li> If the argument is NaN, then the result is NaN.
47.963 + * <li> If the argument is positive or negative infinity, then the
47.964 + * result is positive infinity.
47.965 + * <li> If the argument is positive or negative zero, then the result is
47.966 + * {@code Float.MIN_VALUE}.
47.967 + * <li> If the argument is ±{@code Float.MAX_VALUE}, then
47.968 + * the result is equal to 2<sup>104</sup>.
47.969 + * </ul>
47.970 + *
47.971 + * @param f the floating-point value whose ulp is to be returned
47.972 + * @return the size of an ulp of the argument
47.973 + * @author Joseph D. Darcy
47.974 + * @since 1.5
47.975 + */
47.976 + public static float ulp(float f) {
47.977 + throw new UnsupportedOperationException();
47.978 + }
47.979 +
47.980 + /**
47.981 + * Returns the signum function of the argument; zero if the argument
47.982 + * is zero, 1.0 if the argument is greater than zero, -1.0 if the
47.983 + * argument is less than zero.
47.984 + *
47.985 + * <p>Special Cases:
47.986 + * <ul>
47.987 + * <li> If the argument is NaN, then the result is NaN.
47.988 + * <li> If the argument is positive zero or negative zero, then the
47.989 + * result is the same as the argument.
47.990 + * </ul>
47.991 + *
47.992 + * @param d the floating-point value whose signum is to be returned
47.993 + * @return the signum function of the argument
47.994 + * @author Joseph D. Darcy
47.995 + * @since 1.5
47.996 + */
47.997 + public static double signum(double d) {
47.998 + throw new UnsupportedOperationException();
47.999 + }
47.1000 +
47.1001 + /**
47.1002 + * Returns the signum function of the argument; zero if the argument
47.1003 + * is zero, 1.0f if the argument is greater than zero, -1.0f if the
47.1004 + * argument is less than zero.
47.1005 + *
47.1006 + * <p>Special Cases:
47.1007 + * <ul>
47.1008 + * <li> If the argument is NaN, then the result is NaN.
47.1009 + * <li> If the argument is positive zero or negative zero, then the
47.1010 + * result is the same as the argument.
47.1011 + * </ul>
47.1012 + *
47.1013 + * @param f the floating-point value whose signum is to be returned
47.1014 + * @return the signum function of the argument
47.1015 + * @author Joseph D. Darcy
47.1016 + * @since 1.5
47.1017 + */
47.1018 + public static float signum(float f) {
47.1019 + throw new UnsupportedOperationException();
47.1020 + }
47.1021 +
47.1022 + /**
47.1023 + * Returns the hyperbolic sine of a {@code double} value.
47.1024 + * The hyperbolic sine of <i>x</i> is defined to be
47.1025 + * (<i>e<sup>x</sup> - e<sup>-x</sup></i>)/2
47.1026 + * where <i>e</i> is {@linkplain Math#E Euler's number}.
47.1027 + *
47.1028 + * <p>Special cases:
47.1029 + * <ul>
47.1030 + *
47.1031 + * <li>If the argument is NaN, then the result is NaN.
47.1032 + *
47.1033 + * <li>If the argument is infinite, then the result is an infinity
47.1034 + * with the same sign as the argument.
47.1035 + *
47.1036 + * <li>If the argument is zero, then the result is a zero with the
47.1037 + * same sign as the argument.
47.1038 + *
47.1039 + * </ul>
47.1040 + *
47.1041 + * @param x The number whose hyperbolic sine is to be returned.
47.1042 + * @return The hyperbolic sine of {@code x}.
47.1043 + * @since 1.5
47.1044 + */
47.1045 + public static native double sinh(double x);
47.1046 +
47.1047 + /**
47.1048 + * Returns the hyperbolic cosine of a {@code double} value.
47.1049 + * The hyperbolic cosine of <i>x</i> is defined to be
47.1050 + * (<i>e<sup>x</sup> + e<sup>-x</sup></i>)/2
47.1051 + * where <i>e</i> is {@linkplain Math#E Euler's number}.
47.1052 + *
47.1053 + * <p>Special cases:
47.1054 + * <ul>
47.1055 + *
47.1056 + * <li>If the argument is NaN, then the result is NaN.
47.1057 + *
47.1058 + * <li>If the argument is infinite, then the result is positive
47.1059 + * infinity.
47.1060 + *
47.1061 + * <li>If the argument is zero, then the result is {@code 1.0}.
47.1062 + *
47.1063 + * </ul>
47.1064 + *
47.1065 + * @param x The number whose hyperbolic cosine is to be returned.
47.1066 + * @return The hyperbolic cosine of {@code x}.
47.1067 + * @since 1.5
47.1068 + */
47.1069 + public static native double cosh(double x);
47.1070 +
47.1071 + /**
47.1072 + * Returns the hyperbolic tangent of a {@code double} value.
47.1073 + * The hyperbolic tangent of <i>x</i> is defined to be
47.1074 + * (<i>e<sup>x</sup> - e<sup>-x</sup></i>)/(<i>e<sup>x</sup> + e<sup>-x</sup></i>),
47.1075 + * in other words, {@linkplain Math#sinh
47.1076 + * sinh(<i>x</i>)}/{@linkplain Math#cosh cosh(<i>x</i>)}. Note
47.1077 + * that the absolute value of the exact tanh is always less than
47.1078 + * 1.
47.1079 + *
47.1080 + * <p>Special cases:
47.1081 + * <ul>
47.1082 + *
47.1083 + * <li>If the argument is NaN, then the result is NaN.
47.1084 + *
47.1085 + * <li>If the argument is zero, then the result is a zero with the
47.1086 + * same sign as the argument.
47.1087 + *
47.1088 + * <li>If the argument is positive infinity, then the result is
47.1089 + * {@code +1.0}.
47.1090 + *
47.1091 + * <li>If the argument is negative infinity, then the result is
47.1092 + * {@code -1.0}.
47.1093 + *
47.1094 + * </ul>
47.1095 + *
47.1096 + * @param x The number whose hyperbolic tangent is to be returned.
47.1097 + * @return The hyperbolic tangent of {@code x}.
47.1098 + * @since 1.5
47.1099 + */
47.1100 + public static native double tanh(double x);
47.1101 +
47.1102 + /**
47.1103 + * Returns sqrt(<i>x</i><sup>2</sup> +<i>y</i><sup>2</sup>)
47.1104 + * without intermediate overflow or underflow.
47.1105 + *
47.1106 + * <p>Special cases:
47.1107 + * <ul>
47.1108 + *
47.1109 + * <li> If either argument is infinite, then the result
47.1110 + * is positive infinity.
47.1111 + *
47.1112 + * <li> If either argument is NaN and neither argument is infinite,
47.1113 + * then the result is NaN.
47.1114 + *
47.1115 + * </ul>
47.1116 + *
47.1117 + * @param x a value
47.1118 + * @param y a value
47.1119 + * @return sqrt(<i>x</i><sup>2</sup> +<i>y</i><sup>2</sup>)
47.1120 + * without intermediate overflow or underflow
47.1121 + * @since 1.5
47.1122 + */
47.1123 + public static native double hypot(double x, double y);
47.1124 +
47.1125 + /**
47.1126 + * Returns <i>e</i><sup>x</sup> -1. Note that for values of
47.1127 + * <i>x</i> near 0, the exact sum of
47.1128 + * {@code expm1(x)} + 1 is much closer to the true
47.1129 + * result of <i>e</i><sup>x</sup> than {@code exp(x)}.
47.1130 + *
47.1131 + * <p>Special cases:
47.1132 + * <ul>
47.1133 + * <li>If the argument is NaN, the result is NaN.
47.1134 + *
47.1135 + * <li>If the argument is positive infinity, then the result is
47.1136 + * positive infinity.
47.1137 + *
47.1138 + * <li>If the argument is negative infinity, then the result is
47.1139 + * -1.0.
47.1140 + *
47.1141 + * <li>If the argument is zero, then the result is a zero with the
47.1142 + * same sign as the argument.
47.1143 + *
47.1144 + * </ul>
47.1145 + *
47.1146 + * @param x the exponent to raise <i>e</i> to in the computation of
47.1147 + * <i>e</i><sup>{@code x}</sup> -1.
47.1148 + * @return the value <i>e</i><sup>{@code x}</sup> - 1.
47.1149 + * @since 1.5
47.1150 + */
47.1151 + public static native double expm1(double x);
47.1152 +
47.1153 + /**
47.1154 + * Returns the natural logarithm of the sum of the argument and 1.
47.1155 + * Note that for small values {@code x}, the result of
47.1156 + * {@code log1p(x)} is much closer to the true result of ln(1
47.1157 + * + {@code x}) than the floating-point evaluation of
47.1158 + * {@code log(1.0+x)}.
47.1159 + *
47.1160 + * <p>Special cases:
47.1161 + * <ul>
47.1162 + *
47.1163 + * <li>If the argument is NaN or less than -1, then the result is
47.1164 + * NaN.
47.1165 + *
47.1166 + * <li>If the argument is positive infinity, then the result is
47.1167 + * positive infinity.
47.1168 + *
47.1169 + * <li>If the argument is negative one, then the result is
47.1170 + * negative infinity.
47.1171 + *
47.1172 + * <li>If the argument is zero, then the result is a zero with the
47.1173 + * same sign as the argument.
47.1174 + *
47.1175 + * </ul>
47.1176 + *
47.1177 + * @param x a value
47.1178 + * @return the value ln({@code x} + 1), the natural
47.1179 + * log of {@code x} + 1
47.1180 + * @since 1.5
47.1181 + */
47.1182 + public static native double log1p(double x);
47.1183 +
47.1184 + /**
47.1185 + * Returns the first floating-point argument with the sign of the
47.1186 + * second floating-point argument. For this method, a NaN
47.1187 + * {@code sign} argument is always treated as if it were
47.1188 + * positive.
47.1189 + *
47.1190 + * @param magnitude the parameter providing the magnitude of the result
47.1191 + * @param sign the parameter providing the sign of the result
47.1192 + * @return a value with the magnitude of {@code magnitude}
47.1193 + * and the sign of {@code sign}.
47.1194 + * @since 1.6
47.1195 + */
47.1196 + public static double copySign(double magnitude, double sign) {
47.1197 + throw new UnsupportedOperationException();
47.1198 + }
47.1199 +
47.1200 + /**
47.1201 + * Returns the first floating-point argument with the sign of the
47.1202 + * second floating-point argument. For this method, a NaN
47.1203 + * {@code sign} argument is always treated as if it were
47.1204 + * positive.
47.1205 + *
47.1206 + * @param magnitude the parameter providing the magnitude of the result
47.1207 + * @param sign the parameter providing the sign of the result
47.1208 + * @return a value with the magnitude of {@code magnitude}
47.1209 + * and the sign of {@code sign}.
47.1210 + * @since 1.6
47.1211 + */
47.1212 + public static float copySign(float magnitude, float sign) {
47.1213 + throw new UnsupportedOperationException();
47.1214 + }
47.1215 + /**
47.1216 + * Returns the unbiased exponent used in the representation of a
47.1217 + * {@code float}. Special cases:
47.1218 + *
47.1219 + * <ul>
47.1220 + * <li>If the argument is NaN or infinite, then the result is
47.1221 + * {@link Float#MAX_EXPONENT} + 1.
47.1222 + * <li>If the argument is zero or subnormal, then the result is
47.1223 + * {@link Float#MIN_EXPONENT} -1.
47.1224 + * </ul>
47.1225 + * @param f a {@code float} value
47.1226 + * @since 1.6
47.1227 + */
47.1228 + public static int getExponent(float f) {
47.1229 + throw new UnsupportedOperationException();
47.1230 + }
47.1231 +
47.1232 + /**
47.1233 + * Returns the unbiased exponent used in the representation of a
47.1234 + * {@code double}. Special cases:
47.1235 + *
47.1236 + * <ul>
47.1237 + * <li>If the argument is NaN or infinite, then the result is
47.1238 + * {@link Double#MAX_EXPONENT} + 1.
47.1239 + * <li>If the argument is zero or subnormal, then the result is
47.1240 + * {@link Double#MIN_EXPONENT} -1.
47.1241 + * </ul>
47.1242 + * @param d a {@code double} value
47.1243 + * @since 1.6
47.1244 + */
47.1245 + public static int getExponent(double d) {
47.1246 + throw new UnsupportedOperationException();
47.1247 + }
47.1248 +
47.1249 + /**
47.1250 + * Returns the floating-point number adjacent to the first
47.1251 + * argument in the direction of the second argument. If both
47.1252 + * arguments compare as equal the second argument is returned.
47.1253 + *
47.1254 + * <p>Special cases:
47.1255 + * <ul>
47.1256 + * <li> If either argument is a NaN, then NaN is returned.
47.1257 + *
47.1258 + * <li> If both arguments are signed zeros, {@code direction}
47.1259 + * is returned unchanged (as implied by the requirement of
47.1260 + * returning the second argument if the arguments compare as
47.1261 + * equal).
47.1262 + *
47.1263 + * <li> If {@code start} is
47.1264 + * ±{@link Double#MIN_VALUE} and {@code direction}
47.1265 + * has a value such that the result should have a smaller
47.1266 + * magnitude, then a zero with the same sign as {@code start}
47.1267 + * is returned.
47.1268 + *
47.1269 + * <li> If {@code start} is infinite and
47.1270 + * {@code direction} has a value such that the result should
47.1271 + * have a smaller magnitude, {@link Double#MAX_VALUE} with the
47.1272 + * same sign as {@code start} is returned.
47.1273 + *
47.1274 + * <li> If {@code start} is equal to ±
47.1275 + * {@link Double#MAX_VALUE} and {@code direction} has a
47.1276 + * value such that the result should have a larger magnitude, an
47.1277 + * infinity with same sign as {@code start} is returned.
47.1278 + * </ul>
47.1279 + *
47.1280 + * @param start starting floating-point value
47.1281 + * @param direction value indicating which of
47.1282 + * {@code start}'s neighbors or {@code start} should
47.1283 + * be returned
47.1284 + * @return The floating-point number adjacent to {@code start} in the
47.1285 + * direction of {@code direction}.
47.1286 + * @since 1.6
47.1287 + */
47.1288 + public static double nextAfter(double start, double direction) {
47.1289 + throw new UnsupportedOperationException();
47.1290 + }
47.1291 +
47.1292 + /**
47.1293 + * Returns the floating-point number adjacent to the first
47.1294 + * argument in the direction of the second argument. If both
47.1295 + * arguments compare as equal a value equivalent to the second argument
47.1296 + * is returned.
47.1297 + *
47.1298 + * <p>Special cases:
47.1299 + * <ul>
47.1300 + * <li> If either argument is a NaN, then NaN is returned.
47.1301 + *
47.1302 + * <li> If both arguments are signed zeros, a value equivalent
47.1303 + * to {@code direction} is returned.
47.1304 + *
47.1305 + * <li> If {@code start} is
47.1306 + * ±{@link Float#MIN_VALUE} and {@code direction}
47.1307 + * has a value such that the result should have a smaller
47.1308 + * magnitude, then a zero with the same sign as {@code start}
47.1309 + * is returned.
47.1310 + *
47.1311 + * <li> If {@code start} is infinite and
47.1312 + * {@code direction} has a value such that the result should
47.1313 + * have a smaller magnitude, {@link Float#MAX_VALUE} with the
47.1314 + * same sign as {@code start} is returned.
47.1315 + *
47.1316 + * <li> If {@code start} is equal to ±
47.1317 + * {@link Float#MAX_VALUE} and {@code direction} has a
47.1318 + * value such that the result should have a larger magnitude, an
47.1319 + * infinity with same sign as {@code start} is returned.
47.1320 + * </ul>
47.1321 + *
47.1322 + * @param start starting floating-point value
47.1323 + * @param direction value indicating which of
47.1324 + * {@code start}'s neighbors or {@code start} should
47.1325 + * be returned
47.1326 + * @return The floating-point number adjacent to {@code start} in the
47.1327 + * direction of {@code direction}.
47.1328 + * @since 1.6
47.1329 + */
47.1330 + public static float nextAfter(float start, double direction) {
47.1331 + throw new UnsupportedOperationException();
47.1332 + }
47.1333 +
47.1334 + /**
47.1335 + * Returns the floating-point value adjacent to {@code d} in
47.1336 + * the direction of positive infinity. This method is
47.1337 + * semantically equivalent to {@code nextAfter(d,
47.1338 + * Double.POSITIVE_INFINITY)}; however, a {@code nextUp}
47.1339 + * implementation may run faster than its equivalent
47.1340 + * {@code nextAfter} call.
47.1341 + *
47.1342 + * <p>Special Cases:
47.1343 + * <ul>
47.1344 + * <li> If the argument is NaN, the result is NaN.
47.1345 + *
47.1346 + * <li> If the argument is positive infinity, the result is
47.1347 + * positive infinity.
47.1348 + *
47.1349 + * <li> If the argument is zero, the result is
47.1350 + * {@link Double#MIN_VALUE}
47.1351 + *
47.1352 + * </ul>
47.1353 + *
47.1354 + * @param d starting floating-point value
47.1355 + * @return The adjacent floating-point value closer to positive
47.1356 + * infinity.
47.1357 + * @since 1.6
47.1358 + */
47.1359 + public static double nextUp(double d) {
47.1360 + throw new UnsupportedOperationException();
47.1361 + }
47.1362 +
47.1363 + /**
47.1364 + * Returns the floating-point value adjacent to {@code f} in
47.1365 + * the direction of positive infinity. This method is
47.1366 + * semantically equivalent to {@code nextAfter(f,
47.1367 + * Float.POSITIVE_INFINITY)}; however, a {@code nextUp}
47.1368 + * implementation may run faster than its equivalent
47.1369 + * {@code nextAfter} call.
47.1370 + *
47.1371 + * <p>Special Cases:
47.1372 + * <ul>
47.1373 + * <li> If the argument is NaN, the result is NaN.
47.1374 + *
47.1375 + * <li> If the argument is positive infinity, the result is
47.1376 + * positive infinity.
47.1377 + *
47.1378 + * <li> If the argument is zero, the result is
47.1379 + * {@link Float#MIN_VALUE}
47.1380 + *
47.1381 + * </ul>
47.1382 + *
47.1383 + * @param f starting floating-point value
47.1384 + * @return The adjacent floating-point value closer to positive
47.1385 + * infinity.
47.1386 + * @since 1.6
47.1387 + */
47.1388 + public static float nextUp(float f) {
47.1389 + throw new UnsupportedOperationException();
47.1390 + }
47.1391 +
47.1392 +
47.1393 + /**
47.1394 + * Return {@code d} ×
47.1395 + * 2<sup>{@code scaleFactor}</sup> rounded as if performed
47.1396 + * by a single correctly rounded floating-point multiply to a
47.1397 + * member of the double value set. See the Java
47.1398 + * Language Specification for a discussion of floating-point
47.1399 + * value sets. If the exponent of the result is between {@link
47.1400 + * Double#MIN_EXPONENT} and {@link Double#MAX_EXPONENT}, the
47.1401 + * answer is calculated exactly. If the exponent of the result
47.1402 + * would be larger than {@code Double.MAX_EXPONENT}, an
47.1403 + * infinity is returned. Note that if the result is subnormal,
47.1404 + * precision may be lost; that is, when {@code scalb(x, n)}
47.1405 + * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
47.1406 + * <i>x</i>. When the result is non-NaN, the result has the same
47.1407 + * sign as {@code d}.
47.1408 + *
47.1409 + * <p>Special cases:
47.1410 + * <ul>
47.1411 + * <li> If the first argument is NaN, NaN is returned.
47.1412 + * <li> If the first argument is infinite, then an infinity of the
47.1413 + * same sign is returned.
47.1414 + * <li> If the first argument is zero, then a zero of the same
47.1415 + * sign is returned.
47.1416 + * </ul>
47.1417 + *
47.1418 + * @param d number to be scaled by a power of two.
47.1419 + * @param scaleFactor power of 2 used to scale {@code d}
47.1420 + * @return {@code d} × 2<sup>{@code scaleFactor}</sup>
47.1421 + * @since 1.6
47.1422 + */
47.1423 + public static double scalb(double d, int scaleFactor) {
47.1424 + throw new UnsupportedOperationException();
47.1425 + }
47.1426 +
47.1427 + /**
47.1428 + * Return {@code f} ×
47.1429 + * 2<sup>{@code scaleFactor}</sup> rounded as if performed
47.1430 + * by a single correctly rounded floating-point multiply to a
47.1431 + * member of the float value set. See the Java
47.1432 + * Language Specification for a discussion of floating-point
47.1433 + * value sets. If the exponent of the result is between {@link
47.1434 + * Float#MIN_EXPONENT} and {@link Float#MAX_EXPONENT}, the
47.1435 + * answer is calculated exactly. If the exponent of the result
47.1436 + * would be larger than {@code Float.MAX_EXPONENT}, an
47.1437 + * infinity is returned. Note that if the result is subnormal,
47.1438 + * precision may be lost; that is, when {@code scalb(x, n)}
47.1439 + * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
47.1440 + * <i>x</i>. When the result is non-NaN, the result has the same
47.1441 + * sign as {@code f}.
47.1442 + *
47.1443 + * <p>Special cases:
47.1444 + * <ul>
47.1445 + * <li> If the first argument is NaN, NaN is returned.
47.1446 + * <li> If the first argument is infinite, then an infinity of the
47.1447 + * same sign is returned.
47.1448 + * <li> If the first argument is zero, then a zero of the same
47.1449 + * sign is returned.
47.1450 + * </ul>
47.1451 + *
47.1452 + * @param f number to be scaled by a power of two.
47.1453 + * @param scaleFactor power of 2 used to scale {@code f}
47.1454 + * @return {@code f} × 2<sup>{@code scaleFactor}</sup>
47.1455 + * @since 1.6
47.1456 + */
47.1457 + public static float scalb(float f, int scaleFactor) {
47.1458 + throw new UnsupportedOperationException();
47.1459 + }
47.1460 +}
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
48.2 +++ b/emul/src/main/java/java/lang/String.java Thu Oct 11 06:16:00 2012 -0700
48.3 @@ -0,0 +1,3065 @@
48.4 +/*
48.5 + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
48.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
48.7 + *
48.8 + * This code is free software; you can redistribute it and/or modify it
48.9 + * under the terms of the GNU General Public License version 2 only, as
48.10 + * published by the Free Software Foundation. Oracle designates this
48.11 + * particular file as subject to the "Classpath" exception as provided
48.12 + * by Oracle in the LICENSE file that accompanied this code.
48.13 + *
48.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
48.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
48.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
48.17 + * version 2 for more details (a copy is included in the LICENSE file that
48.18 + * accompanied this code).
48.19 + *
48.20 + * You should have received a copy of the GNU General Public License version
48.21 + * 2 along with this work; if not, write to the Free Software Foundation,
48.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
48.23 + *
48.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
48.25 + * or visit www.oracle.com if you need additional information or have any
48.26 + * questions.
48.27 + */
48.28 +
48.29 +package java.lang;
48.30 +
48.31 +import org.apidesign.bck2brwsr.core.ExtraJavaScript;
48.32 +import java.util.Comparator;
48.33 +
48.34 +/**
48.35 + * The <code>String</code> class represents character strings. All
48.36 + * string literals in Java programs, such as <code>"abc"</code>, are
48.37 + * implemented as instances of this class.
48.38 + * <p>
48.39 + * Strings are constant; their values cannot be changed after they
48.40 + * are created. String buffers support mutable strings.
48.41 + * Because String objects are immutable they can be shared. For example:
48.42 + * <p><blockquote><pre>
48.43 + * String str = "abc";
48.44 + * </pre></blockquote><p>
48.45 + * is equivalent to:
48.46 + * <p><blockquote><pre>
48.47 + * char data[] = {'a', 'b', 'c'};
48.48 + * String str = new String(data);
48.49 + * </pre></blockquote><p>
48.50 + * Here are some more examples of how strings can be used:
48.51 + * <p><blockquote><pre>
48.52 + * System.out.println("abc");
48.53 + * String cde = "cde";
48.54 + * System.out.println("abc" + cde);
48.55 + * String c = "abc".substring(2,3);
48.56 + * String d = cde.substring(1, 2);
48.57 + * </pre></blockquote>
48.58 + * <p>
48.59 + * The class <code>String</code> includes methods for examining
48.60 + * individual characters of the sequence, for comparing strings, for
48.61 + * searching strings, for extracting substrings, and for creating a
48.62 + * copy of a string with all characters translated to uppercase or to
48.63 + * lowercase. Case mapping is based on the Unicode Standard version
48.64 + * specified by the {@link java.lang.Character Character} class.
48.65 + * <p>
48.66 + * The Java language provides special support for the string
48.67 + * concatenation operator ( + ), and for conversion of
48.68 + * other objects to strings. String concatenation is implemented
48.69 + * through the <code>StringBuilder</code>(or <code>StringBuffer</code>)
48.70 + * class and its <code>append</code> method.
48.71 + * String conversions are implemented through the method
48.72 + * <code>toString</code>, defined by <code>Object</code> and
48.73 + * inherited by all classes in Java. For additional information on
48.74 + * string concatenation and conversion, see Gosling, Joy, and Steele,
48.75 + * <i>The Java Language Specification</i>.
48.76 + *
48.77 + * <p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor
48.78 + * or method in this class will cause a {@link NullPointerException} to be
48.79 + * thrown.
48.80 + *
48.81 + * <p>A <code>String</code> represents a string in the UTF-16 format
48.82 + * in which <em>supplementary characters</em> are represented by <em>surrogate
48.83 + * pairs</em> (see the section <a href="Character.html#unicode">Unicode
48.84 + * Character Representations</a> in the <code>Character</code> class for
48.85 + * more information).
48.86 + * Index values refer to <code>char</code> code units, so a supplementary
48.87 + * character uses two positions in a <code>String</code>.
48.88 + * <p>The <code>String</code> class provides methods for dealing with
48.89 + * Unicode code points (i.e., characters), in addition to those for
48.90 + * dealing with Unicode code units (i.e., <code>char</code> values).
48.91 + *
48.92 + * @author Lee Boynton
48.93 + * @author Arthur van Hoff
48.94 + * @author Martin Buchholz
48.95 + * @author Ulf Zibis
48.96 + * @see java.lang.Object#toString()
48.97 + * @see java.lang.StringBuffer
48.98 + * @see java.lang.StringBuilder
48.99 + * @see java.nio.charset.Charset
48.100 + * @since JDK1.0
48.101 + */
48.102 +
48.103 +@ExtraJavaScript(
48.104 + resource="/org/apidesign/vm4brwsr/emul/java_lang_String.js",
48.105 + processByteCode=false
48.106 +)
48.107 +public final class String
48.108 + implements java.io.Serializable, Comparable<String>, CharSequence
48.109 +{
48.110 + /** The value is used for character storage. */
48.111 + private final char value[];
48.112 +
48.113 + /** The offset is the first index of the storage that is used. */
48.114 + private final int offset;
48.115 +
48.116 + /** The count is the number of characters in the String. */
48.117 + private final int count;
48.118 +
48.119 + /** Cache the hash code for the string */
48.120 + private int hash; // Default to 0
48.121 +
48.122 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
48.123 + private static final long serialVersionUID = -6849794470754667710L;
48.124 +
48.125 + /**
48.126 + * Class String is special cased within the Serialization Stream Protocol.
48.127 + *
48.128 + * A String instance is written initially into an ObjectOutputStream in the
48.129 + * following format:
48.130 + * <pre>
48.131 + * <code>TC_STRING</code> (utf String)
48.132 + * </pre>
48.133 + * The String is written by method <code>DataOutput.writeUTF</code>.
48.134 + * A new handle is generated to refer to all future references to the
48.135 + * string instance within the stream.
48.136 + */
48.137 +// private static final ObjectStreamField[] serialPersistentFields =
48.138 +// new ObjectStreamField[0];
48.139 +
48.140 + /**
48.141 + * Initializes a newly created {@code String} object so that it represents
48.142 + * an empty character sequence. Note that use of this constructor is
48.143 + * unnecessary since Strings are immutable.
48.144 + */
48.145 + public String() {
48.146 + this.offset = 0;
48.147 + this.count = 0;
48.148 + this.value = new char[0];
48.149 + }
48.150 +
48.151 + /**
48.152 + * Initializes a newly created {@code String} object so that it represents
48.153 + * the same sequence of characters as the argument; in other words, the
48.154 + * newly created string is a copy of the argument string. Unless an
48.155 + * explicit copy of {@code original} is needed, use of this constructor is
48.156 + * unnecessary since Strings are immutable.
48.157 + *
48.158 + * @param original
48.159 + * A {@code String}
48.160 + */
48.161 + public String(String original) {
48.162 + int size = original.count;
48.163 + char[] originalValue = original.value;
48.164 + char[] v;
48.165 + if (originalValue.length > size) {
48.166 + // The array representing the String is bigger than the new
48.167 + // String itself. Perhaps this constructor is being called
48.168 + // in order to trim the baggage, so make a copy of the array.
48.169 + int off = original.offset;
48.170 + v = copyOfRange(originalValue, off, off+size);
48.171 + } else {
48.172 + // The array representing the String is the same
48.173 + // size as the String, so no point in making a copy.
48.174 + v = originalValue;
48.175 + }
48.176 + this.offset = 0;
48.177 + this.count = size;
48.178 + this.value = v;
48.179 + }
48.180 +
48.181 + /**
48.182 + * Allocates a new {@code String} so that it represents the sequence of
48.183 + * characters currently contained in the character array argument. The
48.184 + * contents of the character array are copied; subsequent modification of
48.185 + * the character array does not affect the newly created string.
48.186 + *
48.187 + * @param value
48.188 + * The initial value of the string
48.189 + */
48.190 + public String(char value[]) {
48.191 + int size = value.length;
48.192 + this.offset = 0;
48.193 + this.count = size;
48.194 + this.value = copyOf(value, size);
48.195 + }
48.196 +
48.197 + /**
48.198 + * Allocates a new {@code String} that contains characters from a subarray
48.199 + * of the character array argument. The {@code offset} argument is the
48.200 + * index of the first character of the subarray and the {@code count}
48.201 + * argument specifies the length of the subarray. The contents of the
48.202 + * subarray are copied; subsequent modification of the character array does
48.203 + * not affect the newly created string.
48.204 + *
48.205 + * @param value
48.206 + * Array that is the source of characters
48.207 + *
48.208 + * @param offset
48.209 + * The initial offset
48.210 + *
48.211 + * @param count
48.212 + * The length
48.213 + *
48.214 + * @throws IndexOutOfBoundsException
48.215 + * If the {@code offset} and {@code count} arguments index
48.216 + * characters outside the bounds of the {@code value} array
48.217 + */
48.218 + public String(char value[], int offset, int count) {
48.219 + if (offset < 0) {
48.220 + throw new StringIndexOutOfBoundsException(offset);
48.221 + }
48.222 + if (count < 0) {
48.223 + throw new StringIndexOutOfBoundsException(count);
48.224 + }
48.225 + // Note: offset or count might be near -1>>>1.
48.226 + if (offset > value.length - count) {
48.227 + throw new StringIndexOutOfBoundsException(offset + count);
48.228 + }
48.229 + this.offset = 0;
48.230 + this.count = count;
48.231 + this.value = copyOfRange(value, offset, offset+count);
48.232 + }
48.233 +
48.234 + /**
48.235 + * Allocates a new {@code String} that contains characters from a subarray
48.236 + * of the <a href="Character.html#unicode">Unicode code point</a> array
48.237 + * argument. The {@code offset} argument is the index of the first code
48.238 + * point of the subarray and the {@code count} argument specifies the
48.239 + * length of the subarray. The contents of the subarray are converted to
48.240 + * {@code char}s; subsequent modification of the {@code int} array does not
48.241 + * affect the newly created string.
48.242 + *
48.243 + * @param codePoints
48.244 + * Array that is the source of Unicode code points
48.245 + *
48.246 + * @param offset
48.247 + * The initial offset
48.248 + *
48.249 + * @param count
48.250 + * The length
48.251 + *
48.252 + * @throws IllegalArgumentException
48.253 + * If any invalid Unicode code point is found in {@code
48.254 + * codePoints}
48.255 + *
48.256 + * @throws IndexOutOfBoundsException
48.257 + * If the {@code offset} and {@code count} arguments index
48.258 + * characters outside the bounds of the {@code codePoints} array
48.259 + *
48.260 + * @since 1.5
48.261 + */
48.262 + public String(int[] codePoints, int offset, int count) {
48.263 + if (offset < 0) {
48.264 + throw new StringIndexOutOfBoundsException(offset);
48.265 + }
48.266 + if (count < 0) {
48.267 + throw new StringIndexOutOfBoundsException(count);
48.268 + }
48.269 + // Note: offset or count might be near -1>>>1.
48.270 + if (offset > codePoints.length - count) {
48.271 + throw new StringIndexOutOfBoundsException(offset + count);
48.272 + }
48.273 +
48.274 + final int end = offset + count;
48.275 +
48.276 + // Pass 1: Compute precise size of char[]
48.277 + int n = count;
48.278 + for (int i = offset; i < end; i++) {
48.279 + int c = codePoints[i];
48.280 + if (Character.isBmpCodePoint(c))
48.281 + continue;
48.282 + else if (Character.isValidCodePoint(c))
48.283 + n++;
48.284 + else throw new IllegalArgumentException(Integer.toString(c));
48.285 + }
48.286 +
48.287 + // Pass 2: Allocate and fill in char[]
48.288 + final char[] v = new char[n];
48.289 +
48.290 + for (int i = offset, j = 0; i < end; i++, j++) {
48.291 + int c = codePoints[i];
48.292 + if (Character.isBmpCodePoint(c))
48.293 + v[j] = (char) c;
48.294 + else
48.295 + Character.toSurrogates(c, v, j++);
48.296 + }
48.297 +
48.298 + this.value = v;
48.299 + this.count = n;
48.300 + this.offset = 0;
48.301 + }
48.302 +
48.303 + /**
48.304 + * Allocates a new {@code String} constructed from a subarray of an array
48.305 + * of 8-bit integer values.
48.306 + *
48.307 + * <p> The {@code offset} argument is the index of the first byte of the
48.308 + * subarray, and the {@code count} argument specifies the length of the
48.309 + * subarray.
48.310 + *
48.311 + * <p> Each {@code byte} in the subarray is converted to a {@code char} as
48.312 + * specified in the method above.
48.313 + *
48.314 + * @deprecated This method does not properly convert bytes into characters.
48.315 + * As of JDK 1.1, the preferred way to do this is via the
48.316 + * {@code String} constructors that take a {@link
48.317 + * java.nio.charset.Charset}, charset name, or that use the platform's
48.318 + * default charset.
48.319 + *
48.320 + * @param ascii
48.321 + * The bytes to be converted to characters
48.322 + *
48.323 + * @param hibyte
48.324 + * The top 8 bits of each 16-bit Unicode code unit
48.325 + *
48.326 + * @param offset
48.327 + * The initial offset
48.328 + * @param count
48.329 + * The length
48.330 + *
48.331 + * @throws IndexOutOfBoundsException
48.332 + * If the {@code offset} or {@code count} argument is invalid
48.333 + *
48.334 + * @see #String(byte[], int)
48.335 + * @see #String(byte[], int, int, java.lang.String)
48.336 + * @see #String(byte[], int, int, java.nio.charset.Charset)
48.337 + * @see #String(byte[], int, int)
48.338 + * @see #String(byte[], java.lang.String)
48.339 + * @see #String(byte[], java.nio.charset.Charset)
48.340 + * @see #String(byte[])
48.341 + */
48.342 + @Deprecated
48.343 + public String(byte ascii[], int hibyte, int offset, int count) {
48.344 + checkBounds(ascii, offset, count);
48.345 + char value[] = new char[count];
48.346 +
48.347 + if (hibyte == 0) {
48.348 + for (int i = count ; i-- > 0 ;) {
48.349 + value[i] = (char) (ascii[i + offset] & 0xff);
48.350 + }
48.351 + } else {
48.352 + hibyte <<= 8;
48.353 + for (int i = count ; i-- > 0 ;) {
48.354 + value[i] = (char) (hibyte | (ascii[i + offset] & 0xff));
48.355 + }
48.356 + }
48.357 + this.offset = 0;
48.358 + this.count = count;
48.359 + this.value = value;
48.360 + }
48.361 +
48.362 + /**
48.363 + * Allocates a new {@code String} containing characters constructed from
48.364 + * an array of 8-bit integer values. Each character <i>c</i>in the
48.365 + * resulting string is constructed from the corresponding component
48.366 + * <i>b</i> in the byte array such that:
48.367 + *
48.368 + * <blockquote><pre>
48.369 + * <b><i>c</i></b> == (char)(((hibyte & 0xff) << 8)
48.370 + * | (<b><i>b</i></b> & 0xff))
48.371 + * </pre></blockquote>
48.372 + *
48.373 + * @deprecated This method does not properly convert bytes into
48.374 + * characters. As of JDK 1.1, the preferred way to do this is via the
48.375 + * {@code String} constructors that take a {@link
48.376 + * java.nio.charset.Charset}, charset name, or that use the platform's
48.377 + * default charset.
48.378 + *
48.379 + * @param ascii
48.380 + * The bytes to be converted to characters
48.381 + *
48.382 + * @param hibyte
48.383 + * The top 8 bits of each 16-bit Unicode code unit
48.384 + *
48.385 + * @see #String(byte[], int, int, java.lang.String)
48.386 + * @see #String(byte[], int, int, java.nio.charset.Charset)
48.387 + * @see #String(byte[], int, int)
48.388 + * @see #String(byte[], java.lang.String)
48.389 + * @see #String(byte[], java.nio.charset.Charset)
48.390 + * @see #String(byte[])
48.391 + */
48.392 + @Deprecated
48.393 + public String(byte ascii[], int hibyte) {
48.394 + this(ascii, hibyte, 0, ascii.length);
48.395 + }
48.396 +
48.397 + /* Common private utility method used to bounds check the byte array
48.398 + * and requested offset & length values used by the String(byte[],..)
48.399 + * constructors.
48.400 + */
48.401 + private static void checkBounds(byte[] bytes, int offset, int length) {
48.402 + if (length < 0)
48.403 + throw new StringIndexOutOfBoundsException(length);
48.404 + if (offset < 0)
48.405 + throw new StringIndexOutOfBoundsException(offset);
48.406 + if (offset > bytes.length - length)
48.407 + throw new StringIndexOutOfBoundsException(offset + length);
48.408 + }
48.409 +
48.410 + /**
48.411 + * Constructs a new {@code String} by decoding the specified subarray of
48.412 + * bytes using the specified charset. The length of the new {@code String}
48.413 + * is a function of the charset, and hence may not be equal to the length
48.414 + * of the subarray.
48.415 + *
48.416 + * <p> The behavior of this constructor when the given bytes are not valid
48.417 + * in the given charset is unspecified. The {@link
48.418 + * java.nio.charset.CharsetDecoder} class should be used when more control
48.419 + * over the decoding process is required.
48.420 + *
48.421 + * @param bytes
48.422 + * The bytes to be decoded into characters
48.423 + *
48.424 + * @param offset
48.425 + * The index of the first byte to decode
48.426 + *
48.427 + * @param length
48.428 + * The number of bytes to decode
48.429 +
48.430 + * @param charsetName
48.431 + * The name of a supported {@linkplain java.nio.charset.Charset
48.432 + * charset}
48.433 + *
48.434 + * @throws UnsupportedEncodingException
48.435 + * If the named charset is not supported
48.436 + *
48.437 + * @throws IndexOutOfBoundsException
48.438 + * If the {@code offset} and {@code length} arguments index
48.439 + * characters outside the bounds of the {@code bytes} array
48.440 + *
48.441 + * @since JDK1.1
48.442 + */
48.443 +// public String(byte bytes[], int offset, int length, String charsetName)
48.444 +// throws UnsupportedEncodingException
48.445 +// {
48.446 +// if (charsetName == null)
48.447 +// throw new NullPointerException("charsetName");
48.448 +// checkBounds(bytes, offset, length);
48.449 +// char[] v = StringCoding.decode(charsetName, bytes, offset, length);
48.450 +// this.offset = 0;
48.451 +// this.count = v.length;
48.452 +// this.value = v;
48.453 +// }
48.454 +
48.455 + /**
48.456 + * Constructs a new {@code String} by decoding the specified subarray of
48.457 + * bytes using the specified {@linkplain java.nio.charset.Charset charset}.
48.458 + * The length of the new {@code String} is a function of the charset, and
48.459 + * hence may not be equal to the length of the subarray.
48.460 + *
48.461 + * <p> This method always replaces malformed-input and unmappable-character
48.462 + * sequences with this charset's default replacement string. The {@link
48.463 + * java.nio.charset.CharsetDecoder} class should be used when more control
48.464 + * over the decoding process is required.
48.465 + *
48.466 + * @param bytes
48.467 + * The bytes to be decoded into characters
48.468 + *
48.469 + * @param offset
48.470 + * The index of the first byte to decode
48.471 + *
48.472 + * @param length
48.473 + * The number of bytes to decode
48.474 + *
48.475 + * @param charset
48.476 + * The {@linkplain java.nio.charset.Charset charset} to be used to
48.477 + * decode the {@code bytes}
48.478 + *
48.479 + * @throws IndexOutOfBoundsException
48.480 + * If the {@code offset} and {@code length} arguments index
48.481 + * characters outside the bounds of the {@code bytes} array
48.482 + *
48.483 + * @since 1.6
48.484 + */
48.485 + /* don't want dependnecy on Charset
48.486 + public String(byte bytes[], int offset, int length, Charset charset) {
48.487 + if (charset == null)
48.488 + throw new NullPointerException("charset");
48.489 + checkBounds(bytes, offset, length);
48.490 + char[] v = StringCoding.decode(charset, bytes, offset, length);
48.491 + this.offset = 0;
48.492 + this.count = v.length;
48.493 + this.value = v;
48.494 + }
48.495 + */
48.496 +
48.497 + /**
48.498 + * Constructs a new {@code String} by decoding the specified array of bytes
48.499 + * using the specified {@linkplain java.nio.charset.Charset charset}. The
48.500 + * length of the new {@code String} is a function of the charset, and hence
48.501 + * may not be equal to the length of the byte array.
48.502 + *
48.503 + * <p> The behavior of this constructor when the given bytes are not valid
48.504 + * in the given charset is unspecified. The {@link
48.505 + * java.nio.charset.CharsetDecoder} class should be used when more control
48.506 + * over the decoding process is required.
48.507 + *
48.508 + * @param bytes
48.509 + * The bytes to be decoded into characters
48.510 + *
48.511 + * @param charsetName
48.512 + * The name of a supported {@linkplain java.nio.charset.Charset
48.513 + * charset}
48.514 + *
48.515 + * @throws UnsupportedEncodingException
48.516 + * If the named charset is not supported
48.517 + *
48.518 + * @since JDK1.1
48.519 + */
48.520 +// public String(byte bytes[], String charsetName)
48.521 +// throws UnsupportedEncodingException
48.522 +// {
48.523 +// this(bytes, 0, bytes.length, charsetName);
48.524 +// }
48.525 +
48.526 + /**
48.527 + * Constructs a new {@code String} by decoding the specified array of
48.528 + * bytes using the specified {@linkplain java.nio.charset.Charset charset}.
48.529 + * The length of the new {@code String} is a function of the charset, and
48.530 + * hence may not be equal to the length of the byte array.
48.531 + *
48.532 + * <p> This method always replaces malformed-input and unmappable-character
48.533 + * sequences with this charset's default replacement string. The {@link
48.534 + * java.nio.charset.CharsetDecoder} class should be used when more control
48.535 + * over the decoding process is required.
48.536 + *
48.537 + * @param bytes
48.538 + * The bytes to be decoded into characters
48.539 + *
48.540 + * @param charset
48.541 + * The {@linkplain java.nio.charset.Charset charset} to be used to
48.542 + * decode the {@code bytes}
48.543 + *
48.544 + * @since 1.6
48.545 + */
48.546 + /* don't want dep on Charset
48.547 + public String(byte bytes[], Charset charset) {
48.548 + this(bytes, 0, bytes.length, charset);
48.549 + }
48.550 + */
48.551 +
48.552 + /**
48.553 + * Constructs a new {@code String} by decoding the specified subarray of
48.554 + * bytes using the platform's default charset. The length of the new
48.555 + * {@code String} is a function of the charset, and hence may not be equal
48.556 + * to the length of the subarray.
48.557 + *
48.558 + * <p> The behavior of this constructor when the given bytes are not valid
48.559 + * in the default charset is unspecified. The {@link
48.560 + * java.nio.charset.CharsetDecoder} class should be used when more control
48.561 + * over the decoding process is required.
48.562 + *
48.563 + * @param bytes
48.564 + * The bytes to be decoded into characters
48.565 + *
48.566 + * @param offset
48.567 + * The index of the first byte to decode
48.568 + *
48.569 + * @param length
48.570 + * The number of bytes to decode
48.571 + *
48.572 + * @throws IndexOutOfBoundsException
48.573 + * If the {@code offset} and the {@code length} arguments index
48.574 + * characters outside the bounds of the {@code bytes} array
48.575 + *
48.576 + * @since JDK1.1
48.577 + */
48.578 + public String(byte bytes[], int offset, int length) {
48.579 + checkBounds(bytes, offset, length);
48.580 + char[] v = new char[length];
48.581 + for (int i = 0; i < length; i++) {
48.582 + v[i] = (char)bytes[offset++];
48.583 + }
48.584 + this.offset = 0;
48.585 + this.count = v.length;
48.586 + this.value = v;
48.587 + }
48.588 +
48.589 + /**
48.590 + * Constructs a new {@code String} by decoding the specified array of bytes
48.591 + * using the platform's default charset. The length of the new {@code
48.592 + * String} is a function of the charset, and hence may not be equal to the
48.593 + * length of the byte array.
48.594 + *
48.595 + * <p> The behavior of this constructor when the given bytes are not valid
48.596 + * in the default charset is unspecified. The {@link
48.597 + * java.nio.charset.CharsetDecoder} class should be used when more control
48.598 + * over the decoding process is required.
48.599 + *
48.600 + * @param bytes
48.601 + * The bytes to be decoded into characters
48.602 + *
48.603 + * @since JDK1.1
48.604 + */
48.605 + public String(byte bytes[]) {
48.606 + this(bytes, 0, bytes.length);
48.607 + }
48.608 +
48.609 + /**
48.610 + * Allocates a new string that contains the sequence of characters
48.611 + * currently contained in the string buffer argument. The contents of the
48.612 + * string buffer are copied; subsequent modification of the string buffer
48.613 + * does not affect the newly created string.
48.614 + *
48.615 + * @param buffer
48.616 + * A {@code StringBuffer}
48.617 + */
48.618 + public String(StringBuffer buffer) {
48.619 + String result = buffer.toString();
48.620 + this.value = result.value;
48.621 + this.count = result.count;
48.622 + this.offset = result.offset;
48.623 + }
48.624 +
48.625 + /**
48.626 + * Allocates a new string that contains the sequence of characters
48.627 + * currently contained in the string builder argument. The contents of the
48.628 + * string builder are copied; subsequent modification of the string builder
48.629 + * does not affect the newly created string.
48.630 + *
48.631 + * <p> This constructor is provided to ease migration to {@code
48.632 + * StringBuilder}. Obtaining a string from a string builder via the {@code
48.633 + * toString} method is likely to run faster and is generally preferred.
48.634 + *
48.635 + * @param builder
48.636 + * A {@code StringBuilder}
48.637 + *
48.638 + * @since 1.5
48.639 + */
48.640 + public String(StringBuilder builder) {
48.641 + String result = builder.toString();
48.642 + this.value = result.value;
48.643 + this.count = result.count;
48.644 + this.offset = result.offset;
48.645 + }
48.646 +
48.647 +
48.648 + // Package private constructor which shares value array for speed.
48.649 + String(int offset, int count, char value[]) {
48.650 + this.value = value;
48.651 + this.offset = offset;
48.652 + this.count = count;
48.653 + }
48.654 +
48.655 + /**
48.656 + * Returns the length of this string.
48.657 + * The length is equal to the number of <a href="Character.html#unicode">Unicode
48.658 + * code units</a> in the string.
48.659 + *
48.660 + * @return the length of the sequence of characters represented by this
48.661 + * object.
48.662 + */
48.663 + public int length() {
48.664 + return count;
48.665 + }
48.666 +
48.667 + /**
48.668 + * Returns <tt>true</tt> if, and only if, {@link #length()} is <tt>0</tt>.
48.669 + *
48.670 + * @return <tt>true</tt> if {@link #length()} is <tt>0</tt>, otherwise
48.671 + * <tt>false</tt>
48.672 + *
48.673 + * @since 1.6
48.674 + */
48.675 + public boolean isEmpty() {
48.676 + return count == 0;
48.677 + }
48.678 +
48.679 + /**
48.680 + * Returns the <code>char</code> value at the
48.681 + * specified index. An index ranges from <code>0</code> to
48.682 + * <code>length() - 1</code>. The first <code>char</code> value of the sequence
48.683 + * is at index <code>0</code>, the next at index <code>1</code>,
48.684 + * and so on, as for array indexing.
48.685 + *
48.686 + * <p>If the <code>char</code> value specified by the index is a
48.687 + * <a href="Character.html#unicode">surrogate</a>, the surrogate
48.688 + * value is returned.
48.689 + *
48.690 + * @param index the index of the <code>char</code> value.
48.691 + * @return the <code>char</code> value at the specified index of this string.
48.692 + * The first <code>char</code> value is at index <code>0</code>.
48.693 + * @exception IndexOutOfBoundsException if the <code>index</code>
48.694 + * argument is negative or not less than the length of this
48.695 + * string.
48.696 + */
48.697 + public char charAt(int index) {
48.698 + if ((index < 0) || (index >= count)) {
48.699 + throw new StringIndexOutOfBoundsException(index);
48.700 + }
48.701 + return value[index + offset];
48.702 + }
48.703 +
48.704 + /**
48.705 + * Returns the character (Unicode code point) at the specified
48.706 + * index. The index refers to <code>char</code> values
48.707 + * (Unicode code units) and ranges from <code>0</code> to
48.708 + * {@link #length()}<code> - 1</code>.
48.709 + *
48.710 + * <p> If the <code>char</code> value specified at the given index
48.711 + * is in the high-surrogate range, the following index is less
48.712 + * than the length of this <code>String</code>, and the
48.713 + * <code>char</code> value at the following index is in the
48.714 + * low-surrogate range, then the supplementary code point
48.715 + * corresponding to this surrogate pair is returned. Otherwise,
48.716 + * the <code>char</code> value at the given index is returned.
48.717 + *
48.718 + * @param index the index to the <code>char</code> values
48.719 + * @return the code point value of the character at the
48.720 + * <code>index</code>
48.721 + * @exception IndexOutOfBoundsException if the <code>index</code>
48.722 + * argument is negative or not less than the length of this
48.723 + * string.
48.724 + * @since 1.5
48.725 + */
48.726 + public int codePointAt(int index) {
48.727 + if ((index < 0) || (index >= count)) {
48.728 + throw new StringIndexOutOfBoundsException(index);
48.729 + }
48.730 + return Character.codePointAtImpl(value, offset + index, offset + count);
48.731 + }
48.732 +
48.733 + /**
48.734 + * Returns the character (Unicode code point) before the specified
48.735 + * index. The index refers to <code>char</code> values
48.736 + * (Unicode code units) and ranges from <code>1</code> to {@link
48.737 + * CharSequence#length() length}.
48.738 + *
48.739 + * <p> If the <code>char</code> value at <code>(index - 1)</code>
48.740 + * is in the low-surrogate range, <code>(index - 2)</code> is not
48.741 + * negative, and the <code>char</code> value at <code>(index -
48.742 + * 2)</code> is in the high-surrogate range, then the
48.743 + * supplementary code point value of the surrogate pair is
48.744 + * returned. If the <code>char</code> value at <code>index -
48.745 + * 1</code> is an unpaired low-surrogate or a high-surrogate, the
48.746 + * surrogate value is returned.
48.747 + *
48.748 + * @param index the index following the code point that should be returned
48.749 + * @return the Unicode code point value before the given index.
48.750 + * @exception IndexOutOfBoundsException if the <code>index</code>
48.751 + * argument is less than 1 or greater than the length
48.752 + * of this string.
48.753 + * @since 1.5
48.754 + */
48.755 + public int codePointBefore(int index) {
48.756 + int i = index - 1;
48.757 + if ((i < 0) || (i >= count)) {
48.758 + throw new StringIndexOutOfBoundsException(index);
48.759 + }
48.760 + return Character.codePointBeforeImpl(value, offset + index, offset);
48.761 + }
48.762 +
48.763 + /**
48.764 + * Returns the number of Unicode code points in the specified text
48.765 + * range of this <code>String</code>. The text range begins at the
48.766 + * specified <code>beginIndex</code> and extends to the
48.767 + * <code>char</code> at index <code>endIndex - 1</code>. Thus the
48.768 + * length (in <code>char</code>s) of the text range is
48.769 + * <code>endIndex-beginIndex</code>. Unpaired surrogates within
48.770 + * the text range count as one code point each.
48.771 + *
48.772 + * @param beginIndex the index to the first <code>char</code> of
48.773 + * the text range.
48.774 + * @param endIndex the index after the last <code>char</code> of
48.775 + * the text range.
48.776 + * @return the number of Unicode code points in the specified text
48.777 + * range
48.778 + * @exception IndexOutOfBoundsException if the
48.779 + * <code>beginIndex</code> is negative, or <code>endIndex</code>
48.780 + * is larger than the length of this <code>String</code>, or
48.781 + * <code>beginIndex</code> is larger than <code>endIndex</code>.
48.782 + * @since 1.5
48.783 + */
48.784 + public int codePointCount(int beginIndex, int endIndex) {
48.785 + if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) {
48.786 + throw new IndexOutOfBoundsException();
48.787 + }
48.788 + return Character.codePointCountImpl(value, offset+beginIndex, endIndex-beginIndex);
48.789 + }
48.790 +
48.791 + /**
48.792 + * Returns the index within this <code>String</code> that is
48.793 + * offset from the given <code>index</code> by
48.794 + * <code>codePointOffset</code> code points. Unpaired surrogates
48.795 + * within the text range given by <code>index</code> and
48.796 + * <code>codePointOffset</code> count as one code point each.
48.797 + *
48.798 + * @param index the index to be offset
48.799 + * @param codePointOffset the offset in code points
48.800 + * @return the index within this <code>String</code>
48.801 + * @exception IndexOutOfBoundsException if <code>index</code>
48.802 + * is negative or larger then the length of this
48.803 + * <code>String</code>, or if <code>codePointOffset</code> is positive
48.804 + * and the substring starting with <code>index</code> has fewer
48.805 + * than <code>codePointOffset</code> code points,
48.806 + * or if <code>codePointOffset</code> is negative and the substring
48.807 + * before <code>index</code> has fewer than the absolute value
48.808 + * of <code>codePointOffset</code> code points.
48.809 + * @since 1.5
48.810 + */
48.811 + public int offsetByCodePoints(int index, int codePointOffset) {
48.812 + if (index < 0 || index > count) {
48.813 + throw new IndexOutOfBoundsException();
48.814 + }
48.815 + return Character.offsetByCodePointsImpl(value, offset, count,
48.816 + offset+index, codePointOffset) - offset;
48.817 + }
48.818 +
48.819 + /**
48.820 + * Copy characters from this string into dst starting at dstBegin.
48.821 + * This method doesn't perform any range checking.
48.822 + */
48.823 + void getChars(char dst[], int dstBegin) {
48.824 + arraycopy(value, offset, dst, dstBegin, count);
48.825 + }
48.826 +
48.827 + /**
48.828 + * Copies characters from this string into the destination character
48.829 + * array.
48.830 + * <p>
48.831 + * The first character to be copied is at index <code>srcBegin</code>;
48.832 + * the last character to be copied is at index <code>srcEnd-1</code>
48.833 + * (thus the total number of characters to be copied is
48.834 + * <code>srcEnd-srcBegin</code>). The characters are copied into the
48.835 + * subarray of <code>dst</code> starting at index <code>dstBegin</code>
48.836 + * and ending at index:
48.837 + * <p><blockquote><pre>
48.838 + * dstbegin + (srcEnd-srcBegin) - 1
48.839 + * </pre></blockquote>
48.840 + *
48.841 + * @param srcBegin index of the first character in the string
48.842 + * to copy.
48.843 + * @param srcEnd index after the last character in the string
48.844 + * to copy.
48.845 + * @param dst the destination array.
48.846 + * @param dstBegin the start offset in the destination array.
48.847 + * @exception IndexOutOfBoundsException If any of the following
48.848 + * is true:
48.849 + * <ul><li><code>srcBegin</code> is negative.
48.850 + * <li><code>srcBegin</code> is greater than <code>srcEnd</code>
48.851 + * <li><code>srcEnd</code> is greater than the length of this
48.852 + * string
48.853 + * <li><code>dstBegin</code> is negative
48.854 + * <li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than
48.855 + * <code>dst.length</code></ul>
48.856 + */
48.857 + public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
48.858 + if (srcBegin < 0) {
48.859 + throw new StringIndexOutOfBoundsException(srcBegin);
48.860 + }
48.861 + if (srcEnd > count) {
48.862 + throw new StringIndexOutOfBoundsException(srcEnd);
48.863 + }
48.864 + if (srcBegin > srcEnd) {
48.865 + throw new StringIndexOutOfBoundsException(srcEnd - srcBegin);
48.866 + }
48.867 + arraycopy(value, offset + srcBegin, dst, dstBegin,
48.868 + srcEnd - srcBegin);
48.869 + }
48.870 +
48.871 + /**
48.872 + * Copies characters from this string into the destination byte array. Each
48.873 + * byte receives the 8 low-order bits of the corresponding character. The
48.874 + * eight high-order bits of each character are not copied and do not
48.875 + * participate in the transfer in any way.
48.876 + *
48.877 + * <p> The first character to be copied is at index {@code srcBegin}; the
48.878 + * last character to be copied is at index {@code srcEnd-1}. The total
48.879 + * number of characters to be copied is {@code srcEnd-srcBegin}. The
48.880 + * characters, converted to bytes, are copied into the subarray of {@code
48.881 + * dst} starting at index {@code dstBegin} and ending at index:
48.882 + *
48.883 + * <blockquote><pre>
48.884 + * dstbegin + (srcEnd-srcBegin) - 1
48.885 + * </pre></blockquote>
48.886 + *
48.887 + * @deprecated This method does not properly convert characters into
48.888 + * bytes. As of JDK 1.1, the preferred way to do this is via the
48.889 + * {@link #getBytes()} method, which uses the platform's default charset.
48.890 + *
48.891 + * @param srcBegin
48.892 + * Index of the first character in the string to copy
48.893 + *
48.894 + * @param srcEnd
48.895 + * Index after the last character in the string to copy
48.896 + *
48.897 + * @param dst
48.898 + * The destination array
48.899 + *
48.900 + * @param dstBegin
48.901 + * The start offset in the destination array
48.902 + *
48.903 + * @throws IndexOutOfBoundsException
48.904 + * If any of the following is true:
48.905 + * <ul>
48.906 + * <li> {@code srcBegin} is negative
48.907 + * <li> {@code srcBegin} is greater than {@code srcEnd}
48.908 + * <li> {@code srcEnd} is greater than the length of this String
48.909 + * <li> {@code dstBegin} is negative
48.910 + * <li> {@code dstBegin+(srcEnd-srcBegin)} is larger than {@code
48.911 + * dst.length}
48.912 + * </ul>
48.913 + */
48.914 + @Deprecated
48.915 + public void getBytes(int srcBegin, int srcEnd, byte dst[], int dstBegin) {
48.916 + if (srcBegin < 0) {
48.917 + throw new StringIndexOutOfBoundsException(srcBegin);
48.918 + }
48.919 + if (srcEnd > count) {
48.920 + throw new StringIndexOutOfBoundsException(srcEnd);
48.921 + }
48.922 + if (srcBegin > srcEnd) {
48.923 + throw new StringIndexOutOfBoundsException(srcEnd - srcBegin);
48.924 + }
48.925 + int j = dstBegin;
48.926 + int n = offset + srcEnd;
48.927 + int i = offset + srcBegin;
48.928 + char[] val = value; /* avoid getfield opcode */
48.929 +
48.930 + while (i < n) {
48.931 + dst[j++] = (byte)val[i++];
48.932 + }
48.933 + }
48.934 +
48.935 + /**
48.936 + * Encodes this {@code String} into a sequence of bytes using the named
48.937 + * charset, storing the result into a new byte array.
48.938 + *
48.939 + * <p> The behavior of this method when this string cannot be encoded in
48.940 + * the given charset is unspecified. The {@link
48.941 + * java.nio.charset.CharsetEncoder} class should be used when more control
48.942 + * over the encoding process is required.
48.943 + *
48.944 + * @param charsetName
48.945 + * The name of a supported {@linkplain java.nio.charset.Charset
48.946 + * charset}
48.947 + *
48.948 + * @return The resultant byte array
48.949 + *
48.950 + * @throws UnsupportedEncodingException
48.951 + * If the named charset is not supported
48.952 + *
48.953 + * @since JDK1.1
48.954 + */
48.955 +// public byte[] getBytes(String charsetName)
48.956 +// throws UnsupportedEncodingException
48.957 +// {
48.958 +// if (charsetName == null) throw new NullPointerException();
48.959 +// return StringCoding.encode(charsetName, value, offset, count);
48.960 +// }
48.961 +
48.962 + /**
48.963 + * Encodes this {@code String} into a sequence of bytes using the given
48.964 + * {@linkplain java.nio.charset.Charset charset}, storing the result into a
48.965 + * new byte array.
48.966 + *
48.967 + * <p> This method always replaces malformed-input and unmappable-character
48.968 + * sequences with this charset's default replacement byte array. The
48.969 + * {@link java.nio.charset.CharsetEncoder} class should be used when more
48.970 + * control over the encoding process is required.
48.971 + *
48.972 + * @param charset
48.973 + * The {@linkplain java.nio.charset.Charset} to be used to encode
48.974 + * the {@code String}
48.975 + *
48.976 + * @return The resultant byte array
48.977 + *
48.978 + * @since 1.6
48.979 + */
48.980 + /* don't want dep on Charset
48.981 + public byte[] getBytes(Charset charset) {
48.982 + if (charset == null) throw new NullPointerException();
48.983 + return StringCoding.encode(charset, value, offset, count);
48.984 + }
48.985 + */
48.986 +
48.987 + /**
48.988 + * Encodes this {@code String} into a sequence of bytes using the
48.989 + * platform's default charset, storing the result into a new byte array.
48.990 + *
48.991 + * <p> The behavior of this method when this string cannot be encoded in
48.992 + * the default charset is unspecified. The {@link
48.993 + * java.nio.charset.CharsetEncoder} class should be used when more control
48.994 + * over the encoding process is required.
48.995 + *
48.996 + * @return The resultant byte array
48.997 + *
48.998 + * @since JDK1.1
48.999 + */
48.1000 + public byte[] getBytes() {
48.1001 + byte[] arr = new byte[length()];
48.1002 + for (int i = 0; i < arr.length; i++) {
48.1003 + final char v = charAt(i);
48.1004 + arr[i] = (byte)v;
48.1005 + }
48.1006 + return arr;
48.1007 + }
48.1008 +
48.1009 + /**
48.1010 + * Compares this string to the specified object. The result is {@code
48.1011 + * true} if and only if the argument is not {@code null} and is a {@code
48.1012 + * String} object that represents the same sequence of characters as this
48.1013 + * object.
48.1014 + *
48.1015 + * @param anObject
48.1016 + * The object to compare this {@code String} against
48.1017 + *
48.1018 + * @return {@code true} if the given object represents a {@code String}
48.1019 + * equivalent to this string, {@code false} otherwise
48.1020 + *
48.1021 + * @see #compareTo(String)
48.1022 + * @see #equalsIgnoreCase(String)
48.1023 + */
48.1024 + public boolean equals(Object anObject) {
48.1025 + if (this == anObject) {
48.1026 + return true;
48.1027 + }
48.1028 + if (anObject instanceof String) {
48.1029 + String anotherString = (String)anObject;
48.1030 + int n = count;
48.1031 + if (n == anotherString.count) {
48.1032 + char v1[] = value;
48.1033 + char v2[] = anotherString.value;
48.1034 + int i = offset;
48.1035 + int j = anotherString.offset;
48.1036 + while (n-- != 0) {
48.1037 + if (v1[i++] != v2[j++])
48.1038 + return false;
48.1039 + }
48.1040 + return true;
48.1041 + }
48.1042 + }
48.1043 + return false;
48.1044 + }
48.1045 +
48.1046 + /**
48.1047 + * Compares this string to the specified {@code StringBuffer}. The result
48.1048 + * is {@code true} if and only if this {@code String} represents the same
48.1049 + * sequence of characters as the specified {@code StringBuffer}.
48.1050 + *
48.1051 + * @param sb
48.1052 + * The {@code StringBuffer} to compare this {@code String} against
48.1053 + *
48.1054 + * @return {@code true} if this {@code String} represents the same
48.1055 + * sequence of characters as the specified {@code StringBuffer},
48.1056 + * {@code false} otherwise
48.1057 + *
48.1058 + * @since 1.4
48.1059 + */
48.1060 + public boolean contentEquals(StringBuffer sb) {
48.1061 + synchronized(sb) {
48.1062 + return contentEquals((CharSequence)sb);
48.1063 + }
48.1064 + }
48.1065 +
48.1066 + /**
48.1067 + * Compares this string to the specified {@code CharSequence}. The result
48.1068 + * is {@code true} if and only if this {@code String} represents the same
48.1069 + * sequence of char values as the specified sequence.
48.1070 + *
48.1071 + * @param cs
48.1072 + * The sequence to compare this {@code String} against
48.1073 + *
48.1074 + * @return {@code true} if this {@code String} represents the same
48.1075 + * sequence of char values as the specified sequence, {@code
48.1076 + * false} otherwise
48.1077 + *
48.1078 + * @since 1.5
48.1079 + */
48.1080 + public boolean contentEquals(CharSequence cs) {
48.1081 + if (count != cs.length())
48.1082 + return false;
48.1083 + // Argument is a StringBuffer, StringBuilder
48.1084 + if (cs instanceof AbstractStringBuilder) {
48.1085 + char v1[] = value;
48.1086 + char v2[] = ((AbstractStringBuilder)cs).getValue();
48.1087 + int i = offset;
48.1088 + int j = 0;
48.1089 + int n = count;
48.1090 + while (n-- != 0) {
48.1091 + if (v1[i++] != v2[j++])
48.1092 + return false;
48.1093 + }
48.1094 + return true;
48.1095 + }
48.1096 + // Argument is a String
48.1097 + if (cs.equals(this))
48.1098 + return true;
48.1099 + // Argument is a generic CharSequence
48.1100 + char v1[] = value;
48.1101 + int i = offset;
48.1102 + int j = 0;
48.1103 + int n = count;
48.1104 + while (n-- != 0) {
48.1105 + if (v1[i++] != cs.charAt(j++))
48.1106 + return false;
48.1107 + }
48.1108 + return true;
48.1109 + }
48.1110 +
48.1111 + /**
48.1112 + * Compares this {@code String} to another {@code String}, ignoring case
48.1113 + * considerations. Two strings are considered equal ignoring case if they
48.1114 + * are of the same length and corresponding characters in the two strings
48.1115 + * are equal ignoring case.
48.1116 + *
48.1117 + * <p> Two characters {@code c1} and {@code c2} are considered the same
48.1118 + * ignoring case if at least one of the following is true:
48.1119 + * <ul>
48.1120 + * <li> The two characters are the same (as compared by the
48.1121 + * {@code ==} operator)
48.1122 + * <li> Applying the method {@link
48.1123 + * java.lang.Character#toUpperCase(char)} to each character
48.1124 + * produces the same result
48.1125 + * <li> Applying the method {@link
48.1126 + * java.lang.Character#toLowerCase(char)} to each character
48.1127 + * produces the same result
48.1128 + * </ul>
48.1129 + *
48.1130 + * @param anotherString
48.1131 + * The {@code String} to compare this {@code String} against
48.1132 + *
48.1133 + * @return {@code true} if the argument is not {@code null} and it
48.1134 + * represents an equivalent {@code String} ignoring case; {@code
48.1135 + * false} otherwise
48.1136 + *
48.1137 + * @see #equals(Object)
48.1138 + */
48.1139 + public boolean equalsIgnoreCase(String anotherString) {
48.1140 + return (this == anotherString) ? true :
48.1141 + (anotherString != null) && (anotherString.count == count) &&
48.1142 + regionMatches(true, 0, anotherString, 0, count);
48.1143 + }
48.1144 +
48.1145 + /**
48.1146 + * Compares two strings lexicographically.
48.1147 + * The comparison is based on the Unicode value of each character in
48.1148 + * the strings. The character sequence represented by this
48.1149 + * <code>String</code> object is compared lexicographically to the
48.1150 + * character sequence represented by the argument string. The result is
48.1151 + * a negative integer if this <code>String</code> object
48.1152 + * lexicographically precedes the argument string. The result is a
48.1153 + * positive integer if this <code>String</code> object lexicographically
48.1154 + * follows the argument string. The result is zero if the strings
48.1155 + * are equal; <code>compareTo</code> returns <code>0</code> exactly when
48.1156 + * the {@link #equals(Object)} method would return <code>true</code>.
48.1157 + * <p>
48.1158 + * This is the definition of lexicographic ordering. If two strings are
48.1159 + * different, then either they have different characters at some index
48.1160 + * that is a valid index for both strings, or their lengths are different,
48.1161 + * or both. If they have different characters at one or more index
48.1162 + * positions, let <i>k</i> be the smallest such index; then the string
48.1163 + * whose character at position <i>k</i> has the smaller value, as
48.1164 + * determined by using the < operator, lexicographically precedes the
48.1165 + * other string. In this case, <code>compareTo</code> returns the
48.1166 + * difference of the two character values at position <code>k</code> in
48.1167 + * the two string -- that is, the value:
48.1168 + * <blockquote><pre>
48.1169 + * this.charAt(k)-anotherString.charAt(k)
48.1170 + * </pre></blockquote>
48.1171 + * If there is no index position at which they differ, then the shorter
48.1172 + * string lexicographically precedes the longer string. In this case,
48.1173 + * <code>compareTo</code> returns the difference of the lengths of the
48.1174 + * strings -- that is, the value:
48.1175 + * <blockquote><pre>
48.1176 + * this.length()-anotherString.length()
48.1177 + * </pre></blockquote>
48.1178 + *
48.1179 + * @param anotherString the <code>String</code> to be compared.
48.1180 + * @return the value <code>0</code> if the argument string is equal to
48.1181 + * this string; a value less than <code>0</code> if this string
48.1182 + * is lexicographically less than the string argument; and a
48.1183 + * value greater than <code>0</code> if this string is
48.1184 + * lexicographically greater than the string argument.
48.1185 + */
48.1186 + public int compareTo(String anotherString) {
48.1187 + int len1 = count;
48.1188 + int len2 = anotherString.count;
48.1189 + int n = Math.min(len1, len2);
48.1190 + char v1[] = value;
48.1191 + char v2[] = anotherString.value;
48.1192 + int i = offset;
48.1193 + int j = anotherString.offset;
48.1194 +
48.1195 + if (i == j) {
48.1196 + int k = i;
48.1197 + int lim = n + i;
48.1198 + while (k < lim) {
48.1199 + char c1 = v1[k];
48.1200 + char c2 = v2[k];
48.1201 + if (c1 != c2) {
48.1202 + return c1 - c2;
48.1203 + }
48.1204 + k++;
48.1205 + }
48.1206 + } else {
48.1207 + while (n-- != 0) {
48.1208 + char c1 = v1[i++];
48.1209 + char c2 = v2[j++];
48.1210 + if (c1 != c2) {
48.1211 + return c1 - c2;
48.1212 + }
48.1213 + }
48.1214 + }
48.1215 + return len1 - len2;
48.1216 + }
48.1217 +
48.1218 + /**
48.1219 + * A Comparator that orders <code>String</code> objects as by
48.1220 + * <code>compareToIgnoreCase</code>. This comparator is serializable.
48.1221 + * <p>
48.1222 + * Note that this Comparator does <em>not</em> take locale into account,
48.1223 + * and will result in an unsatisfactory ordering for certain locales.
48.1224 + * The java.text package provides <em>Collators</em> to allow
48.1225 + * locale-sensitive ordering.
48.1226 + *
48.1227 + * @see java.text.Collator#compare(String, String)
48.1228 + * @since 1.2
48.1229 + */
48.1230 + public static final Comparator<String> CASE_INSENSITIVE_ORDER
48.1231 + = new CaseInsensitiveComparator();
48.1232 + private static class CaseInsensitiveComparator
48.1233 + implements Comparator<String>, java.io.Serializable {
48.1234 + // use serialVersionUID from JDK 1.2.2 for interoperability
48.1235 + private static final long serialVersionUID = 8575799808933029326L;
48.1236 +
48.1237 + public int compare(String s1, String s2) {
48.1238 + int n1 = s1.length();
48.1239 + int n2 = s2.length();
48.1240 + int min = Math.min(n1, n2);
48.1241 + for (int i = 0; i < min; i++) {
48.1242 + char c1 = s1.charAt(i);
48.1243 + char c2 = s2.charAt(i);
48.1244 + if (c1 != c2) {
48.1245 + c1 = Character.toUpperCase(c1);
48.1246 + c2 = Character.toUpperCase(c2);
48.1247 + if (c1 != c2) {
48.1248 + c1 = Character.toLowerCase(c1);
48.1249 + c2 = Character.toLowerCase(c2);
48.1250 + if (c1 != c2) {
48.1251 + // No overflow because of numeric promotion
48.1252 + return c1 - c2;
48.1253 + }
48.1254 + }
48.1255 + }
48.1256 + }
48.1257 + return n1 - n2;
48.1258 + }
48.1259 + }
48.1260 +
48.1261 + /**
48.1262 + * Compares two strings lexicographically, ignoring case
48.1263 + * differences. This method returns an integer whose sign is that of
48.1264 + * calling <code>compareTo</code> with normalized versions of the strings
48.1265 + * where case differences have been eliminated by calling
48.1266 + * <code>Character.toLowerCase(Character.toUpperCase(character))</code> on
48.1267 + * each character.
48.1268 + * <p>
48.1269 + * Note that this method does <em>not</em> take locale into account,
48.1270 + * and will result in an unsatisfactory ordering for certain locales.
48.1271 + * The java.text package provides <em>collators</em> to allow
48.1272 + * locale-sensitive ordering.
48.1273 + *
48.1274 + * @param str the <code>String</code> to be compared.
48.1275 + * @return a negative integer, zero, or a positive integer as the
48.1276 + * specified String is greater than, equal to, or less
48.1277 + * than this String, ignoring case considerations.
48.1278 + * @see java.text.Collator#compare(String, String)
48.1279 + * @since 1.2
48.1280 + */
48.1281 + public int compareToIgnoreCase(String str) {
48.1282 + return CASE_INSENSITIVE_ORDER.compare(this, str);
48.1283 + }
48.1284 +
48.1285 + /**
48.1286 + * Tests if two string regions are equal.
48.1287 + * <p>
48.1288 + * A substring of this <tt>String</tt> object is compared to a substring
48.1289 + * of the argument other. The result is true if these substrings
48.1290 + * represent identical character sequences. The substring of this
48.1291 + * <tt>String</tt> object to be compared begins at index <tt>toffset</tt>
48.1292 + * and has length <tt>len</tt>. The substring of other to be compared
48.1293 + * begins at index <tt>ooffset</tt> and has length <tt>len</tt>. The
48.1294 + * result is <tt>false</tt> if and only if at least one of the following
48.1295 + * is true:
48.1296 + * <ul><li><tt>toffset</tt> is negative.
48.1297 + * <li><tt>ooffset</tt> is negative.
48.1298 + * <li><tt>toffset+len</tt> is greater than the length of this
48.1299 + * <tt>String</tt> object.
48.1300 + * <li><tt>ooffset+len</tt> is greater than the length of the other
48.1301 + * argument.
48.1302 + * <li>There is some nonnegative integer <i>k</i> less than <tt>len</tt>
48.1303 + * such that:
48.1304 + * <tt>this.charAt(toffset+<i>k</i>) != other.charAt(ooffset+<i>k</i>)</tt>
48.1305 + * </ul>
48.1306 + *
48.1307 + * @param toffset the starting offset of the subregion in this string.
48.1308 + * @param other the string argument.
48.1309 + * @param ooffset the starting offset of the subregion in the string
48.1310 + * argument.
48.1311 + * @param len the number of characters to compare.
48.1312 + * @return <code>true</code> if the specified subregion of this string
48.1313 + * exactly matches the specified subregion of the string argument;
48.1314 + * <code>false</code> otherwise.
48.1315 + */
48.1316 + public boolean regionMatches(int toffset, String other, int ooffset,
48.1317 + int len) {
48.1318 + char ta[] = value;
48.1319 + int to = offset + toffset;
48.1320 + char pa[] = other.value;
48.1321 + int po = other.offset + ooffset;
48.1322 + // Note: toffset, ooffset, or len might be near -1>>>1.
48.1323 + if ((ooffset < 0) || (toffset < 0) || (toffset > (long)count - len)
48.1324 + || (ooffset > (long)other.count - len)) {
48.1325 + return false;
48.1326 + }
48.1327 + while (len-- > 0) {
48.1328 + if (ta[to++] != pa[po++]) {
48.1329 + return false;
48.1330 + }
48.1331 + }
48.1332 + return true;
48.1333 + }
48.1334 +
48.1335 + /**
48.1336 + * Tests if two string regions are equal.
48.1337 + * <p>
48.1338 + * A substring of this <tt>String</tt> object is compared to a substring
48.1339 + * of the argument <tt>other</tt>. The result is <tt>true</tt> if these
48.1340 + * substrings represent character sequences that are the same, ignoring
48.1341 + * case if and only if <tt>ignoreCase</tt> is true. The substring of
48.1342 + * this <tt>String</tt> object to be compared begins at index
48.1343 + * <tt>toffset</tt> and has length <tt>len</tt>. The substring of
48.1344 + * <tt>other</tt> to be compared begins at index <tt>ooffset</tt> and
48.1345 + * has length <tt>len</tt>. The result is <tt>false</tt> if and only if
48.1346 + * at least one of the following is true:
48.1347 + * <ul><li><tt>toffset</tt> is negative.
48.1348 + * <li><tt>ooffset</tt> is negative.
48.1349 + * <li><tt>toffset+len</tt> is greater than the length of this
48.1350 + * <tt>String</tt> object.
48.1351 + * <li><tt>ooffset+len</tt> is greater than the length of the other
48.1352 + * argument.
48.1353 + * <li><tt>ignoreCase</tt> is <tt>false</tt> and there is some nonnegative
48.1354 + * integer <i>k</i> less than <tt>len</tt> such that:
48.1355 + * <blockquote><pre>
48.1356 + * this.charAt(toffset+k) != other.charAt(ooffset+k)
48.1357 + * </pre></blockquote>
48.1358 + * <li><tt>ignoreCase</tt> is <tt>true</tt> and there is some nonnegative
48.1359 + * integer <i>k</i> less than <tt>len</tt> such that:
48.1360 + * <blockquote><pre>
48.1361 + * Character.toLowerCase(this.charAt(toffset+k)) !=
48.1362 + Character.toLowerCase(other.charAt(ooffset+k))
48.1363 + * </pre></blockquote>
48.1364 + * and:
48.1365 + * <blockquote><pre>
48.1366 + * Character.toUpperCase(this.charAt(toffset+k)) !=
48.1367 + * Character.toUpperCase(other.charAt(ooffset+k))
48.1368 + * </pre></blockquote>
48.1369 + * </ul>
48.1370 + *
48.1371 + * @param ignoreCase if <code>true</code>, ignore case when comparing
48.1372 + * characters.
48.1373 + * @param toffset the starting offset of the subregion in this
48.1374 + * string.
48.1375 + * @param other the string argument.
48.1376 + * @param ooffset the starting offset of the subregion in the string
48.1377 + * argument.
48.1378 + * @param len the number of characters to compare.
48.1379 + * @return <code>true</code> if the specified subregion of this string
48.1380 + * matches the specified subregion of the string argument;
48.1381 + * <code>false</code> otherwise. Whether the matching is exact
48.1382 + * or case insensitive depends on the <code>ignoreCase</code>
48.1383 + * argument.
48.1384 + */
48.1385 + public boolean regionMatches(boolean ignoreCase, int toffset,
48.1386 + String other, int ooffset, int len) {
48.1387 + char ta[] = value;
48.1388 + int to = offset + toffset;
48.1389 + char pa[] = other.value;
48.1390 + int po = other.offset + ooffset;
48.1391 + // Note: toffset, ooffset, or len might be near -1>>>1.
48.1392 + if ((ooffset < 0) || (toffset < 0) || (toffset > (long)count - len) ||
48.1393 + (ooffset > (long)other.count - len)) {
48.1394 + return false;
48.1395 + }
48.1396 + while (len-- > 0) {
48.1397 + char c1 = ta[to++];
48.1398 + char c2 = pa[po++];
48.1399 + if (c1 == c2) {
48.1400 + continue;
48.1401 + }
48.1402 + if (ignoreCase) {
48.1403 + // If characters don't match but case may be ignored,
48.1404 + // try converting both characters to uppercase.
48.1405 + // If the results match, then the comparison scan should
48.1406 + // continue.
48.1407 + char u1 = Character.toUpperCase(c1);
48.1408 + char u2 = Character.toUpperCase(c2);
48.1409 + if (u1 == u2) {
48.1410 + continue;
48.1411 + }
48.1412 + // Unfortunately, conversion to uppercase does not work properly
48.1413 + // for the Georgian alphabet, which has strange rules about case
48.1414 + // conversion. So we need to make one last check before
48.1415 + // exiting.
48.1416 + if (Character.toLowerCase(u1) == Character.toLowerCase(u2)) {
48.1417 + continue;
48.1418 + }
48.1419 + }
48.1420 + return false;
48.1421 + }
48.1422 + return true;
48.1423 + }
48.1424 +
48.1425 + /**
48.1426 + * Tests if the substring of this string beginning at the
48.1427 + * specified index starts with the specified prefix.
48.1428 + *
48.1429 + * @param prefix the prefix.
48.1430 + * @param toffset where to begin looking in this string.
48.1431 + * @return <code>true</code> if the character sequence represented by the
48.1432 + * argument is a prefix of the substring of this object starting
48.1433 + * at index <code>toffset</code>; <code>false</code> otherwise.
48.1434 + * The result is <code>false</code> if <code>toffset</code> is
48.1435 + * negative or greater than the length of this
48.1436 + * <code>String</code> object; otherwise the result is the same
48.1437 + * as the result of the expression
48.1438 + * <pre>
48.1439 + * this.substring(toffset).startsWith(prefix)
48.1440 + * </pre>
48.1441 + */
48.1442 + public boolean startsWith(String prefix, int toffset) {
48.1443 + char ta[] = value;
48.1444 + int to = offset + toffset;
48.1445 + char pa[] = prefix.value;
48.1446 + int po = prefix.offset;
48.1447 + int pc = prefix.count;
48.1448 + // Note: toffset might be near -1>>>1.
48.1449 + if ((toffset < 0) || (toffset > count - pc)) {
48.1450 + return false;
48.1451 + }
48.1452 + while (--pc >= 0) {
48.1453 + if (ta[to++] != pa[po++]) {
48.1454 + return false;
48.1455 + }
48.1456 + }
48.1457 + return true;
48.1458 + }
48.1459 +
48.1460 + /**
48.1461 + * Tests if this string starts with the specified prefix.
48.1462 + *
48.1463 + * @param prefix the prefix.
48.1464 + * @return <code>true</code> if the character sequence represented by the
48.1465 + * argument is a prefix of the character sequence represented by
48.1466 + * this string; <code>false</code> otherwise.
48.1467 + * Note also that <code>true</code> will be returned if the
48.1468 + * argument is an empty string or is equal to this
48.1469 + * <code>String</code> object as determined by the
48.1470 + * {@link #equals(Object)} method.
48.1471 + * @since 1. 0
48.1472 + */
48.1473 + public boolean startsWith(String prefix) {
48.1474 + return startsWith(prefix, 0);
48.1475 + }
48.1476 +
48.1477 + /**
48.1478 + * Tests if this string ends with the specified suffix.
48.1479 + *
48.1480 + * @param suffix the suffix.
48.1481 + * @return <code>true</code> if the character sequence represented by the
48.1482 + * argument is a suffix of the character sequence represented by
48.1483 + * this object; <code>false</code> otherwise. Note that the
48.1484 + * result will be <code>true</code> if the argument is the
48.1485 + * empty string or is equal to this <code>String</code> object
48.1486 + * as determined by the {@link #equals(Object)} method.
48.1487 + */
48.1488 + public boolean endsWith(String suffix) {
48.1489 + return startsWith(suffix, count - suffix.count);
48.1490 + }
48.1491 +
48.1492 + /**
48.1493 + * Returns a hash code for this string. The hash code for a
48.1494 + * <code>String</code> object is computed as
48.1495 + * <blockquote><pre>
48.1496 + * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
48.1497 + * </pre></blockquote>
48.1498 + * using <code>int</code> arithmetic, where <code>s[i]</code> is the
48.1499 + * <i>i</i>th character of the string, <code>n</code> is the length of
48.1500 + * the string, and <code>^</code> indicates exponentiation.
48.1501 + * (The hash value of the empty string is zero.)
48.1502 + *
48.1503 + * @return a hash code value for this object.
48.1504 + */
48.1505 + public int hashCode() {
48.1506 + int h = hash;
48.1507 + if (h == 0 && count > 0) {
48.1508 + int off = offset;
48.1509 + char val[] = value;
48.1510 + int len = count;
48.1511 +
48.1512 + for (int i = 0; i < len; i++) {
48.1513 + h = 31*h + val[off++];
48.1514 + }
48.1515 + hash = h;
48.1516 + }
48.1517 + return h;
48.1518 + }
48.1519 +
48.1520 + /**
48.1521 + * Returns the index within this string of the first occurrence of
48.1522 + * the specified character. If a character with value
48.1523 + * <code>ch</code> occurs in the character sequence represented by
48.1524 + * this <code>String</code> object, then the index (in Unicode
48.1525 + * code units) of the first such occurrence is returned. For
48.1526 + * values of <code>ch</code> in the range from 0 to 0xFFFF
48.1527 + * (inclusive), this is the smallest value <i>k</i> such that:
48.1528 + * <blockquote><pre>
48.1529 + * this.charAt(<i>k</i>) == ch
48.1530 + * </pre></blockquote>
48.1531 + * is true. For other values of <code>ch</code>, it is the
48.1532 + * smallest value <i>k</i> such that:
48.1533 + * <blockquote><pre>
48.1534 + * this.codePointAt(<i>k</i>) == ch
48.1535 + * </pre></blockquote>
48.1536 + * is true. In either case, if no such character occurs in this
48.1537 + * string, then <code>-1</code> is returned.
48.1538 + *
48.1539 + * @param ch a character (Unicode code point).
48.1540 + * @return the index of the first occurrence of the character in the
48.1541 + * character sequence represented by this object, or
48.1542 + * <code>-1</code> if the character does not occur.
48.1543 + */
48.1544 + public int indexOf(int ch) {
48.1545 + return indexOf(ch, 0);
48.1546 + }
48.1547 +
48.1548 + /**
48.1549 + * Returns the index within this string of the first occurrence of the
48.1550 + * specified character, starting the search at the specified index.
48.1551 + * <p>
48.1552 + * If a character with value <code>ch</code> occurs in the
48.1553 + * character sequence represented by this <code>String</code>
48.1554 + * object at an index no smaller than <code>fromIndex</code>, then
48.1555 + * the index of the first such occurrence is returned. For values
48.1556 + * of <code>ch</code> in the range from 0 to 0xFFFF (inclusive),
48.1557 + * this is the smallest value <i>k</i> such that:
48.1558 + * <blockquote><pre>
48.1559 + * (this.charAt(<i>k</i>) == ch) && (<i>k</i> >= fromIndex)
48.1560 + * </pre></blockquote>
48.1561 + * is true. For other values of <code>ch</code>, it is the
48.1562 + * smallest value <i>k</i> such that:
48.1563 + * <blockquote><pre>
48.1564 + * (this.codePointAt(<i>k</i>) == ch) && (<i>k</i> >= fromIndex)
48.1565 + * </pre></blockquote>
48.1566 + * is true. In either case, if no such character occurs in this
48.1567 + * string at or after position <code>fromIndex</code>, then
48.1568 + * <code>-1</code> is returned.
48.1569 + *
48.1570 + * <p>
48.1571 + * There is no restriction on the value of <code>fromIndex</code>. If it
48.1572 + * is negative, it has the same effect as if it were zero: this entire
48.1573 + * string may be searched. If it is greater than the length of this
48.1574 + * string, it has the same effect as if it were equal to the length of
48.1575 + * this string: <code>-1</code> is returned.
48.1576 + *
48.1577 + * <p>All indices are specified in <code>char</code> values
48.1578 + * (Unicode code units).
48.1579 + *
48.1580 + * @param ch a character (Unicode code point).
48.1581 + * @param fromIndex the index to start the search from.
48.1582 + * @return the index of the first occurrence of the character in the
48.1583 + * character sequence represented by this object that is greater
48.1584 + * than or equal to <code>fromIndex</code>, or <code>-1</code>
48.1585 + * if the character does not occur.
48.1586 + */
48.1587 + public int indexOf(int ch, int fromIndex) {
48.1588 + if (fromIndex < 0) {
48.1589 + fromIndex = 0;
48.1590 + } else if (fromIndex >= count) {
48.1591 + // Note: fromIndex might be near -1>>>1.
48.1592 + return -1;
48.1593 + }
48.1594 +
48.1595 + if (ch < Character.MIN_SUPPLEMENTARY_CODE_POINT) {
48.1596 + // handle most cases here (ch is a BMP code point or a
48.1597 + // negative value (invalid code point))
48.1598 + final char[] value = this.value;
48.1599 + final int offset = this.offset;
48.1600 + final int max = offset + count;
48.1601 + for (int i = offset + fromIndex; i < max ; i++) {
48.1602 + if (value[i] == ch) {
48.1603 + return i - offset;
48.1604 + }
48.1605 + }
48.1606 + return -1;
48.1607 + } else {
48.1608 + return indexOfSupplementary(ch, fromIndex);
48.1609 + }
48.1610 + }
48.1611 +
48.1612 + /**
48.1613 + * Handles (rare) calls of indexOf with a supplementary character.
48.1614 + */
48.1615 + private int indexOfSupplementary(int ch, int fromIndex) {
48.1616 + if (Character.isValidCodePoint(ch)) {
48.1617 + final char[] value = this.value;
48.1618 + final int offset = this.offset;
48.1619 + final char hi = Character.highSurrogate(ch);
48.1620 + final char lo = Character.lowSurrogate(ch);
48.1621 + final int max = offset + count - 1;
48.1622 + for (int i = offset + fromIndex; i < max; i++) {
48.1623 + if (value[i] == hi && value[i+1] == lo) {
48.1624 + return i - offset;
48.1625 + }
48.1626 + }
48.1627 + }
48.1628 + return -1;
48.1629 + }
48.1630 +
48.1631 + /**
48.1632 + * Returns the index within this string of the last occurrence of
48.1633 + * the specified character. For values of <code>ch</code> in the
48.1634 + * range from 0 to 0xFFFF (inclusive), the index (in Unicode code
48.1635 + * units) returned is the largest value <i>k</i> such that:
48.1636 + * <blockquote><pre>
48.1637 + * this.charAt(<i>k</i>) == ch
48.1638 + * </pre></blockquote>
48.1639 + * is true. For other values of <code>ch</code>, it is the
48.1640 + * largest value <i>k</i> such that:
48.1641 + * <blockquote><pre>
48.1642 + * this.codePointAt(<i>k</i>) == ch
48.1643 + * </pre></blockquote>
48.1644 + * is true. In either case, if no such character occurs in this
48.1645 + * string, then <code>-1</code> is returned. The
48.1646 + * <code>String</code> is searched backwards starting at the last
48.1647 + * character.
48.1648 + *
48.1649 + * @param ch a character (Unicode code point).
48.1650 + * @return the index of the last occurrence of the character in the
48.1651 + * character sequence represented by this object, or
48.1652 + * <code>-1</code> if the character does not occur.
48.1653 + */
48.1654 + public int lastIndexOf(int ch) {
48.1655 + return lastIndexOf(ch, count - 1);
48.1656 + }
48.1657 +
48.1658 + /**
48.1659 + * Returns the index within this string of the last occurrence of
48.1660 + * the specified character, searching backward starting at the
48.1661 + * specified index. For values of <code>ch</code> in the range
48.1662 + * from 0 to 0xFFFF (inclusive), the index returned is the largest
48.1663 + * value <i>k</i> such that:
48.1664 + * <blockquote><pre>
48.1665 + * (this.charAt(<i>k</i>) == ch) && (<i>k</i> <= fromIndex)
48.1666 + * </pre></blockquote>
48.1667 + * is true. For other values of <code>ch</code>, it is the
48.1668 + * largest value <i>k</i> such that:
48.1669 + * <blockquote><pre>
48.1670 + * (this.codePointAt(<i>k</i>) == ch) && (<i>k</i> <= fromIndex)
48.1671 + * </pre></blockquote>
48.1672 + * is true. In either case, if no such character occurs in this
48.1673 + * string at or before position <code>fromIndex</code>, then
48.1674 + * <code>-1</code> is returned.
48.1675 + *
48.1676 + * <p>All indices are specified in <code>char</code> values
48.1677 + * (Unicode code units).
48.1678 + *
48.1679 + * @param ch a character (Unicode code point).
48.1680 + * @param fromIndex the index to start the search from. There is no
48.1681 + * restriction on the value of <code>fromIndex</code>. If it is
48.1682 + * greater than or equal to the length of this string, it has
48.1683 + * the same effect as if it were equal to one less than the
48.1684 + * length of this string: this entire string may be searched.
48.1685 + * If it is negative, it has the same effect as if it were -1:
48.1686 + * -1 is returned.
48.1687 + * @return the index of the last occurrence of the character in the
48.1688 + * character sequence represented by this object that is less
48.1689 + * than or equal to <code>fromIndex</code>, or <code>-1</code>
48.1690 + * if the character does not occur before that point.
48.1691 + */
48.1692 + public int lastIndexOf(int ch, int fromIndex) {
48.1693 + if (ch < Character.MIN_SUPPLEMENTARY_CODE_POINT) {
48.1694 + // handle most cases here (ch is a BMP code point or a
48.1695 + // negative value (invalid code point))
48.1696 + final char[] value = this.value;
48.1697 + final int offset = this.offset;
48.1698 + int i = offset + Math.min(fromIndex, count - 1);
48.1699 + for (; i >= offset ; i--) {
48.1700 + if (value[i] == ch) {
48.1701 + return i - offset;
48.1702 + }
48.1703 + }
48.1704 + return -1;
48.1705 + } else {
48.1706 + return lastIndexOfSupplementary(ch, fromIndex);
48.1707 + }
48.1708 + }
48.1709 +
48.1710 + /**
48.1711 + * Handles (rare) calls of lastIndexOf with a supplementary character.
48.1712 + */
48.1713 + private int lastIndexOfSupplementary(int ch, int fromIndex) {
48.1714 + if (Character.isValidCodePoint(ch)) {
48.1715 + final char[] value = this.value;
48.1716 + final int offset = this.offset;
48.1717 + char hi = Character.highSurrogate(ch);
48.1718 + char lo = Character.lowSurrogate(ch);
48.1719 + int i = offset + Math.min(fromIndex, count - 2);
48.1720 + for (; i >= offset; i--) {
48.1721 + if (value[i] == hi && value[i+1] == lo) {
48.1722 + return i - offset;
48.1723 + }
48.1724 + }
48.1725 + }
48.1726 + return -1;
48.1727 + }
48.1728 +
48.1729 + /**
48.1730 + * Returns the index within this string of the first occurrence of the
48.1731 + * specified substring.
48.1732 + *
48.1733 + * <p>The returned index is the smallest value <i>k</i> for which:
48.1734 + * <blockquote><pre>
48.1735 + * this.startsWith(str, <i>k</i>)
48.1736 + * </pre></blockquote>
48.1737 + * If no such value of <i>k</i> exists, then {@code -1} is returned.
48.1738 + *
48.1739 + * @param str the substring to search for.
48.1740 + * @return the index of the first occurrence of the specified substring,
48.1741 + * or {@code -1} if there is no such occurrence.
48.1742 + */
48.1743 + public int indexOf(String str) {
48.1744 + return indexOf(str, 0);
48.1745 + }
48.1746 +
48.1747 + /**
48.1748 + * Returns the index within this string of the first occurrence of the
48.1749 + * specified substring, starting at the specified index.
48.1750 + *
48.1751 + * <p>The returned index is the smallest value <i>k</i> for which:
48.1752 + * <blockquote><pre>
48.1753 + * <i>k</i> >= fromIndex && this.startsWith(str, <i>k</i>)
48.1754 + * </pre></blockquote>
48.1755 + * If no such value of <i>k</i> exists, then {@code -1} is returned.
48.1756 + *
48.1757 + * @param str the substring to search for.
48.1758 + * @param fromIndex the index from which to start the search.
48.1759 + * @return the index of the first occurrence of the specified substring,
48.1760 + * starting at the specified index,
48.1761 + * or {@code -1} if there is no such occurrence.
48.1762 + */
48.1763 + public int indexOf(String str, int fromIndex) {
48.1764 + return indexOf(value, offset, count,
48.1765 + str.value, str.offset, str.count, fromIndex);
48.1766 + }
48.1767 +
48.1768 + /**
48.1769 + * Code shared by String and StringBuffer to do searches. The
48.1770 + * source is the character array being searched, and the target
48.1771 + * is the string being searched for.
48.1772 + *
48.1773 + * @param source the characters being searched.
48.1774 + * @param sourceOffset offset of the source string.
48.1775 + * @param sourceCount count of the source string.
48.1776 + * @param target the characters being searched for.
48.1777 + * @param targetOffset offset of the target string.
48.1778 + * @param targetCount count of the target string.
48.1779 + * @param fromIndex the index to begin searching from.
48.1780 + */
48.1781 + static int indexOf(char[] source, int sourceOffset, int sourceCount,
48.1782 + char[] target, int targetOffset, int targetCount,
48.1783 + int fromIndex) {
48.1784 + if (fromIndex >= sourceCount) {
48.1785 + return (targetCount == 0 ? sourceCount : -1);
48.1786 + }
48.1787 + if (fromIndex < 0) {
48.1788 + fromIndex = 0;
48.1789 + }
48.1790 + if (targetCount == 0) {
48.1791 + return fromIndex;
48.1792 + }
48.1793 +
48.1794 + char first = target[targetOffset];
48.1795 + int max = sourceOffset + (sourceCount - targetCount);
48.1796 +
48.1797 + for (int i = sourceOffset + fromIndex; i <= max; i++) {
48.1798 + /* Look for first character. */
48.1799 + if (source[i] != first) {
48.1800 + while (++i <= max && source[i] != first);
48.1801 + }
48.1802 +
48.1803 + /* Found first character, now look at the rest of v2 */
48.1804 + if (i <= max) {
48.1805 + int j = i + 1;
48.1806 + int end = j + targetCount - 1;
48.1807 + for (int k = targetOffset + 1; j < end && source[j] ==
48.1808 + target[k]; j++, k++);
48.1809 +
48.1810 + if (j == end) {
48.1811 + /* Found whole string. */
48.1812 + return i - sourceOffset;
48.1813 + }
48.1814 + }
48.1815 + }
48.1816 + return -1;
48.1817 + }
48.1818 +
48.1819 + /**
48.1820 + * Returns the index within this string of the last occurrence of the
48.1821 + * specified substring. The last occurrence of the empty string ""
48.1822 + * is considered to occur at the index value {@code this.length()}.
48.1823 + *
48.1824 + * <p>The returned index is the largest value <i>k</i> for which:
48.1825 + * <blockquote><pre>
48.1826 + * this.startsWith(str, <i>k</i>)
48.1827 + * </pre></blockquote>
48.1828 + * If no such value of <i>k</i> exists, then {@code -1} is returned.
48.1829 + *
48.1830 + * @param str the substring to search for.
48.1831 + * @return the index of the last occurrence of the specified substring,
48.1832 + * or {@code -1} if there is no such occurrence.
48.1833 + */
48.1834 + public int lastIndexOf(String str) {
48.1835 + return lastIndexOf(str, count);
48.1836 + }
48.1837 +
48.1838 + /**
48.1839 + * Returns the index within this string of the last occurrence of the
48.1840 + * specified substring, searching backward starting at the specified index.
48.1841 + *
48.1842 + * <p>The returned index is the largest value <i>k</i> for which:
48.1843 + * <blockquote><pre>
48.1844 + * <i>k</i> <= fromIndex && this.startsWith(str, <i>k</i>)
48.1845 + * </pre></blockquote>
48.1846 + * If no such value of <i>k</i> exists, then {@code -1} is returned.
48.1847 + *
48.1848 + * @param str the substring to search for.
48.1849 + * @param fromIndex the index to start the search from.
48.1850 + * @return the index of the last occurrence of the specified substring,
48.1851 + * searching backward from the specified index,
48.1852 + * or {@code -1} if there is no such occurrence.
48.1853 + */
48.1854 + public int lastIndexOf(String str, int fromIndex) {
48.1855 + return lastIndexOf(value, offset, count,
48.1856 + str.value, str.offset, str.count, fromIndex);
48.1857 + }
48.1858 +
48.1859 + /**
48.1860 + * Code shared by String and StringBuffer to do searches. The
48.1861 + * source is the character array being searched, and the target
48.1862 + * is the string being searched for.
48.1863 + *
48.1864 + * @param source the characters being searched.
48.1865 + * @param sourceOffset offset of the source string.
48.1866 + * @param sourceCount count of the source string.
48.1867 + * @param target the characters being searched for.
48.1868 + * @param targetOffset offset of the target string.
48.1869 + * @param targetCount count of the target string.
48.1870 + * @param fromIndex the index to begin searching from.
48.1871 + */
48.1872 + static int lastIndexOf(char[] source, int sourceOffset, int sourceCount,
48.1873 + char[] target, int targetOffset, int targetCount,
48.1874 + int fromIndex) {
48.1875 + /*
48.1876 + * Check arguments; return immediately where possible. For
48.1877 + * consistency, don't check for null str.
48.1878 + */
48.1879 + int rightIndex = sourceCount - targetCount;
48.1880 + if (fromIndex < 0) {
48.1881 + return -1;
48.1882 + }
48.1883 + if (fromIndex > rightIndex) {
48.1884 + fromIndex = rightIndex;
48.1885 + }
48.1886 + /* Empty string always matches. */
48.1887 + if (targetCount == 0) {
48.1888 + return fromIndex;
48.1889 + }
48.1890 +
48.1891 + int strLastIndex = targetOffset + targetCount - 1;
48.1892 + char strLastChar = target[strLastIndex];
48.1893 + int min = sourceOffset + targetCount - 1;
48.1894 + int i = min + fromIndex;
48.1895 +
48.1896 + startSearchForLastChar:
48.1897 + while (true) {
48.1898 + while (i >= min && source[i] != strLastChar) {
48.1899 + i--;
48.1900 + }
48.1901 + if (i < min) {
48.1902 + return -1;
48.1903 + }
48.1904 + int j = i - 1;
48.1905 + int start = j - (targetCount - 1);
48.1906 + int k = strLastIndex - 1;
48.1907 +
48.1908 + while (j > start) {
48.1909 + if (source[j--] != target[k--]) {
48.1910 + i--;
48.1911 + continue startSearchForLastChar;
48.1912 + }
48.1913 + }
48.1914 + return start - sourceOffset + 1;
48.1915 + }
48.1916 + }
48.1917 +
48.1918 + /**
48.1919 + * Returns a new string that is a substring of this string. The
48.1920 + * substring begins with the character at the specified index and
48.1921 + * extends to the end of this string. <p>
48.1922 + * Examples:
48.1923 + * <blockquote><pre>
48.1924 + * "unhappy".substring(2) returns "happy"
48.1925 + * "Harbison".substring(3) returns "bison"
48.1926 + * "emptiness".substring(9) returns "" (an empty string)
48.1927 + * </pre></blockquote>
48.1928 + *
48.1929 + * @param beginIndex the beginning index, inclusive.
48.1930 + * @return the specified substring.
48.1931 + * @exception IndexOutOfBoundsException if
48.1932 + * <code>beginIndex</code> is negative or larger than the
48.1933 + * length of this <code>String</code> object.
48.1934 + */
48.1935 + public String substring(int beginIndex) {
48.1936 + return substring(beginIndex, count);
48.1937 + }
48.1938 +
48.1939 + /**
48.1940 + * Returns a new string that is a substring of this string. The
48.1941 + * substring begins at the specified <code>beginIndex</code> and
48.1942 + * extends to the character at index <code>endIndex - 1</code>.
48.1943 + * Thus the length of the substring is <code>endIndex-beginIndex</code>.
48.1944 + * <p>
48.1945 + * Examples:
48.1946 + * <blockquote><pre>
48.1947 + * "hamburger".substring(4, 8) returns "urge"
48.1948 + * "smiles".substring(1, 5) returns "mile"
48.1949 + * </pre></blockquote>
48.1950 + *
48.1951 + * @param beginIndex the beginning index, inclusive.
48.1952 + * @param endIndex the ending index, exclusive.
48.1953 + * @return the specified substring.
48.1954 + * @exception IndexOutOfBoundsException if the
48.1955 + * <code>beginIndex</code> is negative, or
48.1956 + * <code>endIndex</code> is larger than the length of
48.1957 + * this <code>String</code> object, or
48.1958 + * <code>beginIndex</code> is larger than
48.1959 + * <code>endIndex</code>.
48.1960 + */
48.1961 + public String substring(int beginIndex, int endIndex) {
48.1962 + if (beginIndex < 0) {
48.1963 + throw new StringIndexOutOfBoundsException(beginIndex);
48.1964 + }
48.1965 + if (endIndex > count) {
48.1966 + throw new StringIndexOutOfBoundsException(endIndex);
48.1967 + }
48.1968 + if (beginIndex > endIndex) {
48.1969 + throw new StringIndexOutOfBoundsException(endIndex - beginIndex);
48.1970 + }
48.1971 + return ((beginIndex == 0) && (endIndex == count)) ? this :
48.1972 + new String(offset + beginIndex, endIndex - beginIndex, value);
48.1973 + }
48.1974 +
48.1975 + /**
48.1976 + * Returns a new character sequence that is a subsequence of this sequence.
48.1977 + *
48.1978 + * <p> An invocation of this method of the form
48.1979 + *
48.1980 + * <blockquote><pre>
48.1981 + * str.subSequence(begin, end)</pre></blockquote>
48.1982 + *
48.1983 + * behaves in exactly the same way as the invocation
48.1984 + *
48.1985 + * <blockquote><pre>
48.1986 + * str.substring(begin, end)</pre></blockquote>
48.1987 + *
48.1988 + * This method is defined so that the <tt>String</tt> class can implement
48.1989 + * the {@link CharSequence} interface. </p>
48.1990 + *
48.1991 + * @param beginIndex the begin index, inclusive.
48.1992 + * @param endIndex the end index, exclusive.
48.1993 + * @return the specified subsequence.
48.1994 + *
48.1995 + * @throws IndexOutOfBoundsException
48.1996 + * if <tt>beginIndex</tt> or <tt>endIndex</tt> are negative,
48.1997 + * if <tt>endIndex</tt> is greater than <tt>length()</tt>,
48.1998 + * or if <tt>beginIndex</tt> is greater than <tt>startIndex</tt>
48.1999 + *
48.2000 + * @since 1.4
48.2001 + * @spec JSR-51
48.2002 + */
48.2003 + public CharSequence subSequence(int beginIndex, int endIndex) {
48.2004 + return this.substring(beginIndex, endIndex);
48.2005 + }
48.2006 +
48.2007 + /**
48.2008 + * Concatenates the specified string to the end of this string.
48.2009 + * <p>
48.2010 + * If the length of the argument string is <code>0</code>, then this
48.2011 + * <code>String</code> object is returned. Otherwise, a new
48.2012 + * <code>String</code> object is created, representing a character
48.2013 + * sequence that is the concatenation of the character sequence
48.2014 + * represented by this <code>String</code> object and the character
48.2015 + * sequence represented by the argument string.<p>
48.2016 + * Examples:
48.2017 + * <blockquote><pre>
48.2018 + * "cares".concat("s") returns "caress"
48.2019 + * "to".concat("get").concat("her") returns "together"
48.2020 + * </pre></blockquote>
48.2021 + *
48.2022 + * @param str the <code>String</code> that is concatenated to the end
48.2023 + * of this <code>String</code>.
48.2024 + * @return a string that represents the concatenation of this object's
48.2025 + * characters followed by the string argument's characters.
48.2026 + */
48.2027 + public String concat(String str) {
48.2028 + int otherLen = str.length();
48.2029 + if (otherLen == 0) {
48.2030 + return this;
48.2031 + }
48.2032 + char buf[] = new char[count + otherLen];
48.2033 + getChars(0, count, buf, 0);
48.2034 + str.getChars(0, otherLen, buf, count);
48.2035 + return new String(0, count + otherLen, buf);
48.2036 + }
48.2037 +
48.2038 + /**
48.2039 + * Returns a new string resulting from replacing all occurrences of
48.2040 + * <code>oldChar</code> in this string with <code>newChar</code>.
48.2041 + * <p>
48.2042 + * If the character <code>oldChar</code> does not occur in the
48.2043 + * character sequence represented by this <code>String</code> object,
48.2044 + * then a reference to this <code>String</code> object is returned.
48.2045 + * Otherwise, a new <code>String</code> object is created that
48.2046 + * represents a character sequence identical to the character sequence
48.2047 + * represented by this <code>String</code> object, except that every
48.2048 + * occurrence of <code>oldChar</code> is replaced by an occurrence
48.2049 + * of <code>newChar</code>.
48.2050 + * <p>
48.2051 + * Examples:
48.2052 + * <blockquote><pre>
48.2053 + * "mesquite in your cellar".replace('e', 'o')
48.2054 + * returns "mosquito in your collar"
48.2055 + * "the war of baronets".replace('r', 'y')
48.2056 + * returns "the way of bayonets"
48.2057 + * "sparring with a purple porpoise".replace('p', 't')
48.2058 + * returns "starring with a turtle tortoise"
48.2059 + * "JonL".replace('q', 'x') returns "JonL" (no change)
48.2060 + * </pre></blockquote>
48.2061 + *
48.2062 + * @param oldChar the old character.
48.2063 + * @param newChar the new character.
48.2064 + * @return a string derived from this string by replacing every
48.2065 + * occurrence of <code>oldChar</code> with <code>newChar</code>.
48.2066 + */
48.2067 + public String replace(char oldChar, char newChar) {
48.2068 + if (oldChar != newChar) {
48.2069 + int len = count;
48.2070 + int i = -1;
48.2071 + char[] val = value; /* avoid getfield opcode */
48.2072 + int off = offset; /* avoid getfield opcode */
48.2073 +
48.2074 + while (++i < len) {
48.2075 + if (val[off + i] == oldChar) {
48.2076 + break;
48.2077 + }
48.2078 + }
48.2079 + if (i < len) {
48.2080 + char buf[] = new char[len];
48.2081 + for (int j = 0 ; j < i ; j++) {
48.2082 + buf[j] = val[off+j];
48.2083 + }
48.2084 + while (i < len) {
48.2085 + char c = val[off + i];
48.2086 + buf[i] = (c == oldChar) ? newChar : c;
48.2087 + i++;
48.2088 + }
48.2089 + return new String(0, len, buf);
48.2090 + }
48.2091 + }
48.2092 + return this;
48.2093 + }
48.2094 +
48.2095 + /**
48.2096 + * Tells whether or not this string matches the given <a
48.2097 + * href="../util/regex/Pattern.html#sum">regular expression</a>.
48.2098 + *
48.2099 + * <p> An invocation of this method of the form
48.2100 + * <i>str</i><tt>.matches(</tt><i>regex</i><tt>)</tt> yields exactly the
48.2101 + * same result as the expression
48.2102 + *
48.2103 + * <blockquote><tt> {@link java.util.regex.Pattern}.{@link
48.2104 + * java.util.regex.Pattern#matches(String,CharSequence)
48.2105 + * matches}(</tt><i>regex</i><tt>,</tt> <i>str</i><tt>)</tt></blockquote>
48.2106 + *
48.2107 + * @param regex
48.2108 + * the regular expression to which this string is to be matched
48.2109 + *
48.2110 + * @return <tt>true</tt> if, and only if, this string matches the
48.2111 + * given regular expression
48.2112 + *
48.2113 + * @throws PatternSyntaxException
48.2114 + * if the regular expression's syntax is invalid
48.2115 + *
48.2116 + * @see java.util.regex.Pattern
48.2117 + *
48.2118 + * @since 1.4
48.2119 + * @spec JSR-51
48.2120 + */
48.2121 + public boolean matches(String regex) {
48.2122 + throw new UnsupportedOperationException();
48.2123 + }
48.2124 +
48.2125 + /**
48.2126 + * Returns true if and only if this string contains the specified
48.2127 + * sequence of char values.
48.2128 + *
48.2129 + * @param s the sequence to search for
48.2130 + * @return true if this string contains <code>s</code>, false otherwise
48.2131 + * @throws NullPointerException if <code>s</code> is <code>null</code>
48.2132 + * @since 1.5
48.2133 + */
48.2134 + public boolean contains(CharSequence s) {
48.2135 + return indexOf(s.toString()) > -1;
48.2136 + }
48.2137 +
48.2138 + /**
48.2139 + * Replaces the first substring of this string that matches the given <a
48.2140 + * href="../util/regex/Pattern.html#sum">regular expression</a> with the
48.2141 + * given replacement.
48.2142 + *
48.2143 + * <p> An invocation of this method of the form
48.2144 + * <i>str</i><tt>.replaceFirst(</tt><i>regex</i><tt>,</tt> <i>repl</i><tt>)</tt>
48.2145 + * yields exactly the same result as the expression
48.2146 + *
48.2147 + * <blockquote><tt>
48.2148 + * {@link java.util.regex.Pattern}.{@link java.util.regex.Pattern#compile
48.2149 + * compile}(</tt><i>regex</i><tt>).{@link
48.2150 + * java.util.regex.Pattern#matcher(java.lang.CharSequence)
48.2151 + * matcher}(</tt><i>str</i><tt>).{@link java.util.regex.Matcher#replaceFirst
48.2152 + * replaceFirst}(</tt><i>repl</i><tt>)</tt></blockquote>
48.2153 + *
48.2154 + *<p>
48.2155 + * Note that backslashes (<tt>\</tt>) and dollar signs (<tt>$</tt>) in the
48.2156 + * replacement string may cause the results to be different than if it were
48.2157 + * being treated as a literal replacement string; see
48.2158 + * {@link java.util.regex.Matcher#replaceFirst}.
48.2159 + * Use {@link java.util.regex.Matcher#quoteReplacement} to suppress the special
48.2160 + * meaning of these characters, if desired.
48.2161 + *
48.2162 + * @param regex
48.2163 + * the regular expression to which this string is to be matched
48.2164 + * @param replacement
48.2165 + * the string to be substituted for the first match
48.2166 + *
48.2167 + * @return The resulting <tt>String</tt>
48.2168 + *
48.2169 + * @throws PatternSyntaxException
48.2170 + * if the regular expression's syntax is invalid
48.2171 + *
48.2172 + * @see java.util.regex.Pattern
48.2173 + *
48.2174 + * @since 1.4
48.2175 + * @spec JSR-51
48.2176 + */
48.2177 + public String replaceFirst(String regex, String replacement) {
48.2178 + throw new UnsupportedOperationException();
48.2179 + }
48.2180 +
48.2181 + /**
48.2182 + * Replaces each substring of this string that matches the given <a
48.2183 + * href="../util/regex/Pattern.html#sum">regular expression</a> with the
48.2184 + * given replacement.
48.2185 + *
48.2186 + * <p> An invocation of this method of the form
48.2187 + * <i>str</i><tt>.replaceAll(</tt><i>regex</i><tt>,</tt> <i>repl</i><tt>)</tt>
48.2188 + * yields exactly the same result as the expression
48.2189 + *
48.2190 + * <blockquote><tt>
48.2191 + * {@link java.util.regex.Pattern}.{@link java.util.regex.Pattern#compile
48.2192 + * compile}(</tt><i>regex</i><tt>).{@link
48.2193 + * java.util.regex.Pattern#matcher(java.lang.CharSequence)
48.2194 + * matcher}(</tt><i>str</i><tt>).{@link java.util.regex.Matcher#replaceAll
48.2195 + * replaceAll}(</tt><i>repl</i><tt>)</tt></blockquote>
48.2196 + *
48.2197 + *<p>
48.2198 + * Note that backslashes (<tt>\</tt>) and dollar signs (<tt>$</tt>) in the
48.2199 + * replacement string may cause the results to be different than if it were
48.2200 + * being treated as a literal replacement string; see
48.2201 + * {@link java.util.regex.Matcher#replaceAll Matcher.replaceAll}.
48.2202 + * Use {@link java.util.regex.Matcher#quoteReplacement} to suppress the special
48.2203 + * meaning of these characters, if desired.
48.2204 + *
48.2205 + * @param regex
48.2206 + * the regular expression to which this string is to be matched
48.2207 + * @param replacement
48.2208 + * the string to be substituted for each match
48.2209 + *
48.2210 + * @return The resulting <tt>String</tt>
48.2211 + *
48.2212 + * @throws PatternSyntaxException
48.2213 + * if the regular expression's syntax is invalid
48.2214 + *
48.2215 + * @see java.util.regex.Pattern
48.2216 + *
48.2217 + * @since 1.4
48.2218 + * @spec JSR-51
48.2219 + */
48.2220 + public String replaceAll(String regex, String replacement) {
48.2221 + throw new UnsupportedOperationException();
48.2222 + }
48.2223 +
48.2224 + /**
48.2225 + * Replaces each substring of this string that matches the literal target
48.2226 + * sequence with the specified literal replacement sequence. The
48.2227 + * replacement proceeds from the beginning of the string to the end, for
48.2228 + * example, replacing "aa" with "b" in the string "aaa" will result in
48.2229 + * "ba" rather than "ab".
48.2230 + *
48.2231 + * @param target The sequence of char values to be replaced
48.2232 + * @param replacement The replacement sequence of char values
48.2233 + * @return The resulting string
48.2234 + * @throws NullPointerException if <code>target</code> or
48.2235 + * <code>replacement</code> is <code>null</code>.
48.2236 + * @since 1.5
48.2237 + */
48.2238 + public String replace(CharSequence target, CharSequence replacement) {
48.2239 + throw new UnsupportedOperationException("This one should be supported, but without dep on rest of regexp");
48.2240 + }
48.2241 +
48.2242 + /**
48.2243 + * Splits this string around matches of the given
48.2244 + * <a href="../util/regex/Pattern.html#sum">regular expression</a>.
48.2245 + *
48.2246 + * <p> The array returned by this method contains each substring of this
48.2247 + * string that is terminated by another substring that matches the given
48.2248 + * expression or is terminated by the end of the string. The substrings in
48.2249 + * the array are in the order in which they occur in this string. If the
48.2250 + * expression does not match any part of the input then the resulting array
48.2251 + * has just one element, namely this string.
48.2252 + *
48.2253 + * <p> The <tt>limit</tt> parameter controls the number of times the
48.2254 + * pattern is applied and therefore affects the length of the resulting
48.2255 + * array. If the limit <i>n</i> is greater than zero then the pattern
48.2256 + * will be applied at most <i>n</i> - 1 times, the array's
48.2257 + * length will be no greater than <i>n</i>, and the array's last entry
48.2258 + * will contain all input beyond the last matched delimiter. If <i>n</i>
48.2259 + * is non-positive then the pattern will be applied as many times as
48.2260 + * possible and the array can have any length. If <i>n</i> is zero then
48.2261 + * the pattern will be applied as many times as possible, the array can
48.2262 + * have any length, and trailing empty strings will be discarded.
48.2263 + *
48.2264 + * <p> The string <tt>"boo:and:foo"</tt>, for example, yields the
48.2265 + * following results with these parameters:
48.2266 + *
48.2267 + * <blockquote><table cellpadding=1 cellspacing=0 summary="Split example showing regex, limit, and result">
48.2268 + * <tr>
48.2269 + * <th>Regex</th>
48.2270 + * <th>Limit</th>
48.2271 + * <th>Result</th>
48.2272 + * </tr>
48.2273 + * <tr><td align=center>:</td>
48.2274 + * <td align=center>2</td>
48.2275 + * <td><tt>{ "boo", "and:foo" }</tt></td></tr>
48.2276 + * <tr><td align=center>:</td>
48.2277 + * <td align=center>5</td>
48.2278 + * <td><tt>{ "boo", "and", "foo" }</tt></td></tr>
48.2279 + * <tr><td align=center>:</td>
48.2280 + * <td align=center>-2</td>
48.2281 + * <td><tt>{ "boo", "and", "foo" }</tt></td></tr>
48.2282 + * <tr><td align=center>o</td>
48.2283 + * <td align=center>5</td>
48.2284 + * <td><tt>{ "b", "", ":and:f", "", "" }</tt></td></tr>
48.2285 + * <tr><td align=center>o</td>
48.2286 + * <td align=center>-2</td>
48.2287 + * <td><tt>{ "b", "", ":and:f", "", "" }</tt></td></tr>
48.2288 + * <tr><td align=center>o</td>
48.2289 + * <td align=center>0</td>
48.2290 + * <td><tt>{ "b", "", ":and:f" }</tt></td></tr>
48.2291 + * </table></blockquote>
48.2292 + *
48.2293 + * <p> An invocation of this method of the form
48.2294 + * <i>str.</i><tt>split(</tt><i>regex</i><tt>,</tt> <i>n</i><tt>)</tt>
48.2295 + * yields the same result as the expression
48.2296 + *
48.2297 + * <blockquote>
48.2298 + * {@link java.util.regex.Pattern}.{@link java.util.regex.Pattern#compile
48.2299 + * compile}<tt>(</tt><i>regex</i><tt>)</tt>.{@link
48.2300 + * java.util.regex.Pattern#split(java.lang.CharSequence,int)
48.2301 + * split}<tt>(</tt><i>str</i><tt>,</tt> <i>n</i><tt>)</tt>
48.2302 + * </blockquote>
48.2303 + *
48.2304 + *
48.2305 + * @param regex
48.2306 + * the delimiting regular expression
48.2307 + *
48.2308 + * @param limit
48.2309 + * the result threshold, as described above
48.2310 + *
48.2311 + * @return the array of strings computed by splitting this string
48.2312 + * around matches of the given regular expression
48.2313 + *
48.2314 + * @throws PatternSyntaxException
48.2315 + * if the regular expression's syntax is invalid
48.2316 + *
48.2317 + * @see java.util.regex.Pattern
48.2318 + *
48.2319 + * @since 1.4
48.2320 + * @spec JSR-51
48.2321 + */
48.2322 + public String[] split(String regex, int limit) {
48.2323 + throw new UnsupportedOperationException("Needs regexp");
48.2324 + }
48.2325 +
48.2326 + /**
48.2327 + * Splits this string around matches of the given <a
48.2328 + * href="../util/regex/Pattern.html#sum">regular expression</a>.
48.2329 + *
48.2330 + * <p> This method works as if by invoking the two-argument {@link
48.2331 + * #split(String, int) split} method with the given expression and a limit
48.2332 + * argument of zero. Trailing empty strings are therefore not included in
48.2333 + * the resulting array.
48.2334 + *
48.2335 + * <p> The string <tt>"boo:and:foo"</tt>, for example, yields the following
48.2336 + * results with these expressions:
48.2337 + *
48.2338 + * <blockquote><table cellpadding=1 cellspacing=0 summary="Split examples showing regex and result">
48.2339 + * <tr>
48.2340 + * <th>Regex</th>
48.2341 + * <th>Result</th>
48.2342 + * </tr>
48.2343 + * <tr><td align=center>:</td>
48.2344 + * <td><tt>{ "boo", "and", "foo" }</tt></td></tr>
48.2345 + * <tr><td align=center>o</td>
48.2346 + * <td><tt>{ "b", "", ":and:f" }</tt></td></tr>
48.2347 + * </table></blockquote>
48.2348 + *
48.2349 + *
48.2350 + * @param regex
48.2351 + * the delimiting regular expression
48.2352 + *
48.2353 + * @return the array of strings computed by splitting this string
48.2354 + * around matches of the given regular expression
48.2355 + *
48.2356 + * @throws PatternSyntaxException
48.2357 + * if the regular expression's syntax is invalid
48.2358 + *
48.2359 + * @see java.util.regex.Pattern
48.2360 + *
48.2361 + * @since 1.4
48.2362 + * @spec JSR-51
48.2363 + */
48.2364 + public String[] split(String regex) {
48.2365 + return split(regex, 0);
48.2366 + }
48.2367 +
48.2368 + /**
48.2369 + * Converts all of the characters in this <code>String</code> to lower
48.2370 + * case using the rules of the given <code>Locale</code>. Case mapping is based
48.2371 + * on the Unicode Standard version specified by the {@link java.lang.Character Character}
48.2372 + * class. Since case mappings are not always 1:1 char mappings, the resulting
48.2373 + * <code>String</code> may be a different length than the original <code>String</code>.
48.2374 + * <p>
48.2375 + * Examples of lowercase mappings are in the following table:
48.2376 + * <table border="1" summary="Lowercase mapping examples showing language code of locale, upper case, lower case, and description">
48.2377 + * <tr>
48.2378 + * <th>Language Code of Locale</th>
48.2379 + * <th>Upper Case</th>
48.2380 + * <th>Lower Case</th>
48.2381 + * <th>Description</th>
48.2382 + * </tr>
48.2383 + * <tr>
48.2384 + * <td>tr (Turkish)</td>
48.2385 + * <td>\u0130</td>
48.2386 + * <td>\u0069</td>
48.2387 + * <td>capital letter I with dot above -> small letter i</td>
48.2388 + * </tr>
48.2389 + * <tr>
48.2390 + * <td>tr (Turkish)</td>
48.2391 + * <td>\u0049</td>
48.2392 + * <td>\u0131</td>
48.2393 + * <td>capital letter I -> small letter dotless i </td>
48.2394 + * </tr>
48.2395 + * <tr>
48.2396 + * <td>(all)</td>
48.2397 + * <td>French Fries</td>
48.2398 + * <td>french fries</td>
48.2399 + * <td>lowercased all chars in String</td>
48.2400 + * </tr>
48.2401 + * <tr>
48.2402 + * <td>(all)</td>
48.2403 + * <td><img src="doc-files/capiota.gif" alt="capiota"><img src="doc-files/capchi.gif" alt="capchi">
48.2404 + * <img src="doc-files/captheta.gif" alt="captheta"><img src="doc-files/capupsil.gif" alt="capupsil">
48.2405 + * <img src="doc-files/capsigma.gif" alt="capsigma"></td>
48.2406 + * <td><img src="doc-files/iota.gif" alt="iota"><img src="doc-files/chi.gif" alt="chi">
48.2407 + * <img src="doc-files/theta.gif" alt="theta"><img src="doc-files/upsilon.gif" alt="upsilon">
48.2408 + * <img src="doc-files/sigma1.gif" alt="sigma"></td>
48.2409 + * <td>lowercased all chars in String</td>
48.2410 + * </tr>
48.2411 + * </table>
48.2412 + *
48.2413 + * @param locale use the case transformation rules for this locale
48.2414 + * @return the <code>String</code>, converted to lowercase.
48.2415 + * @see java.lang.String#toLowerCase()
48.2416 + * @see java.lang.String#toUpperCase()
48.2417 + * @see java.lang.String#toUpperCase(Locale)
48.2418 + * @since 1.1
48.2419 + */
48.2420 +// public String toLowerCase(Locale locale) {
48.2421 +// if (locale == null) {
48.2422 +// throw new NullPointerException();
48.2423 +// }
48.2424 +//
48.2425 +// int firstUpper;
48.2426 +//
48.2427 +// /* Now check if there are any characters that need to be changed. */
48.2428 +// scan: {
48.2429 +// for (firstUpper = 0 ; firstUpper < count; ) {
48.2430 +// char c = value[offset+firstUpper];
48.2431 +// if ((c >= Character.MIN_HIGH_SURROGATE) &&
48.2432 +// (c <= Character.MAX_HIGH_SURROGATE)) {
48.2433 +// int supplChar = codePointAt(firstUpper);
48.2434 +// if (supplChar != Character.toLowerCase(supplChar)) {
48.2435 +// break scan;
48.2436 +// }
48.2437 +// firstUpper += Character.charCount(supplChar);
48.2438 +// } else {
48.2439 +// if (c != Character.toLowerCase(c)) {
48.2440 +// break scan;
48.2441 +// }
48.2442 +// firstUpper++;
48.2443 +// }
48.2444 +// }
48.2445 +// return this;
48.2446 +// }
48.2447 +//
48.2448 +// char[] result = new char[count];
48.2449 +// int resultOffset = 0; /* result may grow, so i+resultOffset
48.2450 +// * is the write location in result */
48.2451 +//
48.2452 +// /* Just copy the first few lowerCase characters. */
48.2453 +// arraycopy(value, offset, result, 0, firstUpper);
48.2454 +//
48.2455 +// String lang = locale.getLanguage();
48.2456 +// boolean localeDependent =
48.2457 +// (lang == "tr" || lang == "az" || lang == "lt");
48.2458 +// char[] lowerCharArray;
48.2459 +// int lowerChar;
48.2460 +// int srcChar;
48.2461 +// int srcCount;
48.2462 +// for (int i = firstUpper; i < count; i += srcCount) {
48.2463 +// srcChar = (int)value[offset+i];
48.2464 +// if ((char)srcChar >= Character.MIN_HIGH_SURROGATE &&
48.2465 +// (char)srcChar <= Character.MAX_HIGH_SURROGATE) {
48.2466 +// srcChar = codePointAt(i);
48.2467 +// srcCount = Character.charCount(srcChar);
48.2468 +// } else {
48.2469 +// srcCount = 1;
48.2470 +// }
48.2471 +// if (localeDependent || srcChar == '\u03A3') { // GREEK CAPITAL LETTER SIGMA
48.2472 +// lowerChar = ConditionalSpecialCasing.toLowerCaseEx(this, i, locale);
48.2473 +// } else if (srcChar == '\u0130') { // LATIN CAPITAL LETTER I DOT
48.2474 +// lowerChar = Character.ERROR;
48.2475 +// } else {
48.2476 +// lowerChar = Character.toLowerCase(srcChar);
48.2477 +// }
48.2478 +// if ((lowerChar == Character.ERROR) ||
48.2479 +// (lowerChar >= Character.MIN_SUPPLEMENTARY_CODE_POINT)) {
48.2480 +// if (lowerChar == Character.ERROR) {
48.2481 +// if (!localeDependent && srcChar == '\u0130') {
48.2482 +// lowerCharArray =
48.2483 +// ConditionalSpecialCasing.toLowerCaseCharArray(this, i, Locale.ENGLISH);
48.2484 +// } else {
48.2485 +// lowerCharArray =
48.2486 +// ConditionalSpecialCasing.toLowerCaseCharArray(this, i, locale);
48.2487 +// }
48.2488 +// } else if (srcCount == 2) {
48.2489 +// resultOffset += Character.toChars(lowerChar, result, i + resultOffset) - srcCount;
48.2490 +// continue;
48.2491 +// } else {
48.2492 +// lowerCharArray = Character.toChars(lowerChar);
48.2493 +// }
48.2494 +//
48.2495 +// /* Grow result if needed */
48.2496 +// int mapLen = lowerCharArray.length;
48.2497 +// if (mapLen > srcCount) {
48.2498 +// char[] result2 = new char[result.length + mapLen - srcCount];
48.2499 +// arraycopy(result, 0, result2, 0,
48.2500 +// i + resultOffset);
48.2501 +// result = result2;
48.2502 +// }
48.2503 +// for (int x=0; x<mapLen; ++x) {
48.2504 +// result[i+resultOffset+x] = lowerCharArray[x];
48.2505 +// }
48.2506 +// resultOffset += (mapLen - srcCount);
48.2507 +// } else {
48.2508 +// result[i+resultOffset] = (char)lowerChar;
48.2509 +// }
48.2510 +// }
48.2511 +// return new String(0, count+resultOffset, result);
48.2512 +// }
48.2513 +
48.2514 + /**
48.2515 + * Converts all of the characters in this <code>String</code> to lower
48.2516 + * case using the rules of the default locale. This is equivalent to calling
48.2517 + * <code>toLowerCase(Locale.getDefault())</code>.
48.2518 + * <p>
48.2519 + * <b>Note:</b> This method is locale sensitive, and may produce unexpected
48.2520 + * results if used for strings that are intended to be interpreted locale
48.2521 + * independently.
48.2522 + * Examples are programming language identifiers, protocol keys, and HTML
48.2523 + * tags.
48.2524 + * For instance, <code>"TITLE".toLowerCase()</code> in a Turkish locale
48.2525 + * returns <code>"t\u005Cu0131tle"</code>, where '\u005Cu0131' is the
48.2526 + * LATIN SMALL LETTER DOTLESS I character.
48.2527 + * To obtain correct results for locale insensitive strings, use
48.2528 + * <code>toLowerCase(Locale.ENGLISH)</code>.
48.2529 + * <p>
48.2530 + * @return the <code>String</code>, converted to lowercase.
48.2531 + * @see java.lang.String#toLowerCase(Locale)
48.2532 + */
48.2533 + public String toLowerCase() {
48.2534 + throw new UnsupportedOperationException("Should be supported but without connection to locale");
48.2535 + }
48.2536 +
48.2537 + /**
48.2538 + * Converts all of the characters in this <code>String</code> to upper
48.2539 + * case using the rules of the given <code>Locale</code>. Case mapping is based
48.2540 + * on the Unicode Standard version specified by the {@link java.lang.Character Character}
48.2541 + * class. Since case mappings are not always 1:1 char mappings, the resulting
48.2542 + * <code>String</code> may be a different length than the original <code>String</code>.
48.2543 + * <p>
48.2544 + * Examples of locale-sensitive and 1:M case mappings are in the following table.
48.2545 + * <p>
48.2546 + * <table border="1" summary="Examples of locale-sensitive and 1:M case mappings. Shows Language code of locale, lower case, upper case, and description.">
48.2547 + * <tr>
48.2548 + * <th>Language Code of Locale</th>
48.2549 + * <th>Lower Case</th>
48.2550 + * <th>Upper Case</th>
48.2551 + * <th>Description</th>
48.2552 + * </tr>
48.2553 + * <tr>
48.2554 + * <td>tr (Turkish)</td>
48.2555 + * <td>\u0069</td>
48.2556 + * <td>\u0130</td>
48.2557 + * <td>small letter i -> capital letter I with dot above</td>
48.2558 + * </tr>
48.2559 + * <tr>
48.2560 + * <td>tr (Turkish)</td>
48.2561 + * <td>\u0131</td>
48.2562 + * <td>\u0049</td>
48.2563 + * <td>small letter dotless i -> capital letter I</td>
48.2564 + * </tr>
48.2565 + * <tr>
48.2566 + * <td>(all)</td>
48.2567 + * <td>\u00df</td>
48.2568 + * <td>\u0053 \u0053</td>
48.2569 + * <td>small letter sharp s -> two letters: SS</td>
48.2570 + * </tr>
48.2571 + * <tr>
48.2572 + * <td>(all)</td>
48.2573 + * <td>Fahrvergnügen</td>
48.2574 + * <td>FAHRVERGNÜGEN</td>
48.2575 + * <td></td>
48.2576 + * </tr>
48.2577 + * </table>
48.2578 + * @param locale use the case transformation rules for this locale
48.2579 + * @return the <code>String</code>, converted to uppercase.
48.2580 + * @see java.lang.String#toUpperCase()
48.2581 + * @see java.lang.String#toLowerCase()
48.2582 + * @see java.lang.String#toLowerCase(Locale)
48.2583 + * @since 1.1
48.2584 + */
48.2585 + /* not for javascript
48.2586 + public String toUpperCase(Locale locale) {
48.2587 + if (locale == null) {
48.2588 + throw new NullPointerException();
48.2589 + }
48.2590 +
48.2591 + int firstLower;
48.2592 +
48.2593 + // Now check if there are any characters that need to be changed.
48.2594 + scan: {
48.2595 + for (firstLower = 0 ; firstLower < count; ) {
48.2596 + int c = (int)value[offset+firstLower];
48.2597 + int srcCount;
48.2598 + if ((c >= Character.MIN_HIGH_SURROGATE) &&
48.2599 + (c <= Character.MAX_HIGH_SURROGATE)) {
48.2600 + c = codePointAt(firstLower);
48.2601 + srcCount = Character.charCount(c);
48.2602 + } else {
48.2603 + srcCount = 1;
48.2604 + }
48.2605 + int upperCaseChar = Character.toUpperCaseEx(c);
48.2606 + if ((upperCaseChar == Character.ERROR) ||
48.2607 + (c != upperCaseChar)) {
48.2608 + break scan;
48.2609 + }
48.2610 + firstLower += srcCount;
48.2611 + }
48.2612 + return this;
48.2613 + }
48.2614 +
48.2615 + char[] result = new char[count]; /* may grow *
48.2616 + int resultOffset = 0; /* result may grow, so i+resultOffset
48.2617 + * is the write location in result *
48.2618 +
48.2619 + /* Just copy the first few upperCase characters. *
48.2620 + arraycopy(value, offset, result, 0, firstLower);
48.2621 +
48.2622 + String lang = locale.getLanguage();
48.2623 + boolean localeDependent =
48.2624 + (lang == "tr" || lang == "az" || lang == "lt");
48.2625 + char[] upperCharArray;
48.2626 + int upperChar;
48.2627 + int srcChar;
48.2628 + int srcCount;
48.2629 + for (int i = firstLower; i < count; i += srcCount) {
48.2630 + srcChar = (int)value[offset+i];
48.2631 + if ((char)srcChar >= Character.MIN_HIGH_SURROGATE &&
48.2632 + (char)srcChar <= Character.MAX_HIGH_SURROGATE) {
48.2633 + srcChar = codePointAt(i);
48.2634 + srcCount = Character.charCount(srcChar);
48.2635 + } else {
48.2636 + srcCount = 1;
48.2637 + }
48.2638 + if (localeDependent) {
48.2639 + upperChar = ConditionalSpecialCasing.toUpperCaseEx(this, i, locale);
48.2640 + } else {
48.2641 + upperChar = Character.toUpperCaseEx(srcChar);
48.2642 + }
48.2643 + if ((upperChar == Character.ERROR) ||
48.2644 + (upperChar >= Character.MIN_SUPPLEMENTARY_CODE_POINT)) {
48.2645 + if (upperChar == Character.ERROR) {
48.2646 + if (localeDependent) {
48.2647 + upperCharArray =
48.2648 + ConditionalSpecialCasing.toUpperCaseCharArray(this, i, locale);
48.2649 + } else {
48.2650 + upperCharArray = Character.toUpperCaseCharArray(srcChar);
48.2651 + }
48.2652 + } else if (srcCount == 2) {
48.2653 + resultOffset += Character.toChars(upperChar, result, i + resultOffset) - srcCount;
48.2654 + continue;
48.2655 + } else {
48.2656 + upperCharArray = Character.toChars(upperChar);
48.2657 + }
48.2658 +
48.2659 + /* Grow result if needed *
48.2660 + int mapLen = upperCharArray.length;
48.2661 + if (mapLen > srcCount) {
48.2662 + char[] result2 = new char[result.length + mapLen - srcCount];
48.2663 + arraycopy(result, 0, result2, 0,
48.2664 + i + resultOffset);
48.2665 + result = result2;
48.2666 + }
48.2667 + for (int x=0; x<mapLen; ++x) {
48.2668 + result[i+resultOffset+x] = upperCharArray[x];
48.2669 + }
48.2670 + resultOffset += (mapLen - srcCount);
48.2671 + } else {
48.2672 + result[i+resultOffset] = (char)upperChar;
48.2673 + }
48.2674 + }
48.2675 + return new String(0, count+resultOffset, result);
48.2676 + }
48.2677 + */
48.2678 +
48.2679 + /**
48.2680 + * Converts all of the characters in this <code>String</code> to upper
48.2681 + * case using the rules of the default locale. This method is equivalent to
48.2682 + * <code>toUpperCase(Locale.getDefault())</code>.
48.2683 + * <p>
48.2684 + * <b>Note:</b> This method is locale sensitive, and may produce unexpected
48.2685 + * results if used for strings that are intended to be interpreted locale
48.2686 + * independently.
48.2687 + * Examples are programming language identifiers, protocol keys, and HTML
48.2688 + * tags.
48.2689 + * For instance, <code>"title".toUpperCase()</code> in a Turkish locale
48.2690 + * returns <code>"T\u005Cu0130TLE"</code>, where '\u005Cu0130' is the
48.2691 + * LATIN CAPITAL LETTER I WITH DOT ABOVE character.
48.2692 + * To obtain correct results for locale insensitive strings, use
48.2693 + * <code>toUpperCase(Locale.ENGLISH)</code>.
48.2694 + * <p>
48.2695 + * @return the <code>String</code>, converted to uppercase.
48.2696 + * @see java.lang.String#toUpperCase(Locale)
48.2697 + */
48.2698 + public String toUpperCase() {
48.2699 + throw new UnsupportedOperationException();
48.2700 + }
48.2701 +
48.2702 + /**
48.2703 + * Returns a copy of the string, with leading and trailing whitespace
48.2704 + * omitted.
48.2705 + * <p>
48.2706 + * If this <code>String</code> object represents an empty character
48.2707 + * sequence, or the first and last characters of character sequence
48.2708 + * represented by this <code>String</code> object both have codes
48.2709 + * greater than <code>'\u0020'</code> (the space character), then a
48.2710 + * reference to this <code>String</code> object is returned.
48.2711 + * <p>
48.2712 + * Otherwise, if there is no character with a code greater than
48.2713 + * <code>'\u0020'</code> in the string, then a new
48.2714 + * <code>String</code> object representing an empty string is created
48.2715 + * and returned.
48.2716 + * <p>
48.2717 + * Otherwise, let <i>k</i> be the index of the first character in the
48.2718 + * string whose code is greater than <code>'\u0020'</code>, and let
48.2719 + * <i>m</i> be the index of the last character in the string whose code
48.2720 + * is greater than <code>'\u0020'</code>. A new <code>String</code>
48.2721 + * object is created, representing the substring of this string that
48.2722 + * begins with the character at index <i>k</i> and ends with the
48.2723 + * character at index <i>m</i>-that is, the result of
48.2724 + * <code>this.substring(<i>k</i>, <i>m</i>+1)</code>.
48.2725 + * <p>
48.2726 + * This method may be used to trim whitespace (as defined above) from
48.2727 + * the beginning and end of a string.
48.2728 + *
48.2729 + * @return A copy of this string with leading and trailing white
48.2730 + * space removed, or this string if it has no leading or
48.2731 + * trailing white space.
48.2732 + */
48.2733 + public String trim() {
48.2734 + int len = count;
48.2735 + int st = 0;
48.2736 + int off = offset; /* avoid getfield opcode */
48.2737 + char[] val = value; /* avoid getfield opcode */
48.2738 +
48.2739 + while ((st < len) && (val[off + st] <= ' ')) {
48.2740 + st++;
48.2741 + }
48.2742 + while ((st < len) && (val[off + len - 1] <= ' ')) {
48.2743 + len--;
48.2744 + }
48.2745 + return ((st > 0) || (len < count)) ? substring(st, len) : this;
48.2746 + }
48.2747 +
48.2748 + /**
48.2749 + * This object (which is already a string!) is itself returned.
48.2750 + *
48.2751 + * @return the string itself.
48.2752 + */
48.2753 + public String toString() {
48.2754 + return this;
48.2755 + }
48.2756 +
48.2757 + /**
48.2758 + * Converts this string to a new character array.
48.2759 + *
48.2760 + * @return a newly allocated character array whose length is the length
48.2761 + * of this string and whose contents are initialized to contain
48.2762 + * the character sequence represented by this string.
48.2763 + */
48.2764 + public char[] toCharArray() {
48.2765 + char result[] = new char[count];
48.2766 + getChars(0, count, result, 0);
48.2767 + return result;
48.2768 + }
48.2769 +
48.2770 + /**
48.2771 + * Returns a formatted string using the specified format string and
48.2772 + * arguments.
48.2773 + *
48.2774 + * <p> The locale always used is the one returned by {@link
48.2775 + * java.util.Locale#getDefault() Locale.getDefault()}.
48.2776 + *
48.2777 + * @param format
48.2778 + * A <a href="../util/Formatter.html#syntax">format string</a>
48.2779 + *
48.2780 + * @param args
48.2781 + * Arguments referenced by the format specifiers in the format
48.2782 + * string. If there are more arguments than format specifiers, the
48.2783 + * extra arguments are ignored. The number of arguments is
48.2784 + * variable and may be zero. The maximum number of arguments is
48.2785 + * limited by the maximum dimension of a Java array as defined by
48.2786 + * <cite>The Java™ Virtual Machine Specification</cite>.
48.2787 + * The behaviour on a
48.2788 + * <tt>null</tt> argument depends on the <a
48.2789 + * href="../util/Formatter.html#syntax">conversion</a>.
48.2790 + *
48.2791 + * @throws IllegalFormatException
48.2792 + * If a format string contains an illegal syntax, a format
48.2793 + * specifier that is incompatible with the given arguments,
48.2794 + * insufficient arguments given the format string, or other
48.2795 + * illegal conditions. For specification of all possible
48.2796 + * formatting errors, see the <a
48.2797 + * href="../util/Formatter.html#detail">Details</a> section of the
48.2798 + * formatter class specification.
48.2799 + *
48.2800 + * @throws NullPointerException
48.2801 + * If the <tt>format</tt> is <tt>null</tt>
48.2802 + *
48.2803 + * @return A formatted string
48.2804 + *
48.2805 + * @see java.util.Formatter
48.2806 + * @since 1.5
48.2807 + */
48.2808 + public static String format(String format, Object ... args) {
48.2809 + throw new UnsupportedOperationException();
48.2810 + }
48.2811 +
48.2812 + /**
48.2813 + * Returns a formatted string using the specified locale, format string,
48.2814 + * and arguments.
48.2815 + *
48.2816 + * @param l
48.2817 + * The {@linkplain java.util.Locale locale} to apply during
48.2818 + * formatting. If <tt>l</tt> is <tt>null</tt> then no localization
48.2819 + * is applied.
48.2820 + *
48.2821 + * @param format
48.2822 + * A <a href="../util/Formatter.html#syntax">format string</a>
48.2823 + *
48.2824 + * @param args
48.2825 + * Arguments referenced by the format specifiers in the format
48.2826 + * string. If there are more arguments than format specifiers, the
48.2827 + * extra arguments are ignored. The number of arguments is
48.2828 + * variable and may be zero. The maximum number of arguments is
48.2829 + * limited by the maximum dimension of a Java array as defined by
48.2830 + * <cite>The Java™ Virtual Machine Specification</cite>.
48.2831 + * The behaviour on a
48.2832 + * <tt>null</tt> argument depends on the <a
48.2833 + * href="../util/Formatter.html#syntax">conversion</a>.
48.2834 + *
48.2835 + * @throws IllegalFormatException
48.2836 + * If a format string contains an illegal syntax, a format
48.2837 + * specifier that is incompatible with the given arguments,
48.2838 + * insufficient arguments given the format string, or other
48.2839 + * illegal conditions. For specification of all possible
48.2840 + * formatting errors, see the <a
48.2841 + * href="../util/Formatter.html#detail">Details</a> section of the
48.2842 + * formatter class specification
48.2843 + *
48.2844 + * @throws NullPointerException
48.2845 + * If the <tt>format</tt> is <tt>null</tt>
48.2846 + *
48.2847 + * @return A formatted string
48.2848 + *
48.2849 + * @see java.util.Formatter
48.2850 + * @since 1.5
48.2851 + */
48.2852 +// public static String format(Locale l, String format, Object ... args) {
48.2853 +// return new Formatter(l).format(format, args).toString();
48.2854 +// }
48.2855 +
48.2856 + /**
48.2857 + * Returns the string representation of the <code>Object</code> argument.
48.2858 + *
48.2859 + * @param obj an <code>Object</code>.
48.2860 + * @return if the argument is <code>null</code>, then a string equal to
48.2861 + * <code>"null"</code>; otherwise, the value of
48.2862 + * <code>obj.toString()</code> is returned.
48.2863 + * @see java.lang.Object#toString()
48.2864 + */
48.2865 + public static String valueOf(Object obj) {
48.2866 + return (obj == null) ? "null" : obj.toString();
48.2867 + }
48.2868 +
48.2869 + /**
48.2870 + * Returns the string representation of the <code>char</code> array
48.2871 + * argument. The contents of the character array are copied; subsequent
48.2872 + * modification of the character array does not affect the newly
48.2873 + * created string.
48.2874 + *
48.2875 + * @param data a <code>char</code> array.
48.2876 + * @return a newly allocated string representing the same sequence of
48.2877 + * characters contained in the character array argument.
48.2878 + */
48.2879 + public static String valueOf(char data[]) {
48.2880 + return new String(data);
48.2881 + }
48.2882 +
48.2883 + /**
48.2884 + * Returns the string representation of a specific subarray of the
48.2885 + * <code>char</code> array argument.
48.2886 + * <p>
48.2887 + * The <code>offset</code> argument is the index of the first
48.2888 + * character of the subarray. The <code>count</code> argument
48.2889 + * specifies the length of the subarray. The contents of the subarray
48.2890 + * are copied; subsequent modification of the character array does not
48.2891 + * affect the newly created string.
48.2892 + *
48.2893 + * @param data the character array.
48.2894 + * @param offset the initial offset into the value of the
48.2895 + * <code>String</code>.
48.2896 + * @param count the length of the value of the <code>String</code>.
48.2897 + * @return a string representing the sequence of characters contained
48.2898 + * in the subarray of the character array argument.
48.2899 + * @exception IndexOutOfBoundsException if <code>offset</code> is
48.2900 + * negative, or <code>count</code> is negative, or
48.2901 + * <code>offset+count</code> is larger than
48.2902 + * <code>data.length</code>.
48.2903 + */
48.2904 + public static String valueOf(char data[], int offset, int count) {
48.2905 + return new String(data, offset, count);
48.2906 + }
48.2907 +
48.2908 + /**
48.2909 + * Returns a String that represents the character sequence in the
48.2910 + * array specified.
48.2911 + *
48.2912 + * @param data the character array.
48.2913 + * @param offset initial offset of the subarray.
48.2914 + * @param count length of the subarray.
48.2915 + * @return a <code>String</code> that contains the characters of the
48.2916 + * specified subarray of the character array.
48.2917 + */
48.2918 + public static String copyValueOf(char data[], int offset, int count) {
48.2919 + // All public String constructors now copy the data.
48.2920 + return new String(data, offset, count);
48.2921 + }
48.2922 +
48.2923 + /**
48.2924 + * Returns a String that represents the character sequence in the
48.2925 + * array specified.
48.2926 + *
48.2927 + * @param data the character array.
48.2928 + * @return a <code>String</code> that contains the characters of the
48.2929 + * character array.
48.2930 + */
48.2931 + public static String copyValueOf(char data[]) {
48.2932 + return copyValueOf(data, 0, data.length);
48.2933 + }
48.2934 +
48.2935 + /**
48.2936 + * Returns the string representation of the <code>boolean</code> argument.
48.2937 + *
48.2938 + * @param b a <code>boolean</code>.
48.2939 + * @return if the argument is <code>true</code>, a string equal to
48.2940 + * <code>"true"</code> is returned; otherwise, a string equal to
48.2941 + * <code>"false"</code> is returned.
48.2942 + */
48.2943 + public static String valueOf(boolean b) {
48.2944 + return b ? "true" : "false";
48.2945 + }
48.2946 +
48.2947 + /**
48.2948 + * Returns the string representation of the <code>char</code>
48.2949 + * argument.
48.2950 + *
48.2951 + * @param c a <code>char</code>.
48.2952 + * @return a string of length <code>1</code> containing
48.2953 + * as its single character the argument <code>c</code>.
48.2954 + */
48.2955 + public static String valueOf(char c) {
48.2956 + char data[] = {c};
48.2957 + return new String(0, 1, data);
48.2958 + }
48.2959 +
48.2960 + /**
48.2961 + * Returns the string representation of the <code>int</code> argument.
48.2962 + * <p>
48.2963 + * The representation is exactly the one returned by the
48.2964 + * <code>Integer.toString</code> method of one argument.
48.2965 + *
48.2966 + * @param i an <code>int</code>.
48.2967 + * @return a string representation of the <code>int</code> argument.
48.2968 + * @see java.lang.Integer#toString(int, int)
48.2969 + */
48.2970 + public static String valueOf(int i) {
48.2971 + return Integer.toString(i);
48.2972 + }
48.2973 +
48.2974 + /**
48.2975 + * Returns the string representation of the <code>long</code> argument.
48.2976 + * <p>
48.2977 + * The representation is exactly the one returned by the
48.2978 + * <code>Long.toString</code> method of one argument.
48.2979 + *
48.2980 + * @param l a <code>long</code>.
48.2981 + * @return a string representation of the <code>long</code> argument.
48.2982 + * @see java.lang.Long#toString(long)
48.2983 + */
48.2984 + public static String valueOf(long l) {
48.2985 + return Long.toString(l);
48.2986 + }
48.2987 +
48.2988 + /**
48.2989 + * Returns the string representation of the <code>float</code> argument.
48.2990 + * <p>
48.2991 + * The representation is exactly the one returned by the
48.2992 + * <code>Float.toString</code> method of one argument.
48.2993 + *
48.2994 + * @param f a <code>float</code>.
48.2995 + * @return a string representation of the <code>float</code> argument.
48.2996 + * @see java.lang.Float#toString(float)
48.2997 + */
48.2998 + public static String valueOf(float f) {
48.2999 + return Float.toString(f);
48.3000 + }
48.3001 +
48.3002 + /**
48.3003 + * Returns the string representation of the <code>double</code> argument.
48.3004 + * <p>
48.3005 + * The representation is exactly the one returned by the
48.3006 + * <code>Double.toString</code> method of one argument.
48.3007 + *
48.3008 + * @param d a <code>double</code>.
48.3009 + * @return a string representation of the <code>double</code> argument.
48.3010 + * @see java.lang.Double#toString(double)
48.3011 + */
48.3012 + public static String valueOf(double d) {
48.3013 + return Double.toString(d);
48.3014 + }
48.3015 +
48.3016 + /**
48.3017 + * Returns a canonical representation for the string object.
48.3018 + * <p>
48.3019 + * A pool of strings, initially empty, is maintained privately by the
48.3020 + * class <code>String</code>.
48.3021 + * <p>
48.3022 + * When the intern method is invoked, if the pool already contains a
48.3023 + * string equal to this <code>String</code> object as determined by
48.3024 + * the {@link #equals(Object)} method, then the string from the pool is
48.3025 + * returned. Otherwise, this <code>String</code> object is added to the
48.3026 + * pool and a reference to this <code>String</code> object is returned.
48.3027 + * <p>
48.3028 + * It follows that for any two strings <code>s</code> and <code>t</code>,
48.3029 + * <code>s.intern() == t.intern()</code> is <code>true</code>
48.3030 + * if and only if <code>s.equals(t)</code> is <code>true</code>.
48.3031 + * <p>
48.3032 + * All literal strings and string-valued constant expressions are
48.3033 + * interned. String literals are defined in section 3.10.5 of the
48.3034 + * <cite>The Java™ Language Specification</cite>.
48.3035 + *
48.3036 + * @return a string that has the same contents as this string, but is
48.3037 + * guaranteed to be from a pool of unique strings.
48.3038 + */
48.3039 + public native String intern();
48.3040 +
48.3041 + static char[] copyOfRange(char[] original, int from, int to) {
48.3042 + int newLength = to - from;
48.3043 + if (newLength < 0) {
48.3044 + throw new IllegalArgumentException(from + " > " + to);
48.3045 + }
48.3046 + char[] copy = new char[newLength];
48.3047 + arraycopy(original, from, copy, 0,
48.3048 + Math.min(original.length - from, newLength));
48.3049 + return copy;
48.3050 + }
48.3051 + static char[] copyOf(char[] original, int newLength) {
48.3052 + char[] copy = new char[newLength];
48.3053 + arraycopy(original, 0, copy, 0,
48.3054 + Math.min(original.length, newLength));
48.3055 + return copy;
48.3056 + }
48.3057 + static void arraycopy(
48.3058 + char[] value, int srcBegin, char[] dst, int dstBegin, int count
48.3059 + ) {
48.3060 + while (count-- > 0) {
48.3061 + dst[dstBegin++] = value[srcBegin++];
48.3062 + }
48.3063 + }
48.3064 + // access system property
48.3065 + static String getProperty(String nm) {
48.3066 + return null;
48.3067 + }
48.3068 +}
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
49.2 +++ b/emul/src/main/java/java/lang/StringBuffer.java Thu Oct 11 06:16:00 2012 -0700
49.3 @@ -0,0 +1,605 @@
49.4 +/*
49.5 + * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved.
49.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
49.7 + *
49.8 + * This code is free software; you can redistribute it and/or modify it
49.9 + * under the terms of the GNU General Public License version 2 only, as
49.10 + * published by the Free Software Foundation. Oracle designates this
49.11 + * particular file as subject to the "Classpath" exception as provided
49.12 + * by Oracle in the LICENSE file that accompanied this code.
49.13 + *
49.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
49.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
49.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
49.17 + * version 2 for more details (a copy is included in the LICENSE file that
49.18 + * accompanied this code).
49.19 + *
49.20 + * You should have received a copy of the GNU General Public License version
49.21 + * 2 along with this work; if not, write to the Free Software Foundation,
49.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
49.23 + *
49.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
49.25 + * or visit www.oracle.com if you need additional information or have any
49.26 + * questions.
49.27 + */
49.28 +
49.29 +package java.lang;
49.30 +
49.31 +
49.32 +/**
49.33 + * A thread-safe, mutable sequence of characters.
49.34 + * A string buffer is like a {@link String}, but can be modified. At any
49.35 + * point in time it contains some particular sequence of characters, but
49.36 + * the length and content of the sequence can be changed through certain
49.37 + * method calls.
49.38 + * <p>
49.39 + * String buffers are safe for use by multiple threads. The methods
49.40 + * are synchronized where necessary so that all the operations on any
49.41 + * particular instance behave as if they occur in some serial order
49.42 + * that is consistent with the order of the method calls made by each of
49.43 + * the individual threads involved.
49.44 + * <p>
49.45 + * The principal operations on a <code>StringBuffer</code> are the
49.46 + * <code>append</code> and <code>insert</code> methods, which are
49.47 + * overloaded so as to accept data of any type. Each effectively
49.48 + * converts a given datum to a string and then appends or inserts the
49.49 + * characters of that string to the string buffer. The
49.50 + * <code>append</code> method always adds these characters at the end
49.51 + * of the buffer; the <code>insert</code> method adds the characters at
49.52 + * a specified point.
49.53 + * <p>
49.54 + * For example, if <code>z</code> refers to a string buffer object
49.55 + * whose current contents are "<code>start</code>", then
49.56 + * the method call <code>z.append("le")</code> would cause the string
49.57 + * buffer to contain "<code>startle</code>", whereas
49.58 + * <code>z.insert(4, "le")</code> would alter the string buffer to
49.59 + * contain "<code>starlet</code>".
49.60 + * <p>
49.61 + * In general, if sb refers to an instance of a <code>StringBuffer</code>,
49.62 + * then <code>sb.append(x)</code> has the same effect as
49.63 + * <code>sb.insert(sb.length(), x)</code>.
49.64 + * <p>
49.65 + * Whenever an operation occurs involving a source sequence (such as
49.66 + * appending or inserting from a source sequence) this class synchronizes
49.67 + * only on the string buffer performing the operation, not on the source.
49.68 + * <p>
49.69 + * Every string buffer has a capacity. As long as the length of the
49.70 + * character sequence contained in the string buffer does not exceed
49.71 + * the capacity, it is not necessary to allocate a new internal
49.72 + * buffer array. If the internal buffer overflows, it is
49.73 + * automatically made larger.
49.74 + *
49.75 + * As of release JDK 5, this class has been supplemented with an equivalent
49.76 + * class designed for use by a single thread, {@link StringBuilder}. The
49.77 + * <tt>StringBuilder</tt> class should generally be used in preference to
49.78 + * this one, as it supports all of the same operations but it is faster, as
49.79 + * it performs no synchronization.
49.80 + *
49.81 + * @author Arthur van Hoff
49.82 + * @see java.lang.StringBuilder
49.83 + * @see java.lang.String
49.84 + * @since JDK1.0
49.85 + */
49.86 + public final class StringBuffer
49.87 + extends AbstractStringBuilder
49.88 + implements java.io.Serializable, CharSequence
49.89 +{
49.90 +
49.91 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
49.92 + static final long serialVersionUID = 3388685877147921107L;
49.93 +
49.94 + /**
49.95 + * Constructs a string buffer with no characters in it and an
49.96 + * initial capacity of 16 characters.
49.97 + */
49.98 + public StringBuffer() {
49.99 + super(16);
49.100 + }
49.101 +
49.102 + /**
49.103 + * Constructs a string buffer with no characters in it and
49.104 + * the specified initial capacity.
49.105 + *
49.106 + * @param capacity the initial capacity.
49.107 + * @exception NegativeArraySizeException if the <code>capacity</code>
49.108 + * argument is less than <code>0</code>.
49.109 + */
49.110 + public StringBuffer(int capacity) {
49.111 + super(capacity);
49.112 + }
49.113 +
49.114 + /**
49.115 + * Constructs a string buffer initialized to the contents of the
49.116 + * specified string. The initial capacity of the string buffer is
49.117 + * <code>16</code> plus the length of the string argument.
49.118 + *
49.119 + * @param str the initial contents of the buffer.
49.120 + * @exception NullPointerException if <code>str</code> is <code>null</code>
49.121 + */
49.122 + public StringBuffer(String str) {
49.123 + super(str.length() + 16);
49.124 + append(str);
49.125 + }
49.126 +
49.127 + /**
49.128 + * Constructs a string buffer that contains the same characters
49.129 + * as the specified <code>CharSequence</code>. The initial capacity of
49.130 + * the string buffer is <code>16</code> plus the length of the
49.131 + * <code>CharSequence</code> argument.
49.132 + * <p>
49.133 + * If the length of the specified <code>CharSequence</code> is
49.134 + * less than or equal to zero, then an empty buffer of capacity
49.135 + * <code>16</code> is returned.
49.136 + *
49.137 + * @param seq the sequence to copy.
49.138 + * @exception NullPointerException if <code>seq</code> is <code>null</code>
49.139 + * @since 1.5
49.140 + */
49.141 + public StringBuffer(CharSequence seq) {
49.142 + this(seq.length() + 16);
49.143 + append(seq);
49.144 + }
49.145 +
49.146 + public synchronized int length() {
49.147 + return count;
49.148 + }
49.149 +
49.150 + public synchronized int capacity() {
49.151 + return value.length;
49.152 + }
49.153 +
49.154 +
49.155 + public synchronized void ensureCapacity(int minimumCapacity) {
49.156 + if (minimumCapacity > value.length) {
49.157 + expandCapacity(minimumCapacity);
49.158 + }
49.159 + }
49.160 +
49.161 + /**
49.162 + * @since 1.5
49.163 + */
49.164 + public synchronized void trimToSize() {
49.165 + super.trimToSize();
49.166 + }
49.167 +
49.168 + /**
49.169 + * @throws IndexOutOfBoundsException {@inheritDoc}
49.170 + * @see #length()
49.171 + */
49.172 + public synchronized void setLength(int newLength) {
49.173 + super.setLength(newLength);
49.174 + }
49.175 +
49.176 + /**
49.177 + * @throws IndexOutOfBoundsException {@inheritDoc}
49.178 + * @see #length()
49.179 + */
49.180 + public synchronized char charAt(int index) {
49.181 + if ((index < 0) || (index >= count))
49.182 + throw new StringIndexOutOfBoundsException(index);
49.183 + return value[index];
49.184 + }
49.185 +
49.186 + /**
49.187 + * @since 1.5
49.188 + */
49.189 + public synchronized int codePointAt(int index) {
49.190 + return super.codePointAt(index);
49.191 + }
49.192 +
49.193 + /**
49.194 + * @since 1.5
49.195 + */
49.196 + public synchronized int codePointBefore(int index) {
49.197 + return super.codePointBefore(index);
49.198 + }
49.199 +
49.200 + /**
49.201 + * @since 1.5
49.202 + */
49.203 + public synchronized int codePointCount(int beginIndex, int endIndex) {
49.204 + return super.codePointCount(beginIndex, endIndex);
49.205 + }
49.206 +
49.207 + /**
49.208 + * @since 1.5
49.209 + */
49.210 + public synchronized int offsetByCodePoints(int index, int codePointOffset) {
49.211 + return super.offsetByCodePoints(index, codePointOffset);
49.212 + }
49.213 +
49.214 + /**
49.215 + * @throws NullPointerException {@inheritDoc}
49.216 + * @throws IndexOutOfBoundsException {@inheritDoc}
49.217 + */
49.218 + public synchronized void getChars(int srcBegin, int srcEnd, char[] dst,
49.219 + int dstBegin)
49.220 + {
49.221 + super.getChars(srcBegin, srcEnd, dst, dstBegin);
49.222 + }
49.223 +
49.224 + /**
49.225 + * @throws IndexOutOfBoundsException {@inheritDoc}
49.226 + * @see #length()
49.227 + */
49.228 + public synchronized void setCharAt(int index, char ch) {
49.229 + if ((index < 0) || (index >= count))
49.230 + throw new StringIndexOutOfBoundsException(index);
49.231 + value[index] = ch;
49.232 + }
49.233 +
49.234 + public synchronized StringBuffer append(Object obj) {
49.235 + super.append(String.valueOf(obj));
49.236 + return this;
49.237 + }
49.238 +
49.239 + public synchronized StringBuffer append(String str) {
49.240 + super.append(str);
49.241 + return this;
49.242 + }
49.243 +
49.244 + /**
49.245 + * Appends the specified <tt>StringBuffer</tt> to this sequence.
49.246 + * <p>
49.247 + * The characters of the <tt>StringBuffer</tt> argument are appended,
49.248 + * in order, to the contents of this <tt>StringBuffer</tt>, increasing the
49.249 + * length of this <tt>StringBuffer</tt> by the length of the argument.
49.250 + * If <tt>sb</tt> is <tt>null</tt>, then the four characters
49.251 + * <tt>"null"</tt> are appended to this <tt>StringBuffer</tt>.
49.252 + * <p>
49.253 + * Let <i>n</i> be the length of the old character sequence, the one
49.254 + * contained in the <tt>StringBuffer</tt> just prior to execution of the
49.255 + * <tt>append</tt> method. Then the character at index <i>k</i> in
49.256 + * the new character sequence is equal to the character at index <i>k</i>
49.257 + * in the old character sequence, if <i>k</i> is less than <i>n</i>;
49.258 + * otherwise, it is equal to the character at index <i>k-n</i> in the
49.259 + * argument <code>sb</code>.
49.260 + * <p>
49.261 + * This method synchronizes on <code>this</code> (the destination)
49.262 + * object but does not synchronize on the source (<code>sb</code>).
49.263 + *
49.264 + * @param sb the <tt>StringBuffer</tt> to append.
49.265 + * @return a reference to this object.
49.266 + * @since 1.4
49.267 + */
49.268 + public synchronized StringBuffer append(StringBuffer sb) {
49.269 + super.append(sb);
49.270 + return this;
49.271 + }
49.272 +
49.273 +
49.274 + /**
49.275 + * Appends the specified <code>CharSequence</code> to this
49.276 + * sequence.
49.277 + * <p>
49.278 + * The characters of the <code>CharSequence</code> argument are appended,
49.279 + * in order, increasing the length of this sequence by the length of the
49.280 + * argument.
49.281 + *
49.282 + * <p>The result of this method is exactly the same as if it were an
49.283 + * invocation of this.append(s, 0, s.length());
49.284 + *
49.285 + * <p>This method synchronizes on this (the destination)
49.286 + * object but does not synchronize on the source (<code>s</code>).
49.287 + *
49.288 + * <p>If <code>s</code> is <code>null</code>, then the four characters
49.289 + * <code>"null"</code> are appended.
49.290 + *
49.291 + * @param s the <code>CharSequence</code> to append.
49.292 + * @return a reference to this object.
49.293 + * @since 1.5
49.294 + */
49.295 + public StringBuffer append(CharSequence s) {
49.296 + // Note, synchronization achieved via other invocations
49.297 + if (s == null)
49.298 + s = "null";
49.299 + if (s instanceof String)
49.300 + return this.append((String)s);
49.301 + if (s instanceof StringBuffer)
49.302 + return this.append((StringBuffer)s);
49.303 + return this.append(s, 0, s.length());
49.304 + }
49.305 +
49.306 + /**
49.307 + * @throws IndexOutOfBoundsException {@inheritDoc}
49.308 + * @since 1.5
49.309 + */
49.310 + public synchronized StringBuffer append(CharSequence s, int start, int end)
49.311 + {
49.312 + super.append(s, start, end);
49.313 + return this;
49.314 + }
49.315 +
49.316 + public synchronized StringBuffer append(char[] str) {
49.317 + super.append(str);
49.318 + return this;
49.319 + }
49.320 +
49.321 + /**
49.322 + * @throws IndexOutOfBoundsException {@inheritDoc}
49.323 + */
49.324 + public synchronized StringBuffer append(char[] str, int offset, int len) {
49.325 + super.append(str, offset, len);
49.326 + return this;
49.327 + }
49.328 +
49.329 + public synchronized StringBuffer append(boolean b) {
49.330 + super.append(b);
49.331 + return this;
49.332 + }
49.333 +
49.334 + public synchronized StringBuffer append(char c) {
49.335 + super.append(c);
49.336 + return this;
49.337 + }
49.338 +
49.339 + public synchronized StringBuffer append(int i) {
49.340 + super.append(i);
49.341 + return this;
49.342 + }
49.343 +
49.344 + /**
49.345 + * @since 1.5
49.346 + */
49.347 + public synchronized StringBuffer appendCodePoint(int codePoint) {
49.348 + super.appendCodePoint(codePoint);
49.349 + return this;
49.350 + }
49.351 +
49.352 + public synchronized StringBuffer append(long lng) {
49.353 + super.append(lng);
49.354 + return this;
49.355 + }
49.356 +
49.357 + public synchronized StringBuffer append(float f) {
49.358 + super.append(f);
49.359 + return this;
49.360 + }
49.361 +
49.362 + public synchronized StringBuffer append(double d) {
49.363 + super.append(d);
49.364 + return this;
49.365 + }
49.366 +
49.367 + /**
49.368 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.369 + * @since 1.2
49.370 + */
49.371 + public synchronized StringBuffer delete(int start, int end) {
49.372 + super.delete(start, end);
49.373 + return this;
49.374 + }
49.375 +
49.376 + /**
49.377 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.378 + * @since 1.2
49.379 + */
49.380 + public synchronized StringBuffer deleteCharAt(int index) {
49.381 + super.deleteCharAt(index);
49.382 + return this;
49.383 + }
49.384 +
49.385 + /**
49.386 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.387 + * @since 1.2
49.388 + */
49.389 + public synchronized StringBuffer replace(int start, int end, String str) {
49.390 + super.replace(start, end, str);
49.391 + return this;
49.392 + }
49.393 +
49.394 + /**
49.395 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.396 + * @since 1.2
49.397 + */
49.398 + public synchronized String substring(int start) {
49.399 + return substring(start, count);
49.400 + }
49.401 +
49.402 + /**
49.403 + * @throws IndexOutOfBoundsException {@inheritDoc}
49.404 + * @since 1.4
49.405 + */
49.406 + public synchronized CharSequence subSequence(int start, int end) {
49.407 + return super.substring(start, end);
49.408 + }
49.409 +
49.410 + /**
49.411 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.412 + * @since 1.2
49.413 + */
49.414 + public synchronized String substring(int start, int end) {
49.415 + return super.substring(start, end);
49.416 + }
49.417 +
49.418 + /**
49.419 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.420 + * @since 1.2
49.421 + */
49.422 + public synchronized StringBuffer insert(int index, char[] str, int offset,
49.423 + int len)
49.424 + {
49.425 + super.insert(index, str, offset, len);
49.426 + return this;
49.427 + }
49.428 +
49.429 + /**
49.430 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.431 + */
49.432 + public synchronized StringBuffer insert(int offset, Object obj) {
49.433 + super.insert(offset, String.valueOf(obj));
49.434 + return this;
49.435 + }
49.436 +
49.437 + /**
49.438 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.439 + */
49.440 + public synchronized StringBuffer insert(int offset, String str) {
49.441 + super.insert(offset, str);
49.442 + return this;
49.443 + }
49.444 +
49.445 + /**
49.446 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.447 + */
49.448 + public synchronized StringBuffer insert(int offset, char[] str) {
49.449 + super.insert(offset, str);
49.450 + return this;
49.451 + }
49.452 +
49.453 + /**
49.454 + * @throws IndexOutOfBoundsException {@inheritDoc}
49.455 + * @since 1.5
49.456 + */
49.457 + public StringBuffer insert(int dstOffset, CharSequence s) {
49.458 + // Note, synchronization achieved via other invocations
49.459 + if (s == null)
49.460 + s = "null";
49.461 + if (s instanceof String)
49.462 + return this.insert(dstOffset, (String)s);
49.463 + return this.insert(dstOffset, s, 0, s.length());
49.464 + }
49.465 +
49.466 + /**
49.467 + * @throws IndexOutOfBoundsException {@inheritDoc}
49.468 + * @since 1.5
49.469 + */
49.470 + public synchronized StringBuffer insert(int dstOffset, CharSequence s,
49.471 + int start, int end)
49.472 + {
49.473 + super.insert(dstOffset, s, start, end);
49.474 + return this;
49.475 + }
49.476 +
49.477 + /**
49.478 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.479 + */
49.480 + public StringBuffer insert(int offset, boolean b) {
49.481 + return insert(offset, String.valueOf(b));
49.482 + }
49.483 +
49.484 + /**
49.485 + * @throws IndexOutOfBoundsException {@inheritDoc}
49.486 + */
49.487 + public synchronized StringBuffer insert(int offset, char c) {
49.488 + super.insert(offset, c);
49.489 + return this;
49.490 + }
49.491 +
49.492 + /**
49.493 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.494 + */
49.495 + public StringBuffer insert(int offset, int i) {
49.496 + return insert(offset, String.valueOf(i));
49.497 + }
49.498 +
49.499 + /**
49.500 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.501 + */
49.502 + public StringBuffer insert(int offset, long l) {
49.503 + return insert(offset, String.valueOf(l));
49.504 + }
49.505 +
49.506 + /**
49.507 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.508 + */
49.509 + public StringBuffer insert(int offset, float f) {
49.510 + return insert(offset, String.valueOf(f));
49.511 + }
49.512 +
49.513 + /**
49.514 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
49.515 + */
49.516 + public StringBuffer insert(int offset, double d) {
49.517 + return insert(offset, String.valueOf(d));
49.518 + }
49.519 +
49.520 + /**
49.521 + * @throws NullPointerException {@inheritDoc}
49.522 + * @since 1.4
49.523 + */
49.524 + public int indexOf(String str) {
49.525 + return indexOf(str, 0);
49.526 + }
49.527 +
49.528 + /**
49.529 + * @throws NullPointerException {@inheritDoc}
49.530 + * @since 1.4
49.531 + */
49.532 + public synchronized int indexOf(String str, int fromIndex) {
49.533 + return String.indexOf(value, 0, count,
49.534 + str.toCharArray(), 0, str.length(), fromIndex);
49.535 + }
49.536 +
49.537 + /**
49.538 + * @throws NullPointerException {@inheritDoc}
49.539 + * @since 1.4
49.540 + */
49.541 + public int lastIndexOf(String str) {
49.542 + // Note, synchronization achieved via other invocations
49.543 + return lastIndexOf(str, count);
49.544 + }
49.545 +
49.546 + /**
49.547 + * @throws NullPointerException {@inheritDoc}
49.548 + * @since 1.4
49.549 + */
49.550 + public synchronized int lastIndexOf(String str, int fromIndex) {
49.551 + return String.lastIndexOf(value, 0, count,
49.552 + str.toCharArray(), 0, str.length(), fromIndex);
49.553 + }
49.554 +
49.555 + /**
49.556 + * @since JDK1.0.2
49.557 + */
49.558 + public synchronized StringBuffer reverse() {
49.559 + super.reverse();
49.560 + return this;
49.561 + }
49.562 +
49.563 + public synchronized String toString() {
49.564 + return new String(value, 0, count);
49.565 + }
49.566 +
49.567 +// /**
49.568 +// * Serializable fields for StringBuffer.
49.569 +// *
49.570 +// * @serialField value char[]
49.571 +// * The backing character array of this StringBuffer.
49.572 +// * @serialField count int
49.573 +// * The number of characters in this StringBuffer.
49.574 +// * @serialField shared boolean
49.575 +// * A flag indicating whether the backing array is shared.
49.576 +// * The value is ignored upon deserialization.
49.577 +// */
49.578 +// private static final java.io.ObjectStreamField[] serialPersistentFields =
49.579 +// {
49.580 +// new java.io.ObjectStreamField("value", char[].class),
49.581 +// new java.io.ObjectStreamField("count", Integer.TYPE),
49.582 +// new java.io.ObjectStreamField("shared", Boolean.TYPE),
49.583 +// };
49.584 +//
49.585 +// /**
49.586 +// * readObject is called to restore the state of the StringBuffer from
49.587 +// * a stream.
49.588 +// */
49.589 +// private synchronized void writeObject(java.io.ObjectOutputStream s)
49.590 +// throws java.io.IOException {
49.591 +// java.io.ObjectOutputStream.PutField fields = s.putFields();
49.592 +// fields.put("value", value);
49.593 +// fields.put("count", count);
49.594 +// fields.put("shared", false);
49.595 +// s.writeFields();
49.596 +// }
49.597 +//
49.598 +// /**
49.599 +// * readObject is called to restore the state of the StringBuffer from
49.600 +// * a stream.
49.601 +// */
49.602 +// private void readObject(java.io.ObjectInputStream s)
49.603 +// throws java.io.IOException, ClassNotFoundException {
49.604 +// java.io.ObjectInputStream.GetField fields = s.readFields();
49.605 +// value = (char[])fields.get("value", null);
49.606 +// count = fields.get("count", 0);
49.607 +// }
49.608 +}
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
50.2 +++ b/emul/src/main/java/java/lang/StringBuilder.java Thu Oct 11 06:16:00 2012 -0700
50.3 @@ -0,0 +1,437 @@
50.4 +/*
50.5 + * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
50.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
50.7 + *
50.8 + * This code is free software; you can redistribute it and/or modify it
50.9 + * under the terms of the GNU General Public License version 2 only, as
50.10 + * published by the Free Software Foundation. Oracle designates this
50.11 + * particular file as subject to the "Classpath" exception as provided
50.12 + * by Oracle in the LICENSE file that accompanied this code.
50.13 + *
50.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
50.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
50.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
50.17 + * version 2 for more details (a copy is included in the LICENSE file that
50.18 + * accompanied this code).
50.19 + *
50.20 + * You should have received a copy of the GNU General Public License version
50.21 + * 2 along with this work; if not, write to the Free Software Foundation,
50.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
50.23 + *
50.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
50.25 + * or visit www.oracle.com if you need additional information or have any
50.26 + * questions.
50.27 + */
50.28 +
50.29 +package java.lang;
50.30 +
50.31 +
50.32 +/**
50.33 + * A mutable sequence of characters. This class provides an API compatible
50.34 + * with <code>StringBuffer</code>, but with no guarantee of synchronization.
50.35 + * This class is designed for use as a drop-in replacement for
50.36 + * <code>StringBuffer</code> in places where the string buffer was being
50.37 + * used by a single thread (as is generally the case). Where possible,
50.38 + * it is recommended that this class be used in preference to
50.39 + * <code>StringBuffer</code> as it will be faster under most implementations.
50.40 + *
50.41 + * <p>The principal operations on a <code>StringBuilder</code> are the
50.42 + * <code>append</code> and <code>insert</code> methods, which are
50.43 + * overloaded so as to accept data of any type. Each effectively
50.44 + * converts a given datum to a string and then appends or inserts the
50.45 + * characters of that string to the string builder. The
50.46 + * <code>append</code> method always adds these characters at the end
50.47 + * of the builder; the <code>insert</code> method adds the characters at
50.48 + * a specified point.
50.49 + * <p>
50.50 + * For example, if <code>z</code> refers to a string builder object
50.51 + * whose current contents are "<code>start</code>", then
50.52 + * the method call <code>z.append("le")</code> would cause the string
50.53 + * builder to contain "<code>startle</code>", whereas
50.54 + * <code>z.insert(4, "le")</code> would alter the string builder to
50.55 + * contain "<code>starlet</code>".
50.56 + * <p>
50.57 + * In general, if sb refers to an instance of a <code>StringBuilder</code>,
50.58 + * then <code>sb.append(x)</code> has the same effect as
50.59 + * <code>sb.insert(sb.length(), x)</code>.
50.60 + *
50.61 + * Every string builder has a capacity. As long as the length of the
50.62 + * character sequence contained in the string builder does not exceed
50.63 + * the capacity, it is not necessary to allocate a new internal
50.64 + * buffer. If the internal buffer overflows, it is automatically made larger.
50.65 + *
50.66 + * <p>Instances of <code>StringBuilder</code> are not safe for
50.67 + * use by multiple threads. If such synchronization is required then it is
50.68 + * recommended that {@link java.lang.StringBuffer} be used.
50.69 + *
50.70 + * @author Michael McCloskey
50.71 + * @see java.lang.StringBuffer
50.72 + * @see java.lang.String
50.73 + * @since 1.5
50.74 + */
50.75 +public final class StringBuilder
50.76 + extends AbstractStringBuilder
50.77 + implements java.io.Serializable, CharSequence
50.78 +{
50.79 +
50.80 + /** use serialVersionUID for interoperability */
50.81 + static final long serialVersionUID = 4383685877147921099L;
50.82 +
50.83 + /**
50.84 + * Constructs a string builder with no characters in it and an
50.85 + * initial capacity of 16 characters.
50.86 + */
50.87 + public StringBuilder() {
50.88 + super(16);
50.89 + }
50.90 +
50.91 + /**
50.92 + * Constructs a string builder with no characters in it and an
50.93 + * initial capacity specified by the <code>capacity</code> argument.
50.94 + *
50.95 + * @param capacity the initial capacity.
50.96 + * @throws NegativeArraySizeException if the <code>capacity</code>
50.97 + * argument is less than <code>0</code>.
50.98 + */
50.99 + public StringBuilder(int capacity) {
50.100 + super(capacity);
50.101 + }
50.102 +
50.103 + /**
50.104 + * Constructs a string builder initialized to the contents of the
50.105 + * specified string. The initial capacity of the string builder is
50.106 + * <code>16</code> plus the length of the string argument.
50.107 + *
50.108 + * @param str the initial contents of the buffer.
50.109 + * @throws NullPointerException if <code>str</code> is <code>null</code>
50.110 + */
50.111 + public StringBuilder(String str) {
50.112 + super(str.length() + 16);
50.113 + append(str);
50.114 + }
50.115 +
50.116 + /**
50.117 + * Constructs a string builder that contains the same characters
50.118 + * as the specified <code>CharSequence</code>. The initial capacity of
50.119 + * the string builder is <code>16</code> plus the length of the
50.120 + * <code>CharSequence</code> argument.
50.121 + *
50.122 + * @param seq the sequence to copy.
50.123 + * @throws NullPointerException if <code>seq</code> is <code>null</code>
50.124 + */
50.125 + public StringBuilder(CharSequence seq) {
50.126 + this(seq.length() + 16);
50.127 + append(seq);
50.128 + }
50.129 +
50.130 + public StringBuilder append(Object obj) {
50.131 + return append(String.valueOf(obj));
50.132 + }
50.133 +
50.134 + public StringBuilder append(String str) {
50.135 + super.append(str);
50.136 + return this;
50.137 + }
50.138 +
50.139 + // Appends the specified string builder to this sequence.
50.140 + private StringBuilder append(StringBuilder sb) {
50.141 + if (sb == null)
50.142 + return append("null");
50.143 + int len = sb.length();
50.144 + int newcount = count + len;
50.145 + if (newcount > value.length)
50.146 + expandCapacity(newcount);
50.147 + sb.getChars(0, len, value, count);
50.148 + count = newcount;
50.149 + return this;
50.150 + }
50.151 +
50.152 + /**
50.153 + * Appends the specified <tt>StringBuffer</tt> to this sequence.
50.154 + * <p>
50.155 + * The characters of the <tt>StringBuffer</tt> argument are appended,
50.156 + * in order, to this sequence, increasing the
50.157 + * length of this sequence by the length of the argument.
50.158 + * If <tt>sb</tt> is <tt>null</tt>, then the four characters
50.159 + * <tt>"null"</tt> are appended to this sequence.
50.160 + * <p>
50.161 + * Let <i>n</i> be the length of this character sequence just prior to
50.162 + * execution of the <tt>append</tt> method. Then the character at index
50.163 + * <i>k</i> in the new character sequence is equal to the character at
50.164 + * index <i>k</i> in the old character sequence, if <i>k</i> is less than
50.165 + * <i>n</i>; otherwise, it is equal to the character at index <i>k-n</i>
50.166 + * in the argument <code>sb</code>.
50.167 + *
50.168 + * @param sb the <tt>StringBuffer</tt> to append.
50.169 + * @return a reference to this object.
50.170 + */
50.171 + public StringBuilder append(StringBuffer sb) {
50.172 + super.append(sb);
50.173 + return this;
50.174 + }
50.175 +
50.176 + /**
50.177 + */
50.178 + public StringBuilder append(CharSequence s) {
50.179 + if (s == null)
50.180 + s = "null";
50.181 + if (s instanceof String)
50.182 + return this.append((String)s);
50.183 + if (s instanceof StringBuffer)
50.184 + return this.append((StringBuffer)s);
50.185 + if (s instanceof StringBuilder)
50.186 + return this.append((StringBuilder)s);
50.187 + return this.append(s, 0, s.length());
50.188 + }
50.189 +
50.190 + /**
50.191 + * @throws IndexOutOfBoundsException {@inheritDoc}
50.192 + */
50.193 + public StringBuilder append(CharSequence s, int start, int end) {
50.194 + super.append(s, start, end);
50.195 + return this;
50.196 + }
50.197 +
50.198 + public StringBuilder append(char[] str) {
50.199 + super.append(str);
50.200 + return this;
50.201 + }
50.202 +
50.203 + /**
50.204 + * @throws IndexOutOfBoundsException {@inheritDoc}
50.205 + */
50.206 + public StringBuilder append(char[] str, int offset, int len) {
50.207 + super.append(str, offset, len);
50.208 + return this;
50.209 + }
50.210 +
50.211 + public StringBuilder append(boolean b) {
50.212 + super.append(b);
50.213 + return this;
50.214 + }
50.215 +
50.216 + public StringBuilder append(char c) {
50.217 + super.append(c);
50.218 + return this;
50.219 + }
50.220 +
50.221 + public StringBuilder append(int i) {
50.222 + super.append(i);
50.223 + return this;
50.224 + }
50.225 +
50.226 + public StringBuilder append(long lng) {
50.227 + super.append(lng);
50.228 + return this;
50.229 + }
50.230 +
50.231 + public StringBuilder append(float f) {
50.232 + super.append(f);
50.233 + return this;
50.234 + }
50.235 +
50.236 + public StringBuilder append(double d) {
50.237 + super.append(d);
50.238 + return this;
50.239 + }
50.240 +
50.241 + /**
50.242 + * @since 1.5
50.243 + */
50.244 + public StringBuilder appendCodePoint(int codePoint) {
50.245 + super.appendCodePoint(codePoint);
50.246 + return this;
50.247 + }
50.248 +
50.249 + /**
50.250 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
50.251 + */
50.252 + public StringBuilder delete(int start, int end) {
50.253 + super.delete(start, end);
50.254 + return this;
50.255 + }
50.256 +
50.257 + /**
50.258 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
50.259 + */
50.260 + public StringBuilder deleteCharAt(int index) {
50.261 + super.deleteCharAt(index);
50.262 + return this;
50.263 + }
50.264 +
50.265 + /**
50.266 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
50.267 + */
50.268 + public StringBuilder replace(int start, int end, String str) {
50.269 + super.replace(start, end, str);
50.270 + return this;
50.271 + }
50.272 +
50.273 + /**
50.274 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
50.275 + */
50.276 + public StringBuilder insert(int index, char[] str, int offset,
50.277 + int len)
50.278 + {
50.279 + super.insert(index, str, offset, len);
50.280 + return this;
50.281 + }
50.282 +
50.283 + /**
50.284 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
50.285 + */
50.286 + public StringBuilder insert(int offset, Object obj) {
50.287 + return insert(offset, String.valueOf(obj));
50.288 + }
50.289 +
50.290 + /**
50.291 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
50.292 + */
50.293 + public StringBuilder insert(int offset, String str) {
50.294 + super.insert(offset, str);
50.295 + return this;
50.296 + }
50.297 +
50.298 + /**
50.299 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
50.300 + */
50.301 + public StringBuilder insert(int offset, char[] str) {
50.302 + super.insert(offset, str);
50.303 + return this;
50.304 + }
50.305 +
50.306 + /**
50.307 + * @throws IndexOutOfBoundsException {@inheritDoc}
50.308 + */
50.309 + public StringBuilder insert(int dstOffset, CharSequence s) {
50.310 + if (s == null)
50.311 + s = "null";
50.312 + if (s instanceof String)
50.313 + return this.insert(dstOffset, (String)s);
50.314 + return this.insert(dstOffset, s, 0, s.length());
50.315 + }
50.316 +
50.317 + /**
50.318 + * @throws IndexOutOfBoundsException {@inheritDoc}
50.319 + */
50.320 + public StringBuilder insert(int dstOffset, CharSequence s,
50.321 + int start, int end)
50.322 + {
50.323 + super.insert(dstOffset, s, start, end);
50.324 + return this;
50.325 + }
50.326 +
50.327 + /**
50.328 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
50.329 + */
50.330 + public StringBuilder insert(int offset, boolean b) {
50.331 + super.insert(offset, b);
50.332 + return this;
50.333 + }
50.334 +
50.335 + /**
50.336 + * @throws IndexOutOfBoundsException {@inheritDoc}
50.337 + */
50.338 + public StringBuilder insert(int offset, char c) {
50.339 + super.insert(offset, c);
50.340 + return this;
50.341 + }
50.342 +
50.343 + /**
50.344 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
50.345 + */
50.346 + public StringBuilder insert(int offset, int i) {
50.347 + return insert(offset, String.valueOf(i));
50.348 + }
50.349 +
50.350 + /**
50.351 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
50.352 + */
50.353 + public StringBuilder insert(int offset, long l) {
50.354 + return insert(offset, String.valueOf(l));
50.355 + }
50.356 +
50.357 + /**
50.358 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
50.359 + */
50.360 + public StringBuilder insert(int offset, float f) {
50.361 + return insert(offset, String.valueOf(f));
50.362 + }
50.363 +
50.364 + /**
50.365 + * @throws StringIndexOutOfBoundsException {@inheritDoc}
50.366 + */
50.367 + public StringBuilder insert(int offset, double d) {
50.368 + return insert(offset, String.valueOf(d));
50.369 + }
50.370 +
50.371 + /**
50.372 + * @throws NullPointerException {@inheritDoc}
50.373 + */
50.374 + public int indexOf(String str) {
50.375 + return indexOf(str, 0);
50.376 + }
50.377 +
50.378 + /**
50.379 + * @throws NullPointerException {@inheritDoc}
50.380 + */
50.381 + public int indexOf(String str, int fromIndex) {
50.382 + return String.indexOf(value, 0, count,
50.383 + str.toCharArray(), 0, str.length(), fromIndex);
50.384 + }
50.385 +
50.386 + /**
50.387 + * @throws NullPointerException {@inheritDoc}
50.388 + */
50.389 + public int lastIndexOf(String str) {
50.390 + return lastIndexOf(str, count);
50.391 + }
50.392 +
50.393 + /**
50.394 + * @throws NullPointerException {@inheritDoc}
50.395 + */
50.396 + public int lastIndexOf(String str, int fromIndex) {
50.397 + return String.lastIndexOf(value, 0, count,
50.398 + str.toCharArray(), 0, str.length(), fromIndex);
50.399 + }
50.400 +
50.401 + public StringBuilder reverse() {
50.402 + super.reverse();
50.403 + return this;
50.404 + }
50.405 +
50.406 + public String toString() {
50.407 + // Create a copy, don't share the array
50.408 + return new String(value, 0, count);
50.409 + }
50.410 +
50.411 + /**
50.412 + * Save the state of the <tt>StringBuilder</tt> instance to a stream
50.413 + * (that is, serialize it).
50.414 + *
50.415 + * @serialData the number of characters currently stored in the string
50.416 + * builder (<tt>int</tt>), followed by the characters in the
50.417 + * string builder (<tt>char[]</tt>). The length of the
50.418 + * <tt>char</tt> array may be greater than the number of
50.419 + * characters currently stored in the string builder, in which
50.420 + * case extra characters are ignored.
50.421 + */
50.422 +// private void writeObject(java.io.ObjectOutputStream s)
50.423 +// throws java.io.IOException {
50.424 +// s.defaultWriteObject();
50.425 +// s.writeInt(count);
50.426 +// s.writeObject(value);
50.427 +// }
50.428 +
50.429 + /**
50.430 + * readObject is called to restore the state of the StringBuffer from
50.431 + * a stream.
50.432 + */
50.433 +// private void readObject(java.io.ObjectInputStream s)
50.434 +// throws java.io.IOException, ClassNotFoundException {
50.435 +// s.defaultReadObject();
50.436 +// count = s.readInt();
50.437 +// value = (char[]) s.readObject();
50.438 +// }
50.439 +
50.440 +}
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
51.2 +++ b/emul/src/main/java/java/lang/StringIndexOutOfBoundsException.java Thu Oct 11 06:16:00 2012 -0700
51.3 @@ -0,0 +1,71 @@
51.4 +/*
51.5 + * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved.
51.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
51.7 + *
51.8 + * This code is free software; you can redistribute it and/or modify it
51.9 + * under the terms of the GNU General Public License version 2 only, as
51.10 + * published by the Free Software Foundation. Oracle designates this
51.11 + * particular file as subject to the "Classpath" exception as provided
51.12 + * by Oracle in the LICENSE file that accompanied this code.
51.13 + *
51.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
51.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
51.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
51.17 + * version 2 for more details (a copy is included in the LICENSE file that
51.18 + * accompanied this code).
51.19 + *
51.20 + * You should have received a copy of the GNU General Public License version
51.21 + * 2 along with this work; if not, write to the Free Software Foundation,
51.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
51.23 + *
51.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
51.25 + * or visit www.oracle.com if you need additional information or have any
51.26 + * questions.
51.27 + */
51.28 +
51.29 +package java.lang;
51.30 +
51.31 +/**
51.32 + * Thrown by <code>String</code> methods to indicate that an index
51.33 + * is either negative or greater than the size of the string. For
51.34 + * some methods such as the charAt method, this exception also is
51.35 + * thrown when the index is equal to the size of the string.
51.36 + *
51.37 + * @author unascribed
51.38 + * @see java.lang.String#charAt(int)
51.39 + * @since JDK1.0
51.40 + */
51.41 +public
51.42 +class StringIndexOutOfBoundsException extends IndexOutOfBoundsException {
51.43 + private static final long serialVersionUID = -6762910422159637258L;
51.44 +
51.45 + /**
51.46 + * Constructs a <code>StringIndexOutOfBoundsException</code> with no
51.47 + * detail message.
51.48 + *
51.49 + * @since JDK1.0.
51.50 + */
51.51 + public StringIndexOutOfBoundsException() {
51.52 + super();
51.53 + }
51.54 +
51.55 + /**
51.56 + * Constructs a <code>StringIndexOutOfBoundsException</code> with
51.57 + * the specified detail message.
51.58 + *
51.59 + * @param s the detail message.
51.60 + */
51.61 + public StringIndexOutOfBoundsException(String s) {
51.62 + super(s);
51.63 + }
51.64 +
51.65 + /**
51.66 + * Constructs a new <code>StringIndexOutOfBoundsException</code>
51.67 + * class with an argument indicating the illegal index.
51.68 + *
51.69 + * @param index the illegal index.
51.70 + */
51.71 + public StringIndexOutOfBoundsException(int index) {
51.72 + super("String index out of range: " + index);
51.73 + }
51.74 +}
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
52.2 +++ b/emul/src/main/java/java/lang/Throwable.java Thu Oct 11 06:16:00 2012 -0700
52.3 @@ -0,0 +1,1078 @@
52.4 +/*
52.5 + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
52.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
52.7 + *
52.8 + * This code is free software; you can redistribute it and/or modify it
52.9 + * under the terms of the GNU General Public License version 2 only, as
52.10 + * published by the Free Software Foundation. Oracle designates this
52.11 + * particular file as subject to the "Classpath" exception as provided
52.12 + * by Oracle in the LICENSE file that accompanied this code.
52.13 + *
52.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
52.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
52.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
52.17 + * version 2 for more details (a copy is included in the LICENSE file that
52.18 + * accompanied this code).
52.19 + *
52.20 + * You should have received a copy of the GNU General Public License version
52.21 + * 2 along with this work; if not, write to the Free Software Foundation,
52.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
52.23 + *
52.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
52.25 + * or visit www.oracle.com if you need additional information or have any
52.26 + * questions.
52.27 + */
52.28 +
52.29 +package java.lang;
52.30 +import java.io.*;
52.31 +
52.32 +/**
52.33 + * The {@code Throwable} class is the superclass of all errors and
52.34 + * exceptions in the Java language. Only objects that are instances of this
52.35 + * class (or one of its subclasses) are thrown by the Java Virtual Machine or
52.36 + * can be thrown by the Java {@code throw} statement. Similarly, only
52.37 + * this class or one of its subclasses can be the argument type in a
52.38 + * {@code catch} clause.
52.39 + *
52.40 + * For the purposes of compile-time checking of exceptions, {@code
52.41 + * Throwable} and any subclass of {@code Throwable} that is not also a
52.42 + * subclass of either {@link RuntimeException} or {@link Error} are
52.43 + * regarded as checked exceptions.
52.44 + *
52.45 + * <p>Instances of two subclasses, {@link java.lang.Error} and
52.46 + * {@link java.lang.Exception}, are conventionally used to indicate
52.47 + * that exceptional situations have occurred. Typically, these instances
52.48 + * are freshly created in the context of the exceptional situation so
52.49 + * as to include relevant information (such as stack trace data).
52.50 + *
52.51 + * <p>A throwable contains a snapshot of the execution stack of its
52.52 + * thread at the time it was created. It can also contain a message
52.53 + * string that gives more information about the error. Over time, a
52.54 + * throwable can {@linkplain Throwable#addSuppressed suppress} other
52.55 + * throwables from being propagated. Finally, the throwable can also
52.56 + * contain a <i>cause</i>: another throwable that caused this
52.57 + * throwable to be constructed. The recording of this causal information
52.58 + * is referred to as the <i>chained exception</i> facility, as the
52.59 + * cause can, itself, have a cause, and so on, leading to a "chain" of
52.60 + * exceptions, each caused by another.
52.61 + *
52.62 + * <p>One reason that a throwable may have a cause is that the class that
52.63 + * throws it is built atop a lower layered abstraction, and an operation on
52.64 + * the upper layer fails due to a failure in the lower layer. It would be bad
52.65 + * design to let the throwable thrown by the lower layer propagate outward, as
52.66 + * it is generally unrelated to the abstraction provided by the upper layer.
52.67 + * Further, doing so would tie the API of the upper layer to the details of
52.68 + * its implementation, assuming the lower layer's exception was a checked
52.69 + * exception. Throwing a "wrapped exception" (i.e., an exception containing a
52.70 + * cause) allows the upper layer to communicate the details of the failure to
52.71 + * its caller without incurring either of these shortcomings. It preserves
52.72 + * the flexibility to change the implementation of the upper layer without
52.73 + * changing its API (in particular, the set of exceptions thrown by its
52.74 + * methods).
52.75 + *
52.76 + * <p>A second reason that a throwable may have a cause is that the method
52.77 + * that throws it must conform to a general-purpose interface that does not
52.78 + * permit the method to throw the cause directly. For example, suppose
52.79 + * a persistent collection conforms to the {@link java.util.Collection
52.80 + * Collection} interface, and that its persistence is implemented atop
52.81 + * {@code java.io}. Suppose the internals of the {@code add} method
52.82 + * can throw an {@link java.io.IOException IOException}. The implementation
52.83 + * can communicate the details of the {@code IOException} to its caller
52.84 + * while conforming to the {@code Collection} interface by wrapping the
52.85 + * {@code IOException} in an appropriate unchecked exception. (The
52.86 + * specification for the persistent collection should indicate that it is
52.87 + * capable of throwing such exceptions.)
52.88 + *
52.89 + * <p>A cause can be associated with a throwable in two ways: via a
52.90 + * constructor that takes the cause as an argument, or via the
52.91 + * {@link #initCause(Throwable)} method. New throwable classes that
52.92 + * wish to allow causes to be associated with them should provide constructors
52.93 + * that take a cause and delegate (perhaps indirectly) to one of the
52.94 + * {@code Throwable} constructors that takes a cause.
52.95 + *
52.96 + * Because the {@code initCause} method is public, it allows a cause to be
52.97 + * associated with any throwable, even a "legacy throwable" whose
52.98 + * implementation predates the addition of the exception chaining mechanism to
52.99 + * {@code Throwable}.
52.100 + *
52.101 + * <p>By convention, class {@code Throwable} and its subclasses have two
52.102 + * constructors, one that takes no arguments and one that takes a
52.103 + * {@code String} argument that can be used to produce a detail message.
52.104 + * Further, those subclasses that might likely have a cause associated with
52.105 + * them should have two more constructors, one that takes a
52.106 + * {@code Throwable} (the cause), and one that takes a
52.107 + * {@code String} (the detail message) and a {@code Throwable} (the
52.108 + * cause).
52.109 + *
52.110 + * @author unascribed
52.111 + * @author Josh Bloch (Added exception chaining and programmatic access to
52.112 + * stack trace in 1.4.)
52.113 + * @jls 11.2 Compile-Time Checking of Exceptions
52.114 + * @since JDK1.0
52.115 + */
52.116 +public class Throwable implements Serializable {
52.117 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
52.118 + private static final long serialVersionUID = -3042686055658047285L;
52.119 +
52.120 + /**
52.121 + * Native code saves some indication of the stack backtrace in this slot.
52.122 + */
52.123 + private transient Object backtrace;
52.124 +
52.125 + /**
52.126 + * Specific details about the Throwable. For example, for
52.127 + * {@code FileNotFoundException}, this contains the name of
52.128 + * the file that could not be found.
52.129 + *
52.130 + * @serial
52.131 + */
52.132 + private String detailMessage;
52.133 +
52.134 +
52.135 + /**
52.136 + * Holder class to defer initializing sentinel objects only used
52.137 + * for serialization.
52.138 + */
52.139 + private static class SentinelHolder {
52.140 + /**
52.141 + * {@linkplain #setStackTrace(StackTraceElement[]) Setting the
52.142 + * stack trace} to a one-element array containing this sentinel
52.143 + * value indicates future attempts to set the stack trace will be
52.144 + * ignored. The sentinal is equal to the result of calling:<br>
52.145 + * {@code new StackTraceElement("", "", null, Integer.MIN_VALUE)}
52.146 + */
52.147 + public static final StackTraceElement STACK_TRACE_ELEMENT_SENTINEL =
52.148 + new StackTraceElement("", "", null, Integer.MIN_VALUE);
52.149 +
52.150 + /**
52.151 + * Sentinel value used in the serial form to indicate an immutable
52.152 + * stack trace.
52.153 + */
52.154 + public static final StackTraceElement[] STACK_TRACE_SENTINEL =
52.155 + new StackTraceElement[] {STACK_TRACE_ELEMENT_SENTINEL};
52.156 + }
52.157 +
52.158 + /**
52.159 + * A shared value for an empty stack.
52.160 + */
52.161 + private static final StackTraceElement[] UNASSIGNED_STACK = new StackTraceElement[0];
52.162 +
52.163 + /*
52.164 + * To allow Throwable objects to be made immutable and safely
52.165 + * reused by the JVM, such as OutOfMemoryErrors, fields of
52.166 + * Throwable that are writable in response to user actions, cause,
52.167 + * stackTrace, and suppressedExceptions obey the following
52.168 + * protocol:
52.169 + *
52.170 + * 1) The fields are initialized to a non-null sentinel value
52.171 + * which indicates the value has logically not been set.
52.172 + *
52.173 + * 2) Writing a null to the field indicates further writes
52.174 + * are forbidden
52.175 + *
52.176 + * 3) The sentinel value may be replaced with another non-null
52.177 + * value.
52.178 + *
52.179 + * For example, implementations of the HotSpot JVM have
52.180 + * preallocated OutOfMemoryError objects to provide for better
52.181 + * diagnosability of that situation. These objects are created
52.182 + * without calling the constructor for that class and the fields
52.183 + * in question are initialized to null. To support this
52.184 + * capability, any new fields added to Throwable that require
52.185 + * being initialized to a non-null value require a coordinated JVM
52.186 + * change.
52.187 + */
52.188 +
52.189 + /**
52.190 + * The throwable that caused this throwable to get thrown, or null if this
52.191 + * throwable was not caused by another throwable, or if the causative
52.192 + * throwable is unknown. If this field is equal to this throwable itself,
52.193 + * it indicates that the cause of this throwable has not yet been
52.194 + * initialized.
52.195 + *
52.196 + * @serial
52.197 + * @since 1.4
52.198 + */
52.199 + private Throwable cause = this;
52.200 +
52.201 + /**
52.202 + * The stack trace, as returned by {@link #getStackTrace()}.
52.203 + *
52.204 + * The field is initialized to a zero-length array. A {@code
52.205 + * null} value of this field indicates subsequent calls to {@link
52.206 + * #setStackTrace(StackTraceElement[])} and {@link
52.207 + * #fillInStackTrace()} will be be no-ops.
52.208 + *
52.209 + * @serial
52.210 + * @since 1.4
52.211 + */
52.212 + private StackTraceElement[] stackTrace = UNASSIGNED_STACK;
52.213 +
52.214 + // Setting this static field introduces an acceptable
52.215 + // initialization dependency on a few java.util classes.
52.216 +// I don't think this dependency is acceptable
52.217 +// private static final List<Throwable> SUPPRESSED_SENTINEL =
52.218 +// Collections.unmodifiableList(new ArrayList<Throwable>(0));
52.219 +
52.220 + /**
52.221 + * The list of suppressed exceptions, as returned by {@link
52.222 + * #getSuppressed()}. The list is initialized to a zero-element
52.223 + * unmodifiable sentinel list. When a serialized Throwable is
52.224 + * read in, if the {@code suppressedExceptions} field points to a
52.225 + * zero-element list, the field is reset to the sentinel value.
52.226 + *
52.227 + * @serial
52.228 + * @since 1.7
52.229 + */
52.230 +// private List<Throwable> suppressedExceptions = SUPPRESSED_SENTINEL;
52.231 +
52.232 + /** Message for trying to suppress a null exception. */
52.233 + private static final String NULL_CAUSE_MESSAGE = "Cannot suppress a null exception.";
52.234 +
52.235 + /** Message for trying to suppress oneself. */
52.236 + private static final String SELF_SUPPRESSION_MESSAGE = "Self-suppression not permitted";
52.237 +
52.238 + /** Caption for labeling causative exception stack traces */
52.239 + private static final String CAUSE_CAPTION = "Caused by: ";
52.240 +
52.241 + /** Caption for labeling suppressed exception stack traces */
52.242 + private static final String SUPPRESSED_CAPTION = "Suppressed: ";
52.243 +
52.244 + /**
52.245 + * Constructs a new throwable with {@code null} as its detail message.
52.246 + * The cause is not initialized, and may subsequently be initialized by a
52.247 + * call to {@link #initCause}.
52.248 + *
52.249 + * <p>The {@link #fillInStackTrace()} method is called to initialize
52.250 + * the stack trace data in the newly created throwable.
52.251 + */
52.252 + public Throwable() {
52.253 + fillInStackTrace();
52.254 + }
52.255 +
52.256 + /**
52.257 + * Constructs a new throwable with the specified detail message. The
52.258 + * cause is not initialized, and may subsequently be initialized by
52.259 + * a call to {@link #initCause}.
52.260 + *
52.261 + * <p>The {@link #fillInStackTrace()} method is called to initialize
52.262 + * the stack trace data in the newly created throwable.
52.263 + *
52.264 + * @param message the detail message. The detail message is saved for
52.265 + * later retrieval by the {@link #getMessage()} method.
52.266 + */
52.267 + public Throwable(String message) {
52.268 + fillInStackTrace();
52.269 + detailMessage = message;
52.270 + }
52.271 +
52.272 + /**
52.273 + * Constructs a new throwable with the specified detail message and
52.274 + * cause. <p>Note that the detail message associated with
52.275 + * {@code cause} is <i>not</i> automatically incorporated in
52.276 + * this throwable's detail message.
52.277 + *
52.278 + * <p>The {@link #fillInStackTrace()} method is called to initialize
52.279 + * the stack trace data in the newly created throwable.
52.280 + *
52.281 + * @param message the detail message (which is saved for later retrieval
52.282 + * by the {@link #getMessage()} method).
52.283 + * @param cause the cause (which is saved for later retrieval by the
52.284 + * {@link #getCause()} method). (A {@code null} value is
52.285 + * permitted, and indicates that the cause is nonexistent or
52.286 + * unknown.)
52.287 + * @since 1.4
52.288 + */
52.289 + public Throwable(String message, Throwable cause) {
52.290 + fillInStackTrace();
52.291 + detailMessage = message;
52.292 + this.cause = cause;
52.293 + }
52.294 +
52.295 + /**
52.296 + * Constructs a new throwable with the specified cause and a detail
52.297 + * message of {@code (cause==null ? null : cause.toString())} (which
52.298 + * typically contains the class and detail message of {@code cause}).
52.299 + * This constructor is useful for throwables that are little more than
52.300 + * wrappers for other throwables (for example, {@link
52.301 + * java.security.PrivilegedActionException}).
52.302 + *
52.303 + * <p>The {@link #fillInStackTrace()} method is called to initialize
52.304 + * the stack trace data in the newly created throwable.
52.305 + *
52.306 + * @param cause the cause (which is saved for later retrieval by the
52.307 + * {@link #getCause()} method). (A {@code null} value is
52.308 + * permitted, and indicates that the cause is nonexistent or
52.309 + * unknown.)
52.310 + * @since 1.4
52.311 + */
52.312 + public Throwable(Throwable cause) {
52.313 + fillInStackTrace();
52.314 + detailMessage = (cause==null ? null : cause.toString());
52.315 + this.cause = cause;
52.316 + }
52.317 +
52.318 + /**
52.319 + * Constructs a new throwable with the specified detail message,
52.320 + * cause, {@linkplain #addSuppressed suppression} enabled or
52.321 + * disabled, and writable stack trace enabled or disabled. If
52.322 + * suppression is disabled, {@link #getSuppressed} for this object
52.323 + * will return a zero-length array and calls to {@link
52.324 + * #addSuppressed} that would otherwise append an exception to the
52.325 + * suppressed list will have no effect. If the writable stack
52.326 + * trace is false, this constructor will not call {@link
52.327 + * #fillInStackTrace()}, a {@code null} will be written to the
52.328 + * {@code stackTrace} field, and subsequent calls to {@code
52.329 + * fillInStackTrace} and {@link
52.330 + * #setStackTrace(StackTraceElement[])} will not set the stack
52.331 + * trace. If the writable stack trace is false, {@link
52.332 + * #getStackTrace} will return a zero length array.
52.333 + *
52.334 + * <p>Note that the other constructors of {@code Throwable} treat
52.335 + * suppression as being enabled and the stack trace as being
52.336 + * writable. Subclasses of {@code Throwable} should document any
52.337 + * conditions under which suppression is disabled and document
52.338 + * conditions under which the stack trace is not writable.
52.339 + * Disabling of suppression should only occur in exceptional
52.340 + * circumstances where special requirements exist, such as a
52.341 + * virtual machine reusing exception objects under low-memory
52.342 + * situations. Circumstances where a given exception object is
52.343 + * repeatedly caught and rethrown, such as to implement control
52.344 + * flow between two sub-systems, is another situation where
52.345 + * immutable throwable objects would be appropriate.
52.346 + *
52.347 + * @param message the detail message.
52.348 + * @param cause the cause. (A {@code null} value is permitted,
52.349 + * and indicates that the cause is nonexistent or unknown.)
52.350 + * @param enableSuppression whether or not suppression is enabled or disabled
52.351 + * @param writableStackTrace whether or not the stack trace should be
52.352 + * writable
52.353 + *
52.354 + * @see OutOfMemoryError
52.355 + * @see NullPointerException
52.356 + * @see ArithmeticException
52.357 + * @since 1.7
52.358 + */
52.359 + protected Throwable(String message, Throwable cause,
52.360 + boolean enableSuppression,
52.361 + boolean writableStackTrace) {
52.362 + if (writableStackTrace) {
52.363 + fillInStackTrace();
52.364 + } else {
52.365 + stackTrace = null;
52.366 + }
52.367 + detailMessage = message;
52.368 + this.cause = cause;
52.369 +// if (!enableSuppression)
52.370 +// suppressedExceptions = null;
52.371 + }
52.372 +
52.373 + /**
52.374 + * Returns the detail message string of this throwable.
52.375 + *
52.376 + * @return the detail message string of this {@code Throwable} instance
52.377 + * (which may be {@code null}).
52.378 + */
52.379 + public String getMessage() {
52.380 + return detailMessage;
52.381 + }
52.382 +
52.383 + /**
52.384 + * Creates a localized description of this throwable.
52.385 + * Subclasses may override this method in order to produce a
52.386 + * locale-specific message. For subclasses that do not override this
52.387 + * method, the default implementation returns the same result as
52.388 + * {@code getMessage()}.
52.389 + *
52.390 + * @return The localized description of this throwable.
52.391 + * @since JDK1.1
52.392 + */
52.393 + public String getLocalizedMessage() {
52.394 + return getMessage();
52.395 + }
52.396 +
52.397 + /**
52.398 + * Returns the cause of this throwable or {@code null} if the
52.399 + * cause is nonexistent or unknown. (The cause is the throwable that
52.400 + * caused this throwable to get thrown.)
52.401 + *
52.402 + * <p>This implementation returns the cause that was supplied via one of
52.403 + * the constructors requiring a {@code Throwable}, or that was set after
52.404 + * creation with the {@link #initCause(Throwable)} method. While it is
52.405 + * typically unnecessary to override this method, a subclass can override
52.406 + * it to return a cause set by some other means. This is appropriate for
52.407 + * a "legacy chained throwable" that predates the addition of chained
52.408 + * exceptions to {@code Throwable}. Note that it is <i>not</i>
52.409 + * necessary to override any of the {@code PrintStackTrace} methods,
52.410 + * all of which invoke the {@code getCause} method to determine the
52.411 + * cause of a throwable.
52.412 + *
52.413 + * @return the cause of this throwable or {@code null} if the
52.414 + * cause is nonexistent or unknown.
52.415 + * @since 1.4
52.416 + */
52.417 + public synchronized Throwable getCause() {
52.418 + return (cause==this ? null : cause);
52.419 + }
52.420 +
52.421 + /**
52.422 + * Initializes the <i>cause</i> of this throwable to the specified value.
52.423 + * (The cause is the throwable that caused this throwable to get thrown.)
52.424 + *
52.425 + * <p>This method can be called at most once. It is generally called from
52.426 + * within the constructor, or immediately after creating the
52.427 + * throwable. If this throwable was created
52.428 + * with {@link #Throwable(Throwable)} or
52.429 + * {@link #Throwable(String,Throwable)}, this method cannot be called
52.430 + * even once.
52.431 + *
52.432 + * <p>An example of using this method on a legacy throwable type
52.433 + * without other support for setting the cause is:
52.434 + *
52.435 + * <pre>
52.436 + * try {
52.437 + * lowLevelOp();
52.438 + * } catch (LowLevelException le) {
52.439 + * throw (HighLevelException)
52.440 + * new HighLevelException().initCause(le); // Legacy constructor
52.441 + * }
52.442 + * </pre>
52.443 + *
52.444 + * @param cause the cause (which is saved for later retrieval by the
52.445 + * {@link #getCause()} method). (A {@code null} value is
52.446 + * permitted, and indicates that the cause is nonexistent or
52.447 + * unknown.)
52.448 + * @return a reference to this {@code Throwable} instance.
52.449 + * @throws IllegalArgumentException if {@code cause} is this
52.450 + * throwable. (A throwable cannot be its own cause.)
52.451 + * @throws IllegalStateException if this throwable was
52.452 + * created with {@link #Throwable(Throwable)} or
52.453 + * {@link #Throwable(String,Throwable)}, or this method has already
52.454 + * been called on this throwable.
52.455 + * @since 1.4
52.456 + */
52.457 + public synchronized Throwable initCause(Throwable cause) {
52.458 + if (this.cause != this)
52.459 + throw new IllegalStateException("Can't overwrite cause");
52.460 + if (cause == this)
52.461 + throw new IllegalArgumentException("Self-causation not permitted");
52.462 + this.cause = cause;
52.463 + return this;
52.464 + }
52.465 +
52.466 + /**
52.467 + * Returns a short description of this throwable.
52.468 + * The result is the concatenation of:
52.469 + * <ul>
52.470 + * <li> the {@linkplain Class#getName() name} of the class of this object
52.471 + * <li> ": " (a colon and a space)
52.472 + * <li> the result of invoking this object's {@link #getLocalizedMessage}
52.473 + * method
52.474 + * </ul>
52.475 + * If {@code getLocalizedMessage} returns {@code null}, then just
52.476 + * the class name is returned.
52.477 + *
52.478 + * @return a string representation of this throwable.
52.479 + */
52.480 + public String toString() {
52.481 + String s = getClass().getName();
52.482 + String message = getLocalizedMessage();
52.483 + return (message != null) ? (s + ": " + message) : s;
52.484 + }
52.485 +
52.486 + /**
52.487 + * Prints this throwable and its backtrace to the
52.488 + * standard error stream. This method prints a stack trace for this
52.489 + * {@code Throwable} object on the error output stream that is
52.490 + * the value of the field {@code System.err}. The first line of
52.491 + * output contains the result of the {@link #toString()} method for
52.492 + * this object. Remaining lines represent data previously recorded by
52.493 + * the method {@link #fillInStackTrace()}. The format of this
52.494 + * information depends on the implementation, but the following
52.495 + * example may be regarded as typical:
52.496 + * <blockquote><pre>
52.497 + * java.lang.NullPointerException
52.498 + * at MyClass.mash(MyClass.java:9)
52.499 + * at MyClass.crunch(MyClass.java:6)
52.500 + * at MyClass.main(MyClass.java:3)
52.501 + * </pre></blockquote>
52.502 + * This example was produced by running the program:
52.503 + * <pre>
52.504 + * class MyClass {
52.505 + * public static void main(String[] args) {
52.506 + * crunch(null);
52.507 + * }
52.508 + * static void crunch(int[] a) {
52.509 + * mash(a);
52.510 + * }
52.511 + * static void mash(int[] b) {
52.512 + * System.out.println(b[0]);
52.513 + * }
52.514 + * }
52.515 + * </pre>
52.516 + * The backtrace for a throwable with an initialized, non-null cause
52.517 + * should generally include the backtrace for the cause. The format
52.518 + * of this information depends on the implementation, but the following
52.519 + * example may be regarded as typical:
52.520 + * <pre>
52.521 + * HighLevelException: MidLevelException: LowLevelException
52.522 + * at Junk.a(Junk.java:13)
52.523 + * at Junk.main(Junk.java:4)
52.524 + * Caused by: MidLevelException: LowLevelException
52.525 + * at Junk.c(Junk.java:23)
52.526 + * at Junk.b(Junk.java:17)
52.527 + * at Junk.a(Junk.java:11)
52.528 + * ... 1 more
52.529 + * Caused by: LowLevelException
52.530 + * at Junk.e(Junk.java:30)
52.531 + * at Junk.d(Junk.java:27)
52.532 + * at Junk.c(Junk.java:21)
52.533 + * ... 3 more
52.534 + * </pre>
52.535 + * Note the presence of lines containing the characters {@code "..."}.
52.536 + * These lines indicate that the remainder of the stack trace for this
52.537 + * exception matches the indicated number of frames from the bottom of the
52.538 + * stack trace of the exception that was caused by this exception (the
52.539 + * "enclosing" exception). This shorthand can greatly reduce the length
52.540 + * of the output in the common case where a wrapped exception is thrown
52.541 + * from same method as the "causative exception" is caught. The above
52.542 + * example was produced by running the program:
52.543 + * <pre>
52.544 + * public class Junk {
52.545 + * public static void main(String args[]) {
52.546 + * try {
52.547 + * a();
52.548 + * } catch(HighLevelException e) {
52.549 + * e.printStackTrace();
52.550 + * }
52.551 + * }
52.552 + * static void a() throws HighLevelException {
52.553 + * try {
52.554 + * b();
52.555 + * } catch(MidLevelException e) {
52.556 + * throw new HighLevelException(e);
52.557 + * }
52.558 + * }
52.559 + * static void b() throws MidLevelException {
52.560 + * c();
52.561 + * }
52.562 + * static void c() throws MidLevelException {
52.563 + * try {
52.564 + * d();
52.565 + * } catch(LowLevelException e) {
52.566 + * throw new MidLevelException(e);
52.567 + * }
52.568 + * }
52.569 + * static void d() throws LowLevelException {
52.570 + * e();
52.571 + * }
52.572 + * static void e() throws LowLevelException {
52.573 + * throw new LowLevelException();
52.574 + * }
52.575 + * }
52.576 + *
52.577 + * class HighLevelException extends Exception {
52.578 + * HighLevelException(Throwable cause) { super(cause); }
52.579 + * }
52.580 + *
52.581 + * class MidLevelException extends Exception {
52.582 + * MidLevelException(Throwable cause) { super(cause); }
52.583 + * }
52.584 + *
52.585 + * class LowLevelException extends Exception {
52.586 + * }
52.587 + * </pre>
52.588 + * As of release 7, the platform supports the notion of
52.589 + * <i>suppressed exceptions</i> (in conjunction with the {@code
52.590 + * try}-with-resources statement). Any exceptions that were
52.591 + * suppressed in order to deliver an exception are printed out
52.592 + * beneath the stack trace. The format of this information
52.593 + * depends on the implementation, but the following example may be
52.594 + * regarded as typical:
52.595 + *
52.596 + * <pre>
52.597 + * Exception in thread "main" java.lang.Exception: Something happened
52.598 + * at Foo.bar(Foo.java:10)
52.599 + * at Foo.main(Foo.java:5)
52.600 + * Suppressed: Resource$CloseFailException: Resource ID = 0
52.601 + * at Resource.close(Resource.java:26)
52.602 + * at Foo.bar(Foo.java:9)
52.603 + * ... 1 more
52.604 + * </pre>
52.605 + * Note that the "... n more" notation is used on suppressed exceptions
52.606 + * just at it is used on causes. Unlike causes, suppressed exceptions are
52.607 + * indented beyond their "containing exceptions."
52.608 + *
52.609 + * <p>An exception can have both a cause and one or more suppressed
52.610 + * exceptions:
52.611 + * <pre>
52.612 + * Exception in thread "main" java.lang.Exception: Main block
52.613 + * at Foo3.main(Foo3.java:7)
52.614 + * Suppressed: Resource$CloseFailException: Resource ID = 2
52.615 + * at Resource.close(Resource.java:26)
52.616 + * at Foo3.main(Foo3.java:5)
52.617 + * Suppressed: Resource$CloseFailException: Resource ID = 1
52.618 + * at Resource.close(Resource.java:26)
52.619 + * at Foo3.main(Foo3.java:5)
52.620 + * Caused by: java.lang.Exception: I did it
52.621 + * at Foo3.main(Foo3.java:8)
52.622 + * </pre>
52.623 + * Likewise, a suppressed exception can have a cause:
52.624 + * <pre>
52.625 + * Exception in thread "main" java.lang.Exception: Main block
52.626 + * at Foo4.main(Foo4.java:6)
52.627 + * Suppressed: Resource2$CloseFailException: Resource ID = 1
52.628 + * at Resource2.close(Resource2.java:20)
52.629 + * at Foo4.main(Foo4.java:5)
52.630 + * Caused by: java.lang.Exception: Rats, you caught me
52.631 + * at Resource2$CloseFailException.<init>(Resource2.java:45)
52.632 + * ... 2 more
52.633 + * </pre>
52.634 + */
52.635 +// public void printStackTrace() {
52.636 +// printStackTrace(System.err);
52.637 +// }
52.638 +//
52.639 +// /**
52.640 +// * Prints this throwable and its backtrace to the specified print stream.
52.641 +// *
52.642 +// * @param s {@code PrintStream} to use for output
52.643 +// */
52.644 +// public void printStackTrace(PrintStream s) {
52.645 +// printStackTrace(new WrappedPrintStream(s));
52.646 +// }
52.647 +//
52.648 +// private void printStackTrace(PrintStreamOrWriter s) {
52.649 +// // Guard against malicious overrides of Throwable.equals by
52.650 +// // using a Set with identity equality semantics.
52.651 +//// Set<Throwable> dejaVu =
52.652 +//// Collections.newSetFromMap(new IdentityHashMap<Throwable, Boolean>());
52.653 +//// dejaVu.add(this);
52.654 +//
52.655 +// synchronized (s.lock()) {
52.656 +// // Print our stack trace
52.657 +// s.println(this);
52.658 +// StackTraceElement[] trace = getOurStackTrace();
52.659 +// for (StackTraceElement traceElement : trace)
52.660 +// s.println("\tat " + traceElement);
52.661 +//
52.662 +// // Print suppressed exceptions, if any
52.663 +//// for (Throwable se : getSuppressed())
52.664 +//// se.printEnclosedStackTrace(s, trace, SUPPRESSED_CAPTION, "\t", dejaVu);
52.665 +//
52.666 +// // Print cause, if any
52.667 +// Throwable ourCause = getCause();
52.668 +//// if (ourCause != null)
52.669 +//// ourCause.printEnclosedStackTrace(s, trace, CAUSE_CAPTION, "", dejaVu);
52.670 +// }
52.671 +// }
52.672 +//
52.673 +// /**
52.674 +// * Print our stack trace as an enclosed exception for the specified
52.675 +// * stack trace.
52.676 +// */
52.677 +// private void printEnclosedStackTrace(PrintStreamOrWriter s,
52.678 +// StackTraceElement[] enclosingTrace,
52.679 +// String caption,
52.680 +// String prefix,
52.681 +// Object dejaVu) {
52.682 +// assert Thread.holdsLock(s.lock());
52.683 +// {
52.684 +// // Compute number of frames in common between this and enclosing trace
52.685 +// StackTraceElement[] trace = getOurStackTrace();
52.686 +// int m = trace.length - 1;
52.687 +// int n = enclosingTrace.length - 1;
52.688 +// while (m >= 0 && n >=0 && trace[m].equals(enclosingTrace[n])) {
52.689 +// m--; n--;
52.690 +// }
52.691 +// int framesInCommon = trace.length - 1 - m;
52.692 +//
52.693 +// // Print our stack trace
52.694 +// s.println(prefix + caption + this);
52.695 +// for (int i = 0; i <= m; i++)
52.696 +// s.println(prefix + "\tat " + trace[i]);
52.697 +// if (framesInCommon != 0)
52.698 +// s.println(prefix + "\t... " + framesInCommon + " more");
52.699 +//
52.700 +// // Print suppressed exceptions, if any
52.701 +// for (Throwable se : getSuppressed())
52.702 +// se.printEnclosedStackTrace(s, trace, SUPPRESSED_CAPTION,
52.703 +// prefix +"\t", dejaVu);
52.704 +//
52.705 +// // Print cause, if any
52.706 +// Throwable ourCause = getCause();
52.707 +// if (ourCause != null)
52.708 +// ourCause.printEnclosedStackTrace(s, trace, CAUSE_CAPTION, prefix, dejaVu);
52.709 +// }
52.710 +// }
52.711 +//
52.712 +// /**
52.713 +// * Prints this throwable and its backtrace to the specified
52.714 +// * print writer.
52.715 +// *
52.716 +// * @param s {@code PrintWriter} to use for output
52.717 +// * @since JDK1.1
52.718 +// */
52.719 +// public void printStackTrace(PrintWriter s) {
52.720 +// printStackTrace(new WrappedPrintWriter(s));
52.721 +// }
52.722 +//
52.723 +// /**
52.724 +// * Wrapper class for PrintStream and PrintWriter to enable a single
52.725 +// * implementation of printStackTrace.
52.726 +// */
52.727 +// private abstract static class PrintStreamOrWriter {
52.728 +// /** Returns the object to be locked when using this StreamOrWriter */
52.729 +// abstract Object lock();
52.730 +//
52.731 +// /** Prints the specified string as a line on this StreamOrWriter */
52.732 +// abstract void println(Object o);
52.733 +// }
52.734 +//
52.735 +// private static class WrappedPrintStream extends PrintStreamOrWriter {
52.736 +// private final PrintStream printStream;
52.737 +//
52.738 +// WrappedPrintStream(PrintStream printStream) {
52.739 +// this.printStream = printStream;
52.740 +// }
52.741 +//
52.742 +// Object lock() {
52.743 +// return printStream;
52.744 +// }
52.745 +//
52.746 +// void println(Object o) {
52.747 +// printStream.println(o);
52.748 +// }
52.749 +// }
52.750 +//
52.751 +// private static class WrappedPrintWriter extends PrintStreamOrWriter {
52.752 +// private final PrintWriter printWriter;
52.753 +//
52.754 +// WrappedPrintWriter(PrintWriter printWriter) {
52.755 +// this.printWriter = printWriter;
52.756 +// }
52.757 +//
52.758 +// Object lock() {
52.759 +// return printWriter;
52.760 +// }
52.761 +//
52.762 +// void println(Object o) {
52.763 +// printWriter.println(o);
52.764 +// }
52.765 +// }
52.766 +
52.767 + /**
52.768 + * Fills in the execution stack trace. This method records within this
52.769 + * {@code Throwable} object information about the current state of
52.770 + * the stack frames for the current thread.
52.771 + *
52.772 + * <p>If the stack trace of this {@code Throwable} {@linkplain
52.773 + * Throwable#Throwable(String, Throwable, boolean, boolean) is not
52.774 + * writable}, calling this method has no effect.
52.775 + *
52.776 + * @return a reference to this {@code Throwable} instance.
52.777 + * @see java.lang.Throwable#printStackTrace()
52.778 + */
52.779 + public synchronized Throwable fillInStackTrace() {
52.780 + if (stackTrace != null ||
52.781 + backtrace != null /* Out of protocol state */ ) {
52.782 + fillInStackTrace(0);
52.783 + stackTrace = UNASSIGNED_STACK;
52.784 + }
52.785 + return this;
52.786 + }
52.787 +
52.788 + private native Throwable fillInStackTrace(int dummy);
52.789 +
52.790 + /**
52.791 + * Provides programmatic access to the stack trace information printed by
52.792 + * {@link #printStackTrace()}. Returns an array of stack trace elements,
52.793 + * each representing one stack frame. The zeroth element of the array
52.794 + * (assuming the array's length is non-zero) represents the top of the
52.795 + * stack, which is the last method invocation in the sequence. Typically,
52.796 + * this is the point at which this throwable was created and thrown.
52.797 + * The last element of the array (assuming the array's length is non-zero)
52.798 + * represents the bottom of the stack, which is the first method invocation
52.799 + * in the sequence.
52.800 + *
52.801 + * <p>Some virtual machines may, under some circumstances, omit one
52.802 + * or more stack frames from the stack trace. In the extreme case,
52.803 + * a virtual machine that has no stack trace information concerning
52.804 + * this throwable is permitted to return a zero-length array from this
52.805 + * method. Generally speaking, the array returned by this method will
52.806 + * contain one element for every frame that would be printed by
52.807 + * {@code printStackTrace}. Writes to the returned array do not
52.808 + * affect future calls to this method.
52.809 + *
52.810 + * @return an array of stack trace elements representing the stack trace
52.811 + * pertaining to this throwable.
52.812 + * @since 1.4
52.813 + */
52.814 + public StackTraceElement[] getStackTrace() {
52.815 + return getOurStackTrace().clone();
52.816 + }
52.817 +
52.818 + private synchronized StackTraceElement[] getOurStackTrace() {
52.819 + // Initialize stack trace field with information from
52.820 + // backtrace if this is the first call to this method
52.821 + if (stackTrace == UNASSIGNED_STACK ||
52.822 + (stackTrace == null && backtrace != null) /* Out of protocol state */) {
52.823 + int depth = getStackTraceDepth();
52.824 + stackTrace = new StackTraceElement[depth];
52.825 + for (int i=0; i < depth; i++)
52.826 + stackTrace[i] = getStackTraceElement(i);
52.827 + } else if (stackTrace == null) {
52.828 + return UNASSIGNED_STACK;
52.829 + }
52.830 + return stackTrace;
52.831 + }
52.832 +
52.833 + /**
52.834 + * Sets the stack trace elements that will be returned by
52.835 + * {@link #getStackTrace()} and printed by {@link #printStackTrace()}
52.836 + * and related methods.
52.837 + *
52.838 + * This method, which is designed for use by RPC frameworks and other
52.839 + * advanced systems, allows the client to override the default
52.840 + * stack trace that is either generated by {@link #fillInStackTrace()}
52.841 + * when a throwable is constructed or deserialized when a throwable is
52.842 + * read from a serialization stream.
52.843 + *
52.844 + * <p>If the stack trace of this {@code Throwable} {@linkplain
52.845 + * Throwable#Throwable(String, Throwable, boolean, boolean) is not
52.846 + * writable}, calling this method has no effect other than
52.847 + * validating its argument.
52.848 + *
52.849 + * @param stackTrace the stack trace elements to be associated with
52.850 + * this {@code Throwable}. The specified array is copied by this
52.851 + * call; changes in the specified array after the method invocation
52.852 + * returns will have no affect on this {@code Throwable}'s stack
52.853 + * trace.
52.854 + *
52.855 + * @throws NullPointerException if {@code stackTrace} is
52.856 + * {@code null} or if any of the elements of
52.857 + * {@code stackTrace} are {@code null}
52.858 + *
52.859 + * @since 1.4
52.860 + */
52.861 + public void setStackTrace(StackTraceElement[] stackTrace) {
52.862 + // Validate argument
52.863 + StackTraceElement[] defensiveCopy = stackTrace.clone();
52.864 + for (int i = 0; i < defensiveCopy.length; i++) {
52.865 + if (defensiveCopy[i] == null)
52.866 + throw new NullPointerException("stackTrace[" + i + "]");
52.867 + }
52.868 +
52.869 + synchronized (this) {
52.870 + if (this.stackTrace == null && // Immutable stack
52.871 + backtrace == null) // Test for out of protocol state
52.872 + return;
52.873 + this.stackTrace = defensiveCopy;
52.874 + }
52.875 + }
52.876 +
52.877 + /**
52.878 + * Returns the number of elements in the stack trace (or 0 if the stack
52.879 + * trace is unavailable).
52.880 + *
52.881 + * package-protection for use by SharedSecrets.
52.882 + */
52.883 + native int getStackTraceDepth();
52.884 +
52.885 + /**
52.886 + * Returns the specified element of the stack trace.
52.887 + *
52.888 + * package-protection for use by SharedSecrets.
52.889 + *
52.890 + * @param index index of the element to return.
52.891 + * @throws IndexOutOfBoundsException if {@code index < 0 ||
52.892 + * index >= getStackTraceDepth() }
52.893 + */
52.894 + native StackTraceElement getStackTraceElement(int index);
52.895 +
52.896 + /**
52.897 + * Reads a {@code Throwable} from a stream, enforcing
52.898 + * well-formedness constraints on fields. Null entries and
52.899 + * self-pointers are not allowed in the list of {@code
52.900 + * suppressedExceptions}. Null entries are not allowed for stack
52.901 + * trace elements. A null stack trace in the serial form results
52.902 + * in a zero-length stack element array. A single-element stack
52.903 + * trace whose entry is equal to {@code new StackTraceElement("",
52.904 + * "", null, Integer.MIN_VALUE)} results in a {@code null} {@code
52.905 + * stackTrace} field.
52.906 + *
52.907 + * Note that there are no constraints on the value the {@code
52.908 + * cause} field can hold; both {@code null} and {@code this} are
52.909 + * valid values for the field.
52.910 + */
52.911 +// private void readObject(ObjectInputStream s)
52.912 +// throws IOException, ClassNotFoundException {
52.913 +// s.defaultReadObject(); // read in all fields
52.914 +// if (suppressedExceptions != null) {
52.915 +// List<Throwable> suppressed = null;
52.916 +// if (suppressedExceptions.isEmpty()) {
52.917 +// // Use the sentinel for a zero-length list
52.918 +// suppressed = SUPPRESSED_SENTINEL;
52.919 +// } else { // Copy Throwables to new list
52.920 +// suppressed = new ArrayList<Throwable>(1);
52.921 +// for (Throwable t : suppressedExceptions) {
52.922 +// // Enforce constraints on suppressed exceptions in
52.923 +// // case of corrupt or malicious stream.
52.924 +// if (t == null)
52.925 +// throw new NullPointerException(NULL_CAUSE_MESSAGE);
52.926 +// if (t == this)
52.927 +// throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE);
52.928 +// suppressed.add(t);
52.929 +// }
52.930 +// }
52.931 +// suppressedExceptions = suppressed;
52.932 +// } // else a null suppressedExceptions field remains null
52.933 +//
52.934 +// /*
52.935 +// * For zero-length stack traces, use a clone of
52.936 +// * UNASSIGNED_STACK rather than UNASSIGNED_STACK itself to
52.937 +// * allow identity comparison against UNASSIGNED_STACK in
52.938 +// * getOurStackTrace. The identity of UNASSIGNED_STACK in
52.939 +// * stackTrace indicates to the getOurStackTrace method that
52.940 +// * the stackTrace needs to be constructed from the information
52.941 +// * in backtrace.
52.942 +// */
52.943 +// if (stackTrace != null) {
52.944 +// if (stackTrace.length == 0) {
52.945 +// stackTrace = UNASSIGNED_STACK.clone();
52.946 +// } else if (stackTrace.length == 1 &&
52.947 +// // Check for the marker of an immutable stack trace
52.948 +// SentinelHolder.STACK_TRACE_ELEMENT_SENTINEL.equals(stackTrace[0])) {
52.949 +// stackTrace = null;
52.950 +// } else { // Verify stack trace elements are non-null.
52.951 +// for(StackTraceElement ste : stackTrace) {
52.952 +// if (ste == null)
52.953 +// throw new NullPointerException("null StackTraceElement in serial stream. ");
52.954 +// }
52.955 +// }
52.956 +// } else {
52.957 +// // A null stackTrace field in the serial form can result
52.958 +// // from an exception serialized without that field in
52.959 +// // older JDK releases; treat such exceptions as having
52.960 +// // empty stack traces.
52.961 +// stackTrace = UNASSIGNED_STACK.clone();
52.962 +// }
52.963 +// }
52.964 +
52.965 + /**
52.966 + * Write a {@code Throwable} object to a stream.
52.967 + *
52.968 + * A {@code null} stack trace field is represented in the serial
52.969 + * form as a one-element array whose element is equal to {@code
52.970 + * new StackTraceElement("", "", null, Integer.MIN_VALUE)}.
52.971 + */
52.972 +// private synchronized void writeObject(ObjectOutputStream s)
52.973 +// throws IOException {
52.974 +// // Ensure that the stackTrace field is initialized to a
52.975 +// // non-null value, if appropriate. As of JDK 7, a null stack
52.976 +// // trace field is a valid value indicating the stack trace
52.977 +// // should not be set.
52.978 +// getOurStackTrace();
52.979 +//
52.980 +// StackTraceElement[] oldStackTrace = stackTrace;
52.981 +// try {
52.982 +// if (stackTrace == null)
52.983 +// stackTrace = SentinelHolder.STACK_TRACE_SENTINEL;
52.984 +// s.defaultWriteObject();
52.985 +// } finally {
52.986 +// stackTrace = oldStackTrace;
52.987 +// }
52.988 +// }
52.989 +
52.990 + /**
52.991 + * Appends the specified exception to the exceptions that were
52.992 + * suppressed in order to deliver this exception. This method is
52.993 + * thread-safe and typically called (automatically and implicitly)
52.994 + * by the {@code try}-with-resources statement.
52.995 + *
52.996 + * <p>The suppression behavior is enabled <em>unless</em> disabled
52.997 + * {@linkplain #Throwable(String, Throwable, boolean, boolean) via
52.998 + * a constructor}. When suppression is disabled, this method does
52.999 + * nothing other than to validate its argument.
52.1000 + *
52.1001 + * <p>Note that when one exception {@linkplain
52.1002 + * #initCause(Throwable) causes} another exception, the first
52.1003 + * exception is usually caught and then the second exception is
52.1004 + * thrown in response. In other words, there is a causal
52.1005 + * connection between the two exceptions.
52.1006 + *
52.1007 + * In contrast, there are situations where two independent
52.1008 + * exceptions can be thrown in sibling code blocks, in particular
52.1009 + * in the {@code try} block of a {@code try}-with-resources
52.1010 + * statement and the compiler-generated {@code finally} block
52.1011 + * which closes the resource.
52.1012 + *
52.1013 + * In these situations, only one of the thrown exceptions can be
52.1014 + * propagated. In the {@code try}-with-resources statement, when
52.1015 + * there are two such exceptions, the exception originating from
52.1016 + * the {@code try} block is propagated and the exception from the
52.1017 + * {@code finally} block is added to the list of exceptions
52.1018 + * suppressed by the exception from the {@code try} block. As an
52.1019 + * exception unwinds the stack, it can accumulate multiple
52.1020 + * suppressed exceptions.
52.1021 + *
52.1022 + * <p>An exception may have suppressed exceptions while also being
52.1023 + * caused by another exception. Whether or not an exception has a
52.1024 + * cause is semantically known at the time of its creation, unlike
52.1025 + * whether or not an exception will suppress other exceptions
52.1026 + * which is typically only determined after an exception is
52.1027 + * thrown.
52.1028 + *
52.1029 + * <p>Note that programmer written code is also able to take
52.1030 + * advantage of calling this method in situations where there are
52.1031 + * multiple sibling exceptions and only one can be propagated.
52.1032 + *
52.1033 + * @param exception the exception to be added to the list of
52.1034 + * suppressed exceptions
52.1035 + * @throws IllegalArgumentException if {@code exception} is this
52.1036 + * throwable; a throwable cannot suppress itself.
52.1037 + * @throws NullPointerException if {@code exception} is {@code null}
52.1038 + * @since 1.7
52.1039 + */
52.1040 + public final synchronized void addSuppressed(Throwable exception) {
52.1041 + if (exception == this)
52.1042 + throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE);
52.1043 +
52.1044 + if (exception == null)
52.1045 + throw new NullPointerException(NULL_CAUSE_MESSAGE);
52.1046 +
52.1047 +// if (suppressedExceptions == null) // Suppressed exceptions not recorded
52.1048 +// return;
52.1049 +//
52.1050 +// if (suppressedExceptions == SUPPRESSED_SENTINEL)
52.1051 +// suppressedExceptions = new ArrayList<Throwable>(1);
52.1052 +//
52.1053 +// suppressedExceptions.add(exception);
52.1054 + }
52.1055 +
52.1056 + private static final Throwable[] EMPTY_THROWABLE_ARRAY = new Throwable[0];
52.1057 +
52.1058 + /**
52.1059 + * Returns an array containing all of the exceptions that were
52.1060 + * suppressed, typically by the {@code try}-with-resources
52.1061 + * statement, in order to deliver this exception.
52.1062 + *
52.1063 + * If no exceptions were suppressed or {@linkplain
52.1064 + * #Throwable(String, Throwable, boolean, boolean) suppression is
52.1065 + * disabled}, an empty array is returned. This method is
52.1066 + * thread-safe. Writes to the returned array do not affect future
52.1067 + * calls to this method.
52.1068 + *
52.1069 + * @return an array containing all of the exceptions that were
52.1070 + * suppressed to deliver this exception.
52.1071 + * @since 1.7
52.1072 + */
52.1073 + public final synchronized Throwable[] getSuppressed() {
52.1074 + return new Throwable[0];
52.1075 +// if (suppressedExceptions == SUPPRESSED_SENTINEL ||
52.1076 +// suppressedExceptions == null)
52.1077 +// return EMPTY_THROWABLE_ARRAY;
52.1078 +// else
52.1079 +// return suppressedExceptions.toArray(EMPTY_THROWABLE_ARRAY);
52.1080 + }
52.1081 +}
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
53.2 +++ b/emul/src/main/java/java/lang/VirtualMachineError.java Thu Oct 11 06:16:00 2012 -0700
53.3 @@ -0,0 +1,54 @@
53.4 +/*
53.5 + * Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved.
53.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
53.7 + *
53.8 + * This code is free software; you can redistribute it and/or modify it
53.9 + * under the terms of the GNU General Public License version 2 only, as
53.10 + * published by the Free Software Foundation. Oracle designates this
53.11 + * particular file as subject to the "Classpath" exception as provided
53.12 + * by Oracle in the LICENSE file that accompanied this code.
53.13 + *
53.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
53.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
53.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
53.17 + * version 2 for more details (a copy is included in the LICENSE file that
53.18 + * accompanied this code).
53.19 + *
53.20 + * You should have received a copy of the GNU General Public License version
53.21 + * 2 along with this work; if not, write to the Free Software Foundation,
53.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
53.23 + *
53.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
53.25 + * or visit www.oracle.com if you need additional information or have any
53.26 + * questions.
53.27 + */
53.28 +
53.29 +package java.lang;
53.30 +
53.31 +/**
53.32 + * Thrown to indicate that the Java Virtual Machine is broken or has
53.33 + * run out of resources necessary for it to continue operating.
53.34 + *
53.35 + *
53.36 + * @author Frank Yellin
53.37 + * @since JDK1.0
53.38 + */
53.39 +abstract public
53.40 +class VirtualMachineError extends Error {
53.41 + /**
53.42 + * Constructs a <code>VirtualMachineError</code> with no detail message.
53.43 + */
53.44 + public VirtualMachineError() {
53.45 + super();
53.46 + }
53.47 +
53.48 + /**
53.49 + * Constructs a <code>VirtualMachineError</code> with the specified
53.50 + * detail message.
53.51 + *
53.52 + * @param s the detail message.
53.53 + */
53.54 + public VirtualMachineError(String s) {
53.55 + super(s);
53.56 + }
53.57 +}
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
54.2 +++ b/emul/src/main/java/java/lang/annotation/Annotation.java Thu Oct 11 06:16:00 2012 -0700
54.3 @@ -0,0 +1,131 @@
54.4 +/*
54.5 + * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
54.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
54.7 + *
54.8 + * This code is free software; you can redistribute it and/or modify it
54.9 + * under the terms of the GNU General Public License version 2 only, as
54.10 + * published by the Free Software Foundation. Oracle designates this
54.11 + * particular file as subject to the "Classpath" exception as provided
54.12 + * by Oracle in the LICENSE file that accompanied this code.
54.13 + *
54.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
54.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
54.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
54.17 + * version 2 for more details (a copy is included in the LICENSE file that
54.18 + * accompanied this code).
54.19 + *
54.20 + * You should have received a copy of the GNU General Public License version
54.21 + * 2 along with this work; if not, write to the Free Software Foundation,
54.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
54.23 + *
54.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
54.25 + * or visit www.oracle.com if you need additional information or have any
54.26 + * questions.
54.27 + */
54.28 +
54.29 +package java.lang.annotation;
54.30 +
54.31 +/**
54.32 + * The common interface extended by all annotation types. Note that an
54.33 + * interface that manually extends this one does <i>not</i> define
54.34 + * an annotation type. Also note that this interface does not itself
54.35 + * define an annotation type.
54.36 + *
54.37 + * More information about annotation types can be found in section 9.6 of
54.38 + * <cite>The Java™ Language Specification</cite>.
54.39 + *
54.40 + * @author Josh Bloch
54.41 + * @since 1.5
54.42 + */
54.43 +public interface Annotation {
54.44 + /**
54.45 + * Returns true if the specified object represents an annotation
54.46 + * that is logically equivalent to this one. In other words,
54.47 + * returns true if the specified object is an instance of the same
54.48 + * annotation type as this instance, all of whose members are equal
54.49 + * to the corresponding member of this annotation, as defined below:
54.50 + * <ul>
54.51 + * <li>Two corresponding primitive typed members whose values are
54.52 + * <tt>x</tt> and <tt>y</tt> are considered equal if <tt>x == y</tt>,
54.53 + * unless their type is <tt>float</tt> or <tt>double</tt>.
54.54 + *
54.55 + * <li>Two corresponding <tt>float</tt> members whose values
54.56 + * are <tt>x</tt> and <tt>y</tt> are considered equal if
54.57 + * <tt>Float.valueOf(x).equals(Float.valueOf(y))</tt>.
54.58 + * (Unlike the <tt>==</tt> operator, NaN is considered equal
54.59 + * to itself, and <tt>0.0f</tt> unequal to <tt>-0.0f</tt>.)
54.60 + *
54.61 + * <li>Two corresponding <tt>double</tt> members whose values
54.62 + * are <tt>x</tt> and <tt>y</tt> are considered equal if
54.63 + * <tt>Double.valueOf(x).equals(Double.valueOf(y))</tt>.
54.64 + * (Unlike the <tt>==</tt> operator, NaN is considered equal
54.65 + * to itself, and <tt>0.0</tt> unequal to <tt>-0.0</tt>.)
54.66 + *
54.67 + * <li>Two corresponding <tt>String</tt>, <tt>Class</tt>, enum, or
54.68 + * annotation typed members whose values are <tt>x</tt> and <tt>y</tt>
54.69 + * are considered equal if <tt>x.equals(y)</tt>. (Note that this
54.70 + * definition is recursive for annotation typed members.)
54.71 + *
54.72 + * <li>Two corresponding array typed members <tt>x</tt> and <tt>y</tt>
54.73 + * are considered equal if <tt>Arrays.equals(x, y)</tt>, for the
54.74 + * appropriate overloading of {@link java.util.Arrays#equals}.
54.75 + * </ul>
54.76 + *
54.77 + * @return true if the specified object represents an annotation
54.78 + * that is logically equivalent to this one, otherwise false
54.79 + */
54.80 + boolean equals(Object obj);
54.81 +
54.82 + /**
54.83 + * Returns the hash code of this annotation, as defined below:
54.84 + *
54.85 + * <p>The hash code of an annotation is the sum of the hash codes
54.86 + * of its members (including those with default values), as defined
54.87 + * below:
54.88 + *
54.89 + * The hash code of an annotation member is (127 times the hash code
54.90 + * of the member-name as computed by {@link String#hashCode()}) XOR
54.91 + * the hash code of the member-value, as defined below:
54.92 + *
54.93 + * <p>The hash code of a member-value depends on its type:
54.94 + * <ul>
54.95 + * <li>The hash code of a primitive value <tt><i>v</i></tt> is equal to
54.96 + * <tt><i>WrapperType</i>.valueOf(<i>v</i>).hashCode()</tt>, where
54.97 + * <tt><i>WrapperType</i></tt> is the wrapper type corresponding
54.98 + * to the primitive type of <tt><i>v</i></tt> ({@link Byte},
54.99 + * {@link Character}, {@link Double}, {@link Float}, {@link Integer},
54.100 + * {@link Long}, {@link Short}, or {@link Boolean}).
54.101 + *
54.102 + * <li>The hash code of a string, enum, class, or annotation member-value
54.103 + I <tt><i>v</i></tt> is computed as by calling
54.104 + * <tt><i>v</i>.hashCode()</tt>. (In the case of annotation
54.105 + * member values, this is a recursive definition.)
54.106 + *
54.107 + * <li>The hash code of an array member-value is computed by calling
54.108 + * the appropriate overloading of
54.109 + * {@link java.util.Arrays#hashCode(long[]) Arrays.hashCode}
54.110 + * on the value. (There is one overloading for each primitive
54.111 + * type, and one for object reference types.)
54.112 + * </ul>
54.113 + *
54.114 + * @return the hash code of this annotation
54.115 + */
54.116 + int hashCode();
54.117 +
54.118 + /**
54.119 + * Returns a string representation of this annotation. The details
54.120 + * of the representation are implementation-dependent, but the following
54.121 + * may be regarded as typical:
54.122 + * <pre>
54.123 + * @com.acme.util.Name(first=Alfred, middle=E., last=Neuman)
54.124 + * </pre>
54.125 + *
54.126 + * @return a string representation of this annotation
54.127 + */
54.128 + String toString();
54.129 +
54.130 + /**
54.131 + * Returns the annotation type of this annotation.
54.132 + */
54.133 + Class<? extends Annotation> annotationType();
54.134 +}
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
55.2 +++ b/emul/src/main/java/java/lang/annotation/Documented.java Thu Oct 11 06:16:00 2012 -0700
55.3 @@ -0,0 +1,43 @@
55.4 +/*
55.5 + * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
55.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55.7 + *
55.8 + * This code is free software; you can redistribute it and/or modify it
55.9 + * under the terms of the GNU General Public License version 2 only, as
55.10 + * published by the Free Software Foundation. Oracle designates this
55.11 + * particular file as subject to the "Classpath" exception as provided
55.12 + * by Oracle in the LICENSE file that accompanied this code.
55.13 + *
55.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
55.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
55.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
55.17 + * version 2 for more details (a copy is included in the LICENSE file that
55.18 + * accompanied this code).
55.19 + *
55.20 + * You should have received a copy of the GNU General Public License version
55.21 + * 2 along with this work; if not, write to the Free Software Foundation,
55.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
55.23 + *
55.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
55.25 + * or visit www.oracle.com if you need additional information or have any
55.26 + * questions.
55.27 + */
55.28 +
55.29 +package java.lang.annotation;
55.30 +
55.31 +/**
55.32 + * Indicates that annotations with a type are to be documented by javadoc
55.33 + * and similar tools by default. This type should be used to annotate the
55.34 + * declarations of types whose annotations affect the use of annotated
55.35 + * elements by their clients. If a type declaration is annotated with
55.36 + * Documented, its annotations become part of the public API
55.37 + * of the annotated elements.
55.38 + *
55.39 + * @author Joshua Bloch
55.40 + * @since 1.5
55.41 + */
55.42 +@Documented
55.43 +@Retention(RetentionPolicy.RUNTIME)
55.44 +@Target(ElementType.ANNOTATION_TYPE)
55.45 +public @interface Documented {
55.46 +}
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
56.2 +++ b/emul/src/main/java/java/lang/annotation/ElementType.java Thu Oct 11 06:16:00 2012 -0700
56.3 @@ -0,0 +1,63 @@
56.4 +/*
56.5 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
56.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
56.7 + *
56.8 + * This code is free software; you can redistribute it and/or modify it
56.9 + * under the terms of the GNU General Public License version 2 only, as
56.10 + * published by the Free Software Foundation. Oracle designates this
56.11 + * particular file as subject to the "Classpath" exception as provided
56.12 + * by Oracle in the LICENSE file that accompanied this code.
56.13 + *
56.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
56.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
56.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
56.17 + * version 2 for more details (a copy is included in the LICENSE file that
56.18 + * accompanied this code).
56.19 + *
56.20 + * You should have received a copy of the GNU General Public License version
56.21 + * 2 along with this work; if not, write to the Free Software Foundation,
56.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
56.23 + *
56.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
56.25 + * or visit www.oracle.com if you need additional information or have any
56.26 + * questions.
56.27 + */
56.28 +
56.29 +package java.lang.annotation;
56.30 +
56.31 +/**
56.32 + * A program element type. The constants of this enumerated type
56.33 + * provide a simple classification of the declared elements in a
56.34 + * Java program.
56.35 + *
56.36 + * <p>These constants are used with the {@link Target} meta-annotation type
56.37 + * to specify where it is legal to use an annotation type.
56.38 + *
56.39 + * @author Joshua Bloch
56.40 + * @since 1.5
56.41 + */
56.42 +public enum ElementType {
56.43 + /** Class, interface (including annotation type), or enum declaration */
56.44 + TYPE,
56.45 +
56.46 + /** Field declaration (includes enum constants) */
56.47 + FIELD,
56.48 +
56.49 + /** Method declaration */
56.50 + METHOD,
56.51 +
56.52 + /** Parameter declaration */
56.53 + PARAMETER,
56.54 +
56.55 + /** Constructor declaration */
56.56 + CONSTRUCTOR,
56.57 +
56.58 + /** Local variable declaration */
56.59 + LOCAL_VARIABLE,
56.60 +
56.61 + /** Annotation type declaration */
56.62 + ANNOTATION_TYPE,
56.63 +
56.64 + /** Package declaration */
56.65 + PACKAGE
56.66 +}
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
57.2 +++ b/emul/src/main/java/java/lang/annotation/Retention.java Thu Oct 11 06:16:00 2012 -0700
57.3 @@ -0,0 +1,47 @@
57.4 +/*
57.5 + * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
57.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
57.7 + *
57.8 + * This code is free software; you can redistribute it and/or modify it
57.9 + * under the terms of the GNU General Public License version 2 only, as
57.10 + * published by the Free Software Foundation. Oracle designates this
57.11 + * particular file as subject to the "Classpath" exception as provided
57.12 + * by Oracle in the LICENSE file that accompanied this code.
57.13 + *
57.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
57.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
57.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
57.17 + * version 2 for more details (a copy is included in the LICENSE file that
57.18 + * accompanied this code).
57.19 + *
57.20 + * You should have received a copy of the GNU General Public License version
57.21 + * 2 along with this work; if not, write to the Free Software Foundation,
57.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
57.23 + *
57.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
57.25 + * or visit www.oracle.com if you need additional information or have any
57.26 + * questions.
57.27 + */
57.28 +
57.29 +package java.lang.annotation;
57.30 +
57.31 +/**
57.32 + * Indicates how long annotations with the annotated type are to
57.33 + * be retained. If no Retention annotation is present on
57.34 + * an annotation type declaration, the retention policy defaults to
57.35 + * {@code RetentionPolicy.CLASS}.
57.36 + *
57.37 + * <p>A Retention meta-annotation has effect only if the
57.38 + * meta-annotated type is used directly for annotation. It has no
57.39 + * effect if the meta-annotated type is used as a member type in
57.40 + * another annotation type.
57.41 + *
57.42 + * @author Joshua Bloch
57.43 + * @since 1.5
57.44 + */
57.45 +@Documented
57.46 +@Retention(RetentionPolicy.RUNTIME)
57.47 +@Target(ElementType.ANNOTATION_TYPE)
57.48 +public @interface Retention {
57.49 + RetentionPolicy value();
57.50 +}
58.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
58.2 +++ b/emul/src/main/java/java/lang/annotation/RetentionPolicy.java Thu Oct 11 06:16:00 2012 -0700
58.3 @@ -0,0 +1,57 @@
58.4 +/*
58.5 + * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
58.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
58.7 + *
58.8 + * This code is free software; you can redistribute it and/or modify it
58.9 + * under the terms of the GNU General Public License version 2 only, as
58.10 + * published by the Free Software Foundation. Oracle designates this
58.11 + * particular file as subject to the "Classpath" exception as provided
58.12 + * by Oracle in the LICENSE file that accompanied this code.
58.13 + *
58.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
58.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
58.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
58.17 + * version 2 for more details (a copy is included in the LICENSE file that
58.18 + * accompanied this code).
58.19 + *
58.20 + * You should have received a copy of the GNU General Public License version
58.21 + * 2 along with this work; if not, write to the Free Software Foundation,
58.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
58.23 + *
58.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
58.25 + * or visit www.oracle.com if you need additional information or have any
58.26 + * questions.
58.27 + */
58.28 +
58.29 +package java.lang.annotation;
58.30 +
58.31 +/**
58.32 + * Annotation retention policy. The constants of this enumerated type
58.33 + * describe the various policies for retaining annotations. They are used
58.34 + * in conjunction with the {@link Retention} meta-annotation type to specify
58.35 + * how long annotations are to be retained.
58.36 + *
58.37 + * @author Joshua Bloch
58.38 + * @since 1.5
58.39 + */
58.40 +public enum RetentionPolicy {
58.41 + /**
58.42 + * Annotations are to be discarded by the compiler.
58.43 + */
58.44 + SOURCE,
58.45 +
58.46 + /**
58.47 + * Annotations are to be recorded in the class file by the compiler
58.48 + * but need not be retained by the VM at run time. This is the default
58.49 + * behavior.
58.50 + */
58.51 + CLASS,
58.52 +
58.53 + /**
58.54 + * Annotations are to be recorded in the class file by the compiler and
58.55 + * retained by the VM at run time, so they may be read reflectively.
58.56 + *
58.57 + * @see java.lang.reflect.AnnotatedElement
58.58 + */
58.59 + RUNTIME
58.60 +}
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
59.2 +++ b/emul/src/main/java/java/lang/annotation/Target.java Thu Oct 11 06:16:00 2012 -0700
59.3 @@ -0,0 +1,68 @@
59.4 +/*
59.5 + * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
59.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
59.7 + *
59.8 + * This code is free software; you can redistribute it and/or modify it
59.9 + * under the terms of the GNU General Public License version 2 only, as
59.10 + * published by the Free Software Foundation. Oracle designates this
59.11 + * particular file as subject to the "Classpath" exception as provided
59.12 + * by Oracle in the LICENSE file that accompanied this code.
59.13 + *
59.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
59.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
59.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
59.17 + * version 2 for more details (a copy is included in the LICENSE file that
59.18 + * accompanied this code).
59.19 + *
59.20 + * You should have received a copy of the GNU General Public License version
59.21 + * 2 along with this work; if not, write to the Free Software Foundation,
59.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
59.23 + *
59.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
59.25 + * or visit www.oracle.com if you need additional information or have any
59.26 + * questions.
59.27 + */
59.28 +
59.29 +package java.lang.annotation;
59.30 +
59.31 +/**
59.32 + * Indicates the kinds of program element to which an annotation type
59.33 + * is applicable. If a Target meta-annotation is not present on an
59.34 + * annotation type declaration, the declared type may be used on any
59.35 + * program element. If such a meta-annotation is present, the compiler
59.36 + * will enforce the specified usage restriction.
59.37 + *
59.38 + * For example, this meta-annotation indicates that the declared type is
59.39 + * itself a meta-annotation type. It can only be used on annotation type
59.40 + * declarations:
59.41 + * <pre>
59.42 + * @Target(ElementType.ANNOTATION_TYPE)
59.43 + * public @interface MetaAnnotationType {
59.44 + * ...
59.45 + * }
59.46 + * </pre>
59.47 + * This meta-annotation indicates that the declared type is intended solely
59.48 + * for use as a member type in complex annotation type declarations. It
59.49 + * cannot be used to annotate anything directly:
59.50 + * <pre>
59.51 + * @Target({})
59.52 + * public @interface MemberType {
59.53 + * ...
59.54 + * }
59.55 + * </pre>
59.56 + * It is a compile-time error for a single ElementType constant to
59.57 + * appear more than once in a Target annotation. For example, the
59.58 + * following meta-annotation is illegal:
59.59 + * <pre>
59.60 + * @Target({ElementType.FIELD, ElementType.METHOD, ElementType.FIELD})
59.61 + * public @interface Bogus {
59.62 + * ...
59.63 + * }
59.64 + * </pre>
59.65 + */
59.66 +@Documented
59.67 +@Retention(RetentionPolicy.RUNTIME)
59.68 +@Target(ElementType.ANNOTATION_TYPE)
59.69 +public @interface Target {
59.70 + ElementType[] value();
59.71 +}
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
60.2 +++ b/emul/src/main/java/java/lang/annotation/UnsupportedOperationException.java Thu Oct 11 06:16:00 2012 -0700
60.3 @@ -0,0 +1,94 @@
60.4 +/*
60.5 + * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
60.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
60.7 + *
60.8 + * This code is free software; you can redistribute it and/or modify it
60.9 + * under the terms of the GNU General Public License version 2 only, as
60.10 + * published by the Free Software Foundation. Oracle designates this
60.11 + * particular file as subject to the "Classpath" exception as provided
60.12 + * by Oracle in the LICENSE file that accompanied this code.
60.13 + *
60.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
60.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
60.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
60.17 + * version 2 for more details (a copy is included in the LICENSE file that
60.18 + * accompanied this code).
60.19 + *
60.20 + * You should have received a copy of the GNU General Public License version
60.21 + * 2 along with this work; if not, write to the Free Software Foundation,
60.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
60.23 + *
60.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
60.25 + * or visit www.oracle.com if you need additional information or have any
60.26 + * questions.
60.27 + */
60.28 +
60.29 +package java.lang;
60.30 +
60.31 +/**
60.32 + * Thrown to indicate that the requested operation is not supported.<p>
60.33 + *
60.34 + * This class is a member of the
60.35 + * <a href="{@docRoot}/../technotes/guides/collections/index.html">
60.36 + * Java Collections Framework</a>.
60.37 + *
60.38 + * @author Josh Bloch
60.39 + * @since 1.2
60.40 + */
60.41 +public class UnsupportedOperationException extends RuntimeException {
60.42 + /**
60.43 + * Constructs an UnsupportedOperationException with no detail message.
60.44 + */
60.45 + public UnsupportedOperationException() {
60.46 + }
60.47 +
60.48 + /**
60.49 + * Constructs an UnsupportedOperationException with the specified
60.50 + * detail message.
60.51 + *
60.52 + * @param message the detail message
60.53 + */
60.54 + public UnsupportedOperationException(String message) {
60.55 + super(message);
60.56 + }
60.57 +
60.58 + /**
60.59 + * Constructs a new exception with the specified detail message and
60.60 + * cause.
60.61 + *
60.62 + * <p>Note that the detail message associated with <code>cause</code> is
60.63 + * <i>not</i> automatically incorporated in this exception's detail
60.64 + * message.
60.65 + *
60.66 + * @param message the detail message (which is saved for later retrieval
60.67 + * by the {@link Throwable#getMessage()} method).
60.68 + * @param cause the cause (which is saved for later retrieval by the
60.69 + * {@link Throwable#getCause()} method). (A <tt>null</tt> value
60.70 + * is permitted, and indicates that the cause is nonexistent or
60.71 + * unknown.)
60.72 + * @since 1.5
60.73 + */
60.74 + public UnsupportedOperationException(String message, Throwable cause) {
60.75 + super(message, cause);
60.76 + }
60.77 +
60.78 + /**
60.79 + * Constructs a new exception with the specified cause and a detail
60.80 + * message of <tt>(cause==null ? null : cause.toString())</tt> (which
60.81 + * typically contains the class and detail message of <tt>cause</tt>).
60.82 + * This constructor is useful for exceptions that are little more than
60.83 + * wrappers for other throwables (for example, {@link
60.84 + * java.security.PrivilegedActionException}).
60.85 + *
60.86 + * @param cause the cause (which is saved for later retrieval by the
60.87 + * {@link Throwable#getCause()} method). (A <tt>null</tt> value is
60.88 + * permitted, and indicates that the cause is nonexistent or
60.89 + * unknown.)
60.90 + * @since 1.5
60.91 + */
60.92 + public UnsupportedOperationException(Throwable cause) {
60.93 + super(cause);
60.94 + }
60.95 +
60.96 + static final long serialVersionUID = -1242599979055084673L;
60.97 +}
61.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
61.2 +++ b/emul/src/main/java/java/util/Comparator.java Thu Oct 11 06:16:00 2012 -0700
61.3 @@ -0,0 +1,168 @@
61.4 +/*
61.5 + * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
61.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
61.7 + *
61.8 + * This code is free software; you can redistribute it and/or modify it
61.9 + * under the terms of the GNU General Public License version 2 only, as
61.10 + * published by the Free Software Foundation. Oracle designates this
61.11 + * particular file as subject to the "Classpath" exception as provided
61.12 + * by Oracle in the LICENSE file that accompanied this code.
61.13 + *
61.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
61.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
61.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
61.17 + * version 2 for more details (a copy is included in the LICENSE file that
61.18 + * accompanied this code).
61.19 + *
61.20 + * You should have received a copy of the GNU General Public License version
61.21 + * 2 along with this work; if not, write to the Free Software Foundation,
61.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
61.23 + *
61.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
61.25 + * or visit www.oracle.com if you need additional information or have any
61.26 + * questions.
61.27 + */
61.28 +
61.29 +package java.util;
61.30 +
61.31 +/**
61.32 + * A comparison function, which imposes a <i>total ordering</i> on some
61.33 + * collection of objects. Comparators can be passed to a sort method (such
61.34 + * as {@link Collections#sort(List,Comparator) Collections.sort} or {@link
61.35 + * Arrays#sort(Object[],Comparator) Arrays.sort}) to allow precise control
61.36 + * over the sort order. Comparators can also be used to control the order of
61.37 + * certain data structures (such as {@link SortedSet sorted sets} or {@link
61.38 + * SortedMap sorted maps}), or to provide an ordering for collections of
61.39 + * objects that don't have a {@link Comparable natural ordering}.<p>
61.40 + *
61.41 + * The ordering imposed by a comparator <tt>c</tt> on a set of elements
61.42 + * <tt>S</tt> is said to be <i>consistent with equals</i> if and only if
61.43 + * <tt>c.compare(e1, e2)==0</tt> has the same boolean value as
61.44 + * <tt>e1.equals(e2)</tt> for every <tt>e1</tt> and <tt>e2</tt> in
61.45 + * <tt>S</tt>.<p>
61.46 + *
61.47 + * Caution should be exercised when using a comparator capable of imposing an
61.48 + * ordering inconsistent with equals to order a sorted set (or sorted map).
61.49 + * Suppose a sorted set (or sorted map) with an explicit comparator <tt>c</tt>
61.50 + * is used with elements (or keys) drawn from a set <tt>S</tt>. If the
61.51 + * ordering imposed by <tt>c</tt> on <tt>S</tt> is inconsistent with equals,
61.52 + * the sorted set (or sorted map) will behave "strangely." In particular the
61.53 + * sorted set (or sorted map) will violate the general contract for set (or
61.54 + * map), which is defined in terms of <tt>equals</tt>.<p>
61.55 + *
61.56 + * For example, suppose one adds two elements {@code a} and {@code b} such that
61.57 + * {@code (a.equals(b) && c.compare(a, b) != 0)}
61.58 + * to an empty {@code TreeSet} with comparator {@code c}.
61.59 + * The second {@code add} operation will return
61.60 + * true (and the size of the tree set will increase) because {@code a} and
61.61 + * {@code b} are not equivalent from the tree set's perspective, even though
61.62 + * this is contrary to the specification of the
61.63 + * {@link Set#add Set.add} method.<p>
61.64 + *
61.65 + * Note: It is generally a good idea for comparators to also implement
61.66 + * <tt>java.io.Serializable</tt>, as they may be used as ordering methods in
61.67 + * serializable data structures (like {@link TreeSet}, {@link TreeMap}). In
61.68 + * order for the data structure to serialize successfully, the comparator (if
61.69 + * provided) must implement <tt>Serializable</tt>.<p>
61.70 + *
61.71 + * For the mathematically inclined, the <i>relation</i> that defines the
61.72 + * <i>imposed ordering</i> that a given comparator <tt>c</tt> imposes on a
61.73 + * given set of objects <tt>S</tt> is:<pre>
61.74 + * {(x, y) such that c.compare(x, y) <= 0}.
61.75 + * </pre> The <i>quotient</i> for this total order is:<pre>
61.76 + * {(x, y) such that c.compare(x, y) == 0}.
61.77 + * </pre>
61.78 + *
61.79 + * It follows immediately from the contract for <tt>compare</tt> that the
61.80 + * quotient is an <i>equivalence relation</i> on <tt>S</tt>, and that the
61.81 + * imposed ordering is a <i>total order</i> on <tt>S</tt>. When we say that
61.82 + * the ordering imposed by <tt>c</tt> on <tt>S</tt> is <i>consistent with
61.83 + * equals</i>, we mean that the quotient for the ordering is the equivalence
61.84 + * relation defined by the objects' {@link Object#equals(Object)
61.85 + * equals(Object)} method(s):<pre>
61.86 + * {(x, y) such that x.equals(y)}. </pre>
61.87 + *
61.88 + * <p>Unlike {@code Comparable}, a comparator may optionally permit
61.89 + * comparison of null arguments, while maintaining the requirements for
61.90 + * an equivalence relation.
61.91 + *
61.92 + * <p>This interface is a member of the
61.93 + * <a href="{@docRoot}/../technotes/guides/collections/index.html">
61.94 + * Java Collections Framework</a>.
61.95 + *
61.96 + * @param <T> the type of objects that may be compared by this comparator
61.97 + *
61.98 + * @author Josh Bloch
61.99 + * @author Neal Gafter
61.100 + * @see Comparable
61.101 + * @see java.io.Serializable
61.102 + * @since 1.2
61.103 + */
61.104 +
61.105 +public interface Comparator<T> {
61.106 + /**
61.107 + * Compares its two arguments for order. Returns a negative integer,
61.108 + * zero, or a positive integer as the first argument is less than, equal
61.109 + * to, or greater than the second.<p>
61.110 + *
61.111 + * In the foregoing description, the notation
61.112 + * <tt>sgn(</tt><i>expression</i><tt>)</tt> designates the mathematical
61.113 + * <i>signum</i> function, which is defined to return one of <tt>-1</tt>,
61.114 + * <tt>0</tt>, or <tt>1</tt> according to whether the value of
61.115 + * <i>expression</i> is negative, zero or positive.<p>
61.116 + *
61.117 + * The implementor must ensure that <tt>sgn(compare(x, y)) ==
61.118 + * -sgn(compare(y, x))</tt> for all <tt>x</tt> and <tt>y</tt>. (This
61.119 + * implies that <tt>compare(x, y)</tt> must throw an exception if and only
61.120 + * if <tt>compare(y, x)</tt> throws an exception.)<p>
61.121 + *
61.122 + * The implementor must also ensure that the relation is transitive:
61.123 + * <tt>((compare(x, y)>0) && (compare(y, z)>0))</tt> implies
61.124 + * <tt>compare(x, z)>0</tt>.<p>
61.125 + *
61.126 + * Finally, the implementor must ensure that <tt>compare(x, y)==0</tt>
61.127 + * implies that <tt>sgn(compare(x, z))==sgn(compare(y, z))</tt> for all
61.128 + * <tt>z</tt>.<p>
61.129 + *
61.130 + * It is generally the case, but <i>not</i> strictly required that
61.131 + * <tt>(compare(x, y)==0) == (x.equals(y))</tt>. Generally speaking,
61.132 + * any comparator that violates this condition should clearly indicate
61.133 + * this fact. The recommended language is "Note: this comparator
61.134 + * imposes orderings that are inconsistent with equals."
61.135 + *
61.136 + * @param o1 the first object to be compared.
61.137 + * @param o2 the second object to be compared.
61.138 + * @return a negative integer, zero, or a positive integer as the
61.139 + * first argument is less than, equal to, or greater than the
61.140 + * second.
61.141 + * @throws NullPointerException if an argument is null and this
61.142 + * comparator does not permit null arguments
61.143 + * @throws ClassCastException if the arguments' types prevent them from
61.144 + * being compared by this comparator.
61.145 + */
61.146 + int compare(T o1, T o2);
61.147 +
61.148 + /**
61.149 + * Indicates whether some other object is "equal to" this
61.150 + * comparator. This method must obey the general contract of
61.151 + * {@link Object#equals(Object)}. Additionally, this method can return
61.152 + * <tt>true</tt> <i>only</i> if the specified object is also a comparator
61.153 + * and it imposes the same ordering as this comparator. Thus,
61.154 + * <code>comp1.equals(comp2)</code> implies that <tt>sgn(comp1.compare(o1,
61.155 + * o2))==sgn(comp2.compare(o1, o2))</tt> for every object reference
61.156 + * <tt>o1</tt> and <tt>o2</tt>.<p>
61.157 + *
61.158 + * Note that it is <i>always</i> safe <i>not</i> to override
61.159 + * <tt>Object.equals(Object)</tt>. However, overriding this method may,
61.160 + * in some cases, improve performance by allowing programs to determine
61.161 + * that two distinct comparators impose the same order.
61.162 + *
61.163 + * @param obj the reference object with which to compare.
61.164 + * @return <code>true</code> only if the specified object is also
61.165 + * a comparator and it imposes the same ordering as this
61.166 + * comparator.
61.167 + * @see Object#equals(Object)
61.168 + * @see Object#hashCode()
61.169 + */
61.170 + boolean equals(Object obj);
61.171 +}
62.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
62.2 +++ b/emul/src/main/resources/org/apidesign/vm4brwsr/emul/java_lang_String.js Thu Oct 11 06:16:00 2012 -0700
62.3 @@ -0,0 +1,2658 @@
62.4 +/* */
62.5 +
62.6 +
62.7 +function java_lang_String_consVAC(arg0,arg1) {
62.8 + arg0.r = arg1.join("");
62.9 +}
62.10 +
62.11 +function java_lang_String_consVACII(self, charArr, off, cnt) {
62.12 + self.r = charArr.slice(off, off + cnt).join("");
62.13 +}
62.14 +
62.15 +function java_lang_String_charAtCI(arg0,arg1) {
62.16 + return arg0.toString().charAt(arg1);
62.17 +}
62.18 +function java_lang_String_lengthI(arg0) {
62.19 + return arg0.toString().length;
62.20 +}
62.21 +function java_lang_String_isEmptyZ(arg0) {
62.22 + return arg0.toString().length === 0;
62.23 +}
62.24 +
62.25 +/*
62.26 +function java_lang_String_codePointAtII(arg0,arg1) {
62.27 + var arg2;
62.28 +;
62.29 + var stack = new Array(4);
62.30 + var gt = 0;
62.31 + for(;;) switch(gt) {
62.32 + case 0: stack.push(arg1); // 27
62.33 + case 1: if (stack.pop() < 0) { gt = 12; continue; } // 155 0 11
62.34 + case 4: stack.push(arg1); // 27
62.35 + case 5: stack.push(arg0); // 42
62.36 + case 6: stack.push(stack.pop().count); // 180 1 97
62.37 + case 9: if (stack.pop() > stack.pop()) { gt = 21; continue; } // 161 0 12
62.38 + case 12: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
62.39 + case 15: stack.push(stack[stack.length - 1]); // 89
62.40 + case 16: stack.push(arg1); // 27
62.41 + case 17: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
62.42 + case 20: // 191
62.43 + case 21: stack.push(arg0); // 42
62.44 + case 22: stack.push(stack.pop().value); // 180 1 100
62.45 + case 25: stack.push(arg0); // 42
62.46 + case 26: stack.push(stack.pop().offset); // 180 1 99
62.47 + case 29: stack.push(arg1); // 27
62.48 + case 30: stack.push(stack.pop() + stack.pop()); // 96
62.49 + case 31: stack.push(arg0); // 42
62.50 + case 32: stack.push(stack.pop().offset); // 180 1 99
62.51 + case 35: stack.push(arg0); // 42
62.52 + case 36: stack.push(stack.pop().count); // 180 1 97
62.53 + case 39: stack.push(stack.pop() + stack.pop()); // 96
62.54 + 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
62.55 + case 43: return stack.pop(); // 172
62.56 + }
62.57 +}
62.58 +function java_lang_String_codePointBeforeII(arg0,arg1) {
62.59 + var arg2;
62.60 + var arg3;
62.61 +;
62.62 + var stack = new Array(3);
62.63 + var gt = 0;
62.64 + for(;;) switch(gt) {
62.65 + case 0: stack.push(arg1); // 27
62.66 + case 1: stack.push(1); // 4
62.67 + case 2: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.68 + case 3: arg2 = stack.pop(); // 61
62.69 + case 4: stack.push(arg2); // 28
62.70 + case 5: if (stack.pop() < 0) { gt = 16; continue; } // 155 0 11
62.71 + case 8: stack.push(arg2); // 28
62.72 + case 9: stack.push(arg0); // 42
62.73 + case 10: stack.push(stack.pop().count); // 180 1 97
62.74 + case 13: if (stack.pop() > stack.pop()) { gt = 25; continue; } // 161 0 12
62.75 + case 16: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
62.76 + case 19: stack.push(stack[stack.length - 1]); // 89
62.77 + case 20: stack.push(arg1); // 27
62.78 + case 21: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
62.79 + case 24: // 191
62.80 + case 25: stack.push(arg0); // 42
62.81 + case 26: stack.push(stack.pop().value); // 180 1 100
62.82 + case 29: stack.push(arg0); // 42
62.83 + case 30: stack.push(stack.pop().offset); // 180 1 99
62.84 + case 33: stack.push(arg1); // 27
62.85 + case 34: stack.push(stack.pop() + stack.pop()); // 96
62.86 + case 35: stack.push(arg0); // 42
62.87 + case 36: stack.push(stack.pop().offset); // 180 1 99
62.88 + 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
62.89 + case 42: return stack.pop(); // 172
62.90 + }
62.91 +}
62.92 +function java_lang_String_codePointCountIII(arg0,arg1,arg2) {
62.93 + var arg3;
62.94 +;
62.95 + var stack = new Array(4);
62.96 + var gt = 0;
62.97 + for(;;) switch(gt) {
62.98 + case 0: stack.push(arg1); // 27
62.99 + case 1: if (stack.pop() < 0) { gt = 17; continue; } // 155 0 16
62.100 + case 4: stack.push(arg2); // 28
62.101 + case 5: stack.push(arg0); // 42
62.102 + case 6: stack.push(stack.pop().count); // 180 1 97
62.103 + case 9: if (stack.pop() < stack.pop()) { gt = 17; continue; } // 163 0 8
62.104 + case 12: stack.push(arg1); // 27
62.105 + case 13: stack.push(arg2); // 28
62.106 + case 14: if (stack.pop() >= stack.pop()) { gt = 25; continue; } // 164 0 11
62.107 + case 17: stack.push(new java_lang_IndexOutOfBoundsException); // 187 0 194
62.108 + case 20: stack.push(stack[stack.length - 1]); // 89
62.109 + case 21: { java_lang_IndexOutOfBoundsException_consV(stack.pop()); } // 183 1 124
62.110 + case 24: // 191
62.111 + case 25: stack.push(arg0); // 42
62.112 + case 26: stack.push(stack.pop().value); // 180 1 100
62.113 + case 29: stack.push(arg0); // 42
62.114 + case 30: stack.push(stack.pop().offset); // 180 1 99
62.115 + case 33: stack.push(arg1); // 27
62.116 + case 34: stack.push(stack.pop() + stack.pop()); // 96
62.117 + case 35: stack.push(arg2); // 28
62.118 + case 36: stack.push(arg1); // 27
62.119 + case 37: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.120 + 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
62.121 + case 41: return stack.pop(); // 172
62.122 + }
62.123 +}
62.124 +function java_lang_String_offsetByCodePointsIII(arg0,arg1,arg2) {
62.125 + var arg3;
62.126 +;
62.127 + var stack = new Array(5);
62.128 + var gt = 0;
62.129 + for(;;) switch(gt) {
62.130 + case 0: stack.push(arg1); // 27
62.131 + case 1: if (stack.pop() < 0) { gt = 12; continue; } // 155 0 11
62.132 + case 4: stack.push(arg1); // 27
62.133 + case 5: stack.push(arg0); // 42
62.134 + case 6: stack.push(stack.pop().count); // 180 1 97
62.135 + case 9: if (stack.pop() >= stack.pop()) { gt = 20; continue; } // 164 0 11
62.136 + case 12: stack.push(new java_lang_IndexOutOfBoundsException); // 187 0 194
62.137 + case 15: stack.push(stack[stack.length - 1]); // 89
62.138 + case 16: { java_lang_IndexOutOfBoundsException_consV(stack.pop()); } // 183 1 124
62.139 + case 19: // 191
62.140 + case 20: stack.push(arg0); // 42
62.141 + case 21: stack.push(stack.pop().value); // 180 1 100
62.142 + case 24: stack.push(arg0); // 42
62.143 + case 25: stack.push(stack.pop().offset); // 180 1 99
62.144 + case 28: stack.push(arg0); // 42
62.145 + case 29: stack.push(stack.pop().count); // 180 1 97
62.146 + case 32: stack.push(arg0); // 42
62.147 + case 33: stack.push(stack.pop().offset); // 180 1 99
62.148 + case 36: stack.push(arg1); // 27
62.149 + case 37: stack.push(stack.pop() + stack.pop()); // 96
62.150 + case 38: stack.push(arg2); // 28
62.151 + 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
62.152 + case 42: stack.push(arg0); // 42
62.153 + case 43: stack.push(stack.pop().offset); // 180 1 99
62.154 + case 46: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.155 + case 47: return stack.pop(); // 172
62.156 + }
62.157 +}
62.158 +*/
62.159 +
62.160 +// public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
62.161 +function java_lang_String_getCharsVIIACAI(arg0,arg1,arg2,arg3,arg4) {
62.162 + var s = arg0.toString();
62.163 + while (arg1 < arg2) {
62.164 + arg3[arg4++] = s[arg1++];
62.165 + }
62.166 +}
62.167 +
62.168 +/*
62.169 +function java_lang_String_getBytesVIIABI(arg0,arg1,arg2,arg3,arg4) {
62.170 + var arg5;
62.171 + var arg6;
62.172 + var arg7;
62.173 + var arg8;
62.174 + var arg9;
62.175 +;
62.176 + var stack = new Array(4);
62.177 + var gt = 0;
62.178 + for(;;) switch(gt) {
62.179 + case 0: stack.push(arg1); // 27
62.180 + case 1: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 12
62.181 + case 4: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
62.182 + case 7: stack.push(stack[stack.length - 1]); // 89
62.183 + case 8: stack.push(arg1); // 27
62.184 + case 9: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
62.185 + case 12: // 191
62.186 + case 13: stack.push(arg2); // 28
62.187 + case 14: stack.push(arg0); // 42
62.188 + case 15: stack.push(stack.pop().count); // 180 1 97
62.189 + case 18: if (stack.pop() >= stack.pop()) { gt = 30; continue; } // 164 0 12
62.190 + case 21: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
62.191 + case 24: stack.push(stack[stack.length - 1]); // 89
62.192 + case 25: stack.push(arg2); // 28
62.193 + case 26: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
62.194 + case 29: // 191
62.195 + case 30: stack.push(arg1); // 27
62.196 + case 31: stack.push(arg2); // 28
62.197 + case 32: if (stack.pop() >= stack.pop()) { gt = 46; continue; } // 164 0 14
62.198 + case 35: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
62.199 + case 38: stack.push(stack[stack.length - 1]); // 89
62.200 + case 39: stack.push(arg2); // 28
62.201 + case 40: stack.push(arg1); // 27
62.202 + case 41: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.203 + case 42: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
62.204 + case 45: // 191
62.205 + case 46: stack.push(arg4); // 21 4
62.206 + case 48: arg5 = stack.pop() // 54 5
62.207 + case 50: stack.push(arg0); // 42
62.208 + case 51: stack.push(stack.pop().offset); // 180 1 99
62.209 + case 54: stack.push(arg2); // 28
62.210 + case 55: stack.push(stack.pop() + stack.pop()); // 96
62.211 + case 56: arg6 = stack.pop() // 54 6
62.212 + case 58: stack.push(arg0); // 42
62.213 + case 59: stack.push(stack.pop().offset); // 180 1 99
62.214 + case 62: stack.push(arg1); // 27
62.215 + case 63: stack.push(stack.pop() + stack.pop()); // 96
62.216 + case 64: arg7 = stack.pop() // 54 7
62.217 + case 66: stack.push(arg0); // 42
62.218 + case 67: stack.push(stack.pop().value); // 180 1 100
62.219 + case 70: arg8 = stack.pop() // 58 8
62.220 + case 72: stack.push(arg7); // 21 7
62.221 + case 74: stack.push(arg6); // 21 6
62.222 + case 76: if (stack.pop() <= stack.pop()) { gt = 98; continue; } // 162 0 22
62.223 + case 79: stack.push(arg3); // 45
62.224 + case 80: stack.push(arg5); // 21 5
62.225 + case 82: arg5++; // 132 5 1
62.226 + case 85: stack.push(arg8); // 25 8
62.227 + case 87: stack.push(arg7); // 21 7
62.228 + case 89: arg7++; // 132 7 1
62.229 + case 92: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.230 + case 93: // number conversion // 145
62.231 + case 94: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 84
62.232 + case 95: gt = 72; continue; // 167 255 233
62.233 + case 98: return; // 177
62.234 + }
62.235 +}
62.236 +function java_lang_String_getBytesABLjava_lang_String(arg0,arg1) {
62.237 + var arg2;
62.238 +;
62.239 + var stack = new Array(4);
62.240 + var gt = 0;
62.241 + for(;;) switch(gt) {
62.242 + case 0: stack.push(arg1); // 43
62.243 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11
62.244 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198
62.245 + case 7: stack.push(stack[stack.length - 1]); // 89
62.246 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128
62.247 + case 11: // 191
62.248 + case 12: stack.push(arg1); // 43
62.249 + case 13: stack.push(arg0); // 42
62.250 + case 14: stack.push(stack.pop().value); // 180 1 100
62.251 + case 17: stack.push(arg0); // 42
62.252 + case 18: stack.push(stack.pop().offset); // 180 1 99
62.253 + case 21: stack.push(arg0); // 42
62.254 + case 22: stack.push(stack.pop().count); // 180 1 97
62.255 + 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
62.256 + case 28: return stack.pop(); // 176
62.257 + }
62.258 +}
62.259 +function java_lang_String_getBytesABLjava_nio_charset_Charset(arg0,arg1) {
62.260 + var arg2;
62.261 +;
62.262 + var stack = new Array(4);
62.263 + var gt = 0;
62.264 + for(;;) switch(gt) {
62.265 + case 0: stack.push(arg1); // 43
62.266 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11
62.267 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198
62.268 + case 7: stack.push(stack[stack.length - 1]); // 89
62.269 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128
62.270 + case 11: // 191
62.271 + case 12: stack.push(arg1); // 43
62.272 + case 13: stack.push(arg0); // 42
62.273 + case 14: stack.push(stack.pop().value); // 180 1 100
62.274 + case 17: stack.push(arg0); // 42
62.275 + case 18: stack.push(stack.pop().offset); // 180 1 99
62.276 + case 21: stack.push(arg0); // 42
62.277 + case 22: stack.push(stack.pop().count); // 180 1 97
62.278 + 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
62.279 + case 28: return stack.pop(); // 176
62.280 + }
62.281 +}
62.282 +function java_lang_String_getBytesAB(arg0) {
62.283 + var arg1;
62.284 +;
62.285 + var stack = new Array(3);
62.286 + var gt = 0;
62.287 + for(;;) switch(gt) {
62.288 + case 0: stack.push(arg0); // 42
62.289 + case 1: stack.push(stack.pop().value); // 180 1 100
62.290 + case 4: stack.push(arg0); // 42
62.291 + case 5: stack.push(stack.pop().offset); // 180 1 99
62.292 + case 8: stack.push(arg0); // 42
62.293 + case 9: stack.push(stack.pop().count); // 180 1 97
62.294 + 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
62.295 + case 15: return stack.pop(); // 176
62.296 + }
62.297 +}
62.298 +function java_lang_String_equalsZLjava_lang_Object(arg0,arg1) {
62.299 + var arg2;
62.300 + var arg3;
62.301 + var arg4;
62.302 + var arg5;
62.303 + var arg6;
62.304 + var arg7;
62.305 + var arg8;
62.306 +;
62.307 + var stack = new Array(3);
62.308 + var gt = 0;
62.309 + for(;;) switch(gt) {
62.310 + case 0: stack.push(arg0); // 42
62.311 + case 1: stack.push(arg1); // 43
62.312 + case 2: // 166
62.313 + case 3: // 0
62.314 + case 4: stack.push(2); // 5
62.315 + case 5: stack.push(1); // 4
62.316 + case 6: return stack.pop(); // 172
62.317 + case 7: stack.push(arg1); // 43
62.318 + case 8: stack.push(stack.pop().$instOf_java_lang_String ? 1 : 0); // 193 0 200
62.319 + case 11: if (stack.pop() == 0) { gt = 86; continue; } // 153 0 75
62.320 + case 14: stack.push(arg1); // 43
62.321 + case 15: if(stack[stack.length - 1].$instOf_java_lang_String != 1) throw {}; // 192 0 200
62.322 + case 18: arg2 = stack.pop(); // 77
62.323 + case 19: stack.push(arg0); // 42
62.324 + case 20: stack.push(stack.pop().count); // 180 1 97
62.325 + case 23: arg3 = stack.pop(); // 62
62.326 + case 24: stack.push(arg3); // 29
62.327 + case 25: stack.push(arg2); // 44
62.328 + case 26: stack.push(stack.pop().count); // 180 1 97
62.329 + case 29: if (stack.pop() != stack.pop()) { gt = 86; continue; } // 160 0 57
62.330 + case 32: stack.push(arg0); // 42
62.331 + case 33: stack.push(stack.pop().value); // 180 1 100
62.332 + case 36: arg4 = stack.pop() // 58 4
62.333 + case 38: stack.push(arg2); // 44
62.334 + case 39: stack.push(stack.pop().value); // 180 1 100
62.335 + case 42: arg5 = stack.pop() // 58 5
62.336 + case 44: stack.push(arg0); // 42
62.337 + case 45: stack.push(stack.pop().offset); // 180 1 99
62.338 + case 48: arg6 = stack.pop() // 54 6
62.339 + case 50: stack.push(arg2); // 44
62.340 + case 51: stack.push(stack.pop().offset); // 180 1 99
62.341 + case 54: arg7 = stack.pop() // 54 7
62.342 + case 56: stack.push(arg3); // 29
62.343 + case 57: arg3 += 255; // 132 3 255
62.344 + case 60: if (stack.pop() == 0) { gt = 84; continue; } // 153 0 24
62.345 + case 63: stack.push(arg4); // 25 4
62.346 + case 65: stack.push(arg6); // 21 6
62.347 + case 67: arg6++; // 132 6 1
62.348 + case 70: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.349 + case 71: stack.push(arg5); // 25 5
62.350 + case 73: stack.push(arg7); // 21 7
62.351 + case 75: arg7++; // 132 7 1
62.352 + case 78: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.353 + case 79: if (stack.pop() == stack.pop()) { gt = 56; continue; } // 159 255 233
62.354 + case 82: stack.push(0); // 3
62.355 + case 83: return stack.pop(); // 172
62.356 + case 84: stack.push(1); // 4
62.357 + case 85: return stack.pop(); // 172
62.358 + case 86: stack.push(0); // 3
62.359 + case 87: return stack.pop(); // 172
62.360 + }
62.361 +}
62.362 +function java_lang_String_contentEqualsZLjava_lang_StringBuffer(arg0,arg1) {
62.363 + var arg2;
62.364 + var arg3;
62.365 + var arg4;
62.366 +;
62.367 + var stack = new Array(2);
62.368 + var gt = 0;
62.369 + for(;;) switch(gt) {
62.370 + case 0: stack.push(arg1); // 43
62.371 + case 1: stack.push(stack[stack.length - 1]); // 89
62.372 + case 2: arg2 = stack.pop(); // 77
62.373 + case 3: // 194
62.374 + case 4: stack.push(arg0); // 42
62.375 + case 5: stack.push(arg1); // 43
62.376 + case 6: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.contentEqualsZLjava_lang_CharSequence(self, v0)); } // 182 1 146
62.377 + case 9: stack.push(arg2); // 44
62.378 + case 10: // 195
62.379 + case 11: return stack.pop(); // 172
62.380 + case 12: arg3 = stack.pop(); // 78
62.381 + case 13: stack.push(arg2); // 44
62.382 + case 14: // 195
62.383 + case 15: stack.push(arg3); // 45
62.384 + case 16: // 191
62.385 + }
62.386 +}
62.387 +function java_lang_String_contentEqualsZLjava_lang_CharSequence(arg0,arg1) {
62.388 + var arg2;
62.389 + var arg3;
62.390 + var arg4;
62.391 + var arg5;
62.392 + var arg6;
62.393 + var arg7;
62.394 +;
62.395 + var stack = new Array(3);
62.396 + var gt = 0;
62.397 + for(;;) switch(gt) {
62.398 + case 0: stack.push(arg0); // 42
62.399 + case 1: stack.push(stack.pop().count); // 180 1 97
62.400 + case 4: stack.push(arg1); // 43
62.401 + case 5: { var self = stack.pop(); stack.push(self.lengthI(self)); } // 185 1 188
62.402 + case 8: // 1
62.403 + case 9: // 0
62.404 + case 10: if (stack.pop() == stack.pop()) { gt = 15; continue; } // 159 0 5
62.405 + case 13: stack.push(0); // 3
62.406 + case 14: return stack.pop(); // 172
62.407 + case 15: stack.push(arg1); // 43
62.408 + case 16: stack.push(stack.pop().$instOf_java_lang_AbstractStringBuilder ? 1 : 0); // 193 0 186
62.409 + case 19: if (stack.pop() == 0) { gt = 77; continue; } // 153 0 58
62.410 + case 22: stack.push(arg0); // 42
62.411 + case 23: stack.push(stack.pop().value); // 180 1 100
62.412 + case 26: arg2 = stack.pop(); // 77
62.413 + case 27: stack.push(arg1); // 43
62.414 + case 28: if(stack[stack.length - 1].$instOf_java_lang_AbstractStringBuilder != 1) throw {}; // 192 0 186
62.415 + case 31: { var self = stack.pop(); stack.push(self.getValueAC(self)); } // 182 1 103
62.416 + case 34: arg3 = stack.pop(); // 78
62.417 + case 35: stack.push(arg0); // 42
62.418 + case 36: stack.push(stack.pop().offset); // 180 1 99
62.419 + case 39: arg4 = stack.pop() // 54 4
62.420 + case 41: stack.push(0); // 3
62.421 + case 42: arg5 = stack.pop() // 54 5
62.422 + case 44: stack.push(arg0); // 42
62.423 + case 45: stack.push(stack.pop().count); // 180 1 97
62.424 + case 48: arg6 = stack.pop() // 54 6
62.425 + case 50: stack.push(arg6); // 21 6
62.426 + case 52: arg6 += 255; // 132 6 255
62.427 + case 55: if (stack.pop() == 0) { gt = 77; continue; } // 153 0 22
62.428 + case 58: stack.push(arg2); // 44
62.429 + case 59: stack.push(arg4); // 21 4
62.430 + case 61: arg4++; // 132 4 1
62.431 + case 64: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.432 + case 65: stack.push(arg3); // 45
62.433 + case 66: stack.push(arg5); // 21 5
62.434 + case 68: arg5++; // 132 5 1
62.435 + case 71: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.436 + case 72: if (stack.pop() == stack.pop()) { gt = 50; continue; } // 159 255 234
62.437 + case 75: stack.push(0); // 3
62.438 + case 76: return stack.pop(); // 172
62.439 + case 77: stack.push(arg1); // 43
62.440 + case 78: stack.push(arg0); // 42
62.441 + case 79: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.equalsZLjava_lang_Object(self, v0)); } // 182 1 131
62.442 + case 82: if (stack.pop() == 0) { gt = 87; continue; } // 153 0 5
62.443 + case 85: stack.push(1); // 4
62.444 + case 86: return stack.pop(); // 172
62.445 + case 87: stack.push(arg0); // 42
62.446 + case 88: stack.push(stack.pop().value); // 180 1 100
62.447 + case 91: arg2 = stack.pop(); // 77
62.448 + case 92: stack.push(arg0); // 42
62.449 + case 93: stack.push(stack.pop().offset); // 180 1 99
62.450 + case 96: arg3 = stack.pop(); // 62
62.451 + case 97: stack.push(0); // 3
62.452 + case 98: arg4 = stack.pop() // 54 4
62.453 + case 100: stack.push(arg0); // 42
62.454 + case 101: stack.push(stack.pop().count); // 180 1 97
62.455 + case 104: arg5 = stack.pop() // 54 5
62.456 + case 106: stack.push(arg5); // 21 5
62.457 + case 108: arg5 += 255; // 132 5 255
62.458 + case 111: if (stack.pop() == 0) { gt = 136; continue; } // 153 0 25
62.459 + case 114: stack.push(arg2); // 44
62.460 + case 115: stack.push(arg3); // 29
62.461 + case 116: arg3++; // 132 3 1
62.462 + case 119: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.463 + case 120: stack.push(arg1); // 43
62.464 + case 121: stack.push(arg4); // 21 4
62.465 + case 123: arg4++; // 132 4 1
62.466 + case 126: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.charAtCI(self, v0)); } // 185 1 189
62.467 + case 129: // 2
62.468 + case 130: // 0
62.469 + case 131: if (stack.pop() == stack.pop()) { gt = 106; continue; } // 159 255 231
62.470 + case 134: stack.push(0); // 3
62.471 + case 135: return stack.pop(); // 172
62.472 + case 136: stack.push(1); // 4
62.473 + case 137: return stack.pop(); // 172
62.474 + }
62.475 +}
62.476 +function java_lang_String_equalsIgnoreCaseZLjava_lang_String(arg0,arg1) {
62.477 + var arg2;
62.478 +;
62.479 + var stack = new Array(6);
62.480 + var gt = 0;
62.481 + for(;;) switch(gt) {
62.482 + case 0: stack.push(arg0); // 42
62.483 + case 1: stack.push(arg1); // 43
62.484 + case 2: // 166
62.485 + case 3: // 0
62.486 + case 4: stack.push(4); // 7
62.487 + case 5: stack.push(1); // 4
62.488 + case 6: gt = 44; continue; // 167 0 38
62.489 + case 9: stack.push(arg1); // 43
62.490 + case 10: if (!stack.pop()) { gt = 43; continue; } // 198 0 33
62.491 + case 13: stack.push(arg1); // 43
62.492 + case 14: stack.push(stack.pop().count); // 180 1 97
62.493 + case 17: stack.push(arg0); // 42
62.494 + case 18: stack.push(stack.pop().count); // 180 1 97
62.495 + case 21: if (stack.pop() != stack.pop()) { gt = 43; continue; } // 160 0 22
62.496 + case 24: stack.push(arg0); // 42
62.497 + case 25: stack.push(1); // 4
62.498 + case 26: stack.push(0); // 3
62.499 + case 27: stack.push(arg1); // 43
62.500 + case 28: stack.push(0); // 3
62.501 + case 29: stack.push(arg0); // 42
62.502 + case 30: stack.push(stack.pop().count); // 180 1 97
62.503 + 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
62.504 + case 36: if (stack.pop() == 0) { gt = 43; continue; } // 153 0 7
62.505 + case 39: stack.push(1); // 4
62.506 + case 40: gt = 44; continue; // 167 0 4
62.507 + case 43: stack.push(0); // 3
62.508 + case 44: return stack.pop(); // 172
62.509 + }
62.510 +}
62.511 +function java_lang_String_compareToILjava_lang_String(arg0,arg1) {
62.512 + var arg2;
62.513 + var arg3;
62.514 + var arg4;
62.515 + var arg5;
62.516 + var arg6;
62.517 + var arg7;
62.518 + var arg8;
62.519 + var arg9;
62.520 + var arg10;
62.521 + var arg11;
62.522 + var arg12;
62.523 + var arg13;
62.524 +;
62.525 + var stack = new Array(2);
62.526 + var gt = 0;
62.527 + for(;;) switch(gt) {
62.528 + case 0: stack.push(arg0); // 42
62.529 + case 1: stack.push(stack.pop().count); // 180 1 97
62.530 + case 4: arg2 = stack.pop(); // 61
62.531 + case 5: stack.push(arg1); // 43
62.532 + case 6: stack.push(stack.pop().count); // 180 1 97
62.533 + case 9: arg3 = stack.pop(); // 62
62.534 + case 10: stack.push(arg2); // 28
62.535 + case 11: stack.push(arg3); // 29
62.536 + case 12: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Math_minIII(v0, v1)); } // 184 1 127
62.537 + case 15: arg4 = stack.pop() // 54 4
62.538 + case 17: stack.push(arg0); // 42
62.539 + case 18: stack.push(stack.pop().value); // 180 1 100
62.540 + case 21: arg5 = stack.pop() // 58 5
62.541 + case 23: stack.push(arg1); // 43
62.542 + case 24: stack.push(stack.pop().value); // 180 1 100
62.543 + case 27: arg6 = stack.pop() // 58 6
62.544 + case 29: stack.push(arg0); // 42
62.545 + case 30: stack.push(stack.pop().offset); // 180 1 99
62.546 + case 33: arg7 = stack.pop() // 54 7
62.547 + case 35: stack.push(arg1); // 43
62.548 + case 36: stack.push(stack.pop().offset); // 180 1 99
62.549 + case 39: arg8 = stack.pop() // 54 8
62.550 + case 41: stack.push(arg7); // 21 7
62.551 + case 43: stack.push(arg8); // 21 8
62.552 + case 45: if (stack.pop() != stack.pop()) { gt = 102; continue; } // 160 0 57
62.553 + case 48: stack.push(arg7); // 21 7
62.554 + case 50: arg9 = stack.pop() // 54 9
62.555 + case 52: stack.push(arg4); // 21 4
62.556 + case 54: stack.push(arg7); // 21 7
62.557 + case 56: stack.push(stack.pop() + stack.pop()); // 96
62.558 + case 57: arg10 = stack.pop() // 54 10
62.559 + case 59: stack.push(arg9); // 21 9
62.560 + case 61: stack.push(arg10); // 21 10
62.561 + case 63: if (stack.pop() <= stack.pop()) { gt = 99; continue; } // 162 0 36
62.562 + case 66: stack.push(arg5); // 25 5
62.563 + case 68: stack.push(arg9); // 21 9
62.564 + case 70: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.565 + case 71: arg11 = stack.pop() // 54 11
62.566 + case 73: stack.push(arg6); // 25 6
62.567 + case 75: stack.push(arg9); // 21 9
62.568 + case 77: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.569 + case 78: arg12 = stack.pop() // 54 12
62.570 + case 80: stack.push(arg11); // 21 11
62.571 + case 82: stack.push(arg12); // 21 12
62.572 + case 84: if (stack.pop() == stack.pop()) { gt = 93; continue; } // 159 0 9
62.573 + case 87: stack.push(arg11); // 21 11
62.574 + case 89: stack.push(arg12); // 21 12
62.575 + case 91: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.576 + case 92: return stack.pop(); // 172
62.577 + case 93: arg9++; // 132 9 1
62.578 + case 96: gt = 59; continue; // 167 255 219
62.579 + case 99: gt = 146; continue; // 167 0 47
62.580 + case 102: stack.push(arg4); // 21 4
62.581 + case 104: arg4 += 255; // 132 4 255
62.582 + case 107: if (stack.pop() == 0) { gt = 146; continue; } // 153 0 39
62.583 + case 110: stack.push(arg5); // 25 5
62.584 + case 112: stack.push(arg7); // 21 7
62.585 + case 114: arg7++; // 132 7 1
62.586 + case 117: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.587 + case 118: arg9 = stack.pop() // 54 9
62.588 + case 120: stack.push(arg6); // 25 6
62.589 + case 122: stack.push(arg8); // 21 8
62.590 + case 124: arg8++; // 132 8 1
62.591 + case 127: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.592 + case 128: arg10 = stack.pop() // 54 10
62.593 + case 130: stack.push(arg9); // 21 9
62.594 + case 132: stack.push(arg10); // 21 10
62.595 + case 134: if (stack.pop() == stack.pop()) { gt = 143; continue; } // 159 0 9
62.596 + case 137: stack.push(arg9); // 21 9
62.597 + case 139: stack.push(arg10); // 21 10
62.598 + case 141: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.599 + case 142: return stack.pop(); // 172
62.600 + case 143: gt = 102; continue; // 167 255 215
62.601 + case 146: stack.push(arg2); // 28
62.602 + case 147: stack.push(arg3); // 29
62.603 + case 148: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.604 + case 149: return stack.pop(); // 172
62.605 + }
62.606 +}
62.607 +function java_lang_String_compareToIgnoreCaseILjava_lang_String(arg0,arg1) {
62.608 + var arg2;
62.609 +;
62.610 + var stack = new Array(3);
62.611 + var gt = 0;
62.612 + for(;;) switch(gt) {
62.613 + case 0: stack.push(java_lang_String_CASE_INSENSITIVE_ORDER); // 178 1 102
62.614 + case 3: stack.push(arg0); // 42
62.615 + case 4: stack.push(arg1); // 43
62.616 + 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
62.617 + case 8: stack.push(0); // 3
62.618 + case 9: // 0
62.619 + case 10: return stack.pop(); // 172
62.620 + }
62.621 +}
62.622 +function java_lang_String_regionMatchesZILjava_lang_StringII(arg0,arg1,arg2,arg3,arg4) {
62.623 + var arg5;
62.624 + var arg6;
62.625 + var arg7;
62.626 + var arg8;
62.627 + var arg9;
62.628 +;
62.629 + var stack = new Array(6);
62.630 + var gt = 0;
62.631 + for(;;) switch(gt) {
62.632 + case 0: stack.push(arg0); // 42
62.633 + case 1: stack.push(stack.pop().value); // 180 1 100
62.634 + case 4: arg5 = stack.pop() // 58 5
62.635 + case 6: stack.push(arg0); // 42
62.636 + case 7: stack.push(stack.pop().offset); // 180 1 99
62.637 + case 10: stack.push(arg1); // 27
62.638 + case 11: stack.push(stack.pop() + stack.pop()); // 96
62.639 + case 12: arg6 = stack.pop() // 54 6
62.640 + case 14: stack.push(arg2); // 44
62.641 + case 15: stack.push(stack.pop().value); // 180 1 100
62.642 + case 18: arg7 = stack.pop() // 58 7
62.643 + case 20: stack.push(arg2); // 44
62.644 + case 21: stack.push(stack.pop().offset); // 180 1 99
62.645 + case 24: stack.push(arg3); // 29
62.646 + case 25: stack.push(stack.pop() + stack.pop()); // 96
62.647 + case 26: arg8 = stack.pop() // 54 8
62.648 + case 28: stack.push(arg3); // 29
62.649 + case 29: if (stack.pop() < 0) { gt = 66; continue; } // 155 0 37
62.650 + case 32: stack.push(arg1); // 27
62.651 + case 33: if (stack.pop() < 0) { gt = 66; continue; } // 155 0 33
62.652 + case 36: stack.push(arg1); // 27
62.653 + case 37: // number conversion // 133
62.654 + case 38: stack.push(arg0); // 42
62.655 + case 39: stack.push(stack.pop().count); // 180 1 97
62.656 + case 42: // number conversion // 133
62.657 + case 43: stack.push(arg4); // 21 4
62.658 + case 45: // number conversion // 133
62.659 + case 46: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101
62.660 + case 47: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148
62.661 + case 48: if (stack.pop() > 0) { gt = 66; continue; } // 157 0 18
62.662 + case 51: stack.push(arg3); // 29
62.663 + case 52: // number conversion // 133
62.664 + case 53: stack.push(arg2); // 44
62.665 + case 54: stack.push(stack.pop().count); // 180 1 97
62.666 + case 57: // number conversion // 133
62.667 + case 58: stack.push(arg4); // 21 4
62.668 + case 60: // number conversion // 133
62.669 + case 61: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101
62.670 + case 62: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148
62.671 + case 63: if (stack.pop() <= 0) { gt = 68; continue; } // 158 0 5
62.672 + case 66: stack.push(0); // 3
62.673 + case 67: return stack.pop(); // 172
62.674 + case 68: stack.push(arg4); // 21 4
62.675 + case 70: arg4 += 255; // 132 4 255
62.676 + case 73: if (stack.pop() <= 0) { gt = 97; continue; } // 158 0 24
62.677 + case 76: stack.push(arg5); // 25 5
62.678 + case 78: stack.push(arg6); // 21 6
62.679 + case 80: arg6++; // 132 6 1
62.680 + case 83: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.681 + case 84: stack.push(arg7); // 25 7
62.682 + case 86: stack.push(arg8); // 21 8
62.683 + case 88: arg8++; // 132 8 1
62.684 + case 91: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.685 + case 92: if (stack.pop() == stack.pop()) { gt = 68; continue; } // 159 255 232
62.686 + case 95: stack.push(0); // 3
62.687 + case 96: return stack.pop(); // 172
62.688 + case 97: stack.push(1); // 4
62.689 + case 98: return stack.pop(); // 172
62.690 + }
62.691 +}
62.692 +function java_lang_String_regionMatchesZZILjava_lang_StringII(arg0,arg1,arg2,arg3,arg4,arg5) {
62.693 + var arg6;
62.694 + var arg7;
62.695 + var arg8;
62.696 + var arg9;
62.697 + var arg10;
62.698 + var arg11;
62.699 + var arg12;
62.700 + var arg13;
62.701 + var arg14;
62.702 +;
62.703 + var stack = new Array(6);
62.704 + var gt = 0;
62.705 + for(;;) switch(gt) {
62.706 + case 0: stack.push(arg0); // 42
62.707 + case 1: stack.push(stack.pop().value); // 180 1 100
62.708 + case 4: arg6 = stack.pop() // 58 6
62.709 + case 6: stack.push(arg0); // 42
62.710 + case 7: stack.push(stack.pop().offset); // 180 1 99
62.711 + case 10: stack.push(arg2); // 28
62.712 + case 11: stack.push(stack.pop() + stack.pop()); // 96
62.713 + case 12: arg7 = stack.pop() // 54 7
62.714 + case 14: stack.push(arg3); // 45
62.715 + case 15: stack.push(stack.pop().value); // 180 1 100
62.716 + case 18: arg8 = stack.pop() // 58 8
62.717 + case 20: stack.push(arg3); // 45
62.718 + case 21: stack.push(stack.pop().offset); // 180 1 99
62.719 + case 24: stack.push(arg4); // 21 4
62.720 + case 26: stack.push(stack.pop() + stack.pop()); // 96
62.721 + case 27: arg9 = stack.pop() // 54 9
62.722 + case 29: stack.push(arg4); // 21 4
62.723 + case 31: if (stack.pop() < 0) { gt = 69; continue; } // 155 0 38
62.724 + case 34: stack.push(arg2); // 28
62.725 + case 35: if (stack.pop() < 0) { gt = 69; continue; } // 155 0 34
62.726 + case 38: stack.push(arg2); // 28
62.727 + case 39: // number conversion // 133
62.728 + case 40: stack.push(arg0); // 42
62.729 + case 41: stack.push(stack.pop().count); // 180 1 97
62.730 + case 44: // number conversion // 133
62.731 + case 45: stack.push(arg5); // 21 5
62.732 + case 47: // number conversion // 133
62.733 + case 48: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101
62.734 + case 49: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148
62.735 + case 50: if (stack.pop() > 0) { gt = 69; continue; } // 157 0 19
62.736 + case 53: stack.push(arg4); // 21 4
62.737 + case 55: // number conversion // 133
62.738 + case 56: stack.push(arg3); // 45
62.739 + case 57: stack.push(stack.pop().count); // 180 1 97
62.740 + case 60: // number conversion // 133
62.741 + case 61: stack.push(arg5); // 21 5
62.742 + case 63: // number conversion // 133
62.743 + case 64: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101
62.744 + case 65: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148
62.745 + case 66: if (stack.pop() <= 0) { gt = 71; continue; } // 158 0 5
62.746 + case 69: stack.push(0); // 3
62.747 + case 70: return stack.pop(); // 172
62.748 + case 71: stack.push(arg5); // 21 5
62.749 + case 73: arg5 += 255; // 132 5 255
62.750 + case 76: if (stack.pop() <= 0) { gt = 155; continue; } // 158 0 79
62.751 + case 79: stack.push(arg6); // 25 6
62.752 + case 81: stack.push(arg7); // 21 7
62.753 + case 83: arg7++; // 132 7 1
62.754 + case 86: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.755 + case 87: arg10 = stack.pop() // 54 10
62.756 + case 89: stack.push(arg8); // 25 8
62.757 + case 91: stack.push(arg9); // 21 9
62.758 + case 93: arg9++; // 132 9 1
62.759 + case 96: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.760 + case 97: arg11 = stack.pop() // 54 11
62.761 + case 99: stack.push(arg10); // 21 10
62.762 + case 101: stack.push(arg11); // 21 11
62.763 + case 103: if (stack.pop() != stack.pop()) { gt = 109; continue; } // 160 0 6
62.764 + case 106: gt = 71; continue; // 167 255 221
62.765 + case 109: stack.push(arg1); // 27
62.766 + case 110: if (stack.pop() == 0) { gt = 153; continue; } // 153 0 43
62.767 + case 113: stack.push(arg10); // 21 10
62.768 + case 115: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseCC(v0)); } // 184 1 105
62.769 + case 118: arg12 = stack.pop() // 54 12
62.770 + case 120: stack.push(arg11); // 21 11
62.771 + case 122: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseCC(v0)); } // 184 1 105
62.772 + case 125: arg13 = stack.pop() // 54 13
62.773 + case 127: stack.push(arg12); // 21 12
62.774 + case 129: stack.push(arg13); // 21 13
62.775 + case 131: if (stack.pop() != stack.pop()) { gt = 137; continue; } // 160 0 6
62.776 + case 134: gt = 71; continue; // 167 255 193
62.777 + case 137: stack.push(arg12); // 21 12
62.778 + case 139: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseCC(v0)); } // 184 1 104
62.779 + case 142: stack.push(arg13); // 21 13
62.780 + case 144: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseCC(v0)); } // 184 1 104
62.781 + case 147: if (stack.pop() != stack.pop()) { gt = 153; continue; } // 160 0 6
62.782 + case 150: gt = 71; continue; // 167 255 177
62.783 + case 153: stack.push(0); // 3
62.784 + case 154: return stack.pop(); // 172
62.785 + case 155: stack.push(1); // 4
62.786 + case 156: return stack.pop(); // 172
62.787 + }
62.788 +}
62.789 +function java_lang_String_startsWithZLjava_lang_StringI(arg0,arg1,arg2) {
62.790 + var arg3;
62.791 + var arg4;
62.792 + var arg5;
62.793 + var arg6;
62.794 + var arg7;
62.795 + var arg8;
62.796 +;
62.797 + var stack = new Array(3);
62.798 + var gt = 0;
62.799 + for(;;) switch(gt) {
62.800 + case 0: stack.push(arg0); // 42
62.801 + case 1: stack.push(stack.pop().value); // 180 1 100
62.802 + case 4: arg3 = stack.pop(); // 78
62.803 + case 5: stack.push(arg0); // 42
62.804 + case 6: stack.push(stack.pop().offset); // 180 1 99
62.805 + case 9: stack.push(arg2); // 28
62.806 + case 10: stack.push(stack.pop() + stack.pop()); // 96
62.807 + case 11: arg4 = stack.pop() // 54 4
62.808 + case 13: stack.push(arg1); // 43
62.809 + case 14: stack.push(stack.pop().value); // 180 1 100
62.810 + case 17: arg5 = stack.pop() // 58 5
62.811 + case 19: stack.push(arg1); // 43
62.812 + case 20: stack.push(stack.pop().offset); // 180 1 99
62.813 + case 23: arg6 = stack.pop() // 54 6
62.814 + case 25: stack.push(arg1); // 43
62.815 + case 26: stack.push(stack.pop().count); // 180 1 97
62.816 + case 29: arg7 = stack.pop() // 54 7
62.817 + case 31: stack.push(arg2); // 28
62.818 + case 32: if (stack.pop() < 0) { gt = 46; continue; } // 155 0 14
62.819 + case 35: stack.push(arg2); // 28
62.820 + case 36: stack.push(arg0); // 42
62.821 + case 37: stack.push(stack.pop().count); // 180 1 97
62.822 + case 40: stack.push(arg7); // 21 7
62.823 + case 42: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.824 + case 43: if (stack.pop() >= stack.pop()) { gt = 48; continue; } // 164 0 5
62.825 + case 46: stack.push(0); // 3
62.826 + case 47: return stack.pop(); // 172
62.827 + case 48: arg7 += 255; // 132 7 255
62.828 + case 51: stack.push(arg7); // 21 7
62.829 + case 53: if (stack.pop() < 0) { gt = 76; continue; } // 155 0 23
62.830 + case 56: stack.push(arg3); // 45
62.831 + case 57: stack.push(arg4); // 21 4
62.832 + case 59: arg4++; // 132 4 1
62.833 + case 62: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.834 + case 63: stack.push(arg5); // 25 5
62.835 + case 65: stack.push(arg6); // 21 6
62.836 + case 67: arg6++; // 132 6 1
62.837 + case 70: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.838 + case 71: if (stack.pop() == stack.pop()) { gt = 48; continue; } // 159 255 233
62.839 + case 74: stack.push(0); // 3
62.840 + case 75: return stack.pop(); // 172
62.841 + case 76: stack.push(1); // 4
62.842 + case 77: return stack.pop(); // 172
62.843 + }
62.844 +}
62.845 +function java_lang_String_startsWithZLjava_lang_String(arg0,arg1) {
62.846 + var arg2;
62.847 +;
62.848 + var stack = new Array(3);
62.849 + var gt = 0;
62.850 + for(;;) switch(gt) {
62.851 + case 0: stack.push(arg0); // 42
62.852 + case 1: stack.push(arg1); // 43
62.853 + case 2: stack.push(0); // 3
62.854 + 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
62.855 + case 6: return stack.pop(); // 172
62.856 + }
62.857 +}
62.858 +function java_lang_String_endsWithZLjava_lang_String(arg0,arg1) {
62.859 + var arg2;
62.860 +;
62.861 + var stack = new Array(4);
62.862 + var gt = 0;
62.863 + for(;;) switch(gt) {
62.864 + case 0: stack.push(arg0); // 42
62.865 + case 1: stack.push(arg1); // 43
62.866 + case 2: stack.push(arg0); // 42
62.867 + case 3: stack.push(stack.pop().count); // 180 1 97
62.868 + case 6: stack.push(arg1); // 43
62.869 + case 7: stack.push(stack.pop().count); // 180 1 97
62.870 + case 10: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.871 + 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
62.872 + case 14: return stack.pop(); // 172
62.873 + }
62.874 +}
62.875 +function java_lang_String_hashCodeI(arg0) {
62.876 + var arg1;
62.877 + var arg2;
62.878 + var arg3;
62.879 + var arg4;
62.880 + var arg5;
62.881 + var arg6;
62.882 +;
62.883 + var stack = new Array(3);
62.884 + var gt = 0;
62.885 + for(;;) switch(gt) {
62.886 + case 0: stack.push(arg0); // 42
62.887 + case 1: stack.push(stack.pop().hash); // 180 1 98
62.888 + case 4: arg1 = stack.pop(); // 60
62.889 + case 5: stack.push(arg0); // 42
62.890 + case 6: stack.push(stack.pop().count); // 180 1 97
62.891 + case 9: arg2 = stack.pop(); // 61
62.892 + case 10: stack.push(arg1); // 27
62.893 + case 11: if (stack.pop() != 0) { gt = 62; continue; } // 154 0 51
62.894 + case 14: stack.push(arg2); // 28
62.895 + case 15: if (stack.pop() <= 0) { gt = 62; continue; } // 158 0 47
62.896 + case 18: stack.push(arg0); // 42
62.897 + case 19: stack.push(stack.pop().offset); // 180 1 99
62.898 + case 22: arg3 = stack.pop(); // 62
62.899 + case 23: stack.push(arg0); // 42
62.900 + case 24: stack.push(stack.pop().value); // 180 1 100
62.901 + case 27: arg4 = stack.pop() // 58 4
62.902 + case 29: stack.push(0); // 3
62.903 + case 30: arg5 = stack.pop() // 54 5
62.904 + case 32: stack.push(arg5); // 21 5
62.905 + case 34: stack.push(arg2); // 28
62.906 + case 35: if (stack.pop() <= stack.pop()) { gt = 57; continue; } // 162 0 22
62.907 + case 38: stack.push(31); // 16 31
62.908 + case 40: stack.push(arg1); // 27
62.909 + case 41: stack.push(stack.pop() * stack.pop()); // 104
62.910 + case 42: stack.push(arg4); // 25 4
62.911 + case 44: stack.push(arg3); // 29
62.912 + case 45: arg3++; // 132 3 1
62.913 + case 48: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.914 + case 49: stack.push(stack.pop() + stack.pop()); // 96
62.915 + case 50: arg1 = stack.pop(); // 60
62.916 + case 51: arg5++; // 132 5 1
62.917 + case 54: gt = 32; continue; // 167 255 234
62.918 + case 57: stack.push(arg0); // 42
62.919 + case 58: stack.push(arg1); // 27
62.920 + case 59: { var v = stack.pop(); stack.pop().hash = v; } // 181 1 98
62.921 + case 62: stack.push(arg1); // 27
62.922 + case 63: return stack.pop(); // 172
62.923 + }
62.924 +}
62.925 +function java_lang_String_indexOfII(arg0,arg1) {
62.926 + var arg2;
62.927 +;
62.928 + var stack = new Array(3);
62.929 + var gt = 0;
62.930 + for(;;) switch(gt) {
62.931 + case 0: stack.push(arg0); // 42
62.932 + case 1: stack.push(arg1); // 27
62.933 + case 2: stack.push(0); // 3
62.934 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.indexOfIII(self, v0, v1)); } // 182 1 135
62.935 + case 6: return stack.pop(); // 172
62.936 + }
62.937 +}
62.938 +function java_lang_String_indexOfIII(arg0,arg1,arg2) {
62.939 + var arg3;
62.940 + var arg4;
62.941 + var arg5;
62.942 + var arg6;
62.943 + var arg7;
62.944 +;
62.945 + var stack = new Array(3);
62.946 + var gt = 0;
62.947 + for(;;) switch(gt) {
62.948 + case 0: stack.push(arg0); // 42
62.949 + case 1: stack.push(stack.pop().offset); // 180 1 99
62.950 + case 4: stack.push(arg0); // 42
62.951 + case 5: stack.push(stack.pop().count); // 180 1 97
62.952 + case 8: stack.push(stack.pop() + stack.pop()); // 96
62.953 + case 9: arg3 = stack.pop(); // 62
62.954 + case 10: stack.push(arg0); // 42
62.955 + case 11: stack.push(stack.pop().value); // 180 1 100
62.956 + case 14: arg4 = stack.pop() // 58 4
62.957 + case 16: stack.push(arg2); // 28
62.958 + case 17: if (stack.pop() >= 0) { gt = 25; continue; } // 156 0 8
62.959 + case 20: stack.push(0); // 3
62.960 + case 21: arg2 = stack.pop(); // 61
62.961 + case 22: gt = 35; continue; // 167 0 13
62.962 + case 25: stack.push(arg2); // 28
62.963 + case 26: stack.push(arg0); // 42
62.964 + case 27: stack.push(stack.pop().count); // 180 1 97
62.965 + case 30: if (stack.pop() > stack.pop()) { gt = 35; continue; } // 161 0 5
62.966 + case 33: // 2
62.967 + case 34: return stack.pop(); // 172
62.968 + case 35: stack.push(arg0); // 42
62.969 + case 36: stack.push(stack.pop().offset); // 180 1 99
62.970 + case 39: stack.push(arg2); // 28
62.971 + case 40: stack.push(stack.pop() + stack.pop()); // 96
62.972 + case 41: arg5 = stack.pop() // 54 5
62.973 + case 43: stack.push(arg1); // 27
62.974 + case 44: stack.push(65536); // 18 3
62.975 + case 46: if (stack.pop() <= stack.pop()) { gt = 80; continue; } // 162 0 34
62.976 + case 49: stack.push(arg5); // 21 5
62.977 + case 51: stack.push(arg3); // 29
62.978 + case 52: if (stack.pop() <= stack.pop()) { gt = 78; continue; } // 162 0 26
62.979 + case 55: stack.push(arg4); // 25 4
62.980 + case 57: stack.push(arg5); // 21 5
62.981 + case 59: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.982 + case 60: stack.push(arg1); // 27
62.983 + case 61: if (stack.pop() != stack.pop()) { gt = 72; continue; } // 160 0 11
62.984 + case 64: stack.push(arg5); // 21 5
62.985 + case 66: stack.push(arg0); // 42
62.986 + case 67: stack.push(stack.pop().offset); // 180 1 99
62.987 + case 70: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.988 + case 71: return stack.pop(); // 172
62.989 + case 72: arg5++; // 132 5 1
62.990 + case 75: gt = 49; continue; // 167 255 230
62.991 + case 78: // 2
62.992 + case 79: return stack.pop(); // 172
62.993 + case 80: stack.push(arg1); // 27
62.994 + case 81: stack.push(1114111); // 18 4
62.995 + case 83: if (stack.pop() < stack.pop()) { gt = 149; continue; } // 163 0 66
62.996 + case 86: stack.push(arg1); // 27
62.997 + case 87: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109
62.998 + case 90: arg6 = stack.pop() // 58 6
62.999 + case 92: stack.push(arg5); // 21 5
62.1000 + case 94: stack.push(arg3); // 29
62.1001 + case 95: if (stack.pop() <= stack.pop()) { gt = 149; continue; } // 162 0 54
62.1002 + case 98: stack.push(arg4); // 25 4
62.1003 + case 100: stack.push(arg5); // 21 5
62.1004 + case 102: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1005 + case 103: stack.push(arg6); // 25 6
62.1006 + case 105: stack.push(0); // 3
62.1007 + case 106: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1008 + case 107: if (stack.pop() != stack.pop()) { gt = 143; continue; } // 160 0 36
62.1009 + case 110: stack.push(arg5); // 21 5
62.1010 + case 112: stack.push(1); // 4
62.1011 + case 113: stack.push(stack.pop() + stack.pop()); // 96
62.1012 + case 114: stack.push(arg3); // 29
62.1013 + case 115: if (stack.pop() != stack.pop()) { gt = 121; continue; } // 160 0 6
62.1014 + case 118: gt = 149; continue; // 167 0 31
62.1015 + case 121: stack.push(arg4); // 25 4
62.1016 + case 123: stack.push(arg5); // 21 5
62.1017 + case 125: stack.push(1); // 4
62.1018 + case 126: stack.push(stack.pop() + stack.pop()); // 96
62.1019 + case 127: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1020 + case 128: stack.push(arg6); // 25 6
62.1021 + case 130: stack.push(1); // 4
62.1022 + case 131: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1023 + case 132: if (stack.pop() != stack.pop()) { gt = 143; continue; } // 160 0 11
62.1024 + case 135: stack.push(arg5); // 21 5
62.1025 + case 137: stack.push(arg0); // 42
62.1026 + case 138: stack.push(stack.pop().offset); // 180 1 99
62.1027 + case 141: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1028 + case 142: return stack.pop(); // 172
62.1029 + case 143: arg5++; // 132 5 1
62.1030 + case 146: gt = 92; continue; // 167 255 202
62.1031 + case 149: // 2
62.1032 + case 150: return stack.pop(); // 172
62.1033 + }
62.1034 +}
62.1035 +function java_lang_String_lastIndexOfII(arg0,arg1) {
62.1036 + var arg2;
62.1037 +;
62.1038 + var stack = new Array(4);
62.1039 + var gt = 0;
62.1040 + for(;;) switch(gt) {
62.1041 + case 0: stack.push(arg0); // 42
62.1042 + case 1: stack.push(arg1); // 27
62.1043 + case 2: stack.push(arg0); // 42
62.1044 + case 3: stack.push(stack.pop().count); // 180 1 97
62.1045 + case 6: stack.push(1); // 4
62.1046 + case 7: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1047 + case 8: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.lastIndexOfIII(self, v0, v1)); } // 182 1 136
62.1048 + case 11: return stack.pop(); // 172
62.1049 + }
62.1050 +}
62.1051 +function java_lang_String_lastIndexOfIII(arg0,arg1,arg2) {
62.1052 + var arg3;
62.1053 + var arg4;
62.1054 + var arg5;
62.1055 + var arg6;
62.1056 + var arg7;
62.1057 + var arg8;
62.1058 +;
62.1059 + var stack = new Array(3);
62.1060 + var gt = 0;
62.1061 + for(;;) switch(gt) {
62.1062 + case 0: stack.push(arg0); // 42
62.1063 + case 1: stack.push(stack.pop().offset); // 180 1 99
62.1064 + case 4: arg3 = stack.pop(); // 62
62.1065 + case 5: stack.push(arg0); // 42
62.1066 + case 6: stack.push(stack.pop().value); // 180 1 100
62.1067 + case 9: arg4 = stack.pop() // 58 4
62.1068 + case 11: stack.push(arg0); // 42
62.1069 + case 12: stack.push(stack.pop().offset); // 180 1 99
62.1070 + case 15: stack.push(arg2); // 28
62.1071 + case 16: stack.push(arg0); // 42
62.1072 + case 17: stack.push(stack.pop().count); // 180 1 97
62.1073 + case 20: if (stack.pop() > stack.pop()) { gt = 32; continue; } // 161 0 12
62.1074 + case 23: stack.push(arg0); // 42
62.1075 + case 24: stack.push(stack.pop().count); // 180 1 97
62.1076 + case 27: stack.push(1); // 4
62.1077 + case 28: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1078 + case 29: gt = 33; continue; // 167 0 4
62.1079 + case 32: stack.push(arg2); // 28
62.1080 + case 33: stack.push(stack.pop() + stack.pop()); // 96
62.1081 + case 34: arg5 = stack.pop() // 54 5
62.1082 + case 36: stack.push(arg1); // 27
62.1083 + case 37: stack.push(65536); // 18 3
62.1084 + case 39: if (stack.pop() <= stack.pop()) { gt = 73; continue; } // 162 0 34
62.1085 + case 42: stack.push(arg5); // 21 5
62.1086 + case 44: stack.push(arg3); // 29
62.1087 + case 45: if (stack.pop() > stack.pop()) { gt = 71; continue; } // 161 0 26
62.1088 + case 48: stack.push(arg4); // 25 4
62.1089 + case 50: stack.push(arg5); // 21 5
62.1090 + case 52: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1091 + case 53: stack.push(arg1); // 27
62.1092 + case 54: if (stack.pop() != stack.pop()) { gt = 65; continue; } // 160 0 11
62.1093 + case 57: stack.push(arg5); // 21 5
62.1094 + case 59: stack.push(arg0); // 42
62.1095 + case 60: stack.push(stack.pop().offset); // 180 1 99
62.1096 + case 63: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1097 + case 64: return stack.pop(); // 172
62.1098 + case 65: arg5 += 255; // 132 5 255
62.1099 + case 68: gt = 42; continue; // 167 255 230
62.1100 + case 71: // 2
62.1101 + case 72: return stack.pop(); // 172
62.1102 + case 73: stack.push(arg0); // 42
62.1103 + case 74: stack.push(stack.pop().offset); // 180 1 99
62.1104 + case 77: stack.push(arg0); // 42
62.1105 + case 78: stack.push(stack.pop().count); // 180 1 97
62.1106 + case 81: stack.push(stack.pop() + stack.pop()); // 96
62.1107 + case 82: arg6 = stack.pop() // 54 6
62.1108 + case 84: stack.push(arg1); // 27
62.1109 + case 85: stack.push(1114111); // 18 4
62.1110 + case 87: if (stack.pop() < stack.pop()) { gt = 154; continue; } // 163 0 67
62.1111 + case 90: stack.push(arg1); // 27
62.1112 + case 91: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109
62.1113 + case 94: arg7 = stack.pop() // 58 7
62.1114 + case 96: stack.push(arg5); // 21 5
62.1115 + case 98: stack.push(arg3); // 29
62.1116 + case 99: if (stack.pop() > stack.pop()) { gt = 154; continue; } // 161 0 55
62.1117 + case 102: stack.push(arg4); // 25 4
62.1118 + case 104: stack.push(arg5); // 21 5
62.1119 + case 106: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1120 + case 107: stack.push(arg7); // 25 7
62.1121 + case 109: stack.push(0); // 3
62.1122 + case 110: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1123 + case 111: if (stack.pop() != stack.pop()) { gt = 148; continue; } // 160 0 37
62.1124 + case 114: stack.push(arg5); // 21 5
62.1125 + case 116: stack.push(1); // 4
62.1126 + case 117: stack.push(stack.pop() + stack.pop()); // 96
62.1127 + case 118: stack.push(arg6); // 21 6
62.1128 + case 120: if (stack.pop() != stack.pop()) { gt = 126; continue; } // 160 0 6
62.1129 + case 123: gt = 154; continue; // 167 0 31
62.1130 + case 126: stack.push(arg4); // 25 4
62.1131 + case 128: stack.push(arg5); // 21 5
62.1132 + case 130: stack.push(1); // 4
62.1133 + case 131: stack.push(stack.pop() + stack.pop()); // 96
62.1134 + case 132: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1135 + case 133: stack.push(arg7); // 25 7
62.1136 + case 135: stack.push(1); // 4
62.1137 + case 136: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1138 + case 137: if (stack.pop() != stack.pop()) { gt = 148; continue; } // 160 0 11
62.1139 + case 140: stack.push(arg5); // 21 5
62.1140 + case 142: stack.push(arg0); // 42
62.1141 + case 143: stack.push(stack.pop().offset); // 180 1 99
62.1142 + case 146: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1143 + case 147: return stack.pop(); // 172
62.1144 + case 148: arg5 += 255; // 132 5 255
62.1145 + case 151: gt = 96; continue; // 167 255 201
62.1146 + case 154: // 2
62.1147 + case 155: return stack.pop(); // 172
62.1148 + }
62.1149 +}
62.1150 +function java_lang_String_indexOfILjava_lang_String(arg0,arg1) {
62.1151 + var arg2;
62.1152 +;
62.1153 + var stack = new Array(3);
62.1154 + var gt = 0;
62.1155 + for(;;) switch(gt) {
62.1156 + case 0: stack.push(arg0); // 42
62.1157 + case 1: stack.push(arg1); // 43
62.1158 + case 2: stack.push(0); // 3
62.1159 + 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
62.1160 + case 6: return stack.pop(); // 172
62.1161 + }
62.1162 +}
62.1163 +function java_lang_String_indexOfILjava_lang_StringI(arg0,arg1,arg2) {
62.1164 + var arg3;
62.1165 +;
62.1166 + var stack = new Array(7);
62.1167 + var gt = 0;
62.1168 + for(;;) switch(gt) {
62.1169 + case 0: stack.push(arg0); // 42
62.1170 + case 1: stack.push(stack.pop().value); // 180 1 100
62.1171 + case 4: stack.push(arg0); // 42
62.1172 + case 5: stack.push(stack.pop().offset); // 180 1 99
62.1173 + case 8: stack.push(arg0); // 42
62.1174 + case 9: stack.push(stack.pop().count); // 180 1 97
62.1175 + case 12: stack.push(arg1); // 43
62.1176 + case 13: stack.push(stack.pop().value); // 180 1 100
62.1177 + case 16: stack.push(arg1); // 43
62.1178 + case 17: stack.push(stack.pop().offset); // 180 1 99
62.1179 + case 20: stack.push(arg1); // 43
62.1180 + case 21: stack.push(stack.pop().count); // 180 1 97
62.1181 + case 24: stack.push(arg2); // 28
62.1182 + 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
62.1183 + case 28: return stack.pop(); // 172
62.1184 + }
62.1185 +}
62.1186 +function java_lang_String_indexOfIACIIACIII(arg0,arg1,arg2,arg3,arg4,arg5,arg6) {
62.1187 + var arg7;
62.1188 + var arg8;
62.1189 + var arg9;
62.1190 + var arg10;
62.1191 + var arg11;
62.1192 + var arg12;
62.1193 + var stack = new Array();
62.1194 + var gt = 0;
62.1195 + for(;;) switch(gt) {
62.1196 + case 0: stack.push(arg6); // 21 6
62.1197 + case 2: stack.push(arg2); // 28
62.1198 + case 3: if (stack.pop() > stack.pop()) { gt = 17; continue; } // 161 0 14
62.1199 + case 6: stack.push(arg5); // 21 5
62.1200 + case 8: if (stack.pop() != 0) { gt = 15; continue; } // 154 0 7
62.1201 + case 11: stack.push(arg2); // 28
62.1202 + case 12: gt = 16; continue; // 167 0 4
62.1203 + case 15: // 2
62.1204 + case 16: return stack.pop(); // 172
62.1205 + case 17: stack.push(arg6); // 21 6
62.1206 + case 19: if (stack.pop() >= 0) { gt = 25; continue; } // 156 0 6
62.1207 + case 22: stack.push(0); // 3
62.1208 + case 23: arg6 = stack.pop() // 54 6
62.1209 + case 25: stack.push(arg5); // 21 5
62.1210 + case 27: if (stack.pop() != 0) { gt = 33; continue; } // 154 0 6
62.1211 + case 30: stack.push(arg6); // 21 6
62.1212 + case 32: return stack.pop(); // 172
62.1213 + case 33: stack.push(arg3); // 45
62.1214 + case 34: stack.push(arg4); // 21 4
62.1215 + case 36: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1216 + case 37: arg7 = stack.pop() // 54 7
62.1217 + case 39: stack.push(arg1); // 27
62.1218 + case 40: stack.push(arg2); // 28
62.1219 + case 41: stack.push(arg5); // 21 5
62.1220 + case 43: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1221 + case 44: stack.push(stack.pop() + stack.pop()); // 96
62.1222 + case 45: arg8 = stack.pop() // 54 8
62.1223 + case 47: stack.push(arg1); // 27
62.1224 + case 48: stack.push(arg6); // 21 6
62.1225 + case 50: stack.push(stack.pop() + stack.pop()); // 96
62.1226 + case 51: arg9 = stack.pop() // 54 9
62.1227 + case 53: stack.push(arg9); // 21 9
62.1228 + case 55: stack.push(arg8); // 21 8
62.1229 + case 57: if (stack.pop() < stack.pop()) { gt = 164; continue; } // 163 0 107
62.1230 + case 60: stack.push(arg0); // 42
62.1231 + case 61: stack.push(arg9); // 21 9
62.1232 + case 63: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1233 + case 64: stack.push(arg7); // 21 7
62.1234 + case 66: if (stack.pop() == stack.pop()) { gt = 91; continue; } // 159 0 25
62.1235 + case 69: arg9++; // 132 9 1
62.1236 + case 72: stack.push(arg9); // 21 9
62.1237 + case 74: stack.push(arg8); // 21 8
62.1238 + case 76: if (stack.pop() < stack.pop()) { gt = 91; continue; } // 163 0 15
62.1239 + case 79: stack.push(arg0); // 42
62.1240 + case 80: stack.push(arg9); // 21 9
62.1241 + case 82: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1242 + case 83: stack.push(arg7); // 21 7
62.1243 + case 85: if (stack.pop() == stack.pop()) { gt = 91; continue; } // 159 0 6
62.1244 + case 88: gt = 69; continue; // 167 255 237
62.1245 + case 91: stack.push(arg9); // 21 9
62.1246 + case 93: stack.push(arg8); // 21 8
62.1247 + case 95: if (stack.pop() < stack.pop()) { gt = 158; continue; } // 163 0 63
62.1248 + case 98: stack.push(arg9); // 21 9
62.1249 + case 100: stack.push(1); // 4
62.1250 + case 101: stack.push(stack.pop() + stack.pop()); // 96
62.1251 + case 102: arg10 = stack.pop() // 54 10
62.1252 + case 104: stack.push(arg10); // 21 10
62.1253 + case 106: stack.push(arg5); // 21 5
62.1254 + case 108: stack.push(stack.pop() + stack.pop()); // 96
62.1255 + case 109: stack.push(1); // 4
62.1256 + case 110: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1257 + case 111: arg11 = stack.pop() // 54 11
62.1258 + case 113: stack.push(arg4); // 21 4
62.1259 + case 115: stack.push(1); // 4
62.1260 + case 116: stack.push(stack.pop() + stack.pop()); // 96
62.1261 + case 117: arg12 = stack.pop() // 54 12
62.1262 + case 119: stack.push(arg10); // 21 10
62.1263 + case 121: stack.push(arg11); // 21 11
62.1264 + case 123: if (stack.pop() <= stack.pop()) { gt = 146; continue; } // 162 0 23
62.1265 + case 126: stack.push(arg0); // 42
62.1266 + case 127: stack.push(arg10); // 21 10
62.1267 + case 129: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1268 + case 130: stack.push(arg3); // 45
62.1269 + case 131: stack.push(arg12); // 21 12
62.1270 + case 133: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1271 + case 134: if (stack.pop() != stack.pop()) { gt = 146; continue; } // 160 0 12
62.1272 + case 137: arg10++; // 132 10 1
62.1273 + case 140: arg12++; // 132 12 1
62.1274 + case 143: gt = 119; continue; // 167 255 232
62.1275 + case 146: stack.push(arg10); // 21 10
62.1276 + case 148: stack.push(arg11); // 21 11
62.1277 + case 150: if (stack.pop() != stack.pop()) { gt = 158; continue; } // 160 0 8
62.1278 + case 153: stack.push(arg9); // 21 9
62.1279 + case 155: stack.push(arg1); // 27
62.1280 + case 156: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1281 + case 157: return stack.pop(); // 172
62.1282 + case 158: arg9++; // 132 9 1
62.1283 + case 161: gt = 53; continue; // 167 255 148
62.1284 + case 164: // 2
62.1285 + case 165: return stack.pop(); // 172
62.1286 + }
62.1287 +}
62.1288 +function java_lang_String_lastIndexOfILjava_lang_String(arg0,arg1) {
62.1289 + var arg2;
62.1290 +;
62.1291 + var stack = new Array(3);
62.1292 + var gt = 0;
62.1293 + for(;;) switch(gt) {
62.1294 + case 0: stack.push(arg0); // 42
62.1295 + case 1: stack.push(arg1); // 43
62.1296 + case 2: stack.push(arg0); // 42
62.1297 + case 3: stack.push(stack.pop().count); // 180 1 97
62.1298 + 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
62.1299 + case 9: return stack.pop(); // 172
62.1300 + }
62.1301 +}
62.1302 +function java_lang_String_lastIndexOfILjava_lang_StringI(arg0,arg1,arg2) {
62.1303 + var arg3;
62.1304 +;
62.1305 + var stack = new Array(7);
62.1306 + var gt = 0;
62.1307 + for(;;) switch(gt) {
62.1308 + case 0: stack.push(arg0); // 42
62.1309 + case 1: stack.push(stack.pop().value); // 180 1 100
62.1310 + case 4: stack.push(arg0); // 42
62.1311 + case 5: stack.push(stack.pop().offset); // 180 1 99
62.1312 + case 8: stack.push(arg0); // 42
62.1313 + case 9: stack.push(stack.pop().count); // 180 1 97
62.1314 + case 12: stack.push(arg1); // 43
62.1315 + case 13: stack.push(stack.pop().value); // 180 1 100
62.1316 + case 16: stack.push(arg1); // 43
62.1317 + case 17: stack.push(stack.pop().offset); // 180 1 99
62.1318 + case 20: stack.push(arg1); // 43
62.1319 + case 21: stack.push(stack.pop().count); // 180 1 97
62.1320 + case 24: stack.push(arg2); // 28
62.1321 + 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
62.1322 + case 28: return stack.pop(); // 172
62.1323 + }
62.1324 +}
62.1325 +function java_lang_String_lastIndexOfIACIIACIII(arg0,arg1,arg2,arg3,arg4,arg5,arg6) {
62.1326 + var arg7;
62.1327 + var arg8;
62.1328 + var arg9;
62.1329 + var arg10;
62.1330 + var arg11;
62.1331 + var arg12;
62.1332 + var arg13;
62.1333 + var arg14;
62.1334 + var stack = new Array();
62.1335 + var gt = 0;
62.1336 + for(;;) switch(gt) {
62.1337 + case 0: stack.push(arg2); // 28
62.1338 + case 1: stack.push(arg5); // 21 5
62.1339 + case 3: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1340 + case 4: arg7 = stack.pop() // 54 7
62.1341 + case 6: stack.push(arg6); // 21 6
62.1342 + case 8: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 5
62.1343 + case 11: // 2
62.1344 + case 12: return stack.pop(); // 172
62.1345 + case 13: stack.push(arg6); // 21 6
62.1346 + case 15: stack.push(arg7); // 21 7
62.1347 + case 17: if (stack.pop() >= stack.pop()) { gt = 24; continue; } // 164 0 7
62.1348 + case 20: stack.push(arg7); // 21 7
62.1349 + case 22: arg6 = stack.pop() // 54 6
62.1350 + case 24: stack.push(arg5); // 21 5
62.1351 + case 26: if (stack.pop() != 0) { gt = 32; continue; } // 154 0 6
62.1352 + case 29: stack.push(arg6); // 21 6
62.1353 + case 31: return stack.pop(); // 172
62.1354 + case 32: stack.push(arg4); // 21 4
62.1355 + case 34: stack.push(arg5); // 21 5
62.1356 + case 36: stack.push(stack.pop() + stack.pop()); // 96
62.1357 + case 37: stack.push(1); // 4
62.1358 + case 38: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1359 + case 39: arg8 = stack.pop() // 54 8
62.1360 + case 41: stack.push(arg3); // 45
62.1361 + case 42: stack.push(arg8); // 21 8
62.1362 + case 44: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1363 + case 45: arg9 = stack.pop() // 54 9
62.1364 + case 47: stack.push(arg1); // 27
62.1365 + case 48: stack.push(arg5); // 21 5
62.1366 + case 50: stack.push(stack.pop() + stack.pop()); // 96
62.1367 + case 51: stack.push(1); // 4
62.1368 + case 52: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1369 + case 53: arg10 = stack.pop() // 54 10
62.1370 + case 55: stack.push(arg10); // 21 10
62.1371 + case 57: stack.push(arg6); // 21 6
62.1372 + case 59: stack.push(stack.pop() + stack.pop()); // 96
62.1373 + case 60: arg11 = stack.pop() // 54 11
62.1374 + case 62: stack.push(arg11); // 21 11
62.1375 + case 64: stack.push(arg10); // 21 10
62.1376 + case 66: if (stack.pop() > stack.pop()) { gt = 84; continue; } // 161 0 18
62.1377 + case 69: stack.push(arg0); // 42
62.1378 + case 70: stack.push(arg11); // 21 11
62.1379 + case 72: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1380 + case 73: stack.push(arg9); // 21 9
62.1381 + case 75: if (stack.pop() == stack.pop()) { gt = 84; continue; } // 159 0 9
62.1382 + case 78: arg11 += 255; // 132 11 255
62.1383 + case 81: gt = 62; continue; // 167 255 237
62.1384 + case 84: stack.push(arg11); // 21 11
62.1385 + case 86: stack.push(arg10); // 21 10
62.1386 + case 88: if (stack.pop() <= stack.pop()) { gt = 93; continue; } // 162 0 5
62.1387 + case 91: // 2
62.1388 + case 92: return stack.pop(); // 172
62.1389 + case 93: stack.push(arg11); // 21 11
62.1390 + case 95: stack.push(1); // 4
62.1391 + case 96: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1392 + case 97: arg12 = stack.pop() // 54 12
62.1393 + case 99: stack.push(arg12); // 21 12
62.1394 + case 101: stack.push(arg5); // 21 5
62.1395 + case 103: stack.push(1); // 4
62.1396 + case 104: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1397 + case 105: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1398 + case 106: arg13 = stack.pop() // 54 13
62.1399 + case 108: stack.push(arg8); // 21 8
62.1400 + case 110: stack.push(1); // 4
62.1401 + case 111: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1402 + case 112: arg14 = stack.pop() // 54 14
62.1403 + case 114: stack.push(arg12); // 21 12
62.1404 + case 116: stack.push(arg13); // 21 13
62.1405 + case 118: if (stack.pop() >= stack.pop()) { gt = 144; continue; } // 164 0 26
62.1406 + case 121: stack.push(arg0); // 42
62.1407 + case 122: stack.push(arg12); // 21 12
62.1408 + case 124: arg12 += 255; // 132 12 255
62.1409 + case 127: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1410 + case 128: stack.push(arg3); // 45
62.1411 + case 129: stack.push(arg14); // 21 14
62.1412 + case 131: arg14 += 255; // 132 14 255
62.1413 + case 134: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1414 + case 135: if (stack.pop() == stack.pop()) { gt = 114; continue; } // 159 255 235
62.1415 + case 138: arg11 += 255; // 132 11 255
62.1416 + case 141: gt = 62; continue; // 167 255 177
62.1417 + case 144: stack.push(arg13); // 21 13
62.1418 + case 146: stack.push(arg1); // 27
62.1419 + case 147: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1420 + case 148: stack.push(1); // 4
62.1421 + case 149: stack.push(stack.pop() + stack.pop()); // 96
62.1422 + case 150: return stack.pop(); // 172
62.1423 + }
62.1424 +}
62.1425 +function java_lang_String_substringLjava_lang_StringI(arg0,arg1) {
62.1426 + var arg2;
62.1427 +;
62.1428 + var stack = new Array(3);
62.1429 + var gt = 0;
62.1430 + for(;;) switch(gt) {
62.1431 + case 0: stack.push(arg0); // 42
62.1432 + case 1: stack.push(arg1); // 27
62.1433 + case 2: stack.push(arg0); // 42
62.1434 + case 3: stack.push(stack.pop().count); // 180 1 97
62.1435 + 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
62.1436 + case 9: return stack.pop(); // 176
62.1437 + }
62.1438 +}
62.1439 +function java_lang_String_substringLjava_lang_StringII(arg0,arg1,arg2) {
62.1440 + var arg3;
62.1441 +;
62.1442 + var stack = new Array(5);
62.1443 + var gt = 0;
62.1444 + for(;;) switch(gt) {
62.1445 + case 0: stack.push(arg1); // 27
62.1446 + case 1: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 12
62.1447 + case 4: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
62.1448 + case 7: stack.push(stack[stack.length - 1]); // 89
62.1449 + case 8: stack.push(arg1); // 27
62.1450 + case 9: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
62.1451 + case 12: // 191
62.1452 + case 13: stack.push(arg2); // 28
62.1453 + case 14: stack.push(arg0); // 42
62.1454 + case 15: stack.push(stack.pop().count); // 180 1 97
62.1455 + case 18: if (stack.pop() >= stack.pop()) { gt = 30; continue; } // 164 0 12
62.1456 + case 21: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
62.1457 + case 24: stack.push(stack[stack.length - 1]); // 89
62.1458 + case 25: stack.push(arg2); // 28
62.1459 + case 26: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
62.1460 + case 29: // 191
62.1461 + case 30: stack.push(arg1); // 27
62.1462 + case 31: stack.push(arg2); // 28
62.1463 + case 32: if (stack.pop() >= stack.pop()) { gt = 46; continue; } // 164 0 14
62.1464 + case 35: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
62.1465 + case 38: stack.push(stack[stack.length - 1]); // 89
62.1466 + case 39: stack.push(arg2); // 28
62.1467 + case 40: stack.push(arg1); // 27
62.1468 + case 41: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1469 + case 42: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
62.1470 + case 45: // 191
62.1471 + case 46: stack.push(arg1); // 27
62.1472 + case 47: if (stack.pop() != 0) { gt = 62; continue; } // 154 0 15
62.1473 + case 50: stack.push(arg2); // 28
62.1474 + case 51: stack.push(arg0); // 42
62.1475 + case 52: stack.push(stack.pop().count); // 180 1 97
62.1476 + case 55: if (stack.pop() != stack.pop()) { gt = 62; continue; } // 160 0 7
62.1477 + case 58: stack.push(arg0); // 42
62.1478 + case 59: gt = 82; continue; // 167 0 23
62.1479 + case 62: stack.push(new java_lang_String); // 187 0 200
62.1480 + case 65: stack.push(stack[stack.length - 1]); // 89
62.1481 + case 66: stack.push(arg0); // 42
62.1482 + case 67: stack.push(stack.pop().offset); // 180 1 99
62.1483 + case 70: stack.push(arg1); // 27
62.1484 + case 71: stack.push(stack.pop() + stack.pop()); // 96
62.1485 + case 72: stack.push(arg2); // 28
62.1486 + case 73: stack.push(arg1); // 27
62.1487 + case 74: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1488 + case 75: stack.push(arg0); // 42
62.1489 + case 76: stack.push(stack.pop().value); // 180 1 100
62.1490 + 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
62.1491 + case 82: return stack.pop(); // 176
62.1492 + }
62.1493 +}
62.1494 +function java_lang_String_subSequenceLjava_lang_CharSequenceII(arg0,arg1,arg2) {
62.1495 + var arg3;
62.1496 +;
62.1497 + var stack = new Array(3);
62.1498 + var gt = 0;
62.1499 + for(;;) switch(gt) {
62.1500 + case 0: stack.push(arg0); // 42
62.1501 + case 1: stack.push(arg1); // 27
62.1502 + case 2: stack.push(arg2); // 28
62.1503 + 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
62.1504 + case 6: return stack.pop(); // 176
62.1505 + }
62.1506 +}
62.1507 +function java_lang_String_concatLjava_lang_StringLjava_lang_String(arg0,arg1) {
62.1508 + var arg2;
62.1509 + var arg3;
62.1510 + var arg4;
62.1511 +;
62.1512 + var stack = new Array(5);
62.1513 + var gt = 0;
62.1514 + for(;;) switch(gt) {
62.1515 + case 0: stack.push(arg1); // 43
62.1516 + case 1: { var self = stack.pop(); stack.push(self.lengthI(self)); } // 182 1 133
62.1517 + case 4: arg2 = stack.pop(); // 61
62.1518 + case 5: stack.push(arg2); // 28
62.1519 + case 6: if (stack.pop() != 0) { gt = 11; continue; } // 154 0 5
62.1520 + case 9: stack.push(arg0); // 42
62.1521 + case 10: return stack.pop(); // 176
62.1522 + case 11: stack.push(arg0); // 42
62.1523 + case 12: stack.push(stack.pop().count); // 180 1 97
62.1524 + case 15: stack.push(arg2); // 28
62.1525 + case 16: stack.push(stack.pop() + stack.pop()); // 96
62.1526 + case 17: stack.push(new Array(stack.pop())); // 188 5
62.1527 + case 19: arg3 = stack.pop(); // 78
62.1528 + case 20: stack.push(arg0); // 42
62.1529 + case 21: stack.push(0); // 3
62.1530 + case 22: stack.push(arg0); // 42
62.1531 + case 23: stack.push(stack.pop().count); // 180 1 97
62.1532 + case 26: stack.push(arg3); // 45
62.1533 + case 27: stack.push(0); // 3
62.1534 + 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
62.1535 + case 31: stack.push(arg1); // 43
62.1536 + case 32: stack.push(0); // 3
62.1537 + case 33: stack.push(arg2); // 28
62.1538 + case 34: stack.push(arg3); // 45
62.1539 + case 35: stack.push(arg0); // 42
62.1540 + case 36: stack.push(stack.pop().count); // 180 1 97
62.1541 + 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
62.1542 + case 42: stack.push(new java_lang_String); // 187 0 200
62.1543 + case 45: stack.push(stack[stack.length - 1]); // 89
62.1544 + case 46: stack.push(0); // 3
62.1545 + case 47: stack.push(arg0); // 42
62.1546 + case 48: stack.push(stack.pop().count); // 180 1 97
62.1547 + case 51: stack.push(arg2); // 28
62.1548 + case 52: stack.push(stack.pop() + stack.pop()); // 96
62.1549 + case 53: stack.push(arg3); // 45
62.1550 + 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
62.1551 + case 57: return stack.pop(); // 176
62.1552 + }
62.1553 +}
62.1554 +function java_lang_String_replaceLjava_lang_StringCC(arg0,arg1,arg2) {
62.1555 + var arg3;
62.1556 + var arg4;
62.1557 + var arg5;
62.1558 + var arg6;
62.1559 + var arg7;
62.1560 + var arg8;
62.1561 + var arg9;
62.1562 +;
62.1563 + var stack = new Array(5);
62.1564 + var gt = 0;
62.1565 + for(;;) switch(gt) {
62.1566 + case 0: stack.push(arg1); // 27
62.1567 + case 1: stack.push(arg2); // 28
62.1568 + case 2: if (stack.pop() == stack.pop()) { gt = 140; continue; } // 159 0 138
62.1569 + case 5: stack.push(arg0); // 42
62.1570 + case 6: stack.push(stack.pop().count); // 180 1 97
62.1571 + case 9: arg3 = stack.pop(); // 62
62.1572 + case 10: // 2
62.1573 + case 11: arg4 = stack.pop() // 54 4
62.1574 + case 13: stack.push(arg0); // 42
62.1575 + case 14: stack.push(stack.pop().value); // 180 1 100
62.1576 + case 17: arg5 = stack.pop() // 58 5
62.1577 + case 19: stack.push(arg0); // 42
62.1578 + case 20: stack.push(stack.pop().offset); // 180 1 99
62.1579 + case 23: arg6 = stack.pop() // 54 6
62.1580 + case 25: arg4++; // 132 4 1
62.1581 + case 28: stack.push(arg4); // 21 4
62.1582 + case 30: stack.push(arg3); // 29
62.1583 + case 31: if (stack.pop() <= stack.pop()) { gt = 49; continue; } // 162 0 18
62.1584 + case 34: stack.push(arg5); // 25 5
62.1585 + case 36: stack.push(arg6); // 21 6
62.1586 + case 38: stack.push(arg4); // 21 4
62.1587 + case 40: stack.push(stack.pop() + stack.pop()); // 96
62.1588 + case 41: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1589 + case 42: stack.push(arg1); // 27
62.1590 + case 43: if (stack.pop() != stack.pop()) { gt = 25; continue; } // 160 255 238
62.1591 + case 46: gt = 49; continue; // 167 0 3
62.1592 + case 49: stack.push(arg4); // 21 4
62.1593 + case 51: stack.push(arg3); // 29
62.1594 + case 52: if (stack.pop() <= stack.pop()) { gt = 140; continue; } // 162 0 88
62.1595 + case 55: stack.push(arg3); // 29
62.1596 + case 56: stack.push(new Array(stack.pop())); // 188 5
62.1597 + case 58: arg7 = stack.pop() // 58 7
62.1598 + case 60: stack.push(0); // 3
62.1599 + case 61: arg8 = stack.pop() // 54 8
62.1600 + case 63: stack.push(arg8); // 21 8
62.1601 + case 65: stack.push(arg4); // 21 4
62.1602 + case 67: if (stack.pop() <= stack.pop()) { gt = 89; continue; } // 162 0 22
62.1603 + case 70: stack.push(arg7); // 25 7
62.1604 + case 72: stack.push(arg8); // 21 8
62.1605 + case 74: stack.push(arg5); // 25 5
62.1606 + case 76: stack.push(arg6); // 21 6
62.1607 + case 78: stack.push(arg8); // 21 8
62.1608 + case 80: stack.push(stack.pop() + stack.pop()); // 96
62.1609 + case 81: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1610 + case 82: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
62.1611 + case 83: arg8++; // 132 8 1
62.1612 + case 86: gt = 63; continue; // 167 255 233
62.1613 + case 89: stack.push(arg4); // 21 4
62.1614 + case 91: stack.push(arg3); // 29
62.1615 + case 92: if (stack.pop() <= stack.pop()) { gt = 128; continue; } // 162 0 36
62.1616 + case 95: stack.push(arg5); // 25 5
62.1617 + case 97: stack.push(arg6); // 21 6
62.1618 + case 99: stack.push(arg4); // 21 4
62.1619 + case 101: stack.push(stack.pop() + stack.pop()); // 96
62.1620 + case 102: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1621 + case 103: arg8 = stack.pop() // 54 8
62.1622 + case 105: stack.push(arg7); // 25 7
62.1623 + case 107: stack.push(arg4); // 21 4
62.1624 + case 109: stack.push(arg8); // 21 8
62.1625 + case 111: stack.push(arg1); // 27
62.1626 + case 112: if (stack.pop() != stack.pop()) { gt = 119; continue; } // 160 0 7
62.1627 + case 115: stack.push(arg2); // 28
62.1628 + case 116: gt = 121; continue; // 167 0 5
62.1629 + case 119: stack.push(arg8); // 21 8
62.1630 + case 121: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
62.1631 + case 122: arg4++; // 132 4 1
62.1632 + case 125: gt = 89; continue; // 167 255 220
62.1633 + case 128: stack.push(new java_lang_String); // 187 0 200
62.1634 + case 131: stack.push(stack[stack.length - 1]); // 89
62.1635 + case 132: stack.push(0); // 3
62.1636 + case 133: stack.push(arg3); // 29
62.1637 + case 134: stack.push(arg7); // 25 7
62.1638 + 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
62.1639 + case 139: return stack.pop(); // 176
62.1640 + case 140: stack.push(arg0); // 42
62.1641 + case 141: return stack.pop(); // 176
62.1642 + }
62.1643 +}
62.1644 +function java_lang_String_matchesZLjava_lang_String(arg0,arg1) {
62.1645 + var arg2;
62.1646 +;
62.1647 + var stack = new Array(2);
62.1648 + var gt = 0;
62.1649 + for(;;) switch(gt) {
62.1650 + case 0: stack.push(arg1); // 43
62.1651 + case 1: stack.push(arg0); // 42
62.1652 + 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
62.1653 + case 5: return stack.pop(); // 172
62.1654 + }
62.1655 +}
62.1656 +function java_lang_String_containsZLjava_lang_CharSequence(arg0,arg1) {
62.1657 + var arg2;
62.1658 +;
62.1659 + var stack = new Array(2);
62.1660 + var gt = 0;
62.1661 + for(;;) switch(gt) {
62.1662 + case 0: stack.push(arg0); // 42
62.1663 + case 1: stack.push(arg1); // 43
62.1664 + case 2: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132
62.1665 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.indexOfILjava_lang_String(self, v0)); } // 182 1 149
62.1666 + case 8: // 2
62.1667 + case 9: if (stack.pop() >= stack.pop()) { gt = 16; continue; } // 164 0 7
62.1668 + case 12: stack.push(1); // 4
62.1669 + case 13: gt = 17; continue; // 167 0 4
62.1670 + case 16: stack.push(0); // 3
62.1671 + case 17: return stack.pop(); // 172
62.1672 + }
62.1673 +}
62.1674 +function java_lang_String_replaceFirstLjava_lang_StringLjava_lang_StringLjava_lang_String(arg0,arg1,arg2) {
62.1675 + var arg3;
62.1676 +;
62.1677 + var stack = new Array(2);
62.1678 + var gt = 0;
62.1679 + for(;;) switch(gt) {
62.1680 + case 0: stack.push(arg1); // 43
62.1681 + case 1: { var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_String(v0)); } // 184 1 186
62.1682 + case 4: stack.push(arg0); // 42
62.1683 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.matcherLjava_util_regex_MatcherLjava_lang_CharSequence(self, v0)); } // 182 1 185
62.1684 + case 8: stack.push(arg2); // 44
62.1685 + case 9: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.replaceFirstLjava_lang_StringLjava_lang_String(self, v0)); } // 182 1 182
62.1686 + case 12: return stack.pop(); // 176
62.1687 + }
62.1688 +}
62.1689 +function java_lang_String_replaceAllLjava_lang_StringLjava_lang_StringLjava_lang_String(arg0,arg1,arg2) {
62.1690 + var arg3;
62.1691 +;
62.1692 + var stack = new Array(2);
62.1693 + var gt = 0;
62.1694 + for(;;) switch(gt) {
62.1695 + case 0: stack.push(arg1); // 43
62.1696 + case 1: { var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_String(v0)); } // 184 1 186
62.1697 + case 4: stack.push(arg0); // 42
62.1698 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.matcherLjava_util_regex_MatcherLjava_lang_CharSequence(self, v0)); } // 182 1 185
62.1699 + case 8: stack.push(arg2); // 44
62.1700 + case 9: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.replaceAllLjava_lang_StringLjava_lang_String(self, v0)); } // 182 1 181
62.1701 + case 12: return stack.pop(); // 176
62.1702 + }
62.1703 +}
62.1704 +function java_lang_String_replaceLjava_lang_StringLjava_lang_CharSequenceLjava_lang_CharSequence(arg0,arg1,arg2) {
62.1705 + var arg3;
62.1706 +;
62.1707 + var stack = new Array(2);
62.1708 + var gt = 0;
62.1709 + for(;;) switch(gt) {
62.1710 + case 0: stack.push(arg1); // 43
62.1711 + case 1: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132
62.1712 + case 4: stack.push(16); // 16 16
62.1713 + 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
62.1714 + case 9: stack.push(arg0); // 42
62.1715 + case 10: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.matcherLjava_util_regex_MatcherLjava_lang_CharSequence(self, v0)); } // 182 1 185
62.1716 + case 13: stack.push(arg2); // 44
62.1717 + case 14: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132
62.1718 + case 17: { var v0 = stack.pop(); stack.push(java_util_regex_Matcher_quoteReplacementLjava_lang_StringLjava_lang_String(v0)); } // 184 1 180
62.1719 + case 20: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.replaceAllLjava_lang_StringLjava_lang_String(self, v0)); } // 182 1 181
62.1720 + case 23: return stack.pop(); // 176
62.1721 + }
62.1722 +}
62.1723 +function java_lang_String_splitALjava_lang_StringLjava_lang_StringI(arg0,arg1,arg2) {
62.1724 + var arg3;
62.1725 +;
62.1726 + var stack = new Array(3);
62.1727 + var gt = 0;
62.1728 + for(;;) switch(gt) {
62.1729 + case 0: stack.push(arg1); // 43
62.1730 + case 1: { var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_String(v0)); } // 184 1 186
62.1731 + case 4: stack.push(arg0); // 42
62.1732 + case 5: stack.push(arg2); // 28
62.1733 + 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
62.1734 + case 9: return stack.pop(); // 176
62.1735 + }
62.1736 +}
62.1737 +function java_lang_String_splitALjava_lang_StringLjava_lang_String(arg0,arg1) {
62.1738 + var arg2;
62.1739 +;
62.1740 + var stack = new Array(3);
62.1741 + var gt = 0;
62.1742 + for(;;) switch(gt) {
62.1743 + case 0: stack.push(arg0); // 42
62.1744 + case 1: stack.push(arg1); // 43
62.1745 + case 2: stack.push(0); // 3
62.1746 + 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
62.1747 + case 6: return stack.pop(); // 176
62.1748 + }
62.1749 +}
62.1750 +function java_lang_String_toLowerCaseLjava_lang_StringLjava_util_Locale(arg0,arg1) {
62.1751 + var arg2;
62.1752 + var arg3;
62.1753 + var arg4;
62.1754 + var arg5;
62.1755 + var arg6;
62.1756 + var arg7;
62.1757 + var arg8;
62.1758 + var arg9;
62.1759 + var arg10;
62.1760 + var arg11;
62.1761 + var arg12;
62.1762 + var arg13;
62.1763 + var arg14;
62.1764 +;
62.1765 + var stack = new Array(6);
62.1766 + var gt = 0;
62.1767 + for(;;) switch(gt) {
62.1768 + case 0: stack.push(arg1); // 43
62.1769 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11
62.1770 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198
62.1771 + case 7: stack.push(stack[stack.length - 1]); // 89
62.1772 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128
62.1773 + case 11: // 191
62.1774 + case 12: stack.push(0); // 3
62.1775 + case 13: arg2 = stack.pop(); // 61
62.1776 + case 14: stack.push(arg2); // 28
62.1777 + case 15: stack.push(arg0); // 42
62.1778 + case 16: stack.push(stack.pop().count); // 180 1 97
62.1779 + case 19: if (stack.pop() <= stack.pop()) { gt = 94; continue; } // 162 0 75
62.1780 + case 22: stack.push(arg0); // 42
62.1781 + case 23: stack.push(stack.pop().value); // 180 1 100
62.1782 + case 26: stack.push(arg0); // 42
62.1783 + case 27: stack.push(stack.pop().offset); // 180 1 99
62.1784 + case 30: stack.push(arg2); // 28
62.1785 + case 31: stack.push(stack.pop() + stack.pop()); // 96
62.1786 + case 32: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1787 + case 33: arg3 = stack.pop(); // 62
62.1788 + case 34: stack.push(arg3); // 29
62.1789 + case 35: stack.push(55296); // 18 1
62.1790 + case 37: if (stack.pop() > stack.pop()) { gt = 77; continue; } // 161 0 40
62.1791 + case 40: stack.push(arg3); // 29
62.1792 + case 41: stack.push(56319); // 18 2
62.1793 + case 43: if (stack.pop() < stack.pop()) { gt = 77; continue; } // 163 0 34
62.1794 + case 46: stack.push(arg0); // 42
62.1795 + case 47: stack.push(arg2); // 28
62.1796 + case 48: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134
62.1797 + case 51: arg4 = stack.pop() // 54 4
62.1798 + case 53: stack.push(arg4); // 21 4
62.1799 + case 55: stack.push(arg4); // 21 4
62.1800 + case 57: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseII(v0)); } // 184 1 107
62.1801 + case 60: if (stack.pop() == stack.pop()) { gt = 66; continue; } // 159 0 6
62.1802 + case 63: gt = 96; continue; // 167 0 33
62.1803 + case 66: stack.push(arg2); // 28
62.1804 + case 67: stack.push(arg4); // 21 4
62.1805 + case 69: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106
62.1806 + case 72: stack.push(stack.pop() + stack.pop()); // 96
62.1807 + case 73: arg2 = stack.pop(); // 61
62.1808 + case 74: gt = 91; continue; // 167 0 17
62.1809 + case 77: stack.push(arg3); // 29
62.1810 + case 78: stack.push(arg3); // 29
62.1811 + case 79: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseCC(v0)); } // 184 1 104
62.1812 + case 82: if (stack.pop() == stack.pop()) { gt = 88; continue; } // 159 0 6
62.1813 + case 85: gt = 96; continue; // 167 0 11
62.1814 + case 88: arg2++; // 132 2 1
62.1815 + case 91: gt = 14; continue; // 167 255 179
62.1816 + case 94: stack.push(arg0); // 42
62.1817 + case 95: return stack.pop(); // 176
62.1818 + case 96: stack.push(arg0); // 42
62.1819 + case 97: stack.push(stack.pop().count); // 180 1 97
62.1820 + case 100: stack.push(new Array(stack.pop())); // 188 5
62.1821 + case 102: arg3 = stack.pop(); // 78
62.1822 + case 103: stack.push(0); // 3
62.1823 + case 104: arg4 = stack.pop() // 54 4
62.1824 + case 106: stack.push(arg0); // 42
62.1825 + case 107: stack.push(stack.pop().value); // 180 1 100
62.1826 + case 110: stack.push(arg0); // 42
62.1827 + case 111: stack.push(stack.pop().offset); // 180 1 99
62.1828 + case 114: stack.push(arg3); // 45
62.1829 + case 115: stack.push(0); // 3
62.1830 + case 116: stack.push(arg2); // 28
62.1831 + 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
62.1832 + case 120: stack.push(arg1); // 43
62.1833 + case 121: { var self = stack.pop(); stack.push(self.getLanguageLjava_lang_String(self)); } // 182 1 178
62.1834 + case 124: arg5 = stack.pop() // 58 5
62.1835 + case 126: stack.push(arg5); // 25 5
62.1836 + case 128: stack.push("tr"); // 18 11
62.1837 + case 130: // 165
62.1838 + case 131: // 0
62.1839 + case 132: stack.push(6405); // 17 25 5
62.1840 + case 135: stack.push("az"); // 18 5
62.1841 + case 137: // 165
62.1842 + case 138: // 0
62.1843 + case 139: stack.push(1); // 10
62.1844 + case 140: stack.push(arg5); // 25 5
62.1845 + case 142: stack.push("lt"); // 18 9
62.1846 + case 144: // 166
62.1847 + case 145: // 0
62.1848 + case 146: stack.push(4); // 7
62.1849 + case 147: stack.push(1); // 4
62.1850 + case 148: gt = 152; continue; // 167 0 4
62.1851 + case 151: stack.push(0); // 3
62.1852 + case 152: arg6 = stack.pop() // 54 6
62.1853 + case 154: stack.push(arg2); // 28
62.1854 + case 155: arg11 = stack.pop() // 54 11
62.1855 + case 157: stack.push(arg11); // 21 11
62.1856 + case 159: stack.push(arg0); // 42
62.1857 + case 160: stack.push(stack.pop().count); // 180 1 97
62.1858 + case 163: if (stack.pop() <= stack.pop()) { gt = 419; continue; } // 162 1 0
62.1859 + case 166: stack.push(arg0); // 42
62.1860 + case 167: stack.push(stack.pop().value); // 180 1 100
62.1861 + case 170: stack.push(arg0); // 42
62.1862 + case 171: stack.push(stack.pop().offset); // 180 1 99
62.1863 + case 174: stack.push(arg11); // 21 11
62.1864 + case 176: stack.push(stack.pop() + stack.pop()); // 96
62.1865 + case 177: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1866 + case 178: arg9 = stack.pop() // 54 9
62.1867 + case 180: stack.push(arg9); // 21 9
62.1868 + case 182: // number conversion // 146
62.1869 + case 183: stack.push(55296); // 18 1
62.1870 + case 185: if (stack.pop() > stack.pop()) { gt = 214; continue; } // 161 0 29
62.1871 + case 188: stack.push(arg9); // 21 9
62.1872 + case 190: // number conversion // 146
62.1873 + case 191: stack.push(56319); // 18 2
62.1874 + case 193: if (stack.pop() < stack.pop()) { gt = 214; continue; } // 163 0 21
62.1875 + case 196: stack.push(arg0); // 42
62.1876 + case 197: stack.push(arg11); // 21 11
62.1877 + case 199: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134
62.1878 + case 202: arg9 = stack.pop() // 54 9
62.1879 + case 204: stack.push(arg9); // 21 9
62.1880 + case 206: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106
62.1881 + case 209: arg10 = stack.pop() // 54 10
62.1882 + case 211: gt = 217; continue; // 167 0 6
62.1883 + case 214: stack.push(1); // 4
62.1884 + case 215: arg10 = stack.pop() // 54 10
62.1885 + case 217: stack.push(arg6); // 21 6
62.1886 + case 219: if (stack.pop() != 0) { gt = 230; continue; } // 154 0 11
62.1887 + case 222: stack.push(arg9); // 21 9
62.1888 + case 224: stack.push(931); // 17 3 163
62.1889 + case 227: if (stack.pop() != stack.pop()) { gt = 242; continue; } // 160 0 15
62.1890 + case 230: stack.push(arg0); // 42
62.1891 + case 231: stack.push(arg11); // 21 11
62.1892 + case 233: stack.push(arg1); // 43
62.1893 + 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
62.1894 + case 237: arg8 = stack.pop() // 54 8
62.1895 + case 239: gt = 249; continue; // 167 0 10
62.1896 + case 242: stack.push(arg9); // 21 9
62.1897 + case 244: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseII(v0)); } // 184 1 107
62.1898 + case 247: arg8 = stack.pop() // 54 8
62.1899 + case 249: stack.push(arg8); // 21 8
62.1900 + case 251: // 2
62.1901 + case 252: if (stack.pop() == stack.pop()) { gt = 262; continue; } // 159 0 10
62.1902 + case 255: stack.push(arg8); // 21 8
62.1903 + case 257: stack.push(65536); // 18 3
62.1904 + case 259: if (stack.pop() > stack.pop()) { gt = 399; continue; } // 161 0 140
62.1905 + case 262: stack.push(arg8); // 21 8
62.1906 + case 264: // 2
62.1907 + case 265: if (stack.pop() != stack.pop()) { gt = 280; continue; } // 160 0 15
62.1908 + case 268: stack.push(arg0); // 42
62.1909 + case 269: stack.push(arg11); // 21 11
62.1910 + case 271: stack.push(arg1); // 43
62.1911 + 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
62.1912 + case 275: arg7 = stack.pop() // 58 7
62.1913 + case 277: gt = 315; continue; // 167 0 38
62.1914 + case 280: stack.push(arg10); // 21 10
62.1915 + case 282: stack.push(2); // 5
62.1916 + case 283: if (stack.pop() != stack.pop()) { gt = 308; continue; } // 160 0 25
62.1917 + case 286: stack.push(arg4); // 21 4
62.1918 + case 288: stack.push(arg8); // 21 8
62.1919 + case 290: stack.push(arg3); // 45
62.1920 + case 291: stack.push(arg11); // 21 11
62.1921 + case 293: stack.push(arg4); // 21 4
62.1922 + case 295: stack.push(stack.pop() + stack.pop()); // 96
62.1923 + 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
62.1924 + case 299: stack.push(arg10); // 21 10
62.1925 + case 301: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1926 + case 302: stack.push(stack.pop() + stack.pop()); // 96
62.1927 + case 303: arg4 = stack.pop() // 54 4
62.1928 + case 305: gt = 409; continue; // 167 0 104
62.1929 + case 308: stack.push(arg8); // 21 8
62.1930 + case 310: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109
62.1931 + case 313: arg7 = stack.pop() // 58 7
62.1932 + case 315: stack.push(arg7); // 25 7
62.1933 + case 317: stack.push(stack.pop().length); // 190
62.1934 + case 318: arg12 = stack.pop() // 54 12
62.1935 + case 320: stack.push(arg12); // 21 12
62.1936 + case 322: stack.push(arg10); // 21 10
62.1937 + case 324: if (stack.pop() >= stack.pop()) { gt = 355; continue; } // 164 0 31
62.1938 + case 327: stack.push(arg3); // 45
62.1939 + case 328: stack.push(stack.pop().length); // 190
62.1940 + case 329: stack.push(arg12); // 21 12
62.1941 + case 331: stack.push(stack.pop() + stack.pop()); // 96
62.1942 + case 332: stack.push(arg10); // 21 10
62.1943 + case 334: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1944 + case 335: stack.push(new Array(stack.pop())); // 188 5
62.1945 + case 337: arg13 = stack.pop() // 58 13
62.1946 + case 339: stack.push(arg3); // 45
62.1947 + case 340: stack.push(0); // 3
62.1948 + case 341: stack.push(arg13); // 25 13
62.1949 + case 343: stack.push(0); // 3
62.1950 + case 344: stack.push(arg11); // 21 11
62.1951 + case 346: stack.push(arg4); // 21 4
62.1952 + case 348: stack.push(stack.pop() + stack.pop()); // 96
62.1953 + 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
62.1954 + case 352: stack.push(arg13); // 25 13
62.1955 + case 354: arg3 = stack.pop(); // 78
62.1956 + case 355: stack.push(0); // 3
62.1957 + case 356: arg13 = stack.pop() // 54 13
62.1958 + case 358: stack.push(arg13); // 21 13
62.1959 + case 360: stack.push(arg12); // 21 12
62.1960 + case 362: if (stack.pop() <= stack.pop()) { gt = 386; continue; } // 162 0 24
62.1961 + case 365: stack.push(arg3); // 45
62.1962 + case 366: stack.push(arg11); // 21 11
62.1963 + case 368: stack.push(arg4); // 21 4
62.1964 + case 370: stack.push(stack.pop() + stack.pop()); // 96
62.1965 + case 371: stack.push(arg13); // 21 13
62.1966 + case 373: stack.push(stack.pop() + stack.pop()); // 96
62.1967 + case 374: stack.push(arg7); // 25 7
62.1968 + case 376: stack.push(arg13); // 21 13
62.1969 + case 378: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.1970 + case 379: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
62.1971 + case 380: arg13++; // 132 13 1
62.1972 + case 383: gt = 358; continue; // 167 255 231
62.1973 + case 386: stack.push(arg4); // 21 4
62.1974 + case 388: stack.push(arg12); // 21 12
62.1975 + case 390: stack.push(arg10); // 21 10
62.1976 + case 392: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.1977 + case 393: stack.push(stack.pop() + stack.pop()); // 96
62.1978 + case 394: arg4 = stack.pop() // 54 4
62.1979 + case 396: gt = 409; continue; // 167 0 13
62.1980 + case 399: stack.push(arg3); // 45
62.1981 + case 400: stack.push(arg11); // 21 11
62.1982 + case 402: stack.push(arg4); // 21 4
62.1983 + case 404: stack.push(stack.pop() + stack.pop()); // 96
62.1984 + case 405: stack.push(arg8); // 21 8
62.1985 + case 407: // number conversion // 146
62.1986 + case 408: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
62.1987 + case 409: stack.push(arg11); // 21 11
62.1988 + case 411: stack.push(arg10); // 21 10
62.1989 + case 413: stack.push(stack.pop() + stack.pop()); // 96
62.1990 + case 414: arg11 = stack.pop() // 54 11
62.1991 + case 416: gt = 157; continue; // 167 254 253
62.1992 + case 419: stack.push(new java_lang_String); // 187 0 200
62.1993 + case 422: stack.push(stack[stack.length - 1]); // 89
62.1994 + case 423: stack.push(0); // 3
62.1995 + case 424: stack.push(arg0); // 42
62.1996 + case 425: stack.push(stack.pop().count); // 180 1 97
62.1997 + case 428: stack.push(arg4); // 21 4
62.1998 + case 430: stack.push(stack.pop() + stack.pop()); // 96
62.1999 + case 431: stack.push(arg3); // 45
62.2000 + 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
62.2001 + case 435: return stack.pop(); // 176
62.2002 + }
62.2003 +}
62.2004 +function java_lang_String_toLowerCaseLjava_lang_String(arg0) {
62.2005 + var arg1;
62.2006 +;
62.2007 + var stack = new Array(2);
62.2008 + var gt = 0;
62.2009 + for(;;) switch(gt) {
62.2010 + case 0: stack.push(arg0); // 42
62.2011 + case 1: { stack.push(java_util_Locale_getDefaultLjava_util_Locale()); } // 184 1 179
62.2012 + case 4: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.toLowerCaseLjava_lang_StringLjava_util_Locale(self, v0)); } // 182 1 158
62.2013 + case 7: return stack.pop(); // 176
62.2014 + }
62.2015 +}
62.2016 +function java_lang_String_toUpperCaseLjava_lang_StringLjava_util_Locale(arg0,arg1) {
62.2017 + var arg2;
62.2018 + var arg3;
62.2019 + var arg4;
62.2020 + var arg5;
62.2021 + var arg6;
62.2022 + var arg7;
62.2023 + var arg8;
62.2024 + var arg9;
62.2025 + var arg10;
62.2026 + var arg11;
62.2027 + var arg12;
62.2028 + var arg13;
62.2029 + var arg14;
62.2030 +;
62.2031 + var stack = new Array(6);
62.2032 + var gt = 0;
62.2033 + for(;;) switch(gt) {
62.2034 + case 0: stack.push(arg1); // 43
62.2035 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11
62.2036 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198
62.2037 + case 7: stack.push(stack[stack.length - 1]); // 89
62.2038 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128
62.2039 + case 11: // 191
62.2040 + case 12: stack.push(0); // 3
62.2041 + case 13: arg2 = stack.pop(); // 61
62.2042 + case 14: stack.push(arg2); // 28
62.2043 + case 15: stack.push(arg0); // 42
62.2044 + case 16: stack.push(stack.pop().count); // 180 1 97
62.2045 + case 19: if (stack.pop() <= stack.pop()) { gt = 93; continue; } // 162 0 74
62.2046 + case 22: stack.push(arg0); // 42
62.2047 + case 23: stack.push(stack.pop().value); // 180 1 100
62.2048 + case 26: stack.push(arg0); // 42
62.2049 + case 27: stack.push(stack.pop().offset); // 180 1 99
62.2050 + case 30: stack.push(arg2); // 28
62.2051 + case 31: stack.push(stack.pop() + stack.pop()); // 96
62.2052 + case 32: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.2053 + case 33: arg3 = stack.pop(); // 62
62.2054 + case 34: stack.push(arg3); // 29
62.2055 + case 35: stack.push(55296); // 18 1
62.2056 + case 37: if (stack.pop() > stack.pop()) { gt = 61; continue; } // 161 0 24
62.2057 + case 40: stack.push(arg3); // 29
62.2058 + case 41: stack.push(56319); // 18 2
62.2059 + case 43: if (stack.pop() < stack.pop()) { gt = 61; continue; } // 163 0 18
62.2060 + case 46: stack.push(arg0); // 42
62.2061 + case 47: stack.push(arg2); // 28
62.2062 + case 48: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134
62.2063 + case 51: arg3 = stack.pop(); // 62
62.2064 + case 52: stack.push(arg3); // 29
62.2065 + case 53: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106
62.2066 + case 56: arg4 = stack.pop() // 54 4
62.2067 + case 58: gt = 64; continue; // 167 0 6
62.2068 + case 61: stack.push(1); // 4
62.2069 + case 62: arg4 = stack.pop() // 54 4
62.2070 + case 64: stack.push(arg3); // 29
62.2071 + case 65: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseExII(v0)); } // 184 1 108
62.2072 + case 68: arg5 = stack.pop() // 54 5
62.2073 + case 70: stack.push(arg5); // 21 5
62.2074 + case 72: // 2
62.2075 + case 73: if (stack.pop() == stack.pop()) { gt = 95; continue; } // 159 0 22
62.2076 + case 76: stack.push(arg3); // 29
62.2077 + case 77: stack.push(arg5); // 21 5
62.2078 + case 79: if (stack.pop() == stack.pop()) { gt = 85; continue; } // 159 0 6
62.2079 + case 82: gt = 95; continue; // 167 0 13
62.2080 + case 85: stack.push(arg2); // 28
62.2081 + case 86: stack.push(arg4); // 21 4
62.2082 + case 88: stack.push(stack.pop() + stack.pop()); // 96
62.2083 + case 89: arg2 = stack.pop(); // 61
62.2084 + case 90: gt = 14; continue; // 167 255 180
62.2085 + case 93: stack.push(arg0); // 42
62.2086 + case 94: return stack.pop(); // 176
62.2087 + case 95: stack.push(arg0); // 42
62.2088 + case 96: stack.push(stack.pop().count); // 180 1 97
62.2089 + case 99: stack.push(new Array(stack.pop())); // 188 5
62.2090 + case 101: arg3 = stack.pop(); // 78
62.2091 + case 102: stack.push(0); // 3
62.2092 + case 103: arg4 = stack.pop() // 54 4
62.2093 + case 105: stack.push(arg0); // 42
62.2094 + case 106: stack.push(stack.pop().value); // 180 1 100
62.2095 + case 109: stack.push(arg0); // 42
62.2096 + case 110: stack.push(stack.pop().offset); // 180 1 99
62.2097 + case 113: stack.push(arg3); // 45
62.2098 + case 114: stack.push(0); // 3
62.2099 + case 115: stack.push(arg2); // 28
62.2100 + 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
62.2101 + case 119: stack.push(arg1); // 43
62.2102 + case 120: { var self = stack.pop(); stack.push(self.getLanguageLjava_lang_String(self)); } // 182 1 178
62.2103 + case 123: arg5 = stack.pop() // 58 5
62.2104 + case 125: stack.push(arg5); // 25 5
62.2105 + case 127: stack.push("tr"); // 18 11
62.2106 + case 129: // 165
62.2107 + case 130: // 0
62.2108 + case 131: stack.push(6405); // 17 25 5
62.2109 + case 134: stack.push("az"); // 18 5
62.2110 + case 136: // 165
62.2111 + case 137: // 0
62.2112 + case 138: stack.push(1); // 10
62.2113 + case 139: stack.push(arg5); // 25 5
62.2114 + case 141: stack.push("lt"); // 18 9
62.2115 + case 143: // 166
62.2116 + case 144: // 0
62.2117 + case 145: stack.push(4); // 7
62.2118 + case 146: stack.push(1); // 4
62.2119 + case 147: gt = 151; continue; // 167 0 4
62.2120 + case 150: stack.push(0); // 3
62.2121 + case 151: arg6 = stack.pop() // 54 6
62.2122 + case 153: stack.push(arg2); // 28
62.2123 + case 154: arg11 = stack.pop() // 54 11
62.2124 + case 156: stack.push(arg11); // 21 11
62.2125 + case 158: stack.push(arg0); // 42
62.2126 + case 159: stack.push(stack.pop().count); // 180 1 97
62.2127 + case 162: if (stack.pop() <= stack.pop()) { gt = 425; continue; } // 162 1 7
62.2128 + case 165: stack.push(arg0); // 42
62.2129 + case 166: stack.push(stack.pop().value); // 180 1 100
62.2130 + case 169: stack.push(arg0); // 42
62.2131 + case 170: stack.push(stack.pop().offset); // 180 1 99
62.2132 + case 173: stack.push(arg11); // 21 11
62.2133 + case 175: stack.push(stack.pop() + stack.pop()); // 96
62.2134 + case 176: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.2135 + case 177: arg9 = stack.pop() // 54 9
62.2136 + case 179: stack.push(arg9); // 21 9
62.2137 + case 181: // number conversion // 146
62.2138 + case 182: stack.push(55296); // 18 1
62.2139 + case 184: if (stack.pop() > stack.pop()) { gt = 213; continue; } // 161 0 29
62.2140 + case 187: stack.push(arg9); // 21 9
62.2141 + case 189: // number conversion // 146
62.2142 + case 190: stack.push(56319); // 18 2
62.2143 + case 192: if (stack.pop() < stack.pop()) { gt = 213; continue; } // 163 0 21
62.2144 + case 195: stack.push(arg0); // 42
62.2145 + case 196: stack.push(arg11); // 21 11
62.2146 + case 198: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134
62.2147 + case 201: arg9 = stack.pop() // 54 9
62.2148 + case 203: stack.push(arg9); // 21 9
62.2149 + case 205: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106
62.2150 + case 208: arg10 = stack.pop() // 54 10
62.2151 + case 210: gt = 216; continue; // 167 0 6
62.2152 + case 213: stack.push(1); // 4
62.2153 + case 214: arg10 = stack.pop() // 54 10
62.2154 + case 216: stack.push(arg6); // 21 6
62.2155 + case 218: if (stack.pop() == 0) { gt = 233; continue; } // 153 0 15
62.2156 + case 221: stack.push(arg0); // 42
62.2157 + case 222: stack.push(arg11); // 21 11
62.2158 + case 224: stack.push(arg1); // 43
62.2159 + 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
62.2160 + case 228: arg8 = stack.pop() // 54 8
62.2161 + case 230: gt = 240; continue; // 167 0 10
62.2162 + case 233: stack.push(arg9); // 21 9
62.2163 + case 235: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseExII(v0)); } // 184 1 108
62.2164 + case 238: arg8 = stack.pop() // 54 8
62.2165 + case 240: stack.push(arg8); // 21 8
62.2166 + case 242: // 2
62.2167 + case 243: if (stack.pop() == stack.pop()) { gt = 253; continue; } // 159 0 10
62.2168 + case 246: stack.push(arg8); // 21 8
62.2169 + case 248: stack.push(65536); // 18 3
62.2170 + case 250: if (stack.pop() > stack.pop()) { gt = 405; continue; } // 161 0 155
62.2171 + case 253: stack.push(arg8); // 21 8
62.2172 + case 255: // 2
62.2173 + case 256: if (stack.pop() != stack.pop()) { gt = 286; continue; } // 160 0 30
62.2174 + case 259: stack.push(arg6); // 21 6
62.2175 + case 261: if (stack.pop() == 0) { gt = 276; continue; } // 153 0 15
62.2176 + case 264: stack.push(arg0); // 42
62.2177 + case 265: stack.push(arg11); // 21 11
62.2178 + case 267: stack.push(arg1); // 43
62.2179 + 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
62.2180 + case 271: arg7 = stack.pop() // 58 7
62.2181 + case 273: gt = 321; continue; // 167 0 48
62.2182 + case 276: stack.push(arg9); // 21 9
62.2183 + case 278: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseCharArrayACI(v0)); } // 184 1 110
62.2184 + case 281: arg7 = stack.pop() // 58 7
62.2185 + case 283: gt = 321; continue; // 167 0 38
62.2186 + case 286: stack.push(arg10); // 21 10
62.2187 + case 288: stack.push(2); // 5
62.2188 + case 289: if (stack.pop() != stack.pop()) { gt = 314; continue; } // 160 0 25
62.2189 + case 292: stack.push(arg4); // 21 4
62.2190 + case 294: stack.push(arg8); // 21 8
62.2191 + case 296: stack.push(arg3); // 45
62.2192 + case 297: stack.push(arg11); // 21 11
62.2193 + case 299: stack.push(arg4); // 21 4
62.2194 + case 301: stack.push(stack.pop() + stack.pop()); // 96
62.2195 + 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
62.2196 + case 305: stack.push(arg10); // 21 10
62.2197 + case 307: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.2198 + case 308: stack.push(stack.pop() + stack.pop()); // 96
62.2199 + case 309: arg4 = stack.pop() // 54 4
62.2200 + case 311: gt = 415; continue; // 167 0 104
62.2201 + case 314: stack.push(arg8); // 21 8
62.2202 + case 316: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109
62.2203 + case 319: arg7 = stack.pop() // 58 7
62.2204 + case 321: stack.push(arg7); // 25 7
62.2205 + case 323: stack.push(stack.pop().length); // 190
62.2206 + case 324: arg12 = stack.pop() // 54 12
62.2207 + case 326: stack.push(arg12); // 21 12
62.2208 + case 328: stack.push(arg10); // 21 10
62.2209 + case 330: if (stack.pop() >= stack.pop()) { gt = 361; continue; } // 164 0 31
62.2210 + case 333: stack.push(arg3); // 45
62.2211 + case 334: stack.push(stack.pop().length); // 190
62.2212 + case 335: stack.push(arg12); // 21 12
62.2213 + case 337: stack.push(stack.pop() + stack.pop()); // 96
62.2214 + case 338: stack.push(arg10); // 21 10
62.2215 + case 340: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.2216 + case 341: stack.push(new Array(stack.pop())); // 188 5
62.2217 + case 343: arg13 = stack.pop() // 58 13
62.2218 + case 345: stack.push(arg3); // 45
62.2219 + case 346: stack.push(0); // 3
62.2220 + case 347: stack.push(arg13); // 25 13
62.2221 + case 349: stack.push(0); // 3
62.2222 + case 350: stack.push(arg11); // 21 11
62.2223 + case 352: stack.push(arg4); // 21 4
62.2224 + case 354: stack.push(stack.pop() + stack.pop()); // 96
62.2225 + 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
62.2226 + case 358: stack.push(arg13); // 25 13
62.2227 + case 360: arg3 = stack.pop(); // 78
62.2228 + case 361: stack.push(0); // 3
62.2229 + case 362: arg13 = stack.pop() // 54 13
62.2230 + case 364: stack.push(arg13); // 21 13
62.2231 + case 366: stack.push(arg12); // 21 12
62.2232 + case 368: if (stack.pop() <= stack.pop()) { gt = 392; continue; } // 162 0 24
62.2233 + case 371: stack.push(arg3); // 45
62.2234 + case 372: stack.push(arg11); // 21 11
62.2235 + case 374: stack.push(arg4); // 21 4
62.2236 + case 376: stack.push(stack.pop() + stack.pop()); // 96
62.2237 + case 377: stack.push(arg13); // 21 13
62.2238 + case 379: stack.push(stack.pop() + stack.pop()); // 96
62.2239 + case 380: stack.push(arg7); // 25 7
62.2240 + case 382: stack.push(arg13); // 21 13
62.2241 + case 384: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.2242 + case 385: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
62.2243 + case 386: arg13++; // 132 13 1
62.2244 + case 389: gt = 364; continue; // 167 255 231
62.2245 + case 392: stack.push(arg4); // 21 4
62.2246 + case 394: stack.push(arg12); // 21 12
62.2247 + case 396: stack.push(arg10); // 21 10
62.2248 + case 398: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.2249 + case 399: stack.push(stack.pop() + stack.pop()); // 96
62.2250 + case 400: arg4 = stack.pop() // 54 4
62.2251 + case 402: gt = 415; continue; // 167 0 13
62.2252 + case 405: stack.push(arg3); // 45
62.2253 + case 406: stack.push(arg11); // 21 11
62.2254 + case 408: stack.push(arg4); // 21 4
62.2255 + case 410: stack.push(stack.pop() + stack.pop()); // 96
62.2256 + case 411: stack.push(arg8); // 21 8
62.2257 + case 413: // number conversion // 146
62.2258 + case 414: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
62.2259 + case 415: stack.push(arg11); // 21 11
62.2260 + case 417: stack.push(arg10); // 21 10
62.2261 + case 419: stack.push(stack.pop() + stack.pop()); // 96
62.2262 + case 420: arg11 = stack.pop() // 54 11
62.2263 + case 422: gt = 156; continue; // 167 254 246
62.2264 + case 425: stack.push(new java_lang_String); // 187 0 200
62.2265 + case 428: stack.push(stack[stack.length - 1]); // 89
62.2266 + case 429: stack.push(0); // 3
62.2267 + case 430: stack.push(arg0); // 42
62.2268 + case 431: stack.push(stack.pop().count); // 180 1 97
62.2269 + case 434: stack.push(arg4); // 21 4
62.2270 + case 436: stack.push(stack.pop() + stack.pop()); // 96
62.2271 + case 437: stack.push(arg3); // 45
62.2272 + 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
62.2273 + case 441: return stack.pop(); // 176
62.2274 + }
62.2275 +}
62.2276 +function java_lang_String_toUpperCaseLjava_lang_String(arg0) {
62.2277 + var arg1;
62.2278 +;
62.2279 + var stack = new Array(2);
62.2280 + var gt = 0;
62.2281 + for(;;) switch(gt) {
62.2282 + case 0: stack.push(arg0); // 42
62.2283 + case 1: { stack.push(java_util_Locale_getDefaultLjava_util_Locale()); } // 184 1 179
62.2284 + case 4: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.toUpperCaseLjava_lang_StringLjava_util_Locale(self, v0)); } // 182 1 159
62.2285 + case 7: return stack.pop(); // 176
62.2286 + }
62.2287 +}
62.2288 +function java_lang_String_trimLjava_lang_String(arg0) {
62.2289 + var arg1;
62.2290 + var arg2;
62.2291 + var arg3;
62.2292 + var arg4;
62.2293 + var arg5;
62.2294 +;
62.2295 + var stack = new Array(3);
62.2296 + var gt = 0;
62.2297 + for(;;) switch(gt) {
62.2298 + case 0: stack.push(arg0); // 42
62.2299 + case 1: stack.push(stack.pop().count); // 180 1 97
62.2300 + case 4: arg1 = stack.pop(); // 60
62.2301 + case 5: stack.push(0); // 3
62.2302 + case 6: arg2 = stack.pop(); // 61
62.2303 + case 7: stack.push(arg0); // 42
62.2304 + case 8: stack.push(stack.pop().offset); // 180 1 99
62.2305 + case 11: arg3 = stack.pop(); // 62
62.2306 + case 12: stack.push(arg0); // 42
62.2307 + case 13: stack.push(stack.pop().value); // 180 1 100
62.2308 + case 16: arg4 = stack.pop() // 58 4
62.2309 + case 18: stack.push(arg2); // 28
62.2310 + case 19: stack.push(arg1); // 27
62.2311 + case 20: if (stack.pop() <= stack.pop()) { gt = 40; continue; } // 162 0 20
62.2312 + case 23: stack.push(arg4); // 25 4
62.2313 + case 25: stack.push(arg3); // 29
62.2314 + case 26: stack.push(arg2); // 28
62.2315 + case 27: stack.push(stack.pop() + stack.pop()); // 96
62.2316 + case 28: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.2317 + case 29: stack.push(32); // 16 32
62.2318 + case 31: if (stack.pop() < stack.pop()) { gt = 40; continue; } // 163 0 9
62.2319 + case 34: arg2++; // 132 2 1
62.2320 + case 37: gt = 18; continue; // 167 255 237
62.2321 + case 40: stack.push(arg2); // 28
62.2322 + case 41: stack.push(arg1); // 27
62.2323 + case 42: if (stack.pop() <= stack.pop()) { gt = 64; continue; } // 162 0 22
62.2324 + case 45: stack.push(arg4); // 25 4
62.2325 + case 47: stack.push(arg3); // 29
62.2326 + case 48: stack.push(arg1); // 27
62.2327 + case 49: stack.push(stack.pop() + stack.pop()); // 96
62.2328 + case 50: stack.push(1); // 4
62.2329 + case 51: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
62.2330 + case 52: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
62.2331 + case 53: stack.push(32); // 16 32
62.2332 + case 55: if (stack.pop() < stack.pop()) { gt = 64; continue; } // 163 0 9
62.2333 + case 58: arg1 += 255; // 132 1 255
62.2334 + case 61: gt = 40; continue; // 167 255 235
62.2335 + case 64: stack.push(arg2); // 28
62.2336 + case 65: if (stack.pop() > 0) { gt = 76; continue; } // 157 0 11
62.2337 + case 68: stack.push(arg1); // 27
62.2338 + case 69: stack.push(arg0); // 42
62.2339 + case 70: stack.push(stack.pop().count); // 180 1 97
62.2340 + case 73: if (stack.pop() <= stack.pop()) { gt = 85; continue; } // 162 0 12
62.2341 + case 76: stack.push(arg0); // 42
62.2342 + case 77: stack.push(arg2); // 28
62.2343 + case 78: stack.push(arg1); // 27
62.2344 + 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
62.2345 + case 82: gt = 86; continue; // 167 0 4
62.2346 + case 85: stack.push(arg0); // 42
62.2347 + case 86: return stack.pop(); // 176
62.2348 + }
62.2349 +}
62.2350 +*/
62.2351 +function java_lang_String_toStringLjava_lang_String(arg0) {
62.2352 + return arg0.toString();
62.2353 +}
62.2354 +/*
62.2355 +function java_lang_String_toCharArrayAC(arg0) {
62.2356 + var arg1;
62.2357 + var arg2;
62.2358 +;
62.2359 + var stack = new Array(5);
62.2360 + var gt = 0;
62.2361 + for(;;) switch(gt) {
62.2362 + case 0: stack.push(arg0); // 42
62.2363 + case 1: stack.push(stack.pop().count); // 180 1 97
62.2364 + case 4: stack.push(new Array(stack.pop())); // 188 5
62.2365 + case 6: arg1 = stack.pop(); // 76
62.2366 + case 7: stack.push(arg0); // 42
62.2367 + case 8: stack.push(0); // 3
62.2368 + case 9: stack.push(arg0); // 42
62.2369 + case 10: stack.push(stack.pop().count); // 180 1 97
62.2370 + case 13: stack.push(arg1); // 43
62.2371 + case 14: stack.push(0); // 3
62.2372 + 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
62.2373 + case 18: stack.push(arg1); // 43
62.2374 + case 19: return stack.pop(); // 176
62.2375 + }
62.2376 +}
62.2377 +function java_lang_String_formatLjava_lang_StringLjava_lang_StringLjava_lang_Object(arg0,arg1) {
62.2378 + var stack = new Array();
62.2379 + var gt = 0;
62.2380 + for(;;) switch(gt) {
62.2381 + case 0: stack.push(new java_util_Formatter); // 187 0 211
62.2382 + case 3: stack.push(stack[stack.length - 1]); // 89
62.2383 + case 4: { java_util_Formatter_consV(stack.pop()); } // 183 1 174
62.2384 + case 7: stack.push(arg0); // 42
62.2385 + case 8: stack.push(arg1); // 43
62.2386 + 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
62.2387 + case 12: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 175
62.2388 + case 15: return stack.pop(); // 176
62.2389 + }
62.2390 +}
62.2391 +function java_lang_String_formatLjava_lang_StringLjava_util_LocaleLjava_lang_StringLjava_lang_Object(arg0,arg1,arg2) {
62.2392 + var stack = new Array();
62.2393 + var gt = 0;
62.2394 + for(;;) switch(gt) {
62.2395 + case 0: stack.push(new java_util_Formatter); // 187 0 211
62.2396 + case 3: stack.push(stack[stack.length - 1]); // 89
62.2397 + case 4: stack.push(arg0); // 42
62.2398 + case 5: { var v0 = stack.pop(); java_util_Formatter_consVLjava_util_Locale(stack.pop(), v0); } // 183 1 176
62.2399 + case 8: stack.push(arg1); // 43
62.2400 + case 9: stack.push(arg2); // 44
62.2401 + 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
62.2402 + case 13: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 175
62.2403 + case 16: return stack.pop(); // 176
62.2404 + }
62.2405 +}
62.2406 +function java_lang_String_valueOfLjava_lang_StringLjava_lang_Object(arg0) {
62.2407 + var stack = new Array();
62.2408 + var gt = 0;
62.2409 + for(;;) switch(gt) {
62.2410 + case 0: stack.push(arg0); // 42
62.2411 + case 1: if (stack.pop()) { gt = 9; continue; } // 199 0 8
62.2412 + case 4: stack.push("null"); // 18 10
62.2413 + case 6: gt = 13; continue; // 167 0 7
62.2414 + case 9: stack.push(arg0); // 42
62.2415 + case 10: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132
62.2416 + case 13: return stack.pop(); // 176
62.2417 + }
62.2418 +}
62.2419 +function java_lang_String_valueOfLjava_lang_StringAC(arg0) {
62.2420 + var stack = new Array();
62.2421 + var gt = 0;
62.2422 + for(;;) switch(gt) {
62.2423 + case 0: stack.push(new java_lang_String); // 187 0 200
62.2424 + case 3: stack.push(stack[stack.length - 1]); // 89
62.2425 + case 4: stack.push(arg0); // 42
62.2426 + case 5: { var v0 = stack.pop(); java_lang_String_consVAC(stack.pop(), v0); } // 183 1 142
62.2427 + case 8: return stack.pop(); // 176
62.2428 + }
62.2429 +}
62.2430 +function java_lang_String_valueOfLjava_lang_StringACII(arg0,arg1,arg2) {
62.2431 + var stack = new Array();
62.2432 + var gt = 0;
62.2433 + for(;;) switch(gt) {
62.2434 + case 0: stack.push(new java_lang_String); // 187 0 200
62.2435 + case 3: stack.push(stack[stack.length - 1]); // 89
62.2436 + case 4: stack.push(arg0); // 42
62.2437 + case 5: stack.push(arg1); // 27
62.2438 + case 6: stack.push(arg2); // 28
62.2439 + 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
62.2440 + case 10: return stack.pop(); // 176
62.2441 + }
62.2442 +}
62.2443 +function java_lang_String_copyValueOfLjava_lang_StringACII(arg0,arg1,arg2) {
62.2444 + var stack = new Array();
62.2445 + var gt = 0;
62.2446 + for(;;) switch(gt) {
62.2447 + case 0: stack.push(new java_lang_String); // 187 0 200
62.2448 + case 3: stack.push(stack[stack.length - 1]); // 89
62.2449 + case 4: stack.push(arg0); // 42
62.2450 + case 5: stack.push(arg1); // 27
62.2451 + case 6: stack.push(arg2); // 28
62.2452 + 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
62.2453 + case 10: return stack.pop(); // 176
62.2454 + }
62.2455 +}
62.2456 +function java_lang_String_copyValueOfLjava_lang_StringAC(arg0) {
62.2457 + var stack = new Array();
62.2458 + var gt = 0;
62.2459 + for(;;) switch(gt) {
62.2460 + case 0: stack.push(arg0); // 42
62.2461 + case 1: stack.push(0); // 3
62.2462 + case 2: stack.push(arg0); // 42
62.2463 + case 3: stack.push(stack.pop().length); // 190
62.2464 + 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
62.2465 + case 7: return stack.pop(); // 176
62.2466 + }
62.2467 +}
62.2468 +function java_lang_String_valueOfLjava_lang_StringZ(arg0) {
62.2469 + var stack = new Array();
62.2470 + var gt = 0;
62.2471 + for(;;) switch(gt) {
62.2472 + case 0: stack.push(arg0); // 26
62.2473 + case 1: if (stack.pop() == 0) { gt = 9; continue; } // 153 0 8
62.2474 + case 4: stack.push("true"); // 18 12
62.2475 + case 6: gt = 11; continue; // 167 0 5
62.2476 + case 9: stack.push("false"); // 18 8
62.2477 + case 11: return stack.pop(); // 176
62.2478 + }
62.2479 +}
62.2480 +function java_lang_String_valueOfLjava_lang_StringC(arg0) {
62.2481 + var arg1;
62.2482 + var stack = new Array();
62.2483 + var gt = 0;
62.2484 + for(;;) switch(gt) {
62.2485 + case 0: stack.push(1); // 4
62.2486 + case 1: stack.push(new Array(stack.pop())); // 188 5
62.2487 + case 3: stack.push(stack[stack.length - 1]); // 89
62.2488 + case 4: stack.push(0); // 3
62.2489 + case 5: stack.push(arg0); // 26
62.2490 + case 6: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
62.2491 + case 7: arg1 = stack.pop(); // 76
62.2492 + case 8: stack.push(new java_lang_String); // 187 0 200
62.2493 + case 11: stack.push(stack[stack.length - 1]); // 89
62.2494 + case 12: stack.push(0); // 3
62.2495 + case 13: stack.push(1); // 4
62.2496 + case 14: stack.push(arg1); // 43
62.2497 + 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
62.2498 + case 18: return stack.pop(); // 176
62.2499 + }
62.2500 +}
62.2501 +function java_lang_String_valueOfLjava_lang_StringI(arg0) {
62.2502 + var stack = new Array();
62.2503 + var gt = 0;
62.2504 + for(;;) switch(gt) {
62.2505 + case 0: stack.push(arg0); // 26
62.2506 + case 1: stack.push(10); // 16 10
62.2507 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Integer_toStringLjava_lang_StringII(v0, v1)); } // 184 1 125
62.2508 + case 6: return stack.pop(); // 176
62.2509 + }
62.2510 +}
62.2511 +function java_lang_String_valueOfLjava_lang_StringJ(arg0) {
62.2512 + var arg1;
62.2513 + var stack = new Array();
62.2514 + var gt = 0;
62.2515 + for(;;) switch(gt) {
62.2516 + case 0: stack.push(arg0); // 30
62.2517 + case 1: stack.push(10); // 16 10
62.2518 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Long_toStringLjava_lang_StringJI(v0, v1)); } // 184 1 126
62.2519 + case 6: return stack.pop(); // 176
62.2520 + }
62.2521 +}
62.2522 +function java_lang_String_valueOfLjava_lang_StringF(arg0) {
62.2523 + var stack = new Array();
62.2524 + var gt = 0;
62.2525 + for(;;) switch(gt) {
62.2526 + case 0: stack.push(arg0); // 34
62.2527 + case 1: { var v0 = stack.pop(); stack.push(java_lang_Float_toStringLjava_lang_StringF(v0)); } // 184 1 122
62.2528 + case 4: return stack.pop(); // 176
62.2529 + }
62.2530 +}
62.2531 +function java_lang_String_valueOfLjava_lang_StringD(arg0) {
62.2532 + var arg1;
62.2533 + var stack = new Array();
62.2534 + var gt = 0;
62.2535 + for(;;) switch(gt) {
62.2536 + case 0: stack.push(arg0); // 38
62.2537 + case 1: { var v0 = stack.pop(); stack.push(java_lang_Double_toStringLjava_lang_StringD(v0)); } // 184 1 121
62.2538 + case 4: return stack.pop(); // 176
62.2539 + }
62.2540 +}
62.2541 +function java_lang_String_internLjava_lang_String(arg0) {
62.2542 + // no code found for null
62.2543 +}
62.2544 +function java_lang_String_compareToILjava_lang_Object(arg0,arg1) {
62.2545 + var arg2;
62.2546 +;
62.2547 + var stack = new Array(2);
62.2548 + var gt = 0;
62.2549 + for(;;) switch(gt) {
62.2550 + case 0: stack.push(arg0); // 42
62.2551 + case 1: stack.push(arg1); // 43
62.2552 + case 2: if(stack[stack.length - 1].$instOf_java_lang_String != 1) throw {}; // 192 0 200
62.2553 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.compareToILjava_lang_String(self, v0)); } // 182 1 148
62.2554 + case 8: return stack.pop(); // 172
62.2555 + }
62.2556 +}
62.2557 +function java_lang_String_classV() {
62.2558 + var stack = new Array();
62.2559 + var gt = 0;
62.2560 + for(;;) switch(gt) {
62.2561 + case 0: stack.push(0); // 3
62.2562 + case 1: stack.push(new Array(stack.pop())); // 189 0 183
62.2563 + case 4: java_lang_String_serialPersistentFields = stack.pop(); // 179 1 101
62.2564 + case 7: stack.push(new java_lang_String$CaseInsensitiveComparator); // 187 0 202
62.2565 + case 10: stack.push(stack[stack.length - 1]); // 89
62.2566 + case 11: // 1
62.2567 + case 12: { var v0 = stack.pop(); java_lang_String$CaseInsensitiveComparator_consVLjava_lang_String$1(stack.pop(), v0); } // 183 1 160
62.2568 + case 15: java_lang_String_CASE_INSENSITIVE_ORDER = stack.pop(); // 179 1 102
62.2569 + case 18: return; // 177
62.2570 + }
62.2571 +}
62.2572 +*/
62.2573 +var java_lang_String_serialVersionUID = 0;
62.2574 +var java_lang_String_serialPersistentFields = 0;
62.2575 +var java_lang_String_CASE_INSENSITIVE_ORDER = 0;
62.2576 +function java_lang_String() {
62.2577 + /** the real value of this 'string' we delegate to */
62.2578 + this.r = '';
62.2579 +
62.2580 + var self = this;
62.2581 + /*
62.2582 + this.value = 0;
62.2583 + this.offset = 0;
62.2584 + this.count = 0;
62.2585 + this.hash = 0;
62.2586 + */
62.2587 + this.toString = function() { return self.r; };
62.2588 +}
62.2589 +java_lang_String.prototype = new String;
62.2590 +//java_lang_String_classV();
62.2591 +
62.2592 +/* new method for JavaScript String */
62.2593 +String.prototype.charAtCI = java_lang_String_charAtCI;
62.2594 +String.prototype.lengthI = java_lang_String_lengthI;
62.2595 +String.prototype.isEmptyZ = java_lang_String_isEmptyZ;
62.2596 +String.prototype.getCharsVIIACI = java_lang_String_getCharsVIIACAI;
62.2597 +String.prototype.toStringLjava_lang_String = java_lang_String_toStringLjava_lang_String;
62.2598 +String.prototype.$instOf_java_lang_String = true;
62.2599 +String.prototype.$instOf_java_io_Serializable = true;
62.2600 +String.prototype.$instOf_java_lang_Comparable = true;
62.2601 +String.prototype.$instOf_java_lang_CharSequence = true;
62.2602 +
62.2603 +/*
62.2604 + this.lengthI = java_lang_String_lengthI;
62.2605 + this.isEmptyZ = java_lang_String_isEmptyZ;
62.2606 + this.charAtCI = java_lang_String_charAtCI;
62.2607 + this.codePointAtII = java_lang_String_codePointAtII;
62.2608 + this.codePointBeforeII = java_lang_String_codePointBeforeII;
62.2609 + this.codePointCountIII = java_lang_String_codePointCountIII;
62.2610 + this.offsetByCodePointsIII = java_lang_String_offsetByCodePointsIII;
62.2611 + this.getCharsVACI = java_lang_String_getCharsVACI;
62.2612 + this.getCharsVIIACI = java_lang_String_getCharsVIIACI;
62.2613 + this.getBytesVIIABI = java_lang_String_getBytesVIIABI;
62.2614 + this.getBytesABLjava_lang_String = java_lang_String_getBytesABLjava_lang_String;
62.2615 + this.getBytesABLjava_nio_charset_Charset = java_lang_String_getBytesABLjava_nio_charset_Charset;
62.2616 + this.getBytesAB = java_lang_String_getBytesAB;
62.2617 + this.equalsZLjava_lang_Object = java_lang_String_equalsZLjava_lang_Object;
62.2618 + this.contentEqualsZLjava_lang_StringBuffer = java_lang_String_contentEqualsZLjava_lang_StringBuffer;
62.2619 + this.contentEqualsZLjava_lang_CharSequence = java_lang_String_contentEqualsZLjava_lang_CharSequence;
62.2620 + this.equalsIgnoreCaseZLjava_lang_String = java_lang_String_equalsIgnoreCaseZLjava_lang_String;
62.2621 + this.compareToILjava_lang_String = java_lang_String_compareToILjava_lang_String;
62.2622 + this.compareToIgnoreCaseILjava_lang_String = java_lang_String_compareToIgnoreCaseILjava_lang_String;
62.2623 + this.regionMatchesZILjava_lang_StringII = java_lang_String_regionMatchesZILjava_lang_StringII;
62.2624 + this.regionMatchesZZILjava_lang_StringII = java_lang_String_regionMatchesZZILjava_lang_StringII;
62.2625 + this.startsWithZLjava_lang_StringI = java_lang_String_startsWithZLjava_lang_StringI;
62.2626 + this.startsWithZLjava_lang_String = java_lang_String_startsWithZLjava_lang_String;
62.2627 + this.endsWithZLjava_lang_String = java_lang_String_endsWithZLjava_lang_String;
62.2628 + this.hashCodeI = java_lang_String_hashCodeI;
62.2629 + this.indexOfII = java_lang_String_indexOfII;
62.2630 + this.indexOfIII = java_lang_String_indexOfIII;
62.2631 + this.lastIndexOfII = java_lang_String_lastIndexOfII;
62.2632 + this.lastIndexOfIII = java_lang_String_lastIndexOfIII;
62.2633 + this.indexOfILjava_lang_String = java_lang_String_indexOfILjava_lang_String;
62.2634 + this.indexOfILjava_lang_StringI = java_lang_String_indexOfILjava_lang_StringI;
62.2635 + this.lastIndexOfILjava_lang_String = java_lang_String_lastIndexOfILjava_lang_String;
62.2636 + this.lastIndexOfILjava_lang_StringI = java_lang_String_lastIndexOfILjava_lang_StringI;
62.2637 + this.substringLjava_lang_StringI = java_lang_String_substringLjava_lang_StringI;
62.2638 + this.substringLjava_lang_StringII = java_lang_String_substringLjava_lang_StringII;
62.2639 + this.subSequenceLjava_lang_CharSequenceII = java_lang_String_subSequenceLjava_lang_CharSequenceII;
62.2640 + this.concatLjava_lang_StringLjava_lang_String = java_lang_String_concatLjava_lang_StringLjava_lang_String;
62.2641 + this.replaceLjava_lang_StringCC = java_lang_String_replaceLjava_lang_StringCC;
62.2642 + this.matchesZLjava_lang_String = java_lang_String_matchesZLjava_lang_String;
62.2643 + this.containsZLjava_lang_CharSequence = java_lang_String_containsZLjava_lang_CharSequence;
62.2644 + this.replaceFirstLjava_lang_StringLjava_lang_StringLjava_lang_String = java_lang_String_replaceFirstLjava_lang_StringLjava_lang_StringLjava_lang_String;
62.2645 + this.replaceAllLjava_lang_StringLjava_lang_StringLjava_lang_String = java_lang_String_replaceAllLjava_lang_StringLjava_lang_StringLjava_lang_String;
62.2646 + this.replaceLjava_lang_StringLjava_lang_CharSequenceLjava_lang_CharSequence = java_lang_String_replaceLjava_lang_StringLjava_lang_CharSequenceLjava_lang_CharSequence;
62.2647 + this.splitALjava_lang_StringLjava_lang_StringI = java_lang_String_splitALjava_lang_StringLjava_lang_StringI;
62.2648 + this.splitALjava_lang_StringLjava_lang_String = java_lang_String_splitALjava_lang_StringLjava_lang_String;
62.2649 + this.toLowerCaseLjava_lang_StringLjava_util_Locale = java_lang_String_toLowerCaseLjava_lang_StringLjava_util_Locale;
62.2650 + this.toLowerCaseLjava_lang_String = java_lang_String_toLowerCaseLjava_lang_String;
62.2651 + this.toUpperCaseLjava_lang_StringLjava_util_Locale = java_lang_String_toUpperCaseLjava_lang_StringLjava_util_Locale;
62.2652 + this.toUpperCaseLjava_lang_String = java_lang_String_toUpperCaseLjava_lang_String;
62.2653 + this.trimLjava_lang_String = java_lang_String_trimLjava_lang_String;
62.2654 + this.toStringLjava_lang_String = java_lang_String_toStringLjava_lang_String;
62.2655 + this.toCharArrayAC = java_lang_String_toCharArrayAC;
62.2656 + this.internLjava_lang_String = java_lang_String_internLjava_lang_String;
62.2657 + this.compareToILjava_lang_Object = java_lang_String_compareToILjava_lang_Object;
62.2658 + */
62.2659 +
62.2660 +
62.2661 +
63.1 --- a/htmlpage/pom.xml Fri Sep 28 14:58:21 2012 +0200
63.2 +++ b/htmlpage/pom.xml Thu Oct 11 06:16:00 2012 -0700
63.3 @@ -31,6 +31,25 @@
63.4 <groupId>org.netbeans.api</groupId>
63.5 <artifactId>org-openide-util-lookup</artifactId>
63.6 </dependency>
63.7 + <dependency>
63.8 + <groupId>org.apidesign.bck2brwsr</groupId>
63.9 + <artifactId>core</artifactId>
63.10 + <version>1.0-SNAPSHOT</version>
63.11 + <type>jar</type>
63.12 + </dependency>
63.13 + <dependency>
63.14 + <groupId>org.apidesign.bck2brwsr</groupId>
63.15 + <artifactId>emul</artifactId>
63.16 + <version>1.0-SNAPSHOT</version>
63.17 + <type>jar</type>
63.18 + </dependency>
63.19 + <dependency>
63.20 + <groupId>org.apidesign.bck2brwsr</groupId>
63.21 + <artifactId>vm4brwsr</artifactId>
63.22 + <version>0.1-SNAPSHOT</version>
63.23 + <type>jar</type>
63.24 + <scope>test</scope>
63.25 + </dependency>
63.26 </dependencies>
63.27 <build>
63.28 <plugins>
64.1 --- a/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Fri Sep 28 14:58:21 2012 +0200
64.2 +++ b/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Thu Oct 11 06:16:00 2012 -0700
64.3 @@ -55,7 +55,7 @@
64.4 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
64.5 for (Element e : roundEnv.getElementsAnnotatedWith(Page.class)) {
64.6 Page p = e.getAnnotation(Page.class);
64.7 - PackageElement pe = (PackageElement)e;
64.8 + PackageElement pe = (PackageElement)e.getEnclosingElement();
64.9 String pkg = pe.getQualifiedName().toString();
64.10
64.11 ProcessPage pp;
65.1 --- a/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.java Fri Sep 28 14:58:21 2012 +0200
65.2 +++ b/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.java Thu Oct 11 06:16:00 2012 -0700
65.3 @@ -17,6 +17,8 @@
65.4 */
65.5 package org.apidesign.bck2brwsr.htmlpage.api;
65.6
65.7 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
65.8 +
65.9 /** Represents a generic HTML element.
65.10 *
65.11 * @author Jaroslav Tulach <jtulach@netbeans.org>
65.12 @@ -30,14 +32,33 @@
65.13
65.14 abstract void dontSubclass();
65.15
65.16 + @JavaScriptBody(
65.17 + args={"el", "property", "value"},
65.18 + body="var e = window.document.getElementById(el.id);\n"
65.19 + + "e[property] = value;\n"
65.20 + )
65.21 static void setAttribute(Element el, String property, Object value) {
65.22 throw new UnsupportedOperationException("Needs JavaScript!");
65.23 }
65.24 +
65.25 + @JavaScriptBody(
65.26 + args={"el", "property"},
65.27 + body="var e = window.document.getElementById(el.id);\n"
65.28 + + "return e[property];\n"
65.29 + )
65.30 + static Object getAttribute(Element el, String property) {
65.31 + throw new UnsupportedOperationException("Needs JavaScript!");
65.32 + }
65.33
65.34 /** Executes given runnable when user performs a "click" on the given
65.35 * element.
65.36 * @param r the runnable to execute, never null
65.37 */
65.38 + @JavaScriptBody(
65.39 + args={"el", "r"},
65.40 + body="var e = window.document.getElementById(el.id);\n"
65.41 + + "e.onclick = function() { r.runV(); };\n"
65.42 + )
65.43 public final void addOnClick(Runnable r) {
65.44 throw new UnsupportedOperationException("Needs JavaScript!");
65.45 }
66.1 --- a/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.js Fri Sep 28 14:58:21 2012 +0200
66.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
66.3 @@ -1,10 +0,0 @@
66.4 -
66.5 -
66.6 -function org_apidesign_bck2brwsr_htmlpage_api_Element_setAttribute_Lorg_apidesign_bck2brwsr_htmlpage_api_ElementLjava_lang_StringLjava_lang_Object(self, property, value) {
66.7 - document.getElementById(self.id)[property] = value;
66.8 -}
66.9 -
66.10 -function org_apidesign_bck2brwsr_htmlpage_api_Element_addOnClick_Ljava_lang_Runnable(self, run) {
66.11 - document.getElementById(self.id).onClick = function() { run.runV(); };
66.12 -}
66.13 -
67.1 --- a/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Input.java Fri Sep 28 14:58:21 2012 +0200
67.2 +++ b/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Input.java Thu Oct 11 06:16:00 2012 -0700
67.3 @@ -31,6 +31,10 @@
67.4 }
67.5
67.6 public void setAutocomplete(boolean state) {
67.7 - setAttribute(this, "autocomplete", state);
67.8 + Element.setAttribute(this, "autocomplete", state);
67.9 + }
67.10 +
67.11 + public final String getValue() {
67.12 + return (String)Element.getAttribute(this, "value");
67.13 }
67.14 }
68.1 --- a/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Page.java Fri Sep 28 14:58:21 2012 +0200
68.2 +++ b/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Page.java Thu Oct 11 06:16:00 2012 -0700
68.3 @@ -32,7 +32,7 @@
68.4 * @author Jaroslav Tulach <jtulach@netbeans.org>
68.5 */
68.6 @Retention(RetentionPolicy.SOURCE)
68.7 -@Target(ElementType.PACKAGE)
68.8 +@Target(ElementType.TYPE)
68.9 public @interface Page {
68.10 /** Path to the XHTML page to read in */
68.11 String xhtml();
69.1 --- a/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Title.java Fri Sep 28 14:58:21 2012 +0200
69.2 +++ b/htmlpage/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Title.java Thu Oct 11 06:16:00 2012 -0700
69.3 @@ -29,4 +29,8 @@
69.4 @Override
69.5 void dontSubclass() {
69.6 }
69.7 +
69.8 + public final void setText(String text) {
69.9 + Element.setAttribute(this, "innerHTML", text);
69.10 + }
69.11 }
70.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
70.2 +++ b/htmlpage/src/test/java/org/apidesign/bck2brwsr/htmlpage/PageController.java Thu Oct 11 06:16:00 2012 -0700
70.3 @@ -0,0 +1,32 @@
70.4 +package org.apidesign.bck2brwsr.htmlpage;
70.5 +
70.6 +import org.apidesign.bck2brwsr.htmlpage.api.OnClick;
70.7 +import org.apidesign.bck2brwsr.htmlpage.api.Page;
70.8 +
70.9 +/** Trivial demo for the bck2brwsr project. First of all start
70.10 + * with <a href="TestPage.html">your XHTML page</a>. Include there
70.11 + * a script that will <em>boot Java</em> in your browser.
70.12 + * <p>
70.13 + * Then use <code>@Page</code> annotation to
70.14 + * generate a Java representation of elements with IDs in that page.
70.15 + * Depending on the type of the elements, they will have different
70.16 + * methods (e.g. <code>PG_TITLE</code> has <code>setText</code>, etc.).
70.17 + * Use <code>@OnClick</code> annotation to associate behavior
70.18 + * with existing elements. Use the generated elements
70.19 + * (<code>PG_TITLE</code>, <code>PG_TEXT</code>) to modify the page.
70.20 + * <p>
70.21 + * Everything is type-safe. As soon as somebody modifies the page and
70.22 + * removes the IDs or re-assigns them to wrong elements. Java compiler
70.23 + * will emit an error.
70.24 + * <p>
70.25 + * Welcome to the type-safe HTML5 world!
70.26 + *
70.27 + * @author Jaroslav Tulach <jtulach@netbeans.org>
70.28 + */
70.29 +@Page(xhtml="TestPage.html", name="TestPage")
70.30 +public class PageController {
70.31 + @OnClick(id="pg.button")
70.32 + static void updateTitle() {
70.33 + TestPage.PG_TITLE.setText(TestPage.PG_TEXT.getValue());
70.34 + }
70.35 +}
71.1 --- a/htmlpage/src/test/java/org/apidesign/bck2brwsr/htmlpage/ProcessPageTest.java Fri Sep 28 14:58:21 2012 +0200
71.2 +++ b/htmlpage/src/test/java/org/apidesign/bck2brwsr/htmlpage/ProcessPageTest.java Thu Oct 11 06:16:00 2012 -0700
71.3 @@ -19,17 +19,20 @@
71.4
71.5 import java.io.IOException;
71.6 import java.io.InputStream;
71.7 +import java.lang.reflect.Method;
71.8 import java.util.Set;
71.9 +import javax.script.Invocable;
71.10 +import javax.script.ScriptEngine;
71.11 +import javax.script.ScriptEngineManager;
71.12 +import javax.script.ScriptException;
71.13 import org.testng.annotations.Test;
71.14 import static org.testng.Assert.*;
71.15
71.16 -import org.apidesign.bck2brwsr.htmlpage.api.*;
71.17 -
71.18 public class ProcessPageTest {
71.19
71.20
71.21 @Test public void findsThreeIds() throws IOException {
71.22 - InputStream is = ProcessPageTest.class.getResourceAsStream("TestPage.xhtml");
71.23 + InputStream is = ProcessPageTest.class.getResourceAsStream("TestPage.html");
71.24 assertNotNull(is, "Sample HTML page found");
71.25 ProcessPage res = ProcessPage.readPage(is);
71.26 final Set<String> ids = res.ids();
71.27 @@ -40,16 +43,67 @@
71.28 assertEquals(res.tagNameForId("pg.text"), "input");
71.29 }
71.30
71.31 - void testWhetherWeCanCallTheGeneratedIdFields() {
71.32 - Title t = TestPage.PG_TITLE;
71.33 + @Test public void testCompileAndRunPageController() throws Exception {
71.34 + StringBuilder sb = new StringBuilder();
71.35 + sb.append(
71.36 + "var window = new Object();\n"
71.37 + + "var doc = new Object();\n"
71.38 + + "doc.button = new Object();\n"
71.39 + + "doc.title = new Object();\n"
71.40 + + "doc.title.innerHTML = 'nothing';\n"
71.41 + + "doc.text = new Object();\n"
71.42 + + "doc.text.value = 'something';\n"
71.43 + + "doc.getElementById = function(id) {\n"
71.44 + + " switch(id) {\n"
71.45 + + " case 'pg.button': return doc.button;\n"
71.46 + + " case 'pg.title': return doc.title;\n"
71.47 + + " case 'pg.text': return doc.text;\n"
71.48 + + " }\n"
71.49 + + " throw id;\n"
71.50 + + " }\n"
71.51 + + "\n"
71.52 + + "function clickAndCheck() {\n"
71.53 + + " doc.button.onclick();\n"
71.54 + + " return doc.title.innerHTML.toString();\n"
71.55 + + "};\n"
71.56 + + "\n"
71.57 + + "window.document = doc;\n"
71.58 + );
71.59 + Invocable i = compileClass(sb, "org/apidesign/bck2brwsr/htmlpage/PageController");
71.60 +
71.61 + Object ret = null;
71.62 + try {
71.63 + ret = i.invokeFunction("clickAndCheck");
71.64 + } catch (ScriptException ex) {
71.65 + fail("Execution failed in " + sb, ex);
71.66 + } catch (NoSuchMethodException ex) {
71.67 + fail("Cannot find method in " + sb, ex);
71.68 + }
71.69 + assertEquals(ret, "something", "We expect that the JavaCode performs all the wiring");
71.70 }
71.71 -
71.72 - @OnClick(id="pg.button")
71.73 - static void handleButtonClick() {
71.74 -
71.75 - }
71.76 -
71.77 - @Test public void testOnclickHandlerGenerated() {
71.78 -
71.79 +
71.80 + static Invocable compileClass(StringBuilder sb, String... names) throws ScriptException, IOException {
71.81 + if (sb == null) {
71.82 + sb = new StringBuilder();
71.83 + }
71.84 + try {
71.85 + Method m;
71.86 + Class<?> genJS = Class.forName("org.apidesign.vm4brwsr.GenJS");
71.87 + m = genJS.getDeclaredMethod("compile", Appendable.class, String[].class);
71.88 + m.setAccessible(true);
71.89 + m.invoke(null, sb, names);
71.90 + } catch (Exception exception) {
71.91 + throw new IOException(exception);
71.92 + }
71.93 + ScriptEngineManager sem = new ScriptEngineManager();
71.94 + ScriptEngine js = sem.getEngineByExtension("js");
71.95 + try {
71.96 + Object res = js.eval(sb.toString());
71.97 + assertTrue(js instanceof Invocable, "It is invocable object: " + res);
71.98 + return (Invocable) js;
71.99 + } catch (ScriptException ex) {
71.100 + fail("Could not compile:\n" + sb, ex);
71.101 + return null;
71.102 + }
71.103 }
71.104 }
72.1 --- a/htmlpage/src/test/java/org/apidesign/bck2brwsr/htmlpage/package-info.java Fri Sep 28 14:58:21 2012 +0200
72.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
72.3 @@ -1,22 +0,0 @@
72.4 -/**
72.5 - * Java 4 Browser Bytecode Translator
72.6 - * Copyright (C) 2012-2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
72.7 - *
72.8 - * This program is free software: you can redistribute it and/or modify
72.9 - * it under the terms of the GNU General Public License as published by
72.10 - * the Free Software Foundation, version 2 of the License.
72.11 - *
72.12 - * This program is distributed in the hope that it will be useful,
72.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
72.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72.15 - * GNU General Public License for more details.
72.16 - *
72.17 - * You should have received a copy of the GNU General Public License
72.18 - * along with this program. Look for COPYING file in the top folder.
72.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
72.20 - */
72.21 -@Page(xhtml="TestPage.xhtml", name="TestPage")
72.22 -package org.apidesign.bck2brwsr.htmlpage;
72.23 -
72.24 -import org.apidesign.bck2brwsr.htmlpage.api.Page;
72.25 -
73.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
73.2 +++ b/htmlpage/src/test/resources/org/apidesign/bck2brwsr/htmlpage/TestPage.html Thu Oct 11 06:16:00 2012 -0700
73.3 @@ -0,0 +1,30 @@
73.4 +<?xml version="1.0" encoding="UTF-8"?>
73.5 +<!--
73.6 +
73.7 + Java 4 Browser Bytecode Translator
73.8 + Copyright (C) 2012-2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
73.9 +
73.10 + This program is free software: you can redistribute it and/or modify
73.11 + it under the terms of the GNU General Public License as published by
73.12 + the Free Software Foundation, version 2 of the License.
73.13 +
73.14 + This program is distributed in the hope that it will be useful,
73.15 + but WITHOUT ANY WARRANTY; without even the implied warranty of
73.16 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
73.17 + GNU General Public License for more details.
73.18 +
73.19 + You should have received a copy of the GNU General Public License
73.20 + along with this program. Look for COPYING file in the top folder.
73.21 + If not, see http://opensource.org/licenses/GPL-2.0.
73.22 +
73.23 +-->
73.24 +<!DOCTYPE html>
73.25 +<html xmlns="http://www.w3.org/1999/xhtml">
73.26 + <head>
73.27 + <title id="pg.title">Default Title</title>
73.28 + </head>
73.29 + <body>
73.30 + New title: <input id="pg.text"/>
73.31 + <button id="pg.button">Change title!</button>
73.32 + </body>
73.33 +</html>
74.1 --- a/htmlpage/src/test/resources/org/apidesign/bck2brwsr/htmlpage/TestPage.xhtml Fri Sep 28 14:58:21 2012 +0200
74.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
74.3 @@ -1,30 +0,0 @@
74.4 -<?xml version="1.0" encoding="UTF-8"?>
74.5 -<!--
74.6 -
74.7 - Java 4 Browser Bytecode Translator
74.8 - Copyright (C) 2012-2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
74.9 -
74.10 - This program is free software: you can redistribute it and/or modify
74.11 - it under the terms of the GNU General Public License as published by
74.12 - the Free Software Foundation, version 2 of the License.
74.13 -
74.14 - This program is distributed in the hope that it will be useful,
74.15 - but WITHOUT ANY WARRANTY; without even the implied warranty of
74.16 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74.17 - GNU General Public License for more details.
74.18 -
74.19 - You should have received a copy of the GNU General Public License
74.20 - along with this program. Look for COPYING file in the top folder.
74.21 - If not, see http://opensource.org/licenses/GPL-2.0.
74.22 -
74.23 --->
74.24 -<!DOCTYPE html>
74.25 -<html xmlns="http://www.w3.org/1999/xhtml">
74.26 - <head>
74.27 - <title id="pg.title">Default Title</title>
74.28 - </head>
74.29 - <body>
74.30 - New title: <input id="pg.text"/>
74.31 - <button id="pg.button">Change title!</button>
74.32 - </body>
74.33 -</html>
75.1 --- a/pom.xml Fri Sep 28 14:58:21 2012 +0200
75.2 +++ b/pom.xml Thu Oct 11 06:16:00 2012 -0700
75.3 @@ -9,6 +9,8 @@
75.4 <modules>
75.5 <module>vm</module>
75.6 <module>htmlpage</module>
75.7 + <module>emul</module>
75.8 + <module>core</module>
75.9 </modules>
75.10 <licenses>
75.11 <license>
76.1 --- a/vm/pom.xml Fri Sep 28 14:58:21 2012 +0200
76.2 +++ b/vm/pom.xml Thu Oct 11 06:16:00 2012 -0700
76.3 @@ -7,7 +7,7 @@
76.4 <version>1.0-SNAPSHOT</version>
76.5 </parent>
76.6
76.7 - <groupId>org.apidesign</groupId>
76.8 + <groupId>org.apidesign.bck2brwsr</groupId>
76.9 <artifactId>vm4brwsr</artifactId>
76.10 <version>0.1-SNAPSHOT</version>
76.11 <packaging>jar</packaging>
76.12 @@ -86,5 +86,17 @@
76.13 <artifactId>org-netbeans-modules-classfile</artifactId>
76.14 <type>jar</type>
76.15 </dependency>
76.16 + <dependency>
76.17 + <groupId>org.apidesign.bck2brwsr</groupId>
76.18 + <artifactId>core</artifactId>
76.19 + <version>1.0-SNAPSHOT</version>
76.20 + <type>jar</type>
76.21 + </dependency>
76.22 + <dependency>
76.23 + <groupId>org.apidesign.bck2brwsr</groupId>
76.24 + <artifactId>emul</artifactId>
76.25 + <version>1.0-SNAPSHOT</version>
76.26 + <scope>test</scope>
76.27 + </dependency>
76.28 </dependencies>
76.29 </project>
77.1 --- a/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Fri Sep 28 14:58:21 2012 +0200
77.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Thu Oct 11 06:16:00 2012 -0700
77.3 @@ -22,6 +22,11 @@
77.4 import java.util.ArrayList;
77.5 import java.util.Collection;
77.6 import java.util.List;
77.7 +import org.apidesign.bck2brwsr.core.ExtraJavaScript;
77.8 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
77.9 +import org.netbeans.modules.classfile.Annotation;
77.10 +import org.netbeans.modules.classfile.AnnotationComponent;
77.11 +import org.netbeans.modules.classfile.ArrayElementValue;
77.12 import static org.netbeans.modules.classfile.ByteCodes.*;
77.13 import org.netbeans.modules.classfile.CPClassInfo;
77.14 import org.netbeans.modules.classfile.CPEntry;
77.15 @@ -31,8 +36,10 @@
77.16 import org.netbeans.modules.classfile.ClassFile;
77.17 import org.netbeans.modules.classfile.ClassName;
77.18 import org.netbeans.modules.classfile.Code;
77.19 +import org.netbeans.modules.classfile.ElementValue;
77.20 import org.netbeans.modules.classfile.Method;
77.21 import org.netbeans.modules.classfile.Parameter;
77.22 +import org.netbeans.modules.classfile.PrimitiveElementValue;
77.23 import org.netbeans.modules.classfile.Variable;
77.24
77.25 /** Translator of the code inside class files to JavaScript.
77.26 @@ -62,14 +69,30 @@
77.27 * generated JavaScript code works properly. The names are in internal
77.28 * JVM form so String is <code>java/lang/String</code>. Can be <code>null</code>
77.29 * if one is not interested in knowing references
77.30 + * @param scripts write only collection with names of resources to read
77.31 + * @return the initialization code for this class, if any. Otherwise <code>null</code>
77.32 + *
77.33 * @throws IOException if something goes wrong during read or write or translating
77.34 */
77.35
77.36 - public static void compile(
77.37 + public static String compile(
77.38 InputStream classFile, Appendable out,
77.39 - Collection<? super String> references
77.40 + Collection<? super String> references,
77.41 + Collection<? super String> scripts
77.42 ) throws IOException {
77.43 ClassFile jc = new ClassFile(classFile, true);
77.44 + final ClassName extraAnn = ClassName.getClassName(ExtraJavaScript.class.getName().replace('.', '/'));
77.45 + Annotation a = jc.getAnnotation(extraAnn);
77.46 + if (a != null) {
77.47 + final ElementValue annVal = a.getComponent("resource").getValue();
77.48 + String res = ((PrimitiveElementValue)annVal).getValue().getValue().toString();
77.49 + scripts.add(res);
77.50 + final AnnotationComponent process = a.getComponent("processByteCode");
77.51 + if (process != null && "const=0".equals(process.getValue().toString())) {
77.52 + return null;
77.53 + }
77.54 + }
77.55 +
77.56 ByteCodeToJavaScript compiler = new ByteCodeToJavaScript(
77.57 jc, out, references
77.58 );
77.59 @@ -95,26 +118,39 @@
77.60 out.append("\n this." + v.getName() + " = 0;");
77.61 }
77.62 }
77.63 - out.append("\n}");
77.64 + out.append("\n}\n\nfunction ").append(className).append("_proto() {");
77.65 + out.append("\n if (").append(className).
77.66 + append(".prototype.$instOf_").append(className).append(") {");
77.67 + out.append("\n return ").append(className).append(".prototype;");
77.68 + out.append("\n }");
77.69 ClassName sc = jc.getSuperClass();
77.70 if (sc != null) {
77.71 - out.append("\n").append(className)
77.72 + out.append("\n ").append(sc.getInternalName().replace('/', '_')).append("_proto();");
77.73 + out.append("\n ").append(className)
77.74 .append(".prototype = new ").append(sc.getInternalName().replace('/', '_')).append(';');
77.75 }
77.76 for (Method m : jc.getMethods()) {
77.77 if (!m.isStatic() && !m.isPrivate() && !m.getName().contains("<init>")) {
77.78 - compiler.generateMethodReference("\n" + className + ".prototype.", m);
77.79 + compiler.generateMethodReference("\n " + className + ".prototype.", m);
77.80 }
77.81 }
77.82 - out.append("\n" + className + ".prototype.$instOf_").append(className).append(" = true;");
77.83 + out.append("\n " + className + ".prototype.$instOf_").append(className).append(" = true;");
77.84 for (ClassName superInterface : jc.getInterfaces()) {
77.85 - out.append("\n" + className + ".prototype.$instOf_").append(superInterface.getInternalName().replace('/', '_')).append(" = true;");
77.86 + out.append("\n " + className + ".prototype.$instOf_").append(superInterface.getInternalName().replace('/', '_')).append(" = true;");
77.87 }
77.88 + out.append("\n return ").append(className).append(".prototype;");
77.89 + out.append("\n}");
77.90 + out.append("\n").append(className).append("_proto();");
77.91 + StringBuilder sb = new StringBuilder();
77.92 for (String init : toInitilize) {
77.93 - out.append("\n").append(init).append("();");
77.94 + sb.append("\n").append(init).append("();");
77.95 }
77.96 + return sb.toString();
77.97 }
77.98 private void generateStaticMethod(Method m, List<String> toInitilize) throws IOException {
77.99 + if (javaScriptBody(m, true)) {
77.100 + return;
77.101 + }
77.102 final String mn = findMethodName(m);
77.103 out.append("\nfunction ").append(
77.104 jc.getName().getInternalName().replace('/', '_')
77.105 @@ -160,6 +196,9 @@
77.106 }
77.107
77.108 private void generateInstanceMethod(Method m) throws IOException {
77.109 + if (javaScriptBody(m, false)) {
77.110 + return;
77.111 + }
77.112 out.append("\nfunction ").append(
77.113 jc.getName().getInternalName().replace('/', '_')
77.114 ).append('_').append(findMethodName(m));
77.115 @@ -184,9 +223,7 @@
77.116 out.append(" var ");
77.117 out.append("arg").append(String.valueOf(i + 1)).append(";\n");
77.118 }
77.119 - out.append(";\n var stack = new Array(");
77.120 - out.append(Integer.toString(code.getMaxStack()));
77.121 - out.append(");\n");
77.122 + out.append(";\n var stack = new Array();\n");
77.123 produceCode(code.getByteCodes());
77.124 } else {
77.125 out.append(" /* no code found for ").append(m.getTypeSignature()).append(" */\n");
77.126 @@ -313,6 +350,24 @@
77.127 case bc_lxor:
77.128 out.append("stack.push(stack.pop() ^ stack.pop());");
77.129 break;
77.130 + case bc_ineg:
77.131 + case bc_lneg:
77.132 + case bc_fneg:
77.133 + case bc_dneg:
77.134 + out.append("stack.push(- stack.pop());");
77.135 + break;
77.136 + case bc_ishl:
77.137 + case bc_lshl:
77.138 + out.append("{ var v = stack.pop(); stack.push(stack.pop() << v); }");
77.139 + break;
77.140 + case bc_ishr:
77.141 + case bc_lshr:
77.142 + out.append("{ var v = stack.pop(); stack.push(stack.pop() >> v); }");
77.143 + break;
77.144 + case bc_iushr:
77.145 + case bc_lushr:
77.146 + out.append("{ var v = stack.pop(); stack.push(stack.pop() >>> v); }");
77.147 + break;
77.148 case bc_iinc: {
77.149 final int varIndx = (byteCodes[++i] + 256) % 256;
77.150 final int incrBy = (byteCodes[++i] + 256) % 256;
77.151 @@ -549,6 +604,11 @@
77.152 out.append("{ var indx = stack.pop(); stack.push(stack.pop()[indx]); }");
77.153 break;
77.154 }
77.155 + case bc_pop2:
77.156 + out.append("stack.pop();");
77.157 + case bc_pop:
77.158 + out.append("stack.pop();");
77.159 + break;
77.160 case bc_dup:
77.161 out.append("stack.push(stack[stack.length - 1]);");
77.162 break;
77.163 @@ -681,6 +741,7 @@
77.164 sig.insert(firstPos, 'A');
77.165 }
77.166 }
77.167 + array = false;
77.168 continue;
77.169 case 'V':
77.170 assert !count;
77.171 @@ -843,7 +904,9 @@
77.172
77.173 private String encodeConstant(CPEntry entry) {
77.174 final String v;
77.175 - if (entry instanceof CPStringInfo) {
77.176 + if (entry instanceof CPClassInfo) {
77.177 + v = "new java_lang_Class";
77.178 + } else if (entry instanceof CPStringInfo) {
77.179 v = "\"" + entry.getValue().toString().replace("\"", "\\\"") + "\"";
77.180 } else {
77.181 v = entry.getValue().toString();
77.182 @@ -854,4 +917,46 @@
77.183 private String findDescriptor(String d) {
77.184 return d.replace('[', 'A');
77.185 }
77.186 +
77.187 + private boolean javaScriptBody(Method m, boolean isStatic) throws IOException {
77.188 + final ClassName extraAnn = ClassName.getClassName(JavaScriptBody.class.getName().replace('.', '/'));
77.189 + Annotation a = m.getAnnotation(extraAnn);
77.190 + if (a != null) {
77.191 + final ElementValue annVal = a.getComponent("body").getValue();
77.192 + String body = ((PrimitiveElementValue) annVal).getValue().getValue().toString();
77.193 +
77.194 + final ArrayElementValue arrVal = (ArrayElementValue) a.getComponent("args").getValue();
77.195 + final int len = arrVal.getValues().length;
77.196 + String[] names = new String[len];
77.197 + for (int i = 0; i < len; i++) {
77.198 + names[i] = ((PrimitiveElementValue) arrVal.getValues()[i]).getValue().getValue().toString();
77.199 + }
77.200 + out.append("\nfunction ").append(
77.201 + jc.getName().getInternalName().replace('/', '_')).append('_').append(findMethodName(m));
77.202 + out.append("(");
77.203 + String space;
77.204 + int index;
77.205 + if (!isStatic) {
77.206 + out.append(names[0]);
77.207 + space = ",";
77.208 + index = 1;
77.209 + } else {
77.210 + space = "";
77.211 + index = 0;
77.212 + }
77.213 + List<Parameter> args = m.getParameters();
77.214 + for (int i = 0; i < args.size(); i++) {
77.215 + out.append(space);
77.216 + out.append(names[index]);
77.217 + final String desc = findDescriptor(args.get(i).getDescriptor());
77.218 + index++;
77.219 + space = ",";
77.220 + }
77.221 + out.append(") {").append("\n");
77.222 + out.append(body);
77.223 + out.append("\n}\n");
77.224 + return true;
77.225 + }
77.226 + return false;
77.227 + }
77.228 }
78.1 --- a/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Fri Sep 28 14:58:21 2012 +0200
78.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Thu Oct 11 06:16:00 2012 -0700
78.3 @@ -5,11 +5,15 @@
78.4 import java.io.IOException;
78.5 import java.io.InputStream;
78.6 import java.io.Writer;
78.7 +import java.net.URL;
78.8 import java.util.Arrays;
78.9 -import java.util.HashSet;
78.10 +import java.util.Collections;
78.11 +import java.util.Enumeration;
78.12 +import java.util.HashMap;
78.13 +import java.util.Iterator;
78.14 import java.util.LinkedList;
78.15 import java.util.List;
78.16 -import java.util.Set;
78.17 +import java.util.Map;
78.18
78.19 /** Generator of JavaScript from bytecode of classes on classpath of the VM.
78.20 *
78.21 @@ -34,43 +38,142 @@
78.22 compile(out, Arrays.asList(names));
78.23 }
78.24 static void compile(Appendable out, List<String> names) throws IOException {
78.25 - Set<String> processed = new HashSet<String>();
78.26 - LinkedList<String> toProcess = new LinkedList<String>(names);
78.27 - for (;;) {
78.28 - toProcess.removeAll(processed);
78.29 - if (toProcess.isEmpty()) {
78.30 - break;
78.31 + for (String baseClass : names) {
78.32 + Map<String,String> processed = new HashMap<String, String>();
78.33 + LinkedList<String> toProcess = new LinkedList<String>();
78.34 + toProcess.add(baseClass);
78.35 + for (;;) {
78.36 + String name = null;
78.37 + Iterator<String> it = toProcess.iterator();
78.38 + while (it.hasNext() && name == null) {
78.39 + String n = it.next();
78.40 + if (processed.get(n) != null) {
78.41 + continue;
78.42 + }
78.43 + name = n;
78.44 + }
78.45 + if (name == null) {
78.46 + break;
78.47 + }
78.48 + if (name.startsWith("java/")
78.49 + && !name.equals("java/lang/Object")
78.50 + && !name.equals("java/lang/Class")
78.51 + && !name.equals("java/lang/Number")
78.52 + && !name.equals("java/lang/Integer")
78.53 + && !name.equals("java/lang/Throwable")
78.54 + && !name.equals("java/lang/Exception")
78.55 + && !name.equals("java/lang/RuntimeException")
78.56 + && !name.equals("java/lang/UnsupportedOperationException")
78.57 + && !name.equals("java/lang/String")
78.58 + && !name.equals("java/lang/String$CaseInsensitiveComparator")
78.59 + && !name.equals("java/lang/StringBuilder")
78.60 + && !name.equals("java/lang/AbstractStringBuilder")
78.61 + ) {
78.62 + processed.put(name, "");
78.63 + continue;
78.64 + }
78.65 + InputStream is = loadClass(name);
78.66 + if (is == null) {
78.67 + throw new IOException("Can't find class " + name);
78.68 + }
78.69 + LinkedList<String> scripts = new LinkedList<String>();
78.70 + try {
78.71 + String initCode = ByteCodeToJavaScript.compile(is, out, toProcess, scripts);
78.72 + processed.put(name, initCode == null ? "" : initCode);
78.73 + } catch (RuntimeException ex) {
78.74 + if (out instanceof CharSequence) {
78.75 + CharSequence seq = (CharSequence)out;
78.76 + int lastBlock = seq.length();
78.77 + while (lastBlock-- >= 0) {
78.78 + if (seq.charAt(lastBlock) == '{') {
78.79 + break;
78.80 + }
78.81 + }
78.82 + throw new IOException("Error while compiling " + name + "\n"
78.83 + + seq.subSequence(lastBlock + 1, seq.length()), ex
78.84 + );
78.85 + } else {
78.86 + throw new IOException("Error while compiling " + name + "\n"
78.87 + + out, ex
78.88 + );
78.89 + }
78.90 + }
78.91 + for (String resource : scripts) {
78.92 + InputStream emul = GenJS.class.getResourceAsStream(resource);
78.93 + if (emul == null) {
78.94 + throw new IOException("Can't find " + resource);
78.95 + }
78.96 + readResource(emul, out);
78.97 + }
78.98 }
78.99 - String name = toProcess.getFirst();
78.100 - processed.add(name);
78.101 - if (name.startsWith("java/") && !name.equals("java/lang/Object")) {
78.102 - continue;
78.103 - }
78.104 - InputStream is = GenJS.class.getClassLoader().getResourceAsStream(name + ".class");
78.105 - if (is == null) {
78.106 - throw new IOException("Can't find class " + name);
78.107 - }
78.108 - try {
78.109 - ByteCodeToJavaScript.compile(is, out, toProcess);
78.110 - } catch (RuntimeException ex) {
78.111 - if (out instanceof CharSequence) {
78.112 - CharSequence seq = (CharSequence)out;
78.113 - int lastBlock = seq.length();
78.114 - while (lastBlock-- >= 0) {
78.115 - if (seq.charAt(lastBlock) == '{') {
78.116 - break;
78.117 - }
78.118 - }
78.119 - throw new IOException("Error while compiling " + name + "\n"
78.120 - + seq.subSequence(lastBlock + 1, seq.length()), ex
78.121 - );
78.122 - } else {
78.123 - throw new IOException("Error while compiling " + name + "\n"
78.124 - + out, ex
78.125 - );
78.126 +
78.127 + Collections.reverse(toProcess);
78.128 +
78.129 + for (String clazz : toProcess) {
78.130 + String initCode = processed.remove(clazz);
78.131 + if (initCode != null) {
78.132 + out.append(initCode).append("\n");
78.133 }
78.134 }
78.135 }
78.136 +
78.137 + }
78.138 + private static void readResource(InputStream emul, Appendable out) throws IOException {
78.139 + try {
78.140 + int state = 0;
78.141 + for (;;) {
78.142 + int ch = emul.read();
78.143 + if (ch == -1) {
78.144 + break;
78.145 + }
78.146 + if (ch < 0 || ch > 255) {
78.147 + throw new IOException("Invalid char in emulation " + ch);
78.148 + }
78.149 + switch (state) {
78.150 + case 0:
78.151 + if (ch == '/') {
78.152 + state = 1;
78.153 + } else {
78.154 + out.append((char)ch);
78.155 + }
78.156 + break;
78.157 + case 1:
78.158 + if (ch == '*') {
78.159 + state = 2;
78.160 + } else {
78.161 + out.append('/').append((char)ch);
78.162 + state = 0;
78.163 + }
78.164 + break;
78.165 + case 2:
78.166 + if (ch == '*') {
78.167 + state = 3;
78.168 + }
78.169 + break;
78.170 + case 3:
78.171 + if (ch == '/') {
78.172 + state = 0;
78.173 + } else {
78.174 + state = 2;
78.175 + }
78.176 + break;
78.177 + }
78.178 + }
78.179 + } finally {
78.180 + emul.close();
78.181 + }
78.182 + }
78.183 +
78.184 + private static InputStream loadClass(String name) throws IOException {
78.185 + Enumeration<URL> en = ClassLoader.getSystemClassLoader().getResources(name + ".class");
78.186 + URL u = null;
78.187 + while (en.hasMoreElements()) {
78.188 + u = en.nextElement();
78.189 + }
78.190 + if (u == null) {
78.191 + throw new IOException("Can't find " + name);
78.192 + }
78.193 + return u.openStream();
78.194 }
78.195
78.196 }
79.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
79.2 +++ b/vm/src/main/resources/org/apidesign/vm4brwsr/emulation/java_lang_String.js Thu Oct 11 06:16:00 2012 -0700
79.3 @@ -0,0 +1,3296 @@
79.4 +/* */
79.5 +
79.6 +
79.7 +/*
79.8 +function java_lang_String_consV(arg0) {
79.9 + var arg1;
79.10 +;
79.11 + var stack = new Array(2);
79.12 + var gt = 0;
79.13 + for(;;) switch(gt) {
79.14 + case 0: stack.push(arg0); // 42
79.15 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130
79.16 + case 4: stack.push(arg0); // 42
79.17 + case 5: stack.push(0); // 3
79.18 + case 6: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99
79.19 + case 9: stack.push(arg0); // 42
79.20 + case 10: stack.push(0); // 3
79.21 + case 11: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97
79.22 + case 14: stack.push(arg0); // 42
79.23 + case 15: stack.push(0); // 3
79.24 + case 16: stack.push(new Array(stack.pop())); // 188 5
79.25 + case 18: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100
79.26 + case 21: return; // 177
79.27 + }
79.28 +}
79.29 +function java_lang_String_consVLjava_lang_String(arg0,arg1) {
79.30 + var arg2;
79.31 + var arg3;
79.32 + var arg4;
79.33 + var arg5;
79.34 + var arg6;
79.35 +;
79.36 + var stack = new Array(4);
79.37 + var gt = 0;
79.38 + for(;;) switch(gt) {
79.39 + case 0: stack.push(arg0); // 42
79.40 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130
79.41 + case 4: stack.push(arg1); // 43
79.42 + case 5: stack.push(stack.pop().count); // 180 1 97
79.43 + case 8: arg2 = stack.pop(); // 61
79.44 + case 9: stack.push(arg1); // 43
79.45 + case 10: stack.push(stack.pop().value); // 180 1 100
79.46 + case 13: arg3 = stack.pop(); // 78
79.47 + case 14: stack.push(arg3); // 45
79.48 + case 15: stack.push(stack.pop().length); // 190
79.49 + case 16: stack.push(arg2); // 28
79.50 + case 17: if (stack.pop() >= stack.pop()) { gt = 41; continue; } // 164 0 24
79.51 + case 20: stack.push(arg1); // 43
79.52 + case 21: stack.push(stack.pop().offset); // 180 1 99
79.53 + case 24: arg5 = stack.pop() // 54 5
79.54 + case 26: stack.push(arg3); // 45
79.55 + case 27: stack.push(arg5); // 21 5
79.56 + case 29: stack.push(arg5); // 21 5
79.57 + case 31: stack.push(arg2); // 28
79.58 + case 32: stack.push(stack.pop() + stack.pop()); // 96
79.59 + 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
79.60 + case 36: arg4 = stack.pop() // 58 4
79.61 + case 38: gt = 44; continue; // 167 0 6
79.62 + case 41: stack.push(arg3); // 45
79.63 + case 42: arg4 = stack.pop() // 58 4
79.64 + case 44: stack.push(arg0); // 42
79.65 + case 45: stack.push(0); // 3
79.66 + case 46: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99
79.67 + case 49: stack.push(arg0); // 42
79.68 + case 50: stack.push(arg2); // 28
79.69 + case 51: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97
79.70 + case 54: stack.push(arg0); // 42
79.71 + case 55: stack.push(arg4); // 25 4
79.72 + case 57: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100
79.73 + case 60: return; // 177
79.74 + }
79.75 +}
79.76 +*/
79.77 +function java_lang_String_consVAC(arg0,arg1) {
79.78 + arg0.r = arg1.join("");
79.79 +}
79.80 +/*
79.81 +function java_lang_String_consVACII(arg0,arg1,arg2,arg3) {
79.82 + var arg4;
79.83 +;
79.84 + var stack = new Array(5);
79.85 + var gt = 0;
79.86 + for(;;) switch(gt) {
79.87 + case 0: stack.push(arg0); // 42
79.88 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130
79.89 + case 4: stack.push(arg2); // 28
79.90 + case 5: if (stack.pop() >= 0) { gt = 17; continue; } // 156 0 12
79.91 + case 8: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.92 + case 11: stack.push(stack[stack.length - 1]); // 89
79.93 + case 12: stack.push(arg2); // 28
79.94 + case 13: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.95 + case 16: // 191
79.96 + case 17: stack.push(arg3); // 29
79.97 + case 18: if (stack.pop() >= 0) { gt = 30; continue; } // 156 0 12
79.98 + case 21: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.99 + case 24: stack.push(stack[stack.length - 1]); // 89
79.100 + case 25: stack.push(arg3); // 29
79.101 + case 26: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.102 + case 29: // 191
79.103 + case 30: stack.push(arg2); // 28
79.104 + case 31: stack.push(arg1); // 43
79.105 + case 32: stack.push(stack.pop().length); // 190
79.106 + case 33: stack.push(arg3); // 29
79.107 + case 34: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.108 + case 35: if (stack.pop() >= stack.pop()) { gt = 49; continue; } // 164 0 14
79.109 + case 38: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.110 + case 41: stack.push(stack[stack.length - 1]); // 89
79.111 + case 42: stack.push(arg2); // 28
79.112 + case 43: stack.push(arg3); // 29
79.113 + case 44: stack.push(stack.pop() + stack.pop()); // 96
79.114 + case 45: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.115 + case 48: // 191
79.116 + case 49: stack.push(arg0); // 42
79.117 + case 50: stack.push(0); // 3
79.118 + case 51: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99
79.119 + case 54: stack.push(arg0); // 42
79.120 + case 55: stack.push(arg3); // 29
79.121 + case 56: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97
79.122 + case 59: stack.push(arg0); // 42
79.123 + case 60: stack.push(arg1); // 43
79.124 + case 61: stack.push(arg2); // 28
79.125 + case 62: stack.push(arg2); // 28
79.126 + case 63: stack.push(arg3); // 29
79.127 + case 64: stack.push(stack.pop() + stack.pop()); // 96
79.128 + 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
79.129 + case 68: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100
79.130 + case 71: return; // 177
79.131 + }
79.132 +}
79.133 +function java_lang_String_consVAIII(arg0,arg1,arg2,arg3) {
79.134 + var arg4;
79.135 + var arg5;
79.136 + var arg6;
79.137 + var arg7;
79.138 + var arg8;
79.139 + var arg9;
79.140 + var arg10;
79.141 + var arg11;
79.142 + var arg12;
79.143 +;
79.144 + var stack = new Array(4);
79.145 + var gt = 0;
79.146 + for(;;) switch(gt) {
79.147 + case 0: stack.push(arg0); // 42
79.148 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130
79.149 + case 4: stack.push(arg2); // 28
79.150 + case 5: if (stack.pop() >= 0) { gt = 17; continue; } // 156 0 12
79.151 + case 8: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.152 + case 11: stack.push(stack[stack.length - 1]); // 89
79.153 + case 12: stack.push(arg2); // 28
79.154 + case 13: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.155 + case 16: // 191
79.156 + case 17: stack.push(arg3); // 29
79.157 + case 18: if (stack.pop() >= 0) { gt = 30; continue; } // 156 0 12
79.158 + case 21: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.159 + case 24: stack.push(stack[stack.length - 1]); // 89
79.160 + case 25: stack.push(arg3); // 29
79.161 + case 26: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.162 + case 29: // 191
79.163 + case 30: stack.push(arg2); // 28
79.164 + case 31: stack.push(arg1); // 43
79.165 + case 32: stack.push(stack.pop().length); // 190
79.166 + case 33: stack.push(arg3); // 29
79.167 + case 34: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.168 + case 35: if (stack.pop() >= stack.pop()) { gt = 49; continue; } // 164 0 14
79.169 + case 38: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.170 + case 41: stack.push(stack[stack.length - 1]); // 89
79.171 + case 42: stack.push(arg2); // 28
79.172 + case 43: stack.push(arg3); // 29
79.173 + case 44: stack.push(stack.pop() + stack.pop()); // 96
79.174 + case 45: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.175 + case 48: // 191
79.176 + case 49: stack.push(0); // 3
79.177 + case 50: arg4 = stack.pop() // 54 4
79.178 + case 52: stack.push(1); // 4
79.179 + case 53: arg5 = stack.pop() // 54 5
79.180 + case 55: stack.push(arg3); // 29
79.181 + case 56: stack.push(arg5); // 21 5
79.182 + case 58: stack.push(stack.pop() + stack.pop()); // 96
79.183 + case 59: stack.push(new Array(stack.pop())); // 188 5
79.184 + case 61: arg6 = stack.pop() // 58 6
79.185 + case 63: stack.push(arg2); // 28
79.186 + case 64: arg7 = stack.pop() // 54 7
79.187 + case 66: stack.push(0); // 3
79.188 + case 67: arg8 = stack.pop() // 54 8
79.189 + case 69: stack.push(0); // 3
79.190 + case 70: arg9 = stack.pop() // 54 9
79.191 + case 72: stack.push(arg9); // 21 9
79.192 + case 74: stack.push(arg3); // 29
79.193 + case 75: if (stack.pop() <= stack.pop()) { gt = 255; continue; } // 162 0 180
79.194 + case 78: stack.push(arg1); // 43
79.195 + case 79: stack.push(arg7); // 21 7
79.196 + case 81: arg7++; // 132 7 1
79.197 + case 84: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 46
79.198 + case 85: arg10 = stack.pop() // 54 10
79.199 + case 87: stack.push(arg10); // 21 10
79.200 + case 89: if (stack.pop() >= 0) { gt = 100; continue; } // 156 0 11
79.201 + case 92: stack.push(new java_lang_IllegalArgumentException); // 187 0 193
79.202 + case 95: stack.push(stack[stack.length - 1]); // 89
79.203 + case 96: { java_lang_IllegalArgumentException_consV(stack.pop()); } // 183 1 123
79.204 + case 99: // 191
79.205 + case 100: stack.push(arg5); // 21 5
79.206 + case 102: if (stack.pop() > 0) { gt = 195; continue; } // 157 0 93
79.207 + case 105: stack.push(arg8); // 21 8
79.208 + case 107: stack.push(1); // 4
79.209 + case 108: stack.push(stack.pop() + stack.pop()); // 96
79.210 + case 109: stack.push(arg6); // 25 6
79.211 + case 111: stack.push(stack.pop().length); // 190
79.212 + case 112: if (stack.pop() > stack.pop()) { gt = 195; continue; } // 161 0 83
79.213 + case 115: stack.push(arg4); // 21 4
79.214 + case 117: if (stack.pop() != 0) { gt = 153; continue; } // 154 0 36
79.215 + case 120: stack.push(arg5); // 21 5
79.216 + case 122: // 116
79.217 + case 123: stack.push(1); // 4
79.218 + case 124: stack.push(stack.pop() + stack.pop()); // 96
79.219 + case 125: stack.push(arg3); // 29
79.220 + case 126: stack.push(stack.pop() * stack.pop()); // 104
79.221 + case 127: stack.push(10); // 16 10
79.222 + case 129: // 120
79.223 + case 130: stack.push(arg9); // 21 9
79.224 + case 132: { var tmp = stack.pop(); stack.push(Math.floor(stack.pop() / tmp)); } // 108
79.225 + case 133: arg4 = stack.pop() // 54 4
79.226 + case 135: stack.push(arg4); // 21 4
79.227 + case 137: stack.push(10); // 16 10
79.228 + case 139: // 122
79.229 + case 140: arg4 = stack.pop() // 54 4
79.230 + case 142: stack.push(arg4); // 21 4
79.231 + case 144: if (stack.pop() > 0) { gt = 159; continue; } // 157 0 15
79.232 + case 147: stack.push(1); // 4
79.233 + case 148: arg4 = stack.pop() // 54 4
79.234 + case 150: gt = 159; continue; // 167 0 9
79.235 + case 153: stack.push(arg4); // 21 4
79.236 + case 155: stack.push(2); // 5
79.237 + case 156: stack.push(stack.pop() * stack.pop()); // 104
79.238 + case 157: arg4 = stack.pop() // 54 4
79.239 + case 159: stack.push(arg6); // 25 6
79.240 + case 161: stack.push(stack.pop().length); // 190
79.241 + case 162: stack.push(arg4); // 21 4
79.242 + case 164: stack.push(stack.pop() + stack.pop()); // 96
79.243 + case 165: stack.push(arg3); // 29
79.244 + case 166: stack.push(2); // 5
79.245 + case 167: stack.push(stack.pop() * stack.pop()); // 104
79.246 + case 168: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Math_minIII(v0, v1)); } // 184 1 127
79.247 + case 171: arg11 = stack.pop() // 54 11
79.248 + case 173: stack.push(arg11); // 21 11
79.249 + case 175: stack.push(arg6); // 25 6
79.250 + case 177: stack.push(stack.pop().length); // 190
79.251 + case 178: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.252 + case 179: stack.push(arg3); // 29
79.253 + case 180: stack.push(arg9); // 21 9
79.254 + case 182: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.255 + case 183: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.256 + case 184: arg5 = stack.pop() // 54 5
79.257 + case 186: stack.push(arg6); // 25 6
79.258 + case 188: stack.push(arg11); // 21 11
79.259 + case 190: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_util_Arrays_copyOfACACAI(v0, v1)); } // 184 1 172
79.260 + case 193: arg6 = stack.pop() // 58 6
79.261 + case 195: stack.push(arg10); // 21 10
79.262 + case 197: stack.push(65536); // 18 3
79.263 + case 199: if (stack.pop() <= stack.pop()) { gt = 216; continue; } // 162 0 17
79.264 + case 202: stack.push(arg6); // 25 6
79.265 + case 204: stack.push(arg8); // 21 8
79.266 + case 206: arg8++; // 132 8 1
79.267 + case 209: stack.push(arg10); // 21 10
79.268 + case 211: // number conversion // 146
79.269 + case 212: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
79.270 + case 213: gt = 249; continue; // 167 0 36
79.271 + case 216: stack.push(arg10); // 21 10
79.272 + case 218: stack.push(1114111); // 18 4
79.273 + case 220: if (stack.pop() < stack.pop()) { gt = 241; continue; } // 163 0 21
79.274 + case 223: stack.push(arg10); // 21 10
79.275 + case 225: stack.push(arg6); // 25 6
79.276 + case 227: stack.push(arg8); // 21 8
79.277 + case 229: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_Character_toSurrogatesVIACAI(v0, v1, v2); } // 184 1 112
79.278 + case 232: arg8 += 2; // 132 8 2
79.279 + case 235: arg5 += 255; // 132 5 255
79.280 + case 238: gt = 249; continue; // 167 0 11
79.281 + case 241: stack.push(new java_lang_IllegalArgumentException); // 187 0 193
79.282 + case 244: stack.push(stack[stack.length - 1]); // 89
79.283 + case 245: { java_lang_IllegalArgumentException_consV(stack.pop()); } // 183 1 123
79.284 + case 248: // 191
79.285 + case 249: arg9++; // 132 9 1
79.286 + case 252: gt = 72; continue; // 167 255 76
79.287 + case 255: stack.push(arg0); // 42
79.288 + case 256: stack.push(0); // 3
79.289 + case 257: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99
79.290 + case 260: stack.push(arg0); // 42
79.291 + case 261: stack.push(arg6); // 25 6
79.292 + case 263: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100
79.293 + case 266: stack.push(arg0); // 42
79.294 + case 267: stack.push(arg8); // 21 8
79.295 + case 269: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97
79.296 + case 272: return; // 177
79.297 + }
79.298 +}
79.299 +function java_lang_String_consVABIII(arg0,arg1,arg2,arg3,arg4) {
79.300 + var arg5;
79.301 + var arg6;
79.302 + var arg7;
79.303 +;
79.304 + var stack = new Array(6);
79.305 + var gt = 0;
79.306 + for(;;) switch(gt) {
79.307 + case 0: stack.push(arg0); // 42
79.308 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130
79.309 + case 4: stack.push(arg1); // 43
79.310 + case 5: stack.push(arg3); // 29
79.311 + case 6: stack.push(arg4); // 21 4
79.312 + case 8: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_checkBoundsVABAIAI(v0, v1, v2); } // 184 1 140
79.313 + case 11: stack.push(arg4); // 21 4
79.314 + case 13: stack.push(new Array(stack.pop())); // 188 5
79.315 + case 15: arg5 = stack.pop() // 58 5
79.316 + case 17: stack.push(arg2); // 28
79.317 + case 18: if (stack.pop() != 0) { gt = 55; continue; } // 154 0 37
79.318 + case 21: stack.push(arg4); // 21 4
79.319 + case 23: arg6 = stack.pop() // 54 6
79.320 + case 25: stack.push(arg6); // 21 6
79.321 + case 27: arg6 += 255; // 132 6 255
79.322 + case 30: if (stack.pop() <= 0) { gt = 52; continue; } // 158 0 22
79.323 + case 33: stack.push(arg5); // 25 5
79.324 + case 35: stack.push(arg6); // 21 6
79.325 + case 37: stack.push(arg1); // 43
79.326 + case 38: stack.push(arg6); // 21 6
79.327 + case 40: stack.push(arg3); // 29
79.328 + case 41: stack.push(stack.pop() + stack.pop()); // 96
79.329 + case 42: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 51
79.330 + case 43: stack.push(255); // 17 0 255
79.331 + case 46: stack.push(stack.pop() & stack.pop()); // 126
79.332 + case 47: // number conversion // 146
79.333 + case 48: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
79.334 + case 49: gt = 25; continue; // 167 255 232
79.335 + case 52: gt = 93; continue; // 167 0 41
79.336 + case 55: stack.push(arg2); // 28
79.337 + case 56: stack.push(8); // 16 8
79.338 + case 58: // 120
79.339 + case 59: arg2 = stack.pop(); // 61
79.340 + case 60: stack.push(arg4); // 21 4
79.341 + case 62: arg6 = stack.pop() // 54 6
79.342 + case 64: stack.push(arg6); // 21 6
79.343 + case 66: arg6 += 255; // 132 6 255
79.344 + case 69: if (stack.pop() <= 0) { gt = 93; continue; } // 158 0 24
79.345 + case 72: stack.push(arg5); // 25 5
79.346 + case 74: stack.push(arg6); // 21 6
79.347 + case 76: stack.push(arg2); // 28
79.348 + case 77: stack.push(arg1); // 43
79.349 + case 78: stack.push(arg6); // 21 6
79.350 + case 80: stack.push(arg3); // 29
79.351 + case 81: stack.push(stack.pop() + stack.pop()); // 96
79.352 + case 82: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 51
79.353 + case 83: stack.push(255); // 17 0 255
79.354 + case 86: stack.push(stack.pop() & stack.pop()); // 126
79.355 + case 87: stack.push(stack.pop() | stack.pop()); // 128
79.356 + case 88: // number conversion // 146
79.357 + case 89: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
79.358 + case 90: gt = 64; continue; // 167 255 230
79.359 + case 93: stack.push(arg0); // 42
79.360 + case 94: stack.push(0); // 3
79.361 + case 95: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99
79.362 + case 98: stack.push(arg0); // 42
79.363 + case 99: stack.push(arg4); // 21 4
79.364 + case 101: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97
79.365 + case 104: stack.push(arg0); // 42
79.366 + case 105: stack.push(arg5); // 25 5
79.367 + case 107: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100
79.368 + case 110: return; // 177
79.369 + }
79.370 +}
79.371 +function java_lang_String_consVABI(arg0,arg1,arg2) {
79.372 + var arg3;
79.373 +;
79.374 + var stack = new Array(5);
79.375 + var gt = 0;
79.376 + for(;;) switch(gt) {
79.377 + case 0: stack.push(arg0); // 42
79.378 + case 1: stack.push(arg1); // 43
79.379 + case 2: stack.push(arg2); // 28
79.380 + case 3: stack.push(0); // 3
79.381 + case 4: stack.push(arg1); // 43
79.382 + case 5: stack.push(stack.pop().length); // 190
79.383 + 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
79.384 + case 9: return; // 177
79.385 + }
79.386 +}
79.387 +function java_lang_String_checkBoundsVABII(arg0,arg1,arg2) {
79.388 + var stack = new Array();
79.389 + var gt = 0;
79.390 + for(;;) switch(gt) {
79.391 + case 0: stack.push(arg2); // 28
79.392 + case 1: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 12
79.393 + case 4: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.394 + case 7: stack.push(stack[stack.length - 1]); // 89
79.395 + case 8: stack.push(arg2); // 28
79.396 + case 9: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.397 + case 12: // 191
79.398 + case 13: stack.push(arg1); // 27
79.399 + case 14: if (stack.pop() >= 0) { gt = 26; continue; } // 156 0 12
79.400 + case 17: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.401 + case 20: stack.push(stack[stack.length - 1]); // 89
79.402 + case 21: stack.push(arg1); // 27
79.403 + case 22: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.404 + case 25: // 191
79.405 + case 26: stack.push(arg1); // 27
79.406 + case 27: stack.push(arg0); // 42
79.407 + case 28: stack.push(stack.pop().length); // 190
79.408 + case 29: stack.push(arg2); // 28
79.409 + case 30: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.410 + case 31: if (stack.pop() >= stack.pop()) { gt = 45; continue; } // 164 0 14
79.411 + case 34: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.412 + case 37: stack.push(stack[stack.length - 1]); // 89
79.413 + case 38: stack.push(arg1); // 27
79.414 + case 39: stack.push(arg2); // 28
79.415 + case 40: stack.push(stack.pop() + stack.pop()); // 96
79.416 + case 41: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.417 + case 44: // 191
79.418 + case 45: return; // 177
79.419 + }
79.420 +}
79.421 +function java_lang_String_consVABIILjava_lang_String(arg0,arg1,arg2,arg3,arg4) {
79.422 + var arg5;
79.423 + var arg6;
79.424 +;
79.425 + var stack = new Array(4);
79.426 + var gt = 0;
79.427 + for(;;) switch(gt) {
79.428 + case 0: stack.push(arg0); // 42
79.429 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130
79.430 + case 4: stack.push(arg4); // 25 4
79.431 + case 6: if (stack.pop()) { gt = 19; continue; } // 199 0 13
79.432 + case 9: stack.push(new java_lang_NullPointerException); // 187 0 198
79.433 + case 12: stack.push(stack[stack.length - 1]); // 89
79.434 + case 13: stack.push("charsetName"); // 18 7
79.435 + case 15: { var v0 = stack.pop(); java_lang_NullPointerException_consVLjava_lang_String(stack.pop(), v0); } // 183 1 129
79.436 + case 18: // 191
79.437 + case 19: stack.push(arg1); // 43
79.438 + case 20: stack.push(arg2); // 28
79.439 + case 21: stack.push(arg3); // 29
79.440 + case 22: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_checkBoundsVABAIAI(v0, v1, v2); } // 184 1 140
79.441 + case 25: stack.push(arg4); // 25 4
79.442 + case 27: stack.push(arg1); // 43
79.443 + case 28: stack.push(arg2); // 28
79.444 + case 29: stack.push(arg3); // 29
79.445 + 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
79.446 + case 33: arg5 = stack.pop() // 58 5
79.447 + case 35: stack.push(arg0); // 42
79.448 + case 36: stack.push(0); // 3
79.449 + case 37: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99
79.450 + case 40: stack.push(arg0); // 42
79.451 + case 41: stack.push(arg5); // 25 5
79.452 + case 43: stack.push(stack.pop().length); // 190
79.453 + case 44: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97
79.454 + case 47: stack.push(arg0); // 42
79.455 + case 48: stack.push(arg5); // 25 5
79.456 + case 50: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100
79.457 + case 53: return; // 177
79.458 + }
79.459 +}
79.460 +function java_lang_String_consVABIILjava_nio_charset_Charset(arg0,arg1,arg2,arg3,arg4) {
79.461 + var arg5;
79.462 + var arg6;
79.463 +;
79.464 + var stack = new Array(4);
79.465 + var gt = 0;
79.466 + for(;;) switch(gt) {
79.467 + case 0: stack.push(arg0); // 42
79.468 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130
79.469 + case 4: stack.push(arg4); // 25 4
79.470 + case 6: if (stack.pop()) { gt = 19; continue; } // 199 0 13
79.471 + case 9: stack.push(new java_lang_NullPointerException); // 187 0 198
79.472 + case 12: stack.push(stack[stack.length - 1]); // 89
79.473 + case 13: stack.push("charset"); // 18 6
79.474 + case 15: { var v0 = stack.pop(); java_lang_NullPointerException_consVLjava_lang_String(stack.pop(), v0); } // 183 1 129
79.475 + case 18: // 191
79.476 + case 19: stack.push(arg1); // 43
79.477 + case 20: stack.push(arg2); // 28
79.478 + case 21: stack.push(arg3); // 29
79.479 + case 22: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_checkBoundsVABAIAI(v0, v1, v2); } // 184 1 140
79.480 + case 25: stack.push(arg4); // 25 4
79.481 + case 27: stack.push(arg1); // 43
79.482 + case 28: stack.push(arg2); // 28
79.483 + case 29: stack.push(arg3); // 29
79.484 + 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
79.485 + case 33: arg5 = stack.pop() // 58 5
79.486 + case 35: stack.push(arg0); // 42
79.487 + case 36: stack.push(0); // 3
79.488 + case 37: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99
79.489 + case 40: stack.push(arg0); // 42
79.490 + case 41: stack.push(arg5); // 25 5
79.491 + case 43: stack.push(stack.pop().length); // 190
79.492 + case 44: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97
79.493 + case 47: stack.push(arg0); // 42
79.494 + case 48: stack.push(arg5); // 25 5
79.495 + case 50: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100
79.496 + case 53: return; // 177
79.497 + }
79.498 +}
79.499 +function java_lang_String_consVABLjava_lang_String(arg0,arg1,arg2) {
79.500 + var arg3;
79.501 +;
79.502 + var stack = new Array(5);
79.503 + var gt = 0;
79.504 + for(;;) switch(gt) {
79.505 + case 0: stack.push(arg0); // 42
79.506 + case 1: stack.push(arg1); // 43
79.507 + case 2: stack.push(0); // 3
79.508 + case 3: stack.push(arg1); // 43
79.509 + case 4: stack.push(stack.pop().length); // 190
79.510 + case 5: stack.push(arg2); // 44
79.511 + 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
79.512 + case 9: return; // 177
79.513 + }
79.514 +}
79.515 +function java_lang_String_consVABLjava_nio_charset_Charset(arg0,arg1,arg2) {
79.516 + var arg3;
79.517 +;
79.518 + var stack = new Array(5);
79.519 + var gt = 0;
79.520 + for(;;) switch(gt) {
79.521 + case 0: stack.push(arg0); // 42
79.522 + case 1: stack.push(arg1); // 43
79.523 + case 2: stack.push(0); // 3
79.524 + case 3: stack.push(arg1); // 43
79.525 + case 4: stack.push(stack.pop().length); // 190
79.526 + case 5: stack.push(arg2); // 44
79.527 + 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
79.528 + case 9: return; // 177
79.529 + }
79.530 +}
79.531 +function java_lang_String_consVABII(arg0,arg1,arg2,arg3) {
79.532 + var arg4;
79.533 + var arg5;
79.534 +;
79.535 + var stack = new Array(3);
79.536 + var gt = 0;
79.537 + for(;;) switch(gt) {
79.538 + case 0: stack.push(arg0); // 42
79.539 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130
79.540 + case 4: stack.push(arg1); // 43
79.541 + case 5: stack.push(arg2); // 28
79.542 + case 6: stack.push(arg3); // 29
79.543 + case 7: { var v2 = stack.pop(); var v1 = stack.pop(); var v0 = stack.pop(); java_lang_String_checkBoundsVABAIAI(v0, v1, v2); } // 184 1 140
79.544 + case 10: stack.push(arg1); // 43
79.545 + case 11: stack.push(arg2); // 28
79.546 + case 12: stack.push(arg3); // 29
79.547 + 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
79.548 + case 16: arg4 = stack.pop() // 58 4
79.549 + case 18: stack.push(arg0); // 42
79.550 + case 19: stack.push(0); // 3
79.551 + case 20: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99
79.552 + case 23: stack.push(arg0); // 42
79.553 + case 24: stack.push(arg4); // 25 4
79.554 + case 26: stack.push(stack.pop().length); // 190
79.555 + case 27: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97
79.556 + case 30: stack.push(arg0); // 42
79.557 + case 31: stack.push(arg4); // 25 4
79.558 + case 33: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100
79.559 + case 36: return; // 177
79.560 + }
79.561 +}
79.562 +function java_lang_String_consVAB(arg0,arg1) {
79.563 + var arg2;
79.564 +;
79.565 + var stack = new Array(4);
79.566 + var gt = 0;
79.567 + for(;;) switch(gt) {
79.568 + case 0: stack.push(arg0); // 42
79.569 + case 1: stack.push(arg1); // 43
79.570 + case 2: stack.push(0); // 3
79.571 + case 3: stack.push(arg1); // 43
79.572 + case 4: stack.push(stack.pop().length); // 190
79.573 + 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
79.574 + case 8: return; // 177
79.575 + }
79.576 +}
79.577 +function java_lang_String_consVLjava_lang_StringBuffer(arg0,arg1) {
79.578 + var arg2;
79.579 + var arg3;
79.580 +;
79.581 + var stack = new Array(2);
79.582 + var gt = 0;
79.583 + for(;;) switch(gt) {
79.584 + case 0: stack.push(arg0); // 42
79.585 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130
79.586 + case 4: stack.push(arg1); // 43
79.587 + case 5: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 161
79.588 + case 8: arg2 = stack.pop(); // 77
79.589 + case 9: stack.push(arg0); // 42
79.590 + case 10: stack.push(arg2); // 44
79.591 + case 11: stack.push(stack.pop().value); // 180 1 100
79.592 + case 14: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100
79.593 + case 17: stack.push(arg0); // 42
79.594 + case 18: stack.push(arg2); // 44
79.595 + case 19: stack.push(stack.pop().count); // 180 1 97
79.596 + case 22: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97
79.597 + case 25: stack.push(arg0); // 42
79.598 + case 26: stack.push(arg2); // 44
79.599 + case 27: stack.push(stack.pop().offset); // 180 1 99
79.600 + case 30: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99
79.601 + case 33: return; // 177
79.602 + }
79.603 +}
79.604 +function java_lang_String_consVLjava_lang_StringBuilder(arg0,arg1) {
79.605 + var arg2;
79.606 + var arg3;
79.607 +;
79.608 + var stack = new Array(2);
79.609 + var gt = 0;
79.610 + for(;;) switch(gt) {
79.611 + case 0: stack.push(arg0); // 42
79.612 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130
79.613 + case 4: stack.push(arg1); // 43
79.614 + case 5: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 162
79.615 + case 8: arg2 = stack.pop(); // 77
79.616 + case 9: stack.push(arg0); // 42
79.617 + case 10: stack.push(arg2); // 44
79.618 + case 11: stack.push(stack.pop().value); // 180 1 100
79.619 + case 14: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100
79.620 + case 17: stack.push(arg0); // 42
79.621 + case 18: stack.push(arg2); // 44
79.622 + case 19: stack.push(stack.pop().count); // 180 1 97
79.623 + case 22: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97
79.624 + case 25: stack.push(arg0); // 42
79.625 + case 26: stack.push(arg2); // 44
79.626 + case 27: stack.push(stack.pop().offset); // 180 1 99
79.627 + case 30: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99
79.628 + case 33: return; // 177
79.629 + }
79.630 +}
79.631 +function java_lang_String_consVIIAC(arg0,arg1,arg2,arg3) {
79.632 + var arg4;
79.633 +;
79.634 + var stack = new Array(2);
79.635 + var gt = 0;
79.636 + for(;;) switch(gt) {
79.637 + case 0: stack.push(arg0); // 42
79.638 + case 1: { java_lang_Object_consV(stack.pop()); } // 183 1 130
79.639 + case 4: stack.push(arg0); // 42
79.640 + case 5: stack.push(arg3); // 45
79.641 + case 6: { var v = stack.pop(); stack.pop().value = v; } // 181 1 100
79.642 + case 9: stack.push(arg0); // 42
79.643 + case 10: stack.push(arg1); // 27
79.644 + case 11: { var v = stack.pop(); stack.pop().offset = v; } // 181 1 99
79.645 + case 14: stack.push(arg0); // 42
79.646 + case 15: stack.push(arg2); // 28
79.647 + case 16: { var v = stack.pop(); stack.pop().count = v; } // 181 1 97
79.648 + case 19: return; // 177
79.649 + }
79.650 +}
79.651 +*/
79.652 +
79.653 +function java_lang_String_charAtCI(arg0,arg1) {
79.654 + return arg0.toString().charAt(arg1);
79.655 +}
79.656 +function java_lang_String_lengthI(arg0) {
79.657 + return arg0.toString().length;
79.658 +}
79.659 +function java_lang_String_isEmptyZ(arg0) {
79.660 + return arg0.toString().length === 0;
79.661 +}
79.662 +
79.663 +/*
79.664 +function java_lang_String_codePointAtII(arg0,arg1) {
79.665 + var arg2;
79.666 +;
79.667 + var stack = new Array(4);
79.668 + var gt = 0;
79.669 + for(;;) switch(gt) {
79.670 + case 0: stack.push(arg1); // 27
79.671 + case 1: if (stack.pop() < 0) { gt = 12; continue; } // 155 0 11
79.672 + case 4: stack.push(arg1); // 27
79.673 + case 5: stack.push(arg0); // 42
79.674 + case 6: stack.push(stack.pop().count); // 180 1 97
79.675 + case 9: if (stack.pop() > stack.pop()) { gt = 21; continue; } // 161 0 12
79.676 + case 12: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.677 + case 15: stack.push(stack[stack.length - 1]); // 89
79.678 + case 16: stack.push(arg1); // 27
79.679 + case 17: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.680 + case 20: // 191
79.681 + case 21: stack.push(arg0); // 42
79.682 + case 22: stack.push(stack.pop().value); // 180 1 100
79.683 + case 25: stack.push(arg0); // 42
79.684 + case 26: stack.push(stack.pop().offset); // 180 1 99
79.685 + case 29: stack.push(arg1); // 27
79.686 + case 30: stack.push(stack.pop() + stack.pop()); // 96
79.687 + case 31: stack.push(arg0); // 42
79.688 + case 32: stack.push(stack.pop().offset); // 180 1 99
79.689 + case 35: stack.push(arg0); // 42
79.690 + case 36: stack.push(stack.pop().count); // 180 1 97
79.691 + case 39: stack.push(stack.pop() + stack.pop()); // 96
79.692 + 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
79.693 + case 43: return stack.pop(); // 172
79.694 + }
79.695 +}
79.696 +function java_lang_String_codePointBeforeII(arg0,arg1) {
79.697 + var arg2;
79.698 + var arg3;
79.699 +;
79.700 + var stack = new Array(3);
79.701 + var gt = 0;
79.702 + for(;;) switch(gt) {
79.703 + case 0: stack.push(arg1); // 27
79.704 + case 1: stack.push(1); // 4
79.705 + case 2: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.706 + case 3: arg2 = stack.pop(); // 61
79.707 + case 4: stack.push(arg2); // 28
79.708 + case 5: if (stack.pop() < 0) { gt = 16; continue; } // 155 0 11
79.709 + case 8: stack.push(arg2); // 28
79.710 + case 9: stack.push(arg0); // 42
79.711 + case 10: stack.push(stack.pop().count); // 180 1 97
79.712 + case 13: if (stack.pop() > stack.pop()) { gt = 25; continue; } // 161 0 12
79.713 + case 16: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.714 + case 19: stack.push(stack[stack.length - 1]); // 89
79.715 + case 20: stack.push(arg1); // 27
79.716 + case 21: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.717 + case 24: // 191
79.718 + case 25: stack.push(arg0); // 42
79.719 + case 26: stack.push(stack.pop().value); // 180 1 100
79.720 + case 29: stack.push(arg0); // 42
79.721 + case 30: stack.push(stack.pop().offset); // 180 1 99
79.722 + case 33: stack.push(arg1); // 27
79.723 + case 34: stack.push(stack.pop() + stack.pop()); // 96
79.724 + case 35: stack.push(arg0); // 42
79.725 + case 36: stack.push(stack.pop().offset); // 180 1 99
79.726 + 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
79.727 + case 42: return stack.pop(); // 172
79.728 + }
79.729 +}
79.730 +function java_lang_String_codePointCountIII(arg0,arg1,arg2) {
79.731 + var arg3;
79.732 +;
79.733 + var stack = new Array(4);
79.734 + var gt = 0;
79.735 + for(;;) switch(gt) {
79.736 + case 0: stack.push(arg1); // 27
79.737 + case 1: if (stack.pop() < 0) { gt = 17; continue; } // 155 0 16
79.738 + case 4: stack.push(arg2); // 28
79.739 + case 5: stack.push(arg0); // 42
79.740 + case 6: stack.push(stack.pop().count); // 180 1 97
79.741 + case 9: if (stack.pop() < stack.pop()) { gt = 17; continue; } // 163 0 8
79.742 + case 12: stack.push(arg1); // 27
79.743 + case 13: stack.push(arg2); // 28
79.744 + case 14: if (stack.pop() >= stack.pop()) { gt = 25; continue; } // 164 0 11
79.745 + case 17: stack.push(new java_lang_IndexOutOfBoundsException); // 187 0 194
79.746 + case 20: stack.push(stack[stack.length - 1]); // 89
79.747 + case 21: { java_lang_IndexOutOfBoundsException_consV(stack.pop()); } // 183 1 124
79.748 + case 24: // 191
79.749 + case 25: stack.push(arg0); // 42
79.750 + case 26: stack.push(stack.pop().value); // 180 1 100
79.751 + case 29: stack.push(arg0); // 42
79.752 + case 30: stack.push(stack.pop().offset); // 180 1 99
79.753 + case 33: stack.push(arg1); // 27
79.754 + case 34: stack.push(stack.pop() + stack.pop()); // 96
79.755 + case 35: stack.push(arg2); // 28
79.756 + case 36: stack.push(arg1); // 27
79.757 + case 37: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.758 + 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
79.759 + case 41: return stack.pop(); // 172
79.760 + }
79.761 +}
79.762 +function java_lang_String_offsetByCodePointsIII(arg0,arg1,arg2) {
79.763 + var arg3;
79.764 +;
79.765 + var stack = new Array(5);
79.766 + var gt = 0;
79.767 + for(;;) switch(gt) {
79.768 + case 0: stack.push(arg1); // 27
79.769 + case 1: if (stack.pop() < 0) { gt = 12; continue; } // 155 0 11
79.770 + case 4: stack.push(arg1); // 27
79.771 + case 5: stack.push(arg0); // 42
79.772 + case 6: stack.push(stack.pop().count); // 180 1 97
79.773 + case 9: if (stack.pop() >= stack.pop()) { gt = 20; continue; } // 164 0 11
79.774 + case 12: stack.push(new java_lang_IndexOutOfBoundsException); // 187 0 194
79.775 + case 15: stack.push(stack[stack.length - 1]); // 89
79.776 + case 16: { java_lang_IndexOutOfBoundsException_consV(stack.pop()); } // 183 1 124
79.777 + case 19: // 191
79.778 + case 20: stack.push(arg0); // 42
79.779 + case 21: stack.push(stack.pop().value); // 180 1 100
79.780 + case 24: stack.push(arg0); // 42
79.781 + case 25: stack.push(stack.pop().offset); // 180 1 99
79.782 + case 28: stack.push(arg0); // 42
79.783 + case 29: stack.push(stack.pop().count); // 180 1 97
79.784 + case 32: stack.push(arg0); // 42
79.785 + case 33: stack.push(stack.pop().offset); // 180 1 99
79.786 + case 36: stack.push(arg1); // 27
79.787 + case 37: stack.push(stack.pop() + stack.pop()); // 96
79.788 + case 38: stack.push(arg2); // 28
79.789 + 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
79.790 + case 42: stack.push(arg0); // 42
79.791 + case 43: stack.push(stack.pop().offset); // 180 1 99
79.792 + case 46: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.793 + case 47: return stack.pop(); // 172
79.794 + }
79.795 +}
79.796 +*/
79.797 +
79.798 +// public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
79.799 +function java_lang_String_getCharsVIIACAI(arg0,arg1,arg2,arg3,arg4) {
79.800 + var s = arg0.toString();
79.801 + while (arg1 < arg2) {
79.802 + arg3[arg4++] = s[arg1++];
79.803 + }
79.804 +}
79.805 +
79.806 +/*
79.807 +function java_lang_String_getBytesVIIABI(arg0,arg1,arg2,arg3,arg4) {
79.808 + var arg5;
79.809 + var arg6;
79.810 + var arg7;
79.811 + var arg8;
79.812 + var arg9;
79.813 +;
79.814 + var stack = new Array(4);
79.815 + var gt = 0;
79.816 + for(;;) switch(gt) {
79.817 + case 0: stack.push(arg1); // 27
79.818 + case 1: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 12
79.819 + case 4: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.820 + case 7: stack.push(stack[stack.length - 1]); // 89
79.821 + case 8: stack.push(arg1); // 27
79.822 + case 9: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.823 + case 12: // 191
79.824 + case 13: stack.push(arg2); // 28
79.825 + case 14: stack.push(arg0); // 42
79.826 + case 15: stack.push(stack.pop().count); // 180 1 97
79.827 + case 18: if (stack.pop() >= stack.pop()) { gt = 30; continue; } // 164 0 12
79.828 + case 21: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.829 + case 24: stack.push(stack[stack.length - 1]); // 89
79.830 + case 25: stack.push(arg2); // 28
79.831 + case 26: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.832 + case 29: // 191
79.833 + case 30: stack.push(arg1); // 27
79.834 + case 31: stack.push(arg2); // 28
79.835 + case 32: if (stack.pop() >= stack.pop()) { gt = 46; continue; } // 164 0 14
79.836 + case 35: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.837 + case 38: stack.push(stack[stack.length - 1]); // 89
79.838 + case 39: stack.push(arg2); // 28
79.839 + case 40: stack.push(arg1); // 27
79.840 + case 41: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.841 + case 42: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.842 + case 45: // 191
79.843 + case 46: stack.push(arg4); // 21 4
79.844 + case 48: arg5 = stack.pop() // 54 5
79.845 + case 50: stack.push(arg0); // 42
79.846 + case 51: stack.push(stack.pop().offset); // 180 1 99
79.847 + case 54: stack.push(arg2); // 28
79.848 + case 55: stack.push(stack.pop() + stack.pop()); // 96
79.849 + case 56: arg6 = stack.pop() // 54 6
79.850 + case 58: stack.push(arg0); // 42
79.851 + case 59: stack.push(stack.pop().offset); // 180 1 99
79.852 + case 62: stack.push(arg1); // 27
79.853 + case 63: stack.push(stack.pop() + stack.pop()); // 96
79.854 + case 64: arg7 = stack.pop() // 54 7
79.855 + case 66: stack.push(arg0); // 42
79.856 + case 67: stack.push(stack.pop().value); // 180 1 100
79.857 + case 70: arg8 = stack.pop() // 58 8
79.858 + case 72: stack.push(arg7); // 21 7
79.859 + case 74: stack.push(arg6); // 21 6
79.860 + case 76: if (stack.pop() <= stack.pop()) { gt = 98; continue; } // 162 0 22
79.861 + case 79: stack.push(arg3); // 45
79.862 + case 80: stack.push(arg5); // 21 5
79.863 + case 82: arg5++; // 132 5 1
79.864 + case 85: stack.push(arg8); // 25 8
79.865 + case 87: stack.push(arg7); // 21 7
79.866 + case 89: arg7++; // 132 7 1
79.867 + case 92: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.868 + case 93: // number conversion // 145
79.869 + case 94: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 84
79.870 + case 95: gt = 72; continue; // 167 255 233
79.871 + case 98: return; // 177
79.872 + }
79.873 +}
79.874 +function java_lang_String_getBytesABLjava_lang_String(arg0,arg1) {
79.875 + var arg2;
79.876 +;
79.877 + var stack = new Array(4);
79.878 + var gt = 0;
79.879 + for(;;) switch(gt) {
79.880 + case 0: stack.push(arg1); // 43
79.881 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11
79.882 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198
79.883 + case 7: stack.push(stack[stack.length - 1]); // 89
79.884 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128
79.885 + case 11: // 191
79.886 + case 12: stack.push(arg1); // 43
79.887 + case 13: stack.push(arg0); // 42
79.888 + case 14: stack.push(stack.pop().value); // 180 1 100
79.889 + case 17: stack.push(arg0); // 42
79.890 + case 18: stack.push(stack.pop().offset); // 180 1 99
79.891 + case 21: stack.push(arg0); // 42
79.892 + case 22: stack.push(stack.pop().count); // 180 1 97
79.893 + 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
79.894 + case 28: return stack.pop(); // 176
79.895 + }
79.896 +}
79.897 +function java_lang_String_getBytesABLjava_nio_charset_Charset(arg0,arg1) {
79.898 + var arg2;
79.899 +;
79.900 + var stack = new Array(4);
79.901 + var gt = 0;
79.902 + for(;;) switch(gt) {
79.903 + case 0: stack.push(arg1); // 43
79.904 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11
79.905 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198
79.906 + case 7: stack.push(stack[stack.length - 1]); // 89
79.907 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128
79.908 + case 11: // 191
79.909 + case 12: stack.push(arg1); // 43
79.910 + case 13: stack.push(arg0); // 42
79.911 + case 14: stack.push(stack.pop().value); // 180 1 100
79.912 + case 17: stack.push(arg0); // 42
79.913 + case 18: stack.push(stack.pop().offset); // 180 1 99
79.914 + case 21: stack.push(arg0); // 42
79.915 + case 22: stack.push(stack.pop().count); // 180 1 97
79.916 + 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
79.917 + case 28: return stack.pop(); // 176
79.918 + }
79.919 +}
79.920 +function java_lang_String_getBytesAB(arg0) {
79.921 + var arg1;
79.922 +;
79.923 + var stack = new Array(3);
79.924 + var gt = 0;
79.925 + for(;;) switch(gt) {
79.926 + case 0: stack.push(arg0); // 42
79.927 + case 1: stack.push(stack.pop().value); // 180 1 100
79.928 + case 4: stack.push(arg0); // 42
79.929 + case 5: stack.push(stack.pop().offset); // 180 1 99
79.930 + case 8: stack.push(arg0); // 42
79.931 + case 9: stack.push(stack.pop().count); // 180 1 97
79.932 + 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
79.933 + case 15: return stack.pop(); // 176
79.934 + }
79.935 +}
79.936 +function java_lang_String_equalsZLjava_lang_Object(arg0,arg1) {
79.937 + var arg2;
79.938 + var arg3;
79.939 + var arg4;
79.940 + var arg5;
79.941 + var arg6;
79.942 + var arg7;
79.943 + var arg8;
79.944 +;
79.945 + var stack = new Array(3);
79.946 + var gt = 0;
79.947 + for(;;) switch(gt) {
79.948 + case 0: stack.push(arg0); // 42
79.949 + case 1: stack.push(arg1); // 43
79.950 + case 2: // 166
79.951 + case 3: // 0
79.952 + case 4: stack.push(2); // 5
79.953 + case 5: stack.push(1); // 4
79.954 + case 6: return stack.pop(); // 172
79.955 + case 7: stack.push(arg1); // 43
79.956 + case 8: stack.push(stack.pop().$instOf_java_lang_String ? 1 : 0); // 193 0 200
79.957 + case 11: if (stack.pop() == 0) { gt = 86; continue; } // 153 0 75
79.958 + case 14: stack.push(arg1); // 43
79.959 + case 15: if(stack[stack.length - 1].$instOf_java_lang_String != 1) throw {}; // 192 0 200
79.960 + case 18: arg2 = stack.pop(); // 77
79.961 + case 19: stack.push(arg0); // 42
79.962 + case 20: stack.push(stack.pop().count); // 180 1 97
79.963 + case 23: arg3 = stack.pop(); // 62
79.964 + case 24: stack.push(arg3); // 29
79.965 + case 25: stack.push(arg2); // 44
79.966 + case 26: stack.push(stack.pop().count); // 180 1 97
79.967 + case 29: if (stack.pop() != stack.pop()) { gt = 86; continue; } // 160 0 57
79.968 + case 32: stack.push(arg0); // 42
79.969 + case 33: stack.push(stack.pop().value); // 180 1 100
79.970 + case 36: arg4 = stack.pop() // 58 4
79.971 + case 38: stack.push(arg2); // 44
79.972 + case 39: stack.push(stack.pop().value); // 180 1 100
79.973 + case 42: arg5 = stack.pop() // 58 5
79.974 + case 44: stack.push(arg0); // 42
79.975 + case 45: stack.push(stack.pop().offset); // 180 1 99
79.976 + case 48: arg6 = stack.pop() // 54 6
79.977 + case 50: stack.push(arg2); // 44
79.978 + case 51: stack.push(stack.pop().offset); // 180 1 99
79.979 + case 54: arg7 = stack.pop() // 54 7
79.980 + case 56: stack.push(arg3); // 29
79.981 + case 57: arg3 += 255; // 132 3 255
79.982 + case 60: if (stack.pop() == 0) { gt = 84; continue; } // 153 0 24
79.983 + case 63: stack.push(arg4); // 25 4
79.984 + case 65: stack.push(arg6); // 21 6
79.985 + case 67: arg6++; // 132 6 1
79.986 + case 70: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.987 + case 71: stack.push(arg5); // 25 5
79.988 + case 73: stack.push(arg7); // 21 7
79.989 + case 75: arg7++; // 132 7 1
79.990 + case 78: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.991 + case 79: if (stack.pop() == stack.pop()) { gt = 56; continue; } // 159 255 233
79.992 + case 82: stack.push(0); // 3
79.993 + case 83: return stack.pop(); // 172
79.994 + case 84: stack.push(1); // 4
79.995 + case 85: return stack.pop(); // 172
79.996 + case 86: stack.push(0); // 3
79.997 + case 87: return stack.pop(); // 172
79.998 + }
79.999 +}
79.1000 +function java_lang_String_contentEqualsZLjava_lang_StringBuffer(arg0,arg1) {
79.1001 + var arg2;
79.1002 + var arg3;
79.1003 + var arg4;
79.1004 +;
79.1005 + var stack = new Array(2);
79.1006 + var gt = 0;
79.1007 + for(;;) switch(gt) {
79.1008 + case 0: stack.push(arg1); // 43
79.1009 + case 1: stack.push(stack[stack.length - 1]); // 89
79.1010 + case 2: arg2 = stack.pop(); // 77
79.1011 + case 3: // 194
79.1012 + case 4: stack.push(arg0); // 42
79.1013 + case 5: stack.push(arg1); // 43
79.1014 + case 6: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.contentEqualsZLjava_lang_CharSequence(self, v0)); } // 182 1 146
79.1015 + case 9: stack.push(arg2); // 44
79.1016 + case 10: // 195
79.1017 + case 11: return stack.pop(); // 172
79.1018 + case 12: arg3 = stack.pop(); // 78
79.1019 + case 13: stack.push(arg2); // 44
79.1020 + case 14: // 195
79.1021 + case 15: stack.push(arg3); // 45
79.1022 + case 16: // 191
79.1023 + }
79.1024 +}
79.1025 +function java_lang_String_contentEqualsZLjava_lang_CharSequence(arg0,arg1) {
79.1026 + var arg2;
79.1027 + var arg3;
79.1028 + var arg4;
79.1029 + var arg5;
79.1030 + var arg6;
79.1031 + var arg7;
79.1032 +;
79.1033 + var stack = new Array(3);
79.1034 + var gt = 0;
79.1035 + for(;;) switch(gt) {
79.1036 + case 0: stack.push(arg0); // 42
79.1037 + case 1: stack.push(stack.pop().count); // 180 1 97
79.1038 + case 4: stack.push(arg1); // 43
79.1039 + case 5: { var self = stack.pop(); stack.push(self.lengthI(self)); } // 185 1 188
79.1040 + case 8: // 1
79.1041 + case 9: // 0
79.1042 + case 10: if (stack.pop() == stack.pop()) { gt = 15; continue; } // 159 0 5
79.1043 + case 13: stack.push(0); // 3
79.1044 + case 14: return stack.pop(); // 172
79.1045 + case 15: stack.push(arg1); // 43
79.1046 + case 16: stack.push(stack.pop().$instOf_java_lang_AbstractStringBuilder ? 1 : 0); // 193 0 186
79.1047 + case 19: if (stack.pop() == 0) { gt = 77; continue; } // 153 0 58
79.1048 + case 22: stack.push(arg0); // 42
79.1049 + case 23: stack.push(stack.pop().value); // 180 1 100
79.1050 + case 26: arg2 = stack.pop(); // 77
79.1051 + case 27: stack.push(arg1); // 43
79.1052 + case 28: if(stack[stack.length - 1].$instOf_java_lang_AbstractStringBuilder != 1) throw {}; // 192 0 186
79.1053 + case 31: { var self = stack.pop(); stack.push(self.getValueAC(self)); } // 182 1 103
79.1054 + case 34: arg3 = stack.pop(); // 78
79.1055 + case 35: stack.push(arg0); // 42
79.1056 + case 36: stack.push(stack.pop().offset); // 180 1 99
79.1057 + case 39: arg4 = stack.pop() // 54 4
79.1058 + case 41: stack.push(0); // 3
79.1059 + case 42: arg5 = stack.pop() // 54 5
79.1060 + case 44: stack.push(arg0); // 42
79.1061 + case 45: stack.push(stack.pop().count); // 180 1 97
79.1062 + case 48: arg6 = stack.pop() // 54 6
79.1063 + case 50: stack.push(arg6); // 21 6
79.1064 + case 52: arg6 += 255; // 132 6 255
79.1065 + case 55: if (stack.pop() == 0) { gt = 77; continue; } // 153 0 22
79.1066 + case 58: stack.push(arg2); // 44
79.1067 + case 59: stack.push(arg4); // 21 4
79.1068 + case 61: arg4++; // 132 4 1
79.1069 + case 64: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1070 + case 65: stack.push(arg3); // 45
79.1071 + case 66: stack.push(arg5); // 21 5
79.1072 + case 68: arg5++; // 132 5 1
79.1073 + case 71: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1074 + case 72: if (stack.pop() == stack.pop()) { gt = 50; continue; } // 159 255 234
79.1075 + case 75: stack.push(0); // 3
79.1076 + case 76: return stack.pop(); // 172
79.1077 + case 77: stack.push(arg1); // 43
79.1078 + case 78: stack.push(arg0); // 42
79.1079 + case 79: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.equalsZLjava_lang_Object(self, v0)); } // 182 1 131
79.1080 + case 82: if (stack.pop() == 0) { gt = 87; continue; } // 153 0 5
79.1081 + case 85: stack.push(1); // 4
79.1082 + case 86: return stack.pop(); // 172
79.1083 + case 87: stack.push(arg0); // 42
79.1084 + case 88: stack.push(stack.pop().value); // 180 1 100
79.1085 + case 91: arg2 = stack.pop(); // 77
79.1086 + case 92: stack.push(arg0); // 42
79.1087 + case 93: stack.push(stack.pop().offset); // 180 1 99
79.1088 + case 96: arg3 = stack.pop(); // 62
79.1089 + case 97: stack.push(0); // 3
79.1090 + case 98: arg4 = stack.pop() // 54 4
79.1091 + case 100: stack.push(arg0); // 42
79.1092 + case 101: stack.push(stack.pop().count); // 180 1 97
79.1093 + case 104: arg5 = stack.pop() // 54 5
79.1094 + case 106: stack.push(arg5); // 21 5
79.1095 + case 108: arg5 += 255; // 132 5 255
79.1096 + case 111: if (stack.pop() == 0) { gt = 136; continue; } // 153 0 25
79.1097 + case 114: stack.push(arg2); // 44
79.1098 + case 115: stack.push(arg3); // 29
79.1099 + case 116: arg3++; // 132 3 1
79.1100 + case 119: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1101 + case 120: stack.push(arg1); // 43
79.1102 + case 121: stack.push(arg4); // 21 4
79.1103 + case 123: arg4++; // 132 4 1
79.1104 + case 126: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.charAtCI(self, v0)); } // 185 1 189
79.1105 + case 129: // 2
79.1106 + case 130: // 0
79.1107 + case 131: if (stack.pop() == stack.pop()) { gt = 106; continue; } // 159 255 231
79.1108 + case 134: stack.push(0); // 3
79.1109 + case 135: return stack.pop(); // 172
79.1110 + case 136: stack.push(1); // 4
79.1111 + case 137: return stack.pop(); // 172
79.1112 + }
79.1113 +}
79.1114 +function java_lang_String_equalsIgnoreCaseZLjava_lang_String(arg0,arg1) {
79.1115 + var arg2;
79.1116 +;
79.1117 + var stack = new Array(6);
79.1118 + var gt = 0;
79.1119 + for(;;) switch(gt) {
79.1120 + case 0: stack.push(arg0); // 42
79.1121 + case 1: stack.push(arg1); // 43
79.1122 + case 2: // 166
79.1123 + case 3: // 0
79.1124 + case 4: stack.push(4); // 7
79.1125 + case 5: stack.push(1); // 4
79.1126 + case 6: gt = 44; continue; // 167 0 38
79.1127 + case 9: stack.push(arg1); // 43
79.1128 + case 10: if (!stack.pop()) { gt = 43; continue; } // 198 0 33
79.1129 + case 13: stack.push(arg1); // 43
79.1130 + case 14: stack.push(stack.pop().count); // 180 1 97
79.1131 + case 17: stack.push(arg0); // 42
79.1132 + case 18: stack.push(stack.pop().count); // 180 1 97
79.1133 + case 21: if (stack.pop() != stack.pop()) { gt = 43; continue; } // 160 0 22
79.1134 + case 24: stack.push(arg0); // 42
79.1135 + case 25: stack.push(1); // 4
79.1136 + case 26: stack.push(0); // 3
79.1137 + case 27: stack.push(arg1); // 43
79.1138 + case 28: stack.push(0); // 3
79.1139 + case 29: stack.push(arg0); // 42
79.1140 + case 30: stack.push(stack.pop().count); // 180 1 97
79.1141 + 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
79.1142 + case 36: if (stack.pop() == 0) { gt = 43; continue; } // 153 0 7
79.1143 + case 39: stack.push(1); // 4
79.1144 + case 40: gt = 44; continue; // 167 0 4
79.1145 + case 43: stack.push(0); // 3
79.1146 + case 44: return stack.pop(); // 172
79.1147 + }
79.1148 +}
79.1149 +function java_lang_String_compareToILjava_lang_String(arg0,arg1) {
79.1150 + var arg2;
79.1151 + var arg3;
79.1152 + var arg4;
79.1153 + var arg5;
79.1154 + var arg6;
79.1155 + var arg7;
79.1156 + var arg8;
79.1157 + var arg9;
79.1158 + var arg10;
79.1159 + var arg11;
79.1160 + var arg12;
79.1161 + var arg13;
79.1162 +;
79.1163 + var stack = new Array(2);
79.1164 + var gt = 0;
79.1165 + for(;;) switch(gt) {
79.1166 + case 0: stack.push(arg0); // 42
79.1167 + case 1: stack.push(stack.pop().count); // 180 1 97
79.1168 + case 4: arg2 = stack.pop(); // 61
79.1169 + case 5: stack.push(arg1); // 43
79.1170 + case 6: stack.push(stack.pop().count); // 180 1 97
79.1171 + case 9: arg3 = stack.pop(); // 62
79.1172 + case 10: stack.push(arg2); // 28
79.1173 + case 11: stack.push(arg3); // 29
79.1174 + case 12: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Math_minIII(v0, v1)); } // 184 1 127
79.1175 + case 15: arg4 = stack.pop() // 54 4
79.1176 + case 17: stack.push(arg0); // 42
79.1177 + case 18: stack.push(stack.pop().value); // 180 1 100
79.1178 + case 21: arg5 = stack.pop() // 58 5
79.1179 + case 23: stack.push(arg1); // 43
79.1180 + case 24: stack.push(stack.pop().value); // 180 1 100
79.1181 + case 27: arg6 = stack.pop() // 58 6
79.1182 + case 29: stack.push(arg0); // 42
79.1183 + case 30: stack.push(stack.pop().offset); // 180 1 99
79.1184 + case 33: arg7 = stack.pop() // 54 7
79.1185 + case 35: stack.push(arg1); // 43
79.1186 + case 36: stack.push(stack.pop().offset); // 180 1 99
79.1187 + case 39: arg8 = stack.pop() // 54 8
79.1188 + case 41: stack.push(arg7); // 21 7
79.1189 + case 43: stack.push(arg8); // 21 8
79.1190 + case 45: if (stack.pop() != stack.pop()) { gt = 102; continue; } // 160 0 57
79.1191 + case 48: stack.push(arg7); // 21 7
79.1192 + case 50: arg9 = stack.pop() // 54 9
79.1193 + case 52: stack.push(arg4); // 21 4
79.1194 + case 54: stack.push(arg7); // 21 7
79.1195 + case 56: stack.push(stack.pop() + stack.pop()); // 96
79.1196 + case 57: arg10 = stack.pop() // 54 10
79.1197 + case 59: stack.push(arg9); // 21 9
79.1198 + case 61: stack.push(arg10); // 21 10
79.1199 + case 63: if (stack.pop() <= stack.pop()) { gt = 99; continue; } // 162 0 36
79.1200 + case 66: stack.push(arg5); // 25 5
79.1201 + case 68: stack.push(arg9); // 21 9
79.1202 + case 70: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1203 + case 71: arg11 = stack.pop() // 54 11
79.1204 + case 73: stack.push(arg6); // 25 6
79.1205 + case 75: stack.push(arg9); // 21 9
79.1206 + case 77: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1207 + case 78: arg12 = stack.pop() // 54 12
79.1208 + case 80: stack.push(arg11); // 21 11
79.1209 + case 82: stack.push(arg12); // 21 12
79.1210 + case 84: if (stack.pop() == stack.pop()) { gt = 93; continue; } // 159 0 9
79.1211 + case 87: stack.push(arg11); // 21 11
79.1212 + case 89: stack.push(arg12); // 21 12
79.1213 + case 91: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1214 + case 92: return stack.pop(); // 172
79.1215 + case 93: arg9++; // 132 9 1
79.1216 + case 96: gt = 59; continue; // 167 255 219
79.1217 + case 99: gt = 146; continue; // 167 0 47
79.1218 + case 102: stack.push(arg4); // 21 4
79.1219 + case 104: arg4 += 255; // 132 4 255
79.1220 + case 107: if (stack.pop() == 0) { gt = 146; continue; } // 153 0 39
79.1221 + case 110: stack.push(arg5); // 25 5
79.1222 + case 112: stack.push(arg7); // 21 7
79.1223 + case 114: arg7++; // 132 7 1
79.1224 + case 117: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1225 + case 118: arg9 = stack.pop() // 54 9
79.1226 + case 120: stack.push(arg6); // 25 6
79.1227 + case 122: stack.push(arg8); // 21 8
79.1228 + case 124: arg8++; // 132 8 1
79.1229 + case 127: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1230 + case 128: arg10 = stack.pop() // 54 10
79.1231 + case 130: stack.push(arg9); // 21 9
79.1232 + case 132: stack.push(arg10); // 21 10
79.1233 + case 134: if (stack.pop() == stack.pop()) { gt = 143; continue; } // 159 0 9
79.1234 + case 137: stack.push(arg9); // 21 9
79.1235 + case 139: stack.push(arg10); // 21 10
79.1236 + case 141: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1237 + case 142: return stack.pop(); // 172
79.1238 + case 143: gt = 102; continue; // 167 255 215
79.1239 + case 146: stack.push(arg2); // 28
79.1240 + case 147: stack.push(arg3); // 29
79.1241 + case 148: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1242 + case 149: return stack.pop(); // 172
79.1243 + }
79.1244 +}
79.1245 +function java_lang_String_compareToIgnoreCaseILjava_lang_String(arg0,arg1) {
79.1246 + var arg2;
79.1247 +;
79.1248 + var stack = new Array(3);
79.1249 + var gt = 0;
79.1250 + for(;;) switch(gt) {
79.1251 + case 0: stack.push(java_lang_String_CASE_INSENSITIVE_ORDER); // 178 1 102
79.1252 + case 3: stack.push(arg0); // 42
79.1253 + case 4: stack.push(arg1); // 43
79.1254 + 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
79.1255 + case 8: stack.push(0); // 3
79.1256 + case 9: // 0
79.1257 + case 10: return stack.pop(); // 172
79.1258 + }
79.1259 +}
79.1260 +function java_lang_String_regionMatchesZILjava_lang_StringII(arg0,arg1,arg2,arg3,arg4) {
79.1261 + var arg5;
79.1262 + var arg6;
79.1263 + var arg7;
79.1264 + var arg8;
79.1265 + var arg9;
79.1266 +;
79.1267 + var stack = new Array(6);
79.1268 + var gt = 0;
79.1269 + for(;;) switch(gt) {
79.1270 + case 0: stack.push(arg0); // 42
79.1271 + case 1: stack.push(stack.pop().value); // 180 1 100
79.1272 + case 4: arg5 = stack.pop() // 58 5
79.1273 + case 6: stack.push(arg0); // 42
79.1274 + case 7: stack.push(stack.pop().offset); // 180 1 99
79.1275 + case 10: stack.push(arg1); // 27
79.1276 + case 11: stack.push(stack.pop() + stack.pop()); // 96
79.1277 + case 12: arg6 = stack.pop() // 54 6
79.1278 + case 14: stack.push(arg2); // 44
79.1279 + case 15: stack.push(stack.pop().value); // 180 1 100
79.1280 + case 18: arg7 = stack.pop() // 58 7
79.1281 + case 20: stack.push(arg2); // 44
79.1282 + case 21: stack.push(stack.pop().offset); // 180 1 99
79.1283 + case 24: stack.push(arg3); // 29
79.1284 + case 25: stack.push(stack.pop() + stack.pop()); // 96
79.1285 + case 26: arg8 = stack.pop() // 54 8
79.1286 + case 28: stack.push(arg3); // 29
79.1287 + case 29: if (stack.pop() < 0) { gt = 66; continue; } // 155 0 37
79.1288 + case 32: stack.push(arg1); // 27
79.1289 + case 33: if (stack.pop() < 0) { gt = 66; continue; } // 155 0 33
79.1290 + case 36: stack.push(arg1); // 27
79.1291 + case 37: // number conversion // 133
79.1292 + case 38: stack.push(arg0); // 42
79.1293 + case 39: stack.push(stack.pop().count); // 180 1 97
79.1294 + case 42: // number conversion // 133
79.1295 + case 43: stack.push(arg4); // 21 4
79.1296 + case 45: // number conversion // 133
79.1297 + case 46: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101
79.1298 + case 47: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148
79.1299 + case 48: if (stack.pop() > 0) { gt = 66; continue; } // 157 0 18
79.1300 + case 51: stack.push(arg3); // 29
79.1301 + case 52: // number conversion // 133
79.1302 + case 53: stack.push(arg2); // 44
79.1303 + case 54: stack.push(stack.pop().count); // 180 1 97
79.1304 + case 57: // number conversion // 133
79.1305 + case 58: stack.push(arg4); // 21 4
79.1306 + case 60: // number conversion // 133
79.1307 + case 61: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101
79.1308 + case 62: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148
79.1309 + case 63: if (stack.pop() <= 0) { gt = 68; continue; } // 158 0 5
79.1310 + case 66: stack.push(0); // 3
79.1311 + case 67: return stack.pop(); // 172
79.1312 + case 68: stack.push(arg4); // 21 4
79.1313 + case 70: arg4 += 255; // 132 4 255
79.1314 + case 73: if (stack.pop() <= 0) { gt = 97; continue; } // 158 0 24
79.1315 + case 76: stack.push(arg5); // 25 5
79.1316 + case 78: stack.push(arg6); // 21 6
79.1317 + case 80: arg6++; // 132 6 1
79.1318 + case 83: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1319 + case 84: stack.push(arg7); // 25 7
79.1320 + case 86: stack.push(arg8); // 21 8
79.1321 + case 88: arg8++; // 132 8 1
79.1322 + case 91: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1323 + case 92: if (stack.pop() == stack.pop()) { gt = 68; continue; } // 159 255 232
79.1324 + case 95: stack.push(0); // 3
79.1325 + case 96: return stack.pop(); // 172
79.1326 + case 97: stack.push(1); // 4
79.1327 + case 98: return stack.pop(); // 172
79.1328 + }
79.1329 +}
79.1330 +function java_lang_String_regionMatchesZZILjava_lang_StringII(arg0,arg1,arg2,arg3,arg4,arg5) {
79.1331 + var arg6;
79.1332 + var arg7;
79.1333 + var arg8;
79.1334 + var arg9;
79.1335 + var arg10;
79.1336 + var arg11;
79.1337 + var arg12;
79.1338 + var arg13;
79.1339 + var arg14;
79.1340 +;
79.1341 + var stack = new Array(6);
79.1342 + var gt = 0;
79.1343 + for(;;) switch(gt) {
79.1344 + case 0: stack.push(arg0); // 42
79.1345 + case 1: stack.push(stack.pop().value); // 180 1 100
79.1346 + case 4: arg6 = stack.pop() // 58 6
79.1347 + case 6: stack.push(arg0); // 42
79.1348 + case 7: stack.push(stack.pop().offset); // 180 1 99
79.1349 + case 10: stack.push(arg2); // 28
79.1350 + case 11: stack.push(stack.pop() + stack.pop()); // 96
79.1351 + case 12: arg7 = stack.pop() // 54 7
79.1352 + case 14: stack.push(arg3); // 45
79.1353 + case 15: stack.push(stack.pop().value); // 180 1 100
79.1354 + case 18: arg8 = stack.pop() // 58 8
79.1355 + case 20: stack.push(arg3); // 45
79.1356 + case 21: stack.push(stack.pop().offset); // 180 1 99
79.1357 + case 24: stack.push(arg4); // 21 4
79.1358 + case 26: stack.push(stack.pop() + stack.pop()); // 96
79.1359 + case 27: arg9 = stack.pop() // 54 9
79.1360 + case 29: stack.push(arg4); // 21 4
79.1361 + case 31: if (stack.pop() < 0) { gt = 69; continue; } // 155 0 38
79.1362 + case 34: stack.push(arg2); // 28
79.1363 + case 35: if (stack.pop() < 0) { gt = 69; continue; } // 155 0 34
79.1364 + case 38: stack.push(arg2); // 28
79.1365 + case 39: // number conversion // 133
79.1366 + case 40: stack.push(arg0); // 42
79.1367 + case 41: stack.push(stack.pop().count); // 180 1 97
79.1368 + case 44: // number conversion // 133
79.1369 + case 45: stack.push(arg5); // 21 5
79.1370 + case 47: // number conversion // 133
79.1371 + case 48: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101
79.1372 + case 49: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148
79.1373 + case 50: if (stack.pop() > 0) { gt = 69; continue; } // 157 0 19
79.1374 + case 53: stack.push(arg4); // 21 4
79.1375 + case 55: // number conversion // 133
79.1376 + case 56: stack.push(arg3); // 45
79.1377 + case 57: stack.push(stack.pop().count); // 180 1 97
79.1378 + case 60: // number conversion // 133
79.1379 + case 61: stack.push(arg5); // 21 5
79.1380 + case 63: // number conversion // 133
79.1381 + case 64: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 101
79.1382 + case 65: { var delta = stack.pop() - stack.pop(); stack.push(delta < 0 ?-1 : (delta == 0 ? 0 : 1)); } // 148
79.1383 + case 66: if (stack.pop() <= 0) { gt = 71; continue; } // 158 0 5
79.1384 + case 69: stack.push(0); // 3
79.1385 + case 70: return stack.pop(); // 172
79.1386 + case 71: stack.push(arg5); // 21 5
79.1387 + case 73: arg5 += 255; // 132 5 255
79.1388 + case 76: if (stack.pop() <= 0) { gt = 155; continue; } // 158 0 79
79.1389 + case 79: stack.push(arg6); // 25 6
79.1390 + case 81: stack.push(arg7); // 21 7
79.1391 + case 83: arg7++; // 132 7 1
79.1392 + case 86: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1393 + case 87: arg10 = stack.pop() // 54 10
79.1394 + case 89: stack.push(arg8); // 25 8
79.1395 + case 91: stack.push(arg9); // 21 9
79.1396 + case 93: arg9++; // 132 9 1
79.1397 + case 96: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1398 + case 97: arg11 = stack.pop() // 54 11
79.1399 + case 99: stack.push(arg10); // 21 10
79.1400 + case 101: stack.push(arg11); // 21 11
79.1401 + case 103: if (stack.pop() != stack.pop()) { gt = 109; continue; } // 160 0 6
79.1402 + case 106: gt = 71; continue; // 167 255 221
79.1403 + case 109: stack.push(arg1); // 27
79.1404 + case 110: if (stack.pop() == 0) { gt = 153; continue; } // 153 0 43
79.1405 + case 113: stack.push(arg10); // 21 10
79.1406 + case 115: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseCC(v0)); } // 184 1 105
79.1407 + case 118: arg12 = stack.pop() // 54 12
79.1408 + case 120: stack.push(arg11); // 21 11
79.1409 + case 122: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseCC(v0)); } // 184 1 105
79.1410 + case 125: arg13 = stack.pop() // 54 13
79.1411 + case 127: stack.push(arg12); // 21 12
79.1412 + case 129: stack.push(arg13); // 21 13
79.1413 + case 131: if (stack.pop() != stack.pop()) { gt = 137; continue; } // 160 0 6
79.1414 + case 134: gt = 71; continue; // 167 255 193
79.1415 + case 137: stack.push(arg12); // 21 12
79.1416 + case 139: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseCC(v0)); } // 184 1 104
79.1417 + case 142: stack.push(arg13); // 21 13
79.1418 + case 144: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseCC(v0)); } // 184 1 104
79.1419 + case 147: if (stack.pop() != stack.pop()) { gt = 153; continue; } // 160 0 6
79.1420 + case 150: gt = 71; continue; // 167 255 177
79.1421 + case 153: stack.push(0); // 3
79.1422 + case 154: return stack.pop(); // 172
79.1423 + case 155: stack.push(1); // 4
79.1424 + case 156: return stack.pop(); // 172
79.1425 + }
79.1426 +}
79.1427 +function java_lang_String_startsWithZLjava_lang_StringI(arg0,arg1,arg2) {
79.1428 + var arg3;
79.1429 + var arg4;
79.1430 + var arg5;
79.1431 + var arg6;
79.1432 + var arg7;
79.1433 + var arg8;
79.1434 +;
79.1435 + var stack = new Array(3);
79.1436 + var gt = 0;
79.1437 + for(;;) switch(gt) {
79.1438 + case 0: stack.push(arg0); // 42
79.1439 + case 1: stack.push(stack.pop().value); // 180 1 100
79.1440 + case 4: arg3 = stack.pop(); // 78
79.1441 + case 5: stack.push(arg0); // 42
79.1442 + case 6: stack.push(stack.pop().offset); // 180 1 99
79.1443 + case 9: stack.push(arg2); // 28
79.1444 + case 10: stack.push(stack.pop() + stack.pop()); // 96
79.1445 + case 11: arg4 = stack.pop() // 54 4
79.1446 + case 13: stack.push(arg1); // 43
79.1447 + case 14: stack.push(stack.pop().value); // 180 1 100
79.1448 + case 17: arg5 = stack.pop() // 58 5
79.1449 + case 19: stack.push(arg1); // 43
79.1450 + case 20: stack.push(stack.pop().offset); // 180 1 99
79.1451 + case 23: arg6 = stack.pop() // 54 6
79.1452 + case 25: stack.push(arg1); // 43
79.1453 + case 26: stack.push(stack.pop().count); // 180 1 97
79.1454 + case 29: arg7 = stack.pop() // 54 7
79.1455 + case 31: stack.push(arg2); // 28
79.1456 + case 32: if (stack.pop() < 0) { gt = 46; continue; } // 155 0 14
79.1457 + case 35: stack.push(arg2); // 28
79.1458 + case 36: stack.push(arg0); // 42
79.1459 + case 37: stack.push(stack.pop().count); // 180 1 97
79.1460 + case 40: stack.push(arg7); // 21 7
79.1461 + case 42: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1462 + case 43: if (stack.pop() >= stack.pop()) { gt = 48; continue; } // 164 0 5
79.1463 + case 46: stack.push(0); // 3
79.1464 + case 47: return stack.pop(); // 172
79.1465 + case 48: arg7 += 255; // 132 7 255
79.1466 + case 51: stack.push(arg7); // 21 7
79.1467 + case 53: if (stack.pop() < 0) { gt = 76; continue; } // 155 0 23
79.1468 + case 56: stack.push(arg3); // 45
79.1469 + case 57: stack.push(arg4); // 21 4
79.1470 + case 59: arg4++; // 132 4 1
79.1471 + case 62: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1472 + case 63: stack.push(arg5); // 25 5
79.1473 + case 65: stack.push(arg6); // 21 6
79.1474 + case 67: arg6++; // 132 6 1
79.1475 + case 70: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1476 + case 71: if (stack.pop() == stack.pop()) { gt = 48; continue; } // 159 255 233
79.1477 + case 74: stack.push(0); // 3
79.1478 + case 75: return stack.pop(); // 172
79.1479 + case 76: stack.push(1); // 4
79.1480 + case 77: return stack.pop(); // 172
79.1481 + }
79.1482 +}
79.1483 +function java_lang_String_startsWithZLjava_lang_String(arg0,arg1) {
79.1484 + var arg2;
79.1485 +;
79.1486 + var stack = new Array(3);
79.1487 + var gt = 0;
79.1488 + for(;;) switch(gt) {
79.1489 + case 0: stack.push(arg0); // 42
79.1490 + case 1: stack.push(arg1); // 43
79.1491 + case 2: stack.push(0); // 3
79.1492 + 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
79.1493 + case 6: return stack.pop(); // 172
79.1494 + }
79.1495 +}
79.1496 +function java_lang_String_endsWithZLjava_lang_String(arg0,arg1) {
79.1497 + var arg2;
79.1498 +;
79.1499 + var stack = new Array(4);
79.1500 + var gt = 0;
79.1501 + for(;;) switch(gt) {
79.1502 + case 0: stack.push(arg0); // 42
79.1503 + case 1: stack.push(arg1); // 43
79.1504 + case 2: stack.push(arg0); // 42
79.1505 + case 3: stack.push(stack.pop().count); // 180 1 97
79.1506 + case 6: stack.push(arg1); // 43
79.1507 + case 7: stack.push(stack.pop().count); // 180 1 97
79.1508 + case 10: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1509 + 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
79.1510 + case 14: return stack.pop(); // 172
79.1511 + }
79.1512 +}
79.1513 +function java_lang_String_hashCodeI(arg0) {
79.1514 + var arg1;
79.1515 + var arg2;
79.1516 + var arg3;
79.1517 + var arg4;
79.1518 + var arg5;
79.1519 + var arg6;
79.1520 +;
79.1521 + var stack = new Array(3);
79.1522 + var gt = 0;
79.1523 + for(;;) switch(gt) {
79.1524 + case 0: stack.push(arg0); // 42
79.1525 + case 1: stack.push(stack.pop().hash); // 180 1 98
79.1526 + case 4: arg1 = stack.pop(); // 60
79.1527 + case 5: stack.push(arg0); // 42
79.1528 + case 6: stack.push(stack.pop().count); // 180 1 97
79.1529 + case 9: arg2 = stack.pop(); // 61
79.1530 + case 10: stack.push(arg1); // 27
79.1531 + case 11: if (stack.pop() != 0) { gt = 62; continue; } // 154 0 51
79.1532 + case 14: stack.push(arg2); // 28
79.1533 + case 15: if (stack.pop() <= 0) { gt = 62; continue; } // 158 0 47
79.1534 + case 18: stack.push(arg0); // 42
79.1535 + case 19: stack.push(stack.pop().offset); // 180 1 99
79.1536 + case 22: arg3 = stack.pop(); // 62
79.1537 + case 23: stack.push(arg0); // 42
79.1538 + case 24: stack.push(stack.pop().value); // 180 1 100
79.1539 + case 27: arg4 = stack.pop() // 58 4
79.1540 + case 29: stack.push(0); // 3
79.1541 + case 30: arg5 = stack.pop() // 54 5
79.1542 + case 32: stack.push(arg5); // 21 5
79.1543 + case 34: stack.push(arg2); // 28
79.1544 + case 35: if (stack.pop() <= stack.pop()) { gt = 57; continue; } // 162 0 22
79.1545 + case 38: stack.push(31); // 16 31
79.1546 + case 40: stack.push(arg1); // 27
79.1547 + case 41: stack.push(stack.pop() * stack.pop()); // 104
79.1548 + case 42: stack.push(arg4); // 25 4
79.1549 + case 44: stack.push(arg3); // 29
79.1550 + case 45: arg3++; // 132 3 1
79.1551 + case 48: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1552 + case 49: stack.push(stack.pop() + stack.pop()); // 96
79.1553 + case 50: arg1 = stack.pop(); // 60
79.1554 + case 51: arg5++; // 132 5 1
79.1555 + case 54: gt = 32; continue; // 167 255 234
79.1556 + case 57: stack.push(arg0); // 42
79.1557 + case 58: stack.push(arg1); // 27
79.1558 + case 59: { var v = stack.pop(); stack.pop().hash = v; } // 181 1 98
79.1559 + case 62: stack.push(arg1); // 27
79.1560 + case 63: return stack.pop(); // 172
79.1561 + }
79.1562 +}
79.1563 +function java_lang_String_indexOfII(arg0,arg1) {
79.1564 + var arg2;
79.1565 +;
79.1566 + var stack = new Array(3);
79.1567 + var gt = 0;
79.1568 + for(;;) switch(gt) {
79.1569 + case 0: stack.push(arg0); // 42
79.1570 + case 1: stack.push(arg1); // 27
79.1571 + case 2: stack.push(0); // 3
79.1572 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.indexOfIII(self, v0, v1)); } // 182 1 135
79.1573 + case 6: return stack.pop(); // 172
79.1574 + }
79.1575 +}
79.1576 +function java_lang_String_indexOfIII(arg0,arg1,arg2) {
79.1577 + var arg3;
79.1578 + var arg4;
79.1579 + var arg5;
79.1580 + var arg6;
79.1581 + var arg7;
79.1582 +;
79.1583 + var stack = new Array(3);
79.1584 + var gt = 0;
79.1585 + for(;;) switch(gt) {
79.1586 + case 0: stack.push(arg0); // 42
79.1587 + case 1: stack.push(stack.pop().offset); // 180 1 99
79.1588 + case 4: stack.push(arg0); // 42
79.1589 + case 5: stack.push(stack.pop().count); // 180 1 97
79.1590 + case 8: stack.push(stack.pop() + stack.pop()); // 96
79.1591 + case 9: arg3 = stack.pop(); // 62
79.1592 + case 10: stack.push(arg0); // 42
79.1593 + case 11: stack.push(stack.pop().value); // 180 1 100
79.1594 + case 14: arg4 = stack.pop() // 58 4
79.1595 + case 16: stack.push(arg2); // 28
79.1596 + case 17: if (stack.pop() >= 0) { gt = 25; continue; } // 156 0 8
79.1597 + case 20: stack.push(0); // 3
79.1598 + case 21: arg2 = stack.pop(); // 61
79.1599 + case 22: gt = 35; continue; // 167 0 13
79.1600 + case 25: stack.push(arg2); // 28
79.1601 + case 26: stack.push(arg0); // 42
79.1602 + case 27: stack.push(stack.pop().count); // 180 1 97
79.1603 + case 30: if (stack.pop() > stack.pop()) { gt = 35; continue; } // 161 0 5
79.1604 + case 33: // 2
79.1605 + case 34: return stack.pop(); // 172
79.1606 + case 35: stack.push(arg0); // 42
79.1607 + case 36: stack.push(stack.pop().offset); // 180 1 99
79.1608 + case 39: stack.push(arg2); // 28
79.1609 + case 40: stack.push(stack.pop() + stack.pop()); // 96
79.1610 + case 41: arg5 = stack.pop() // 54 5
79.1611 + case 43: stack.push(arg1); // 27
79.1612 + case 44: stack.push(65536); // 18 3
79.1613 + case 46: if (stack.pop() <= stack.pop()) { gt = 80; continue; } // 162 0 34
79.1614 + case 49: stack.push(arg5); // 21 5
79.1615 + case 51: stack.push(arg3); // 29
79.1616 + case 52: if (stack.pop() <= stack.pop()) { gt = 78; continue; } // 162 0 26
79.1617 + case 55: stack.push(arg4); // 25 4
79.1618 + case 57: stack.push(arg5); // 21 5
79.1619 + case 59: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1620 + case 60: stack.push(arg1); // 27
79.1621 + case 61: if (stack.pop() != stack.pop()) { gt = 72; continue; } // 160 0 11
79.1622 + case 64: stack.push(arg5); // 21 5
79.1623 + case 66: stack.push(arg0); // 42
79.1624 + case 67: stack.push(stack.pop().offset); // 180 1 99
79.1625 + case 70: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1626 + case 71: return stack.pop(); // 172
79.1627 + case 72: arg5++; // 132 5 1
79.1628 + case 75: gt = 49; continue; // 167 255 230
79.1629 + case 78: // 2
79.1630 + case 79: return stack.pop(); // 172
79.1631 + case 80: stack.push(arg1); // 27
79.1632 + case 81: stack.push(1114111); // 18 4
79.1633 + case 83: if (stack.pop() < stack.pop()) { gt = 149; continue; } // 163 0 66
79.1634 + case 86: stack.push(arg1); // 27
79.1635 + case 87: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109
79.1636 + case 90: arg6 = stack.pop() // 58 6
79.1637 + case 92: stack.push(arg5); // 21 5
79.1638 + case 94: stack.push(arg3); // 29
79.1639 + case 95: if (stack.pop() <= stack.pop()) { gt = 149; continue; } // 162 0 54
79.1640 + case 98: stack.push(arg4); // 25 4
79.1641 + case 100: stack.push(arg5); // 21 5
79.1642 + case 102: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1643 + case 103: stack.push(arg6); // 25 6
79.1644 + case 105: stack.push(0); // 3
79.1645 + case 106: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1646 + case 107: if (stack.pop() != stack.pop()) { gt = 143; continue; } // 160 0 36
79.1647 + case 110: stack.push(arg5); // 21 5
79.1648 + case 112: stack.push(1); // 4
79.1649 + case 113: stack.push(stack.pop() + stack.pop()); // 96
79.1650 + case 114: stack.push(arg3); // 29
79.1651 + case 115: if (stack.pop() != stack.pop()) { gt = 121; continue; } // 160 0 6
79.1652 + case 118: gt = 149; continue; // 167 0 31
79.1653 + case 121: stack.push(arg4); // 25 4
79.1654 + case 123: stack.push(arg5); // 21 5
79.1655 + case 125: stack.push(1); // 4
79.1656 + case 126: stack.push(stack.pop() + stack.pop()); // 96
79.1657 + case 127: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1658 + case 128: stack.push(arg6); // 25 6
79.1659 + case 130: stack.push(1); // 4
79.1660 + case 131: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1661 + case 132: if (stack.pop() != stack.pop()) { gt = 143; continue; } // 160 0 11
79.1662 + case 135: stack.push(arg5); // 21 5
79.1663 + case 137: stack.push(arg0); // 42
79.1664 + case 138: stack.push(stack.pop().offset); // 180 1 99
79.1665 + case 141: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1666 + case 142: return stack.pop(); // 172
79.1667 + case 143: arg5++; // 132 5 1
79.1668 + case 146: gt = 92; continue; // 167 255 202
79.1669 + case 149: // 2
79.1670 + case 150: return stack.pop(); // 172
79.1671 + }
79.1672 +}
79.1673 +function java_lang_String_lastIndexOfII(arg0,arg1) {
79.1674 + var arg2;
79.1675 +;
79.1676 + var stack = new Array(4);
79.1677 + var gt = 0;
79.1678 + for(;;) switch(gt) {
79.1679 + case 0: stack.push(arg0); // 42
79.1680 + case 1: stack.push(arg1); // 27
79.1681 + case 2: stack.push(arg0); // 42
79.1682 + case 3: stack.push(stack.pop().count); // 180 1 97
79.1683 + case 6: stack.push(1); // 4
79.1684 + case 7: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1685 + case 8: { var v1 = stack.pop(); var v0 = stack.pop(); var self = stack.pop(); stack.push(self.lastIndexOfIII(self, v0, v1)); } // 182 1 136
79.1686 + case 11: return stack.pop(); // 172
79.1687 + }
79.1688 +}
79.1689 +function java_lang_String_lastIndexOfIII(arg0,arg1,arg2) {
79.1690 + var arg3;
79.1691 + var arg4;
79.1692 + var arg5;
79.1693 + var arg6;
79.1694 + var arg7;
79.1695 + var arg8;
79.1696 +;
79.1697 + var stack = new Array(3);
79.1698 + var gt = 0;
79.1699 + for(;;) switch(gt) {
79.1700 + case 0: stack.push(arg0); // 42
79.1701 + case 1: stack.push(stack.pop().offset); // 180 1 99
79.1702 + case 4: arg3 = stack.pop(); // 62
79.1703 + case 5: stack.push(arg0); // 42
79.1704 + case 6: stack.push(stack.pop().value); // 180 1 100
79.1705 + case 9: arg4 = stack.pop() // 58 4
79.1706 + case 11: stack.push(arg0); // 42
79.1707 + case 12: stack.push(stack.pop().offset); // 180 1 99
79.1708 + case 15: stack.push(arg2); // 28
79.1709 + case 16: stack.push(arg0); // 42
79.1710 + case 17: stack.push(stack.pop().count); // 180 1 97
79.1711 + case 20: if (stack.pop() > stack.pop()) { gt = 32; continue; } // 161 0 12
79.1712 + case 23: stack.push(arg0); // 42
79.1713 + case 24: stack.push(stack.pop().count); // 180 1 97
79.1714 + case 27: stack.push(1); // 4
79.1715 + case 28: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1716 + case 29: gt = 33; continue; // 167 0 4
79.1717 + case 32: stack.push(arg2); // 28
79.1718 + case 33: stack.push(stack.pop() + stack.pop()); // 96
79.1719 + case 34: arg5 = stack.pop() // 54 5
79.1720 + case 36: stack.push(arg1); // 27
79.1721 + case 37: stack.push(65536); // 18 3
79.1722 + case 39: if (stack.pop() <= stack.pop()) { gt = 73; continue; } // 162 0 34
79.1723 + case 42: stack.push(arg5); // 21 5
79.1724 + case 44: stack.push(arg3); // 29
79.1725 + case 45: if (stack.pop() > stack.pop()) { gt = 71; continue; } // 161 0 26
79.1726 + case 48: stack.push(arg4); // 25 4
79.1727 + case 50: stack.push(arg5); // 21 5
79.1728 + case 52: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1729 + case 53: stack.push(arg1); // 27
79.1730 + case 54: if (stack.pop() != stack.pop()) { gt = 65; continue; } // 160 0 11
79.1731 + case 57: stack.push(arg5); // 21 5
79.1732 + case 59: stack.push(arg0); // 42
79.1733 + case 60: stack.push(stack.pop().offset); // 180 1 99
79.1734 + case 63: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1735 + case 64: return stack.pop(); // 172
79.1736 + case 65: arg5 += 255; // 132 5 255
79.1737 + case 68: gt = 42; continue; // 167 255 230
79.1738 + case 71: // 2
79.1739 + case 72: return stack.pop(); // 172
79.1740 + case 73: stack.push(arg0); // 42
79.1741 + case 74: stack.push(stack.pop().offset); // 180 1 99
79.1742 + case 77: stack.push(arg0); // 42
79.1743 + case 78: stack.push(stack.pop().count); // 180 1 97
79.1744 + case 81: stack.push(stack.pop() + stack.pop()); // 96
79.1745 + case 82: arg6 = stack.pop() // 54 6
79.1746 + case 84: stack.push(arg1); // 27
79.1747 + case 85: stack.push(1114111); // 18 4
79.1748 + case 87: if (stack.pop() < stack.pop()) { gt = 154; continue; } // 163 0 67
79.1749 + case 90: stack.push(arg1); // 27
79.1750 + case 91: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109
79.1751 + case 94: arg7 = stack.pop() // 58 7
79.1752 + case 96: stack.push(arg5); // 21 5
79.1753 + case 98: stack.push(arg3); // 29
79.1754 + case 99: if (stack.pop() > stack.pop()) { gt = 154; continue; } // 161 0 55
79.1755 + case 102: stack.push(arg4); // 25 4
79.1756 + case 104: stack.push(arg5); // 21 5
79.1757 + case 106: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1758 + case 107: stack.push(arg7); // 25 7
79.1759 + case 109: stack.push(0); // 3
79.1760 + case 110: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1761 + case 111: if (stack.pop() != stack.pop()) { gt = 148; continue; } // 160 0 37
79.1762 + case 114: stack.push(arg5); // 21 5
79.1763 + case 116: stack.push(1); // 4
79.1764 + case 117: stack.push(stack.pop() + stack.pop()); // 96
79.1765 + case 118: stack.push(arg6); // 21 6
79.1766 + case 120: if (stack.pop() != stack.pop()) { gt = 126; continue; } // 160 0 6
79.1767 + case 123: gt = 154; continue; // 167 0 31
79.1768 + case 126: stack.push(arg4); // 25 4
79.1769 + case 128: stack.push(arg5); // 21 5
79.1770 + case 130: stack.push(1); // 4
79.1771 + case 131: stack.push(stack.pop() + stack.pop()); // 96
79.1772 + case 132: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1773 + case 133: stack.push(arg7); // 25 7
79.1774 + case 135: stack.push(1); // 4
79.1775 + case 136: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1776 + case 137: if (stack.pop() != stack.pop()) { gt = 148; continue; } // 160 0 11
79.1777 + case 140: stack.push(arg5); // 21 5
79.1778 + case 142: stack.push(arg0); // 42
79.1779 + case 143: stack.push(stack.pop().offset); // 180 1 99
79.1780 + case 146: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1781 + case 147: return stack.pop(); // 172
79.1782 + case 148: arg5 += 255; // 132 5 255
79.1783 + case 151: gt = 96; continue; // 167 255 201
79.1784 + case 154: // 2
79.1785 + case 155: return stack.pop(); // 172
79.1786 + }
79.1787 +}
79.1788 +function java_lang_String_indexOfILjava_lang_String(arg0,arg1) {
79.1789 + var arg2;
79.1790 +;
79.1791 + var stack = new Array(3);
79.1792 + var gt = 0;
79.1793 + for(;;) switch(gt) {
79.1794 + case 0: stack.push(arg0); // 42
79.1795 + case 1: stack.push(arg1); // 43
79.1796 + case 2: stack.push(0); // 3
79.1797 + 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
79.1798 + case 6: return stack.pop(); // 172
79.1799 + }
79.1800 +}
79.1801 +function java_lang_String_indexOfILjava_lang_StringI(arg0,arg1,arg2) {
79.1802 + var arg3;
79.1803 +;
79.1804 + var stack = new Array(7);
79.1805 + var gt = 0;
79.1806 + for(;;) switch(gt) {
79.1807 + case 0: stack.push(arg0); // 42
79.1808 + case 1: stack.push(stack.pop().value); // 180 1 100
79.1809 + case 4: stack.push(arg0); // 42
79.1810 + case 5: stack.push(stack.pop().offset); // 180 1 99
79.1811 + case 8: stack.push(arg0); // 42
79.1812 + case 9: stack.push(stack.pop().count); // 180 1 97
79.1813 + case 12: stack.push(arg1); // 43
79.1814 + case 13: stack.push(stack.pop().value); // 180 1 100
79.1815 + case 16: stack.push(arg1); // 43
79.1816 + case 17: stack.push(stack.pop().offset); // 180 1 99
79.1817 + case 20: stack.push(arg1); // 43
79.1818 + case 21: stack.push(stack.pop().count); // 180 1 97
79.1819 + case 24: stack.push(arg2); // 28
79.1820 + 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
79.1821 + case 28: return stack.pop(); // 172
79.1822 + }
79.1823 +}
79.1824 +function java_lang_String_indexOfIACIIACIII(arg0,arg1,arg2,arg3,arg4,arg5,arg6) {
79.1825 + var arg7;
79.1826 + var arg8;
79.1827 + var arg9;
79.1828 + var arg10;
79.1829 + var arg11;
79.1830 + var arg12;
79.1831 + var stack = new Array();
79.1832 + var gt = 0;
79.1833 + for(;;) switch(gt) {
79.1834 + case 0: stack.push(arg6); // 21 6
79.1835 + case 2: stack.push(arg2); // 28
79.1836 + case 3: if (stack.pop() > stack.pop()) { gt = 17; continue; } // 161 0 14
79.1837 + case 6: stack.push(arg5); // 21 5
79.1838 + case 8: if (stack.pop() != 0) { gt = 15; continue; } // 154 0 7
79.1839 + case 11: stack.push(arg2); // 28
79.1840 + case 12: gt = 16; continue; // 167 0 4
79.1841 + case 15: // 2
79.1842 + case 16: return stack.pop(); // 172
79.1843 + case 17: stack.push(arg6); // 21 6
79.1844 + case 19: if (stack.pop() >= 0) { gt = 25; continue; } // 156 0 6
79.1845 + case 22: stack.push(0); // 3
79.1846 + case 23: arg6 = stack.pop() // 54 6
79.1847 + case 25: stack.push(arg5); // 21 5
79.1848 + case 27: if (stack.pop() != 0) { gt = 33; continue; } // 154 0 6
79.1849 + case 30: stack.push(arg6); // 21 6
79.1850 + case 32: return stack.pop(); // 172
79.1851 + case 33: stack.push(arg3); // 45
79.1852 + case 34: stack.push(arg4); // 21 4
79.1853 + case 36: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1854 + case 37: arg7 = stack.pop() // 54 7
79.1855 + case 39: stack.push(arg1); // 27
79.1856 + case 40: stack.push(arg2); // 28
79.1857 + case 41: stack.push(arg5); // 21 5
79.1858 + case 43: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1859 + case 44: stack.push(stack.pop() + stack.pop()); // 96
79.1860 + case 45: arg8 = stack.pop() // 54 8
79.1861 + case 47: stack.push(arg1); // 27
79.1862 + case 48: stack.push(arg6); // 21 6
79.1863 + case 50: stack.push(stack.pop() + stack.pop()); // 96
79.1864 + case 51: arg9 = stack.pop() // 54 9
79.1865 + case 53: stack.push(arg9); // 21 9
79.1866 + case 55: stack.push(arg8); // 21 8
79.1867 + case 57: if (stack.pop() < stack.pop()) { gt = 164; continue; } // 163 0 107
79.1868 + case 60: stack.push(arg0); // 42
79.1869 + case 61: stack.push(arg9); // 21 9
79.1870 + case 63: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1871 + case 64: stack.push(arg7); // 21 7
79.1872 + case 66: if (stack.pop() == stack.pop()) { gt = 91; continue; } // 159 0 25
79.1873 + case 69: arg9++; // 132 9 1
79.1874 + case 72: stack.push(arg9); // 21 9
79.1875 + case 74: stack.push(arg8); // 21 8
79.1876 + case 76: if (stack.pop() < stack.pop()) { gt = 91; continue; } // 163 0 15
79.1877 + case 79: stack.push(arg0); // 42
79.1878 + case 80: stack.push(arg9); // 21 9
79.1879 + case 82: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1880 + case 83: stack.push(arg7); // 21 7
79.1881 + case 85: if (stack.pop() == stack.pop()) { gt = 91; continue; } // 159 0 6
79.1882 + case 88: gt = 69; continue; // 167 255 237
79.1883 + case 91: stack.push(arg9); // 21 9
79.1884 + case 93: stack.push(arg8); // 21 8
79.1885 + case 95: if (stack.pop() < stack.pop()) { gt = 158; continue; } // 163 0 63
79.1886 + case 98: stack.push(arg9); // 21 9
79.1887 + case 100: stack.push(1); // 4
79.1888 + case 101: stack.push(stack.pop() + stack.pop()); // 96
79.1889 + case 102: arg10 = stack.pop() // 54 10
79.1890 + case 104: stack.push(arg10); // 21 10
79.1891 + case 106: stack.push(arg5); // 21 5
79.1892 + case 108: stack.push(stack.pop() + stack.pop()); // 96
79.1893 + case 109: stack.push(1); // 4
79.1894 + case 110: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1895 + case 111: arg11 = stack.pop() // 54 11
79.1896 + case 113: stack.push(arg4); // 21 4
79.1897 + case 115: stack.push(1); // 4
79.1898 + case 116: stack.push(stack.pop() + stack.pop()); // 96
79.1899 + case 117: arg12 = stack.pop() // 54 12
79.1900 + case 119: stack.push(arg10); // 21 10
79.1901 + case 121: stack.push(arg11); // 21 11
79.1902 + case 123: if (stack.pop() <= stack.pop()) { gt = 146; continue; } // 162 0 23
79.1903 + case 126: stack.push(arg0); // 42
79.1904 + case 127: stack.push(arg10); // 21 10
79.1905 + case 129: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1906 + case 130: stack.push(arg3); // 45
79.1907 + case 131: stack.push(arg12); // 21 12
79.1908 + case 133: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.1909 + case 134: if (stack.pop() != stack.pop()) { gt = 146; continue; } // 160 0 12
79.1910 + case 137: arg10++; // 132 10 1
79.1911 + case 140: arg12++; // 132 12 1
79.1912 + case 143: gt = 119; continue; // 167 255 232
79.1913 + case 146: stack.push(arg10); // 21 10
79.1914 + case 148: stack.push(arg11); // 21 11
79.1915 + case 150: if (stack.pop() != stack.pop()) { gt = 158; continue; } // 160 0 8
79.1916 + case 153: stack.push(arg9); // 21 9
79.1917 + case 155: stack.push(arg1); // 27
79.1918 + case 156: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1919 + case 157: return stack.pop(); // 172
79.1920 + case 158: arg9++; // 132 9 1
79.1921 + case 161: gt = 53; continue; // 167 255 148
79.1922 + case 164: // 2
79.1923 + case 165: return stack.pop(); // 172
79.1924 + }
79.1925 +}
79.1926 +function java_lang_String_lastIndexOfILjava_lang_String(arg0,arg1) {
79.1927 + var arg2;
79.1928 +;
79.1929 + var stack = new Array(3);
79.1930 + var gt = 0;
79.1931 + for(;;) switch(gt) {
79.1932 + case 0: stack.push(arg0); // 42
79.1933 + case 1: stack.push(arg1); // 43
79.1934 + case 2: stack.push(arg0); // 42
79.1935 + case 3: stack.push(stack.pop().count); // 180 1 97
79.1936 + 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
79.1937 + case 9: return stack.pop(); // 172
79.1938 + }
79.1939 +}
79.1940 +function java_lang_String_lastIndexOfILjava_lang_StringI(arg0,arg1,arg2) {
79.1941 + var arg3;
79.1942 +;
79.1943 + var stack = new Array(7);
79.1944 + var gt = 0;
79.1945 + for(;;) switch(gt) {
79.1946 + case 0: stack.push(arg0); // 42
79.1947 + case 1: stack.push(stack.pop().value); // 180 1 100
79.1948 + case 4: stack.push(arg0); // 42
79.1949 + case 5: stack.push(stack.pop().offset); // 180 1 99
79.1950 + case 8: stack.push(arg0); // 42
79.1951 + case 9: stack.push(stack.pop().count); // 180 1 97
79.1952 + case 12: stack.push(arg1); // 43
79.1953 + case 13: stack.push(stack.pop().value); // 180 1 100
79.1954 + case 16: stack.push(arg1); // 43
79.1955 + case 17: stack.push(stack.pop().offset); // 180 1 99
79.1956 + case 20: stack.push(arg1); // 43
79.1957 + case 21: stack.push(stack.pop().count); // 180 1 97
79.1958 + case 24: stack.push(arg2); // 28
79.1959 + 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
79.1960 + case 28: return stack.pop(); // 172
79.1961 + }
79.1962 +}
79.1963 +function java_lang_String_lastIndexOfIACIIACIII(arg0,arg1,arg2,arg3,arg4,arg5,arg6) {
79.1964 + var arg7;
79.1965 + var arg8;
79.1966 + var arg9;
79.1967 + var arg10;
79.1968 + var arg11;
79.1969 + var arg12;
79.1970 + var arg13;
79.1971 + var arg14;
79.1972 + var stack = new Array();
79.1973 + var gt = 0;
79.1974 + for(;;) switch(gt) {
79.1975 + case 0: stack.push(arg2); // 28
79.1976 + case 1: stack.push(arg5); // 21 5
79.1977 + case 3: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1978 + case 4: arg7 = stack.pop() // 54 7
79.1979 + case 6: stack.push(arg6); // 21 6
79.1980 + case 8: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 5
79.1981 + case 11: // 2
79.1982 + case 12: return stack.pop(); // 172
79.1983 + case 13: stack.push(arg6); // 21 6
79.1984 + case 15: stack.push(arg7); // 21 7
79.1985 + case 17: if (stack.pop() >= stack.pop()) { gt = 24; continue; } // 164 0 7
79.1986 + case 20: stack.push(arg7); // 21 7
79.1987 + case 22: arg6 = stack.pop() // 54 6
79.1988 + case 24: stack.push(arg5); // 21 5
79.1989 + case 26: if (stack.pop() != 0) { gt = 32; continue; } // 154 0 6
79.1990 + case 29: stack.push(arg6); // 21 6
79.1991 + case 31: return stack.pop(); // 172
79.1992 + case 32: stack.push(arg4); // 21 4
79.1993 + case 34: stack.push(arg5); // 21 5
79.1994 + case 36: stack.push(stack.pop() + stack.pop()); // 96
79.1995 + case 37: stack.push(1); // 4
79.1996 + case 38: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.1997 + case 39: arg8 = stack.pop() // 54 8
79.1998 + case 41: stack.push(arg3); // 45
79.1999 + case 42: stack.push(arg8); // 21 8
79.2000 + case 44: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2001 + case 45: arg9 = stack.pop() // 54 9
79.2002 + case 47: stack.push(arg1); // 27
79.2003 + case 48: stack.push(arg5); // 21 5
79.2004 + case 50: stack.push(stack.pop() + stack.pop()); // 96
79.2005 + case 51: stack.push(1); // 4
79.2006 + case 52: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2007 + case 53: arg10 = stack.pop() // 54 10
79.2008 + case 55: stack.push(arg10); // 21 10
79.2009 + case 57: stack.push(arg6); // 21 6
79.2010 + case 59: stack.push(stack.pop() + stack.pop()); // 96
79.2011 + case 60: arg11 = stack.pop() // 54 11
79.2012 + case 62: stack.push(arg11); // 21 11
79.2013 + case 64: stack.push(arg10); // 21 10
79.2014 + case 66: if (stack.pop() > stack.pop()) { gt = 84; continue; } // 161 0 18
79.2015 + case 69: stack.push(arg0); // 42
79.2016 + case 70: stack.push(arg11); // 21 11
79.2017 + case 72: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2018 + case 73: stack.push(arg9); // 21 9
79.2019 + case 75: if (stack.pop() == stack.pop()) { gt = 84; continue; } // 159 0 9
79.2020 + case 78: arg11 += 255; // 132 11 255
79.2021 + case 81: gt = 62; continue; // 167 255 237
79.2022 + case 84: stack.push(arg11); // 21 11
79.2023 + case 86: stack.push(arg10); // 21 10
79.2024 + case 88: if (stack.pop() <= stack.pop()) { gt = 93; continue; } // 162 0 5
79.2025 + case 91: // 2
79.2026 + case 92: return stack.pop(); // 172
79.2027 + case 93: stack.push(arg11); // 21 11
79.2028 + case 95: stack.push(1); // 4
79.2029 + case 96: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2030 + case 97: arg12 = stack.pop() // 54 12
79.2031 + case 99: stack.push(arg12); // 21 12
79.2032 + case 101: stack.push(arg5); // 21 5
79.2033 + case 103: stack.push(1); // 4
79.2034 + case 104: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2035 + case 105: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2036 + case 106: arg13 = stack.pop() // 54 13
79.2037 + case 108: stack.push(arg8); // 21 8
79.2038 + case 110: stack.push(1); // 4
79.2039 + case 111: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2040 + case 112: arg14 = stack.pop() // 54 14
79.2041 + case 114: stack.push(arg12); // 21 12
79.2042 + case 116: stack.push(arg13); // 21 13
79.2043 + case 118: if (stack.pop() >= stack.pop()) { gt = 144; continue; } // 164 0 26
79.2044 + case 121: stack.push(arg0); // 42
79.2045 + case 122: stack.push(arg12); // 21 12
79.2046 + case 124: arg12 += 255; // 132 12 255
79.2047 + case 127: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2048 + case 128: stack.push(arg3); // 45
79.2049 + case 129: stack.push(arg14); // 21 14
79.2050 + case 131: arg14 += 255; // 132 14 255
79.2051 + case 134: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2052 + case 135: if (stack.pop() == stack.pop()) { gt = 114; continue; } // 159 255 235
79.2053 + case 138: arg11 += 255; // 132 11 255
79.2054 + case 141: gt = 62; continue; // 167 255 177
79.2055 + case 144: stack.push(arg13); // 21 13
79.2056 + case 146: stack.push(arg1); // 27
79.2057 + case 147: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2058 + case 148: stack.push(1); // 4
79.2059 + case 149: stack.push(stack.pop() + stack.pop()); // 96
79.2060 + case 150: return stack.pop(); // 172
79.2061 + }
79.2062 +}
79.2063 +function java_lang_String_substringLjava_lang_StringI(arg0,arg1) {
79.2064 + var arg2;
79.2065 +;
79.2066 + var stack = new Array(3);
79.2067 + var gt = 0;
79.2068 + for(;;) switch(gt) {
79.2069 + case 0: stack.push(arg0); // 42
79.2070 + case 1: stack.push(arg1); // 27
79.2071 + case 2: stack.push(arg0); // 42
79.2072 + case 3: stack.push(stack.pop().count); // 180 1 97
79.2073 + 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
79.2074 + case 9: return stack.pop(); // 176
79.2075 + }
79.2076 +}
79.2077 +function java_lang_String_substringLjava_lang_StringII(arg0,arg1,arg2) {
79.2078 + var arg3;
79.2079 +;
79.2080 + var stack = new Array(5);
79.2081 + var gt = 0;
79.2082 + for(;;) switch(gt) {
79.2083 + case 0: stack.push(arg1); // 27
79.2084 + case 1: if (stack.pop() >= 0) { gt = 13; continue; } // 156 0 12
79.2085 + case 4: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.2086 + case 7: stack.push(stack[stack.length - 1]); // 89
79.2087 + case 8: stack.push(arg1); // 27
79.2088 + case 9: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.2089 + case 12: // 191
79.2090 + case 13: stack.push(arg2); // 28
79.2091 + case 14: stack.push(arg0); // 42
79.2092 + case 15: stack.push(stack.pop().count); // 180 1 97
79.2093 + case 18: if (stack.pop() >= stack.pop()) { gt = 30; continue; } // 164 0 12
79.2094 + case 21: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.2095 + case 24: stack.push(stack[stack.length - 1]); // 89
79.2096 + case 25: stack.push(arg2); // 28
79.2097 + case 26: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.2098 + case 29: // 191
79.2099 + case 30: stack.push(arg1); // 27
79.2100 + case 31: stack.push(arg2); // 28
79.2101 + case 32: if (stack.pop() >= stack.pop()) { gt = 46; continue; } // 164 0 14
79.2102 + case 35: stack.push(new java_lang_StringIndexOutOfBoundsException); // 187 0 206
79.2103 + case 38: stack.push(stack[stack.length - 1]); // 89
79.2104 + case 39: stack.push(arg2); // 28
79.2105 + case 40: stack.push(arg1); // 27
79.2106 + case 41: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2107 + case 42: { var v0 = stack.pop(); java_lang_StringIndexOutOfBoundsException_consVI(stack.pop(), v0); } // 183 1 169
79.2108 + case 45: // 191
79.2109 + case 46: stack.push(arg1); // 27
79.2110 + case 47: if (stack.pop() != 0) { gt = 62; continue; } // 154 0 15
79.2111 + case 50: stack.push(arg2); // 28
79.2112 + case 51: stack.push(arg0); // 42
79.2113 + case 52: stack.push(stack.pop().count); // 180 1 97
79.2114 + case 55: if (stack.pop() != stack.pop()) { gt = 62; continue; } // 160 0 7
79.2115 + case 58: stack.push(arg0); // 42
79.2116 + case 59: gt = 82; continue; // 167 0 23
79.2117 + case 62: stack.push(new java_lang_String); // 187 0 200
79.2118 + case 65: stack.push(stack[stack.length - 1]); // 89
79.2119 + case 66: stack.push(arg0); // 42
79.2120 + case 67: stack.push(stack.pop().offset); // 180 1 99
79.2121 + case 70: stack.push(arg1); // 27
79.2122 + case 71: stack.push(stack.pop() + stack.pop()); // 96
79.2123 + case 72: stack.push(arg2); // 28
79.2124 + case 73: stack.push(arg1); // 27
79.2125 + case 74: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2126 + case 75: stack.push(arg0); // 42
79.2127 + case 76: stack.push(stack.pop().value); // 180 1 100
79.2128 + 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
79.2129 + case 82: return stack.pop(); // 176
79.2130 + }
79.2131 +}
79.2132 +function java_lang_String_subSequenceLjava_lang_CharSequenceII(arg0,arg1,arg2) {
79.2133 + var arg3;
79.2134 +;
79.2135 + var stack = new Array(3);
79.2136 + var gt = 0;
79.2137 + for(;;) switch(gt) {
79.2138 + case 0: stack.push(arg0); // 42
79.2139 + case 1: stack.push(arg1); // 27
79.2140 + case 2: stack.push(arg2); // 28
79.2141 + 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
79.2142 + case 6: return stack.pop(); // 176
79.2143 + }
79.2144 +}
79.2145 +function java_lang_String_concatLjava_lang_StringLjava_lang_String(arg0,arg1) {
79.2146 + var arg2;
79.2147 + var arg3;
79.2148 + var arg4;
79.2149 +;
79.2150 + var stack = new Array(5);
79.2151 + var gt = 0;
79.2152 + for(;;) switch(gt) {
79.2153 + case 0: stack.push(arg1); // 43
79.2154 + case 1: { var self = stack.pop(); stack.push(self.lengthI(self)); } // 182 1 133
79.2155 + case 4: arg2 = stack.pop(); // 61
79.2156 + case 5: stack.push(arg2); // 28
79.2157 + case 6: if (stack.pop() != 0) { gt = 11; continue; } // 154 0 5
79.2158 + case 9: stack.push(arg0); // 42
79.2159 + case 10: return stack.pop(); // 176
79.2160 + case 11: stack.push(arg0); // 42
79.2161 + case 12: stack.push(stack.pop().count); // 180 1 97
79.2162 + case 15: stack.push(arg2); // 28
79.2163 + case 16: stack.push(stack.pop() + stack.pop()); // 96
79.2164 + case 17: stack.push(new Array(stack.pop())); // 188 5
79.2165 + case 19: arg3 = stack.pop(); // 78
79.2166 + case 20: stack.push(arg0); // 42
79.2167 + case 21: stack.push(0); // 3
79.2168 + case 22: stack.push(arg0); // 42
79.2169 + case 23: stack.push(stack.pop().count); // 180 1 97
79.2170 + case 26: stack.push(arg3); // 45
79.2171 + case 27: stack.push(0); // 3
79.2172 + 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
79.2173 + case 31: stack.push(arg1); // 43
79.2174 + case 32: stack.push(0); // 3
79.2175 + case 33: stack.push(arg2); // 28
79.2176 + case 34: stack.push(arg3); // 45
79.2177 + case 35: stack.push(arg0); // 42
79.2178 + case 36: stack.push(stack.pop().count); // 180 1 97
79.2179 + 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
79.2180 + case 42: stack.push(new java_lang_String); // 187 0 200
79.2181 + case 45: stack.push(stack[stack.length - 1]); // 89
79.2182 + case 46: stack.push(0); // 3
79.2183 + case 47: stack.push(arg0); // 42
79.2184 + case 48: stack.push(stack.pop().count); // 180 1 97
79.2185 + case 51: stack.push(arg2); // 28
79.2186 + case 52: stack.push(stack.pop() + stack.pop()); // 96
79.2187 + case 53: stack.push(arg3); // 45
79.2188 + 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
79.2189 + case 57: return stack.pop(); // 176
79.2190 + }
79.2191 +}
79.2192 +function java_lang_String_replaceLjava_lang_StringCC(arg0,arg1,arg2) {
79.2193 + var arg3;
79.2194 + var arg4;
79.2195 + var arg5;
79.2196 + var arg6;
79.2197 + var arg7;
79.2198 + var arg8;
79.2199 + var arg9;
79.2200 +;
79.2201 + var stack = new Array(5);
79.2202 + var gt = 0;
79.2203 + for(;;) switch(gt) {
79.2204 + case 0: stack.push(arg1); // 27
79.2205 + case 1: stack.push(arg2); // 28
79.2206 + case 2: if (stack.pop() == stack.pop()) { gt = 140; continue; } // 159 0 138
79.2207 + case 5: stack.push(arg0); // 42
79.2208 + case 6: stack.push(stack.pop().count); // 180 1 97
79.2209 + case 9: arg3 = stack.pop(); // 62
79.2210 + case 10: // 2
79.2211 + case 11: arg4 = stack.pop() // 54 4
79.2212 + case 13: stack.push(arg0); // 42
79.2213 + case 14: stack.push(stack.pop().value); // 180 1 100
79.2214 + case 17: arg5 = stack.pop() // 58 5
79.2215 + case 19: stack.push(arg0); // 42
79.2216 + case 20: stack.push(stack.pop().offset); // 180 1 99
79.2217 + case 23: arg6 = stack.pop() // 54 6
79.2218 + case 25: arg4++; // 132 4 1
79.2219 + case 28: stack.push(arg4); // 21 4
79.2220 + case 30: stack.push(arg3); // 29
79.2221 + case 31: if (stack.pop() <= stack.pop()) { gt = 49; continue; } // 162 0 18
79.2222 + case 34: stack.push(arg5); // 25 5
79.2223 + case 36: stack.push(arg6); // 21 6
79.2224 + case 38: stack.push(arg4); // 21 4
79.2225 + case 40: stack.push(stack.pop() + stack.pop()); // 96
79.2226 + case 41: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2227 + case 42: stack.push(arg1); // 27
79.2228 + case 43: if (stack.pop() != stack.pop()) { gt = 25; continue; } // 160 255 238
79.2229 + case 46: gt = 49; continue; // 167 0 3
79.2230 + case 49: stack.push(arg4); // 21 4
79.2231 + case 51: stack.push(arg3); // 29
79.2232 + case 52: if (stack.pop() <= stack.pop()) { gt = 140; continue; } // 162 0 88
79.2233 + case 55: stack.push(arg3); // 29
79.2234 + case 56: stack.push(new Array(stack.pop())); // 188 5
79.2235 + case 58: arg7 = stack.pop() // 58 7
79.2236 + case 60: stack.push(0); // 3
79.2237 + case 61: arg8 = stack.pop() // 54 8
79.2238 + case 63: stack.push(arg8); // 21 8
79.2239 + case 65: stack.push(arg4); // 21 4
79.2240 + case 67: if (stack.pop() <= stack.pop()) { gt = 89; continue; } // 162 0 22
79.2241 + case 70: stack.push(arg7); // 25 7
79.2242 + case 72: stack.push(arg8); // 21 8
79.2243 + case 74: stack.push(arg5); // 25 5
79.2244 + case 76: stack.push(arg6); // 21 6
79.2245 + case 78: stack.push(arg8); // 21 8
79.2246 + case 80: stack.push(stack.pop() + stack.pop()); // 96
79.2247 + case 81: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2248 + case 82: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
79.2249 + case 83: arg8++; // 132 8 1
79.2250 + case 86: gt = 63; continue; // 167 255 233
79.2251 + case 89: stack.push(arg4); // 21 4
79.2252 + case 91: stack.push(arg3); // 29
79.2253 + case 92: if (stack.pop() <= stack.pop()) { gt = 128; continue; } // 162 0 36
79.2254 + case 95: stack.push(arg5); // 25 5
79.2255 + case 97: stack.push(arg6); // 21 6
79.2256 + case 99: stack.push(arg4); // 21 4
79.2257 + case 101: stack.push(stack.pop() + stack.pop()); // 96
79.2258 + case 102: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2259 + case 103: arg8 = stack.pop() // 54 8
79.2260 + case 105: stack.push(arg7); // 25 7
79.2261 + case 107: stack.push(arg4); // 21 4
79.2262 + case 109: stack.push(arg8); // 21 8
79.2263 + case 111: stack.push(arg1); // 27
79.2264 + case 112: if (stack.pop() != stack.pop()) { gt = 119; continue; } // 160 0 7
79.2265 + case 115: stack.push(arg2); // 28
79.2266 + case 116: gt = 121; continue; // 167 0 5
79.2267 + case 119: stack.push(arg8); // 21 8
79.2268 + case 121: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
79.2269 + case 122: arg4++; // 132 4 1
79.2270 + case 125: gt = 89; continue; // 167 255 220
79.2271 + case 128: stack.push(new java_lang_String); // 187 0 200
79.2272 + case 131: stack.push(stack[stack.length - 1]); // 89
79.2273 + case 132: stack.push(0); // 3
79.2274 + case 133: stack.push(arg3); // 29
79.2275 + case 134: stack.push(arg7); // 25 7
79.2276 + 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
79.2277 + case 139: return stack.pop(); // 176
79.2278 + case 140: stack.push(arg0); // 42
79.2279 + case 141: return stack.pop(); // 176
79.2280 + }
79.2281 +}
79.2282 +function java_lang_String_matchesZLjava_lang_String(arg0,arg1) {
79.2283 + var arg2;
79.2284 +;
79.2285 + var stack = new Array(2);
79.2286 + var gt = 0;
79.2287 + for(;;) switch(gt) {
79.2288 + case 0: stack.push(arg1); // 43
79.2289 + case 1: stack.push(arg0); // 42
79.2290 + 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
79.2291 + case 5: return stack.pop(); // 172
79.2292 + }
79.2293 +}
79.2294 +function java_lang_String_containsZLjava_lang_CharSequence(arg0,arg1) {
79.2295 + var arg2;
79.2296 +;
79.2297 + var stack = new Array(2);
79.2298 + var gt = 0;
79.2299 + for(;;) switch(gt) {
79.2300 + case 0: stack.push(arg0); // 42
79.2301 + case 1: stack.push(arg1); // 43
79.2302 + case 2: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132
79.2303 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.indexOfILjava_lang_String(self, v0)); } // 182 1 149
79.2304 + case 8: // 2
79.2305 + case 9: if (stack.pop() >= stack.pop()) { gt = 16; continue; } // 164 0 7
79.2306 + case 12: stack.push(1); // 4
79.2307 + case 13: gt = 17; continue; // 167 0 4
79.2308 + case 16: stack.push(0); // 3
79.2309 + case 17: return stack.pop(); // 172
79.2310 + }
79.2311 +}
79.2312 +function java_lang_String_replaceFirstLjava_lang_StringLjava_lang_StringLjava_lang_String(arg0,arg1,arg2) {
79.2313 + var arg3;
79.2314 +;
79.2315 + var stack = new Array(2);
79.2316 + var gt = 0;
79.2317 + for(;;) switch(gt) {
79.2318 + case 0: stack.push(arg1); // 43
79.2319 + case 1: { var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_String(v0)); } // 184 1 186
79.2320 + case 4: stack.push(arg0); // 42
79.2321 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.matcherLjava_util_regex_MatcherLjava_lang_CharSequence(self, v0)); } // 182 1 185
79.2322 + case 8: stack.push(arg2); // 44
79.2323 + case 9: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.replaceFirstLjava_lang_StringLjava_lang_String(self, v0)); } // 182 1 182
79.2324 + case 12: return stack.pop(); // 176
79.2325 + }
79.2326 +}
79.2327 +function java_lang_String_replaceAllLjava_lang_StringLjava_lang_StringLjava_lang_String(arg0,arg1,arg2) {
79.2328 + var arg3;
79.2329 +;
79.2330 + var stack = new Array(2);
79.2331 + var gt = 0;
79.2332 + for(;;) switch(gt) {
79.2333 + case 0: stack.push(arg1); // 43
79.2334 + case 1: { var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_String(v0)); } // 184 1 186
79.2335 + case 4: stack.push(arg0); // 42
79.2336 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.matcherLjava_util_regex_MatcherLjava_lang_CharSequence(self, v0)); } // 182 1 185
79.2337 + case 8: stack.push(arg2); // 44
79.2338 + case 9: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.replaceAllLjava_lang_StringLjava_lang_String(self, v0)); } // 182 1 181
79.2339 + case 12: return stack.pop(); // 176
79.2340 + }
79.2341 +}
79.2342 +function java_lang_String_replaceLjava_lang_StringLjava_lang_CharSequenceLjava_lang_CharSequence(arg0,arg1,arg2) {
79.2343 + var arg3;
79.2344 +;
79.2345 + var stack = new Array(2);
79.2346 + var gt = 0;
79.2347 + for(;;) switch(gt) {
79.2348 + case 0: stack.push(arg1); // 43
79.2349 + case 1: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132
79.2350 + case 4: stack.push(16); // 16 16
79.2351 + 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
79.2352 + case 9: stack.push(arg0); // 42
79.2353 + case 10: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.matcherLjava_util_regex_MatcherLjava_lang_CharSequence(self, v0)); } // 182 1 185
79.2354 + case 13: stack.push(arg2); // 44
79.2355 + case 14: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132
79.2356 + case 17: { var v0 = stack.pop(); stack.push(java_util_regex_Matcher_quoteReplacementLjava_lang_StringLjava_lang_String(v0)); } // 184 1 180
79.2357 + case 20: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.replaceAllLjava_lang_StringLjava_lang_String(self, v0)); } // 182 1 181
79.2358 + case 23: return stack.pop(); // 176
79.2359 + }
79.2360 +}
79.2361 +function java_lang_String_splitALjava_lang_StringLjava_lang_StringI(arg0,arg1,arg2) {
79.2362 + var arg3;
79.2363 +;
79.2364 + var stack = new Array(3);
79.2365 + var gt = 0;
79.2366 + for(;;) switch(gt) {
79.2367 + case 0: stack.push(arg1); // 43
79.2368 + case 1: { var v0 = stack.pop(); stack.push(java_util_regex_Pattern_compileLjava_util_regex_PatternLjava_lang_String(v0)); } // 184 1 186
79.2369 + case 4: stack.push(arg0); // 42
79.2370 + case 5: stack.push(arg2); // 28
79.2371 + 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
79.2372 + case 9: return stack.pop(); // 176
79.2373 + }
79.2374 +}
79.2375 +function java_lang_String_splitALjava_lang_StringLjava_lang_String(arg0,arg1) {
79.2376 + var arg2;
79.2377 +;
79.2378 + var stack = new Array(3);
79.2379 + var gt = 0;
79.2380 + for(;;) switch(gt) {
79.2381 + case 0: stack.push(arg0); // 42
79.2382 + case 1: stack.push(arg1); // 43
79.2383 + case 2: stack.push(0); // 3
79.2384 + 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
79.2385 + case 6: return stack.pop(); // 176
79.2386 + }
79.2387 +}
79.2388 +function java_lang_String_toLowerCaseLjava_lang_StringLjava_util_Locale(arg0,arg1) {
79.2389 + var arg2;
79.2390 + var arg3;
79.2391 + var arg4;
79.2392 + var arg5;
79.2393 + var arg6;
79.2394 + var arg7;
79.2395 + var arg8;
79.2396 + var arg9;
79.2397 + var arg10;
79.2398 + var arg11;
79.2399 + var arg12;
79.2400 + var arg13;
79.2401 + var arg14;
79.2402 +;
79.2403 + var stack = new Array(6);
79.2404 + var gt = 0;
79.2405 + for(;;) switch(gt) {
79.2406 + case 0: stack.push(arg1); // 43
79.2407 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11
79.2408 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198
79.2409 + case 7: stack.push(stack[stack.length - 1]); // 89
79.2410 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128
79.2411 + case 11: // 191
79.2412 + case 12: stack.push(0); // 3
79.2413 + case 13: arg2 = stack.pop(); // 61
79.2414 + case 14: stack.push(arg2); // 28
79.2415 + case 15: stack.push(arg0); // 42
79.2416 + case 16: stack.push(stack.pop().count); // 180 1 97
79.2417 + case 19: if (stack.pop() <= stack.pop()) { gt = 94; continue; } // 162 0 75
79.2418 + case 22: stack.push(arg0); // 42
79.2419 + case 23: stack.push(stack.pop().value); // 180 1 100
79.2420 + case 26: stack.push(arg0); // 42
79.2421 + case 27: stack.push(stack.pop().offset); // 180 1 99
79.2422 + case 30: stack.push(arg2); // 28
79.2423 + case 31: stack.push(stack.pop() + stack.pop()); // 96
79.2424 + case 32: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2425 + case 33: arg3 = stack.pop(); // 62
79.2426 + case 34: stack.push(arg3); // 29
79.2427 + case 35: stack.push(55296); // 18 1
79.2428 + case 37: if (stack.pop() > stack.pop()) { gt = 77; continue; } // 161 0 40
79.2429 + case 40: stack.push(arg3); // 29
79.2430 + case 41: stack.push(56319); // 18 2
79.2431 + case 43: if (stack.pop() < stack.pop()) { gt = 77; continue; } // 163 0 34
79.2432 + case 46: stack.push(arg0); // 42
79.2433 + case 47: stack.push(arg2); // 28
79.2434 + case 48: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134
79.2435 + case 51: arg4 = stack.pop() // 54 4
79.2436 + case 53: stack.push(arg4); // 21 4
79.2437 + case 55: stack.push(arg4); // 21 4
79.2438 + case 57: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseII(v0)); } // 184 1 107
79.2439 + case 60: if (stack.pop() == stack.pop()) { gt = 66; continue; } // 159 0 6
79.2440 + case 63: gt = 96; continue; // 167 0 33
79.2441 + case 66: stack.push(arg2); // 28
79.2442 + case 67: stack.push(arg4); // 21 4
79.2443 + case 69: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106
79.2444 + case 72: stack.push(stack.pop() + stack.pop()); // 96
79.2445 + case 73: arg2 = stack.pop(); // 61
79.2446 + case 74: gt = 91; continue; // 167 0 17
79.2447 + case 77: stack.push(arg3); // 29
79.2448 + case 78: stack.push(arg3); // 29
79.2449 + case 79: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseCC(v0)); } // 184 1 104
79.2450 + case 82: if (stack.pop() == stack.pop()) { gt = 88; continue; } // 159 0 6
79.2451 + case 85: gt = 96; continue; // 167 0 11
79.2452 + case 88: arg2++; // 132 2 1
79.2453 + case 91: gt = 14; continue; // 167 255 179
79.2454 + case 94: stack.push(arg0); // 42
79.2455 + case 95: return stack.pop(); // 176
79.2456 + case 96: stack.push(arg0); // 42
79.2457 + case 97: stack.push(stack.pop().count); // 180 1 97
79.2458 + case 100: stack.push(new Array(stack.pop())); // 188 5
79.2459 + case 102: arg3 = stack.pop(); // 78
79.2460 + case 103: stack.push(0); // 3
79.2461 + case 104: arg4 = stack.pop() // 54 4
79.2462 + case 106: stack.push(arg0); // 42
79.2463 + case 107: stack.push(stack.pop().value); // 180 1 100
79.2464 + case 110: stack.push(arg0); // 42
79.2465 + case 111: stack.push(stack.pop().offset); // 180 1 99
79.2466 + case 114: stack.push(arg3); // 45
79.2467 + case 115: stack.push(0); // 3
79.2468 + case 116: stack.push(arg2); // 28
79.2469 + 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
79.2470 + case 120: stack.push(arg1); // 43
79.2471 + case 121: { var self = stack.pop(); stack.push(self.getLanguageLjava_lang_String(self)); } // 182 1 178
79.2472 + case 124: arg5 = stack.pop() // 58 5
79.2473 + case 126: stack.push(arg5); // 25 5
79.2474 + case 128: stack.push("tr"); // 18 11
79.2475 + case 130: // 165
79.2476 + case 131: // 0
79.2477 + case 132: stack.push(6405); // 17 25 5
79.2478 + case 135: stack.push("az"); // 18 5
79.2479 + case 137: // 165
79.2480 + case 138: // 0
79.2481 + case 139: stack.push(1); // 10
79.2482 + case 140: stack.push(arg5); // 25 5
79.2483 + case 142: stack.push("lt"); // 18 9
79.2484 + case 144: // 166
79.2485 + case 145: // 0
79.2486 + case 146: stack.push(4); // 7
79.2487 + case 147: stack.push(1); // 4
79.2488 + case 148: gt = 152; continue; // 167 0 4
79.2489 + case 151: stack.push(0); // 3
79.2490 + case 152: arg6 = stack.pop() // 54 6
79.2491 + case 154: stack.push(arg2); // 28
79.2492 + case 155: arg11 = stack.pop() // 54 11
79.2493 + case 157: stack.push(arg11); // 21 11
79.2494 + case 159: stack.push(arg0); // 42
79.2495 + case 160: stack.push(stack.pop().count); // 180 1 97
79.2496 + case 163: if (stack.pop() <= stack.pop()) { gt = 419; continue; } // 162 1 0
79.2497 + case 166: stack.push(arg0); // 42
79.2498 + case 167: stack.push(stack.pop().value); // 180 1 100
79.2499 + case 170: stack.push(arg0); // 42
79.2500 + case 171: stack.push(stack.pop().offset); // 180 1 99
79.2501 + case 174: stack.push(arg11); // 21 11
79.2502 + case 176: stack.push(stack.pop() + stack.pop()); // 96
79.2503 + case 177: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2504 + case 178: arg9 = stack.pop() // 54 9
79.2505 + case 180: stack.push(arg9); // 21 9
79.2506 + case 182: // number conversion // 146
79.2507 + case 183: stack.push(55296); // 18 1
79.2508 + case 185: if (stack.pop() > stack.pop()) { gt = 214; continue; } // 161 0 29
79.2509 + case 188: stack.push(arg9); // 21 9
79.2510 + case 190: // number conversion // 146
79.2511 + case 191: stack.push(56319); // 18 2
79.2512 + case 193: if (stack.pop() < stack.pop()) { gt = 214; continue; } // 163 0 21
79.2513 + case 196: stack.push(arg0); // 42
79.2514 + case 197: stack.push(arg11); // 21 11
79.2515 + case 199: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134
79.2516 + case 202: arg9 = stack.pop() // 54 9
79.2517 + case 204: stack.push(arg9); // 21 9
79.2518 + case 206: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106
79.2519 + case 209: arg10 = stack.pop() // 54 10
79.2520 + case 211: gt = 217; continue; // 167 0 6
79.2521 + case 214: stack.push(1); // 4
79.2522 + case 215: arg10 = stack.pop() // 54 10
79.2523 + case 217: stack.push(arg6); // 21 6
79.2524 + case 219: if (stack.pop() != 0) { gt = 230; continue; } // 154 0 11
79.2525 + case 222: stack.push(arg9); // 21 9
79.2526 + case 224: stack.push(931); // 17 3 163
79.2527 + case 227: if (stack.pop() != stack.pop()) { gt = 242; continue; } // 160 0 15
79.2528 + case 230: stack.push(arg0); // 42
79.2529 + case 231: stack.push(arg11); // 21 11
79.2530 + case 233: stack.push(arg1); // 43
79.2531 + 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
79.2532 + case 237: arg8 = stack.pop() // 54 8
79.2533 + case 239: gt = 249; continue; // 167 0 10
79.2534 + case 242: stack.push(arg9); // 21 9
79.2535 + case 244: { var v0 = stack.pop(); stack.push(java_lang_Character_toLowerCaseII(v0)); } // 184 1 107
79.2536 + case 247: arg8 = stack.pop() // 54 8
79.2537 + case 249: stack.push(arg8); // 21 8
79.2538 + case 251: // 2
79.2539 + case 252: if (stack.pop() == stack.pop()) { gt = 262; continue; } // 159 0 10
79.2540 + case 255: stack.push(arg8); // 21 8
79.2541 + case 257: stack.push(65536); // 18 3
79.2542 + case 259: if (stack.pop() > stack.pop()) { gt = 399; continue; } // 161 0 140
79.2543 + case 262: stack.push(arg8); // 21 8
79.2544 + case 264: // 2
79.2545 + case 265: if (stack.pop() != stack.pop()) { gt = 280; continue; } // 160 0 15
79.2546 + case 268: stack.push(arg0); // 42
79.2547 + case 269: stack.push(arg11); // 21 11
79.2548 + case 271: stack.push(arg1); // 43
79.2549 + 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
79.2550 + case 275: arg7 = stack.pop() // 58 7
79.2551 + case 277: gt = 315; continue; // 167 0 38
79.2552 + case 280: stack.push(arg10); // 21 10
79.2553 + case 282: stack.push(2); // 5
79.2554 + case 283: if (stack.pop() != stack.pop()) { gt = 308; continue; } // 160 0 25
79.2555 + case 286: stack.push(arg4); // 21 4
79.2556 + case 288: stack.push(arg8); // 21 8
79.2557 + case 290: stack.push(arg3); // 45
79.2558 + case 291: stack.push(arg11); // 21 11
79.2559 + case 293: stack.push(arg4); // 21 4
79.2560 + case 295: stack.push(stack.pop() + stack.pop()); // 96
79.2561 + 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
79.2562 + case 299: stack.push(arg10); // 21 10
79.2563 + case 301: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2564 + case 302: stack.push(stack.pop() + stack.pop()); // 96
79.2565 + case 303: arg4 = stack.pop() // 54 4
79.2566 + case 305: gt = 409; continue; // 167 0 104
79.2567 + case 308: stack.push(arg8); // 21 8
79.2568 + case 310: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109
79.2569 + case 313: arg7 = stack.pop() // 58 7
79.2570 + case 315: stack.push(arg7); // 25 7
79.2571 + case 317: stack.push(stack.pop().length); // 190
79.2572 + case 318: arg12 = stack.pop() // 54 12
79.2573 + case 320: stack.push(arg12); // 21 12
79.2574 + case 322: stack.push(arg10); // 21 10
79.2575 + case 324: if (stack.pop() >= stack.pop()) { gt = 355; continue; } // 164 0 31
79.2576 + case 327: stack.push(arg3); // 45
79.2577 + case 328: stack.push(stack.pop().length); // 190
79.2578 + case 329: stack.push(arg12); // 21 12
79.2579 + case 331: stack.push(stack.pop() + stack.pop()); // 96
79.2580 + case 332: stack.push(arg10); // 21 10
79.2581 + case 334: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2582 + case 335: stack.push(new Array(stack.pop())); // 188 5
79.2583 + case 337: arg13 = stack.pop() // 58 13
79.2584 + case 339: stack.push(arg3); // 45
79.2585 + case 340: stack.push(0); // 3
79.2586 + case 341: stack.push(arg13); // 25 13
79.2587 + case 343: stack.push(0); // 3
79.2588 + case 344: stack.push(arg11); // 21 11
79.2589 + case 346: stack.push(arg4); // 21 4
79.2590 + case 348: stack.push(stack.pop() + stack.pop()); // 96
79.2591 + 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
79.2592 + case 352: stack.push(arg13); // 25 13
79.2593 + case 354: arg3 = stack.pop(); // 78
79.2594 + case 355: stack.push(0); // 3
79.2595 + case 356: arg13 = stack.pop() // 54 13
79.2596 + case 358: stack.push(arg13); // 21 13
79.2597 + case 360: stack.push(arg12); // 21 12
79.2598 + case 362: if (stack.pop() <= stack.pop()) { gt = 386; continue; } // 162 0 24
79.2599 + case 365: stack.push(arg3); // 45
79.2600 + case 366: stack.push(arg11); // 21 11
79.2601 + case 368: stack.push(arg4); // 21 4
79.2602 + case 370: stack.push(stack.pop() + stack.pop()); // 96
79.2603 + case 371: stack.push(arg13); // 21 13
79.2604 + case 373: stack.push(stack.pop() + stack.pop()); // 96
79.2605 + case 374: stack.push(arg7); // 25 7
79.2606 + case 376: stack.push(arg13); // 21 13
79.2607 + case 378: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2608 + case 379: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
79.2609 + case 380: arg13++; // 132 13 1
79.2610 + case 383: gt = 358; continue; // 167 255 231
79.2611 + case 386: stack.push(arg4); // 21 4
79.2612 + case 388: stack.push(arg12); // 21 12
79.2613 + case 390: stack.push(arg10); // 21 10
79.2614 + case 392: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2615 + case 393: stack.push(stack.pop() + stack.pop()); // 96
79.2616 + case 394: arg4 = stack.pop() // 54 4
79.2617 + case 396: gt = 409; continue; // 167 0 13
79.2618 + case 399: stack.push(arg3); // 45
79.2619 + case 400: stack.push(arg11); // 21 11
79.2620 + case 402: stack.push(arg4); // 21 4
79.2621 + case 404: stack.push(stack.pop() + stack.pop()); // 96
79.2622 + case 405: stack.push(arg8); // 21 8
79.2623 + case 407: // number conversion // 146
79.2624 + case 408: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
79.2625 + case 409: stack.push(arg11); // 21 11
79.2626 + case 411: stack.push(arg10); // 21 10
79.2627 + case 413: stack.push(stack.pop() + stack.pop()); // 96
79.2628 + case 414: arg11 = stack.pop() // 54 11
79.2629 + case 416: gt = 157; continue; // 167 254 253
79.2630 + case 419: stack.push(new java_lang_String); // 187 0 200
79.2631 + case 422: stack.push(stack[stack.length - 1]); // 89
79.2632 + case 423: stack.push(0); // 3
79.2633 + case 424: stack.push(arg0); // 42
79.2634 + case 425: stack.push(stack.pop().count); // 180 1 97
79.2635 + case 428: stack.push(arg4); // 21 4
79.2636 + case 430: stack.push(stack.pop() + stack.pop()); // 96
79.2637 + case 431: stack.push(arg3); // 45
79.2638 + 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
79.2639 + case 435: return stack.pop(); // 176
79.2640 + }
79.2641 +}
79.2642 +function java_lang_String_toLowerCaseLjava_lang_String(arg0) {
79.2643 + var arg1;
79.2644 +;
79.2645 + var stack = new Array(2);
79.2646 + var gt = 0;
79.2647 + for(;;) switch(gt) {
79.2648 + case 0: stack.push(arg0); // 42
79.2649 + case 1: { stack.push(java_util_Locale_getDefaultLjava_util_Locale()); } // 184 1 179
79.2650 + case 4: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.toLowerCaseLjava_lang_StringLjava_util_Locale(self, v0)); } // 182 1 158
79.2651 + case 7: return stack.pop(); // 176
79.2652 + }
79.2653 +}
79.2654 +function java_lang_String_toUpperCaseLjava_lang_StringLjava_util_Locale(arg0,arg1) {
79.2655 + var arg2;
79.2656 + var arg3;
79.2657 + var arg4;
79.2658 + var arg5;
79.2659 + var arg6;
79.2660 + var arg7;
79.2661 + var arg8;
79.2662 + var arg9;
79.2663 + var arg10;
79.2664 + var arg11;
79.2665 + var arg12;
79.2666 + var arg13;
79.2667 + var arg14;
79.2668 +;
79.2669 + var stack = new Array(6);
79.2670 + var gt = 0;
79.2671 + for(;;) switch(gt) {
79.2672 + case 0: stack.push(arg1); // 43
79.2673 + case 1: if (stack.pop()) { gt = 12; continue; } // 199 0 11
79.2674 + case 4: stack.push(new java_lang_NullPointerException); // 187 0 198
79.2675 + case 7: stack.push(stack[stack.length - 1]); // 89
79.2676 + case 8: { java_lang_NullPointerException_consV(stack.pop()); } // 183 1 128
79.2677 + case 11: // 191
79.2678 + case 12: stack.push(0); // 3
79.2679 + case 13: arg2 = stack.pop(); // 61
79.2680 + case 14: stack.push(arg2); // 28
79.2681 + case 15: stack.push(arg0); // 42
79.2682 + case 16: stack.push(stack.pop().count); // 180 1 97
79.2683 + case 19: if (stack.pop() <= stack.pop()) { gt = 93; continue; } // 162 0 74
79.2684 + case 22: stack.push(arg0); // 42
79.2685 + case 23: stack.push(stack.pop().value); // 180 1 100
79.2686 + case 26: stack.push(arg0); // 42
79.2687 + case 27: stack.push(stack.pop().offset); // 180 1 99
79.2688 + case 30: stack.push(arg2); // 28
79.2689 + case 31: stack.push(stack.pop() + stack.pop()); // 96
79.2690 + case 32: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2691 + case 33: arg3 = stack.pop(); // 62
79.2692 + case 34: stack.push(arg3); // 29
79.2693 + case 35: stack.push(55296); // 18 1
79.2694 + case 37: if (stack.pop() > stack.pop()) { gt = 61; continue; } // 161 0 24
79.2695 + case 40: stack.push(arg3); // 29
79.2696 + case 41: stack.push(56319); // 18 2
79.2697 + case 43: if (stack.pop() < stack.pop()) { gt = 61; continue; } // 163 0 18
79.2698 + case 46: stack.push(arg0); // 42
79.2699 + case 47: stack.push(arg2); // 28
79.2700 + case 48: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134
79.2701 + case 51: arg3 = stack.pop(); // 62
79.2702 + case 52: stack.push(arg3); // 29
79.2703 + case 53: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106
79.2704 + case 56: arg4 = stack.pop() // 54 4
79.2705 + case 58: gt = 64; continue; // 167 0 6
79.2706 + case 61: stack.push(1); // 4
79.2707 + case 62: arg4 = stack.pop() // 54 4
79.2708 + case 64: stack.push(arg3); // 29
79.2709 + case 65: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseExII(v0)); } // 184 1 108
79.2710 + case 68: arg5 = stack.pop() // 54 5
79.2711 + case 70: stack.push(arg5); // 21 5
79.2712 + case 72: // 2
79.2713 + case 73: if (stack.pop() == stack.pop()) { gt = 95; continue; } // 159 0 22
79.2714 + case 76: stack.push(arg3); // 29
79.2715 + case 77: stack.push(arg5); // 21 5
79.2716 + case 79: if (stack.pop() == stack.pop()) { gt = 85; continue; } // 159 0 6
79.2717 + case 82: gt = 95; continue; // 167 0 13
79.2718 + case 85: stack.push(arg2); // 28
79.2719 + case 86: stack.push(arg4); // 21 4
79.2720 + case 88: stack.push(stack.pop() + stack.pop()); // 96
79.2721 + case 89: arg2 = stack.pop(); // 61
79.2722 + case 90: gt = 14; continue; // 167 255 180
79.2723 + case 93: stack.push(arg0); // 42
79.2724 + case 94: return stack.pop(); // 176
79.2725 + case 95: stack.push(arg0); // 42
79.2726 + case 96: stack.push(stack.pop().count); // 180 1 97
79.2727 + case 99: stack.push(new Array(stack.pop())); // 188 5
79.2728 + case 101: arg3 = stack.pop(); // 78
79.2729 + case 102: stack.push(0); // 3
79.2730 + case 103: arg4 = stack.pop() // 54 4
79.2731 + case 105: stack.push(arg0); // 42
79.2732 + case 106: stack.push(stack.pop().value); // 180 1 100
79.2733 + case 109: stack.push(arg0); // 42
79.2734 + case 110: stack.push(stack.pop().offset); // 180 1 99
79.2735 + case 113: stack.push(arg3); // 45
79.2736 + case 114: stack.push(0); // 3
79.2737 + case 115: stack.push(arg2); // 28
79.2738 + 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
79.2739 + case 119: stack.push(arg1); // 43
79.2740 + case 120: { var self = stack.pop(); stack.push(self.getLanguageLjava_lang_String(self)); } // 182 1 178
79.2741 + case 123: arg5 = stack.pop() // 58 5
79.2742 + case 125: stack.push(arg5); // 25 5
79.2743 + case 127: stack.push("tr"); // 18 11
79.2744 + case 129: // 165
79.2745 + case 130: // 0
79.2746 + case 131: stack.push(6405); // 17 25 5
79.2747 + case 134: stack.push("az"); // 18 5
79.2748 + case 136: // 165
79.2749 + case 137: // 0
79.2750 + case 138: stack.push(1); // 10
79.2751 + case 139: stack.push(arg5); // 25 5
79.2752 + case 141: stack.push("lt"); // 18 9
79.2753 + case 143: // 166
79.2754 + case 144: // 0
79.2755 + case 145: stack.push(4); // 7
79.2756 + case 146: stack.push(1); // 4
79.2757 + case 147: gt = 151; continue; // 167 0 4
79.2758 + case 150: stack.push(0); // 3
79.2759 + case 151: arg6 = stack.pop() // 54 6
79.2760 + case 153: stack.push(arg2); // 28
79.2761 + case 154: arg11 = stack.pop() // 54 11
79.2762 + case 156: stack.push(arg11); // 21 11
79.2763 + case 158: stack.push(arg0); // 42
79.2764 + case 159: stack.push(stack.pop().count); // 180 1 97
79.2765 + case 162: if (stack.pop() <= stack.pop()) { gt = 425; continue; } // 162 1 7
79.2766 + case 165: stack.push(arg0); // 42
79.2767 + case 166: stack.push(stack.pop().value); // 180 1 100
79.2768 + case 169: stack.push(arg0); // 42
79.2769 + case 170: stack.push(stack.pop().offset); // 180 1 99
79.2770 + case 173: stack.push(arg11); // 21 11
79.2771 + case 175: stack.push(stack.pop() + stack.pop()); // 96
79.2772 + case 176: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2773 + case 177: arg9 = stack.pop() // 54 9
79.2774 + case 179: stack.push(arg9); // 21 9
79.2775 + case 181: // number conversion // 146
79.2776 + case 182: stack.push(55296); // 18 1
79.2777 + case 184: if (stack.pop() > stack.pop()) { gt = 213; continue; } // 161 0 29
79.2778 + case 187: stack.push(arg9); // 21 9
79.2779 + case 189: // number conversion // 146
79.2780 + case 190: stack.push(56319); // 18 2
79.2781 + case 192: if (stack.pop() < stack.pop()) { gt = 213; continue; } // 163 0 21
79.2782 + case 195: stack.push(arg0); // 42
79.2783 + case 196: stack.push(arg11); // 21 11
79.2784 + case 198: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.codePointAtII(self, v0)); } // 182 1 134
79.2785 + case 201: arg9 = stack.pop() // 54 9
79.2786 + case 203: stack.push(arg9); // 21 9
79.2787 + case 205: { var v0 = stack.pop(); stack.push(java_lang_Character_charCountII(v0)); } // 184 1 106
79.2788 + case 208: arg10 = stack.pop() // 54 10
79.2789 + case 210: gt = 216; continue; // 167 0 6
79.2790 + case 213: stack.push(1); // 4
79.2791 + case 214: arg10 = stack.pop() // 54 10
79.2792 + case 216: stack.push(arg6); // 21 6
79.2793 + case 218: if (stack.pop() == 0) { gt = 233; continue; } // 153 0 15
79.2794 + case 221: stack.push(arg0); // 42
79.2795 + case 222: stack.push(arg11); // 21 11
79.2796 + case 224: stack.push(arg1); // 43
79.2797 + 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
79.2798 + case 228: arg8 = stack.pop() // 54 8
79.2799 + case 230: gt = 240; continue; // 167 0 10
79.2800 + case 233: stack.push(arg9); // 21 9
79.2801 + case 235: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseExII(v0)); } // 184 1 108
79.2802 + case 238: arg8 = stack.pop() // 54 8
79.2803 + case 240: stack.push(arg8); // 21 8
79.2804 + case 242: // 2
79.2805 + case 243: if (stack.pop() == stack.pop()) { gt = 253; continue; } // 159 0 10
79.2806 + case 246: stack.push(arg8); // 21 8
79.2807 + case 248: stack.push(65536); // 18 3
79.2808 + case 250: if (stack.pop() > stack.pop()) { gt = 405; continue; } // 161 0 155
79.2809 + case 253: stack.push(arg8); // 21 8
79.2810 + case 255: // 2
79.2811 + case 256: if (stack.pop() != stack.pop()) { gt = 286; continue; } // 160 0 30
79.2812 + case 259: stack.push(arg6); // 21 6
79.2813 + case 261: if (stack.pop() == 0) { gt = 276; continue; } // 153 0 15
79.2814 + case 264: stack.push(arg0); // 42
79.2815 + case 265: stack.push(arg11); // 21 11
79.2816 + case 267: stack.push(arg1); // 43
79.2817 + 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
79.2818 + case 271: arg7 = stack.pop() // 58 7
79.2819 + case 273: gt = 321; continue; // 167 0 48
79.2820 + case 276: stack.push(arg9); // 21 9
79.2821 + case 278: { var v0 = stack.pop(); stack.push(java_lang_Character_toUpperCaseCharArrayACI(v0)); } // 184 1 110
79.2822 + case 281: arg7 = stack.pop() // 58 7
79.2823 + case 283: gt = 321; continue; // 167 0 38
79.2824 + case 286: stack.push(arg10); // 21 10
79.2825 + case 288: stack.push(2); // 5
79.2826 + case 289: if (stack.pop() != stack.pop()) { gt = 314; continue; } // 160 0 25
79.2827 + case 292: stack.push(arg4); // 21 4
79.2828 + case 294: stack.push(arg8); // 21 8
79.2829 + case 296: stack.push(arg3); // 45
79.2830 + case 297: stack.push(arg11); // 21 11
79.2831 + case 299: stack.push(arg4); // 21 4
79.2832 + case 301: stack.push(stack.pop() + stack.pop()); // 96
79.2833 + 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
79.2834 + case 305: stack.push(arg10); // 21 10
79.2835 + case 307: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2836 + case 308: stack.push(stack.pop() + stack.pop()); // 96
79.2837 + case 309: arg4 = stack.pop() // 54 4
79.2838 + case 311: gt = 415; continue; // 167 0 104
79.2839 + case 314: stack.push(arg8); // 21 8
79.2840 + case 316: { var v0 = stack.pop(); stack.push(java_lang_Character_toCharsACI(v0)); } // 184 1 109
79.2841 + case 319: arg7 = stack.pop() // 58 7
79.2842 + case 321: stack.push(arg7); // 25 7
79.2843 + case 323: stack.push(stack.pop().length); // 190
79.2844 + case 324: arg12 = stack.pop() // 54 12
79.2845 + case 326: stack.push(arg12); // 21 12
79.2846 + case 328: stack.push(arg10); // 21 10
79.2847 + case 330: if (stack.pop() >= stack.pop()) { gt = 361; continue; } // 164 0 31
79.2848 + case 333: stack.push(arg3); // 45
79.2849 + case 334: stack.push(stack.pop().length); // 190
79.2850 + case 335: stack.push(arg12); // 21 12
79.2851 + case 337: stack.push(stack.pop() + stack.pop()); // 96
79.2852 + case 338: stack.push(arg10); // 21 10
79.2853 + case 340: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2854 + case 341: stack.push(new Array(stack.pop())); // 188 5
79.2855 + case 343: arg13 = stack.pop() // 58 13
79.2856 + case 345: stack.push(arg3); // 45
79.2857 + case 346: stack.push(0); // 3
79.2858 + case 347: stack.push(arg13); // 25 13
79.2859 + case 349: stack.push(0); // 3
79.2860 + case 350: stack.push(arg11); // 21 11
79.2861 + case 352: stack.push(arg4); // 21 4
79.2862 + case 354: stack.push(stack.pop() + stack.pop()); // 96
79.2863 + 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
79.2864 + case 358: stack.push(arg13); // 25 13
79.2865 + case 360: arg3 = stack.pop(); // 78
79.2866 + case 361: stack.push(0); // 3
79.2867 + case 362: arg13 = stack.pop() // 54 13
79.2868 + case 364: stack.push(arg13); // 21 13
79.2869 + case 366: stack.push(arg12); // 21 12
79.2870 + case 368: if (stack.pop() <= stack.pop()) { gt = 392; continue; } // 162 0 24
79.2871 + case 371: stack.push(arg3); // 45
79.2872 + case 372: stack.push(arg11); // 21 11
79.2873 + case 374: stack.push(arg4); // 21 4
79.2874 + case 376: stack.push(stack.pop() + stack.pop()); // 96
79.2875 + case 377: stack.push(arg13); // 21 13
79.2876 + case 379: stack.push(stack.pop() + stack.pop()); // 96
79.2877 + case 380: stack.push(arg7); // 25 7
79.2878 + case 382: stack.push(arg13); // 21 13
79.2879 + case 384: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2880 + case 385: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
79.2881 + case 386: arg13++; // 132 13 1
79.2882 + case 389: gt = 364; continue; // 167 255 231
79.2883 + case 392: stack.push(arg4); // 21 4
79.2884 + case 394: stack.push(arg12); // 21 12
79.2885 + case 396: stack.push(arg10); // 21 10
79.2886 + case 398: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2887 + case 399: stack.push(stack.pop() + stack.pop()); // 96
79.2888 + case 400: arg4 = stack.pop() // 54 4
79.2889 + case 402: gt = 415; continue; // 167 0 13
79.2890 + case 405: stack.push(arg3); // 45
79.2891 + case 406: stack.push(arg11); // 21 11
79.2892 + case 408: stack.push(arg4); // 21 4
79.2893 + case 410: stack.push(stack.pop() + stack.pop()); // 96
79.2894 + case 411: stack.push(arg8); // 21 8
79.2895 + case 413: // number conversion // 146
79.2896 + case 414: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
79.2897 + case 415: stack.push(arg11); // 21 11
79.2898 + case 417: stack.push(arg10); // 21 10
79.2899 + case 419: stack.push(stack.pop() + stack.pop()); // 96
79.2900 + case 420: arg11 = stack.pop() // 54 11
79.2901 + case 422: gt = 156; continue; // 167 254 246
79.2902 + case 425: stack.push(new java_lang_String); // 187 0 200
79.2903 + case 428: stack.push(stack[stack.length - 1]); // 89
79.2904 + case 429: stack.push(0); // 3
79.2905 + case 430: stack.push(arg0); // 42
79.2906 + case 431: stack.push(stack.pop().count); // 180 1 97
79.2907 + case 434: stack.push(arg4); // 21 4
79.2908 + case 436: stack.push(stack.pop() + stack.pop()); // 96
79.2909 + case 437: stack.push(arg3); // 45
79.2910 + 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
79.2911 + case 441: return stack.pop(); // 176
79.2912 + }
79.2913 +}
79.2914 +function java_lang_String_toUpperCaseLjava_lang_String(arg0) {
79.2915 + var arg1;
79.2916 +;
79.2917 + var stack = new Array(2);
79.2918 + var gt = 0;
79.2919 + for(;;) switch(gt) {
79.2920 + case 0: stack.push(arg0); // 42
79.2921 + case 1: { stack.push(java_util_Locale_getDefaultLjava_util_Locale()); } // 184 1 179
79.2922 + case 4: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.toUpperCaseLjava_lang_StringLjava_util_Locale(self, v0)); } // 182 1 159
79.2923 + case 7: return stack.pop(); // 176
79.2924 + }
79.2925 +}
79.2926 +function java_lang_String_trimLjava_lang_String(arg0) {
79.2927 + var arg1;
79.2928 + var arg2;
79.2929 + var arg3;
79.2930 + var arg4;
79.2931 + var arg5;
79.2932 +;
79.2933 + var stack = new Array(3);
79.2934 + var gt = 0;
79.2935 + for(;;) switch(gt) {
79.2936 + case 0: stack.push(arg0); // 42
79.2937 + case 1: stack.push(stack.pop().count); // 180 1 97
79.2938 + case 4: arg1 = stack.pop(); // 60
79.2939 + case 5: stack.push(0); // 3
79.2940 + case 6: arg2 = stack.pop(); // 61
79.2941 + case 7: stack.push(arg0); // 42
79.2942 + case 8: stack.push(stack.pop().offset); // 180 1 99
79.2943 + case 11: arg3 = stack.pop(); // 62
79.2944 + case 12: stack.push(arg0); // 42
79.2945 + case 13: stack.push(stack.pop().value); // 180 1 100
79.2946 + case 16: arg4 = stack.pop() // 58 4
79.2947 + case 18: stack.push(arg2); // 28
79.2948 + case 19: stack.push(arg1); // 27
79.2949 + case 20: if (stack.pop() <= stack.pop()) { gt = 40; continue; } // 162 0 20
79.2950 + case 23: stack.push(arg4); // 25 4
79.2951 + case 25: stack.push(arg3); // 29
79.2952 + case 26: stack.push(arg2); // 28
79.2953 + case 27: stack.push(stack.pop() + stack.pop()); // 96
79.2954 + case 28: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2955 + case 29: stack.push(32); // 16 32
79.2956 + case 31: if (stack.pop() < stack.pop()) { gt = 40; continue; } // 163 0 9
79.2957 + case 34: arg2++; // 132 2 1
79.2958 + case 37: gt = 18; continue; // 167 255 237
79.2959 + case 40: stack.push(arg2); // 28
79.2960 + case 41: stack.push(arg1); // 27
79.2961 + case 42: if (stack.pop() <= stack.pop()) { gt = 64; continue; } // 162 0 22
79.2962 + case 45: stack.push(arg4); // 25 4
79.2963 + case 47: stack.push(arg3); // 29
79.2964 + case 48: stack.push(arg1); // 27
79.2965 + case 49: stack.push(stack.pop() + stack.pop()); // 96
79.2966 + case 50: stack.push(1); // 4
79.2967 + case 51: { var tmp = stack.pop(); stack.push(stack.pop() - tmp); } // 100
79.2968 + case 52: { var indx = stack.pop(); stack.push(stack.pop()[indx]); } // 52
79.2969 + case 53: stack.push(32); // 16 32
79.2970 + case 55: if (stack.pop() < stack.pop()) { gt = 64; continue; } // 163 0 9
79.2971 + case 58: arg1 += 255; // 132 1 255
79.2972 + case 61: gt = 40; continue; // 167 255 235
79.2973 + case 64: stack.push(arg2); // 28
79.2974 + case 65: if (stack.pop() > 0) { gt = 76; continue; } // 157 0 11
79.2975 + case 68: stack.push(arg1); // 27
79.2976 + case 69: stack.push(arg0); // 42
79.2977 + case 70: stack.push(stack.pop().count); // 180 1 97
79.2978 + case 73: if (stack.pop() <= stack.pop()) { gt = 85; continue; } // 162 0 12
79.2979 + case 76: stack.push(arg0); // 42
79.2980 + case 77: stack.push(arg2); // 28
79.2981 + case 78: stack.push(arg1); // 27
79.2982 + 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
79.2983 + case 82: gt = 86; continue; // 167 0 4
79.2984 + case 85: stack.push(arg0); // 42
79.2985 + case 86: return stack.pop(); // 176
79.2986 + }
79.2987 +}
79.2988 +*/
79.2989 +function java_lang_String_toStringLjava_lang_String(arg0) {
79.2990 + return arg0.toString();
79.2991 +}
79.2992 +/*
79.2993 +function java_lang_String_toCharArrayAC(arg0) {
79.2994 + var arg1;
79.2995 + var arg2;
79.2996 +;
79.2997 + var stack = new Array(5);
79.2998 + var gt = 0;
79.2999 + for(;;) switch(gt) {
79.3000 + case 0: stack.push(arg0); // 42
79.3001 + case 1: stack.push(stack.pop().count); // 180 1 97
79.3002 + case 4: stack.push(new Array(stack.pop())); // 188 5
79.3003 + case 6: arg1 = stack.pop(); // 76
79.3004 + case 7: stack.push(arg0); // 42
79.3005 + case 8: stack.push(0); // 3
79.3006 + case 9: stack.push(arg0); // 42
79.3007 + case 10: stack.push(stack.pop().count); // 180 1 97
79.3008 + case 13: stack.push(arg1); // 43
79.3009 + case 14: stack.push(0); // 3
79.3010 + 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
79.3011 + case 18: stack.push(arg1); // 43
79.3012 + case 19: return stack.pop(); // 176
79.3013 + }
79.3014 +}
79.3015 +function java_lang_String_formatLjava_lang_StringLjava_lang_StringLjava_lang_Object(arg0,arg1) {
79.3016 + var stack = new Array();
79.3017 + var gt = 0;
79.3018 + for(;;) switch(gt) {
79.3019 + case 0: stack.push(new java_util_Formatter); // 187 0 211
79.3020 + case 3: stack.push(stack[stack.length - 1]); // 89
79.3021 + case 4: { java_util_Formatter_consV(stack.pop()); } // 183 1 174
79.3022 + case 7: stack.push(arg0); // 42
79.3023 + case 8: stack.push(arg1); // 43
79.3024 + 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
79.3025 + case 12: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 175
79.3026 + case 15: return stack.pop(); // 176
79.3027 + }
79.3028 +}
79.3029 +function java_lang_String_formatLjava_lang_StringLjava_util_LocaleLjava_lang_StringLjava_lang_Object(arg0,arg1,arg2) {
79.3030 + var stack = new Array();
79.3031 + var gt = 0;
79.3032 + for(;;) switch(gt) {
79.3033 + case 0: stack.push(new java_util_Formatter); // 187 0 211
79.3034 + case 3: stack.push(stack[stack.length - 1]); // 89
79.3035 + case 4: stack.push(arg0); // 42
79.3036 + case 5: { var v0 = stack.pop(); java_util_Formatter_consVLjava_util_Locale(stack.pop(), v0); } // 183 1 176
79.3037 + case 8: stack.push(arg1); // 43
79.3038 + case 9: stack.push(arg2); // 44
79.3039 + 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
79.3040 + case 13: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 175
79.3041 + case 16: return stack.pop(); // 176
79.3042 + }
79.3043 +}
79.3044 +function java_lang_String_valueOfLjava_lang_StringLjava_lang_Object(arg0) {
79.3045 + var stack = new Array();
79.3046 + var gt = 0;
79.3047 + for(;;) switch(gt) {
79.3048 + case 0: stack.push(arg0); // 42
79.3049 + case 1: if (stack.pop()) { gt = 9; continue; } // 199 0 8
79.3050 + case 4: stack.push("null"); // 18 10
79.3051 + case 6: gt = 13; continue; // 167 0 7
79.3052 + case 9: stack.push(arg0); // 42
79.3053 + case 10: { var self = stack.pop(); stack.push(self.toStringLjava_lang_String(self)); } // 182 1 132
79.3054 + case 13: return stack.pop(); // 176
79.3055 + }
79.3056 +}
79.3057 +function java_lang_String_valueOfLjava_lang_StringAC(arg0) {
79.3058 + var stack = new Array();
79.3059 + var gt = 0;
79.3060 + for(;;) switch(gt) {
79.3061 + case 0: stack.push(new java_lang_String); // 187 0 200
79.3062 + case 3: stack.push(stack[stack.length - 1]); // 89
79.3063 + case 4: stack.push(arg0); // 42
79.3064 + case 5: { var v0 = stack.pop(); java_lang_String_consVAC(stack.pop(), v0); } // 183 1 142
79.3065 + case 8: return stack.pop(); // 176
79.3066 + }
79.3067 +}
79.3068 +function java_lang_String_valueOfLjava_lang_StringACII(arg0,arg1,arg2) {
79.3069 + var stack = new Array();
79.3070 + var gt = 0;
79.3071 + for(;;) switch(gt) {
79.3072 + case 0: stack.push(new java_lang_String); // 187 0 200
79.3073 + case 3: stack.push(stack[stack.length - 1]); // 89
79.3074 + case 4: stack.push(arg0); // 42
79.3075 + case 5: stack.push(arg1); // 27
79.3076 + case 6: stack.push(arg2); // 28
79.3077 + 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
79.3078 + case 10: return stack.pop(); // 176
79.3079 + }
79.3080 +}
79.3081 +function java_lang_String_copyValueOfLjava_lang_StringACII(arg0,arg1,arg2) {
79.3082 + var stack = new Array();
79.3083 + var gt = 0;
79.3084 + for(;;) switch(gt) {
79.3085 + case 0: stack.push(new java_lang_String); // 187 0 200
79.3086 + case 3: stack.push(stack[stack.length - 1]); // 89
79.3087 + case 4: stack.push(arg0); // 42
79.3088 + case 5: stack.push(arg1); // 27
79.3089 + case 6: stack.push(arg2); // 28
79.3090 + 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
79.3091 + case 10: return stack.pop(); // 176
79.3092 + }
79.3093 +}
79.3094 +function java_lang_String_copyValueOfLjava_lang_StringAC(arg0) {
79.3095 + var stack = new Array();
79.3096 + var gt = 0;
79.3097 + for(;;) switch(gt) {
79.3098 + case 0: stack.push(arg0); // 42
79.3099 + case 1: stack.push(0); // 3
79.3100 + case 2: stack.push(arg0); // 42
79.3101 + case 3: stack.push(stack.pop().length); // 190
79.3102 + 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
79.3103 + case 7: return stack.pop(); // 176
79.3104 + }
79.3105 +}
79.3106 +function java_lang_String_valueOfLjava_lang_StringZ(arg0) {
79.3107 + var stack = new Array();
79.3108 + var gt = 0;
79.3109 + for(;;) switch(gt) {
79.3110 + case 0: stack.push(arg0); // 26
79.3111 + case 1: if (stack.pop() == 0) { gt = 9; continue; } // 153 0 8
79.3112 + case 4: stack.push("true"); // 18 12
79.3113 + case 6: gt = 11; continue; // 167 0 5
79.3114 + case 9: stack.push("false"); // 18 8
79.3115 + case 11: return stack.pop(); // 176
79.3116 + }
79.3117 +}
79.3118 +function java_lang_String_valueOfLjava_lang_StringC(arg0) {
79.3119 + var arg1;
79.3120 + var stack = new Array();
79.3121 + var gt = 0;
79.3122 + for(;;) switch(gt) {
79.3123 + case 0: stack.push(1); // 4
79.3124 + case 1: stack.push(new Array(stack.pop())); // 188 5
79.3125 + case 3: stack.push(stack[stack.length - 1]); // 89
79.3126 + case 4: stack.push(0); // 3
79.3127 + case 5: stack.push(arg0); // 26
79.3128 + case 6: { var value = stack.pop(); var indx = stack.pop(); stack.pop()[indx] = value; } // 85
79.3129 + case 7: arg1 = stack.pop(); // 76
79.3130 + case 8: stack.push(new java_lang_String); // 187 0 200
79.3131 + case 11: stack.push(stack[stack.length - 1]); // 89
79.3132 + case 12: stack.push(0); // 3
79.3133 + case 13: stack.push(1); // 4
79.3134 + case 14: stack.push(arg1); // 43
79.3135 + 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
79.3136 + case 18: return stack.pop(); // 176
79.3137 + }
79.3138 +}
79.3139 +function java_lang_String_valueOfLjava_lang_StringI(arg0) {
79.3140 + var stack = new Array();
79.3141 + var gt = 0;
79.3142 + for(;;) switch(gt) {
79.3143 + case 0: stack.push(arg0); // 26
79.3144 + case 1: stack.push(10); // 16 10
79.3145 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Integer_toStringLjava_lang_StringII(v0, v1)); } // 184 1 125
79.3146 + case 6: return stack.pop(); // 176
79.3147 + }
79.3148 +}
79.3149 +function java_lang_String_valueOfLjava_lang_StringJ(arg0) {
79.3150 + var arg1;
79.3151 + var stack = new Array();
79.3152 + var gt = 0;
79.3153 + for(;;) switch(gt) {
79.3154 + case 0: stack.push(arg0); // 30
79.3155 + case 1: stack.push(10); // 16 10
79.3156 + case 3: { var v1 = stack.pop(); var v0 = stack.pop(); stack.push(java_lang_Long_toStringLjava_lang_StringJI(v0, v1)); } // 184 1 126
79.3157 + case 6: return stack.pop(); // 176
79.3158 + }
79.3159 +}
79.3160 +function java_lang_String_valueOfLjava_lang_StringF(arg0) {
79.3161 + var stack = new Array();
79.3162 + var gt = 0;
79.3163 + for(;;) switch(gt) {
79.3164 + case 0: stack.push(arg0); // 34
79.3165 + case 1: { var v0 = stack.pop(); stack.push(java_lang_Float_toStringLjava_lang_StringF(v0)); } // 184 1 122
79.3166 + case 4: return stack.pop(); // 176
79.3167 + }
79.3168 +}
79.3169 +function java_lang_String_valueOfLjava_lang_StringD(arg0) {
79.3170 + var arg1;
79.3171 + var stack = new Array();
79.3172 + var gt = 0;
79.3173 + for(;;) switch(gt) {
79.3174 + case 0: stack.push(arg0); // 38
79.3175 + case 1: { var v0 = stack.pop(); stack.push(java_lang_Double_toStringLjava_lang_StringD(v0)); } // 184 1 121
79.3176 + case 4: return stack.pop(); // 176
79.3177 + }
79.3178 +}
79.3179 +function java_lang_String_internLjava_lang_String(arg0) {
79.3180 + // no code found for null
79.3181 +}
79.3182 +function java_lang_String_compareToILjava_lang_Object(arg0,arg1) {
79.3183 + var arg2;
79.3184 +;
79.3185 + var stack = new Array(2);
79.3186 + var gt = 0;
79.3187 + for(;;) switch(gt) {
79.3188 + case 0: stack.push(arg0); // 42
79.3189 + case 1: stack.push(arg1); // 43
79.3190 + case 2: if(stack[stack.length - 1].$instOf_java_lang_String != 1) throw {}; // 192 0 200
79.3191 + case 5: { var v0 = stack.pop(); var self = stack.pop(); stack.push(self.compareToILjava_lang_String(self, v0)); } // 182 1 148
79.3192 + case 8: return stack.pop(); // 172
79.3193 + }
79.3194 +}
79.3195 +function java_lang_String_classV() {
79.3196 + var stack = new Array();
79.3197 + var gt = 0;
79.3198 + for(;;) switch(gt) {
79.3199 + case 0: stack.push(0); // 3
79.3200 + case 1: stack.push(new Array(stack.pop())); // 189 0 183
79.3201 + case 4: java_lang_String_serialPersistentFields = stack.pop(); // 179 1 101
79.3202 + case 7: stack.push(new java_lang_String$CaseInsensitiveComparator); // 187 0 202
79.3203 + case 10: stack.push(stack[stack.length - 1]); // 89
79.3204 + case 11: // 1
79.3205 + case 12: { var v0 = stack.pop(); java_lang_String$CaseInsensitiveComparator_consVLjava_lang_String$1(stack.pop(), v0); } // 183 1 160
79.3206 + case 15: java_lang_String_CASE_INSENSITIVE_ORDER = stack.pop(); // 179 1 102
79.3207 + case 18: return; // 177
79.3208 + }
79.3209 +}
79.3210 +*/
79.3211 +var java_lang_String_serialVersionUID = 0;
79.3212 +var java_lang_String_serialPersistentFields = 0;
79.3213 +var java_lang_String_CASE_INSENSITIVE_ORDER = 0;
79.3214 +function java_lang_String() {
79.3215 + /** the real value of this 'string' we delegate to */
79.3216 + this.r = '';
79.3217 +
79.3218 + var self = this;
79.3219 + /*
79.3220 + this.value = 0;
79.3221 + this.offset = 0;
79.3222 + this.count = 0;
79.3223 + this.hash = 0;
79.3224 + */
79.3225 + this.toString = function() { return self.r; };
79.3226 +}
79.3227 +java_lang_String.prototype = new String;
79.3228 +//java_lang_String_classV();
79.3229 +
79.3230 +/* new method for JavaScript String */
79.3231 +String.prototype.charAtCI = java_lang_String_charAtCI;
79.3232 +String.prototype.lengthI = java_lang_String_lengthI;
79.3233 +String.prototype.isEmptyZ = java_lang_String_isEmptyZ;
79.3234 +String.prototype.getCharsVIIACAI = java_lang_String_getCharsVIIACAI;
79.3235 +String.prototype.toStringLjava_lang_String = java_lang_String_toStringLjava_lang_String;
79.3236 +String.prototype.$instOf_java_lang_String = true;
79.3237 +String.prototype.$instOf_java_io_Serializable = true;
79.3238 +String.prototype.$instOf_java_lang_Comparable = true;
79.3239 +String.prototype.$instOf_java_lang_CharSequence = true;
79.3240 +
79.3241 +/*
79.3242 + this.lengthI = java_lang_String_lengthI;
79.3243 + this.isEmptyZ = java_lang_String_isEmptyZ;
79.3244 + this.charAtCI = java_lang_String_charAtCI;
79.3245 + this.codePointAtII = java_lang_String_codePointAtII;
79.3246 + this.codePointBeforeII = java_lang_String_codePointBeforeII;
79.3247 + this.codePointCountIII = java_lang_String_codePointCountIII;
79.3248 + this.offsetByCodePointsIII = java_lang_String_offsetByCodePointsIII;
79.3249 + this.getCharsVACI = java_lang_String_getCharsVACI;
79.3250 + this.getCharsVIIACI = java_lang_String_getCharsVIIACI;
79.3251 + this.getBytesVIIABI = java_lang_String_getBytesVIIABI;
79.3252 + this.getBytesABLjava_lang_String = java_lang_String_getBytesABLjava_lang_String;
79.3253 + this.getBytesABLjava_nio_charset_Charset = java_lang_String_getBytesABLjava_nio_charset_Charset;
79.3254 + this.getBytesAB = java_lang_String_getBytesAB;
79.3255 + this.equalsZLjava_lang_Object = java_lang_String_equalsZLjava_lang_Object;
79.3256 + this.contentEqualsZLjava_lang_StringBuffer = java_lang_String_contentEqualsZLjava_lang_StringBuffer;
79.3257 + this.contentEqualsZLjava_lang_CharSequence = java_lang_String_contentEqualsZLjava_lang_CharSequence;
79.3258 + this.equalsIgnoreCaseZLjava_lang_String = java_lang_String_equalsIgnoreCaseZLjava_lang_String;
79.3259 + this.compareToILjava_lang_String = java_lang_String_compareToILjava_lang_String;
79.3260 + this.compareToIgnoreCaseILjava_lang_String = java_lang_String_compareToIgnoreCaseILjava_lang_String;
79.3261 + this.regionMatchesZILjava_lang_StringII = java_lang_String_regionMatchesZILjava_lang_StringII;
79.3262 + this.regionMatchesZZILjava_lang_StringII = java_lang_String_regionMatchesZZILjava_lang_StringII;
79.3263 + this.startsWithZLjava_lang_StringI = java_lang_String_startsWithZLjava_lang_StringI;
79.3264 + this.startsWithZLjava_lang_String = java_lang_String_startsWithZLjava_lang_String;
79.3265 + this.endsWithZLjava_lang_String = java_lang_String_endsWithZLjava_lang_String;
79.3266 + this.hashCodeI = java_lang_String_hashCodeI;
79.3267 + this.indexOfII = java_lang_String_indexOfII;
79.3268 + this.indexOfIII = java_lang_String_indexOfIII;
79.3269 + this.lastIndexOfII = java_lang_String_lastIndexOfII;
79.3270 + this.lastIndexOfIII = java_lang_String_lastIndexOfIII;
79.3271 + this.indexOfILjava_lang_String = java_lang_String_indexOfILjava_lang_String;
79.3272 + this.indexOfILjava_lang_StringI = java_lang_String_indexOfILjava_lang_StringI;
79.3273 + this.lastIndexOfILjava_lang_String = java_lang_String_lastIndexOfILjava_lang_String;
79.3274 + this.lastIndexOfILjava_lang_StringI = java_lang_String_lastIndexOfILjava_lang_StringI;
79.3275 + this.substringLjava_lang_StringI = java_lang_String_substringLjava_lang_StringI;
79.3276 + this.substringLjava_lang_StringII = java_lang_String_substringLjava_lang_StringII;
79.3277 + this.subSequenceLjava_lang_CharSequenceII = java_lang_String_subSequenceLjava_lang_CharSequenceII;
79.3278 + this.concatLjava_lang_StringLjava_lang_String = java_lang_String_concatLjava_lang_StringLjava_lang_String;
79.3279 + this.replaceLjava_lang_StringCC = java_lang_String_replaceLjava_lang_StringCC;
79.3280 + this.matchesZLjava_lang_String = java_lang_String_matchesZLjava_lang_String;
79.3281 + this.containsZLjava_lang_CharSequence = java_lang_String_containsZLjava_lang_CharSequence;
79.3282 + this.replaceFirstLjava_lang_StringLjava_lang_StringLjava_lang_String = java_lang_String_replaceFirstLjava_lang_StringLjava_lang_StringLjava_lang_String;
79.3283 + this.replaceAllLjava_lang_StringLjava_lang_StringLjava_lang_String = java_lang_String_replaceAllLjava_lang_StringLjava_lang_StringLjava_lang_String;
79.3284 + this.replaceLjava_lang_StringLjava_lang_CharSequenceLjava_lang_CharSequence = java_lang_String_replaceLjava_lang_StringLjava_lang_CharSequenceLjava_lang_CharSequence;
79.3285 + this.splitALjava_lang_StringLjava_lang_StringI = java_lang_String_splitALjava_lang_StringLjava_lang_StringI;
79.3286 + this.splitALjava_lang_StringLjava_lang_String = java_lang_String_splitALjava_lang_StringLjava_lang_String;
79.3287 + this.toLowerCaseLjava_lang_StringLjava_util_Locale = java_lang_String_toLowerCaseLjava_lang_StringLjava_util_Locale;
79.3288 + this.toLowerCaseLjava_lang_String = java_lang_String_toLowerCaseLjava_lang_String;
79.3289 + this.toUpperCaseLjava_lang_StringLjava_util_Locale = java_lang_String_toUpperCaseLjava_lang_StringLjava_util_Locale;
79.3290 + this.toUpperCaseLjava_lang_String = java_lang_String_toUpperCaseLjava_lang_String;
79.3291 + this.trimLjava_lang_String = java_lang_String_trimLjava_lang_String;
79.3292 + this.toStringLjava_lang_String = java_lang_String_toStringLjava_lang_String;
79.3293 + this.toCharArrayAC = java_lang_String_toCharArrayAC;
79.3294 + this.internLjava_lang_String = java_lang_String_internLjava_lang_String;
79.3295 + this.compareToILjava_lang_Object = java_lang_String_compareToILjava_lang_Object;
79.3296 + */
79.3297 +
79.3298 +
79.3299 +
80.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
80.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/InstanceSubTest.java Thu Oct 11 06:16:00 2012 -0700
80.3 @@ -0,0 +1,15 @@
80.4 +package org.apidesign.vm4brwsr;
80.5 +
80.6 +/** Checks if everything works OK, when we switch the
80.7 + * order of loaded classes.
80.8 + *
80.9 + * @author Jaroslav Tulach <jtulach@netbeans.org>
80.10 + */
80.11 +public class InstanceSubTest extends InstanceTest {
80.12 +
80.13 + @Override
80.14 + protected String startCompilationWith() {
80.15 + return "org/apidesign/vm4brwsr/InstanceSub";
80.16 + }
80.17 +
80.18 +}
81.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/InstanceTest.java Fri Sep 28 14:58:21 2012 +0200
81.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/InstanceTest.java Thu Oct 11 06:16:00 2012 -0700
81.3 @@ -102,11 +102,15 @@
81.4 );
81.5 }
81.6
81.7 - private static void assertExec(String msg, String methodName, Object expRes, Object... args) throws Exception {
81.8 + protected String startCompilationWith() {
81.9 + return "org/apidesign/vm4brwsr/Instance";
81.10 + }
81.11 +
81.12 + private void assertExec(
81.13 + String msg, String methodName, Object expRes, Object... args
81.14 + ) throws Exception {
81.15 StringBuilder sb = new StringBuilder();
81.16 - Invocable i = StaticMethodTest.compileClass(sb,
81.17 - "org/apidesign/vm4brwsr/Instance"
81.18 - );
81.19 + Invocable i = StaticMethodTest.compileClass(sb, startCompilationWith());
81.20
81.21 Object ret = null;
81.22 try {
82.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethod.java Fri Sep 28 14:58:21 2012 +0200
82.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethod.java Thu Oct 11 06:16:00 2012 -0700
82.3 @@ -17,6 +17,8 @@
82.4 */
82.5 package org.apidesign.vm4brwsr;
82.6
82.7 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
82.8 +
82.9 /**
82.10 *
82.11 * @author Jaroslav Tulach <jtulach@netbeans.org>
82.12 @@ -61,6 +63,16 @@
82.13 public static long orOrAnd(boolean doOr, int a, int b) {
82.14 return doOr ? a | b : a & b;
82.15 }
82.16 + public static int shiftLeft(int what, int much) {
82.17 + return what << much;
82.18 + }
82.19 + public static int shiftArithmRight(int what, int much, boolean signed) {
82.20 + if (signed) {
82.21 + return what >> much;
82.22 + } else {
82.23 + return what >>> much;
82.24 + }
82.25 + }
82.26 public static long factRec(int n) {
82.27 if (n <= 1) {
82.28 return 1;
82.29 @@ -81,4 +93,16 @@
82.30 cnt++;
82.31 return cnt;
82.32 }
82.33 +
82.34 + @JavaScriptBody(
82.35 + args={"i","j"}, body="return (i + j).toString();"
82.36 + )
82.37 + public static String i2s(int i, int j) {
82.38 + throw new IllegalStateException();
82.39 + }
82.40 +
82.41 + static {
82.42 + // check order of initializers
82.43 + StaticUse.NON_NULL.equals(new Object());
82.44 + }
82.45 }
83.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethodTest.java Fri Sep 28 14:58:21 2012 +0200
83.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethodTest.java Thu Oct 11 06:16:00 2012 -0700
83.3 @@ -143,6 +143,56 @@
83.4 );
83.5 }
83.6
83.7 + @Test public void shiftLeftInJava() throws Exception {
83.8 + int res = StaticMethod.shiftLeft(1, 8);
83.9 + assertEquals(res, 256);
83.10 + }
83.11 +
83.12 + @Test public void shiftLeftInJS() throws Exception {
83.13 + assertExec(
83.14 + "Setting 9th bit",
83.15 + "org_apidesign_vm4brwsr_StaticMethod_shiftLeftIII",
83.16 + Double.valueOf(256),
83.17 + 1, 8
83.18 + );
83.19 + }
83.20 +
83.21 + @Test public void shiftRightInJava() throws Exception {
83.22 + int res = StaticMethod.shiftArithmRight(-8, 3, true);
83.23 + assertEquals(res, -1);
83.24 + }
83.25 +
83.26 + @Test public void shiftRightInJS() throws Exception {
83.27 + assertExec(
83.28 + "Get -1",
83.29 + "org_apidesign_vm4brwsr_StaticMethod_shiftArithmRightIIIZ",
83.30 + Double.valueOf(-1),
83.31 + -8, 3, true
83.32 + );
83.33 + }
83.34 + @Test public void unsignedShiftRightInJava() throws Exception {
83.35 + int res = StaticMethod.shiftArithmRight(8, 3, false);
83.36 + assertEquals(res, 1);
83.37 + }
83.38 +
83.39 + @Test public void unsignedShiftRightInJS() throws Exception {
83.40 + assertExec(
83.41 + "Get -1",
83.42 + "org_apidesign_vm4brwsr_StaticMethod_shiftArithmRightIIIZ",
83.43 + Double.valueOf(1),
83.44 + 8, 3, false
83.45 + );
83.46 + }
83.47 +
83.48 + @Test public void javaScriptBody() throws Exception {
83.49 + assertExec(
83.50 + "JavaScript string",
83.51 + "org_apidesign_vm4brwsr_StaticMethod_i2sLjava_lang_StringII",
83.52 + "333",
83.53 + 330, 3
83.54 + );
83.55 + }
83.56 +
83.57 private static void assertExec(String msg, String methodName, Object expRes, Object... args) throws Exception {
83.58 StringBuilder sb = new StringBuilder();
83.59 Invocable i = compileClass(sb, "org/apidesign/vm4brwsr/StaticMethod");
84.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
84.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/StaticUse.java Thu Oct 11 06:16:00 2012 -0700
84.3 @@ -0,0 +1,5 @@
84.4 +package org.apidesign.vm4brwsr;
84.5 +
84.6 +public class StaticUse {
84.7 + public static final Object NON_NULL = new Object();
84.8 +}
85.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
85.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/StringSample.java Thu Oct 11 06:16:00 2012 -0700
85.3 @@ -0,0 +1,38 @@
85.4 +package org.apidesign.vm4brwsr;
85.5 +
85.6 +/**
85.7 + *
85.8 + * @author Jaroslav Tulach <jtulach@netbeans.org>
85.9 + */
85.10 +public class StringSample {
85.11 + public static final String HELLO = "Hello World!";
85.12 + private static int counter;
85.13 +
85.14 + private final int cnt;
85.15 + public StringSample() {
85.16 + cnt = ++counter;
85.17 + }
85.18 +
85.19 +
85.20 + public static char sayHello(int indx) {
85.21 + return HELLO.charAt(indx);
85.22 + }
85.23 +
85.24 + public static String fromChars(char a, char b, char c) {
85.25 + char[] arr = { a, b, c };
85.26 + return new String(arr).toString();
85.27 + }
85.28 +
85.29 + public static String toStringTest(int howMuch) {
85.30 + StringSample ss = null;
85.31 + for (int i = 0; i < howMuch; i++) {
85.32 + ss = new StringSample();
85.33 + }
85.34 + return ss.toString().toString();
85.35 + }
85.36 +
85.37 + @Override
85.38 + public String toString() {
85.39 + return HELLO + cnt;
85.40 + }
85.41 +}
86.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
86.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/StringTest.java Thu Oct 11 06:16:00 2012 -0700
86.3 @@ -0,0 +1,65 @@
86.4 +package org.apidesign.vm4brwsr;
86.5 +
86.6 +import javax.script.Invocable;
86.7 +import javax.script.ScriptException;
86.8 +import org.testng.annotations.Test;
86.9 +import static org.testng.Assert.*;
86.10 +
86.11 +/**
86.12 + *
86.13 + * @author Jaroslav Tulach <jtulach@netbeans.org>
86.14 + */
86.15 +public class StringTest {
86.16 + @Test public void firstChar() throws Exception {
86.17 + assertExec(
86.18 + "First char in Hello is H",
86.19 + "org_apidesign_vm4brwsr_StringSample_sayHelloCI",
86.20 + "H", 0
86.21 + );
86.22 + }
86.23 +
86.24 + @Test public void fromChars() throws Exception {
86.25 + assertExec(
86.26 + "First char in Hello is ABC",
86.27 + "org_apidesign_vm4brwsr_StringSample_fromCharsLjava_lang_StringCCC",
86.28 + "ABC", 'A', 'B', 'C'
86.29 + );
86.30 + }
86.31 +
86.32 + @Test(timeOut=10000) public void toStringConcatenation() throws Exception {
86.33 + assertExec(
86.34 + "Five executions should generate 5Hello World!",
86.35 + "org_apidesign_vm4brwsr_StringSample_toStringTestLjava_lang_StringI",
86.36 + "Hello World!5", 5
86.37 + );
86.38 + }
86.39 + @Test public void toStringConcatenationJava() throws Exception {
86.40 + assertEquals("Hello World!5", StringSample.toStringTest(5));
86.41 + }
86.42 +
86.43 + private static void assertExec(String msg, String methodName, Object expRes, Object... args) throws Exception {
86.44 + StringBuilder sb = new StringBuilder();
86.45 + Invocable i = StaticMethodTest.compileClass(sb,
86.46 + "org/apidesign/vm4brwsr/StringSample",
86.47 + "java/lang/String"
86.48 + );
86.49 +
86.50 + Object ret = null;
86.51 + try {
86.52 + ret = i.invokeFunction(methodName, args);
86.53 + } catch (ScriptException ex) {
86.54 + fail("Execution failed in " + sb, ex);
86.55 + } catch (NoSuchMethodException ex) {
86.56 + fail("Cannot find method in " + sb, ex);
86.57 + }
86.58 + if (ret == null && expRes == null) {
86.59 + return;
86.60 + }
86.61 + if (expRes.equals(ret)) {
86.62 + return;
86.63 + }
86.64 + assertEquals(ret, expRes, msg + "was: " + ret + "\n" + sb);
86.65 +
86.66 + }
86.67 +
86.68 +}