diff options
author | Tom Tromey <tromey@redhat.com> | 2005-07-16 01:27:14 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2005-07-16 01:27:14 +0000 |
commit | b0fa81eea9a270f23d6ad67ca7a6d25c18d20da1 (patch) | |
tree | 8762d1f992e2f725a6bde1ff966ed6f1e5f4f823 /libjava/java/lang | |
parent | ea54b29342c8506acb4f858c68340c44b72e3532 (diff) | |
download | gcc-b0fa81eea9a270f23d6ad67ca7a6d25c18d20da1.zip gcc-b0fa81eea9a270f23d6ad67ca7a6d25c18d20da1.tar.gz gcc-b0fa81eea9a270f23d6ad67ca7a6d25c18d20da1.tar.bz2 |
Major merge with Classpath.
Removed many duplicate files.
* HACKING: Updated.x
* classpath: Imported new directory.
* standard.omit: New file.
* Makefile.in, aclocal.m4, configure: Rebuilt.
* sources.am: New file.
* configure.ac: Run Classpath configure script. Moved code around
to support. Disable xlib AWT peers (temporarily).
* Makefile.am (SUBDIRS): Added 'classpath'
(JAVAC): Removed.
(AM_CPPFLAGS): Added more -I options.
(BOOTCLASSPATH): Simplified.
Completely redid how sources are built.
Include sources.am.
* include/Makefile.am (tool_include__HEADERS): Removed jni.h.
* include/jni.h: Removed (in Classpath).
* scripts/classes.pl: Updated to look at built classes.
* scripts/makemake.tcl: New file.
* testsuite/libjava.jni/jni.exp (gcj_jni_compile_c_to_so): Added
-I options.
(gcj_jni_invocation_compile_c_to_binary): Likewise.
From-SVN: r102082
Diffstat (limited to 'libjava/java/lang')
118 files changed, 0 insertions, 22097 deletions
diff --git a/libjava/java/lang/AbstractMethodError.java b/libjava/java/lang/AbstractMethodError.java deleted file mode 100644 index b9eb622..0000000 --- a/libjava/java/lang/AbstractMethodError.java +++ /dev/null @@ -1,75 +0,0 @@ -/* AbstractMethodError.java -- thrown if an abstract method is invoked - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * An <code>AbstractMethodError</code> is thrown when an application attempts - * to access an abstract method. Compilers typically detect this error, but - * it can be thrown at run time if the definition of a class has changed - * since the application was last compiled. This can also occur when - * reflecting on methods. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public class AbstractMethodError extends IncompatibleClassChangeError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -1654391082989018462L; - - /** - * Create an error without a message. - */ - public AbstractMethodError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public AbstractMethodError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/ArithmeticException.java b/libjava/java/lang/ArithmeticException.java deleted file mode 100644 index 5acea43..0000000 --- a/libjava/java/lang/ArithmeticException.java +++ /dev/null @@ -1,77 +0,0 @@ -/* ArithmeticException.java -- exception thrown to indicate conditions - like divide by zero. - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown when a math error has occured, such as trying to divide an - * integer by zero. For example:<br> - * <pre> - * int i = 0; - * int j = 2 / i; - * </pre> - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @status updated to 1.4 - */ -public class ArithmeticException extends RuntimeException -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 2256477558314496007L; - - /** - * Create an exception without a message. - */ - public ArithmeticException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public ArithmeticException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/ArrayIndexOutOfBoundsException.java b/libjava/java/lang/ArrayIndexOutOfBoundsException.java deleted file mode 100644 index 371623b..0000000 --- a/libjava/java/lang/ArrayIndexOutOfBoundsException.java +++ /dev/null @@ -1,87 +0,0 @@ -/* ArrayIndexOutOfBoundsException.java -- exception thrown when accessing - an illegal index. - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown when attempting to access a position outside the valid range of - * an array. For example:<br> - * <pre> - * int[] i = { 1 }; - * i[1] = 2; - * </pre> - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @status updated to 1.4 - */ -public class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -5116101128118950844L; - - /** - * Create an exception without a message. - */ - public ArrayIndexOutOfBoundsException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public ArrayIndexOutOfBoundsException(String s) - { - super(s); - } - - /** - * Create an exception indicating the illegal index. - * - * @param index the invalid index - */ - public ArrayIndexOutOfBoundsException(int index) - { - super("Array index out of range: " + index); - } -} diff --git a/libjava/java/lang/ArrayStoreException.java b/libjava/java/lang/ArrayStoreException.java deleted file mode 100644 index 042e78c..0000000 --- a/libjava/java/lang/ArrayStoreException.java +++ /dev/null @@ -1,77 +0,0 @@ -/* ArrayStoreException.java -- exception thrown to when trying to store an - object into an array of a different type. - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown when trying to store an object of the wrong runtime type in an - * array. For example:<br> - * <pre> - * Object[] o = new Integer[1]; - * o[0] = "oops"; - * </pre> - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @status updated to 1.4 - */ -public class ArrayStoreException extends RuntimeException -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -4522193890499838241L; - - /** - * Create an exception without a message. - */ - public ArrayStoreException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public ArrayStoreException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/AssertionError.java b/libjava/java/lang/AssertionError.java deleted file mode 100644 index 778eb58..0000000 --- a/libjava/java/lang/AssertionError.java +++ /dev/null @@ -1,148 +0,0 @@ -/* AssertionError.java -- indication of a failed assertion - Copyright (C) 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * An assertion error normally occurs as a result of the <code>assert</code> - * statement added in JDK 1.4, to indicate that an assertion failed. There - * are enough constructors to ensure that - * <code>new AssertionError(<em>expression</em>)</code> will work for all - * expressions, regardless of type, as if the error message were given by - * the string <code>"" + <em>expression</em></code>. This extends Error, - * because you usually do not want to inadvertently trap an assertion failure. - * - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.4 - * @status updated to 1.4 - */ -public class AssertionError extends Error -{ - /** - * Compatible with JDK 1.4+. - */ - private static final long serialVersionUID = -5013299493970297370L; - - /** - * Construct an AssertionError with no detail message. - */ - public AssertionError() - { - } - - /** - * Construct an AssertionError with the string conversion of the given - * object as its error message. If the object is a Throwable, it is also - * set as the cause of this error. - * - * @param msg the source of the error message - * @see Throwable#getCause() - */ - public AssertionError(Object msg) - { - super("" + msg); - if (msg instanceof Throwable) - initCause((Throwable) msg); - } - - /** - * Construct an AssertionError with the string conversion of the given - * boolean as its error message. - * - * @param msg the source of the error message - */ - public AssertionError(boolean msg) - { - super(msg ? "true" : "false"); - } - - /** - * Construct an AssertionError with the string conversion of the given - * char as its error message. - * - * @param msg the source of the error message - */ - public AssertionError(char msg) - { - super(String.valueOf(msg)); - } - - /** - * Construct an AssertionError with the string conversion of the given - * int as its error message. - * - * @param msg the source of the error message - */ - public AssertionError(int msg) - { - super(Integer.toString(msg, 10)); - } - - /** - * Construct an AssertionError with the string conversion of the given - * long as its error message. - * - * @param msg the source of the error message - */ - public AssertionError(long msg) - { - super(Long.toString(msg)); - } - - /** - * Construct an AssertionError with the string conversion of the given - * float as its error message. - * - * @param msg the source of the error message - */ - public AssertionError(float msg) - { - super(Float.toString(msg)); - } - - /** - * Construct an AssertionError with the string conversion of the given - * double as its error message. - * - * @param msg the source of the error message - */ - public AssertionError(double msg) - { - super(Double.toString(msg)); - } -} diff --git a/libjava/java/lang/Boolean.java b/libjava/java/lang/Boolean.java deleted file mode 100644 index b691028..0000000 --- a/libjava/java/lang/Boolean.java +++ /dev/null @@ -1,224 +0,0 @@ -/* Boolean.java -- object wrapper for boolean - Copyright (C) 1998, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -import java.io.Serializable; - -/** - * Instances of class <code>Boolean</code> represent primitive - * <code>boolean</code> values. - * - * @author Paul Fisher - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.0 - * @status updated to 1.4 - */ -public final class Boolean implements Serializable -{ - /** - * Compatible with JDK 1.0.2+. - */ - private static final long serialVersionUID = -3665804199014368530L; - - /** - * This field is a <code>Boolean</code> object representing the - * primitive value <code>true</code>. This instance is returned - * by the static <code>valueOf()</code> methods if they return - * a <code>Boolean</code> representing <code>true</code>. - */ - public static final Boolean TRUE = new Boolean(true); - - /** - * This field is a <code>Boolean</code> object representing the - * primitive value <code>false</code>. This instance is returned - * by the static <code>valueOf()</code> methods if they return - * a <code>Boolean</code> representing <code>false</code>. - */ - public static final Boolean FALSE = new Boolean(false); - - /** - * The primitive type <code>boolean</code> is represented by this - * <code>Class</code> object. - * - * @since 1.1 - */ - public static final Class TYPE = VMClassLoader.getPrimitiveClass('Z'); - - /** - * The immutable value of this Boolean. - * @serial the wrapped value - */ - private final boolean value; - - /** - * Create a <code>Boolean</code> object representing the value of the - * argument <code>value</code>. In general the use of the static - * method <code>valueof(boolean)</code> is more efficient since it will - * not create a new object. - * - * @param value the primitive value of this <code>Boolean</code> - * @see #valueOf(boolean) - */ - public Boolean(boolean value) - { - this.value = value; - } - - /** - * Creates a <code>Boolean</code> object representing the primitive - * <code>true</code> if and only if <code>s</code> matches - * the string "true" ignoring case, otherwise the object will represent - * the primitive <code>false</code>. In general the use of the static - * method <code>valueof(String)</code> is more efficient since it will - * not create a new object. - * - * @param s the <code>String</code> representation of <code>true</code> - * or false - */ - public Boolean(String s) - { - value = "true".equalsIgnoreCase(s); - } - - /** - * Return the primitive <code>boolean</code> value of this - * <code>Boolean</code> object. - * - * @return true or false, depending on the value of this Boolean - */ - public boolean booleanValue() - { - return value; - } - - /** - * Returns the Boolean <code>TRUE</code> if the given boolean is - * <code>true</code>, otherwise it will return the Boolean - * <code>FALSE</code>. - * - * @param b the boolean to wrap - * @return the wrapper object - * @see #TRUE - * @see #FALSE - * @since 1.4 - */ - public static Boolean valueOf(boolean b) - { - return b ? TRUE : FALSE; - } - - /** - * Returns the Boolean <code>TRUE</code> if and only if the given - * String is equal, ignoring case, to the the String "true", otherwise - * it will return the Boolean <code>FALSE</code>. - * - * @param s the string to convert - * @return a wrapped boolean from the string - */ - public static Boolean valueOf(String s) - { - return "true".equalsIgnoreCase(s) ? TRUE : FALSE; - } - - /** - * Returns "true" if the value of the give boolean is <code>true</code> and - * returns "false" if the value of the given boolean is <code>false</code>. - * - * @param b the boolean to convert - * @return the string representation of the boolean - * @since 1.4 - */ - public static String toString(boolean b) - { - return b ? "true" : "false"; - } - - /** - * Returns "true" if the value of this object is <code>true</code> and - * returns "false" if the value of this object is <code>false</code>. - * - * @return the string representation of this - */ - public String toString() - { - return value ? "true" : "false"; - } - - /** - * Returns the integer <code>1231</code> if this object represents - * the primitive <code>true</code> and the integer <code>1237</code> - * otherwise. - * - * @return the hash code - */ - public int hashCode() - { - return value ? 1231 : 1237; - } - - /** - * If the <code>obj</code> is an instance of <code>Boolean</code> and - * has the same primitive value as this object then <code>true</code> - * is returned. In all other cases, including if the <code>obj</code> - * is <code>null</code>, <code>false</code> is returned. - * - * @param obj possibly an instance of any <code>Class</code> - * @return true if <code>obj</code> equals this - */ - public boolean equals(Object obj) - { - return obj instanceof Boolean && value == ((Boolean) obj).value; - } - - /** - * If the value of the system property <code>name</code> matches - * "true" ignoring case then the function returns <code>true</code>. - * - * @param name the property name to look up - * @return true if the property resulted in "true" - * @throws SecurityException if accessing the system property is forbidden - * @see System#getProperty(String) - */ - public static boolean getBoolean(String name) - { - if (name == null || "".equals(name)) - return false; - return "true".equalsIgnoreCase(System.getProperty(name)); - } -} diff --git a/libjava/java/lang/Byte.java b/libjava/java/lang/Byte.java deleted file mode 100644 index 338e216..0000000 --- a/libjava/java/lang/Byte.java +++ /dev/null @@ -1,357 +0,0 @@ -/* Byte.java -- object wrapper for byte - Copyright (C) 1998, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Instances of class <code>Byte</code> represent primitive <code>byte</code> - * values. - * - * Additionally, this class provides various helper functions and variables - * useful to bytes. - * - * @author Paul Fisher - * @author John Keiser - * @author Per Bothner - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.1 - * @status updated to 1.4 - */ -public final class Byte extends Number implements Comparable -{ - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = -7183698231559129828L; - - /** - * The minimum value a <code>byte</code> can represent is -128 (or - * -2<sup>7</sup>). - */ - public static final byte MIN_VALUE = -128; - - /** - * The maximum value a <code>byte</code> can represent is 127 (or - * 2<sup>7</sup> - 1). - */ - public static final byte MAX_VALUE = 127; - - /** - * The primitive type <code>byte</code> is represented by this - * <code>Class</code> object. - */ - public static final Class TYPE = VMClassLoader.getPrimitiveClass('B'); - - /** - * The immutable value of this Byte. - * - * @serial the wrapped byte - */ - private final byte value; - - /** - * Create a <code>Byte</code> object representing the value of the - * <code>byte</code> argument. - * - * @param value the value to use - */ - public Byte(byte value) - { - this.value = value; - } - - /** - * Create a <code>Byte</code> object representing the value specified - * by the <code>String</code> argument - * - * @param s the string to convert - * @throws NumberFormatException if the String does not contain a byte - * @see #valueOf(String) - */ - public Byte(String s) - { - value = parseByte(s, 10); - } - - /** - * Converts the <code>byte</code> to a <code>String</code> and assumes - * a radix of 10. - * - * @param b the <code>byte</code> to convert to <code>String</code> - * @return the <code>String</code> representation of the argument - */ - public static String toString(byte b) - { - return String.valueOf(b); - } - - /** - * Converts the specified <code>String</code> into a <code>byte</code>. - * This function assumes a radix of 10. - * - * @param s the <code>String</code> to convert - * @return the <code>byte</code> value of <code>s</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>byte</code> - * @see #parseByte(String) - */ - public static byte parseByte(String s) - { - return parseByte(s, 10); - } - - /** - * Converts the specified <code>String</code> into an <code>int</code> - * using the specified radix (base). The string must not be <code>null</code> - * or empty. It may begin with an optional '-', which will negate the answer, - * provided that there are also valid digits. Each digit is parsed as if by - * <code>Character.digit(d, radix)</code>, and must be in the range - * <code>0</code> to <code>radix - 1</code>. Finally, the result must be - * within <code>MIN_VALUE</code> to <code>MAX_VALUE</code>, inclusive. - * Unlike Double.parseDouble, you may not have a leading '+'. - * - * @param s the <code>String</code> to convert - * @param radix the radix (base) to use in the conversion - * @return the <code>String</code> argument converted to <code>byte</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>byte</code> - */ - public static byte parseByte(String s, int radix) - { - int i = Integer.parseInt(s, radix, false); - if ((byte) i != i) - throw new NumberFormatException(); - return (byte) i; - } - - /** - * Creates a new <code>Byte</code> object using the <code>String</code> - * and specified radix (base). - * - * @param s the <code>String</code> to convert - * @param radix the radix (base) to convert with - * @return the new <code>Byte</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>byte</code> - * @see #parseByte(String, int) - */ - public static Byte valueOf(String s, int radix) - { - return new Byte(parseByte(s, radix)); - } - - /** - * Creates a new <code>Byte</code> object using the <code>String</code>, - * assuming a radix of 10. - * - * @param s the <code>String</code> to convert - * @return the new <code>Byte</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>byte</code> - * @see #Byte(String) - * @see #parseByte(String) - */ - public static Byte valueOf(String s) - { - return new Byte(parseByte(s, 10)); - } - - /** - * Convert the specified <code>String</code> into a <code>Byte</code>. - * The <code>String</code> may represent decimal, hexadecimal, or - * octal numbers. - * - * <p>The extended BNF grammar is as follows:<br> - * <pre> - * <em>DecodableString</em>: - * ( [ <code>-</code> ] <em>DecimalNumber</em> ) - * | ( [ <code>-</code> ] ( <code>0x</code> | <code>0X</code> - * | <code>#</code> ) { <em>HexDigit</em> }+ ) - * | ( [ <code>-</code> ] <code>0</code> { <em>OctalDigit</em> } ) - * <em>DecimalNumber</em>: - * <em>DecimalDigit except '0'</em> { <em>DecimalDigit</em> } - * <em>DecimalDigit</em>: - * <em>Character.digit(d, 10) has value 0 to 9</em> - * <em>OctalDigit</em>: - * <em>Character.digit(d, 8) has value 0 to 7</em> - * <em>DecimalDigit</em>: - * <em>Character.digit(d, 16) has value 0 to 15</em> - * </pre> - * Finally, the value must be in the range <code>MIN_VALUE</code> to - * <code>MAX_VALUE</code>, or an exception is thrown. - * - * @param s the <code>String</code> to interpret - * @return the value of the String as a <code>Byte</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>byte</code> - * @throws NullPointerException if <code>s</code> is null - * @see Integer#decode(String) - */ - public static Byte decode(String s) - { - int i = Integer.parseInt(s, 10, true); - if ((byte) i != i) - throw new NumberFormatException(); - return new Byte((byte) i); - } - - /** - * Return the value of this <code>Byte</code>. - * - * @return the byte value - */ - public byte byteValue() - { - return value; - } - - /** - * Return the value of this <code>Byte</code> as a <code>short</code>. - * - * @return the short value - */ - public short shortValue() - { - return value; - } - - /** - * Return the value of this <code>Byte</code> as an <code>int</code>. - * - * @return the int value - */ - public int intValue() - { - return value; - } - - /** - * Return the value of this <code>Byte</code> as a <code>long</code>. - * - * @return the long value - */ - public long longValue() - { - return value; - } - - /** - * Return the value of this <code>Byte</code> as a <code>float</code>. - * - * @return the float value - */ - public float floatValue() - { - return value; - } - - /** - * Return the value of this <code>Byte</code> as a <code>double</code>. - * - * @return the double value - */ - public double doubleValue() - { - return value; - } - - /** - * Converts the <code>Byte</code> value to a <code>String</code> and - * assumes a radix of 10. - * - * @return the <code>String</code> representation of this <code>Byte</code> - * @see Integer#toString() - */ - public String toString() - { - return String.valueOf(value); - } - - /** - * Return a hashcode representing this Object. <code>Byte</code>'s hash - * code is simply its value. - * - * @return this Object's hash code - */ - public int hashCode() - { - return value; - } - - /** - * Returns <code>true</code> if <code>obj</code> is an instance of - * <code>Byte</code> and represents the same byte value. - * - * @param obj the object to compare - * @return whether these Objects are semantically equal - */ - public boolean equals(Object obj) - { - return obj instanceof Byte && value == ((Byte) obj).value; - } - - /** - * Compare two Bytes numerically by comparing their <code>byte</code> values. - * The result is positive if the first is greater, negative if the second - * is greater, and 0 if the two are equal. - * - * @param b the Byte to compare - * @return the comparison - * @since 1.2 - */ - public int compareTo(Byte b) - { - return value - b.value; - } - - /** - * Behaves like <code>compareTo(Byte)</code> unless the Object - * is not a <code>Byte</code>. - * - * @param o the object to compare - * @return the comparison - * @throws ClassCastException if the argument is not a <code>Byte</code> - * @see #compareTo(Byte) - * @see Comparable - * @since 1.2 - */ - public int compareTo(Object o) - { - return compareTo((Byte) o); - } -} diff --git a/libjava/java/lang/CharSequence.java b/libjava/java/lang/CharSequence.java deleted file mode 100644 index 5c014e1..0000000 --- a/libjava/java/lang/CharSequence.java +++ /dev/null @@ -1,99 +0,0 @@ -/* CharSequence.java -- Anything that has an indexed sequence of chars - Copyright (C) 2001, 2002 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * General functions on a sequence of chars. This interface is implemented - * by <code>String</code>, <code>StringBuffer</code> and - * <code>CharBuffer</code> to give a uniform way to get chars at a certain - * index, the number of characters in the sequence and a subrange of the - * chars. Indexes start at 0 and the last index is <code>length()-1</code>. - * - * <p>Even when classes implement this interface they are not always - * exchangeble because they might implement their compare, equals or hash - * function differently. This means that in general one should not use a - * <code>CharSequence</code> as keys in collections since two sequences - * with the same chars at the same indexes with the same length might not - * have the same hash code, be equal or be comparable since the are - * represented by different classes. - * - * @author Mark Wielaard (mark@klomp.org) - * @since 1.4 - * @status updated to 1.4 - */ -public interface CharSequence -{ - /** - * Returns the character at the given index. - * - * @param i the index to retrieve from - * @return the character at that location - * @throws IndexOutOfBoundsException if i < 0 || i >= length() - 1 - */ - char charAt(int i); - - /** - * Returns the length of the sequence. This is the number of 16-bit - * characters in the sequence, which may differ from the length of the - * underlying encoding. - * - * @return the sequence length - */ - int length(); - - /** - * Returns a new <code>CharSequence</code> of the indicated range. - * - * @param begin the start index (inclusive) - * @param end the end index (exclusive) - * @return a subsequence of this - * @throws IndexOutOfBoundsException if begin > end || begin < 0 || - * end > length() - */ - CharSequence subSequence(int begin, int end); - - /** - * Returns the complete <code>CharSequence</code> as a <code>String</code>. - * Classes that implement this interface should return a <code>String</code> - * which contains only the characters in the sequence in the correct order. - * - * @return the character sequence as a String - */ - String toString(); -} diff --git a/libjava/java/lang/ClassCastException.java b/libjava/java/lang/ClassCastException.java deleted file mode 100644 index c490f42..0000000 --- a/libjava/java/lang/ClassCastException.java +++ /dev/null @@ -1,76 +0,0 @@ -/* ClassCastException.java -- exception thrown on bad cast - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown when an attempt is made to cast an object which is not of the - * appropriate runtime type. For example:<br> - * <pre> - * Object o = new Vector(); - * String s = (String) o; - * </pre> - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @status updated to 1.4 - */ -public class ClassCastException extends RuntimeException -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -9223365651070458532L; - - /** - * Create an exception without a message. - */ - public ClassCastException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public ClassCastException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/ClassCircularityError.java b/libjava/java/lang/ClassCircularityError.java deleted file mode 100644 index ecdfb7a..0000000 --- a/libjava/java/lang/ClassCircularityError.java +++ /dev/null @@ -1,73 +0,0 @@ -/* ClassCircularityError.java -- thrown when linking circular classes - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * A <code>ClassCircularityError</code> is thrown when a circular dependency - * has been detected while initializing a class. This signals binary - * incompatible versions of class files, as the compiler normally catches this. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public class ClassCircularityError extends LinkageError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 1054362542914539689L; - - /** - * Create an error without a message. - */ - public ClassCircularityError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public ClassCircularityError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/ClassFormatError.java b/libjava/java/lang/ClassFormatError.java deleted file mode 100644 index 7f90f5c..0000000 --- a/libjava/java/lang/ClassFormatError.java +++ /dev/null @@ -1,72 +0,0 @@ -/* ClassFormatError.java -- thrown if a class file is invalid - Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * A <code>ClassFormatError</code> is thrown when a Java Virtual Machine - * unable to read a class file because the file is corrupted or cannot be - * interpreted as a class file. - * - * @author Brian Jones - * @status updated to 1.4 - */ -public class ClassFormatError extends LinkageError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -8420114879011949195L; - - /** - * Create an error without a message. - */ - public ClassFormatError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public ClassFormatError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/ClassNotFoundException.java b/libjava/java/lang/ClassNotFoundException.java deleted file mode 100644 index 6b6ae94..0000000 --- a/libjava/java/lang/ClassNotFoundException.java +++ /dev/null @@ -1,125 +0,0 @@ -/* ClassNotFoundException.java -- thrown when class definition cannot be found - Copyright (C) 1998, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown when a class is requested by reflection, but the class definition - * cannot be found. This exception is often chained from another Throwable. - * - * @author Brian Jones - * @author Eric Blake (ebb9@email.byu.edu) - * @see Class#forName(String) - * @see ClassLoader#findSystemClass(String) - * @see ClassLoader#loadClass(String, boolean) - * @status updated to 1.4 - */ -public class ClassNotFoundException extends Exception -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 9176873029745254542L; - - /** - * The cause of this exception (duplicates the one stored in Throwable). - * - * @serial the exception cause - * @since 1.2 - */ - private final Throwable ex; - - /** - * Create an exception without a message. Note that this initializes the - * cause to null. - */ - public ClassNotFoundException() - { - this(null, null); - } - - /** - * Create an exception with a message. Note that this initializes the - * cause to null. - * - * @param s the message - */ - public ClassNotFoundException(String s) - { - this(s, null); - } - - /** - * Create an exception with a message and chain it to the exception - * which occurred while loading the class. - * - * @param s the message - * @param ex the chained exception - * @since 1.2 - */ - public ClassNotFoundException(String s, Throwable ex) - { - super(s, ex); - this.ex = ex; - } - - /** - * Returns the exception which occurred while loading the class, - * otherwise returns null. This is a legacy method; the preferred choice - * now is {@link Throwable#getCause()}. - * - * @return the cause of this exception - * @since 1.2 - */ - public Throwable getException() - { - return ex; - } - - /** - * Returns the exception which occurred while loading the class, - * otherwise returns null. - * - * @return the cause of this exception - * @since 1.4 - */ - public Throwable getCause() - { - return ex; - } -} diff --git a/libjava/java/lang/CloneNotSupportedException.java b/libjava/java/lang/CloneNotSupportedException.java deleted file mode 100644 index 9d10cf3..0000000 --- a/libjava/java/lang/CloneNotSupportedException.java +++ /dev/null @@ -1,92 +0,0 @@ -/* CloneNotSupportedException.java -- thrown when an object cannot be cloned - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown to indicate an object should not or could not be cloned. This - * includes the case when {@link Object#clone()} is called on an object - * which does not implement the {@link Cloneable} interface. For example:<br> - * <pre> - * void m() throws CloneNotSupportedException - * { - * clone(); - * } - * </pre> - * - * <p>Notice that calling <code>clone()</code> on an array will never produce - * this exception, as the VM will always succeed in copying the array, or - * cause an OutOfMemoryError first. For example:<br> - * <pre> - * void m(int[] array) - * { - * int[] copy = (int[]) array.clone(); - * } - * </pre> - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @author Eric Blake (ebb9@email.byu.edu) - * @see Cloneable - * @see Object#clone() - * @status updated to 1.4 - */ -public class CloneNotSupportedException extends Exception -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 5195511250079656443L; - - /** - * Create an exception without a message. - */ - public CloneNotSupportedException() - { - } - - /** - * Create an exception with a message. - * - * @param s the error message - */ - public CloneNotSupportedException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/Cloneable.java b/libjava/java/lang/Cloneable.java deleted file mode 100644 index 10f20ce..0000000 --- a/libjava/java/lang/Cloneable.java +++ /dev/null @@ -1,78 +0,0 @@ -/* Cloneable.java -- Interface for marking objects cloneable by Object.clone() - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * This interface should be implemented by classes wishing to - * support of override <code>Object.clone()</code>. The default - * behaviour of <code>clone()</code> performs a shallow copy, but - * subclasses often change this to perform a deep copy. Therefore, - * it is a good idea to document how deep your clone will go. - * If <code>clone()</code> is called on an object which does not - * implement this interface, a <code>CloneNotSupportedException</code> - * will be thrown. - * - * <p>This interface is simply a tagging interface; it carries no - * requirements on methods to implement. However, it is typical for - * a Cloneable class to implement at least <code>equals</code>, - * <code>hashCode</code>, and <code>clone</code>, sometimes - * increasing the accessibility of clone to be public. The typical - * implementation of <code>clone</code> invokes <code>super.clone()</code> - * rather than a constructor, but this is not a requirement. - * - * <p>If an object that implement Cloneable should not be cloned, - * simply override the <code>clone</code> method to throw a - * <code>CloneNotSupportedException</code>. - * - * <p>All array types implement Cloneable, and have a public - * <code>clone</code> method that will never fail with a - * <code>CloneNotSupportedException</code>. - * - * @author Paul Fisher - * @author Eric Blake (ebb9@email.byu.edu) - * @author Warren Levy (warrenl@cygnus.com) - * @see Object#clone() - * @see CloneNotSupportedException - * @since 1.0 - * @status updated to 1.4 - */ -public interface Cloneable -{ - // Tagging interface only. -} diff --git a/libjava/java/lang/Comparable.java b/libjava/java/lang/Comparable.java deleted file mode 100644 index a8afe1e..0000000 --- a/libjava/java/lang/Comparable.java +++ /dev/null @@ -1,98 +0,0 @@ -/* Comparable.java -- Interface for comparaing objects to obtain an ordering - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Interface for objects that can be ordering among other objects. The - * ordering can be <em>total</em>, such that two objects only compare equal - * if they are also equal by the equals method, or <em>partial</em> such - * that this is not necessarily true. For example, a case-sensitive - * dictionary order comparison of Strings is total, but if it is - * case-insensitive it is partial, because "abc" and "ABC" compare as - * equal even though "abc".equals("ABC") returns false. However, if you use - * a partial ordering, it is a good idea to document your class as - * "inconsistent with equals", because the behavior of your class in a - * SortedMap will be different than in a HashMap. - * - * <p>Lists, arrays, and sets of objects that implement this interface can - * be sorted automatically, without the need for an explicit - * {@link java.util.Comparator}. Note that <code>e1.compareTo(null)</code> - * should throw an Exception; as should comparison between incompatible - * classes. - * - * @author Geoff Berry - * @author Warren Levy (warrenl@cygnus.com) - * @see java.util.Comparator - * @see java.util.Collections#sort(java.util.List) - * @see java.util.Arrays#sort(Object[]) - * @see java.util.SortedSet - * @see java.util.SortedMap - * @see java.util.TreeSet - * @see java.util.TreeMap - * @since 1.2 - * @status updated to 1.4 - */ -public interface Comparable -{ - /** - * Compares this object with another, and returns a numerical result based - * on the comparison. If the result is negative, this object sorts less - * than the other; if 0, the two are equal, and if positive, this object - * sorts greater than the other. To translate this into boolean, simply - * perform <code>o1.compareTo(o2) <em><op></em> 0</code>, where op - * is one of <, <=, =, !=, >, or >=. - * - * <p>You must make sure that the comparison is mutual, ie. - * <code>sgn(x.compareTo(y)) == -sgn(y.compareTo(x))</code> (where sgn() is - * defined as -1, 0, or 1 based on the sign). This includes throwing an - * exception in either direction if the two are not comparable; hence, - * <code>compareTo(null)</code> should always throw an Exception. - * - * <p>You should also ensure transitivity, in two forms: - * <code>x.compareTo(y) > 0 && y.compareTo(z) > 0</code> implies - * <code>x.compareTo(z) > 0</code>; and <code>x.compareTo(y) == 0</code> - * implies <code>x.compareTo(z) == y.compareTo(z)</code>. - * - * @param o the object to be compared - * @return an integer describing the comparison - * @throws NullPointerException if o is null - * @throws ClassCastException if o cannot be compared - */ - int compareTo(Object o); -} diff --git a/libjava/java/lang/Compiler.java b/libjava/java/lang/Compiler.java deleted file mode 100644 index 56fb951..0000000 --- a/libjava/java/lang/Compiler.java +++ /dev/null @@ -1,127 +0,0 @@ -/* Compiler.java -- placeholder for Java-to-native runtime compilers - Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * The <code>Compiler</code> class is a placeholder for a JIT compiler - * implementation, and does nothing unless there is such a compiler. - * - * <p>The system property <code>java.compiler</code> may contain the name - * of a library to load with <code>System.loadLibrary</code> when the - * virtual machine first starts. If so, and loading the library succeeds, - * then a function by the name of <code>java_lang_Compiler_start()</code> - * in that library is called. - * - * <p>Note that a VM might not have implemented any of this. - * - * @author Tom Tromey (tromey@cygnus.com) - * @see System#getProperty(String) - * @see System#getProperty(String, String) - * @see System#loadLibrary(String) - * @since JDK 1.0 - * @status updated to 1.4 - */ -public final class Compiler -{ - /** - * Don't allow new `Compiler's to be made. - */ - private Compiler() - { - } - - /** - * Compile the class named by <code>oneClass</code>. - * - * @param oneClass the class to compile - * @return <code>false</code> if no compiler is available or - * compilation failed, <code>true</code> if compilation succeeded - * @throws NullPointerException if oneClass is null - */ - public static boolean compileClass(Class oneClass) - { - return VMCompiler.compileClass(oneClass); - } - - /** - * Compile the classes whose name matches <code>classNames</code>. - * - * @param classNames the name of classes to compile - * @return <code>false</code> if no compiler is available or - * compilation failed, <code>true</code> if compilation succeeded - * @throws NullPointerException if classNames is null - */ - public static boolean compileClasses(String classNames) - { - return VMCompiler.compileClasses(classNames); - } - - /** - * This method examines the argument and performs an operation - * according to the compilers documentation. No specific operation - * is required. - * - * @param arg a compiler-specific argument - * @return a compiler-specific value, including null - * @throws NullPointerException if the compiler doesn't like a null arg - */ - public static Object command(Object arg) - { - return VMCompiler.command(arg); - } - - /** - * Calling <code>Compiler.enable()</code> will cause the compiler - * to resume operation if it was previously disabled; provided that a - * compiler even exists. - */ - public static void enable() - { - VMCompiler.enable(); - } - - /** - * Calling <code>Compiler.disable()</code> will cause the compiler - * to be suspended; provided that a compiler even exists. - */ - public static void disable() - { - VMCompiler.disable(); - } -} diff --git a/libjava/java/lang/Error.java b/libjava/java/lang/Error.java deleted file mode 100644 index f66c754..0000000 --- a/libjava/java/lang/Error.java +++ /dev/null @@ -1,107 +0,0 @@ -/* Error.java -- Indication of fatal abnormal conditions - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Applications should not try to catch errors since they indicate - * abnormal conditions. An abnormal condition is something which should not - * occur, or which should not be recovered from. This latter category - * includes <code>ThreadDeath</code> and <code>AssertionError</code>. - * - * <p>A method is not required to declare any subclass of <code>Error</code> in - * its <code>throws</code> clause which might be thrown but not caught while - * executing the method. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.0 - * @status updated to 1.4 - */ -public class Error extends Throwable -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 4980196508277280342L; - - /** - * Create an error without a message. The cause remains uninitialized. - * - * @see #initCause(Throwable) - */ - public Error() - { - } - - /** - * Create an error with a message. The cause remains uninitialized. - * - * @param s the message string - * @see #initCause(Throwable) - */ - public Error(String s) - { - super(s); - } - - /** - * Create an error with a message and a cause. - * - * @param s the message string - * @param cause the cause of this error - * @since 1.4 - */ - public Error(String s, Throwable cause) - { - super(s, cause); - } - - /** - * Create an error with a given cause, and a message of - * <code>cause == null ? null : cause.toString()</code>. - * - * @param cause the cause of this error - * @since 1.4 - */ - public Error(Throwable cause) - { - super(cause); - } -} diff --git a/libjava/java/lang/Exception.java b/libjava/java/lang/Exception.java deleted file mode 100644 index 42f7c64..0000000 --- a/libjava/java/lang/Exception.java +++ /dev/null @@ -1,104 +0,0 @@ -/* Exception.java -- generic exception thrown to indicate an exceptional - condition has occurred. - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * The root class of all exceptions worth catching in a program. This - * includes the special category of <code>RuntimeException</code>, which - * does not need to be declared in a throws clause. Exceptions can be used - * to represent almost any exceptional behavior, such as programming errors, - * mouse movements, keyboard clicking, etc. - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @author Eric Blake (ebb9@email.byu.edu) - * @status updated to 1.4 - */ -public class Exception extends Throwable -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -3387516993124229948L; - - /** - * Create an exception without a message. The cause remains uninitialized. - * - * @see #initCause(Throwable) - */ - public Exception() - { - } - - /** - * Create an exception with a message. The cause remains uninitialized. - * - * @param s the message - * @see #initCause(Throwable) - */ - public Exception(String s) - { - super(s); - } - - /** - * Create an exception with a message and a cause. - * - * @param s the message string - * @param cause the cause of this error - * @since 1.4 - */ - public Exception(String s, Throwable cause) - { - super(s, cause); - } - - /** - * Create an exception with a given cause, and a message of - * <code>cause == null ? null : cause.toString()</code>. - * - * @param cause the cause of this exception - * @since 1.4 - */ - public Exception(Throwable cause) - { - super(cause); - } -} diff --git a/libjava/java/lang/ExceptionInInitializerError.java b/libjava/java/lang/ExceptionInInitializerError.java deleted file mode 100644 index 1e58095..0000000 --- a/libjava/java/lang/ExceptionInInitializerError.java +++ /dev/null @@ -1,123 +0,0 @@ -/* ExceptionInInitializerError.java -- thrown when class initialization fails - with an uncaught exception - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * An <code>ExceptionInInitializerError</code> is thrown when an uncaught - * exception has occurred in a static initializer or the initializer for a - * static variable. In general, this wraps only RuntimeExceptions, since the - * compiler does not allow a checked exception to be uncaught in an - * initializer. This exception only occurs during reflection, when a class - * is initialized as part of another action. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.1 - * @status updated to 1.4 - */ -public class ExceptionInInitializerError extends LinkageError -{ - /** - * Compatible with JDK 1.1+. - */ - static final long serialVersionUID = 1521711792217232256L; - - /** - * The cause of this exception (duplicates the one stored in Throwable). - * - * @serial the exception cause - */ - private final Throwable exception; - - /** - * Create an error without a message. The cause is initialized as null. - */ - public ExceptionInInitializerError() - { - this((String) null); - } - - /** - * Create an error with a message. The cause is initialized as null. - * - * @param s the message - */ - public ExceptionInInitializerError(String s) - { - super(s); - exception = null; - } - - /** - * Creates an error an saves a reference to the <code>Throwable</code> - * object. The message string is null. - * - * @param t the exception thrown - */ - public ExceptionInInitializerError(Throwable t) - { - super(null); - initCause(t); - exception = t; - } - - /** - * Return the exception that caused this error to be created. This is a - * legacy method; the preferred choice now is {@link Throwable#getCause()}. - * - * @return the cause, or null if unknown - */ - public Throwable getException() - { - return exception; - } - - /** - * Return the exception that cause this error to be created. - * - * @return the cause, or null if unknown - * @since 1.4 - */ - public Throwable getCause() - { - return exception; - } -} diff --git a/libjava/java/lang/IllegalAccessError.java b/libjava/java/lang/IllegalAccessError.java deleted file mode 100644 index e482160..0000000 --- a/libjava/java/lang/IllegalAccessError.java +++ /dev/null @@ -1,76 +0,0 @@ -/* IllegalAccessError.java -- thrown when linking to an inaccessible member - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * An <code>IllegalAccessError</code> is thrown when an attempt is made to - * call a method, or access or modify a field that the application does not - * have access to. Because this error is usually caught by a compiler, - * the error only occurs at runtime when the definition of a class has - * changed in a way that is incompatible with the previously compiled - * application. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public class IllegalAccessError extends IncompatibleClassChangeError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -8988904074992417891L; - - /** - * Create an error without a message. - */ - public IllegalAccessError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public IllegalAccessError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/IllegalAccessException.java b/libjava/java/lang/IllegalAccessException.java deleted file mode 100644 index 3fe83b5..0000000 --- a/libjava/java/lang/IllegalAccessException.java +++ /dev/null @@ -1,95 +0,0 @@ -/* IllegalAccessException.java -- thrown on attempt to reflect on - inaccessible data - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown whenever a reflective method tries to do something that the - * compiler would not allow. For example, using reflection to set a private - * variable that belongs to a class in another package is bad. - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @see Class#newInstance() - * @see Field#set(Object, Object) - * @see Field#setBoolean(Object, boolean) - * @see Field#setByte(Object, byte) - * @see Field#setShort(Object, short) - * @see Field#setChar(Object, char) - * @see Field#setInt(Object, int) - * @see Field#setLong(Object, long) - * @see Field#setFloat(Object, float) - * @see Field#setDouble(Object, double) - * @see Field#get(Object) - * @see Field#getBoolean(Object) - * @see Field#getByte(Object) - * @see Field#getShort(Object) - * @see Field#getChar(Object) - * @see Field#getInt(Object) - * @see Field#getLong(Object) - * @see Field#getFloat(Object) - * @see Field#getDouble(Object) - * @see Method#invoke(Object, Object[]) - * @see Constructor#newInstance(Object[]) - * @status updated to 1.4 - */ -public class IllegalAccessException extends Exception -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 6616958222490762034L; - - /** - * Create an exception without a message. - */ - public IllegalAccessException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public IllegalAccessException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/IllegalArgumentException.java b/libjava/java/lang/IllegalArgumentException.java deleted file mode 100644 index 7b822b9..0000000 --- a/libjava/java/lang/IllegalArgumentException.java +++ /dev/null @@ -1,75 +0,0 @@ -/* IllegalArgumentException.java -- thrown when a method is passed an - illegal or inappropriate argument - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package java.lang; - -/** - * Thrown when a method is passed an illegal or inappropriate argument. For - * example:<br> - * <pre> - * wait(-1); - * </pre> - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @status updated to 1.4 - */ -public class IllegalArgumentException extends RuntimeException -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -5365630128856068164L; - - /** - * Create an exception without a message. - */ - public IllegalArgumentException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public IllegalArgumentException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/IllegalMonitorStateException.java b/libjava/java/lang/IllegalMonitorStateException.java deleted file mode 100644 index 13b3f95..0000000 --- a/libjava/java/lang/IllegalMonitorStateException.java +++ /dev/null @@ -1,78 +0,0 @@ -/* IllegalMonitorStateException.java -- thrown when trying to wait or - notify a monitor that is not owned - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown when a thread attempts to wait or notify on a monitor that it - * does not own (ie. it has not synchronized on the object). For example:<br> - * <pre> - * void m() { - * notify(); - * } - * </pre> - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @status updated to 1.4 - */ -public class IllegalMonitorStateException extends RuntimeException -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 3713306369498869069L; - - /** - * Create an exception without a message. - */ - public IllegalMonitorStateException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public IllegalMonitorStateException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/IllegalStateException.java b/libjava/java/lang/IllegalStateException.java deleted file mode 100644 index 5c2bbad..0000000 --- a/libjava/java/lang/IllegalStateException.java +++ /dev/null @@ -1,80 +0,0 @@ -/* IllegalStateException.java -- thrown when invoking a method at - an illegal or inappropriate time - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown when a method is invoked at an illegal or inappropriate time. For - * example:<br> - * <pre> - * void m(Collecion c) - * { - * c.iterator().remove(); - * } - * </pre> - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @since 1.1 - * @status updated to 1.4 - */ -public class IllegalStateException extends RuntimeException -{ - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = -1848914673093119416L; - - /** - * Create an exception without a message. - */ - public IllegalStateException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public IllegalStateException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/IllegalThreadStateException.java b/libjava/java/lang/IllegalThreadStateException.java deleted file mode 100644 index e14385a..0000000 --- a/libjava/java/lang/IllegalThreadStateException.java +++ /dev/null @@ -1,75 +0,0 @@ -/* IllegalThreadStateException.java -- thrown when trying to manipulate a - Thread when it is not in an appropriate state - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown When trying to manipulate a Thread which is in an inappropriate - * state. Since the documentation suggests that this can happen with - * <code>Thread.suspend</code> or <code>Thread.resume</code>, but these - * two methods are deprecated, this exception is likely very rare. - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @status updated to 1.4 - */ -public class IllegalThreadStateException extends IllegalArgumentException -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -7626246362397460174L; - - /** - * Create an exception without a message. - */ - public IllegalThreadStateException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public IllegalThreadStateException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/IncompatibleClassChangeError.java b/libjava/java/lang/IncompatibleClassChangeError.java deleted file mode 100644 index 637410a..0000000 --- a/libjava/java/lang/IncompatibleClassChangeError.java +++ /dev/null @@ -1,73 +0,0 @@ -/* IncompatibleClassChangeError.java -- thrown for binary incompatible classes - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * An <code>IncompatibleClassChangeError</code> is thrown when the definition - * of a class used by the currently executing method has changed in an - * incompatible way. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public class IncompatibleClassChangeError extends LinkageError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -4914975503642802119L; - - /** - * Create an error without a message. - */ - public IncompatibleClassChangeError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public IncompatibleClassChangeError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/IndexOutOfBoundsException.java b/libjava/java/lang/IndexOutOfBoundsException.java deleted file mode 100644 index c53c67e..0000000 --- a/libjava/java/lang/IndexOutOfBoundsException.java +++ /dev/null @@ -1,75 +0,0 @@ -/* IndexOutOfBoundsException.java -- thrown for an invalid index - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * This exception can be thrown to indicate an attempt to access an - * index which is out of bounds on objects like String, Array, or Vector. - * Usually any negative integer less than or equal to -1 and positive - * integer greater than or equal to the size of the object is an index - * which would be out of bounds. - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @status updated to 1.4 - */ -public class IndexOutOfBoundsException extends RuntimeException -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 234122996006267687L; - - /** - * Create an exception without a message. - */ - public IndexOutOfBoundsException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public IndexOutOfBoundsException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/InstantiationError.java b/libjava/java/lang/InstantiationError.java deleted file mode 100644 index dd12b51..0000000 --- a/libjava/java/lang/InstantiationError.java +++ /dev/null @@ -1,75 +0,0 @@ -/* InstantiationError.java -- thrown when the linker cannot create an instance - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * An <code>InstantiationError</code> is thrown when an attempt is made to - * create an instance of an abstract class or an interface. Because this - * error is usually caught by a compiler, the error only occurs at runtime - * when the definition of a class has changed in a way that is incompatible - * with the previously compiled application. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public class InstantiationError extends IncompatibleClassChangeError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -4885810657349421204L; - - /** - * Create an error without a message. - */ - public InstantiationError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public InstantiationError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/InstantiationException.java b/libjava/java/lang/InstantiationException.java deleted file mode 100644 index 367b14b..0000000 --- a/libjava/java/lang/InstantiationException.java +++ /dev/null @@ -1,74 +0,0 @@ -/* InstantiationException.java -- thrown when reflection cannot create an - instance - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown when an attempt is made to use reflection to build a - * non-instantiable class (an interface or abstract class). - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @see Class#newInstance() - * @status updated to 1.4 - */ -public class InstantiationException extends Exception -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -8441929162975509110L; - - /** - * Create an exception without a message. - */ - public InstantiationException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public InstantiationException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/Integer.java b/libjava/java/lang/Integer.java deleted file mode 100644 index 61d7ef0..0000000 --- a/libjava/java/lang/Integer.java +++ /dev/null @@ -1,606 +0,0 @@ -/* Integer.java -- object wrapper for int - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Instances of class <code>Integer</code> represent primitive - * <code>int</code> values. - * - * Additionally, this class provides various helper functions and variables - * related to ints. - * - * @author Paul Fisher - * @author John Keiser - * @author Warren Levy - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.0 - * @status updated to 1.4 - */ -public final class Integer extends Number implements Comparable -{ - /** - * Compatible with JDK 1.0.2+. - */ - private static final long serialVersionUID = 1360826667806852920L; - - /** - * The minimum value an <code>int</code> can represent is -2147483648 (or - * -2<sup>31</sup>). - */ - public static final int MIN_VALUE = 0x80000000; - - /** - * The maximum value an <code>int</code> can represent is 2147483647 (or - * 2<sup>31</sup> - 1). - */ - public static final int MAX_VALUE = 0x7fffffff; - - /** - * The primitive type <code>int</code> is represented by this - * <code>Class</code> object. - * @since 1.1 - */ - public static final Class TYPE = VMClassLoader.getPrimitiveClass('I'); - - /** - * The immutable value of this Integer. - * - * @serial the wrapped int - */ - private final int value; - - /** - * Create an <code>Integer</code> object representing the value of the - * <code>int</code> argument. - * - * @param value the value to use - */ - public Integer(int value) - { - this.value = value; - } - - /** - * Create an <code>Integer</code> object representing the value of the - * argument after conversion to an <code>int</code>. - * - * @param s the string to convert - * @throws NumberFormatException if the String does not contain an int - * @see #valueOf(String) - */ - public Integer(String s) - { - value = parseInt(s, 10, false); - } - - /** - * Converts the <code>int</code> to a <code>String</code> using - * the specified radix (base). If the radix exceeds - * <code>Character.MIN_RADIX</code> or <code>Character.MAX_RADIX</code>, 10 - * is used instead. If the result is negative, the leading character is - * '-' ('\\u002D'). The remaining characters come from - * <code>Character.forDigit(digit, radix)</code> ('0'-'9','a'-'z'). - * - * @param num the <code>int</code> to convert to <code>String</code> - * @param radix the radix (base) to use in the conversion - * @return the <code>String</code> representation of the argument - */ - public static String toString(int num, int radix) - { - if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) - radix = 10; - - // For negative numbers, print out the absolute value w/ a leading '-'. - // Use an array large enough for a binary number. - char[] buffer = new char[33]; - int i = 33; - boolean isNeg = false; - if (num < 0) - { - isNeg = true; - num = -num; - - // When the value is MIN_VALUE, it overflows when made positive - if (num < 0) - { - buffer[--i] = digits[(int) (-(num + radix) % radix)]; - num = -(num / radix); - } - } - - do - { - buffer[--i] = digits[num % radix]; - num /= radix; - } - while (num > 0); - - if (isNeg) - buffer[--i] = '-'; - - // Package constructor avoids an array copy. - return new String(buffer, i, 33 - i, true); - } - - /** - * Converts the <code>int</code> to a <code>String</code> assuming it is - * unsigned in base 16. - * - * @param i the <code>int</code> to convert to <code>String</code> - * @return the <code>String</code> representation of the argument - */ - public static String toHexString(int i) - { - return toUnsignedString(i, 4); - } - - /** - * Converts the <code>int</code> to a <code>String</code> assuming it is - * unsigned in base 8. - * - * @param i the <code>int</code> to convert to <code>String</code> - * @return the <code>String</code> representation of the argument - */ - public static String toOctalString(int i) - { - return toUnsignedString(i, 3); - } - - /** - * Converts the <code>int</code> to a <code>String</code> assuming it is - * unsigned in base 2. - * - * @param i the <code>int</code> to convert to <code>String</code> - * @return the <code>String</code> representation of the argument - */ - public static String toBinaryString(int i) - { - return toUnsignedString(i, 1); - } - - /** - * Converts the <code>int</code> to a <code>String</code> and assumes - * a radix of 10. - * - * @param i the <code>int</code> to convert to <code>String</code> - * @return the <code>String</code> representation of the argument - * @see #toString(int, int) - */ - public static String toString(int i) - { - // This is tricky: in libgcj, String.valueOf(int) is a fast native - // implementation. In Classpath it just calls back to - // Integer.toString(int, int). - return String.valueOf(i); - } - - /** - * Converts the specified <code>String</code> into an <code>int</code> - * using the specified radix (base). The string must not be <code>null</code> - * or empty. It may begin with an optional '-', which will negate the answer, - * provided that there are also valid digits. Each digit is parsed as if by - * <code>Character.digit(d, radix)</code>, and must be in the range - * <code>0</code> to <code>radix - 1</code>. Finally, the result must be - * within <code>MIN_VALUE</code> to <code>MAX_VALUE</code>, inclusive. - * Unlike Double.parseDouble, you may not have a leading '+'. - * - * @param str the <code>String</code> to convert - * @param radix the radix (base) to use in the conversion - * @return the <code>String</code> argument converted to <code>int</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as an - * <code>int</code> - */ - public static int parseInt(String str, int radix) - { - return parseInt(str, radix, false); - } - - /** - * Converts the specified <code>String</code> into an <code>int</code>. - * This function assumes a radix of 10. - * - * @param s the <code>String</code> to convert - * @return the <code>int</code> value of <code>s</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as an - * <code>int</code> - * @see #parseInt(String, int) - */ - public static int parseInt(String s) - { - return parseInt(s, 10, false); - } - - /** - * Creates a new <code>Integer</code> object using the <code>String</code> - * and specified radix (base). - * - * @param s the <code>String</code> to convert - * @param radix the radix (base) to convert with - * @return the new <code>Integer</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as an - * <code>int</code> - * @see #parseInt(String, int) - */ - public static Integer valueOf(String s, int radix) - { - return new Integer(parseInt(s, radix, false)); - } - - /** - * Creates a new <code>Integer</code> object using the <code>String</code>, - * assuming a radix of 10. - * - * @param s the <code>String</code> to convert - * @return the new <code>Integer</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as an - * <code>int</code> - * @see #Integer(String) - * @see #parseInt(String) - */ - public static Integer valueOf(String s) - { - return new Integer(parseInt(s, 10, false)); - } - - /** - * Return the value of this <code>Integer</code> as a <code>byte</code>. - * - * @return the byte value - */ - public byte byteValue() - { - return (byte) value; - } - - /** - * Return the value of this <code>Integer</code> as a <code>short</code>. - * - * @return the short value - */ - public short shortValue() - { - return (short) value; - } - - /** - * Return the value of this <code>Integer</code>. - * @return the int value - */ - public int intValue() - { - return value; - } - - /** - * Return the value of this <code>Integer</code> as a <code>long</code>. - * - * @return the long value - */ - public long longValue() - { - return value; - } - - /** - * Return the value of this <code>Integer</code> as a <code>float</code>. - * - * @return the float value - */ - public float floatValue() - { - return value; - } - - /** - * Return the value of this <code>Integer</code> as a <code>double</code>. - * - * @return the double value - */ - public double doubleValue() - { - return value; - } - - /** - * Converts the <code>Integer</code> value to a <code>String</code> and - * assumes a radix of 10. - * - * @return the <code>String</code> representation - */ - public String toString() - { - return String.valueOf(value); - } - - /** - * Return a hashcode representing this Object. <code>Integer</code>'s hash - * code is simply its value. - * - * @return this Object's hash code - */ - public int hashCode() - { - return value; - } - - /** - * Returns <code>true</code> if <code>obj</code> is an instance of - * <code>Integer</code> and represents the same int value. - * - * @param obj the object to compare - * @return whether these Objects are semantically equal - */ - public boolean equals(Object obj) - { - return obj instanceof Integer && value == ((Integer) obj).value; - } - - /** - * Get the specified system property as an <code>Integer</code>. The - * <code>decode()</code> method will be used to interpret the value of - * the property. - * - * @param nm the name of the system property - * @return the system property as an <code>Integer</code>, or null if the - * property is not found or cannot be decoded - * @throws SecurityException if accessing the system property is forbidden - * @see System#getProperty(String) - * @see #decode(String) - */ - public static Integer getInteger(String nm) - { - return getInteger(nm, null); - } - - /** - * Get the specified system property as an <code>Integer</code>, or use a - * default <code>int</code> value if the property is not found or is not - * decodable. The <code>decode()</code> method will be used to interpret - * the value of the property. - * - * @param nm the name of the system property - * @param val the default value - * @return the value of the system property, or the default - * @throws SecurityException if accessing the system property is forbidden - * @see System#getProperty(String) - * @see #decode(String) - */ - public static Integer getInteger(String nm, int val) - { - Integer result = getInteger(nm, null); - return result == null ? new Integer(val) : result; - } - - /** - * Get the specified system property as an <code>Integer</code>, or use a - * default <code>Integer</code> value if the property is not found or is - * not decodable. The <code>decode()</code> method will be used to - * interpret the value of the property. - * - * @param nm the name of the system property - * @param def the default value - * @return the value of the system property, or the default - * @throws SecurityException if accessing the system property is forbidden - * @see System#getProperty(String) - * @see #decode(String) - */ - public static Integer getInteger(String nm, Integer def) - { - if (nm == null || "".equals(nm)) - return def; - nm = System.getProperty(nm); - if (nm == null) - return def; - try - { - return decode(nm); - } - catch (NumberFormatException e) - { - return def; - } - } - - /** - * Convert the specified <code>String</code> into an <code>Integer</code>. - * The <code>String</code> may represent decimal, hexadecimal, or - * octal numbers. - * - * <p>The extended BNF grammar is as follows:<br> - * <pre> - * <em>DecodableString</em>: - * ( [ <code>-</code> ] <em>DecimalNumber</em> ) - * | ( [ <code>-</code> ] ( <code>0x</code> | <code>0X</code> - * | <code>#</code> ) <em>HexDigit</em> { <em>HexDigit</em> } ) - * | ( [ <code>-</code> ] <code>0</code> { <em>OctalDigit</em> } ) - * <em>DecimalNumber</em>: - * <em>DecimalDigit except '0'</em> { <em>DecimalDigit</em> } - * <em>DecimalDigit</em>: - * <em>Character.digit(d, 10) has value 0 to 9</em> - * <em>OctalDigit</em>: - * <em>Character.digit(d, 8) has value 0 to 7</em> - * <em>DecimalDigit</em>: - * <em>Character.digit(d, 16) has value 0 to 15</em> - * </pre> - * Finally, the value must be in the range <code>MIN_VALUE</code> to - * <code>MAX_VALUE</code>, or an exception is thrown. - * - * @param str the <code>String</code> to interpret - * @return the value of the String as an <code>Integer</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>int</code> - * @throws NullPointerException if <code>s</code> is null - * @since 1.2 - */ - public static Integer decode(String str) - { - return new Integer(parseInt(str, 10, true)); - } - - /** - * Compare two Integers numerically by comparing their <code>int</code> - * values. The result is positive if the first is greater, negative if the - * second is greater, and 0 if the two are equal. - * - * @param i the Integer to compare - * @return the comparison - * @since 1.2 - */ - public int compareTo(Integer i) - { - if (value == i.value) - return 0; - // Returns just -1 or 1 on inequality; doing math might overflow. - return value > i.value ? 1 : -1; - } - - /** - * Behaves like <code>compareTo(Integer)</code> unless the Object - * is not an <code>Integer</code>. - * - * @param o the object to compare - * @return the comparison - * @throws ClassCastException if the argument is not an <code>Integer</code> - * @see #compareTo(Integer) - * @see Comparable - * @since 1.2 - */ - public int compareTo(Object o) - { - return compareTo((Integer) o); - } - - /** - * Helper for converting unsigned numbers to String. - * - * @param num the number - * @param exp log2(digit) (ie. 1, 3, or 4 for binary, oct, hex) - */ - // Package visible for use by Long. - static String toUnsignedString(int num, int exp) - { - // Use an array large enough for a binary number. - int mask = (1 << exp) - 1; - char[] buffer = new char[32]; - int i = 32; - do - { - buffer[--i] = digits[num & mask]; - num >>>= exp; - } - while (num != 0); - - // Package constructor avoids an array copy. - return new String(buffer, i, 32 - i, true); - } - - /** - * Helper for parsing ints, used by Integer, Short, and Byte. - * - * @param str the string to parse - * @param radix the radix to use, must be 10 if decode is true - * @param decode if called from decode - * @return the parsed int value - * @throws NumberFormatException if there is an error - * @throws NullPointerException if decode is true and str if null - * @see #parseInt(String, int) - * @see #decode(String) - * @see Byte#parseInt(String, int) - * @see Short#parseInt(String, int) - */ - static int parseInt(String str, int radix, boolean decode) - { - if (! decode && str == null) - throw new NumberFormatException(); - int index = 0; - int len = str.length(); - boolean isNeg = false; - if (len == 0) - throw new NumberFormatException(); - int ch = str.charAt(index); - if (ch == '-') - { - if (len == 1) - throw new NumberFormatException(); - isNeg = true; - ch = str.charAt(++index); - } - if (decode) - { - if (ch == '0') - { - if (++index == len) - return 0; - if ((str.charAt(index) & ~('x' ^ 'X')) == 'X') - { - radix = 16; - index++; - } - else - radix = 8; - } - else if (ch == '#') - { - radix = 16; - index++; - } - } - if (index == len) - throw new NumberFormatException(); - - int max = MAX_VALUE / radix; - // We can't directly write `max = (MAX_VALUE + 1) / radix'. - // So instead we fake it. - if (isNeg && MAX_VALUE % radix == radix - 1) - ++max; - - int val = 0; - while (index < len) - { - if (val < 0 || val > max) - throw new NumberFormatException(); - - ch = Character.digit(str.charAt(index++), radix); - val = val * radix + ch; - if (ch < 0 || (val < 0 && (! isNeg || val != MIN_VALUE))) - throw new NumberFormatException(); - } - return isNeg ? -val : val; - } -} diff --git a/libjava/java/lang/InternalError.java b/libjava/java/lang/InternalError.java deleted file mode 100644 index 3a95bbea..0000000 --- a/libjava/java/lang/InternalError.java +++ /dev/null @@ -1,72 +0,0 @@ -/* InternalError.java -- thrown when the VM encounters an internal error - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * An <code>InternalError</code> is thrown when a mystical error has - * occurred in the Java Virtual Machine. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public class InternalError extends VirtualMachineError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -9062593416125562365L; - - /** - * Create an error without a message. - */ - public InternalError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public InternalError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/InterruptedException.java b/libjava/java/lang/InterruptedException.java deleted file mode 100644 index da2173c..0000000 --- a/libjava/java/lang/InterruptedException.java +++ /dev/null @@ -1,80 +0,0 @@ -/* InterruptedException.java -- thrown when a thread is interrupted - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown when a thread interrupts another thread which was previously - * sleeping, waiting, or paused in some other way. See the - * <code>interrupt</code> method of class <code>Thread</code>. - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @see Object#wait() - * @see Object#wait(long) - * @see Object#wait(long, int) - * @see Thread#sleep(long) - * @see Thread#interrupt() - * @see Thread#interrupted() - * @status updated to 1.4 - */ -public class InterruptedException extends Exception -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 6700697376100628473L; - - /** - * Create an exception without a message. - */ - public InterruptedException() - { - } - - /** - * Create an exception with a message. - * - * - * @param s the message - */ - public InterruptedException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/LinkageError.java b/libjava/java/lang/LinkageError.java deleted file mode 100644 index 0287020..0000000 --- a/libjava/java/lang/LinkageError.java +++ /dev/null @@ -1,74 +0,0 @@ -/* LinkageError.java -- thrown when classes valid at separate compile times - cannot be linked to each other - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Subclasses of <code>LinkageError</code> are thrown to indicate that two - * classes which were compatible at separate compilation times cannot be - * linked to one another. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public class LinkageError extends Error -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 3579600108157160122L; - - /** - * Create an error without a message. - */ - public LinkageError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public LinkageError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/Long.java b/libjava/java/lang/Long.java deleted file mode 100644 index 703eab8..0000000 --- a/libjava/java/lang/Long.java +++ /dev/null @@ -1,614 +0,0 @@ -/* Long.java -- object wrapper for long - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Instances of class <code>Long</code> represent primitive - * <code>long</code> values. - * - * Additionally, this class provides various helper functions and variables - * related to longs. - * - * @author Paul Fisher - * @author John Keiser - * @author Warren Levy - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.0 - * @status updated to 1.4 - */ -public final class Long extends Number implements Comparable -{ - /** - * Compatible with JDK 1.0.2+. - */ - private static final long serialVersionUID = 4290774380558885855L; - - /** - * The minimum value a <code>long</code> can represent is - * -9223372036854775808L (or -2<sup>63</sup>). - */ - public static final long MIN_VALUE = 0x8000000000000000L; - - /** - * The maximum value a <code>long</code> can represent is - * 9223372036854775807 (or 2<sup>63</sup> - 1). - */ - public static final long MAX_VALUE = 0x7fffffffffffffffL; - - /** - * The primitive type <code>long</code> is represented by this - * <code>Class</code> object. - * @since 1.1 - */ - public static final Class TYPE = VMClassLoader.getPrimitiveClass ('J'); - - /** - * The immutable value of this Long. - * - * @serial the wrapped long - */ - private final long value; - - /** - * Create a <code>Long</code> object representing the value of the - * <code>long</code> argument. - * - * @param value the value to use - */ - public Long(long value) - { - this.value = value; - } - - /** - * Create a <code>Long</code> object representing the value of the - * argument after conversion to a <code>long</code>. - * - * @param s the string to convert - * @throws NumberFormatException if the String does not contain a long - * @see #valueOf(String) - */ - public Long(String s) - { - value = parseLong(s, 10, false); - } - - /** - * Converts the <code>long</code> to a <code>String</code> using - * the specified radix (base). If the radix exceeds - * <code>Character.MIN_RADIX</code> or <code>Character.MAX_RADIX</code>, 10 - * is used instead. If the result is negative, the leading character is - * '-' ('\\u002D'). The remaining characters come from - * <code>Character.forDigit(digit, radix)</code> ('0'-'9','a'-'z'). - * - * @param num the <code>long</code> to convert to <code>String</code> - * @param radix the radix (base) to use in the conversion - * @return the <code>String</code> representation of the argument - */ - public static String toString(long num, int radix) - { - // Use the Integer toString for efficiency if possible. - if ((int) num == num) - return Integer.toString((int) num, radix); - - if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) - radix = 10; - - // For negative numbers, print out the absolute value w/ a leading '-'. - // Use an array large enough for a binary number. - char[] buffer = new char[65]; - int i = 65; - boolean isNeg = false; - if (num < 0) - { - isNeg = true; - num = -num; - - // When the value is MIN_VALUE, it overflows when made positive - if (num < 0) - { - buffer[--i] = digits[(int) (-(num + radix) % radix)]; - num = -(num / radix); - } - } - - do - { - buffer[--i] = digits[(int) (num % radix)]; - num /= radix; - } - while (num > 0); - - if (isNeg) - buffer[--i] = '-'; - - // Package constructor avoids an array copy. - return new String(buffer, i, 65 - i, true); - } - - /** - * Converts the <code>long</code> to a <code>String</code> assuming it is - * unsigned in base 16. - * - * @param l the <code>long</code> to convert to <code>String</code> - * @return the <code>String</code> representation of the argument - */ - public static String toHexString(long l) - { - return toUnsignedString(l, 4); - } - - /** - * Converts the <code>long</code> to a <code>String</code> assuming it is - * unsigned in base 8. - * - * @param l the <code>long</code> to convert to <code>String</code> - * @return the <code>String</code> representation of the argument - */ - public static String toOctalString(long l) - { - return toUnsignedString(l, 3); - } - - /** - * Converts the <code>long</code> to a <code>String</code> assuming it is - * unsigned in base 2. - * - * @param l the <code>long</code> to convert to <code>String</code> - * @return the <code>String</code> representation of the argument - */ - public static String toBinaryString(long l) - { - return toUnsignedString(l, 1); - } - - /** - * Converts the <code>long</code> to a <code>String</code> and assumes - * a radix of 10. - * - * @param num the <code>long</code> to convert to <code>String</code> - * @return the <code>String</code> representation of the argument - * @see #toString(long, int) - */ - public static String toString(long num) - { - return toString(num, 10); - } - - /** - * Converts the specified <code>String</code> into an <code>int</code> - * using the specified radix (base). The string must not be <code>null</code> - * or empty. It may begin with an optional '-', which will negate the answer, - * provided that there are also valid digits. Each digit is parsed as if by - * <code>Character.digit(d, radix)</code>, and must be in the range - * <code>0</code> to <code>radix - 1</code>. Finally, the result must be - * within <code>MIN_VALUE</code> to <code>MAX_VALUE</code>, inclusive. - * Unlike Double.parseDouble, you may not have a leading '+'; and 'l' or - * 'L' as the last character is only valid in radices 22 or greater, where - * it is a digit and not a type indicator. - * - * @param str the <code>String</code> to convert - * @param radix the radix (base) to use in the conversion - * @return the <code>String</code> argument converted to <code>long</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>long</code> - */ - public static long parseLong(String str, int radix) - { - return parseLong(str, radix, false); - } - - /** - * Converts the specified <code>String</code> into a <code>long</code>. - * This function assumes a radix of 10. - * - * @param s the <code>String</code> to convert - * @return the <code>int</code> value of <code>s</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>long</code> - * @see #parseLong(String, int) - */ - public static long parseLong(String s) - { - return parseLong(s, 10, false); - } - - /** - * Creates a new <code>Long</code> object using the <code>String</code> - * and specified radix (base). - * - * @param s the <code>String</code> to convert - * @param radix the radix (base) to convert with - * @return the new <code>Long</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>long</code> - * @see #parseLong(String, int) - */ - public static Long valueOf(String s, int radix) - { - return new Long(parseLong(s, radix, false)); - } - - /** - * Creates a new <code>Long</code> object using the <code>String</code>, - * assuming a radix of 10. - * - * @param s the <code>String</code> to convert - * @return the new <code>Long</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>long</code> - * @see #Long(String) - * @see #parseLong(String) - */ - public static Long valueOf(String s) - { - return new Long(parseLong(s, 10, false)); - } - - /** - * Convert the specified <code>String</code> into a <code>Long</code>. - * The <code>String</code> may represent decimal, hexadecimal, or - * octal numbers. - * - * <p>The extended BNF grammar is as follows:<br> - * <pre> - * <em>DecodableString</em>: - * ( [ <code>-</code> ] <em>DecimalNumber</em> ) - * | ( [ <code>-</code> ] ( <code>0x</code> | <code>0X</code> - * | <code>#</code> ) <em>HexDigit</em> { <em>HexDigit</em> } ) - * | ( [ <code>-</code> ] <code>0</code> { <em>OctalDigit</em> } ) - * <em>DecimalNumber</em>: - * <em>DecimalDigit except '0'</em> { <em>DecimalDigit</em> } - * <em>DecimalDigit</em>: - * <em>Character.digit(d, 10) has value 0 to 9</em> - * <em>OctalDigit</em>: - * <em>Character.digit(d, 8) has value 0 to 7</em> - * <em>DecimalDigit</em>: - * <em>Character.digit(d, 16) has value 0 to 15</em> - * </pre> - * Finally, the value must be in the range <code>MIN_VALUE</code> to - * <code>MAX_VALUE</code>, or an exception is thrown. Note that you cannot - * use a trailing 'l' or 'L', unlike in Java source code. - * - * @param str the <code>String</code> to interpret - * @return the value of the String as a <code>Long</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>long</code> - * @throws NullPointerException if <code>s</code> is null - * @since 1.2 - */ - public static Long decode(String str) - { - return new Long(parseLong(str, 10, true)); - } - - /** - * Return the value of this <code>Long</code> as a <code>byte</code>. - * - * @return the byte value - */ - public byte byteValue() - { - return (byte) value; - } - - /** - * Return the value of this <code>Long</code> as a <code>short</code>. - * - * @return the short value - */ - public short shortValue() - { - return (short) value; - } - - /** - * Return the value of this <code>Long</code> as an <code>int</code>. - * - * @return the int value - */ - public int intValue() - { - return (int) value; - } - - /** - * Return the value of this <code>Long</code>. - * - * @return the long value - */ - public long longValue() - { - return value; - } - - /** - * Return the value of this <code>Long</code> as a <code>float</code>. - * - * @return the float value - */ - public float floatValue() - { - return value; - } - - /** - * Return the value of this <code>Long</code> as a <code>double</code>. - * - * @return the double value - */ - public double doubleValue() - { - return value; - } - - /** - * Converts the <code>Long</code> value to a <code>String</code> and - * assumes a radix of 10. - * - * @return the <code>String</code> representation - */ - public String toString() - { - return toString(value, 10); - } - - /** - * Return a hashcode representing this Object. <code>Long</code>'s hash - * code is calculated by <code>(int) (value ^ (value >> 32))</code>. - * - * @return this Object's hash code - */ - public int hashCode() - { - return (int) (value ^ (value >>> 32)); - } - - /** - * Returns <code>true</code> if <code>obj</code> is an instance of - * <code>Long</code> and represents the same long value. - * - * @param obj the object to compare - * @return whether these Objects are semantically equal - */ - public boolean equals(Object obj) - { - return obj instanceof Long && value == ((Long) obj).value; - } - - /** - * Get the specified system property as a <code>Long</code>. The - * <code>decode()</code> method will be used to interpret the value of - * the property. - * - * @param nm the name of the system property - * @return the system property as a <code>Long</code>, or null if the - * property is not found or cannot be decoded - * @throws SecurityException if accessing the system property is forbidden - * @see System#getProperty(String) - * @see #decode(String) - */ - public static Long getLong(String nm) - { - return getLong(nm, null); - } - - /** - * Get the specified system property as a <code>Long</code>, or use a - * default <code>long</code> value if the property is not found or is not - * decodable. The <code>decode()</code> method will be used to interpret - * the value of the property. - * - * @param nm the name of the system property - * @param val the default value - * @return the value of the system property, or the default - * @throws SecurityException if accessing the system property is forbidden - * @see System#getProperty(String) - * @see #decode(String) - */ - public static Long getLong(String nm, long val) - { - Long result = getLong(nm, null); - return result == null ? new Long(val) : result; - } - - /** - * Get the specified system property as a <code>Long</code>, or use a - * default <code>Long</code> value if the property is not found or is - * not decodable. The <code>decode()</code> method will be used to - * interpret the value of the property. - * - * @param nm the name of the system property - * @param def the default value - * @return the value of the system property, or the default - * @throws SecurityException if accessing the system property is forbidden - * @see System#getProperty(String) - * @see #decode(String) - */ - public static Long getLong(String nm, Long def) - { - if (nm == null || "".equals(nm)) - return def; - nm = System.getProperty(nm); - if (nm == null) - return def; - try - { - return decode(nm); - } - catch (NumberFormatException e) - { - return def; - } - } - - /** - * Compare two Longs numerically by comparing their <code>long</code> - * values. The result is positive if the first is greater, negative if the - * second is greater, and 0 if the two are equal. - * - * @param l the Long to compare - * @return the comparison - * @since 1.2 - */ - public int compareTo(Long l) - { - if (value == l.value) - return 0; - // Returns just -1 or 1 on inequality; doing math might overflow the long. - return value > l.value ? 1 : -1; - } - - /** - * Behaves like <code>compareTo(Long)</code> unless the Object - * is not a <code>Long</code>. - * - * @param o the object to compare - * @return the comparison - * @throws ClassCastException if the argument is not a <code>Long</code> - * @see #compareTo(Long) - * @see Comparable - * @since 1.2 - */ - public int compareTo(Object o) - { - return compareTo((Long) o); - } - - /** - * Helper for converting unsigned numbers to String. - * - * @param num the number - * @param exp log2(digit) (ie. 1, 3, or 4 for binary, oct, hex) - */ - private static String toUnsignedString(long num, int exp) - { - // Use the Integer toUnsignedString for efficiency if possible. - // If NUM<0 then this particular optimization doesn't work - // properly. - if (num >= 0 && (int) num == num) - return Integer.toUnsignedString((int) num, exp); - - // Use an array large enough for a binary number. - int mask = (1 << exp) - 1; - char[] buffer = new char[64]; - int i = 64; - do - { - buffer[--i] = digits[(int) num & mask]; - num >>>= exp; - } - while (num != 0); - - // Package constructor avoids an array copy. - return new String(buffer, i, 64 - i, true); - } - - /** - * Helper for parsing longs. - * - * @param str the string to parse - * @param radix the radix to use, must be 10 if decode is true - * @param decode if called from decode - * @return the parsed long value - * @throws NumberFormatException if there is an error - * @throws NullPointerException if decode is true and str is null - * @see #parseLong(String, int) - * @see #decode(String) - */ - private static long parseLong(String str, int radix, boolean decode) - { - if (! decode && str == null) - throw new NumberFormatException(); - int index = 0; - int len = str.length(); - boolean isNeg = false; - if (len == 0) - throw new NumberFormatException(); - int ch = str.charAt(index); - if (ch == '-') - { - if (len == 1) - throw new NumberFormatException(); - isNeg = true; - ch = str.charAt(++index); - } - if (decode) - { - if (ch == '0') - { - if (++index == len) - return 0; - if ((str.charAt(index) & ~('x' ^ 'X')) == 'X') - { - radix = 16; - index++; - } - else - radix = 8; - } - else if (ch == '#') - { - radix = 16; - index++; - } - } - if (index == len) - throw new NumberFormatException(); - - long max = MAX_VALUE / radix; - // We can't directly write `max = (MAX_VALUE + 1) / radix'. - // So instead we fake it. - if (isNeg && MAX_VALUE % radix == radix - 1) - ++max; - - long val = 0; - while (index < len) - { - if (val < 0 || val > max) - throw new NumberFormatException(); - - ch = Character.digit(str.charAt(index++), radix); - val = val * radix + ch; - if (ch < 0 || (val < 0 && (! isNeg || val != MIN_VALUE))) - throw new NumberFormatException(); - } - return isNeg ? -val : val; - } -} diff --git a/libjava/java/lang/Math.java b/libjava/java/lang/Math.java deleted file mode 100644 index 08081e2..0000000 --- a/libjava/java/lang/Math.java +++ /dev/null @@ -1,650 +0,0 @@ -/* java.lang.Math -- common mathematical functions, native allowed - Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -import gnu.classpath.Configuration; - -import java.util.Random; - -/** - * Helper class containing useful mathematical functions and constants. - * <P> - * - * Note that angles are specified in radians. Conversion functions are - * provided for your convenience. - * - * @author Paul Fisher - * @author John Keiser - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.0 - */ -public final class Math -{ - /** - * Math is non-instantiable - */ - private Math() - { - } - - static - { - if (Configuration.INIT_LOAD_LIBRARY) - { - System.loadLibrary("javalang"); - } - } - - /** - * A random number generator, initialized on first use. - */ - private static Random rand; - - /** - * The most accurate approximation to the mathematical constant <em>e</em>: - * <code>2.718281828459045</code>. Used in natural log and exp. - * - * @see #log(double) - * @see #exp(double) - */ - public static final double E = 2.718281828459045; - - /** - * The most accurate approximation to the mathematical constant <em>pi</em>: - * <code>3.141592653589793</code>. This is the ratio of a circle's diameter - * to its circumference. - */ - public static final double PI = 3.141592653589793; - - /** - * Take the absolute value of the argument. - * (Absolute value means make it positive.) - * <P> - * - * Note that the the largest negative value (Integer.MIN_VALUE) cannot - * be made positive. In this case, because of the rules of negation in - * a computer, MIN_VALUE is what will be returned. - * This is a <em>negative</em> value. You have been warned. - * - * @param i the number to take the absolute value of - * @return the absolute value - * @see Integer#MIN_VALUE - */ - public static int abs(int i) - { - return (i < 0) ? -i : i; - } - - /** - * Take the absolute value of the argument. - * (Absolute value means make it positive.) - * <P> - * - * Note that the the largest negative value (Long.MIN_VALUE) cannot - * be made positive. In this case, because of the rules of negation in - * a computer, MIN_VALUE is what will be returned. - * This is a <em>negative</em> value. You have been warned. - * - * @param l the number to take the absolute value of - * @return the absolute value - * @see Long#MIN_VALUE - */ - public static long abs(long l) - { - return (l < 0) ? -l : l; - } - - /** - * Take the absolute value of the argument. - * (Absolute value means make it positive.) - * <P> - * - * This is equivalent, but faster than, calling - * <code>Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))</code>. - * - * @param f the number to take the absolute value of - * @return the absolute value - */ - public static float abs(float f) - { - return (f <= 0) ? 0 - f : f; - } - - /** - * Take the absolute value of the argument. - * (Absolute value means make it positive.) - * - * This is equivalent, but faster than, calling - * <code>Double.longBitsToDouble(Double.doubleToLongBits(a) - * << 1) >>> 1);</code>. - * - * @param d the number to take the absolute value of - * @return the absolute value - */ - public static double abs(double d) - { - return (d <= 0) ? 0 - d : d; - } - - /** - * Return whichever argument is smaller. - * - * @param a the first number - * @param b a second number - * @return the smaller of the two numbers - */ - public static int min(int a, int b) - { - return (a < b) ? a : b; - } - - /** - * Return whichever argument is smaller. - * - * @param a the first number - * @param b a second number - * @return the smaller of the two numbers - */ - public static long min(long a, long b) - { - return (a < b) ? a : b; - } - - /** - * Return whichever argument is smaller. If either argument is NaN, the - * result is NaN, and when comparing 0 and -0, -0 is always smaller. - * - * @param a the first number - * @param b a second number - * @return the smaller of the two numbers - */ - public static float min(float a, float b) - { - // this check for NaN, from JLS 15.21.1, saves a method call - if (a != a) - return a; - // no need to check if b is NaN; < will work correctly - // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special - if (a == 0 && b == 0) - return -(-a - b); - return (a < b) ? a : b; - } - - /** - * Return whichever argument is smaller. If either argument is NaN, the - * result is NaN, and when comparing 0 and -0, -0 is always smaller. - * - * @param a the first number - * @param b a second number - * @return the smaller of the two numbers - */ - public static double min(double a, double b) - { - // this check for NaN, from JLS 15.21.1, saves a method call - if (a != a) - return a; - // no need to check if b is NaN; < will work correctly - // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special - if (a == 0 && b == 0) - return -(-a - b); - return (a < b) ? a : b; - } - - /** - * Return whichever argument is larger. - * - * @param a the first number - * @param b a second number - * @return the larger of the two numbers - */ - public static int max(int a, int b) - { - return (a > b) ? a : b; - } - - /** - * Return whichever argument is larger. - * - * @param a the first number - * @param b a second number - * @return the larger of the two numbers - */ - public static long max(long a, long b) - { - return (a > b) ? a : b; - } - - /** - * Return whichever argument is larger. If either argument is NaN, the - * result is NaN, and when comparing 0 and -0, 0 is always larger. - * - * @param a the first number - * @param b a second number - * @return the larger of the two numbers - */ - public static float max(float a, float b) - { - // this check for NaN, from JLS 15.21.1, saves a method call - if (a != a) - return a; - // no need to check if b is NaN; > will work correctly - // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special - if (a == 0 && b == 0) - return a - -b; - return (a > b) ? a : b; - } - - /** - * Return whichever argument is larger. If either argument is NaN, the - * result is NaN, and when comparing 0 and -0, 0 is always larger. - * - * @param a the first number - * @param b a second number - * @return the larger of the two numbers - */ - public static double max(double a, double b) - { - // this check for NaN, from JLS 15.21.1, saves a method call - if (a != a) - return a; - // no need to check if b is NaN; > will work correctly - // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special - if (a == 0 && b == 0) - return a - -b; - return (a > b) ? a : b; - } - - /** - * The trigonometric function <em>sin</em>. The sine of NaN or infinity is - * NaN, and the sine of 0 retains its sign. This is accurate within 1 ulp, - * and is semi-monotonic. - * - * @param a the angle (in radians) - * @return sin(a) - */ - public static native double sin(double a); - - /** - * The trigonometric function <em>cos</em>. The cosine of NaN or infinity is - * NaN. This is accurate within 1 ulp, and is semi-monotonic. - * - * @param a the angle (in radians) - * @return cos(a) - */ - public static native double cos(double a); - - /** - * The trigonometric function <em>tan</em>. The tangent of NaN or infinity - * is NaN, and the tangent of 0 retains its sign. This is accurate within 1 - * ulp, and is semi-monotonic. - * - * @param a the angle (in radians) - * @return tan(a) - */ - public static native double tan(double a); - - /** - * The trigonometric function <em>arcsin</em>. The range of angles returned - * is -pi/2 to pi/2 radians (-90 to 90 degrees). If the argument is NaN or - * its absolute value is beyond 1, the result is NaN; and the arcsine of - * 0 retains its sign. This is accurate within 1 ulp, and is semi-monotonic. - * - * @param a the sin to turn back into an angle - * @return arcsin(a) - */ - public static native double asin(double a); - - /** - * The trigonometric function <em>arccos</em>. The range of angles returned - * is 0 to pi radians (0 to 180 degrees). If the argument is NaN or - * its absolute value is beyond 1, the result is NaN. This is accurate - * within 1 ulp, and is semi-monotonic. - * - * @param a the cos to turn back into an angle - * @return arccos(a) - */ - public static native double acos(double a); - - /** - * The trigonometric function <em>arcsin</em>. The range of angles returned - * is -pi/2 to pi/2 radians (-90 to 90 degrees). If the argument is NaN, the - * result is NaN; and the arctangent of 0 retains its sign. This is accurate - * within 1 ulp, and is semi-monotonic. - * - * @param a the tan to turn back into an angle - * @return arcsin(a) - * @see #atan2(double, double) - */ - public static native double atan(double a); - - /** - * A special version of the trigonometric function <em>arctan</em>, for - * converting rectangular coordinates <em>(x, y)</em> to polar - * <em>(r, theta)</em>. This computes the arctangent of x/y in the range - * of -pi to pi radians (-180 to 180 degrees). Special cases:<ul> - * <li>If either argument is NaN, the result is NaN.</li> - * <li>If the first argument is positive zero and the second argument is - * positive, or the first argument is positive and finite and the second - * argument is positive infinity, then the result is positive zero.</li> - * <li>If the first argument is negative zero and the second argument is - * positive, or the first argument is negative and finite and the second - * argument is positive infinity, then the result is negative zero.</li> - * <li>If the first argument is positive zero and the second argument is - * negative, or the first argument is positive and finite and the second - * argument is negative infinity, then the result is the double value - * closest to pi.</li> - * <li>If the first argument is negative zero and the second argument is - * negative, or the first argument is negative and finite and the second - * argument is negative infinity, then the result is the double value - * closest to -pi.</li> - * <li>If the first argument is positive and the second argument is - * positive zero or negative zero, or the first argument is positive - * infinity and the second argument is finite, then the result is the - * double value closest to pi/2.</li> - * <li>If the first argument is negative and the second argument is - * positive zero or negative zero, or the first argument is negative - * infinity and the second argument is finite, then the result is the - * double value closest to -pi/2.</li> - * <li>If both arguments are positive infinity, then the result is the - * double value closest to pi/4.</li> - * <li>If the first argument is positive infinity and the second argument - * is negative infinity, then the result is the double value closest to - * 3*pi/4.</li> - * <li>If the first argument is negative infinity and the second argument - * is positive infinity, then the result is the double value closest to - * -pi/4.</li> - * <li>If both arguments are negative infinity, then the result is the - * double value closest to -3*pi/4.</li> - * - * </ul><p>This is accurate within 2 ulps, and is semi-monotonic. To get r, - * use sqrt(x*x+y*y). - * - * @param y the y position - * @param x the x position - * @return <em>theta</em> in the conversion of (x, y) to (r, theta) - * @see #atan(double) - */ - public static native double atan2(double y, double x); - - /** - * Take <em>e</em><sup>a</sup>. The opposite of <code>log()</code>. If the - * argument is NaN, the result is NaN; if the argument is positive infinity, - * the result is positive infinity; and if the argument is negative - * infinity, the result is positive zero. This is accurate within 1 ulp, - * and is semi-monotonic. - * - * @param a the number to raise to the power - * @return the number raised to the power of <em>e</em> - * @see #log(double) - * @see #pow(double, double) - */ - public static native double exp(double a); - - /** - * Take ln(a) (the natural log). The opposite of <code>exp()</code>. If the - * argument is NaN or negative, the result is NaN; if the argument is - * positive infinity, the result is positive infinity; and if the argument - * is either zero, the result is negative infinity. This is accurate within - * 1 ulp, and is semi-monotonic. - * - * <p>Note that the way to get log<sub>b</sub>(a) is to do this: - * <code>ln(a) / ln(b)</code>. - * - * @param a the number to take the natural log of - * @return the natural log of <code>a</code> - * @see #exp(double) - */ - public static native double log(double a); - - /** - * Take a square root. If the argument is NaN or negative, the result is - * NaN; if the argument is positive infinity, the result is positive - * infinity; and if the result is either zero, the result is the same. - * This is accurate within the limits of doubles. - * - * <p>For other roots, use pow(a, 1 / rootNumber). - * - * @param a the numeric argument - * @return the square root of the argument - * @see #pow(double, double) - */ - public static native double sqrt(double a); - - /** - * Raise a number to a power. Special cases:<ul> - * <li>If the second argument is positive or negative zero, then the result - * is 1.0.</li> - * <li>If the second argument is 1.0, then the result is the same as the - * first argument.</li> - * <li>If the second argument is NaN, then the result is NaN.</li> - * <li>If the first argument is NaN and the second argument is nonzero, - * then the result is NaN.</li> - * <li>If the absolute value of the first argument is greater than 1 and - * the second argument is positive infinity, or the absolute value of the - * first argument is less than 1 and the second argument is negative - * infinity, then the result is positive infinity.</li> - * <li>If the absolute value of the first argument is greater than 1 and - * the second argument is negative infinity, or the absolute value of the - * first argument is less than 1 and the second argument is positive - * infinity, then the result is positive zero.</li> - * <li>If the absolute value of the first argument equals 1 and the second - * argument is infinite, then the result is NaN.</li> - * <li>If the first argument is positive zero and the second argument is - * greater than zero, or the first argument is positive infinity and the - * second argument is less than zero, then the result is positive zero.</li> - * <li>If the first argument is positive zero and the second argument is - * less than zero, or the first argument is positive infinity and the - * second argument is greater than zero, then the result is positive - * infinity.</li> - * <li>If the first argument is negative zero and the second argument is - * greater than zero but not a finite odd integer, or the first argument is - * negative infinity and the second argument is less than zero but not a - * finite odd integer, then the result is positive zero.</li> - * <li>If the first argument is negative zero and the second argument is a - * positive finite odd integer, or the first argument is negative infinity - * and the second argument is a negative finite odd integer, then the result - * is negative zero.</li> - * <li>If the first argument is negative zero and the second argument is - * less than zero but not a finite odd integer, or the first argument is - * negative infinity and the second argument is greater than zero but not a - * finite odd integer, then the result is positive infinity.</li> - * <li>If the first argument is negative zero and the second argument is a - * negative finite odd integer, or the first argument is negative infinity - * and the second argument is a positive finite odd integer, then the result - * is negative infinity.</li> - * <li>If the first argument is less than zero and the second argument is a - * finite even integer, then the result is equal to the result of raising - * the absolute value of the first argument to the power of the second - * argument.</li> - * <li>If the first argument is less than zero and the second argument is a - * finite odd integer, then the result is equal to the negative of the - * result of raising the absolute value of the first argument to the power - * of the second argument.</li> - * <li>If the first argument is finite and less than zero and the second - * argument is finite and not an integer, then the result is NaN.</li> - * <li>If both arguments are integers, then the result is exactly equal to - * the mathematical result of raising the first argument to the power of - * the second argument if that result can in fact be represented exactly as - * a double value.</li> - * - * </ul><p>(In the foregoing descriptions, a floating-point value is - * considered to be an integer if and only if it is a fixed point of the - * method {@link #ceil(double)} or, equivalently, a fixed point of the - * method {@link #floor(double)}. A value is a fixed point of a one-argument - * method if and only if the result of applying the method to the value is - * equal to the value.) This is accurate within 1 ulp, and is semi-monotonic. - * - * @param a the number to raise - * @param b the power to raise it to - * @return a<sup>b</sup> - */ - public static native double pow(double a, double b); - - /** - * Get the IEEE 754 floating point remainder on two numbers. This is the - * value of <code>x - y * <em>n</em></code>, where <em>n</em> is the closest - * double to <code>x / y</code> (ties go to the even n); for a zero - * remainder, the sign is that of <code>x</code>. If either argument is NaN, - * the first argument is infinite, or the second argument is zero, the result - * is NaN; if x is finite but y is infinite, the result is x. This is - * accurate within the limits of doubles. - * - * @param x the dividend (the top half) - * @param y the divisor (the bottom half) - * @return the IEEE 754-defined floating point remainder of x/y - * @see #rint(double) - */ - public static native double IEEEremainder(double x, double y); - - /** - * Take the nearest integer that is that is greater than or equal to the - * argument. If the argument is NaN, infinite, or zero, the result is the - * same; if the argument is between -1 and 0, the result is negative zero. - * Note that <code>Math.ceil(x) == -Math.floor(-x)</code>. - * - * @param a the value to act upon - * @return the nearest integer >= <code>a</code> - */ - public static native double ceil(double a); - - /** - * Take the nearest integer that is that is less than or equal to the - * argument. If the argument is NaN, infinite, or zero, the result is the - * same. Note that <code>Math.ceil(x) == -Math.floor(-x)</code>. - * - * @param a the value to act upon - * @return the nearest integer <= <code>a</code> - */ - public static native double floor(double a); - - /** - * Take the nearest integer to the argument. If it is exactly between - * two integers, the even integer is taken. If the argument is NaN, - * infinite, or zero, the result is the same. - * - * @param a the value to act upon - * @return the nearest integer to <code>a</code> - */ - public static native double rint(double a); - - /** - * Take the nearest integer to the argument. This is equivalent to - * <code>(int) Math.floor(a + 0.5f)</code>. If the argument is NaN, the result - * is 0; otherwise if the argument is outside the range of int, the result - * will be Integer.MIN_VALUE or Integer.MAX_VALUE, as appropriate. - * - * @param a the argument to round - * @return the nearest integer to the argument - * @see Integer#MIN_VALUE - * @see Integer#MAX_VALUE - */ - public static int round(float a) - { - // this check for NaN, from JLS 15.21.1, saves a method call - if (a != a) - return 0; - return (int) floor(a + 0.5f); - } - - /** - * Take the nearest long to the argument. This is equivalent to - * <code>(long) Math.floor(a + 0.5)</code>. If the argument is NaN, the - * result is 0; otherwise if the argument is outside the range of long, the - * result will be Long.MIN_VALUE or Long.MAX_VALUE, as appropriate. - * - * @param a the argument to round - * @return the nearest long to the argument - * @see Long#MIN_VALUE - * @see Long#MAX_VALUE - */ - public static long round(double a) - { - // this check for NaN, from JLS 15.21.1, saves a method call - if (a != a) - return 0; - return (long) floor(a + 0.5d); - } - - /** - * Get a random number. This behaves like Random.nextDouble(), seeded by - * System.currentTimeMillis() when first called. In other words, the number - * is from a pseudorandom sequence, and lies in the range [+0.0, 1.0). - * This random sequence is only used by this method, and is threadsafe, - * although you may want your own random number generator if it is shared - * among threads. - * - * @return a random number - * @see Random#nextDouble() - * @see System#currentTimeMillis() - */ - public static synchronized double random() - { - if (rand == null) - rand = new Random(); - return rand.nextDouble(); - } - - /** - * Convert from degrees to radians. The formula for this is - * radians = degrees * (pi/180); however it is not always exact given the - * limitations of floating point numbers. - * - * @param degrees an angle in degrees - * @return the angle in radians - * @since 1.2 - */ - public static double toRadians(double degrees) - { - return (degrees * PI) / 180; - } - - /** - * Convert from radians to degrees. The formula for this is - * degrees = radians * (180/pi); however it is not always exact given the - * limitations of floating point numbers. - * - * @param rads an angle in radians - * @return the angle in degrees - * @since 1.2 - */ - public static double toDegrees(double rads) - { - return (rads * 180) / PI; - } -} diff --git a/libjava/java/lang/NegativeArraySizeException.java b/libjava/java/lang/NegativeArraySizeException.java deleted file mode 100644 index fcfa52e..0000000 --- a/libjava/java/lang/NegativeArraySizeException.java +++ /dev/null @@ -1,77 +0,0 @@ -/* NegativeArraySizeException.java -- thrown on attempt to create array - with a negative size - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown when an attempt is made to create an array with a negative - * size. For example:<br> - * <pre> - * int i = -1; - * int[] array = new int[i]; - * </pre> - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @status updated to 1.4 - */ -public class NegativeArraySizeException extends RuntimeException -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -8960118058596991861L; - - /** - * Create an exception without a message. - */ - public NegativeArraySizeException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public NegativeArraySizeException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/NoClassDefFoundError.java b/libjava/java/lang/NoClassDefFoundError.java deleted file mode 100644 index 7e8e6ca..0000000 --- a/libjava/java/lang/NoClassDefFoundError.java +++ /dev/null @@ -1,76 +0,0 @@ -/* NoClassDefFoundError.java -- thrown when a ClassLoader cannot find a class - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * A <code>NoClassDefFoundError</code> is thrown when a classloader or the - * Java Virtual Machine tries to load a class and no definition of the class - * can be found. This could happen when using the <code>new</code> expression - * or during a normal method call. The reason this would occur at runtime is - * because the missing class definition existed when the currently executing - * class was compiled, but now that definition cannot be found. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public class NoClassDefFoundError extends LinkageError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 9095859863287012458L; - - /** - * Create an error without a message. - */ - public NoClassDefFoundError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public NoClassDefFoundError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/NoSuchFieldError.java b/libjava/java/lang/NoSuchFieldError.java deleted file mode 100644 index af42e35..0000000 --- a/libjava/java/lang/NoSuchFieldError.java +++ /dev/null @@ -1,74 +0,0 @@ -/* NoSuchFieldError.java -- thrown when the linker does not find a field - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * A <code>NoSuchFieldError</code> is thrown if an application attempts - * to access a field of a class, and that class no longer has that field. - * This is normally detected by the compiler, so it signals that you are - * using binary incompatible class versions. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public class NoSuchFieldError extends IncompatibleClassChangeError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -3456430195886129035L; - - /** - * Create an error without a message. - */ - public NoSuchFieldError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public NoSuchFieldError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/NoSuchFieldException.java b/libjava/java/lang/NoSuchFieldException.java deleted file mode 100644 index 74d52d1..0000000 --- a/libjava/java/lang/NoSuchFieldException.java +++ /dev/null @@ -1,73 +0,0 @@ -/* NoSuchFieldException.java -- thrown when reflecting a non-existant field - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown to indicate the class does not have the specified field. This is - * caused by a variety of reflection methods, when looking up a field by name. - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @since 1.1 - * @status updated to 1.4 - */ -public class NoSuchFieldException extends Exception -{ - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = -6143714805279938260L; - - /** - * Create an exception without a message. - */ - public NoSuchFieldException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public NoSuchFieldException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/NoSuchMethodError.java b/libjava/java/lang/NoSuchMethodError.java deleted file mode 100644 index 2bda776..0000000 --- a/libjava/java/lang/NoSuchMethodError.java +++ /dev/null @@ -1,74 +0,0 @@ -/* NoSuchMethodError.java -- thrown when the linker does not find a method - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * A <code>NoSuchMethodError</code> is thrown if an application attempts - * to access a method of a class, and that class no longer has that method. - * This is normally detected by the compiler, so it signals that you are - * using binary incompatible class versions. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public class NoSuchMethodError extends IncompatibleClassChangeError -{ - /** - * Compatible with JDK 1.0+. - */ - static final long serialVersionUID = -3765521442372831335L; - - /** - * Create an error without a message. - */ - public NoSuchMethodError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public NoSuchMethodError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/NoSuchMethodException.java b/libjava/java/lang/NoSuchMethodException.java deleted file mode 100644 index e423efb..0000000 --- a/libjava/java/lang/NoSuchMethodException.java +++ /dev/null @@ -1,72 +0,0 @@ -/* NoSuchMethodException.java -- thrown when reflecting a non-existant method - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown to indicate the class does not have the specified method. This is - * caused by a variety of reflection methods, when looking up a method by name. - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @status updated to 1.4 - */ -public class NoSuchMethodException extends Exception -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 5034388446362600923L; - - /** - * Create an exception without a message. - */ - public NoSuchMethodException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public NoSuchMethodException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/NullPointerException.java b/libjava/java/lang/NullPointerException.java deleted file mode 100644 index 29a4ee0..0000000 --- a/libjava/java/lang/NullPointerException.java +++ /dev/null @@ -1,82 +0,0 @@ -/* NullPointerException.java -- thrown when using null instead of an object - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown when attempting to use <code>null</code> where an object - * is required. The Virtual Machine automatically throws this exception - * for the following:<br><ul> - * <li>Calling an instance method on a null object</li> - * <li>Accessing or modifying a field of a null object</li> - * <li>Taking the array length of a null array</li> - * <li>Accessing or modifying the slots of a null array</li> - * <li>Throwing a null Throwable</li> - * <li>Synchronizing on a null object</li> - * </ul> - * <p>Applications should also throw NullPointerExceptions whenever - * <code>null</code> is an inappropriate parameter to a method. - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @status updated to 1.4 - */ -public class NullPointerException extends RuntimeException -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 5162710183389028792L; - - /** - * Create an exception without a message. - */ - public NullPointerException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public NullPointerException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/Number.java b/libjava/java/lang/Number.java deleted file mode 100644 index eb81f78..0000000 --- a/libjava/java/lang/Number.java +++ /dev/null @@ -1,131 +0,0 @@ -/* Number.java =- abstract superclass of numeric objects - Copyright (C) 1998, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -import java.io.Serializable; - -/** - * Number is a generic superclass of all the numeric classes, including - * the wrapper classes {@link Byte}, {@link Short}, {@link Integer}, - * {@link Long}, {@link Float}, and {@link Double}. Also worth mentioning - * are the classes in {@link java.math}. - * - * It provides ways to convert numeric objects to any primitive. - * - * @author Paul Fisher - * @author John Keiser - * @author Warren Levy - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.0 - * @status updated to 1.4 - */ -public abstract class Number implements Serializable -{ - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = -8742448824652078965L; - - /** - * Table for calculating digits, used in Character, Long, and Integer. - */ - static final char[] digits = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', - 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', - 'u', 'v', 'w', 'x', 'y', 'z', - }; - - /** - * The basic constructor (often called implicitly). - */ - public Number() - { - } - - /** - * Return the value of this <code>Number</code> as an <code>int</code>. - * - * @return the int value - */ - public abstract int intValue(); - - /** - * Return the value of this <code>Number</code> as a <code>long</code>. - * - * @return the long value - */ - public abstract long longValue(); - - /** - * Return the value of this <code>Number</code> as a <code>float</code>. - * - * @return the float value - */ - public abstract float floatValue(); - - /** - * Return the value of this <code>Number</code> as a <code>float</code>. - * - * @return the double value - */ - public abstract double doubleValue(); - - /** - * Return the value of this <code>Number</code> as a <code>byte</code>. - * - * @return the byte value - * @since 1.1 - */ - public byte byteValue() - { - return (byte) intValue(); - } - - /** - * Return the value of this <code>Number</code> as a <code>short</code>. - * - * @return the short value - * @since 1.1 - */ - public short shortValue() - { - return (short) intValue(); - } -} diff --git a/libjava/java/lang/NumberFormatException.java b/libjava/java/lang/NumberFormatException.java deleted file mode 100644 index bf98156..0000000 --- a/libjava/java/lang/NumberFormatException.java +++ /dev/null @@ -1,73 +0,0 @@ -/* NumberFormatException.java -- thrown when parsing a bad string as a number - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Can be thrown when attempting to convert a <code>String</code> to - * one of the numeric types, but the operation fails because the string - * has the wrong format. - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @status updated to 1.4 - */ -public class NumberFormatException extends IllegalArgumentException -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -2848938806368998894L; - - /** - * Create an exception without a message. - */ - public NumberFormatException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public NumberFormatException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/OutOfMemoryError.java b/libjava/java/lang/OutOfMemoryError.java deleted file mode 100644 index 66da563..0000000 --- a/libjava/java/lang/OutOfMemoryError.java +++ /dev/null @@ -1,73 +0,0 @@ -/* OutOfMemoryError.java -- thrown when a memory allocation fails - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Thrown when the Java Virtual Machine is unable to allocate an object - * because it is out of memory and no more memory could be made available - * by the garbage collector. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public class OutOfMemoryError extends VirtualMachineError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 8228564086184010517L; - - /** - * Create an error without a message. - */ - public OutOfMemoryError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public OutOfMemoryError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/Process.java b/libjava/java/lang/Process.java deleted file mode 100644 index b6e18ca..0000000 --- a/libjava/java/lang/Process.java +++ /dev/null @@ -1,129 +0,0 @@ -/* Process.java - Represent spawned system process - Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005 - Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -import java.io.InputStream; -import java.io.OutputStream; - -/** - * An instance of a subclass of <code>Process</code> is created by the - * <code>Runtime.exec</code> methods. Methods in <code>Process</code> - * provide a means to send input to a process, obtain the output from a - * subprocess, destroy a subprocess, obtain the exit value from a - * subprocess, and wait for a subprocess to complete. - * - * <p>This is dependent on the platform, and some processes (like native - * windowing processes, 16-bit processes in Windows, or shell scripts) may - * be limited in functionality. Because some platforms have limited buffers - * between processes, you may need to provide input and read output to prevent - * the process from blocking, or even deadlocking. - * - * <p>Even if all references to this object disapper, the process continues - * to execute to completion. There are no guarantees that the - * subprocess execute asynchronously or concurrently with the process which - * owns this object. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @see Runtime#exec(String[], String[], File) - * @since 1.0 - * @status updated to 1.4 - */ -public abstract class Process -{ - /** - * Empty constructor does nothing. - */ - public Process() - { - } - - /** - * Obtain the output stream that sends data to the subprocess. This is - * the STDIN of the subprocess. When implementing, you should probably - * use a buffered stream. - * - * @return the output stream that pipes to the process input - */ - public abstract OutputStream getOutputStream(); - - /** - * Obtain the input stream that receives data from the subprocess. This is - * the STDOUT of the subprocess. When implementing, you should probably - * use a buffered stream. - * - * @return the input stream that pipes data from the process output - */ - public abstract InputStream getInputStream(); - - /** - * Obtain the input stream that receives data from the subprocess. This is - * the STDERR of the subprocess. When implementing, you should probably - * use a buffered stream. - * - * @return the input stream that pipes data from the process error output - */ - public abstract InputStream getErrorStream(); - - /** - * The thread calling <code>waitFor</code> will block until the subprocess - * has terminated. If the process has already terminated then the method - * immediately returns with the exit value of the subprocess. - * - * @return the subprocess exit value; 0 conventionally denotes success - * @throws InterruptedException if another thread interrupts the blocked one - */ - public abstract int waitFor() throws InterruptedException; - - /** - * When a process terminates there is associated with that termination - * an exit value for the process to indicate why it terminated. A return - * of <code>0</code> denotes normal process termination by convention. - * - * @return the exit value of the subprocess - * @throws IllegalThreadStateException if the subprocess has not terminated - */ - public abstract int exitValue(); - - /** - * Kills the subprocess and all of its children forcibly. - */ - public abstract void destroy(); -} // class Process diff --git a/libjava/java/lang/Runnable.java b/libjava/java/lang/Runnable.java deleted file mode 100644 index 32c52b9..0000000 --- a/libjava/java/lang/Runnable.java +++ /dev/null @@ -1,62 +0,0 @@ -/* Runnable -- interface for a method tied to an Object; often for Threads - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Runnable is an interface you implement to indicate that your class can be - * executed as the main part of a Thread, among other places. When you want - * an entry point to run a piece of code, implement this interface and - * override run. - * - * @author Paul Fisher - * @author Tom Tromey (tromey@cygnus.com) - * @see Thread - * @since 1.0 - * @status updated to 1.4 - */ -public interface Runnable -{ - /** - * This method will be called by whoever wishes to run your class - * implementing Runnable. Note that there are no restrictions on what - * you are allowed to do in the run method, except that you cannot - * throw a checked exception. - */ - void run(); -} diff --git a/libjava/java/lang/RuntimeException.java b/libjava/java/lang/RuntimeException.java deleted file mode 100644 index 72cf087..0000000 --- a/libjava/java/lang/RuntimeException.java +++ /dev/null @@ -1,102 +0,0 @@ -/* RuntimeException.java -- root of all unchecked exceptions - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * All exceptions which are subclasses of <code>RuntimeException</code> - * can be thrown at any time during the execution of a Java virtual machine. - * Methods which throw these exceptions are not required to declare them - * in their throws clause. - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @author Eric Blake (ebb9@email.byu.edu) - * @status updated to 1.4 - */ -public class RuntimeException extends Exception -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -7034897190745766939L; - - /** - * Create an exception without a message. The cause remains uninitialized. - * - * @see #initCause(Throwable) - */ - public RuntimeException() - { - } - - /** - * Create an exception with a message. The cause remains uninitialized. - * - * @param s the message string - * @see #initCause(Throwable) - */ - public RuntimeException(String s) - { - super(s); - } - - /** - * Create an exception with a message and a cause. - * - * @param s the message string - * @param cause the cause of this exception - * @since 1.4 - */ - public RuntimeException(String s, Throwable cause) - { - super(s, cause); - } - - /** - * Create an exception with the given cause, and a message of - * <code>cause == null ? null : cause.toString()</code>. - * - * @param cause the cause of this exception - * @since 1.4 - */ - public RuntimeException(Throwable cause) - { - super(cause); - } -} diff --git a/libjava/java/lang/RuntimePermission.java b/libjava/java/lang/RuntimePermission.java deleted file mode 100644 index ca33307..0000000 --- a/libjava/java/lang/RuntimePermission.java +++ /dev/null @@ -1,208 +0,0 @@ -/* RuntimePermission.java -- permission for a secure runtime action - Copyright (C) 1998, 2000, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -import java.security.BasicPermission; - -/** - * A <code>RuntimePermission</code> contains a permission name, but no - * actions list. This means you either have the permission or you don't. - * - * Permission names have the follow the hierarchial property naming - * convention. In addition, an asterisk may appear at the end of a - * name if following a period or by itself. - * - * <table border=1> - * <tr><th>Valid names</th><th>Invalid names</th></tr> - * <tr><td>"accessClassInPackage.*","*"</td> - * <td>"**", "*x", "*.a"</td></tr> - * </table> - * <br> - * - * The following table provides a list of all the possible RuntimePermission - * permission names with a description of what that permission allows.<br> - * <table border=1> - * <tr><th>Permission Name</th><th>Permission Allows</th><th>Risks</th</tr> - * <tr> - * <td><code>createClassLoader</code></td> - * <td>creation of a class loader</td> - * <td>a class loader can load rogue classes which bypass all security - * permissions</td></tr> - * <tr> - * <td><code>getClassLoader</code></td> - * <td>retrieval of the class loader for the calling class</td> - * <td>rogue code could load classes not otherwise available</td></tr> - * <tr> - * <td><code>setContextClassLoader</code></td> - * <td>allows the setting of the context class loader used by a thread</td> - * <td>rogue code could change the context class loader needed by system - * threads</td></tr> - * <tr> - * <td><code>setSecurityManager</code></td> - * <td>allows the application to replace the security manager</td> - * <td>the new manager may be less restrictive, so that rogue code can - * bypass existing security checks</td></tr> - * <tr> - * <td><code>createSecurityManager</code></td> - * <td>allows the application to create a new security manager</td> - * <td>rogue code can use the new security manager to discover information - * about the execution stack</td></tr> - * <tr> - * <td><code>exitVM</code></td> - * <td>allows the application to halt the virtual machine</td> - * <td>rogue code can mount a denial-of-service attack by killing the - * virtual machine</td></tr> - * <tr> - * <td><code>shutdownHooks</code></td> - * <td>allows registration and modification of shutdown hooks</td> - * <td>rogue code can add a hook that interferes with clean - * virtual machine shutdown</td></tr> - * <tr> - * <td><code>setFactory</code></td> - * <td>allows the application to set the socket factory for socket, - * server socket, stream handler, or RMI socket factory.</td> - * <td>rogue code can create a rogue network object which mangles or - * intercepts data</td></tr> - * <tr> - * <td><code>setIO</code></td> - * <td>allows the application to set System.out, System.in, and - * System.err</td> - * <td>rogue code could sniff user input and intercept or mangle - * output</td></tr> - * <tr> - * <td><code>modifyThread</code></td> - * <td>allows the application to modify any thread in the virtual machine - * using any of the methods <code>stop</code>, <code>resume</code>, - * <code>suspend</code>, <code>setPriority</code>, and - * <code>setName</code> of classs <code>Thread</code></td> - * <td>rogue code could adversely modify system or user threads</td></tr> - * <tr> - * <td><code>stopThread</code></td> - * <td>allows the application to <code>stop</code> any thread it has - * access to in the system</td> - * <td>rogue code can stop arbitrary threads</td></tr> - * <tr> - * <td><code>modifyThreadGroup</code></td> - * <td>allows the application to modify thread groups using any of the - * methods <code>destroy</code>, <code>resume</code>, - * <code>setDaemon</code>, <code>setMaxPriority</code>, - * <code>stop</code>, and <code>suspend</code> of the class - * <code>ThreadGroup</code></td> - * <td>rogue code can mount a denial-of-service attack by changing run - * priorities</td></tr> - * <tr> - * <td><code>getProtectionDomain</code></td> - * <td>retrieve a class's ProtectionDomain</td> - * <td>rogue code can gain information about the security policy, to - * prepare a better attack</td></tr> - * <tr> - * <td><code>readFileDescriptor</code></td> - * <td>read a file descriptor</td> - * <td>rogue code can read sensitive information</td></tr> - * <tr> - * <td><code>writeFileDescriptor</code></td> - * <td>write a file descriptor</td> - * <td>rogue code can write files, including viruses, and can modify the - * virtual machine binary; if not just fill up the disk</td></tr> - * <tr> - * <td><code>loadLibrary.</code><em>library name</em></td> - * <td>dynamic linking of the named library</td> - * <td>native code can bypass many security checks of pure Java</td></tr> - * <tr> - * <td><code>accessClassInPackage.</code><em>package name</em></td> - * <td>access to a package via a ClassLoader</td> - * <td>rogue code can access classes not normally available</td></tr> - * <tr> - * <td><code>defineClassInPackage.</code><em>package name</em></td> - * <td>define a class inside a given package</td> - * <td>rogue code can install rogue classes, including in trusted packages - * like java.security or java.lang</td></tr> - * <tr> - * <td><code>accessDeclaredMembers</code></td> - * <td>access declared class members via reflection</td> - * <td>rogue code can discover information, invoke methods, or modify fields - * that are not otherwise available</td></tr> - * <tr> - * <td><code>queuePrintJob</code></td> - * <td>initiate a print job</td> - * <td>rogue code could make a hard copy of sensitive information, or - * simply waste paper</td></tr> - * </table> - * - * @author Brian Jones - * @author Eric Blake (ebb9@email.byu.edu) - * @see BasicPermission - * @see Permission - * @see SecurityManager - * @since 1.2 - * @status updated to 1.4 - */ -public final class RuntimePermission extends BasicPermission -{ - /** - * Compatible with JDK 1.2+. - */ - private static final long serialVersionUID = 7399184964622342223L; - - /** - * Create a new permission with the specified name. - * - * @param permissionName the name of the granted permission - * @throws NullPointerException if name is null - * @throws IllegalArgumentException thrown if name is empty or invalid - */ - public RuntimePermission(String permissionName) - { - super(permissionName); - } - - /** - * Create a new permission with the specified name. The actions argument - * is ignored, as runtime permissions have no actions. - * - * @param permissionName the name of the granted permission - * @param actions ignored - * @throws NullPointerException if name is null - * @throws IllegalArgumentException thrown if name is empty or invalid - */ - public RuntimePermission(String permissionName, String actions) - { - super(permissionName); - } -} diff --git a/libjava/java/lang/SecurityException.java b/libjava/java/lang/SecurityException.java deleted file mode 100644 index a95d797..0000000 --- a/libjava/java/lang/SecurityException.java +++ /dev/null @@ -1,74 +0,0 @@ -/* SecurityException.java -- thrown to indicate a security violation - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * The security manager will throw this exception to indicate a security - * violation. This can occur any time an operation is attempted which is - * deemed unsafe by the current security policies. - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @see SecurityManager - * @status updated to 1.4 - */ -public class SecurityException extends RuntimeException -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 6878364983674394167L; - - /** - * Create an exception without a message. - */ - public SecurityException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public SecurityException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/Short.java b/libjava/java/lang/Short.java deleted file mode 100644 index fbeea91..0000000 --- a/libjava/java/lang/Short.java +++ /dev/null @@ -1,353 +0,0 @@ -/* Short.java -- object wrapper for short - Copyright (C) 1998, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * Instances of class <code>Short</code> represent primitive - * <code>short</code> values. - * - * Additionally, this class provides various helper functions and variables - * related to shorts. - * - * @author Paul Fisher - * @author John Keiser - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.1 - * @status updated to 1.4 - */ -public final class Short extends Number implements Comparable -{ - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = 7515723908773894738L; - - /** - * The minimum value a <code>short</code> can represent is -32768 (or - * -2<sup>15</sup>). - */ - public static final short MIN_VALUE = -32768; - - /** - * The minimum value a <code>short</code> can represent is 32767 (or - * 2<sup>15</sup>). - */ - public static final short MAX_VALUE = 32767; - - /** - * The primitive type <code>short</code> is represented by this - * <code>Class</code> object. - */ - public static final Class TYPE = VMClassLoader.getPrimitiveClass('S'); - - /** - * The immutable value of this Short. - * - * @serial the wrapped short - */ - private final short value; - - /** - * Create a <code>Short</code> object representing the value of the - * <code>short</code> argument. - * - * @param value the value to use - */ - public Short(short value) - { - this.value = value; - } - - /** - * Create a <code>Short</code> object representing the value of the - * argument after conversion to a <code>short</code>. - * - * @param s the string to convert - * @throws NumberFormatException if the String cannot be parsed - */ - public Short(String s) - { - value = parseShort(s, 10); - } - - /** - * Converts the <code>short</code> to a <code>String</code> and assumes - * a radix of 10. - * - * @param s the <code>short</code> to convert to <code>String</code> - * @return the <code>String</code> representation of the argument - */ - public static String toString(short s) - { - return String.valueOf(s); - } - - /** - * Converts the specified <code>String</code> into a <code>short</code>. - * This function assumes a radix of 10. - * - * @param s the <code>String</code> to convert - * @return the <code>short</code> value of <code>s</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>short</code> - */ - public static short parseShort(String s) - { - return parseShort(s, 10); - } - - /** - * Converts the specified <code>String</code> into a <code>short</code> - * using the specified radix (base). The string must not be <code>null</code> - * or empty. It may begin with an optional '-', which will negate the answer, - * provided that there are also valid digits. Each digit is parsed as if by - * <code>Character.digit(d, radix)</code>, and must be in the range - * <code>0</code> to <code>radix - 1</code>. Finally, the result must be - * within <code>MIN_VALUE</code> to <code>MAX_VALUE</code>, inclusive. - * Unlike Double.parseDouble, you may not have a leading '+'. - * - * @param s the <code>String</code> to convert - * @param radix the radix (base) to use in the conversion - * @return the <code>String</code> argument converted to <code>short</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>short</code> - */ - public static short parseShort(String s, int radix) - { - int i = Integer.parseInt(s, radix, false); - if ((short) i != i) - throw new NumberFormatException(); - return (short) i; - } - - /** - * Creates a new <code>Short</code> object using the <code>String</code> - * and specified radix (base). - * - * @param s the <code>String</code> to convert - * @param radix the radix (base) to convert with - * @return the new <code>Short</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>short</code> - * @see #parseShort(String, int) - */ - public static Short valueOf(String s, int radix) - { - return new Short(parseShort(s, radix)); - } - - /** - * Creates a new <code>Short</code> object using the <code>String</code>, - * assuming a radix of 10. - * - * @param s the <code>String</code> to convert - * @return the new <code>Short</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>short</code> - * @see #Short(String) - * @see #parseShort(String) - */ - public static Short valueOf(String s) - { - return new Short(parseShort(s, 10)); - } - - /** - * Convert the specified <code>String</code> into a <code>Short</code>. - * The <code>String</code> may represent decimal, hexadecimal, or - * octal numbers. - * - * <p>The extended BNF grammar is as follows:<br> - * <pre> - * <em>DecodableString</em>: - * ( [ <code>-</code> ] <em>DecimalNumber</em> ) - * | ( [ <code>-</code> ] ( <code>0x</code> | <code>0X</code> - * | <code>#</code> ) <em>HexDigit</em> { <em>HexDigit</em> } ) - * | ( [ <code>-</code> ] <code>0</code> { <em>OctalDigit</em> } ) - * <em>DecimalNumber</em>: - * <em>DecimalDigit except '0'</em> { <em>DecimalDigit</em> } - * <em>DecimalDigit</em>: - * <em>Character.digit(d, 10) has value 0 to 9</em> - * <em>OctalDigit</em>: - * <em>Character.digit(d, 8) has value 0 to 7</em> - * <em>DecimalDigit</em>: - * <em>Character.digit(d, 16) has value 0 to 15</em> - * </pre> - * Finally, the value must be in the range <code>MIN_VALUE</code> to - * <code>MAX_VALUE</code>, or an exception is thrown. - * - * @param s the <code>String</code> to interpret - * @return the value of the String as a <code>Short</code> - * @throws NumberFormatException if <code>s</code> cannot be parsed as a - * <code>short</code> - * @throws NullPointerException if <code>s</code> is null - * @see Integer#decode(String) - */ - public static Short decode(String s) - { - int i = Integer.parseInt(s, 10, true); - if ((short) i != i) - throw new NumberFormatException(); - return new Short((short) i); - } - - /** - * Return the value of this <code>Short</code> as a <code>byte</code>. - * - * @return the byte value - */ - public byte byteValue() - { - return (byte) value; - } - - /** - * Return the value of this <code>Short</code>. - * - * @return the short value - */ - public short shortValue() - { - return value; - } - - /** - * Return the value of this <code>Short</code> as an <code>int</code>. - * - * @return the int value - */ - public int intValue() - { - return value; - } - - /** - * Return the value of this <code>Short</code> as a <code>long</code>. - * - * @return the long value - */ - public long longValue() - { - return value; - } - - /** - * Return the value of this <code>Short</code> as a <code>float</code>. - * - * @return the float value - */ - public float floatValue() - { - return value; - } - - /** - * Return the value of this <code>Short</code> as a <code>double</code>. - * - * @return the double value - */ - public double doubleValue() - { - return value; - } - - /** - * Converts the <code>Short</code> value to a <code>String</code> and - * assumes a radix of 10. - * - * @return the <code>String</code> representation of this <code>Short</code> - */ - public String toString() - { - return String.valueOf(value); - } - - /** - * Return a hashcode representing this Object. <code>Short</code>'s hash - * code is simply its value. - * - * @return this Object's hash code - */ - public int hashCode() - { - return value; - } - - /** - * Returns <code>true</code> if <code>obj</code> is an instance of - * <code>Short</code> and represents the same short value. - * - * @param obj the object to compare - * @return whether these Objects are semantically equal - */ - public boolean equals(Object obj) - { - return obj instanceof Short && value == ((Short) obj).value; - } - - /** - * Compare two Shorts numerically by comparing their <code>short</code> - * values. The result is positive if the first is greater, negative if the - * second is greater, and 0 if the two are equal. - * - * @param s the Short to compare - * @return the comparison - * @since 1.2 - */ - public int compareTo(Short s) - { - return value - s.value; - } - - /** - * Behaves like <code>compareTo(Short)</code> unless the Object - * is not a <code>Short</code>. - * - * @param o the object to compare - * @return the comparison - * @throws ClassCastException if the argument is not a <code>Short</code> - * @see #compareTo(Short) - * @see Comparable - * @since 1.2 - */ - public int compareTo(Object o) - { - return compareTo((Short)o); - } -} diff --git a/libjava/java/lang/StackOverflowError.java b/libjava/java/lang/StackOverflowError.java deleted file mode 100644 index 5188ddd..0000000 --- a/libjava/java/lang/StackOverflowError.java +++ /dev/null @@ -1,72 +0,0 @@ -/* StackOverflowError.java -- thrown when the stack depth is exceeded - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * A <code>StackOverflowError</code> is thrown when the execution stack - * overflow occurs. This often occurs when a method enters infinit recursion. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public class StackOverflowError extends VirtualMachineError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 8609175038441759607L; - - /** - * Create an error without a message. - */ - public StackOverflowError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public StackOverflowError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/StackTraceElement.java b/libjava/java/lang/StackTraceElement.java deleted file mode 100644 index 6dd4d85..0000000 --- a/libjava/java/lang/StackTraceElement.java +++ /dev/null @@ -1,259 +0,0 @@ -/* StackTraceElement.java -- One function call or call stack element - Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -import java.io.Serializable; - -/** - * One function call or stack trace element. Gives information about - * the execution point such as the source file name, the line number, - * the fully qualified class name, the method name and whether this method - * is native, if this information is known. - * - * @author Mark Wielaard (mark@klomp.org) - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.4 - * @status updated to 1.4 - */ -public final class StackTraceElement implements Serializable -{ - /** - * Compatible with JDK 1.4+. - */ - private static final long serialVersionUID = 6992337162326171013L; - - /** - * The name of the file, null if unknown. - * - * @serial the source code filename, if known - */ - private final String fileName; - - /** - * The line number in the file, negative if unknown. - * - * @serial the source code line number, if known - */ - private final int lineNumber; - - /** - * The fully qualified class name, null if unknown. - * - * @serial the enclosing class, if known - */ - private final String declaringClass; - - /** - * The method name in the class, null if unknown. - * - * @serial the enclosing method, if known - */ - private final String methodName; - - /** Whether the method is native. */ - private final transient boolean isNative; - - /** - * A package local constructor for the StackTraceElement class, to be - * called by the Virtual Machine as part of Throwable.fillInStackTrace. - * There are no public constructors defined for this class. Creation - * of new elements is implementation specific. - * - * @param fileName the name of the file, null if unknown - * @param lineNumber the line in the file, negative if unknown - * @param className the fully qualified name of the class, null if unknown - * @param methodName the name of the method, null if unknown - * @param isNative true if native, false otherwise - */ - StackTraceElement(String fileName, int lineNumber, String className, - String methodName, boolean isNative) - { - this.fileName = fileName; - this.lineNumber = lineNumber; - this.declaringClass = className; - this.methodName = methodName; - this.isNative = isNative; - } - - /** - * Returns the name of the file, or null if unknown. This is usually - * obtained from the <code>SourceFile</code> attribute of the class file - * format, if present. - * - * @return the file name - */ - public String getFileName() - { - return fileName; - } - - /** - * Returns the line number in the file, or a negative number if unknown. - * This is usually obtained from the <code>LineNumberTable</code> attribute - * of the method in the class file format, if present. - * - * @return the line number - */ - public int getLineNumber() - { - return lineNumber; - } - - /** - * Returns the fully qualified class name, or null if unknown. - * - * @return the class name - */ - public String getClassName() - { - return declaringClass; - } - - /** - * Returns the method name in the class, or null if unknown. If the - * execution point is in a constructor, the name is - * <code><init></code>; if the execution point is in the class - * initializer, the name is <code><clinit></code>. - * - * @return the method name - */ - public String getMethodName() - { - return methodName; - } - - /** - * Returns true if the method is native, or false if it is not or unknown. - * - * @return whether the method is native - */ - public boolean isNativeMethod() - { - return isNative; - } - - /** - * Returns a string representation of this stack trace element. The - * returned String is implementation specific. This implementation - * returns the following String: "[class][.][method]([file][:line])". - * If the fully qualified class name or the method is unknown it is - * omitted including the point seperator. If the source file name is - * unknown it is replaced by "Unknown Source" if the method is not native - * or by "Native Method" if the method is native. If the line number - * is unknown it and the colon are omitted. - * - * @return a string representation of this execution point - */ - public String toString() - { - StringBuffer sb = new StringBuffer(); - if (declaringClass != null) - { - sb.append(declaringClass); - if (methodName != null) - sb.append('.'); - } - if (methodName != null) - sb.append(methodName); - sb.append(" ("); - if (fileName != null) - sb.append(fileName); - else - sb.append(isNative ? "Native Method" : "Unknown Source"); - if (lineNumber >= 0) - sb.append(':').append(lineNumber); - sb.append(')'); - return sb.toString(); - } - - /** - * Returns true if the given object is also a StackTraceElement and all - * attributes, except the native flag, are equal (either the same attribute - * between the two elments are null, or both satisfy Object.equals). - * - * @param o the object to compare - * @return true if the two are equal - */ - public boolean equals(Object o) - { - if (! (o instanceof StackTraceElement)) - return false; - StackTraceElement e = (StackTraceElement) o; - return equals(fileName, e.fileName) - && lineNumber == e.lineNumber - && equals(declaringClass, e.declaringClass) - && equals(methodName, e.methodName); - } - - /** - * Returns the hashCode of this StackTraceElement. This implementation - * computes the hashcode by xor-ing the hashcode of all attributes except - * the native flag. - * - * @return the hashcode - */ - public int hashCode() - { - return hashCode(fileName) ^ lineNumber ^ hashCode(declaringClass) - ^ hashCode(methodName); - } - - /** - * Compare two objects according to Collection semantics. - * - * @param o1 the first object - * @param o2 the second object - * @return o1 == null ? o2 == null : o1.equals(o2) - */ - private static boolean equals(Object o1, Object o2) - { - return o1 == null ? o2 == null : o1.equals(o2); - } - - /** - * Hash an object according to Collection semantics. - * - * @param o the object to hash - * @return o1 == null ? 0 : o1.hashCode() - */ - private static int hashCode(Object o) - { - return o == null ? 0 : o.hashCode(); - } -} diff --git a/libjava/java/lang/StrictMath.java b/libjava/java/lang/StrictMath.java deleted file mode 100644 index 32bd354..0000000 --- a/libjava/java/lang/StrictMath.java +++ /dev/null @@ -1,1844 +0,0 @@ -/* java.lang.StrictMath -- common mathematical functions, strict Java - Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -/* - * Some of the algorithms in this class are in the public domain, as part - * of fdlibm (freely-distributable math library), available at - * http://www.netlib.org/fdlibm/, and carry the following copyright: - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -package java.lang; - -import gnu.classpath.Configuration; - -import java.util.Random; - -/** - * Helper class containing useful mathematical functions and constants. - * This class mirrors {@link Math}, but is 100% portable, because it uses - * no native methods whatsoever. Also, these algorithms are all accurate - * to less than 1 ulp, and execute in <code>strictfp</code> mode, while - * Math is allowed to vary in its results for some functions. Unfortunately, - * this usually means StrictMath has less efficiency and speed, as Math can - * use native methods. - * - * <p>The source of the various algorithms used is the fdlibm library, at:<br> - * <a href="http://www.netlib.org/fdlibm/">http://www.netlib.org/fdlibm/</a> - * - * Note that angles are specified in radians. Conversion functions are - * provided for your convenience. - * - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.3 - */ -public final strictfp class StrictMath -{ - /** - * StrictMath is non-instantiable. - */ - private StrictMath() - { - } - - /** - * A random number generator, initialized on first use. - * - * @see #random() - */ - private static Random rand; - - /** - * The most accurate approximation to the mathematical constant <em>e</em>: - * <code>2.718281828459045</code>. Used in natural log and exp. - * - * @see #log(double) - * @see #exp(double) - */ - public static final double E - = 2.718281828459045; // Long bits 0x4005bf0z8b145769L. - - /** - * The most accurate approximation to the mathematical constant <em>pi</em>: - * <code>3.141592653589793</code>. This is the ratio of a circle's diameter - * to its circumference. - */ - public static final double PI - = 3.141592653589793; // Long bits 0x400921fb54442d18L. - - /** - * Take the absolute value of the argument. (Absolute value means make - * it positive.) - * - * <p>Note that the the largest negative value (Integer.MIN_VALUE) cannot - * be made positive. In this case, because of the rules of negation in - * a computer, MIN_VALUE is what will be returned. - * This is a <em>negative</em> value. You have been warned. - * - * @param i the number to take the absolute value of - * @return the absolute value - * @see Integer#MIN_VALUE - */ - public static int abs(int i) - { - return (i < 0) ? -i : i; - } - - /** - * Take the absolute value of the argument. (Absolute value means make - * it positive.) - * - * <p>Note that the the largest negative value (Long.MIN_VALUE) cannot - * be made positive. In this case, because of the rules of negation in - * a computer, MIN_VALUE is what will be returned. - * This is a <em>negative</em> value. You have been warned. - * - * @param l the number to take the absolute value of - * @return the absolute value - * @see Long#MIN_VALUE - */ - public static long abs(long l) - { - return (l < 0) ? -l : l; - } - - /** - * Take the absolute value of the argument. (Absolute value means make - * it positive.) - * - * @param f the number to take the absolute value of - * @return the absolute value - */ - public static float abs(float f) - { - return (f <= 0) ? 0 - f : f; - } - - /** - * Take the absolute value of the argument. (Absolute value means make - * it positive.) - * - * @param d the number to take the absolute value of - * @return the absolute value - */ - public static double abs(double d) - { - return (d <= 0) ? 0 - d : d; - } - - /** - * Return whichever argument is smaller. - * - * @param a the first number - * @param b a second number - * @return the smaller of the two numbers - */ - public static int min(int a, int b) - { - return (a < b) ? a : b; - } - - /** - * Return whichever argument is smaller. - * - * @param a the first number - * @param b a second number - * @return the smaller of the two numbers - */ - public static long min(long a, long b) - { - return (a < b) ? a : b; - } - - /** - * Return whichever argument is smaller. If either argument is NaN, the - * result is NaN, and when comparing 0 and -0, -0 is always smaller. - * - * @param a the first number - * @param b a second number - * @return the smaller of the two numbers - */ - public static float min(float a, float b) - { - // this check for NaN, from JLS 15.21.1, saves a method call - if (a != a) - return a; - // no need to check if b is NaN; < will work correctly - // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special - if (a == 0 && b == 0) - return -(-a - b); - return (a < b) ? a : b; - } - - /** - * Return whichever argument is smaller. If either argument is NaN, the - * result is NaN, and when comparing 0 and -0, -0 is always smaller. - * - * @param a the first number - * @param b a second number - * @return the smaller of the two numbers - */ - public static double min(double a, double b) - { - // this check for NaN, from JLS 15.21.1, saves a method call - if (a != a) - return a; - // no need to check if b is NaN; < will work correctly - // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special - if (a == 0 && b == 0) - return -(-a - b); - return (a < b) ? a : b; - } - - /** - * Return whichever argument is larger. - * - * @param a the first number - * @param b a second number - * @return the larger of the two numbers - */ - public static int max(int a, int b) - { - return (a > b) ? a : b; - } - - /** - * Return whichever argument is larger. - * - * @param a the first number - * @param b a second number - * @return the larger of the two numbers - */ - public static long max(long a, long b) - { - return (a > b) ? a : b; - } - - /** - * Return whichever argument is larger. If either argument is NaN, the - * result is NaN, and when comparing 0 and -0, 0 is always larger. - * - * @param a the first number - * @param b a second number - * @return the larger of the two numbers - */ - public static float max(float a, float b) - { - // this check for NaN, from JLS 15.21.1, saves a method call - if (a != a) - return a; - // no need to check if b is NaN; > will work correctly - // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special - if (a == 0 && b == 0) - return a - -b; - return (a > b) ? a : b; - } - - /** - * Return whichever argument is larger. If either argument is NaN, the - * result is NaN, and when comparing 0 and -0, 0 is always larger. - * - * @param a the first number - * @param b a second number - * @return the larger of the two numbers - */ - public static double max(double a, double b) - { - // this check for NaN, from JLS 15.21.1, saves a method call - if (a != a) - return a; - // no need to check if b is NaN; > will work correctly - // recall that -0.0 == 0.0, but [+-]0.0 - [+-]0.0 behaves special - if (a == 0 && b == 0) - return a - -b; - return (a > b) ? a : b; - } - - /** - * The trigonometric function <em>sin</em>. The sine of NaN or infinity is - * NaN, and the sine of 0 retains its sign. - * - * @param a the angle (in radians) - * @return sin(a) - */ - public static double sin(double a) - { - if (a == Double.NEGATIVE_INFINITY || ! (a < Double.POSITIVE_INFINITY)) - return Double.NaN; - - if (abs(a) <= PI / 4) - return sin(a, 0); - - // Argument reduction needed. - double[] y = new double[2]; - int n = remPiOver2(a, y); - switch (n & 3) - { - case 0: - return sin(y[0], y[1]); - case 1: - return cos(y[0], y[1]); - case 2: - return -sin(y[0], y[1]); - default: - return -cos(y[0], y[1]); - } - } - - /** - * The trigonometric function <em>cos</em>. The cosine of NaN or infinity is - * NaN. - * - * @param a the angle (in radians). - * @return cos(a). - */ - public static double cos(double a) - { - if (a == Double.NEGATIVE_INFINITY || ! (a < Double.POSITIVE_INFINITY)) - return Double.NaN; - - if (abs(a) <= PI / 4) - return cos(a, 0); - - // Argument reduction needed. - double[] y = new double[2]; - int n = remPiOver2(a, y); - switch (n & 3) - { - case 0: - return cos(y[0], y[1]); - case 1: - return -sin(y[0], y[1]); - case 2: - return -cos(y[0], y[1]); - default: - return sin(y[0], y[1]); - } - } - - /** - * The trigonometric function <em>tan</em>. The tangent of NaN or infinity - * is NaN, and the tangent of 0 retains its sign. - * - * @param a the angle (in radians) - * @return tan(a) - */ - public static double tan(double a) - { - if (a == Double.NEGATIVE_INFINITY || ! (a < Double.POSITIVE_INFINITY)) - return Double.NaN; - - if (abs(a) <= PI / 4) - return tan(a, 0, false); - - // Argument reduction needed. - double[] y = new double[2]; - int n = remPiOver2(a, y); - return tan(y[0], y[1], (n & 1) == 1); - } - - /** - * The trigonometric function <em>arcsin</em>. The range of angles returned - * is -pi/2 to pi/2 radians (-90 to 90 degrees). If the argument is NaN or - * its absolute value is beyond 1, the result is NaN; and the arcsine of - * 0 retains its sign. - * - * @param x the sin to turn back into an angle - * @return arcsin(x) - */ - public static double asin(double x) - { - boolean negative = x < 0; - if (negative) - x = -x; - if (! (x <= 1)) - return Double.NaN; - if (x == 1) - return negative ? -PI / 2 : PI / 2; - if (x < 0.5) - { - if (x < 1 / TWO_27) - return negative ? -x : x; - double t = x * x; - double p = t * (PS0 + t * (PS1 + t * (PS2 + t * (PS3 + t - * (PS4 + t * PS5))))); - double q = 1 + t * (QS1 + t * (QS2 + t * (QS3 + t * QS4))); - return negative ? -x - x * (p / q) : x + x * (p / q); - } - double w = 1 - x; // 1>|x|>=0.5. - double t = w * 0.5; - double p = t * (PS0 + t * (PS1 + t * (PS2 + t * (PS3 + t - * (PS4 + t * PS5))))); - double q = 1 + t * (QS1 + t * (QS2 + t * (QS3 + t * QS4))); - double s = sqrt(t); - if (x >= 0.975) - { - w = p / q; - t = PI / 2 - (2 * (s + s * w) - PI_L / 2); - } - else - { - w = (float) s; - double c = (t - w * w) / (s + w); - p = 2 * s * (p / q) - (PI_L / 2 - 2 * c); - q = PI / 4 - 2 * w; - t = PI / 4 - (p - q); - } - return negative ? -t : t; - } - - /** - * The trigonometric function <em>arccos</em>. The range of angles returned - * is 0 to pi radians (0 to 180 degrees). If the argument is NaN or - * its absolute value is beyond 1, the result is NaN. - * - * @param x the cos to turn back into an angle - * @return arccos(x) - */ - public static double acos(double x) - { - boolean negative = x < 0; - if (negative) - x = -x; - if (! (x <= 1)) - return Double.NaN; - if (x == 1) - return negative ? PI : 0; - if (x < 0.5) - { - if (x < 1 / TWO_57) - return PI / 2; - double z = x * x; - double p = z * (PS0 + z * (PS1 + z * (PS2 + z * (PS3 + z - * (PS4 + z * PS5))))); - double q = 1 + z * (QS1 + z * (QS2 + z * (QS3 + z * QS4))); - double r = x - (PI_L / 2 - x * (p / q)); - return negative ? PI / 2 + r : PI / 2 - r; - } - if (negative) // x<=-0.5. - { - double z = (1 + x) * 0.5; - double p = z * (PS0 + z * (PS1 + z * (PS2 + z * (PS3 + z - * (PS4 + z * PS5))))); - double q = 1 + z * (QS1 + z * (QS2 + z * (QS3 + z * QS4))); - double s = sqrt(z); - double w = p / q * s - PI_L / 2; - return PI - 2 * (s + w); - } - double z = (1 - x) * 0.5; // x>0.5. - double s = sqrt(z); - double df = (float) s; - double c = (z - df * df) / (s + df); - double p = z * (PS0 + z * (PS1 + z * (PS2 + z * (PS3 + z - * (PS4 + z * PS5))))); - double q = 1 + z * (QS1 + z * (QS2 + z * (QS3 + z * QS4))); - double w = p / q * s + c; - return 2 * (df + w); - } - - /** - * The trigonometric function <em>arcsin</em>. The range of angles returned - * is -pi/2 to pi/2 radians (-90 to 90 degrees). If the argument is NaN, the - * result is NaN; and the arctangent of 0 retains its sign. - * - * @param x the tan to turn back into an angle - * @return arcsin(x) - * @see #atan2(double, double) - */ - public static double atan(double x) - { - double lo; - double hi; - boolean negative = x < 0; - if (negative) - x = -x; - if (x >= TWO_66) - return negative ? -PI / 2 : PI / 2; - if (! (x >= 0.4375)) // |x|<7/16, or NaN. - { - if (! (x >= 1 / TWO_29)) // Small, or NaN. - return negative ? -x : x; - lo = hi = 0; - } - else if (x < 1.1875) - { - if (x < 0.6875) // 7/16<=|x|<11/16. - { - x = (2 * x - 1) / (2 + x); - hi = ATAN_0_5H; - lo = ATAN_0_5L; - } - else // 11/16<=|x|<19/16. - { - x = (x - 1) / (x + 1); - hi = PI / 4; - lo = PI_L / 4; - } - } - else if (x < 2.4375) // 19/16<=|x|<39/16. - { - x = (x - 1.5) / (1 + 1.5 * x); - hi = ATAN_1_5H; - lo = ATAN_1_5L; - } - else // 39/16<=|x|<2**66. - { - x = -1 / x; - hi = PI / 2; - lo = PI_L / 2; - } - - // Break sum from i=0 to 10 ATi*z**(i+1) into odd and even poly. - double z = x * x; - double w = z * z; - double s1 = z * (AT0 + w * (AT2 + w * (AT4 + w * (AT6 + w - * (AT8 + w * AT10))))); - double s2 = w * (AT1 + w * (AT3 + w * (AT5 + w * (AT7 + w * AT9)))); - if (hi == 0) - return negative ? x * (s1 + s2) - x : x - x * (s1 + s2); - z = hi - ((x * (s1 + s2) - lo) - x); - return negative ? -z : z; - } - - /** - * A special version of the trigonometric function <em>arctan</em>, for - * converting rectangular coordinates <em>(x, y)</em> to polar - * <em>(r, theta)</em>. This computes the arctangent of x/y in the range - * of -pi to pi radians (-180 to 180 degrees). Special cases:<ul> - * <li>If either argument is NaN, the result is NaN.</li> - * <li>If the first argument is positive zero and the second argument is - * positive, or the first argument is positive and finite and the second - * argument is positive infinity, then the result is positive zero.</li> - * <li>If the first argument is negative zero and the second argument is - * positive, or the first argument is negative and finite and the second - * argument is positive infinity, then the result is negative zero.</li> - * <li>If the first argument is positive zero and the second argument is - * negative, or the first argument is positive and finite and the second - * argument is negative infinity, then the result is the double value - * closest to pi.</li> - * <li>If the first argument is negative zero and the second argument is - * negative, or the first argument is negative and finite and the second - * argument is negative infinity, then the result is the double value - * closest to -pi.</li> - * <li>If the first argument is positive and the second argument is - * positive zero or negative zero, or the first argument is positive - * infinity and the second argument is finite, then the result is the - * double value closest to pi/2.</li> - * <li>If the first argument is negative and the second argument is - * positive zero or negative zero, or the first argument is negative - * infinity and the second argument is finite, then the result is the - * double value closest to -pi/2.</li> - * <li>If both arguments are positive infinity, then the result is the - * double value closest to pi/4.</li> - * <li>If the first argument is positive infinity and the second argument - * is negative infinity, then the result is the double value closest to - * 3*pi/4.</li> - * <li>If the first argument is negative infinity and the second argument - * is positive infinity, then the result is the double value closest to - * -pi/4.</li> - * <li>If both arguments are negative infinity, then the result is the - * double value closest to -3*pi/4.</li> - * - * </ul><p>This returns theta, the angle of the point. To get r, albeit - * slightly inaccurately, use sqrt(x*x+y*y). - * - * @param y the y position - * @param x the x position - * @return <em>theta</em> in the conversion of (x, y) to (r, theta) - * @see #atan(double) - */ - public static double atan2(double y, double x) - { - if (x != x || y != y) - return Double.NaN; - if (x == 1) - return atan(y); - if (x == Double.POSITIVE_INFINITY) - { - if (y == Double.POSITIVE_INFINITY) - return PI / 4; - if (y == Double.NEGATIVE_INFINITY) - return -PI / 4; - return 0 * y; - } - if (x == Double.NEGATIVE_INFINITY) - { - if (y == Double.POSITIVE_INFINITY) - return 3 * PI / 4; - if (y == Double.NEGATIVE_INFINITY) - return -3 * PI / 4; - return (1 / (0 * y) == Double.POSITIVE_INFINITY) ? PI : -PI; - } - if (y == 0) - { - if (1 / (0 * x) == Double.POSITIVE_INFINITY) - return y; - return (1 / y == Double.POSITIVE_INFINITY) ? PI : -PI; - } - if (y == Double.POSITIVE_INFINITY || y == Double.NEGATIVE_INFINITY - || x == 0) - return y < 0 ? -PI / 2 : PI / 2; - - double z = abs(y / x); // Safe to do y/x. - if (z > TWO_60) - z = PI / 2 + 0.5 * PI_L; - else if (x < 0 && z < 1 / TWO_60) - z = 0; - else - z = atan(z); - if (x > 0) - return y > 0 ? z : -z; - return y > 0 ? PI - (z - PI_L) : z - PI_L - PI; - } - - /** - * Take <em>e</em><sup>a</sup>. The opposite of <code>log()</code>. If the - * argument is NaN, the result is NaN; if the argument is positive infinity, - * the result is positive infinity; and if the argument is negative - * infinity, the result is positive zero. - * - * @param x the number to raise to the power - * @return the number raised to the power of <em>e</em> - * @see #log(double) - * @see #pow(double, double) - */ - public static double exp(double x) - { - if (x != x) - return x; - if (x > EXP_LIMIT_H) - return Double.POSITIVE_INFINITY; - if (x < EXP_LIMIT_L) - return 0; - - // Argument reduction. - double hi; - double lo; - int k; - double t = abs(x); - if (t > 0.5 * LN2) - { - if (t < 1.5 * LN2) - { - hi = t - LN2_H; - lo = LN2_L; - k = 1; - } - else - { - k = (int) (INV_LN2 * t + 0.5); - hi = t - k * LN2_H; - lo = k * LN2_L; - } - if (x < 0) - { - hi = -hi; - lo = -lo; - k = -k; - } - x = hi - lo; - } - else if (t < 1 / TWO_28) - return 1; - else - lo = hi = k = 0; - - // Now x is in primary range. - t = x * x; - double c = x - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5)))); - if (k == 0) - return 1 - (x * c / (c - 2) - x); - double y = 1 - (lo - x * c / (2 - c) - hi); - return scale(y, k); - } - - /** - * Take ln(a) (the natural log). The opposite of <code>exp()</code>. If the - * argument is NaN or negative, the result is NaN; if the argument is - * positive infinity, the result is positive infinity; and if the argument - * is either zero, the result is negative infinity. - * - * <p>Note that the way to get log<sub>b</sub>(a) is to do this: - * <code>ln(a) / ln(b)</code>. - * - * @param x the number to take the natural log of - * @return the natural log of <code>a</code> - * @see #exp(double) - */ - public static double log(double x) - { - if (x == 0) - return Double.NEGATIVE_INFINITY; - if (x < 0) - return Double.NaN; - if (! (x < Double.POSITIVE_INFINITY)) - return x; - - // Normalize x. - long bits = Double.doubleToLongBits(x); - int exp = (int) (bits >> 52); - if (exp == 0) // Subnormal x. - { - x *= TWO_54; - bits = Double.doubleToLongBits(x); - exp = (int) (bits >> 52) - 54; - } - exp -= 1023; // Unbias exponent. - bits = (bits & 0x000fffffffffffffL) | 0x3ff0000000000000L; - x = Double.longBitsToDouble(bits); - if (x >= SQRT_2) - { - x *= 0.5; - exp++; - } - x--; - if (abs(x) < 1 / TWO_20) - { - if (x == 0) - return exp * LN2_H + exp * LN2_L; - double r = x * x * (0.5 - 1 / 3.0 * x); - if (exp == 0) - return x - r; - return exp * LN2_H - ((r - exp * LN2_L) - x); - } - double s = x / (2 + x); - double z = s * s; - double w = z * z; - double t1 = w * (LG2 + w * (LG4 + w * LG6)); - double t2 = z * (LG1 + w * (LG3 + w * (LG5 + w * LG7))); - double r = t2 + t1; - if (bits >= 0x3ff6174a00000000L && bits < 0x3ff6b85200000000L) - { - double h = 0.5 * x * x; // Need more accuracy for x near sqrt(2). - if (exp == 0) - return x - (h - s * (h + r)); - return exp * LN2_H - ((h - (s * (h + r) + exp * LN2_L)) - x); - } - if (exp == 0) - return x - s * (x - r); - return exp * LN2_H - ((s * (x - r) - exp * LN2_L) - x); - } - - /** - * Take a square root. If the argument is NaN or negative, the result is - * NaN; if the argument is positive infinity, the result is positive - * infinity; and if the result is either zero, the result is the same. - * - * <p>For other roots, use pow(x, 1/rootNumber). - * - * @param x the numeric argument - * @return the square root of the argument - * @see #pow(double, double) - */ - public static double sqrt(double x) - { - if (x < 0) - return Double.NaN; - if (x == 0 || ! (x < Double.POSITIVE_INFINITY)) - return x; - - // Normalize x. - long bits = Double.doubleToLongBits(x); - int exp = (int) (bits >> 52); - if (exp == 0) // Subnormal x. - { - x *= TWO_54; - bits = Double.doubleToLongBits(x); - exp = (int) (bits >> 52) - 54; - } - exp -= 1023; // Unbias exponent. - bits = (bits & 0x000fffffffffffffL) | 0x0010000000000000L; - if ((exp & 1) == 1) // Odd exp, double x to make it even. - bits <<= 1; - exp >>= 1; - - // Generate sqrt(x) bit by bit. - bits <<= 1; - long q = 0; - long s = 0; - long r = 0x0020000000000000L; // Move r right to left. - while (r != 0) - { - long t = s + r; - if (t <= bits) - { - s = t + r; - bits -= t; - q += r; - } - bits <<= 1; - r >>= 1; - } - - // Use floating add to round correctly. - if (bits != 0) - q += q & 1; - return Double.longBitsToDouble((q >> 1) + ((exp + 1022L) << 52)); - } - - /** - * Raise a number to a power. Special cases:<ul> - * <li>If the second argument is positive or negative zero, then the result - * is 1.0.</li> - * <li>If the second argument is 1.0, then the result is the same as the - * first argument.</li> - * <li>If the second argument is NaN, then the result is NaN.</li> - * <li>If the first argument is NaN and the second argument is nonzero, - * then the result is NaN.</li> - * <li>If the absolute value of the first argument is greater than 1 and - * the second argument is positive infinity, or the absolute value of the - * first argument is less than 1 and the second argument is negative - * infinity, then the result is positive infinity.</li> - * <li>If the absolute value of the first argument is greater than 1 and - * the second argument is negative infinity, or the absolute value of the - * first argument is less than 1 and the second argument is positive - * infinity, then the result is positive zero.</li> - * <li>If the absolute value of the first argument equals 1 and the second - * argument is infinite, then the result is NaN.</li> - * <li>If the first argument is positive zero and the second argument is - * greater than zero, or the first argument is positive infinity and the - * second argument is less than zero, then the result is positive zero.</li> - * <li>If the first argument is positive zero and the second argument is - * less than zero, or the first argument is positive infinity and the - * second argument is greater than zero, then the result is positive - * infinity.</li> - * <li>If the first argument is negative zero and the second argument is - * greater than zero but not a finite odd integer, or the first argument is - * negative infinity and the second argument is less than zero but not a - * finite odd integer, then the result is positive zero.</li> - * <li>If the first argument is negative zero and the second argument is a - * positive finite odd integer, or the first argument is negative infinity - * and the second argument is a negative finite odd integer, then the result - * is negative zero.</li> - * <li>If the first argument is negative zero and the second argument is - * less than zero but not a finite odd integer, or the first argument is - * negative infinity and the second argument is greater than zero but not a - * finite odd integer, then the result is positive infinity.</li> - * <li>If the first argument is negative zero and the second argument is a - * negative finite odd integer, or the first argument is negative infinity - * and the second argument is a positive finite odd integer, then the result - * is negative infinity.</li> - * <li>If the first argument is less than zero and the second argument is a - * finite even integer, then the result is equal to the result of raising - * the absolute value of the first argument to the power of the second - * argument.</li> - * <li>If the first argument is less than zero and the second argument is a - * finite odd integer, then the result is equal to the negative of the - * result of raising the absolute value of the first argument to the power - * of the second argument.</li> - * <li>If the first argument is finite and less than zero and the second - * argument is finite and not an integer, then the result is NaN.</li> - * <li>If both arguments are integers, then the result is exactly equal to - * the mathematical result of raising the first argument to the power of - * the second argument if that result can in fact be represented exactly as - * a double value.</li> - * - * </ul><p>(In the foregoing descriptions, a floating-point value is - * considered to be an integer if and only if it is a fixed point of the - * method {@link #ceil(double)} or, equivalently, a fixed point of the - * method {@link #floor(double)}. A value is a fixed point of a one-argument - * method if and only if the result of applying the method to the value is - * equal to the value.) - * - * @param x the number to raise - * @param y the power to raise it to - * @return x<sup>y</sup> - */ - public static double pow(double x, double y) - { - // Special cases first. - if (y == 0) - return 1; - if (y == 1) - return x; - if (y == -1) - return 1 / x; - if (x != x || y != y) - return Double.NaN; - - // When x < 0, yisint tells if y is not an integer (0), even(1), - // or odd (2). - int yisint = 0; - if (x < 0 && floor(y) == y) - yisint = (y % 2 == 0) ? 2 : 1; - double ax = abs(x); - double ay = abs(y); - - // More special cases, of y. - if (ay == Double.POSITIVE_INFINITY) - { - if (ax == 1) - return Double.NaN; - if (ax > 1) - return y > 0 ? y : 0; - return y < 0 ? -y : 0; - } - if (y == 2) - return x * x; - if (y == 0.5) - return sqrt(x); - - // More special cases, of x. - if (x == 0 || ax == Double.POSITIVE_INFINITY || ax == 1) - { - if (y < 0) - ax = 1 / ax; - if (x < 0) - { - if (x == -1 && yisint == 0) - ax = Double.NaN; - else if (yisint == 1) - ax = -ax; - } - return ax; - } - if (x < 0 && yisint == 0) - return Double.NaN; - - // Now we can start! - double t; - double t1; - double t2; - double u; - double v; - double w; - if (ay > TWO_31) - { - if (ay > TWO_64) // Automatic over/underflow. - return ((ax < 1) ? y < 0 : y > 0) ? Double.POSITIVE_INFINITY : 0; - // Over/underflow if x is not close to one. - if (ax < 0.9999995231628418) - return y < 0 ? Double.POSITIVE_INFINITY : 0; - if (ax >= 1.0000009536743164) - return y > 0 ? Double.POSITIVE_INFINITY : 0; - // Now |1-x| is <= 2**-20, sufficient to compute - // log(x) by x-x^2/2+x^3/3-x^4/4. - t = x - 1; - w = t * t * (0.5 - t * (1 / 3.0 - t * 0.25)); - u = INV_LN2_H * t; - v = t * INV_LN2_L - w * INV_LN2; - t1 = (float) (u + v); - t2 = v - (t1 - u); - } - else - { - long bits = Double.doubleToLongBits(ax); - int exp = (int) (bits >> 52); - if (exp == 0) // Subnormal x. - { - ax *= TWO_54; - bits = Double.doubleToLongBits(ax); - exp = (int) (bits >> 52) - 54; - } - exp -= 1023; // Unbias exponent. - ax = Double.longBitsToDouble((bits & 0x000fffffffffffffL) - | 0x3ff0000000000000L); - boolean k; - if (ax < SQRT_1_5) // |x|<sqrt(3/2). - k = false; - else if (ax < SQRT_3) // |x|<sqrt(3). - k = true; - else - { - k = false; - ax *= 0.5; - exp++; - } - - // Compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5). - u = ax - (k ? 1.5 : 1); - v = 1 / (ax + (k ? 1.5 : 1)); - double s = u * v; - double s_h = (float) s; - double t_h = (float) (ax + (k ? 1.5 : 1)); - double t_l = ax - (t_h - (k ? 1.5 : 1)); - double s_l = v * ((u - s_h * t_h) - s_h * t_l); - // Compute log(ax). - double s2 = s * s; - double r = s_l * (s_h + s) + s2 * s2 - * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6))))); - s2 = s_h * s_h; - t_h = (float) (3.0 + s2 + r); - t_l = r - (t_h - 3.0 - s2); - // u+v = s*(1+...). - u = s_h * t_h; - v = s_l * t_h + t_l * s; - // 2/(3log2)*(s+...). - double p_h = (float) (u + v); - double p_l = v - (p_h - u); - double z_h = CP_H * p_h; - double z_l = CP_L * p_h + p_l * CP + (k ? DP_L : 0); - // log2(ax) = (s+..)*2/(3*log2) = exp + dp_h + z_h + z_l. - t = exp; - t1 = (float) (z_h + z_l + (k ? DP_H : 0) + t); - t2 = z_l - (t1 - t - (k ? DP_H : 0) - z_h); - } - - // Split up y into y1+y2 and compute (y1+y2)*(t1+t2). - boolean negative = x < 0 && yisint == 1; - double y1 = (float) y; - double p_l = (y - y1) * t1 + y * t2; - double p_h = y1 * t1; - double z = p_l + p_h; - if (z >= 1024) // Detect overflow. - { - if (z > 1024 || p_l + OVT > z - p_h) - return negative ? Double.NEGATIVE_INFINITY - : Double.POSITIVE_INFINITY; - } - else if (z <= -1075) // Detect underflow. - { - if (z < -1075 || p_l <= z - p_h) - return negative ? -0.0 : 0; - } - - // Compute 2**(p_h+p_l). - int n = round((float) z); - p_h -= n; - t = (float) (p_l + p_h); - u = t * LN2_H; - v = (p_l - (t - p_h)) * LN2 + t * LN2_L; - z = u + v; - w = v - (z - u); - t = z * z; - t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5)))); - double r = (z * t1) / (t1 - 2) - (w + z * w); - z = scale(1 - (r - z), n); - return negative ? -z : z; - } - - /** - * Get the IEEE 754 floating point remainder on two numbers. This is the - * value of <code>x - y * <em>n</em></code>, where <em>n</em> is the closest - * double to <code>x / y</code> (ties go to the even n); for a zero - * remainder, the sign is that of <code>x</code>. If either argument is NaN, - * the first argument is infinite, or the second argument is zero, the result - * is NaN; if x is finite but y is infinite, the result is x. - * - * @param x the dividend (the top half) - * @param y the divisor (the bottom half) - * @return the IEEE 754-defined floating point remainder of x/y - * @see #rint(double) - */ - public static double IEEEremainder(double x, double y) - { - // Purge off exception values. - if (x == Double.NEGATIVE_INFINITY || ! (x < Double.POSITIVE_INFINITY) - || y == 0 || y != y) - return Double.NaN; - - boolean negative = x < 0; - x = abs(x); - y = abs(y); - if (x == y || x == 0) - return 0 * x; // Get correct sign. - - // Achieve x < 2y, then take first shot at remainder. - if (y < TWO_1023) - x %= y + y; - - // Now adjust x to get correct precision. - if (y < 4 / TWO_1023) - { - if (x + x > y) - { - x -= y; - if (x + x >= y) - x -= y; - } - } - else - { - y *= 0.5; - if (x > y) - { - x -= y; - if (x >= y) - x -= y; - } - } - return negative ? -x : x; - } - - /** - * Take the nearest integer that is that is greater than or equal to the - * argument. If the argument is NaN, infinite, or zero, the result is the - * same; if the argument is between -1 and 0, the result is negative zero. - * Note that <code>Math.ceil(x) == -Math.floor(-x)</code>. - * - * @param a the value to act upon - * @return the nearest integer >= <code>a</code> - */ - public static double ceil(double a) - { - return -floor(-a); - } - - /** - * Take the nearest integer that is that is less than or equal to the - * argument. If the argument is NaN, infinite, or zero, the result is the - * same. Note that <code>Math.ceil(x) == -Math.floor(-x)</code>. - * - * @param a the value to act upon - * @return the nearest integer <= <code>a</code> - */ - public static double floor(double a) - { - double x = abs(a); - if (! (x < TWO_52) || (long) a == a) - return a; // No fraction bits; includes NaN and infinity. - if (x < 1) - return a >= 0 ? 0 * a : -1; // Worry about signed zero. - return a < 0 ? (long) a - 1.0 : (long) a; // Cast to long truncates. - } - - /** - * Take the nearest integer to the argument. If it is exactly between - * two integers, the even integer is taken. If the argument is NaN, - * infinite, or zero, the result is the same. - * - * @param a the value to act upon - * @return the nearest integer to <code>a</code> - */ - public static double rint(double a) - { - double x = abs(a); - if (! (x < TWO_52)) - return a; // No fraction bits; includes NaN and infinity. - if (x <= 0.5) - return 0 * a; // Worry about signed zero. - if (x % 2 <= 0.5) - return (long) a; // Catch round down to even. - return (long) (a + (a < 0 ? -0.5 : 0.5)); // Cast to long truncates. - } - - /** - * Take the nearest integer to the argument. This is equivalent to - * <code>(int) Math.floor(f + 0.5f)</code>. If the argument is NaN, the - * result is 0; otherwise if the argument is outside the range of int, the - * result will be Integer.MIN_VALUE or Integer.MAX_VALUE, as appropriate. - * - * @param f the argument to round - * @return the nearest integer to the argument - * @see Integer#MIN_VALUE - * @see Integer#MAX_VALUE - */ - public static int round(float f) - { - return (int) floor(f + 0.5f); - } - - /** - * Take the nearest long to the argument. This is equivalent to - * <code>(long) Math.floor(d + 0.5)</code>. If the argument is NaN, the - * result is 0; otherwise if the argument is outside the range of long, the - * result will be Long.MIN_VALUE or Long.MAX_VALUE, as appropriate. - * - * @param d the argument to round - * @return the nearest long to the argument - * @see Long#MIN_VALUE - * @see Long#MAX_VALUE - */ - public static long round(double d) - { - return (long) floor(d + 0.5); - } - - /** - * Get a random number. This behaves like Random.nextDouble(), seeded by - * System.currentTimeMillis() when first called. In other words, the number - * is from a pseudorandom sequence, and lies in the range [+0.0, 1.0). - * This random sequence is only used by this method, and is threadsafe, - * although you may want your own random number generator if it is shared - * among threads. - * - * @return a random number - * @see Random#nextDouble() - * @see System#currentTimeMillis() - */ - public static synchronized double random() - { - if (rand == null) - rand = new Random(); - return rand.nextDouble(); - } - - /** - * Convert from degrees to radians. The formula for this is - * radians = degrees * (pi/180); however it is not always exact given the - * limitations of floating point numbers. - * - * @param degrees an angle in degrees - * @return the angle in radians - */ - public static double toRadians(double degrees) - { - return (degrees * PI) / 180; - } - - /** - * Convert from radians to degrees. The formula for this is - * degrees = radians * (180/pi); however it is not always exact given the - * limitations of floating point numbers. - * - * @param rads an angle in radians - * @return the angle in degrees - */ - public static double toDegrees(double rads) - { - return (rads * 180) / PI; - } - - /** - * Constants for scaling and comparing doubles by powers of 2. The compiler - * must automatically inline constructs like (1/TWO_54), so we don't list - * negative powers of two here. - */ - private static final double - TWO_16 = 0x10000, // Long bits 0x40f0000000000000L. - TWO_20 = 0x100000, // Long bits 0x4130000000000000L. - TWO_24 = 0x1000000, // Long bits 0x4170000000000000L. - TWO_27 = 0x8000000, // Long bits 0x41a0000000000000L. - TWO_28 = 0x10000000, // Long bits 0x41b0000000000000L. - TWO_29 = 0x20000000, // Long bits 0x41c0000000000000L. - TWO_31 = 0x80000000L, // Long bits 0x41e0000000000000L. - TWO_49 = 0x2000000000000L, // Long bits 0x4300000000000000L. - TWO_52 = 0x10000000000000L, // Long bits 0x4330000000000000L. - TWO_54 = 0x40000000000000L, // Long bits 0x4350000000000000L. - TWO_57 = 0x200000000000000L, // Long bits 0x4380000000000000L. - TWO_60 = 0x1000000000000000L, // Long bits 0x43b0000000000000L. - TWO_64 = 1.8446744073709552e19, // Long bits 0x43f0000000000000L. - TWO_66 = 7.378697629483821e19, // Long bits 0x4410000000000000L. - TWO_1023 = 8.98846567431158e307; // Long bits 0x7fe0000000000000L. - - /** - * Super precision for 2/pi in 24-bit chunks, for use in - * {@link #remPiOver2()}. - */ - private static final int TWO_OVER_PI[] = { - 0xa2f983, 0x6e4e44, 0x1529fc, 0x2757d1, 0xf534dd, 0xc0db62, - 0x95993c, 0x439041, 0xfe5163, 0xabdebb, 0xc561b7, 0x246e3a, - 0x424dd2, 0xe00649, 0x2eea09, 0xd1921c, 0xfe1deb, 0x1cb129, - 0xa73ee8, 0x8235f5, 0x2ebb44, 0x84e99c, 0x7026b4, 0x5f7e41, - 0x3991d6, 0x398353, 0x39f49c, 0x845f8b, 0xbdf928, 0x3b1ff8, - 0x97ffde, 0x05980f, 0xef2f11, 0x8b5a0a, 0x6d1f6d, 0x367ecf, - 0x27cb09, 0xb74f46, 0x3f669e, 0x5fea2d, 0x7527ba, 0xc7ebe5, - 0xf17b3d, 0x0739f7, 0x8a5292, 0xea6bfb, 0x5fb11f, 0x8d5d08, - 0x560330, 0x46fc7b, 0x6babf0, 0xcfbc20, 0x9af436, 0x1da9e3, - 0x91615e, 0xe61b08, 0x659985, 0x5f14a0, 0x68408d, 0xffd880, - 0x4d7327, 0x310606, 0x1556ca, 0x73a8c9, 0x60e27b, 0xc08c6b, - }; - - /** - * Super precision for pi/2 in 24-bit chunks, for use in - * {@link #remPiOver2()}. - */ - private static final double PI_OVER_TWO[] = { - 1.570796251296997, // Long bits 0x3ff921fb40000000L. - 7.549789415861596e-8, // Long bits 0x3e74442d00000000L. - 5.390302529957765e-15, // Long bits 0x3cf8469880000000L. - 3.282003415807913e-22, // Long bits 0x3b78cc5160000000L. - 1.270655753080676e-29, // Long bits 0x39f01b8380000000L. - 1.2293330898111133e-36, // Long bits 0x387a252040000000L. - 2.7337005381646456e-44, // Long bits 0x36e3822280000000L. - 2.1674168387780482e-51, // Long bits 0x3569f31d00000000L. - }; - - /** - * More constants related to pi, used in {@link #remPiOver2()} and - * elsewhere. - */ - private static final double - PI_L = 1.2246467991473532e-16, // Long bits 0x3ca1a62633145c07L. - PIO2_1 = 1.5707963267341256, // Long bits 0x3ff921fb54400000L. - PIO2_1L = 6.077100506506192e-11, // Long bits 0x3dd0b4611a626331L. - PIO2_2 = 6.077100506303966e-11, // Long bits 0x3dd0b4611a600000L. - PIO2_2L = 2.0222662487959506e-21, // Long bits 0x3ba3198a2e037073L. - PIO2_3 = 2.0222662487111665e-21, // Long bits 0x3ba3198a2e000000L. - PIO2_3L = 8.4784276603689e-32; // Long bits 0x397b839a252049c1L. - - /** - * Natural log and square root constants, for calculation of - * {@link #exp(double)}, {@link #log(double)} and - * {@link #power(double, double)}. CP is 2/(3*ln(2)). - */ - private static final double - SQRT_1_5 = 1.224744871391589, // Long bits 0x3ff3988e1409212eL. - SQRT_2 = 1.4142135623730951, // Long bits 0x3ff6a09e667f3bcdL. - SQRT_3 = 1.7320508075688772, // Long bits 0x3ffbb67ae8584caaL. - EXP_LIMIT_H = 709.782712893384, // Long bits 0x40862e42fefa39efL. - EXP_LIMIT_L = -745.1332191019411, // Long bits 0xc0874910d52d3051L. - CP = 0.9617966939259756, // Long bits 0x3feec709dc3a03fdL. - CP_H = 0.9617967009544373, // Long bits 0x3feec709e0000000L. - CP_L = -7.028461650952758e-9, // Long bits 0xbe3e2fe0145b01f5L. - LN2 = 0.6931471805599453, // Long bits 0x3fe62e42fefa39efL. - LN2_H = 0.6931471803691238, // Long bits 0x3fe62e42fee00000L. - LN2_L = 1.9082149292705877e-10, // Long bits 0x3dea39ef35793c76L. - INV_LN2 = 1.4426950408889634, // Long bits 0x3ff71547652b82feL. - INV_LN2_H = 1.4426950216293335, // Long bits 0x3ff7154760000000L. - INV_LN2_L = 1.9259629911266175e-8; // Long bits 0x3e54ae0bf85ddf44L. - - /** - * Constants for computing {@link #log(double)}. - */ - private static final double - LG1 = 0.6666666666666735, // Long bits 0x3fe5555555555593L. - LG2 = 0.3999999999940942, // Long bits 0x3fd999999997fa04L. - LG3 = 0.2857142874366239, // Long bits 0x3fd2492494229359L. - LG4 = 0.22222198432149784, // Long bits 0x3fcc71c51d8e78afL. - LG5 = 0.1818357216161805, // Long bits 0x3fc7466496cb03deL. - LG6 = 0.15313837699209373, // Long bits 0x3fc39a09d078c69fL. - LG7 = 0.14798198605116586; // Long bits 0x3fc2f112df3e5244L. - - /** - * Constants for computing {@link #pow(double, double)}. L and P are - * coefficients for series; OVT is -(1024-log2(ovfl+.5ulp)); and DP is ???. - * The P coefficients also calculate {@link #exp(double)}. - */ - private static final double - L1 = 0.5999999999999946, // Long bits 0x3fe3333333333303L. - L2 = 0.4285714285785502, // Long bits 0x3fdb6db6db6fabffL. - L3 = 0.33333332981837743, // Long bits 0x3fd55555518f264dL. - L4 = 0.272728123808534, // Long bits 0x3fd17460a91d4101L. - L5 = 0.23066074577556175, // Long bits 0x3fcd864a93c9db65L. - L6 = 0.20697501780033842, // Long bits 0x3fca7e284a454eefL. - P1 = 0.16666666666666602, // Long bits 0x3fc555555555553eL. - P2 = -2.7777777777015593e-3, // Long bits 0xbf66c16c16bebd93L. - P3 = 6.613756321437934e-5, // Long bits 0x3f11566aaf25de2cL. - P4 = -1.6533902205465252e-6, // Long bits 0xbebbbd41c5d26bf1L. - P5 = 4.1381367970572385e-8, // Long bits 0x3e66376972bea4d0L. - DP_H = 0.5849624872207642, // Long bits 0x3fe2b80340000000L. - DP_L = 1.350039202129749e-8, // Long bits 0x3e4cfdeb43cfd006L. - OVT = 8.008566259537294e-17; // Long bits 0x3c971547652b82feL. - - /** - * Coefficients for computing {@link #sin(double)}. - */ - private static final double - S1 = -0.16666666666666632, // Long bits 0xbfc5555555555549L. - S2 = 8.33333333332249e-3, // Long bits 0x3f8111111110f8a6L. - S3 = -1.984126982985795e-4, // Long bits 0xbf2a01a019c161d5L. - S4 = 2.7557313707070068e-6, // Long bits 0x3ec71de357b1fe7dL. - S5 = -2.5050760253406863e-8, // Long bits 0xbe5ae5e68a2b9cebL. - S6 = 1.58969099521155e-10; // Long bits 0x3de5d93a5acfd57cL. - - /** - * Coefficients for computing {@link #cos(double)}. - */ - private static final double - C1 = 0.0416666666666666, // Long bits 0x3fa555555555554cL. - C2 = -1.388888888887411e-3, // Long bits 0xbf56c16c16c15177L. - C3 = 2.480158728947673e-5, // Long bits 0x3efa01a019cb1590L. - C4 = -2.7557314351390663e-7, // Long bits 0xbe927e4f809c52adL. - C5 = 2.087572321298175e-9, // Long bits 0x3e21ee9ebdb4b1c4L. - C6 = -1.1359647557788195e-11; // Long bits 0xbda8fae9be8838d4L. - - /** - * Coefficients for computing {@link #tan(double)}. - */ - private static final double - T0 = 0.3333333333333341, // Long bits 0x3fd5555555555563L. - T1 = 0.13333333333320124, // Long bits 0x3fc111111110fe7aL. - T2 = 0.05396825397622605, // Long bits 0x3faba1ba1bb341feL. - T3 = 0.021869488294859542, // Long bits 0x3f9664f48406d637L. - T4 = 8.8632398235993e-3, // Long bits 0x3f8226e3e96e8493L. - T5 = 3.5920791075913124e-3, // Long bits 0x3f6d6d22c9560328L. - T6 = 1.4562094543252903e-3, // Long bits 0x3f57dbc8fee08315L. - T7 = 5.880412408202641e-4, // Long bits 0x3f4344d8f2f26501L. - T8 = 2.464631348184699e-4, // Long bits 0x3f3026f71a8d1068L. - T9 = 7.817944429395571e-5, // Long bits 0x3f147e88a03792a6L. - T10 = 7.140724913826082e-5, // Long bits 0x3f12b80f32f0a7e9L. - T11 = -1.8558637485527546e-5, // Long bits 0xbef375cbdb605373L. - T12 = 2.590730518636337e-5; // Long bits 0x3efb2a7074bf7ad4L. - - /** - * Coefficients for computing {@link #asin(double)} and - * {@link #acos(double)}. - */ - private static final double - PS0 = 0.16666666666666666, // Long bits 0x3fc5555555555555L. - PS1 = -0.3255658186224009, // Long bits 0xbfd4d61203eb6f7dL. - PS2 = 0.20121253213486293, // Long bits 0x3fc9c1550e884455L. - PS3 = -0.04005553450067941, // Long bits 0xbfa48228b5688f3bL. - PS4 = 7.915349942898145e-4, // Long bits 0x3f49efe07501b288L. - PS5 = 3.479331075960212e-5, // Long bits 0x3f023de10dfdf709L. - QS1 = -2.403394911734414, // Long bits 0xc0033a271c8a2d4bL. - QS2 = 2.0209457602335057, // Long bits 0x40002ae59c598ac8L. - QS3 = -0.6882839716054533, // Long bits 0xbfe6066c1b8d0159L. - QS4 = 0.07703815055590194; // Long bits 0x3fb3b8c5b12e9282L. - - /** - * Coefficients for computing {@link #atan(double)}. - */ - private static final double - ATAN_0_5H = 0.4636476090008061, // Long bits 0x3fddac670561bb4fL. - ATAN_0_5L = 2.2698777452961687e-17, // Long bits 0x3c7a2b7f222f65e2L. - ATAN_1_5H = 0.982793723247329, // Long bits 0x3fef730bd281f69bL. - ATAN_1_5L = 1.3903311031230998e-17, // Long bits 0x3c7007887af0cbbdL. - AT0 = 0.3333333333333293, // Long bits 0x3fd555555555550dL. - AT1 = -0.19999999999876483, // Long bits 0xbfc999999998ebc4L. - AT2 = 0.14285714272503466, // Long bits 0x3fc24924920083ffL. - AT3 = -0.11111110405462356, // Long bits 0xbfbc71c6fe231671L. - AT4 = 0.09090887133436507, // Long bits 0x3fb745cdc54c206eL. - AT5 = -0.0769187620504483, // Long bits 0xbfb3b0f2af749a6dL. - AT6 = 0.06661073137387531, // Long bits 0x3fb10d66a0d03d51L. - AT7 = -0.058335701337905735, // Long bits 0xbfadde2d52defd9aL. - AT8 = 0.049768779946159324, // Long bits 0x3fa97b4b24760debL. - AT9 = -0.036531572744216916, // Long bits 0xbfa2b4442c6a6c2fL. - AT10 = 0.016285820115365782; // Long bits 0x3f90ad3ae322da11L. - - /** - * Helper function for reducing an angle to a multiple of pi/2 within - * [-pi/4, pi/4]. - * - * @param x the angle; not infinity or NaN, and outside pi/4 - * @param y an array of 2 doubles modified to hold the remander x % pi/2 - * @return the quadrant of the result, mod 4: 0: [-pi/4, pi/4], - * 1: [pi/4, 3*pi/4], 2: [3*pi/4, 5*pi/4], 3: [-3*pi/4, -pi/4] - */ - private static int remPiOver2(double x, double[] y) - { - boolean negative = x < 0; - x = abs(x); - double z; - int n; - if (Configuration.DEBUG && (x <= PI / 4 || x != x - || x == Double.POSITIVE_INFINITY)) - throw new InternalError("Assertion failure"); - if (x < 3 * PI / 4) // If |x| is small. - { - z = x - PIO2_1; - if ((float) x != (float) (PI / 2)) // 33+53 bit pi is good enough. - { - y[0] = z - PIO2_1L; - y[1] = z - y[0] - PIO2_1L; - } - else // Near pi/2, use 33+33+53 bit pi. - { - z -= PIO2_2; - y[0] = z - PIO2_2L; - y[1] = z - y[0] - PIO2_2L; - } - n = 1; - } - else if (x <= TWO_20 * PI / 2) // Medium size. - { - n = (int) (2 / PI * x + 0.5); - z = x - n * PIO2_1; - double w = n * PIO2_1L; // First round good to 85 bits. - y[0] = z - w; - if (n >= 32 || (float) x == (float) (w)) - { - if (x / y[0] >= TWO_16) // Second iteration, good to 118 bits. - { - double t = z; - w = n * PIO2_2; - z = t - w; - w = n * PIO2_2L - (t - z - w); - y[0] = z - w; - if (x / y[0] >= TWO_49) // Third iteration, 151 bits accuracy. - { - t = z; - w = n * PIO2_3; - z = t - w; - w = n * PIO2_3L - (t - z - w); - y[0] = z - w; - } - } - } - y[1] = z - y[0] - w; - } - else - { - // All other (large) arguments. - int e0 = (int) (Double.doubleToLongBits(x) >> 52) - 1046; - z = scale(x, -e0); // e0 = ilogb(z) - 23. - double[] tx = new double[3]; - for (int i = 0; i < 2; i++) - { - tx[i] = (int) z; - z = (z - tx[i]) * TWO_24; - } - tx[2] = z; - int nx = 2; - while (tx[nx] == 0) - nx--; - n = remPiOver2(tx, y, e0, nx); - } - if (negative) - { - y[0] = -y[0]; - y[1] = -y[1]; - return -n; - } - return n; - } - - /** - * Helper function for reducing an angle to a multiple of pi/2 within - * [-pi/4, pi/4]. - * - * @param x the positive angle, broken into 24-bit chunks - * @param y an array of 2 doubles modified to hold the remander x % pi/2 - * @param e0 the exponent of x[0] - * @param nx the last index used in x - * @return the quadrant of the result, mod 4: 0: [-pi/4, pi/4], - * 1: [pi/4, 3*pi/4], 2: [3*pi/4, 5*pi/4], 3: [-3*pi/4, -pi/4] - */ - private static int remPiOver2(double[] x, double[] y, int e0, int nx) - { - int i; - int ih; - int n; - double fw; - double z; - int[] iq = new int[20]; - double[] f = new double[20]; - double[] q = new double[20]; - boolean recompute = false; - - // Initialize jk, jz, jv, q0; note that 3>q0. - int jk = 4; - int jz = jk; - int jv = max((e0 - 3) / 24, 0); - int q0 = e0 - 24 * (jv + 1); - - // Set up f[0] to f[nx+jk] where f[nx+jk] = TWO_OVER_PI[jv+jk]. - int j = jv - nx; - int m = nx + jk; - for (i = 0; i <= m; i++, j++) - f[i] = (j < 0) ? 0 : TWO_OVER_PI[j]; - - // Compute q[0],q[1],...q[jk]. - for (i = 0; i <= jk; i++) - { - for (j = 0, fw = 0; j <= nx; j++) - fw += x[j] * f[nx + i - j]; - q[i] = fw; - } - - do - { - // Distill q[] into iq[] reversingly. - for (i = 0, j = jz, z = q[jz]; j > 0; i++, j--) - { - fw = (int) (1 / TWO_24 * z); - iq[i] = (int) (z - TWO_24 * fw); - z = q[j - 1] + fw; - } - - // Compute n. - z = scale(z, q0); - z -= 8 * floor(z * 0.125); // Trim off integer >= 8. - n = (int) z; - z -= n; - ih = 0; - if (q0 > 0) // Need iq[jz-1] to determine n. - { - i = iq[jz - 1] >> (24 - q0); - n += i; - iq[jz - 1] -= i << (24 - q0); - ih = iq[jz - 1] >> (23 - q0); - } - else if (q0 == 0) - ih = iq[jz - 1] >> 23; - else if (z >= 0.5) - ih = 2; - - if (ih > 0) // If q > 0.5. - { - n += 1; - int carry = 0; - for (i = 0; i < jz; i++) // Compute 1-q. - { - j = iq[i]; - if (carry == 0) - { - if (j != 0) - { - carry = 1; - iq[i] = 0x1000000 - j; - } - } - else - iq[i] = 0xffffff - j; - } - switch (q0) - { - case 1: // Rare case: chance is 1 in 12 for non-default. - iq[jz - 1] &= 0x7fffff; - break; - case 2: - iq[jz - 1] &= 0x3fffff; - } - if (ih == 2) - { - z = 1 - z; - if (carry != 0) - z -= scale(1, q0); - } - } - - // Check if recomputation is needed. - if (z == 0) - { - j = 0; - for (i = jz - 1; i >= jk; i--) - j |= iq[i]; - if (j == 0) // Need recomputation. - { - int k; - for (k = 1; iq[jk - k] == 0; k++); // k = no. of terms needed. - - for (i = jz + 1; i <= jz + k; i++) // Add q[jz+1] to q[jz+k]. - { - f[nx + i] = TWO_OVER_PI[jv + i]; - for (j = 0, fw = 0; j <= nx; j++) - fw += x[j] * f[nx + i - j]; - q[i] = fw; - } - jz += k; - recompute = true; - } - } - } - while (recompute); - - // Chop off zero terms. - if (z == 0) - { - jz--; - q0 -= 24; - while (iq[jz] == 0) - { - jz--; - q0 -= 24; - } - } - else // Break z into 24-bit if necessary. - { - z = scale(z, -q0); - if (z >= TWO_24) - { - fw = (int) (1 / TWO_24 * z); - iq[jz] = (int) (z - TWO_24 * fw); - jz++; - q0 += 24; - iq[jz] = (int) fw; - } - else - iq[jz] = (int) z; - } - - // Convert integer "bit" chunk to floating-point value. - fw = scale(1, q0); - for (i = jz; i >= 0; i--) - { - q[i] = fw * iq[i]; - fw *= 1 / TWO_24; - } - - // Compute PI_OVER_TWO[0,...,jk]*q[jz,...,0]. - double[] fq = new double[20]; - for (i = jz; i >= 0; i--) - { - fw = 0; - for (int k = 0; k <= jk && k <= jz - i; k++) - fw += PI_OVER_TWO[k] * q[i + k]; - fq[jz - i] = fw; - } - - // Compress fq[] into y[]. - fw = 0; - for (i = jz; i >= 0; i--) - fw += fq[i]; - y[0] = (ih == 0) ? fw : -fw; - fw = fq[0] - fw; - for (i = 1; i <= jz; i++) - fw += fq[i]; - y[1] = (ih == 0) ? fw : -fw; - return n; - } - - /** - * Helper method for scaling a double by a power of 2. - * - * @param x the double - * @param n the scale; |n| < 2048 - * @return x * 2**n - */ - private static double scale(double x, int n) - { - if (Configuration.DEBUG && abs(n) >= 2048) - throw new InternalError("Assertion failure"); - if (x == 0 || x == Double.NEGATIVE_INFINITY - || ! (x < Double.POSITIVE_INFINITY) || n == 0) - return x; - long bits = Double.doubleToLongBits(x); - int exp = (int) (bits >> 52) & 0x7ff; - if (exp == 0) // Subnormal x. - { - x *= TWO_54; - exp = ((int) (Double.doubleToLongBits(x) >> 52) & 0x7ff) - 54; - } - exp += n; - if (exp > 0x7fe) // Overflow. - return Double.POSITIVE_INFINITY * x; - if (exp > 0) // Normal. - return Double.longBitsToDouble((bits & 0x800fffffffffffffL) - | ((long) exp << 52)); - if (exp <= -54) - return 0 * x; // Underflow. - exp += 54; // Subnormal result. - x = Double.longBitsToDouble((bits & 0x800fffffffffffffL) - | ((long) exp << 52)); - return x * (1 / TWO_54); - } - - /** - * Helper trig function; computes sin in range [-pi/4, pi/4]. - * - * @param x angle within about pi/4 - * @param y tail of x, created by remPiOver2 - * @return sin(x+y) - */ - private static double sin(double x, double y) - { - if (Configuration.DEBUG && abs(x + y) > 0.7854) - throw new InternalError("Assertion failure"); - if (abs(x) < 1 / TWO_27) - return x; // If |x| ~< 2**-27, already know answer. - - double z = x * x; - double v = z * x; - double r = S2 + z * (S3 + z * (S4 + z * (S5 + z * S6))); - if (y == 0) - return x + v * (S1 + z * r); - return x - ((z * (0.5 * y - v * r) - y) - v * S1); - } - - /** - * Helper trig function; computes cos in range [-pi/4, pi/4]. - * - * @param x angle within about pi/4 - * @param y tail of x, created by remPiOver2 - * @return cos(x+y) - */ - private static double cos(double x, double y) - { - if (Configuration.DEBUG && abs(x + y) > 0.7854) - throw new InternalError("Assertion failure"); - x = abs(x); - if (x < 1 / TWO_27) - return 1; // If |x| ~< 2**-27, already know answer. - - double z = x * x; - double r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * C6))))); - - if (x < 0.3) - return 1 - (0.5 * z - (z * r - x * y)); - - double qx = (x > 0.78125) ? 0.28125 : (x * 0.25); - return 1 - qx - ((0.5 * z - qx) - (z * r - x * y)); - } - - /** - * Helper trig function; computes tan in range [-pi/4, pi/4]. - * - * @param x angle within about pi/4 - * @param y tail of x, created by remPiOver2 - * @param invert true iff -1/tan should be returned instead - * @return tan(x+y) - */ - private static double tan(double x, double y, boolean invert) - { - // PI/2 is irrational, so no double is a perfect multiple of it. - if (Configuration.DEBUG && (abs(x + y) > 0.7854 || (x == 0 && invert))) - throw new InternalError("Assertion failure"); - boolean negative = x < 0; - if (negative) - { - x = -x; - y = -y; - } - if (x < 1 / TWO_28) // If |x| ~< 2**-28, already know answer. - return (negative ? -1 : 1) * (invert ? -1 / x : x); - - double z; - double w; - boolean large = x >= 0.6744; - if (large) - { - z = PI / 4 - x; - w = PI_L / 4 - y; - x = z + w; - y = 0; - } - z = x * x; - w = z * z; - // Break x**5*(T1+x**2*T2+...) into - // x**5(T1+x**4*T3+...+x**20*T11) - // + x**5(x**2*(T2+x**4*T4+...+x**22*T12)). - double r = T1 + w * (T3 + w * (T5 + w * (T7 + w * (T9 + w * T11)))); - double v = z * (T2 + w * (T4 + w * (T6 + w * (T8 + w * (T10 + w * T12))))); - double s = z * x; - r = y + z * (s * (r + v) + y); - r += T0 * s; - w = x + r; - if (large) - { - v = invert ? -1 : 1; - return (negative ? -1 : 1) * (v - 2 * (x - (w * w / (w + v) - r))); - } - if (! invert) - return w; - - // Compute -1.0/(x+r) accurately. - z = (float) w; - v = r - (z - x); - double a = -1 / w; - double t = (float) a; - return t + a * (1 + t * z + t * v); - } -} diff --git a/libjava/java/lang/StringIndexOutOfBoundsException.java b/libjava/java/lang/StringIndexOutOfBoundsException.java deleted file mode 100644 index ebc4a04..0000000 --- a/libjava/java/lang/StringIndexOutOfBoundsException.java +++ /dev/null @@ -1,85 +0,0 @@ -/* StringIndexOutOfBoundsException.java -- thrown to indicate attempt to - exceed string bounds - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * This exception can be thrown to indicate an attempt to access an index - * which is out of bounds of a String. Any negative integer, and a positive - * integer greater than or equal to the size of the string, is an index - * which would be out of bounds. - * - * @author Brian Jones - * @author Warren Levy (warrenl@cygnus.com) - * @status updated to 1.4 - */ -public class StringIndexOutOfBoundsException extends IndexOutOfBoundsException -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -6762910422159637258L; - - /** - * Create an exception without a message. - */ - public StringIndexOutOfBoundsException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public StringIndexOutOfBoundsException(String s) - { - super(s); - } - - /** - * Create an exception noting the illegal index. - * - * @param index the invalid index - */ - public StringIndexOutOfBoundsException(int index) - { - super("String index out of range: " + index); - } -} diff --git a/libjava/java/lang/ThreadDeath.java b/libjava/java/lang/ThreadDeath.java deleted file mode 100644 index c7d88fb..0000000 --- a/libjava/java/lang/ThreadDeath.java +++ /dev/null @@ -1,68 +0,0 @@ -/* ThreadDeath.java - special exception registering Thread death - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * ThreadDeath is thrown in a thread when someone calls <code>stop()</code> - * on that thread. <b>Important:</b> Make sure you rethrow this exception - * if you catch it. If you don't, the thread will not die. - * - * <p>This is an Error rather than an exception, so that normal code will - * not catch it. It is intended for asynchronous cleanup when using the - * deprecated Thread.stop() method. - * - * @author John Keiser - * @author Tom Tromey (tromey@cygnus.com) - * @see Thread#stop() - * @status updated to 1.4 - */ -public class ThreadDeath extends Error -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -4417128565033088268L; - - /** - * Create an error without a message. - */ - public ThreadDeath() - { - } -} diff --git a/libjava/java/lang/ThreadGroup.java b/libjava/java/lang/ThreadGroup.java deleted file mode 100644 index 6e4c27a..0000000 --- a/libjava/java/lang/ThreadGroup.java +++ /dev/null @@ -1,749 +0,0 @@ -/* ThreadGroup -- a group of Threads - Copyright (C) 1998, 2000, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package java.lang; - -import java.util.Vector; - -/** - * ThreadGroup allows you to group Threads together. There is a hierarchy - * of ThreadGroups, and only the initial ThreadGroup has no parent. A Thread - * may access information about its own ThreadGroup, but not its parents or - * others outside the tree. - * - * @author John Keiser - * @author Tom Tromey - * @author Bryce McKinlay - * @author Eric Blake (ebb9@email.byu.edu) - * @see Thread - * @since 1.0 - * @status updated to 1.4 - */ -public class ThreadGroup -{ - /** The Initial, top-level ThreadGroup. */ - static ThreadGroup root = new ThreadGroup(); - - /** - * This flag is set if an uncaught exception occurs. The runtime should - * check this and exit with an error status if it is set. - */ - static boolean had_uncaught_exception; - - /** The parent thread group. */ - private final ThreadGroup parent; - - /** The group name, non-null. */ - final String name; - - /** The threads in the group. */ - private final Vector threads = new Vector(); - - /** Child thread groups, or null when this group is destroyed. */ - private Vector groups = new Vector(); - - /** If all threads in the group are daemons. */ - private boolean daemon_flag = false; - - /** The maximum group priority. */ - private int maxpri; - - /** - * Hidden constructor to build the root node. - */ - private ThreadGroup() - { - name = "main"; - parent = null; - maxpri = Thread.MAX_PRIORITY; - } - - /** - * Create a new ThreadGroup using the given name and the current thread's - * ThreadGroup as a parent. There may be a security check, - * <code>checkAccess</code>. - * - * @param name the name to use for the ThreadGroup - * @throws SecurityException if the current thread cannot create a group - * @see #checkAccess() - */ - public ThreadGroup(String name) - { - this(Thread.currentThread().group, name); - } - - /** - * Create a new ThreadGroup using the given name and parent group. The new - * group inherits the maximum priority and daemon status of its parent - * group. There may be a security check, <code>checkAccess</code>. - * - * @param name the name to use for the ThreadGroup - * @param parent the ThreadGroup to use as a parent - * @throws NullPointerException if parent is null - * @throws SecurityException if the current thread cannot create a group - * @throws IllegalThreadStateException if the parent is destroyed - * @see #checkAccess() - */ - public ThreadGroup(ThreadGroup parent, String name) - { - parent.checkAccess(); - this.parent = parent; - this.name = name; - maxpri = parent.maxpri; - daemon_flag = parent.daemon_flag; - synchronized (parent) - { - if (parent.groups == null) - throw new IllegalThreadStateException(); - parent.groups.add(this); - } - } - - /** - * Get the name of this ThreadGroup. - * - * @return the name of this ThreadGroup - */ - public final String getName() - { - return name; - } - - /** - * Get the parent of this ThreadGroup. If the parent is not null, there - * may be a security check, <code>checkAccess</code>. - * - * @return the parent of this ThreadGroup - * @throws SecurityException if permission is denied - */ - public final ThreadGroup getParent() - { - if (parent != null) - parent.checkAccess(); - return parent; - } - - /** - * Get the maximum priority of Threads in this ThreadGroup. Threads created - * after this call in this group may not exceed this priority. - * - * @return the maximum priority of Threads in this ThreadGroup - */ - public final int getMaxPriority() - { - return maxpri; - } - - /** - * Tell whether this ThreadGroup is a daemon group. A daemon group will - * be automatically destroyed when its last thread is stopped and - * its last thread group is destroyed. - * - * @return whether this ThreadGroup is a daemon group - */ - public final boolean isDaemon() - { - return daemon_flag; - } - - /** - * Tell whether this ThreadGroup has been destroyed or not. - * - * @return whether this ThreadGroup has been destroyed or not - * @since 1.1 - */ - public synchronized boolean isDestroyed() - { - return groups == null; - } - - /** - * Set whether this ThreadGroup is a daemon group. A daemon group will be - * destroyed when its last thread is stopped and its last thread group is - * destroyed. There may be a security check, <code>checkAccess</code>. - * - * @param daemon whether this ThreadGroup should be a daemon group - * @throws SecurityException if you cannot modify this ThreadGroup - * @see #checkAccess() - */ - public final void setDaemon(boolean daemon) - { - checkAccess(); - daemon_flag = daemon; - } - - /** - * Set the maximum priority for Threads in this ThreadGroup. setMaxPriority - * can only be used to reduce the current maximum. If maxpri is greater - * than the current Maximum of the parent group, the current value is not - * changed. Otherwise, all groups which belong to this have their priority - * adjusted as well. Calling this does not affect threads already in this - * ThreadGroup. There may be a security check, <code>checkAccess</code>. - * - * @param maxpri the new maximum priority for this ThreadGroup - * @throws SecurityException if you cannot modify this ThreadGroup - * @see #getMaxPriority() - * @see #checkAccess() - */ - public final synchronized void setMaxPriority(int maxpri) - { - checkAccess(); - if (maxpri < Thread.MIN_PRIORITY || maxpri > Thread.MAX_PRIORITY) - return; - if (parent != null && maxpri > parent.maxpri) - maxpri = parent.maxpri; - this.maxpri = maxpri; - if (groups == null) - return; - int i = groups.size(); - while (--i >= 0) - ((ThreadGroup) groups.get(i)).setMaxPriority(maxpri); - } - - /** - * Check whether this ThreadGroup is an ancestor of the specified - * ThreadGroup, or if they are the same. - * - * @param group the group to test on - * @return whether this ThreadGroup is a parent of the specified group - */ - public final boolean parentOf(ThreadGroup group) - { - while (group != null) - { - if (group == this) - return true; - group = group.parent; - } - return false; - } - - /** - * Find out if the current Thread can modify this ThreadGroup. This passes - * the check on to <code>SecurityManager.checkAccess(this)</code>. - * - * @throws SecurityException if the current Thread cannot modify this - * ThreadGroup - * @see SecurityManager#checkAccess(ThreadGroup) - */ - public final void checkAccess() - { - // Bypass System.getSecurityManager, for bootstrap efficiency. - SecurityManager sm = SecurityManager.current; - if (sm != null) - sm.checkAccess(this); - } - - /** - * Return an estimate of the total number of active threads in this - * ThreadGroup and all its descendants. This cannot return an exact number, - * since the status of threads may change after they were counted; but it - * should be pretty close. Based on a JDC bug, - * <a href="http://developer.java.sun.com/developer/bugParade/bugs/4089701.html"> - * 4089701</a>, we take active to mean isAlive(). - * - * @return count of active threads in this ThreadGroup and its descendants - */ - public int activeCount() - { - int total = 0; - if (groups == null) - return total; - int i = threads.size(); - while (--i >= 0) - if (((Thread) threads.get(i)).isAlive()) - total++; - i = groups.size(); - while (--i >= 0) - total += ((ThreadGroup) groups.get(i)).activeCount(); - return total; - } - - /** - * Copy all of the active Threads from this ThreadGroup and its descendants - * into the specified array. If the array is not big enough to hold all - * the Threads, extra Threads will simply not be copied. There may be a - * security check, <code>checkAccess</code>. - * - * @param array the array to put the threads into - * @return the number of threads put into the array - * @throws SecurityException if permission was denied - * @throws NullPointerException if array is null - * @throws ArrayStoreException if a thread does not fit in the array - * @see #activeCount() - * @see #checkAccess() - * @see #enumerate(Thread[], boolean) - */ - public int enumerate(Thread[] array) - { - return enumerate(array, 0, true); - } - - /** - * Copy all of the active Threads from this ThreadGroup and, if desired, - * from its descendants, into the specified array. If the array is not big - * enough to hold all the Threads, extra Threads will simply not be copied. - * There may be a security check, <code>checkAccess</code>. - * - * @param array the array to put the threads into - * @param recurse whether to recurse into descendent ThreadGroups - * @return the number of threads put into the array - * @throws SecurityException if permission was denied - * @throws NullPointerException if array is null - * @throws ArrayStoreException if a thread does not fit in the array - * @see #activeCount() - * @see #checkAccess() - */ - public int enumerate(Thread[] array, boolean recurse) - { - return enumerate(array, 0, recurse); - } - - /** - * Get the number of active groups in this ThreadGroup. This group itself - * is not included in the count. A sub-group is active if it has not been - * destroyed. This cannot return an exact number, since the status of - * threads may change after they were counted; but it should be pretty close. - * - * @return the number of active groups in this ThreadGroup - */ - public int activeGroupCount() - { - if (groups == null) - return 0; - int total = groups.size(); - int i = total; - while (--i >= 0) - total += ((ThreadGroup) groups.get(i)).activeGroupCount(); - return total; - } - - /** - * Copy all active ThreadGroups that are descendants of this ThreadGroup - * into the specified array. If the array is not large enough to hold all - * active ThreadGroups, extra ThreadGroups simply will not be copied. There - * may be a security check, <code>checkAccess</code>. - * - * @param array the array to put the ThreadGroups into - * @return the number of ThreadGroups copied into the array - * @throws SecurityException if permission was denied - * @throws NullPointerException if array is null - * @throws ArrayStoreException if a group does not fit in the array - * @see #activeCount() - * @see #checkAccess() - * @see #enumerate(ThreadGroup[], boolean) - */ - public int enumerate(ThreadGroup[] array) - { - return enumerate(array, 0, true); - } - - /** - * Copy all active ThreadGroups that are children of this ThreadGroup into - * the specified array, and if desired, also all descendents. If the array - * is not large enough to hold all active ThreadGroups, extra ThreadGroups - * simply will not be copied. There may be a security check, - * <code>checkAccess</code>. - * - * @param array the array to put the ThreadGroups into - * @param recurse whether to recurse into descendent ThreadGroups - * @return the number of ThreadGroups copied into the array - * @throws SecurityException if permission was denied - * @throws NullPointerException if array is null - * @throws ArrayStoreException if a group does not fit in the array - * @see #activeCount() - * @see #checkAccess() - */ - public int enumerate(ThreadGroup[] array, boolean recurse) - { - return enumerate(array, 0, recurse); - } - - /** - * Stop all Threads in this ThreadGroup and its descendants. - * - * <p>This is inherently unsafe, as it can interrupt synchronized blocks and - * leave data in bad states. Hence, there is a security check: - * <code>checkAccess()</code>, followed by further checks on each thread - * being stopped. - * - * @throws SecurityException if permission is denied - * @see #checkAccess() - * @see Thread#stop(Throwable) - * @deprecated unsafe operation, try not to use - */ - public final synchronized void stop() - { - checkAccess(); - if (groups == null) - return; - int i = threads.size(); - while (--i >= 0) - ((Thread) threads.get(i)).stop(); - i = groups.size(); - while (--i >= 0) - ((ThreadGroup) groups.get(i)).stop(); - } - - /** - * Interrupt all Threads in this ThreadGroup and its sub-groups. There may - * be a security check, <code>checkAccess</code>. - * - * @throws SecurityException if permission is denied - * @see #checkAccess() - * @see Thread#interrupt() - * @since 1.2 - */ - public final synchronized void interrupt() - { - checkAccess(); - if (groups == null) - return; - int i = threads.size(); - while (--i >= 0) - ((Thread) threads.get(i)).interrupt(); - i = groups.size(); - while (--i >= 0) - ((ThreadGroup) groups.get(i)).interrupt(); - } - - /** - * Suspend all Threads in this ThreadGroup and its descendants. - * - * <p>This is inherently unsafe, as suspended threads still hold locks, - * which can lead to deadlock. Hence, there is a security check: - * <code>checkAccess()</code>, followed by further checks on each thread - * being suspended. - * - * @throws SecurityException if permission is denied - * @see #checkAccess() - * @see Thread#suspend() - * @deprecated unsafe operation, try not to use - */ - public final synchronized void suspend() - { - checkAccess(); - if (groups == null) - return; - int i = threads.size(); - while (--i >= 0) - ((Thread) threads.get(i)).suspend(); - i = groups.size(); - while (--i >= 0) - ((ThreadGroup) groups.get(i)).suspend(); - } - - /** - * Resume all suspended Threads in this ThreadGroup and its descendants. - * To mirror suspend(), there is a security check: - * <code>checkAccess()</code>, followed by further checks on each thread - * being resumed. - * - * @throws SecurityException if permission is denied - * @see #checkAccess() - * @see Thread#suspend() - * @deprecated pointless, since suspend is deprecated - */ - public final synchronized void resume() - { - checkAccess(); - if (groups == null) - return; - int i = threads.size(); - while (--i >= 0) - ((Thread) threads.get(i)).resume(); - i = groups.size(); - while (--i >= 0) - ((ThreadGroup) groups.get(i)).resume(); - } - - /** - * Destroy this ThreadGroup. The group must be empty, meaning that all - * threads and sub-groups have completed execution. Daemon groups are - * destroyed automatically. There may be a security check, - * <code>checkAccess</code>. - * - * @throws IllegalThreadStateException if the ThreadGroup is not empty, or - * was previously destroyed - * @throws SecurityException if permission is denied - * @see #checkAccess() - */ - public final synchronized void destroy() - { - checkAccess(); - if (! threads.isEmpty() || groups == null) - throw new IllegalThreadStateException(); - int i = groups.size(); - while (--i >= 0) - ((ThreadGroup) groups.get(i)).destroy(); - groups = null; - if (parent != null) - parent.removeGroup(this); - } - - /** - * Print out information about this ThreadGroup to System.out. This is - * meant for debugging purposes. <b>WARNING:</b> This method is not secure, - * and can print the name of threads to standard out even when you cannot - * otherwise get at such threads. - */ - public void list() - { - list(""); - } - - /** - * When a Thread in this ThreadGroup does not catch an exception, the - * virtual machine calls this method. The default implementation simply - * passes the call to the parent; then in top ThreadGroup, it will - * ignore ThreadDeath and print the stack trace of any other throwable. - * Override this method if you want to handle the exception in a different - * manner. - * - * @param thread the thread that exited - * @param t the uncaught throwable - * @throws NullPointerException if t is null - * @see ThreadDeath - * @see System#err - * @see Throwable#printStackTrace() - */ - public void uncaughtException(Thread thread, Throwable t) - { - if (parent != null) - parent.uncaughtException(thread, t); - else if (! (t instanceof ThreadDeath)) - { - if (t == null) - throw new NullPointerException(); - had_uncaught_exception = true; - try - { - if (thread != null) - System.err.print("Exception in thread \"" + thread.name + "\" "); - t.printStackTrace(System.err); - } - catch (Throwable x) - { - // This means that something is badly screwed up with the runtime, - // or perhaps someone overloaded the Throwable.printStackTrace to - // die. In any case, try to deal with it gracefully. - try - { - System.err.println(t); - System.err.println("*** Got " + x - + " while trying to print stack trace."); - } - catch (Throwable x2) - { - // Here, someone may have overloaded t.toString() or - // x.toString() to die. Give up all hope; we can't even chain - // the exception, because the chain would likewise die. - System.err.println("*** Catastrophic failure while handling " - + "uncaught exception."); - throw new InternalError(); - } - } - } - } - - /** - * Originally intended to tell the VM whether it may suspend Threads in - * low memory situations, this method was never implemented by Sun, and - * is hence a no-op. - * - * @param allow whether to allow low-memory thread suspension; ignored - * @return false - * @since 1.1 - * @deprecated pointless, since suspend is deprecated - */ - public boolean allowThreadSuspension(boolean allow) - { - return false; - } - - /** - * Return a human-readable String representing this ThreadGroup. The format - * of the string is:<br> - * <code>getClass().getName() + "[name=" + getName() + ",maxpri=" - * + getMaxPriority() + ']'</code>. - * - * @return a human-readable String representing this ThreadGroup - */ - public String toString() - { - return getClass().getName() + "[name=" + name + ",maxpri=" + maxpri + ']'; - } - - /** - * Implements enumerate. - * - * @param list the array to put the threads into - * @param next the next open slot in the array - * @param recurse whether to recurse into descendent ThreadGroups - * @return the number of threads put into the array - * @throws SecurityException if permission was denied - * @throws NullPointerException if list is null - * @throws ArrayStoreException if a thread does not fit in the array - * @see #enumerate(Thread[]) - * @see #enumerate(Thread[], boolean) - */ - private int enumerate(Thread[] list, int next, boolean recurse) - { - checkAccess(); - if (groups == null) - return next; - int i = threads.size(); - while (--i >= 0 && next < list.length) - { - Thread t = (Thread) threads.get(i); - if (t.isAlive()) - list[next++] = t; - } - if (recurse) - { - i = groups.size(); - while (--i >= 0 && next < list.length) - { - ThreadGroup g = (ThreadGroup) groups.get(i); - next = g.enumerate(list, next, true); - } - } - return next; - } - - /** - * Implements enumerate. - * - * @param list the array to put the groups into - * @param next the next open slot in the array - * @param recurse whether to recurse into descendent ThreadGroups - * @return the number of groups put into the array - * @throws SecurityException if permission was denied - * @throws NullPointerException if list is null - * @throws ArrayStoreException if a group does not fit in the array - * @see #enumerate(ThreadGroup[]) - * @see #enumerate(ThreadGroup[], boolean) - */ - private int enumerate(ThreadGroup[] list, int next, boolean recurse) - { - checkAccess(); - if (groups == null) - return next; - int i = groups.size(); - while (--i >= 0 && next < list.length) - { - ThreadGroup g = (ThreadGroup) groups.get(i); - list[next++] = g; - if (recurse && next != list.length) - next = g.enumerate(list, next, true); - } - return next; - } - - /** - * Implements list. - * - * @param indentation the current level of indentation - * @see #list() - */ - private void list(String indentation) - { - if (groups == null) - return; - System.out.println(indentation + this); - indentation += " "; - int i = threads.size(); - while (--i >= 0) - System.out.println(indentation + threads.get(i)); - i = groups.size(); - while (--i >= 0) - ((ThreadGroup) groups.get(i)).list(indentation); - } - - /** - * Add a thread to the group. Called by Thread constructors. - * - * @param t the thread to add, non-null - * @throws IllegalThreadStateException if the group is destroyed - */ - final synchronized void addThread(Thread t) - { - if (groups == null) - throw new IllegalThreadStateException("ThreadGroup is destroyed"); - threads.add(t); - } - - /** - * Called by the VM to remove a thread that has died. - * - * @param t the thread to remove, non-null - * @XXX A ThreadListener to call this might be nice. - */ - final synchronized void removeThread(Thread t) - { - if (groups == null) - return; - threads.remove(t); - t.group = null; - // Daemon groups are automatically destroyed when all their threads die. - if (daemon_flag && groups.size() == 0 && threads.size() == 0) - { - // We inline destroy to avoid the access check. - groups = null; - if (parent != null) - parent.removeGroup(this); - } - } - - /** - * Called when a group is destroyed, to remove it from its parent. - * - * @param g the destroyed group, non-null - */ - final synchronized void removeGroup(ThreadGroup g) - { - groups.remove(g); - // Daemon groups are automatically destroyed when all their threads die. - if (daemon_flag && groups.size() == 0 && threads.size() == 0) - { - // We inline destroy to avoid the access check. - groups = null; - if (parent != null) - parent.removeGroup(this); - } - } -} // class ThreadGroup diff --git a/libjava/java/lang/Throwable.java b/libjava/java/lang/Throwable.java deleted file mode 100644 index c47a14b..0000000 --- a/libjava/java/lang/Throwable.java +++ /dev/null @@ -1,563 +0,0 @@ -/* java.lang.Throwable -- Root class for all Exceptions and Errors - Copyright (C) 1998, 1999, 2002, 2004, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package java.lang; - -import gnu.classpath.SystemProperties; - -import java.io.PrintStream; -import java.io.PrintWriter; -import java.io.Serializable; - -/** - * Throwable is the superclass of all exceptions that can be raised. - * - * <p>There are two special cases: {@link Error} and {@link RuntimeException}: - * these two classes (and their subclasses) are considered unchecked - * exceptions, and are either frequent enough or catastrophic enough that you - * do not need to declare them in <code>throws</code> clauses. Everything - * else is a checked exception, and is ususally a subclass of - * {@link Exception}; these exceptions have to be handled or declared. - * - * <p>Instances of this class are usually created with knowledge of the - * execution context, so that you can get a stack trace of the problem spot - * in the code. Also, since JDK 1.4, Throwables participate in "exception - * chaining." This means that one exception can be caused by another, and - * preserve the information of the original. - * - * <p>One reason this is useful is to wrap exceptions to conform to an - * interface. For example, it would be bad design to require all levels - * of a program interface to be aware of the low-level exceptions thrown - * at one level of abstraction. Another example is wrapping a checked - * exception in an unchecked one, to communicate that failure occured - * while still obeying the method throws clause of a superclass. - * - * <p>A cause is assigned in one of two ways; but can only be assigned once - * in the lifetime of the Throwable. There are new constructors added to - * several classes in the exception hierarchy that directly initialize the - * cause, or you can use the <code>initCause</code> method. This second - * method is especially useful if the superclass has not been retrofitted - * with new constructors:<br> - * <pre> - * try - * { - * lowLevelOp(); - * } - * catch (LowLevelException lle) - * { - * throw (HighLevelException) new HighLevelException().initCause(lle); - * } - * </pre> - * Notice the cast in the above example; without it, your method would need - * a throws clase that declared Throwable, defeating the purpose of chainig - * your exceptions. - * - * <p>By convention, exception classes have two constructors: one with no - * arguments, and one that takes a String for a detail message. Further, - * classes which are likely to be used in an exception chain also provide - * a constructor that takes a Throwable, with or without a detail message - * string. - * - * <p>Another 1.4 feature is the StackTrace, a means of reflection that - * allows the program to inspect the context of the exception, and which is - * serialized, so that remote procedure calls can correctly pass exceptions. - * - * @author Brian Jones - * @author John Keiser - * @author Mark Wielaard - * @author Tom Tromey - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.0 - * @status updated to 1.4 - */ -public class Throwable implements Serializable -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -3042686055658047285L; - - /** - * The detail message. - * - * @serial specific details about the exception, may be null - */ - private final String detailMessage; - - /** - * The cause of the throwable, including null for an unknown or non-chained - * cause. This may only be set once; so the field is set to - * <code>this</code> until initialized. - * - * @serial the cause, or null if unknown, or this if not yet set - * @since 1.4 - */ - private Throwable cause = this; - - /** - * The stack trace, in a serialized form. - * - * @serial the elements of the stack trace; this is non-null, and has - * no null entries - * @since 1.4 - */ - private StackTraceElement[] stackTrace; - - /** - * Instantiate this Throwable with an empty message. The cause remains - * uninitialized. {@link #fillInStackTrace()} will be called to set - * up the stack trace. - */ - public Throwable() - { - this((String) null); - } - - /** - * Instantiate this Throwable with the given message. The cause remains - * uninitialized. {@link #fillInStackTrace()} will be called to set - * up the stack trace. - * - * @param message the message to associate with the Throwable - */ - public Throwable(String message) - { - fillInStackTrace(); - detailMessage = message; - } - - /** - * Instantiate this Throwable with the given message and cause. Note that - * the message is unrelated to the message of the cause. - * {@link #fillInStackTrace()} will be called to set up the stack trace. - * - * @param message the message to associate with the Throwable - * @param cause the cause, may be null - * @since 1.4 - */ - public Throwable(String message, Throwable cause) - { - this(message); - this.cause = cause; - } - - /** - * Instantiate this Throwable with the given cause. The message is then - * built as <code>cause == null ? null : cause.toString()</code>. - * {@link #fillInStackTrace()} will be called to set up the stack trace. - * - * @param cause the cause, may be null - * @since 1.4 - */ - public Throwable(Throwable cause) - { - this(cause == null ? null : cause.toString(), cause); - } - - /** - * Get the message associated with this Throwable. - * - * @return the error message associated with this Throwable, may be null - */ - public String getMessage() - { - return detailMessage; - } - - /** - * Get a localized version of this Throwable's error message. - * This method must be overridden in a subclass of Throwable - * to actually produce locale-specific methods. The Throwable - * implementation just returns getMessage(). - * - * @return a localized version of this error message - * @see #getMessage() - * @since 1.1 - */ - public String getLocalizedMessage() - { - return getMessage(); - } - - /** - * Returns the cause of this exception, or null if the cause is not known - * or non-existant. This cause is initialized by the new constructors, - * or by calling initCause. - * - * @return the cause of this Throwable - * @since 1.4 - */ - public Throwable getCause() - { - return cause == this ? null : cause; - } - - /** - * Initialize the cause of this Throwable. This may only be called once - * during the object lifetime, including implicitly by chaining - * constructors. - * - * @param cause the cause of this Throwable, may be null - * @return this - * @throws IllegalArgumentException if cause is this (a Throwable can't be - * its own cause!) - * @throws IllegalStateException if the cause has already been set - * @since 1.4 - */ - public Throwable initCause(Throwable cause) - { - if (cause == this) - throw new IllegalArgumentException(); - if (this.cause != this) - throw new IllegalStateException(); - this.cause = cause; - return this; - } - - /** - * Get a human-readable representation of this Throwable. The detail message - * is retrieved by getLocalizedMessage(). Then, with a null detail - * message, this string is simply the object's class name; otherwise - * the string is <code>getClass().getName() + ": " + message</code>. - * - * @return a human-readable String represting this Throwable - */ - public String toString() - { - String msg = getLocalizedMessage(); - return getClass().getName() + (msg == null ? "" : ": " + msg); - } - - /** - * Print a stack trace to the standard error stream. This stream is the - * current contents of <code>System.err</code>. The first line of output - * is the result of {@link #toString()}, and the remaining lines represent - * the data created by {@link #fillInStackTrace()}. While the format is - * unspecified, this implementation uses the suggested format, demonstrated - * by this example:<br> - * <pre> - * public class Junk - * { - * public static void main(String args[]) - * { - * try - * { - * a(); - * } - * catch(HighLevelException e) - * { - * e.printStackTrace(); - * } - * } - * static void a() throws HighLevelException - * { - * try - * { - * b(); - * } - * catch(MidLevelException e) - * { - * throw new HighLevelException(e); - * } - * } - * static void b() throws MidLevelException - * { - * c(); - * } - * static void c() throws MidLevelException - * { - * try - * { - * d(); - * } - * catch(LowLevelException e) - * { - * throw new MidLevelException(e); - * } - * } - * static void d() throws LowLevelException - * { - * e(); - * } - * static void e() throws LowLevelException - * { - * throw new LowLevelException(); - * } - * } - * class HighLevelException extends Exception - * { - * HighLevelException(Throwable cause) { super(cause); } - * } - * class MidLevelException extends Exception - * { - * MidLevelException(Throwable cause) { super(cause); } - * } - * class LowLevelException extends Exception - * { - * } - * </pre> - * <p> - * <pre> - * HighLevelException: MidLevelException: LowLevelException - * at Junk.a(Junk.java:13) - * at Junk.main(Junk.java:4) - * Caused by: MidLevelException: LowLevelException - * at Junk.c(Junk.java:23) - * at Junk.b(Junk.java:17) - * at Junk.a(Junk.java:11) - * ... 1 more - * Caused by: LowLevelException - * at Junk.e(Junk.java:30) - * at Junk.d(Junk.java:27) - * at Junk.c(Junk.java:21) - * ... 3 more - * </pre> - */ - public void printStackTrace() - { - printStackTrace(System.err); - } - - /** - * Print a stack trace to the specified PrintStream. See - * {@link #printStackTrace()} for the sample format. - * - * @param s the PrintStream to write the trace to - */ - public void printStackTrace(PrintStream s) - { - s.print(stackTraceString()); - } - - /** - * Prints the exception, the detailed message and the stack trace - * associated with this Throwable to the given <code>PrintWriter</code>. - * The actual output written is implemention specific. Use the result of - * <code>getStackTrace()</code> when more precise information is needed. - * - * <p>This implementation first prints a line with the result of this - * object's <code>toString()</code> method. - * <br> - * Then for all elements given by <code>getStackTrace</code> it prints - * a line containing three spaces, the string "at " and the result of calling - * the <code>toString()</code> method on the <code>StackTraceElement</code> - * object. If <code>getStackTrace()</code> returns an empty array it prints - * a line containing three spaces and the string - * "<<No stacktrace available>>". - * <br> - * Then if <code>getCause()</code> doesn't return null it adds a line - * starting with "Caused by: " and the result of calling - * <code>toString()</code> on the cause. - * <br> - * Then for every cause (of a cause, etc) the stacktrace is printed the - * same as for the top level <code>Throwable</code> except that as soon - * as all the remaining stack frames of the cause are the same as the - * the last stack frames of the throwable that the cause is wrapped in - * then a line starting with three spaces and the string "... X more" is - * printed, where X is the number of remaining stackframes. - * - * @param pw the PrintWriter to write the trace to - * @since 1.1 - */ - public void printStackTrace (PrintWriter pw) - { - pw.print(stackTraceString()); - } - - /* - * We use inner class to avoid a static initializer in this basic class. - */ - private static class StaticData - { - static final String nl = SystemProperties.getProperty("line.separator"); - } - - // Create whole stack trace in a stringbuffer so we don't have to print - // it line by line. This prevents printing multiple stack traces from - // different threads to get mixed up when written to the same PrintWriter. - private String stackTraceString() - { - StringBuffer sb = new StringBuffer(); - - // Main stacktrace - StackTraceElement[] stack = getStackTrace(); - stackTraceStringBuffer(sb, this.toString(), stack, 0); - - // The cause(s) - Throwable cause = getCause(); - while (cause != null) - { - // Cause start first line - sb.append("Caused by: "); - - // Cause stacktrace - StackTraceElement[] parentStack = stack; - stack = cause.getStackTrace(); - if (parentStack == null || parentStack.length == 0) - stackTraceStringBuffer(sb, cause.toString(), stack, 0); - else - { - int equal = 0; // Count how many of the last stack frames are equal - int frame = stack.length-1; - int parentFrame = parentStack.length-1; - while (frame > 0 && parentFrame > 0) - { - if (stack[frame].equals(parentStack[parentFrame])) - { - equal++; - frame--; - parentFrame--; - } - else - break; - } - stackTraceStringBuffer(sb, cause.toString(), stack, equal); - } - cause = cause.getCause(); - } - - return sb.toString(); - } - - // Adds to the given StringBuffer a line containing the name and - // all stacktrace elements minus the last equal ones. - private static void stackTraceStringBuffer(StringBuffer sb, String name, - StackTraceElement[] stack, int equal) - { - String nl = StaticData.nl; - // (finish) first line - sb.append(name); - sb.append(nl); - - // The stacktrace - if (stack == null || stack.length == 0) - { - sb.append(" <<No stacktrace available>>"); - sb.append(nl); - } - else - { - for (int i = 0; i < stack.length-equal; i++) - { - sb.append(" at "); - sb.append(stack[i] == null ? "<<Unknown>>" : stack[i].toString()); - sb.append(nl); - } - if (equal > 0) - { - sb.append(" ..."); - sb.append(equal); - sb.append(" more"); - sb.append(nl); - } - } - } - - /** - * Fill in the stack trace with the current execution stack. - * - * @return this same throwable - * @see #printStackTrace() - */ - public Throwable fillInStackTrace() - { - vmState = VMThrowable.fillInStackTrace(this); - stackTrace = null; // Should be regenerated when used. - - return this; - } - - /** - * Provides access to the information printed in {@link #printStackTrace()}. - * The array is non-null, with no null entries, although the virtual - * machine is allowed to skip stack frames. If the array is not 0-length, - * then slot 0 holds the information on the stack frame where the Throwable - * was created (or at least where <code>fillInStackTrace()</code> was - * called). - * - * @return an array of stack trace information, as available from the VM - * @since 1.4 - */ - public StackTraceElement[] getStackTrace() - { - if (stackTrace == null) - if (vmState == null) - stackTrace = new StackTraceElement[0]; - else - { - stackTrace = vmState.getStackTrace(this); - vmState = null; // No longer needed - } - - return stackTrace; - } - - /** - * Change the stack trace manually. This method is designed for remote - * procedure calls, which intend to alter the stack trace before or after - * serialization according to the context of the remote call. - * <p> - * The contents of the given stacktrace is copied so changes to the - * original array do not change the stack trace elements of this - * throwable. - * - * @param stackTrace the new trace to use - * @throws NullPointerException if stackTrace is null or has null elements - * @since 1.4 - */ - public void setStackTrace(StackTraceElement[] stackTrace) - { - int i = stackTrace.length; - StackTraceElement[] st = new StackTraceElement[i]; - - while (--i >= 0) - { - st[i] = stackTrace[i]; - if (st[i] == null) - throw new NullPointerException("Element " + i + " null"); - } - - this.stackTrace = st; - } - - /** - * VM state when fillInStackTrace was called. - * Used by getStackTrace() to get an array of StackTraceElements. - * Cleared when no longer needed. - */ - private transient VMThrowable vmState; -} diff --git a/libjava/java/lang/UnknownError.java b/libjava/java/lang/UnknownError.java deleted file mode 100644 index 7b317bd..0000000 --- a/libjava/java/lang/UnknownError.java +++ /dev/null @@ -1,72 +0,0 @@ -/* UnknownError.java -- thrown when the VM cannot provide more information - about a catastrophic error - Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * An <code>UnknownError</code> is thrown when a serious but unknown - * problem has occurred in the Java Virtual Machine. - * - * @author Brian Jones - * @status updated to 1.4 - */ -public class UnknownError extends VirtualMachineError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 2524784860676771849L; - - /** - * Create an error without a message. - */ - public UnknownError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public UnknownError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/UnsatisfiedLinkError.java b/libjava/java/lang/UnsatisfiedLinkError.java deleted file mode 100644 index 0d513d8..0000000 --- a/libjava/java/lang/UnsatisfiedLinkError.java +++ /dev/null @@ -1,74 +0,0 @@ -/* UnsatisfiedLinkError.java -- thrown when a native method cannot be loaded - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * A <code>UnsatisfiedLinkError</code> is thrown if an appropriate - * native language definition of a method declared <code>native</code> - * cannot be found by the Java Virtual Machine. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @see Runtime - * @status updated to 1.4 - */ -public class UnsatisfiedLinkError extends LinkageError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = -4019343241616879428L; - - /** - * Create an error without a message. - */ - public UnsatisfiedLinkError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public UnsatisfiedLinkError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/UnsupportedClassVersionError.java b/libjava/java/lang/UnsupportedClassVersionError.java deleted file mode 100644 index d6974b7..0000000 --- a/libjava/java/lang/UnsupportedClassVersionError.java +++ /dev/null @@ -1,74 +0,0 @@ -/* UnsupportedClassVersionError.java -- thrown when a class file version - exceeds the capability of the virtual machine - Copyright (C) 1998, 2002 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * An <code>UnsupportedClassVersionError</code> is thrown when the - * Java Virtual Machine determines it does not support the major and minor - * version numbers in the class file it is attempting to read. - * - * @author Brian Jones - * @since 1.2 - * @status updated to 1.4 - */ -public class UnsupportedClassVersionError extends ClassFormatError -{ - /** - * Compatible with JDK 1.2+. - */ - private static final long serialVersionUID = -7123279212883497373L; - - /** - * Create an error without a message. - */ - public UnsupportedClassVersionError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public UnsupportedClassVersionError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/UnsupportedOperationException.java b/libjava/java/lang/UnsupportedOperationException.java deleted file mode 100644 index 0387d0e..0000000 --- a/libjava/java/lang/UnsupportedOperationException.java +++ /dev/null @@ -1,73 +0,0 @@ -/* UnsupportedOperationException.java -- thrown when an operation is not - supported - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * This exception is thrown by an object when an operation is - * requested of it that it does not support. - * - * @author Warren Levy (warrenl@cygnus.com) - * @since 1.2 - * @status updated to 1.4 - */ -public class UnsupportedOperationException extends RuntimeException -{ - /** - * Compatible with JDK 1.2+. - */ - private static final long serialVersionUID = -1242599979055084673L; - - /** - * Create an exception without a message. - */ - public UnsupportedOperationException() - { - } - - /** - * Create an exception with a message. - * - * @param s the message - */ - public UnsupportedOperationException(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/VerifyError.java b/libjava/java/lang/VerifyError.java deleted file mode 100644 index 350ceaa..0000000 --- a/libjava/java/lang/VerifyError.java +++ /dev/null @@ -1,72 +0,0 @@ -/* VerifyError.java -- thrown when a class fails verification - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * A <code>VerifyError</code> is thrown if there is a security problem or - * internal inconsistency in a class file as detected by the "verifier." - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public class VerifyError extends LinkageError -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 7001962396098498785L; - - /** - * Create an error without a message. - */ - public VerifyError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public VerifyError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/VirtualMachineError.java b/libjava/java/lang/VirtualMachineError.java deleted file mode 100644 index 3062c4f..0000000 --- a/libjava/java/lang/VirtualMachineError.java +++ /dev/null @@ -1,73 +0,0 @@ -/* VirtualMachineError.java -- thrown when the Virtual Machine has a problem - Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang; - -/** - * A <code>VirtualMachineError</code> or its subclasses are thrown to - * indicate there is something wrong with the Java Virtual Machine or that - * it does not have the resources needed for it to continue execution. - * - * @author Brian Jones - * @author Tom Tromey (tromey@cygnus.com) - * @status updated to 1.4 - */ -public abstract class VirtualMachineError extends Error -{ - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 4161983926571568670L; - - /** - * Create an error without a message. - */ - public VirtualMachineError() - { - } - - /** - * Create an error with a message. - * - * @param s the message - */ - public VirtualMachineError(String s) - { - super(s); - } -} diff --git a/libjava/java/lang/Void.java b/libjava/java/lang/Void.java deleted file mode 100644 index 1503542..0000000 --- a/libjava/java/lang/Void.java +++ /dev/null @@ -1,68 +0,0 @@ -/* Void.class - defines void.class - Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package java.lang; - - -/** - * Void is a placeholder class so that the variable <code>Void.TYPE</code> - * (also available as <code>void.class</code>) can be supported for - * reflection return types. - * - * <p>This class could be Serializable, but that is up to Sun.</p> - * - * @author Paul Fisher - * @author John Keiser - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.1 - * @status updated to 1.4 - */ -public final class Void -{ - /** - * The return type <code>void</code> is represented by this - * <code>Class</code> object. - */ - public static final Class TYPE = VMClassLoader.getPrimitiveClass('V'); - - /** - * Void is non-instantiable. - */ - private Void() - { - } -} diff --git a/libjava/java/lang/dtoa.c b/libjava/java/lang/dtoa.c deleted file mode 100644 index 6d5ad3b..0000000 --- a/libjava/java/lang/dtoa.c +++ /dev/null @@ -1,906 +0,0 @@ -/**************************************************************** - * - * The author of this software is David M. Gay. - * - * Copyright (c) 1991 by AT&T. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose without fee is hereby granted, provided that this entire notice - * is included in all copies of any software which is or includes a copy - * or modification of this software and in all copies of the supporting - * documentation for such software. - * - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY - * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. - * - ***************************************************************/ - -/* Please send bug reports to - David M. Gay - AT&T Bell Laboratories, Room 2C-463 - 600 Mountain Avenue - Murray Hill, NJ 07974-2070 - U.S.A. - dmg@research.att.com or research!dmg - */ - -#include "mprec.h" -#include <string.h> - -static int -_DEFUN (quorem, - (b, S), - _Jv_Bigint * b _AND _Jv_Bigint * S) -{ - int n; - long borrow, y; - unsigned long carry, q, ys; - unsigned long *bx, *bxe, *sx, *sxe; -#ifdef Pack_32 - long z; - unsigned long si, zs; -#endif - - n = S->_wds; -#ifdef DEBUG - /*debug*/ if (b->_wds > n) - /*debug*/ Bug ("oversize b in quorem"); -#endif - if (b->_wds < n) - return 0; - sx = S->_x; - sxe = sx + --n; - bx = b->_x; - bxe = bx + n; - q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ -#ifdef DEBUG - /*debug*/ if (q > 9) - /*debug*/ Bug ("oversized quotient in quorem"); -#endif - if (q) - { - borrow = 0; - carry = 0; - do - { -#ifdef Pack_32 - si = *sx++; - ys = (si & 0xffff) * q + carry; - zs = (si >> 16) * q + (ys >> 16); - carry = zs >> 16; - y = (*bx & 0xffff) - (ys & 0xffff) + borrow; - borrow = y >> 16; - Sign_Extend (borrow, y); - z = (*bx >> 16) - (zs & 0xffff) + borrow; - borrow = z >> 16; - Sign_Extend (borrow, z); - Storeinc (bx, z, y); -#else - ys = *sx++ * q + carry; - carry = ys >> 16; - y = *bx - (ys & 0xffff) + borrow; - borrow = y >> 16; - Sign_Extend (borrow, y); - *bx++ = y & 0xffff; -#endif - } - while (sx <= sxe); - if (!*bxe) - { - bx = b->_x; - while (--bxe > bx && !*bxe) - --n; - b->_wds = n; - } - } - if (cmp (b, S) >= 0) - { - q++; - borrow = 0; - carry = 0; - bx = b->_x; - sx = S->_x; - do - { -#ifdef Pack_32 - si = *sx++; - ys = (si & 0xffff) + carry; - zs = (si >> 16) + (ys >> 16); - carry = zs >> 16; - y = (*bx & 0xffff) - (ys & 0xffff) + borrow; - borrow = y >> 16; - Sign_Extend (borrow, y); - z = (*bx >> 16) - (zs & 0xffff) + borrow; - borrow = z >> 16; - Sign_Extend (borrow, z); - Storeinc (bx, z, y); -#else - ys = *sx++ + carry; - carry = ys >> 16; - y = *bx - (ys & 0xffff) + borrow; - borrow = y >> 16; - Sign_Extend (borrow, y); - *bx++ = y & 0xffff; -#endif - } - while (sx <= sxe); - bx = b->_x; - bxe = bx + n; - if (!*bxe) - { - while (--bxe > bx && !*bxe) - --n; - b->_wds = n; - } - } - return q; -} - -#ifdef DEBUG -#include <stdio.h> - -void -print (_Jv_Bigint * b) -{ - int i, wds; - unsigned long *x, y; - wds = b->_wds; - x = b->_x+wds; - i = 0; - do - { - x--; - fprintf (stderr, "%08x", *x); - } - while (++i < wds); - fprintf (stderr, "\n"); -} -#endif - -/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. - * - * Inspired by "How to Print Floating-Point Numbers Accurately" by - * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101]. - * - * Modifications: - * 1. Rather than iterating, we use a simple numeric overestimate - * to determine k = floor(log10(d)). We scale relevant - * quantities using O(log2(k)) rather than O(k) multiplications. - * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't - * try to generate digits strictly left to right. Instead, we - * compute with fewer bits and propagate the carry if necessary - * when rounding the final digit up. This is often faster. - * 3. Under the assumption that input will be rounded nearest, - * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. - * That is, we allow equality in stopping tests when the - * round-nearest rule will give the same floating-point value - * as would satisfaction of the stopping test with strict - * inequality. - * 4. We remove common factors of powers of 2 from relevant - * quantities. - * 5. When converting floating-point integers less than 1e16, - * we use floating-point arithmetic rather than resorting - * to multiple-precision integers. - * 6. When asked to produce fewer than 15 digits, we first try - * to get by with floating-point arithmetic; we resort to - * multiple-precision integer arithmetic only if we cannot - * guarantee that the floating-point calculation has given - * the correctly rounded result. For k requested digits and - * "uniformly" distributed input, the probability is - * something like 10^(k-15) that we must resort to the long - * calculation. - */ - - -char * -_DEFUN (_dtoa_r, - (ptr, _d, mode, ndigits, decpt, sign, rve, float_type), - struct _Jv_reent *ptr _AND - double _d _AND - int mode _AND - int ndigits _AND - int *decpt _AND - int *sign _AND - char **rve _AND - int float_type) -{ - /* - float_type == 0 for double precision, 1 for float. - - Arguments ndigits, decpt, sign are similar to those - of ecvt and fcvt; trailing zeros are suppressed from - the returned string. If not null, *rve is set to point - to the end of the return value. If d is +-Infinity or NaN, - then *decpt is set to 9999. - - mode: - 0 ==> shortest string that yields d when read in - and rounded to nearest. - 1 ==> like 0, but with Steele & White stopping rule; - e.g. with IEEE P754 arithmetic , mode 0 gives - 1e23 whereas mode 1 gives 9.999999999999999e22. - 2 ==> max(1,ndigits) significant digits. This gives a - return value similar to that of ecvt, except - that trailing zeros are suppressed. - 3 ==> through ndigits past the decimal point. This - gives a return value similar to that from fcvt, - except that trailing zeros are suppressed, and - ndigits can be negative. - 4-9 should give the same return values as 2-3, i.e., - 4 <= mode <= 9 ==> same return as mode - 2 + (mode & 1). These modes are mainly for - debugging; often they run slower but sometimes - faster than modes 2-3. - 4,5,8,9 ==> left-to-right digit generation. - 6-9 ==> don't try fast floating-point estimate - (if applicable). - - > 16 ==> Floating-point arg is treated as single precision. - - Values of mode other than 0-9 are treated as mode 0. - - Sufficient space is allocated to the return value - to hold the suppressed trailing zeros. - */ - - int bbits, b2, b5, be, dig, i, ieps, ilim0, j, j1, k, k0, - k_check, leftright, m2, m5, s2, s5, try_quick; - int ilim = 0, ilim1 = 0, spec_case = 0; - union double_union d, d2, eps; - long L; -#ifndef Sudden_Underflow - int denorm; - unsigned long x; -#endif - _Jv_Bigint *b, *b1, *delta, *mlo = NULL, *mhi, *S; - double ds; - char *s, *s0; - - d.d = _d; - - if (ptr->_result) - { - ptr->_result->_k = ptr->_result_k; - ptr->_result->_maxwds = 1 << ptr->_result_k; - Bfree (ptr, ptr->_result); - ptr->_result = 0; - } - - if (word0 (d) & Sign_bit) - { - /* set sign for everything, including 0's and NaNs */ - *sign = 1; - word0 (d) &= ~Sign_bit; /* clear sign bit */ - } - else - *sign = 0; - -#if defined(IEEE_Arith) + defined(VAX) -#ifdef IEEE_Arith - if ((word0 (d) & Exp_mask) == Exp_mask) -#else - if (word0 (d) == 0x8000) -#endif - { - /* Infinity or NaN */ - *decpt = 9999; - s = -#ifdef IEEE_Arith - !word1 (d) && !(word0 (d) & 0xfffff) ? "Infinity" : -#endif - "NaN"; - if (rve) - *rve = -#ifdef IEEE_Arith - s[3] ? s + 8 : -#endif - s + 3; - return s; - } -#endif -#ifdef IBM - d.d += 0; /* normalize */ -#endif - if (!d.d) - { - *decpt = 1; - s = "0"; - if (rve) - *rve = s + 1; - return s; - } - - b = d2b (ptr, d.d, &be, &bbits); -#ifdef Sudden_Underflow - i = (int) (word0 (d) >> Exp_shift1 & (Exp_mask >> Exp_shift1)); -#else - if ((i = (int) (word0 (d) >> Exp_shift1 & (Exp_mask >> Exp_shift1)))) - { -#endif - d2.d = d.d; - word0 (d2) &= Frac_mask1; - word0 (d2) |= Exp_11; -#ifdef IBM - if (j = 11 - hi0bits (word0 (d2) & Frac_mask)) - d2.d /= 1 << j; -#endif - - /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 - * log10(x) = log(x) / log(10) - * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) - * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2) - * - * This suggests computing an approximation k to log10(d) by - * - * k = (i - Bias)*0.301029995663981 - * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); - * - * We want k to be too large rather than too small. - * The error in the first-order Taylor series approximation - * is in our favor, so we just round up the constant enough - * to compensate for any error in the multiplication of - * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, - * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, - * adding 1e-13 to the constant term more than suffices. - * Hence we adjust the constant term to 0.1760912590558. - * (We could get a more accurate k by invoking log10, - * but this is probably not worthwhile.) - */ - - i -= Bias; -#ifdef IBM - i <<= 2; - i += j; -#endif -#ifndef Sudden_Underflow - denorm = 0; - } - else - { - /* d is denormalized */ - - i = bbits + be + (Bias + (P - 1) - 1); - x = i > 32 ? word0 (d) << (64 - i) | word1 (d) >> (i - 32) - : word1 (d) << (32 - i); - d2.d = x; - word0 (d2) -= 31 * Exp_msk1; /* adjust exponent */ - i -= (Bias + (P - 1) - 1) + 1; - denorm = 1; - } -#endif - ds = (d2.d - 1.5) * 0.289529654602168 + 0.1760912590558 + i * 0.301029995663981; - k = (int) ds; - if (ds < 0. && ds != k) - k--; /* want k = floor(ds) */ - k_check = 1; - if (k >= 0 && k <= Ten_pmax) - { - if (d.d < tens[k]) - k--; - k_check = 0; - } - j = bbits - i - 1; - if (j >= 0) - { - b2 = 0; - s2 = j; - } - else - { - b2 = -j; - s2 = 0; - } - if (k >= 0) - { - b5 = 0; - s5 = k; - s2 += k; - } - else - { - b2 -= k; - b5 = -k; - s5 = 0; - } - if (mode < 0 || mode > 9) - mode = 0; - try_quick = 1; - if (mode > 5) - { - mode -= 4; - try_quick = 0; - } - leftright = 1; - switch (mode) - { - case 0: - case 1: - ilim = ilim1 = -1; - i = 18; - ndigits = 0; - break; - case 2: - leftright = 0; - /* no break */ - case 4: - if (ndigits <= 0) - ndigits = 1; - ilim = ilim1 = i = ndigits; - break; - case 3: - leftright = 0; - /* no break */ - case 5: - i = ndigits + k + 1; - ilim = i; - ilim1 = i - 1; - if (i <= 0) - i = 1; - } - j = sizeof (unsigned long); - for (ptr->_result_k = 0; (int) (sizeof (_Jv_Bigint) - sizeof (unsigned long)) + j <= i; - j <<= 1) - ptr->_result_k++; - ptr->_result = Balloc (ptr, ptr->_result_k); - s = s0 = (char *) ptr->_result; - - if (ilim >= 0 && ilim <= Quick_max && try_quick) - { - /* Try to get by with floating-point arithmetic. */ - - i = 0; - d2.d = d.d; - k0 = k; - ilim0 = ilim; - ieps = 2; /* conservative */ - if (k > 0) - { - ds = tens[k & 0xf]; - j = k >> 4; - if (j & Bletch) - { - /* prevent overflows */ - j &= Bletch - 1; - d.d /= bigtens[n_bigtens - 1]; - ieps++; - } - for (; j; j >>= 1, i++) - if (j & 1) - { - ieps++; - ds *= bigtens[i]; - } - d.d /= ds; - } - else if ((j1 = -k)) - { - d.d *= tens[j1 & 0xf]; - for (j = j1 >> 4; j; j >>= 1, i++) - if (j & 1) - { - ieps++; - d.d *= bigtens[i]; - } - } - if (k_check && d.d < 1. && ilim > 0) - { - if (ilim1 <= 0) - goto fast_failed; - ilim = ilim1; - k--; - d.d *= 10.; - ieps++; - } - eps.d = ieps * d.d + 7.; - word0 (eps) -= (P - 1) * Exp_msk1; - if (ilim == 0) - { - S = mhi = 0; - d.d -= 5.; - if (d.d > eps.d) - goto one_digit; - if (d.d < -eps.d) - goto no_digits; - goto fast_failed; - } -#ifndef No_leftright - if (leftright) - { - /* Use Steele & White method of only - * generating digits needed. - */ - eps.d = 0.5 / tens[ilim - 1] - eps.d; - for (i = 0;;) - { - L = d.d; - d.d -= L; - *s++ = '0' + (int) L; - if (d.d < eps.d) - goto ret1; - if (1. - d.d < eps.d) - goto bump_up; - if (++i >= ilim) - break; - eps.d *= 10.; - d.d *= 10.; - } - } - else - { -#endif - /* Generate ilim digits, then fix them up. */ - eps.d *= tens[ilim - 1]; - for (i = 1;; i++, d.d *= 10.) - { - L = d.d; - d.d -= L; - *s++ = '0' + (int) L; - if (i == ilim) - { - if (d.d > 0.5 + eps.d) - goto bump_up; - else if (d.d < 0.5 - eps.d) - { - while (*--s == '0'); - s++; - goto ret1; - } - break; - } - } -#ifndef No_leftright - } -#endif - fast_failed: - s = s0; - d.d = d2.d; - k = k0; - ilim = ilim0; - } - - /* Do we have a "small" integer? */ - - if (be >= 0 && k <= Int_max) - { - /* Yes. */ - ds = tens[k]; - if (ndigits < 0 && ilim <= 0) - { - S = mhi = 0; - if (ilim < 0 || d.d <= 5 * ds) - goto no_digits; - goto one_digit; - } - for (i = 1;; i++) - { - L = d.d / ds; - d.d -= L * ds; -#ifdef Check_FLT_ROUNDS - /* If FLT_ROUNDS == 2, L will usually be high by 1 */ - if (d.d < 0) - { - L--; - d.d += ds; - } -#endif - *s++ = '0' + (int) L; - if (i == ilim) - { - d.d += d.d; - if (d.d > ds || (d.d == ds && L & 1)) - { - bump_up: - while (*--s == '9') - if (s == s0) - { - k++; - *s = '0'; - break; - } - ++*s++; - } - break; - } - if (!(d.d *= 10.)) - break; - } - goto ret1; - } - - m2 = b2; - m5 = b5; - mhi = mlo = 0; - if (leftright) - { - if (mode < 2) - { - i = -#ifndef Sudden_Underflow - denorm ? be + (Bias + (P - 1) - 1 + 1) : -#endif -#ifdef IBM - 1 + 4 * P - 3 - bbits + ((bbits + be - 1) & 3); -#else - 1 + P - bbits; -#endif - } - else - { - j = ilim - 1; - if (m5 >= j) - m5 -= j; - else - { - s5 += j -= m5; - b5 += j; - m5 = 0; - } - if ((i = ilim) < 0) - { - m2 -= i; - i = 0; - } - } - b2 += i; - s2 += i; - mhi = i2b (ptr, 1); - } - if (m2 > 0 && s2 > 0) - { - i = m2 < s2 ? m2 : s2; - b2 -= i; - m2 -= i; - s2 -= i; - } - if (b5 > 0) - { - if (leftright) - { - if (m5 > 0) - { - mhi = pow5mult (ptr, mhi, m5); - b1 = mult (ptr, mhi, b); - Bfree (ptr, b); - b = b1; - } - if ((j = b5 - m5)) - b = pow5mult (ptr, b, j); - } - else - b = pow5mult (ptr, b, b5); - } - S = i2b (ptr, 1); - if (s5 > 0) - S = pow5mult (ptr, S, s5); - - /* Check for special case that d is a normalized power of 2. */ - - if (mode < 2) - { - if (!word1 (d) && !(word0 (d) & Bndry_mask) -#ifndef Sudden_Underflow - && word0(d) & Exp_mask -#endif - ) - { - /* The special case */ - b2 += Log2P; - s2 += Log2P; - spec_case = 1; - } - else - spec_case = 0; - } - - /* Arrange for convenient computation of quotients: - * shift left if necessary so divisor has 4 leading 0 bits. - * - * Perhaps we should just compute leading 28 bits of S once - * and for all and pass them and a shift to quorem, so it - * can do shifts and ors to compute the numerator for q. - */ - -#ifdef Pack_32 - if ((i = ((s5 ? 32 - hi0bits (S->_x[S->_wds - 1]) : 1) + s2) & 0x1f)) - i = 32 - i; -#else - if ((i = ((s5 ? 32 - hi0bits (S->_x[S->_wds - 1]) : 1) + s2) & 0xf)) - i = 16 - i; -#endif - if (i > 4) - { - i -= 4; - b2 += i; - m2 += i; - s2 += i; - } - else if (i < 4) - { - i += 28; - b2 += i; - m2 += i; - s2 += i; - } - if (b2 > 0) - b = lshift (ptr, b, b2); - if (s2 > 0) - S = lshift (ptr, S, s2); - if (k_check) - { - if (cmp (b, S) < 0) - { - k--; - b = multadd (ptr, b, 10, 0); /* we botched the k estimate */ - if (leftright) - mhi = multadd (ptr, mhi, 10, 0); - ilim = ilim1; - } - } - if (ilim <= 0 && mode > 2) - { - if (ilim < 0 || cmp (b, S = multadd (ptr, S, 5, 0)) <= 0) - { - /* no digits, fcvt style */ - no_digits: - k = -1 - ndigits; - goto ret; - } - one_digit: - *s++ = '1'; - k++; - goto ret; - } - if (leftright) - { - if (m2 > 0) - mhi = lshift (ptr, mhi, m2); - - /* Single precision case, */ - if (float_type) - mhi = lshift (ptr, mhi, 29); - - /* Compute mlo -- check for special case - * that d is a normalized power of 2. - */ - - mlo = mhi; - if (spec_case) - { - mhi = Balloc (ptr, mhi->_k); - Bcopy (mhi, mlo); - mhi = lshift (ptr, mhi, Log2P); - } - - for (i = 1;; i++) - { - dig = quorem (b, S) + '0'; - /* Do we yet have the shortest decimal string - * that will round to d? - */ - j = cmp (b, mlo); - delta = diff (ptr, S, mhi); - j1 = delta->_sign ? 1 : cmp (b, delta); - Bfree (ptr, delta); -#ifndef ROUND_BIASED - if (j1 == 0 && !mode && !(word1 (d) & 1)) - { - if (dig == '9') - goto round_9_up; - if (j > 0) - dig++; - *s++ = dig; - goto ret; - } -#endif - if (j < 0 || (j == 0 && !mode -#ifndef ROUND_BIASED - && !(word1 (d) & 1) -#endif - )) - { - if (j1 > 0) - { - b = lshift (ptr, b, 1); - j1 = cmp (b, S); - if ((j1 > 0 || (j1 == 0 && dig & 1)) - && dig++ == '9') - goto round_9_up; - } - *s++ = dig; - goto ret; - } - if (j1 > 0) - { - if (dig == '9') - { /* possible if i == 1 */ - round_9_up: - *s++ = '9'; - goto roundoff; - } - *s++ = dig + 1; - goto ret; - } - *s++ = dig; - if (i == ilim) - break; - b = multadd (ptr, b, 10, 0); - if (mlo == mhi) - mlo = mhi = multadd (ptr, mhi, 10, 0); - else - { - mlo = multadd (ptr, mlo, 10, 0); - mhi = multadd (ptr, mhi, 10, 0); - } - } - } - else - for (i = 1;; i++) - { - *s++ = dig = quorem (b, S) + '0'; - if (i >= ilim) - break; - b = multadd (ptr, b, 10, 0); - } - - /* Round off last digit */ - - b = lshift (ptr, b, 1); - j = cmp (b, S); - if (j > 0 || (j == 0 && dig & 1)) - { - roundoff: - while (*--s == '9') - if (s == s0) - { - k++; - *s++ = '1'; - goto ret; - } - ++*s++; - } - else - { - while (*--s == '0'); - s++; - } -ret: - Bfree (ptr, S); - if (mhi) - { - if (mlo && mlo != mhi) - Bfree (ptr, mlo); - Bfree (ptr, mhi); - } -ret1: - Bfree (ptr, b); - *s = 0; - *decpt = k + 1; - if (rve) - *rve = s; - return s0; -} - - -_VOID -_DEFUN (_dtoa, - (_d, mode, ndigits, decpt, sign, rve, buf, float_type), - double _d _AND - int mode _AND - int ndigits _AND - int *decpt _AND - int *sign _AND - char **rve _AND - char *buf _AND - int float_type) -{ - struct _Jv_reent reent; - char *p; - memset (&reent, 0, sizeof reent); - - p = _dtoa_r (&reent, _d, mode, ndigits, decpt, sign, rve, float_type); - strcpy (buf, p); - - return; -} diff --git a/libjava/java/lang/e_acos.c b/libjava/java/lang/e_acos.c deleted file mode 100644 index ee6b168..0000000 --- a/libjava/java/lang/e_acos.c +++ /dev/null @@ -1,111 +0,0 @@ - -/* @(#)e_acos.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* __ieee754_acos(x) - * Method : - * acos(x) = pi/2 - asin(x) - * acos(-x) = pi/2 + asin(x) - * For |x|<=0.5 - * acos(x) = pi/2 - (x + x*x^2*R(x^2)) (see asin.c) - * For x>0.5 - * acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2))) - * = 2asin(sqrt((1-x)/2)) - * = 2s + 2s*z*R(z) ...z=(1-x)/2, s=sqrt(z) - * = 2f + (2c + 2s*z*R(z)) - * where f=hi part of s, and c = (z-f*f)/(s+f) is the correction term - * for f so that f+c ~ sqrt(z). - * For x<-0.5 - * acos(x) = pi - 2asin(sqrt((1-|x|)/2)) - * = pi - 0.5*(s+s*z*R(z)), where z=(1-|x|)/2,s=sqrt(z) - * - * Special cases: - * if x is NaN, return x itself; - * if |x|>1, return NaN with invalid signal. - * - * Function needed: sqrt - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double -#else -static double -#endif -one= 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ -pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */ -pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ -pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */ -pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */ -pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */ -pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */ -pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */ -pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */ -pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */ -qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */ -qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */ -qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */ -qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ - -#ifdef __STDC__ - double __ieee754_acos(double x) -#else - double __ieee754_acos(x) - double x; -#endif -{ - double z,p,q,r,w,s,c,df; - int32_t hx,ix; - GET_HIGH_WORD(hx,x); - ix = hx&0x7fffffff; - if(ix>=0x3ff00000) { /* |x| >= 1 */ - uint32_t lx; - GET_LOW_WORD(lx,x); - if(((ix-0x3ff00000)|lx)==0) { /* |x|==1 */ - if(hx>0) return 0.0; /* acos(1) = 0 */ - else return pi+2.0*pio2_lo; /* acos(-1)= pi */ - } - return (x-x)/(x-x); /* acos(|x|>1) is NaN */ - } - if(ix<0x3fe00000) { /* |x| < 0.5 */ - if(ix<=0x3c600000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/ - z = x*x; - p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); - q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); - r = p/q; - return pio2_hi - (x - (pio2_lo-x*r)); - } else if (hx<0) { /* x < -0.5 */ - z = (one+x)*0.5; - p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); - q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); - s = __ieee754_sqrt(z); - r = p/q; - w = r*s-pio2_lo; - return pi - 2.0*(s+w); - } else { /* x > 0.5 */ - z = (one-x)*0.5; - s = __ieee754_sqrt(z); - df = s; - SET_LOW_WORD(df,0); - c = (z-df*df)/(s+df); - p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); - q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); - r = p/q; - w = r*s+c; - return 2.0*(df+w); - } -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/e_asin.c b/libjava/java/lang/e_asin.c deleted file mode 100644 index 90fc77ff..0000000 --- a/libjava/java/lang/e_asin.c +++ /dev/null @@ -1,120 +0,0 @@ - -/* @(#)e_asin.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* __ieee754_asin(x) - * Method : - * Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ... - * we approximate asin(x) on [0,0.5] by - * asin(x) = x + x*x^2*R(x^2) - * where - * R(x^2) is a rational approximation of (asin(x)-x)/x^3 - * and its remez error is bounded by - * |(asin(x)-x)/x^3 - R(x^2)| < 2^(-58.75) - * - * For x in [0.5,1] - * asin(x) = pi/2-2*asin(sqrt((1-x)/2)) - * Let y = (1-x), z = y/2, s := sqrt(z), and pio2_hi+pio2_lo=pi/2; - * then for x>0.98 - * asin(x) = pi/2 - 2*(s+s*z*R(z)) - * = pio2_hi - (2*(s+s*z*R(z)) - pio2_lo) - * For x<=0.98, let pio4_hi = pio2_hi/2, then - * f = hi part of s; - * c = sqrt(z) - f = (z-f*f)/(s+f) ...f+c=sqrt(z) - * and - * asin(x) = pi/2 - 2*(s+s*z*R(z)) - * = pio4_hi+(pio4-2s)-(2s*z*R(z)-pio2_lo) - * = pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c)) - * - * Special cases: - * if x is NaN, return x itself; - * if |x|>1, return NaN with invalid signal. - * - */ - - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double -#else -static double -#endif -one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ -huge = 1.000e+300, -pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ -pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */ -pio4_hi = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */ - /* coefficient for R(x^2) */ -pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */ -pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */ -pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */ -pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */ -pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */ -pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */ -qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */ -qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */ -qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */ -qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ - -#ifdef __STDC__ - double __ieee754_asin(double x) -#else - double __ieee754_asin(x) - double x; -#endif -{ - double t = 0., w, p, q, c, r, s; - int32_t hx,ix; - GET_HIGH_WORD(hx,x); - ix = hx&0x7fffffff; - if(ix>= 0x3ff00000) { /* |x|>= 1 */ - uint32_t lx; - GET_LOW_WORD(lx,x); - if(((ix-0x3ff00000)|lx)==0) - /* asin(1)=+-pi/2 with inexact */ - return x*pio2_hi+x*pio2_lo; - return (x-x)/(x-x); /* asin(|x|>1) is NaN */ - } else if (ix<0x3fe00000) { /* |x|<0.5 */ - if(ix<0x3e400000) { /* if |x| < 2**-27 */ - if(huge+x>one) return x;/* return x with inexact if x!=0*/ - } else - t = x*x; - p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5))))); - q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4))); - w = p/q; - return x+x*w; - } - /* 1> |x|>= 0.5 */ - w = one-fabs(x); - t = w*0.5; - p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5))))); - q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4))); - s = __ieee754_sqrt(t); - if(ix>=0x3FEF3333) { /* if |x| > 0.975 */ - w = p/q; - t = pio2_hi-(2.0*(s+s*w)-pio2_lo); - } else { - w = s; - SET_LOW_WORD(w,0); - c = (t-w*w)/(s+w); - r = p/q; - p = 2.0*s*r-(pio2_lo-2.0*c); - q = pio4_hi-2.0*w; - t = pio4_hi-(p-q); - } - if(hx>0) return t; else return -t; -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/e_atan2.c b/libjava/java/lang/e_atan2.c deleted file mode 100644 index c75448d..0000000 --- a/libjava/java/lang/e_atan2.c +++ /dev/null @@ -1,131 +0,0 @@ - -/* @(#)e_atan2.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ - -/* __ieee754_atan2(y,x) - * Method : - * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x). - * 2. Reduce x to positive by (if x and y are unexceptional): - * ARG (x+iy) = arctan(y/x) ... if x > 0, - * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0, - * - * Special cases: - * - * ATAN2((anything), NaN ) is NaN; - * ATAN2(NAN , (anything) ) is NaN; - * ATAN2(+-0, +(anything but NaN)) is +-0 ; - * ATAN2(+-0, -(anything but NaN)) is +-pi ; - * ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2; - * ATAN2(+-(anything but INF and NaN), +INF) is +-0 ; - * ATAN2(+-(anything but INF and NaN), -INF) is +-pi; - * ATAN2(+-INF,+INF ) is +-pi/4 ; - * ATAN2(+-INF,-INF ) is +-3pi/4; - * ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2; - * - * Constants: - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double -#else -static double -#endif -tiny = 1.0e-300, -zero = 0.0, -pi_o_4 = 7.8539816339744827900E-01, /* 0x3FE921FB, 0x54442D18 */ -pi_o_2 = 1.5707963267948965580E+00, /* 0x3FF921FB, 0x54442D18 */ -pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */ -pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */ - -#ifdef __STDC__ - double __ieee754_atan2(double y, double x) -#else - double __ieee754_atan2(y,x) - double y,x; -#endif -{ - double z; - int32_t k,m,hx,hy,ix,iy; - uint32_t lx,ly; - - EXTRACT_WORDS(hx,lx,x); - ix = hx&0x7fffffff; - EXTRACT_WORDS(hy,ly,y); - iy = hy&0x7fffffff; - if(((ix|((lx|-lx)>>31))>0x7ff00000)|| - ((iy|((ly|-ly)>>31))>0x7ff00000)) /* x or y is NaN */ - return x+y; - if(((hx-0x3ff00000)|lx)==0) return atan(y); /* x=1.0 */ - m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */ - - /* when y = 0 */ - if((iy|ly)==0) { - switch(m) { - case 0: - case 1: return y; /* atan(+-0,+anything)=+-0 */ - case 2: return pi+tiny;/* atan(+0,-anything) = pi */ - case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */ - } - } - /* when x = 0 */ - if((ix|lx)==0) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny; - - /* when x is INF */ - if(ix==0x7ff00000) { - if(iy==0x7ff00000) { - switch(m) { - case 0: return pi_o_4+tiny;/* atan(+INF,+INF) */ - case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */ - case 2: return 3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/ - case 3: return -3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/ - } - } else { - switch(m) { - case 0: return zero ; /* atan(+...,+INF) */ - case 1: return -zero ; /* atan(-...,+INF) */ - case 2: return pi+tiny ; /* atan(+...,-INF) */ - case 3: return -pi-tiny ; /* atan(-...,-INF) */ - } - } - } - /* when y is INF */ - if(iy==0x7ff00000) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny; - - /* compute y/x */ - k = (iy-ix)>>20; - if(k > 60) z=pi_o_2+0.5*pi_lo; /* |y/x| > 2**60 */ - else if(hx<0&&k<-60) z=0.0; /* |y|/x < -2**60 */ - else z=atan(fabs(y/x)); /* safe to do y/x */ - switch (m) { - case 0: return z ; /* atan(+,+) */ - case 1: { - uint32_t zh; - GET_HIGH_WORD(zh,z); - SET_HIGH_WORD(z,zh ^ 0x80000000); - } - return z ; /* atan(-,+) */ - case 2: return pi-(z-pi_lo);/* atan(+,-) */ - default: /* case 3 */ - return (z-pi_lo)-pi;/* atan(-,-) */ - } -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/e_exp.c b/libjava/java/lang/e_exp.c deleted file mode 100644 index ad37f86..0000000 --- a/libjava/java/lang/e_exp.c +++ /dev/null @@ -1,167 +0,0 @@ - -/* @(#)e_exp.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* __ieee754_exp(x) - * Returns the exponential of x. - * - * Method - * 1. Argument reduction: - * Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658. - * Given x, find r and integer k such that - * - * x = k*ln2 + r, |r| <= 0.5*ln2. - * - * Here r will be represented as r = hi-lo for better - * accuracy. - * - * 2. Approximation of exp(r) by a special rational function on - * the interval [0,0.34658]: - * Write - * R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ... - * We use a special Reme algorithm on [0,0.34658] to generate - * a polynomial of degree 5 to approximate R. The maximum error - * of this polynomial approximation is bounded by 2**-59. In - * other words, - * R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5 - * (where z=r*r, and the values of P1 to P5 are listed below) - * and - * | 5 | -59 - * | 2.0+P1*z+...+P5*z - R(z) | <= 2 - * | | - * The computation of exp(r) thus becomes - * 2*r - * exp(r) = 1 + ------- - * R - r - * r*R1(r) - * = 1 + r + ----------- (for better accuracy) - * 2 - R1(r) - * where - * 2 4 10 - * R1(r) = r - (P1*r + P2*r + ... + P5*r ). - * - * 3. Scale back to obtain exp(x): - * From step 1, we have - * exp(x) = 2^k * exp(r) - * - * Special cases: - * exp(INF) is INF, exp(NaN) is NaN; - * exp(-INF) is 0, and - * for finite argument, only exp(0)=1 is exact. - * - * Accuracy: - * according to an error analysis, the error is always less than - * 1 ulp (unit in the last place). - * - * Misc. info. - * For IEEE double - * if x > 7.09782712893383973096e+02 then exp(x) overflow - * if x < -7.45133219101941108420e+02 then exp(x) underflow - * - * Constants: - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double -#else -static double -#endif -one = 1.0, -halF[2] = {0.5,-0.5,}, -huge = 1.0e+300, -twom1000= 9.33263618503218878990e-302, /* 2**-1000=0x01700000,0*/ -o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */ -u_threshold= -7.45133219101941108420e+02, /* 0xc0874910, 0xD52D3051 */ -ln2HI[2] ={ 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */ - -6.93147180369123816490e-01,},/* 0xbfe62e42, 0xfee00000 */ -ln2LO[2] ={ 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */ - -1.90821492927058770002e-10,},/* 0xbdea39ef, 0x35793c76 */ -invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */ -P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */ -P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */ -P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ -P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ -P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */ - - -#ifdef __STDC__ - double __ieee754_exp(double x) /* default IEEE double exp */ -#else - double __ieee754_exp(x) /* default IEEE double exp */ - double x; -#endif -{ - double y,hi = 0., lo = 0.,c,t; - int32_t k = 0, xsb; - uint32_t hx; - - GET_HIGH_WORD(hx,x); - xsb = (hx>>31)&1; /* sign bit of x */ - hx &= 0x7fffffff; /* high word of |x| */ - - /* filter out non-finite argument */ - if(hx >= 0x40862E42) { /* if |x|>=709.78... */ - if(hx>=0x7ff00000) { - uint32_t lx; - GET_LOW_WORD(lx,x); - if(((hx&0xfffff)|lx)!=0) - return x+x; /* NaN */ - else return (xsb==0)? x:0.0; /* exp(+-inf)={inf,0} */ - } - if(x > o_threshold) return huge*huge; /* overflow */ - if(x < u_threshold) return twom1000*twom1000; /* underflow */ - } - - /* argument reduction */ - if(hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */ - if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ - hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb; - } else { - k = invln2*x+halF[xsb]; - t = k; - hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */ - lo = t*ln2LO[0]; - } - x = hi - lo; - } - else if(hx < 0x3e300000) { /* when |x|<2**-28 */ - if(huge+x>one) return one+x;/* trigger inexact */ - } - else k = 0; - - /* x is now in primary range */ - t = x*x; - c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); - if(k==0) return one-((x*c)/(c-2.0)-x); - else y = one-((lo-(x*c)/(2.0-c))-hi); - if(k >= -1021) { - uint32_t hy; - GET_HIGH_WORD(hy,y); - SET_HIGH_WORD(y,hy+(k<<20)); /* add k to y's exponent */ - return y; - } else { - uint32_t hy; - GET_HIGH_WORD(hy,y); - SET_HIGH_WORD(y,hy+((k+1000)<<20)); /* add k to y's exponent */ - return y*twom1000; - } -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/e_fmod.c b/libjava/java/lang/e_fmod.c deleted file mode 100644 index 1cf0990..0000000 --- a/libjava/java/lang/e_fmod.c +++ /dev/null @@ -1,140 +0,0 @@ - -/* @(#)e_fmod.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* - * __ieee754_fmod(x,y) - * Return x mod y in exact arithmetic - * Method: shift and subtract - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double one = 1.0, Zero[] = {0.0, -0.0,}; -#else -static double one = 1.0, Zero[] = {0.0, -0.0,}; -#endif - -#ifdef __STDC__ - double __ieee754_fmod(double x, double y) -#else - double __ieee754_fmod(x,y) - double x,y ; -#endif -{ - int32_t n,hx,hy,hz,ix,iy,sx,i; - uint32_t lx,ly,lz; - - EXTRACT_WORDS(hx,lx,x); - EXTRACT_WORDS(hy,ly,y); - sx = hx&0x80000000; /* sign of x */ - hx ^=sx; /* |x| */ - hy &= 0x7fffffff; /* |y| */ - - /* purge off exception values */ - if((hy|ly)==0||(hx>=0x7ff00000)|| /* y=0,or x not finite */ - ((hy|((ly|-ly)>>31))>0x7ff00000)) /* or y is NaN */ - return (x*y)/(x*y); - if(hx<=hy) { - if((hx<hy)||(lx<ly)) return x; /* |x|<|y| return x */ - if(lx==ly) - return Zero[(uint32_t)sx>>31]; /* |x|=|y| return x*0*/ - } - - /* determine ix = ilogb(x) */ - if(hx<0x00100000) { /* subnormal x */ - if(hx==0) { - for (ix = -1043, i=lx; i>0; i<<=1) ix -=1; - } else { - for (ix = -1022,i=(hx<<11); i>0; i<<=1) ix -=1; - } - } else ix = (hx>>20)-1023; - - /* determine iy = ilogb(y) */ - if(hy<0x00100000) { /* subnormal y */ - if(hy==0) { - for (iy = -1043, i=ly; i>0; i<<=1) iy -=1; - } else { - for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1; - } - } else iy = (hy>>20)-1023; - - /* set up {hx,lx}, {hy,ly} and align y to x */ - if(ix >= -1022) - hx = 0x00100000|(0x000fffff&hx); - else { /* subnormal x, shift x to normal */ - n = -1022-ix; - if(n<=31) { - hx = (hx<<n)|(lx>>(32-n)); - lx <<= n; - } else { - hx = lx<<(n-32); - lx = 0; - } - } - if(iy >= -1022) - hy = 0x00100000|(0x000fffff&hy); - else { /* subnormal y, shift y to normal */ - n = -1022-iy; - if(n<=31) { - hy = (hy<<n)|(ly>>(32-n)); - ly <<= n; - } else { - hy = ly<<(n-32); - ly = 0; - } - } - - /* fix point fmod */ - n = ix - iy; - while(n--) { - hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1; - if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;} - else { - if((hz|lz)==0) /* return sign(x)*0 */ - return Zero[(uint32_t)sx>>31]; - hx = hz+hz+(lz>>31); lx = lz+lz; - } - } - hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1; - if(hz>=0) {hx=hz;lx=lz;} - - /* convert back to floating value and restore the sign */ - if((hx|lx)==0) /* return sign(x)*0 */ - return Zero[(uint32_t)sx>>31]; - while(hx<0x00100000) { /* normalize x */ - hx = hx+hx+(lx>>31); lx = lx+lx; - iy -= 1; - } - if(iy>= -1022) { /* normalize output */ - hx = ((hx-0x00100000)|((iy+1023)<<20)); - INSERT_WORDS(x,hx|sx,lx); - } else { /* subnormal output */ - n = -1022 - iy; - if(n<=20) { - lx = (lx>>n)|((uint32_t)hx<<(32-n)); - hx >>= n; - } else if (n<=31) { - lx = (hx<<(32-n))|(lx>>n); hx = sx; - } else { - lx = hx>>(n-32); hx = sx; - } - INSERT_WORDS(x,hx|sx,lx); - x *= one; /* create necessary signal */ - } - return x; /* exact output */ -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/e_log.c b/libjava/java/lang/e_log.c deleted file mode 100644 index 093473e..0000000 --- a/libjava/java/lang/e_log.c +++ /dev/null @@ -1,152 +0,0 @@ - -/* @(#)e_log.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* __ieee754_log(x) - * Return the logrithm of x - * - * Method : - * 1. Argument Reduction: find k and f such that - * x = 2^k * (1+f), - * where sqrt(2)/2 < 1+f < sqrt(2) . - * - * 2. Approximation of log(1+f). - * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) - * = 2s + 2/3 s**3 + 2/5 s**5 + ....., - * = 2s + s*R - * We use a special Reme algorithm on [0,0.1716] to generate - * a polynomial of degree 14 to approximate R The maximum error - * of this polynomial approximation is bounded by 2**-58.45. In - * other words, - * 2 4 6 8 10 12 14 - * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s - * (the values of Lg1 to Lg7 are listed in the program) - * and - * | 2 14 | -58.45 - * | Lg1*s +...+Lg7*s - R(z) | <= 2 - * | | - * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2. - * In order to guarantee error in log below 1ulp, we compute log - * by - * log(1+f) = f - s*(f - R) (if f is not too large) - * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy) - * - * 3. Finally, log(x) = k*ln2 + log(1+f). - * = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo))) - * Here ln2 is split into two floating point number: - * ln2_hi + ln2_lo, - * where n*ln2_hi is always exact for |n| < 2000. - * - * Special cases: - * log(x) is NaN with signal if x < 0 (including -INF) ; - * log(+INF) is +INF; log(0) is -INF with signal; - * log(NaN) is that NaN with no signal. - * - * Accuracy: - * according to an error analysis, the error is always less than - * 1 ulp (unit in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double -#else -static double -#endif -ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ -ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */ -two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */ -Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ -Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ -Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ -Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ -Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ -Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ -Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ - -#ifdef __STDC__ -static const double zero = 0.0; -#else -static double zero = 0.0; -#endif - -#ifdef __STDC__ - double __ieee754_log(double x) -#else - double __ieee754_log(x) - double x; -#endif -{ - double hfsq,f,s,z,R,w,t1,t2,dk; - int32_t k,hx,i,j; - uint32_t lx; - - EXTRACT_WORDS(hx,lx,x); - - k=0; - if (hx < 0x00100000) { /* x < 2**-1022 */ - if (((hx&0x7fffffff)|lx)==0) - return -two54/zero; /* log(+-0)=-inf */ - if (hx<0) return (x-x)/zero; /* log(-#) = NaN */ - k -= 54; x *= two54; /* subnormal number, scale up x */ - GET_HIGH_WORD(hx,x); - } - if (hx >= 0x7ff00000) return x+x; - k += (hx>>20)-1023; - hx &= 0x000fffff; - i = (hx+0x95f64)&0x100000; - SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */ - k += (i>>20); - f = x-1.0; - if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */ - if(f==zero) { - if(k==0) - return zero; - else { - dk=(double)k; - return dk*ln2_hi+dk*ln2_lo; - } - } - R = f*f*(0.5-0.33333333333333333*f); - if(k==0) return f-R; else {dk=(double)k; - return dk*ln2_hi-((R-dk*ln2_lo)-f);} - } - s = f/(2.0+f); - dk = (double)k; - z = s*s; - i = hx-0x6147a; - w = z*z; - j = 0x6b851-hx; - t1= w*(Lg2+w*(Lg4+w*Lg6)); - t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); - i |= j; - R = t2+t1; - if(i>0) { - hfsq=0.5*f*f; - if(k==0) return f-(hfsq-s*(hfsq+R)); else - return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f); - } else { - if(k==0) return f-s*(f-R); else - return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f); - } -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/e_pow.c b/libjava/java/lang/e_pow.c deleted file mode 100644 index b21c0e9..0000000 --- a/libjava/java/lang/e_pow.c +++ /dev/null @@ -1,312 +0,0 @@ - -/* @(#)e_pow.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* __ieee754_pow(x,y) return x**y - * - * n - * Method: Let x = 2 * (1+f) - * 1. Compute and return log2(x) in two pieces: - * log2(x) = w1 + w2, - * where w1 has 53-24 = 29 bit trailing zeros. - * 2. Perform y*log2(x) = n+y' by simulating muti-precision - * arithmetic, where |y'|<=0.5. - * 3. Return x**y = 2**n*exp(y'*log2) - * - * Special cases: - * 1. (anything) ** 0 is 1 - * 2. (anything) ** 1 is itself - * 3. (anything) ** NAN is NAN - * 4. NAN ** (anything except 0) is NAN - * 5. +-(|x| > 1) ** +INF is +INF - * 6. +-(|x| > 1) ** -INF is +0 - * 7. +-(|x| < 1) ** +INF is +0 - * 8. +-(|x| < 1) ** -INF is +INF - * 9. +-1 ** +-INF is NAN - * 10. +0 ** (+anything except 0, NAN) is +0 - * 11. -0 ** (+anything except 0, NAN, odd integer) is +0 - * 12. +0 ** (-anything except 0, NAN) is +INF - * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF - * 14. -0 ** (odd integer) = -( +0 ** (odd integer) ) - * 15. +INF ** (+anything except 0,NAN) is +INF - * 16. +INF ** (-anything except 0,NAN) is +0 - * 17. -INF ** (anything) = -0 ** (-anything) - * 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer) - * 19. (-anything except 0 and inf) ** (non-integer) is NAN - * - * Accuracy: - * pow(x,y) returns x**y nearly rounded. In particular - * pow(integer,integer) - * always returns the correct integer provided it is - * representable. - * - * Constants : - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double -#else -static double -#endif -bp[] = {1.0, 1.5,}, -dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */ -dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */ -zero = 0.0, -one = 1.0, -two = 2.0, -two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */ -huge = 1.0e300, -tiny = 1.0e-300, - /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ -L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */ -L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */ -L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */ -L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */ -L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */ -L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */ -P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */ -P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */ -P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ -P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ -P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */ -lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ -lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */ -lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */ -ovt = 8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */ -cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */ -cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */ -cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/ -ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */ -ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/ -ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ - -#ifdef __STDC__ - double __ieee754_pow(double x, double y) -#else - double __ieee754_pow(x,y) - double x, y; -#endif -{ - double z,ax,z_h,z_l,p_h,p_l; - double y1,t1,t2,r,s,t,u,v,w; - int32_t i,j,k,yisint,n; - int32_t hx,hy,ix,iy; - uint32_t lx,ly; - - EXTRACT_WORDS(hx,lx,x); - EXTRACT_WORDS(hy,ly,y); - ix = hx&0x7fffffff; iy = hy&0x7fffffff; - - /* y==zero: x**0 = 1 */ - if((iy|ly)==0) return one; - - /* +-NaN return x+y */ - if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) || - iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) - return x+y; - - /* determine if y is an odd int when x < 0 - * yisint = 0 ... y is not an integer - * yisint = 1 ... y is an odd int - * yisint = 2 ... y is an even int - */ - yisint = 0; - if(hx<0) { - if(iy>=0x43400000) yisint = 2; /* even integer y */ - else if(iy>=0x3ff00000) { - k = (iy>>20)-0x3ff; /* exponent */ - if(k>20) { - j = ly>>(52-k); - if((uint32_t)(j<<(52-k))==ly) yisint = 2-(j&1); - } else if(ly==0) { - j = iy>>(20-k); - if((j<<(20-k))==iy) yisint = 2-(j&1); - } - } - } - - /* special value of y */ - if(ly==0) { - if (iy==0x7ff00000) { /* y is +-inf */ - if(((ix-0x3ff00000)|lx)==0) - return y - y; /* inf**+-1 is NaN */ - else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */ - return (hy>=0)? y: zero; - else /* (|x|<1)**-,+inf = inf,0 */ - return (hy<0)?-y: zero; - } - if(iy==0x3ff00000) { /* y is +-1 */ - if(hy<0) return one/x; else return x; - } - if(hy==0x40000000) return x*x; /* y is 2 */ - if(hy==0x3fe00000) { /* y is 0.5 */ - if(hx>=0) /* x >= +0 */ - return __ieee754_sqrt(x); - } - } - - ax = fabs(x); - /* special value of x */ - if(lx==0) { - if(ix==0x7ff00000||ix==0||ix==0x3ff00000){ - z = ax; /*x is +-0,+-inf,+-1*/ - if(hy<0) z = one/z; /* z = (1/|x|) */ - if(hx<0) { - if(((ix-0x3ff00000)|yisint)==0) { - z = (z-z)/(z-z); /* (-1)**non-int is NaN */ - } else if(yisint==1) - z = -z; /* (x<0)**odd = -(|x|**odd) */ - } - return z; - } - } - - /* (x<0)**(non-int) is NaN */ - /* GCJ LOCAL: This used to be - if((((hx>>31)+1)|yisint)==0) return (x-x)/(x-x); - but ANSI C says a right shift of a signed negative quantity is - implementation defined. */ - if(((((uint32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x); - - /* |y| is huge */ - if(iy>0x41e00000) { /* if |y| > 2**31 */ - if(iy>0x43f00000){ /* if |y| > 2**64, must o/uflow */ - if(ix<=0x3fefffff) return (hy<0)? huge*huge:tiny*tiny; - if(ix>=0x3ff00000) return (hy>0)? huge*huge:tiny*tiny; - } - /* over/underflow if x is not close to one */ - if(ix<0x3fefffff) return (hy<0)? huge*huge:tiny*tiny; - if(ix>0x3ff00000) return (hy>0)? huge*huge:tiny*tiny; - /* now |1-x| is tiny <= 2**-20, suffice to compute - log(x) by x-x^2/2+x^3/3-x^4/4 */ - t = x-1; /* t has 20 trailing zeros */ - w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25)); - u = ivln2_h*t; /* ivln2_h has 21 sig. bits */ - v = t*ivln2_l-w*ivln2; - t1 = u+v; - SET_LOW_WORD(t1,0); - t2 = v-(t1-u); - } else { - double s2,s_h,s_l,t_h,t_l; - n = 0; - /* take care subnormal number */ - if(ix<0x00100000) - {ax *= two53; n -= 53; GET_HIGH_WORD(ix,ax); } - n += ((ix)>>20)-0x3ff; - j = ix&0x000fffff; - /* determine interval */ - ix = j|0x3ff00000; /* normalize ix */ - if(j<=0x3988E) k=0; /* |x|<sqrt(3/2) */ - else if(j<0xBB67A) k=1; /* |x|<sqrt(3) */ - else {k=0;n+=1;ix -= 0x00100000;} - SET_HIGH_WORD(ax,ix); - - /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ - u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */ - v = one/(ax+bp[k]); - s = u*v; - s_h = s; - SET_LOW_WORD(s_h,0); - /* t_h=ax+bp[k] High */ - t_h = zero; - SET_HIGH_WORD(t_h,((ix>>1)|0x20000000)+0x00080000+(k<<18)); - t_l = ax - (t_h-bp[k]); - s_l = v*((u-s_h*t_h)-s_h*t_l); - /* compute log(ax) */ - s2 = s*s; - r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); - r += s_l*(s_h+s); - s2 = s_h*s_h; - t_h = 3.0+s2+r; - SET_LOW_WORD(t_h,0); - t_l = r-((t_h-3.0)-s2); - /* u+v = s*(1+...) */ - u = s_h*t_h; - v = s_l*t_h+t_l*s; - /* 2/(3log2)*(s+...) */ - p_h = u+v; - SET_LOW_WORD(p_h,0); - p_l = v-(p_h-u); - z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ - z_l = cp_l*p_h+p_l*cp+dp_l[k]; - /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ - t = (double)n; - t1 = (((z_h+z_l)+dp_h[k])+t); - SET_LOW_WORD(t1,0); - t2 = z_l-(((t1-t)-dp_h[k])-z_h); - } - - s = one; /* s (sign of result -ve**odd) = -1 else = 1 */ - if(((((uint32_t)hx>>31)-1)|(yisint-1))==0) - s = -one;/* (-ve)**(odd int) */ - - /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ - y1 = y; - SET_LOW_WORD(y1,0); - p_l = (y-y1)*t1+y*t2; - p_h = y1*t1; - z = p_l+p_h; - EXTRACT_WORDS(j,i,z); - if (j>=0x40900000) { /* z >= 1024 */ - if(((j-0x40900000)|i)!=0) /* if z > 1024 */ - return s*huge*huge; /* overflow */ - else { - if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */ - } - } else if((j&0x7fffffff)>=0x4090cc00 ) { /* z <= -1075 */ - if(((j-0xc090cc00)|i)!=0) /* z < -1075 */ - return s*tiny*tiny; /* underflow */ - else { - if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */ - } - } - /* - * compute 2**(p_h+p_l) - */ - i = j&0x7fffffff; - k = (i>>20)-0x3ff; - n = 0; - if(i>0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */ - n = j+(0x00100000>>(k+1)); - k = ((n&0x7fffffff)>>20)-0x3ff; /* new k for n */ - t = zero; - SET_HIGH_WORD(t,n&~(0x000fffff>>k)); - n = ((n&0x000fffff)|0x00100000)>>(20-k); - if(j<0) n = -n; - p_h -= t; - } - t = p_l+p_h; - SET_LOW_WORD(t,0); - u = t*lg2_h; - v = (p_l-(t-p_h))*lg2+t*lg2_l; - z = u+v; - w = v-(z-u); - t = z*z; - t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); - r = (z*t1)/(t1-two)-(w+z*w); - z = one-(r-z); - GET_HIGH_WORD(j,z); - j += (n<<20); - if((j>>20)<=0) z = scalbn(z,(int)n); /* subnormal output */ - else SET_HIGH_WORD(z,j); - return s*z; -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/e_rem_pio2.c b/libjava/java/lang/e_rem_pio2.c deleted file mode 100644 index 543234c..0000000 --- a/libjava/java/lang/e_rem_pio2.c +++ /dev/null @@ -1,185 +0,0 @@ - -/* @(#)e_rem_pio2.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ - -/* __ieee754_rem_pio2(x,y) - * - * return the remainder of x rem pi/2 in y[0]+y[1] - * use __kernel_rem_pio2() - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -/* - * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi - */ -#ifdef __STDC__ -static const int32_t two_over_pi[] = { -#else -static int32_t two_over_pi[] = { -#endif -0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, -0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, -0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, -0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, -0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, -0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, -0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, -0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, -0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, -0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, -0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B, -}; - -#ifdef __STDC__ -static const int32_t npio2_hw[] = { -#else -static int32_t npio2_hw[] = { -#endif -0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C, -0x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C, -0x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A, -0x403DD85A, 0x403F6A7A, 0x40407E4C, 0x4041475C, 0x4042106C, 0x4042D97C, -0x4043A28C, 0x40446B9C, 0x404534AC, 0x4045FDBB, 0x4046C6CB, 0x40478FDB, -0x404858EB, 0x404921FB, -}; - -/* - * invpio2: 53 bits of 2/pi - * pio2_1: first 33 bit of pi/2 - * pio2_1t: pi/2 - pio2_1 - * pio2_2: second 33 bit of pi/2 - * pio2_2t: pi/2 - (pio2_1+pio2_2) - * pio2_3: third 33 bit of pi/2 - * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3) - */ - -#ifdef __STDC__ -static const double -#else -static double -#endif -zero = 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ -half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ -two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */ -invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */ -pio2_1 = 1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */ -pio2_1t = 6.07710050650619224932e-11, /* 0x3DD0B461, 0x1A626331 */ -pio2_2 = 6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */ -pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */ -pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */ -pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */ - -#ifdef __STDC__ - int32_t __ieee754_rem_pio2(double x, double *y) -#else - int32_t __ieee754_rem_pio2(x,y) - double x,y[]; -#endif -{ - double z = 0., w, t, r, fn; - double tx[3]; - int32_t i,j,n,ix,hx; - int e0,nx; - uint32_t low; - - GET_HIGH_WORD(hx,x); /* high word of x */ - ix = hx&0x7fffffff; - if(ix<=0x3fe921fb) /* |x| ~<= pi/4 , no need for reduction */ - {y[0] = x; y[1] = 0; return 0;} - if(ix<0x4002d97c) { /* |x| < 3pi/4, special case with n=+-1 */ - if(hx>0) { - z = x - pio2_1; - if(ix!=0x3ff921fb) { /* 33+53 bit pi is good enough */ - y[0] = z - pio2_1t; - y[1] = (z-y[0])-pio2_1t; - } else { /* near pi/2, use 33+33+53 bit pi */ - z -= pio2_2; - y[0] = z - pio2_2t; - y[1] = (z-y[0])-pio2_2t; - } - return 1; - } else { /* negative x */ - z = x + pio2_1; - if(ix!=0x3ff921fb) { /* 33+53 bit pi is good enough */ - y[0] = z + pio2_1t; - y[1] = (z-y[0])+pio2_1t; - } else { /* near pi/2, use 33+33+53 bit pi */ - z += pio2_2; - y[0] = z + pio2_2t; - y[1] = (z-y[0])+pio2_2t; - } - return -1; - } - } - if(ix<=0x413921fb) { /* |x| ~<= 2^19*(pi/2), medium size */ - t = fabs(x); - n = (int32_t) (t*invpio2+half); - fn = (double)n; - r = t-fn*pio2_1; - w = fn*pio2_1t; /* 1st round good to 85 bit */ - if(n<32&&ix!=npio2_hw[n-1]) { - y[0] = r-w; /* quick check no cancellation */ - } else { - uint32_t high; - j = ix>>20; - y[0] = r-w; - GET_HIGH_WORD(high,y[0]); - i = j-((high>>20)&0x7ff); - if(i>16) { /* 2nd iteration needed, good to 118 */ - t = r; - w = fn*pio2_2; - r = t-w; - w = fn*pio2_2t-((t-r)-w); - y[0] = r-w; - GET_HIGH_WORD(high,y[0]); - i = j-((high>>20)&0x7ff); - if(i>49) { /* 3rd iteration need, 151 bits acc */ - t = r; /* will cover all possible cases */ - w = fn*pio2_3; - r = t-w; - w = fn*pio2_3t-((t-r)-w); - y[0] = r-w; - } - } - } - y[1] = (r-y[0])-w; - if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} - else return n; - } - /* - * all other (large) arguments - */ - if(ix>=0x7ff00000) { /* x is inf or NaN */ - y[0]=y[1]=x-x; return 0; - } - /* set z = scalbn(|x|,ilogb(x)-23) */ - GET_LOW_WORD(low,x); - SET_LOW_WORD(z,low); - e0 = (int)((ix>>20)-1046); /* e0 = ilogb(z)-23; */ - SET_HIGH_WORD(z, ix - ((int32_t)e0<<20)); - for(i=0;i<2;i++) { - tx[i] = (double)((int32_t)(z)); - z = (z-tx[i])*two24; - } - tx[2] = z; - nx = 3; - while(tx[nx-1]==zero) nx--; /* skip zero term */ - n = __kernel_rem_pio2(tx,y,e0,nx,2,two_over_pi); - if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} - return n; -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/e_remainder.c b/libjava/java/lang/e_remainder.c deleted file mode 100644 index 4716d8d..0000000 --- a/libjava/java/lang/e_remainder.c +++ /dev/null @@ -1,80 +0,0 @@ - -/* @(#)e_remainder.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* __ieee754_remainder(x,p) - * Return : - * returns x REM p = x - [x/p]*p as if in infinite - * precise arithmetic, where [x/p] is the (infinite bit) - * integer nearest x/p (in half way case choose the even one). - * Method : - * Based on fmod() return x-[x/p]chopped*p exactlp. - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double zero = 0.0; -#else -static double zero = 0.0; -#endif - - -#ifdef __STDC__ - double __ieee754_remainder(double x, double p) -#else - double __ieee754_remainder(x,p) - double x,p; -#endif -{ - int32_t hx,hp; - uint32_t sx,lx,lp; - double p_half; - - EXTRACT_WORDS(hx,lx,x); - EXTRACT_WORDS(hp,lp,p); - sx = hx&0x80000000; - hp &= 0x7fffffff; - hx &= 0x7fffffff; - - /* purge off exception values */ - if((hp|lp)==0) return (x*p)/(x*p); /* p = 0 */ - if((hx>=0x7ff00000)|| /* x not finite */ - ((hp>=0x7ff00000)&& /* p is NaN */ - (((hp-0x7ff00000)|lp)!=0))) - return (x*p)/(x*p); - - - if (hp<=0x7fdfffff) x = __ieee754_fmod(x,p+p); /* now x < 2p */ - if (((hx-hp)|(lx-lp))==0) return zero*x; - x = fabs(x); - p = fabs(p); - if (hp<0x00200000) { - if(x+x>p) { - x-=p; - if(x+x>=p) x -= p; - } - } else { - p_half = 0.5*p; - if(x>p_half) { - x-=p; - if(x>=p_half) x -= p; - } - } - GET_HIGH_WORD(hx,x); - SET_HIGH_WORD(x,hx^sx); - return x; -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/e_scalb.c b/libjava/java/lang/e_scalb.c deleted file mode 100644 index 0bb924b..0000000 --- a/libjava/java/lang/e_scalb.c +++ /dev/null @@ -1,55 +0,0 @@ - -/* @(#)e_scalb.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* - * __ieee754_scalb(x, fn) is provide for - * passing various standard test suite. One - * should use scalbn() instead. - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef _SCALB_INT -#ifdef __STDC__ - double __ieee754_scalb(double x, int fn) -#else - double __ieee754_scalb(x,fn) - double x; int fn; -#endif -#else -#ifdef __STDC__ - double __ieee754_scalb(double x, double fn) -#else - double __ieee754_scalb(x,fn) - double x, fn; -#endif -#endif -{ -#ifdef _SCALB_INT - return scalbn(x,fn); -#else - if (isnan(x)||isnan(fn)) return x*fn; - if (!finite(fn)) { - if(fn>0.0) return x*fn; - else return x/(-fn); - } - if (rint(fn)!=fn) return (fn-fn)/(fn-fn); - if ( fn > 65000.0) return scalbn(x, 65000); - if (-fn > 65000.0) return scalbn(x,-65000); - return scalbn(x,(int)fn); -#endif -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/e_sqrt.c b/libjava/java/lang/e_sqrt.c deleted file mode 100644 index 1d566a0..0000000 --- a/libjava/java/lang/e_sqrt.c +++ /dev/null @@ -1,452 +0,0 @@ - -/* @(#)e_sqrt.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* __ieee754_sqrt(x) - * Return correctly rounded sqrt. - * ------------------------------------------ - * | Use the hardware sqrt if you have one | - * ------------------------------------------ - * Method: - * Bit by bit method using integer arithmetic. (Slow, but portable) - * 1. Normalization - * Scale x to y in [1,4) with even powers of 2: - * find an integer k such that 1 <= (y=x*2^(2k)) < 4, then - * sqrt(x) = 2^k * sqrt(y) - * 2. Bit by bit computation - * Let q = sqrt(y) truncated to i bit after binary point (q = 1), - * i 0 - * i+1 2 - * s = 2*q , and y = 2 * ( y - q ). (1) - * i i i i - * - * To compute q from q , one checks whether - * i+1 i - * - * -(i+1) 2 - * (q + 2 ) <= y. (2) - * i - * -(i+1) - * If (2) is false, then q = q ; otherwise q = q + 2 . - * i+1 i i+1 i - * - * With some algebric manipulation, it is not difficult to see - * that (2) is equivalent to - * -(i+1) - * s + 2 <= y (3) - * i i - * - * The advantage of (3) is that s and y can be computed by - * i i - * the following recurrence formula: - * if (3) is false - * - * s = s , y = y ; (4) - * i+1 i i+1 i - * - * otherwise, - * -i -(i+1) - * s = s + 2 , y = y - s - 2 (5) - * i+1 i i+1 i i - * - * One may easily use induction to prove (4) and (5). - * Note. Since the left hand side of (3) contain only i+2 bits, - * it does not necessary to do a full (53-bit) comparison - * in (3). - * 3. Final rounding - * After generating the 53 bits result, we compute one more bit. - * Together with the remainder, we can decide whether the - * result is exact, bigger than 1/2ulp, or less than 1/2ulp - * (it will never equal to 1/2ulp). - * The rounding mode can be detected by checking whether - * huge + tiny is equal to huge, and whether huge - tiny is - * equal to huge for some floating point number "huge" and "tiny". - * - * Special cases: - * sqrt(+-0) = +-0 ... exact - * sqrt(inf) = inf - * sqrt(-ve) = NaN ... with invalid signal - * sqrt(NaN) = NaN ... with invalid signal for signaling NaN - * - * Other methods : see the appended file at the end of the program below. - *--------------- - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double one = 1.0, tiny=1.0e-300; -#else -static double one = 1.0, tiny=1.0e-300; -#endif - -#ifdef __STDC__ - double __ieee754_sqrt(double x) -#else - double __ieee754_sqrt(x) - double x; -#endif -{ - double z; - int32_t sign = (int)0x80000000; - uint32_t r,t1,s1,ix1,q1; - int32_t ix0,s0,q,m,t,i; - - EXTRACT_WORDS(ix0,ix1,x); - - /* take care of Inf and NaN */ - if((ix0&0x7ff00000)==0x7ff00000) { - return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf - sqrt(-inf)=sNaN */ - } - /* take care of zero */ - if(ix0<=0) { - if(((ix0&(~sign))|ix1)==0) return x;/* sqrt(+-0) = +-0 */ - else if(ix0<0) - return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ - } - /* normalize x */ - m = (ix0>>20); - if(m==0) { /* subnormal x */ - while(ix0==0) { - m -= 21; - ix0 |= (ix1>>11); ix1 <<= 21; - } - for(i=0;(ix0&0x00100000)==0;i++) ix0<<=1; - m -= i-1; - ix0 |= (ix1>>(32-i)); - ix1 <<= i; - } - m -= 1023; /* unbias exponent */ - ix0 = (ix0&0x000fffff)|0x00100000; - if(m&1){ /* odd m, double x to make it even */ - ix0 += ix0 + ((ix1&sign)>>31); - ix1 += ix1; - } - m >>= 1; /* m = [m/2] */ - - /* generate sqrt(x) bit by bit */ - ix0 += ix0 + ((ix1&sign)>>31); - ix1 += ix1; - q = q1 = s0 = s1 = 0; /* [q,q1] = sqrt(x) */ - r = 0x00200000; /* r = moving bit from right to left */ - - while(r!=0) { - t = s0+r; - if(t<=ix0) { - s0 = t+r; - ix0 -= t; - q += r; - } - ix0 += ix0 + ((ix1&sign)>>31); - ix1 += ix1; - r>>=1; - } - - r = sign; - while(r!=0) { - t1 = s1+r; - t = s0; - if((t<ix0)||((t==ix0)&&(t1<=ix1))) { - s1 = t1+r; - if(((t1&sign)==(uint32_t)sign)&&(s1&sign)==0) s0 += 1; - ix0 -= t; - if (ix1 < t1) ix0 -= 1; - ix1 -= t1; - q1 += r; - } - ix0 += ix0 + ((ix1&sign)>>31); - ix1 += ix1; - r>>=1; - } - - /* use floating add to find out rounding direction */ - if((ix0|ix1)!=0) { - z = one-tiny; /* trigger inexact flag */ - if (z>=one) { - z = one+tiny; - if (q1==(uint32_t)0xffffffff) { q1=0; q += 1;} - else if (z>one) { - if (q1==(uint32_t)0xfffffffe) q+=1; - q1+=2; - } else - q1 += (q1&1); - } - } - ix0 = (q>>1)+0x3fe00000; - ix1 = q1>>1; - if ((q&1)==1) ix1 |= sign; - ix0 += (m <<20); - INSERT_WORDS(z,ix0,ix1); - return z; -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ - -/* -Other methods (use floating-point arithmetic) -------------- -(This is a copy of a drafted paper by Prof W. Kahan -and K.C. Ng, written in May, 1986) - - Two algorithms are given here to implement sqrt(x) - (IEEE double precision arithmetic) in software. - Both supply sqrt(x) correctly rounded. The first algorithm (in - Section A) uses newton iterations and involves four divisions. - The second one uses reciproot iterations to avoid division, but - requires more multiplications. Both algorithms need the ability - to chop results of arithmetic operations instead of round them, - and the INEXACT flag to indicate when an arithmetic operation - is executed exactly with no roundoff error, all part of the - standard (IEEE 754-1985). The ability to perform shift, add, - subtract and logical AND operations upon 32-bit words is needed - too, though not part of the standard. - -A. sqrt(x) by Newton Iteration - - (1) Initial approximation - - Let x0 and x1 be the leading and the trailing 32-bit words of - a floating point number x (in IEEE double format) respectively - - 1 11 52 ...widths - ------------------------------------------------------ - x: |s| e | f | - ------------------------------------------------------ - msb lsb msb lsb ...order - - - ------------------------ ------------------------ - x0: |s| e | f1 | x1: | f2 | - ------------------------ ------------------------ - - By performing shifts and subtracts on x0 and x1 (both regarded - as integers), we obtain an 8-bit approximation of sqrt(x) as - follows. - - k := (x0>>1) + 0x1ff80000; - y0 := k - T1[31&(k>>15)]. ... y ~ sqrt(x) to 8 bits - Here k is a 32-bit integer and T1[] is an integer array containing - correction terms. Now magically the floating value of y (y's - leading 32-bit word is y0, the value of its trailing word is 0) - approximates sqrt(x) to almost 8-bit. - - Value of T1: - static int T1[32]= { - 0, 1024, 3062, 5746, 9193, 13348, 18162, 23592, - 29598, 36145, 43202, 50740, 58733, 67158, 75992, 85215, - 83599, 71378, 60428, 50647, 41945, 34246, 27478, 21581, - 16499, 12183, 8588, 5674, 3403, 1742, 661, 130,}; - - (2) Iterative refinement - - Apply Heron's rule three times to y, we have y approximates - sqrt(x) to within 1 ulp (Unit in the Last Place): - - y := (y+x/y)/2 ... almost 17 sig. bits - y := (y+x/y)/2 ... almost 35 sig. bits - y := y-(y-x/y)/2 ... within 1 ulp - - - Remark 1. - Another way to improve y to within 1 ulp is: - - y := (y+x/y) ... almost 17 sig. bits to 2*sqrt(x) - y := y - 0x00100006 ... almost 18 sig. bits to sqrt(x) - - 2 - (x-y )*y - y := y + 2* ---------- ...within 1 ulp - 2 - 3y + x - - - This formula has one division fewer than the one above; however, - it requires more multiplications and additions. Also x must be - scaled in advance to avoid spurious overflow in evaluating the - expression 3y*y+x. Hence it is not recommended uless division - is slow. If division is very slow, then one should use the - reciproot algorithm given in section B. - - (3) Final adjustment - - By twiddling y's last bit it is possible to force y to be - correctly rounded according to the prevailing rounding mode - as follows. Let r and i be copies of the rounding mode and - inexact flag before entering the square root program. Also we - use the expression y+-ulp for the next representable floating - numbers (up and down) of y. Note that y+-ulp = either fixed - point y+-1, or multiply y by nextafter(1,+-inf) in chopped - mode. - - I := FALSE; ... reset INEXACT flag I - R := RZ; ... set rounding mode to round-toward-zero - z := x/y; ... chopped quotient, possibly inexact - If(not I) then { ... if the quotient is exact - if(z=y) { - I := i; ... restore inexact flag - R := r; ... restore rounded mode - return sqrt(x):=y. - } else { - z := z - ulp; ... special rounding - } - } - i := TRUE; ... sqrt(x) is inexact - If (r=RN) then z=z+ulp ... rounded-to-nearest - If (r=RP) then { ... round-toward-+inf - y = y+ulp; z=z+ulp; - } - y := y+z; ... chopped sum - y0:=y0-0x00100000; ... y := y/2 is correctly rounded. - I := i; ... restore inexact flag - R := r; ... restore rounded mode - return sqrt(x):=y. - - (4) Special cases - - Square root of +inf, +-0, or NaN is itself; - Square root of a negative number is NaN with invalid signal. - - -B. sqrt(x) by Reciproot Iteration - - (1) Initial approximation - - Let x0 and x1 be the leading and the trailing 32-bit words of - a floating point number x (in IEEE double format) respectively - (see section A). By performing shifs and subtracts on x0 and y0, - we obtain a 7.8-bit approximation of 1/sqrt(x) as follows. - - k := 0x5fe80000 - (x0>>1); - y0:= k - T2[63&(k>>14)]. ... y ~ 1/sqrt(x) to 7.8 bits - - Here k is a 32-bit integer and T2[] is an integer array - containing correction terms. Now magically the floating - value of y (y's leading 32-bit word is y0, the value of - its trailing word y1 is set to zero) approximates 1/sqrt(x) - to almost 7.8-bit. - - Value of T2: - static int T2[64]= { - 0x1500, 0x2ef8, 0x4d67, 0x6b02, 0x87be, 0xa395, 0xbe7a, 0xd866, - 0xf14a, 0x1091b,0x11fcd,0x13552,0x14999,0x15c98,0x16e34,0x17e5f, - 0x18d03,0x19a01,0x1a545,0x1ae8a,0x1b5c4,0x1bb01,0x1bfde,0x1c28d, - 0x1c2de,0x1c0db,0x1ba73,0x1b11c,0x1a4b5,0x1953d,0x18266,0x16be0, - 0x1683e,0x179d8,0x18a4d,0x19992,0x1a789,0x1b445,0x1bf61,0x1c989, - 0x1d16d,0x1d77b,0x1dddf,0x1e2ad,0x1e5bf,0x1e6e8,0x1e654,0x1e3cd, - 0x1df2a,0x1d635,0x1cb16,0x1be2c,0x1ae4e,0x19bde,0x1868e,0x16e2e, - 0x1527f,0x1334a,0x11051,0xe951, 0xbe01, 0x8e0d, 0x5924, 0x1edd,}; - - (2) Iterative refinement - - Apply Reciproot iteration three times to y and multiply the - result by x to get an approximation z that matches sqrt(x) - to about 1 ulp. To be exact, we will have - -1ulp < sqrt(x)-z<1.0625ulp. - - ... set rounding mode to Round-to-nearest - y := y*(1.5-0.5*x*y*y) ... almost 15 sig. bits to 1/sqrt(x) - y := y*((1.5-2^-30)+0.5*x*y*y)... about 29 sig. bits to 1/sqrt(x) - ... special arrangement for better accuracy - z := x*y ... 29 bits to sqrt(x), with z*y<1 - z := z + 0.5*z*(1-z*y) ... about 1 ulp to sqrt(x) - - Remark 2. The constant 1.5-2^-30 is chosen to bias the error so that - (a) the term z*y in the final iteration is always less than 1; - (b) the error in the final result is biased upward so that - -1 ulp < sqrt(x) - z < 1.0625 ulp - instead of |sqrt(x)-z|<1.03125ulp. - - (3) Final adjustment - - By twiddling y's last bit it is possible to force y to be - correctly rounded according to the prevailing rounding mode - as follows. Let r and i be copies of the rounding mode and - inexact flag before entering the square root program. Also we - use the expression y+-ulp for the next representable floating - numbers (up and down) of y. Note that y+-ulp = either fixed - point y+-1, or multiply y by nextafter(1,+-inf) in chopped - mode. - - R := RZ; ... set rounding mode to round-toward-zero - switch(r) { - case RN: ... round-to-nearest - if(x<= z*(z-ulp)...chopped) z = z - ulp; else - if(x<= z*(z+ulp)...chopped) z = z; else z = z+ulp; - break; - case RZ:case RM: ... round-to-zero or round-to--inf - R:=RP; ... reset rounding mod to round-to-+inf - if(x<z*z ... rounded up) z = z - ulp; else - if(x>=(z+ulp)*(z+ulp) ...rounded up) z = z+ulp; - break; - case RP: ... round-to-+inf - if(x>(z+ulp)*(z+ulp)...chopped) z = z+2*ulp; else - if(x>z*z ...chopped) z = z+ulp; - break; - } - - Remark 3. The above comparisons can be done in fixed point. For - example, to compare x and w=z*z chopped, it suffices to compare - x1 and w1 (the trailing parts of x and w), regarding them as - two's complement integers. - - ...Is z an exact square root? - To determine whether z is an exact square root of x, let z1 be the - trailing part of z, and also let x0 and x1 be the leading and - trailing parts of x. - - If ((z1&0x03ffffff)!=0) ... not exact if trailing 26 bits of z!=0 - I := 1; ... Raise Inexact flag: z is not exact - else { - j := 1 - [(x0>>20)&1] ... j = logb(x) mod 2 - k := z1 >> 26; ... get z's 25-th and 26-th - fraction bits - I := i or (k&j) or ((k&(j+j+1))!=(x1&3)); - } - R:= r ... restore rounded mode - return sqrt(x):=z. - - If multiplication is cheaper then the foregoing red tape, the - Inexact flag can be evaluated by - - I := i; - I := (z*z!=x) or I. - - Note that z*z can overwrite I; this value must be sensed if it is - True. - - Remark 4. If z*z = x exactly, then bit 25 to bit 0 of z1 must be - zero. - - -------------------- - z1: | f2 | - -------------------- - bit 31 bit 0 - - Further more, bit 27 and 26 of z1, bit 0 and 1 of x1, and the odd - or even of logb(x) have the following relations: - - ------------------------------------------------- - bit 27,26 of z1 bit 1,0 of x1 logb(x) - ------------------------------------------------- - 00 00 odd and even - 01 01 even - 10 10 odd - 10 00 even - 11 01 even - ------------------------------------------------- - - (4) Special cases (see (4) of Section A). - - */ diff --git a/libjava/java/lang/fdlibm.h b/libjava/java/lang/fdlibm.h deleted file mode 100644 index fbfbb66..0000000 --- a/libjava/java/lang/fdlibm.h +++ /dev/null @@ -1,350 +0,0 @@ - -/* @(#)fdlibm.h 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993, 2000 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* AIX needs _XOPEN_SOURCE */ -#ifdef _AIX -#define _XOPEN_SOURCE -#endif - -#include <config.h> -#include <stdlib.h> - -/* GCJ LOCAL: Include files. */ -#include "ieeefp.h" - -#include "mprec.h" - -/* CYGNUS LOCAL: Default to XOPEN_MODE. */ -#define _XOPEN_MODE - -#ifdef __P -#undef __P -#endif - -#ifdef __STDC__ -#define __P(p) p -#else -#define __P(p) () -#endif - -#ifndef HUGE -#define HUGE ((float)3.40282346638528860e+38) -#endif - -/* - * set X_TLOSS = pi*2**52, which is possibly defined in <values.h> - * (one may replace the following line by "#include <values.h>") - */ - -#define X_TLOSS 1.41484755040568800000e+16 - -/* These typedefs are true for the targets running Java. */ - -#define _IEEE_LIBM - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * ANSI/POSIX - */ -extern double acos __P((double)); -extern double asin __P((double)); -extern double atan __P((double)); -extern double atan2 __P((double, double)); -extern double cos __P((double)); -extern double sin __P((double)); -extern double tan __P((double)); - -extern double cosh __P((double)); -extern double sinh __P((double)); -extern double tanh __P((double)); - -extern double exp __P((double)); -extern double frexp __P((double, int *)); -extern double ldexp __P((double, int)); -extern double log __P((double)); -extern double log10 __P((double)); -extern double modf __P((double, double *)); - -extern double pow __P((double, double)); -extern double sqrt __P((double)); - -extern double ceil __P((double)); -extern double fabs __P((double)); -extern double floor __P((double)); -extern double fmod __P((double, double)); - -extern double erf __P((double)); -extern double erfc __P((double)); -extern double gamma __P((double)); -extern double hypot __P((double, double)); -extern int isnan __P((double)); -extern int finite __P((double)); -extern double j0 __P((double)); -extern double j1 __P((double)); -extern double jn __P((int, double)); -extern double lgamma __P((double)); -extern double y0 __P((double)); -extern double y1 __P((double)); -extern double yn __P((int, double)); - -extern double acosh __P((double)); -extern double asinh __P((double)); -extern double atanh __P((double)); -extern double cbrt __P((double)); -extern double logb __P((double)); -extern double nextafter __P((double, double)); -extern double remainder __P((double, double)); - -/* Functions that are not documented, and are not in <math.h>. */ - -extern double logb __P((double)); -#ifdef _SCALB_INT -extern double scalb __P((double, int)); -#else -extern double scalb __P((double, double)); -#endif -extern double significand __P((double)); - -/* ieee style elementary functions */ -extern double __ieee754_sqrt __P((double)); -extern double __ieee754_acos __P((double)); -extern double __ieee754_acosh __P((double)); -extern double __ieee754_log __P((double)); -extern double __ieee754_atanh __P((double)); -extern double __ieee754_asin __P((double)); -extern double __ieee754_atan2 __P((double,double)); -extern double __ieee754_exp __P((double)); -extern double __ieee754_cosh __P((double)); -extern double __ieee754_fmod __P((double,double)); -extern double __ieee754_pow __P((double,double)); -extern double __ieee754_lgamma_r __P((double,int *)); -extern double __ieee754_gamma_r __P((double,int *)); -extern double __ieee754_log10 __P((double)); -extern double __ieee754_sinh __P((double)); -extern double __ieee754_hypot __P((double,double)); -extern double __ieee754_j0 __P((double)); -extern double __ieee754_j1 __P((double)); -extern double __ieee754_y0 __P((double)); -extern double __ieee754_y1 __P((double)); -extern double __ieee754_jn __P((int,double)); -extern double __ieee754_yn __P((int,double)); -extern double __ieee754_remainder __P((double,double)); -extern int32_t __ieee754_rem_pio2 __P((double,double*)); -#ifdef _SCALB_INT -extern double __ieee754_scalb __P((double,int)); -#else -extern double __ieee754_scalb __P((double,double)); -#endif - -/* fdlibm kernel function */ -extern double __kernel_standard __P((double,double,int)); -extern double __kernel_sin __P((double,double,int)); -extern double __kernel_cos __P((double,double)); -extern double __kernel_tan __P((double,double,int)); -extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int32_t*)); - -/* Undocumented float functions. */ -extern float logbf __P((float)); -#ifdef _SCALB_INT -extern float scalbf __P((float, int)); -#else -extern float scalbf __P((float, float)); -#endif -extern float significandf __P((float)); - -/* - * Functions callable from C, intended to support IEEE arithmetic. - */ -extern double copysign __P((double, double)); -extern int ilogb __P((double)); -extern double rint __P((double)); -extern float rintf __P((float)); -extern double scalbn __P((double, int)); - -/* ieee style elementary float functions */ -extern float __ieee754_sqrtf __P((float)); -extern float __ieee754_acosf __P((float)); -extern float __ieee754_acoshf __P((float)); -extern float __ieee754_logf __P((float)); -extern float __ieee754_atanhf __P((float)); -extern float __ieee754_asinf __P((float)); -extern float __ieee754_atan2f __P((float,float)); -extern float __ieee754_expf __P((float)); -extern float __ieee754_coshf __P((float)); -extern float __ieee754_fmodf __P((float,float)); -extern float __ieee754_powf __P((float,float)); -extern float __ieee754_lgammaf_r __P((float,int *)); -extern float __ieee754_gammaf_r __P((float,int *)); -extern float __ieee754_log10f __P((float)); -extern float __ieee754_sinhf __P((float)); -extern float __ieee754_hypotf __P((float,float)); -extern float __ieee754_j0f __P((float)); -extern float __ieee754_j1f __P((float)); -extern float __ieee754_y0f __P((float)); -extern float __ieee754_y1f __P((float)); -extern float __ieee754_jnf __P((int,float)); -extern float __ieee754_ynf __P((int,float)); -extern float __ieee754_remainderf __P((float,float)); -extern int32_t __ieee754_rem_pio2f __P((float,float*)); -#ifdef _SCALB_INT -extern float __ieee754_scalbf __P((float,int)); -#else -extern float __ieee754_scalbf __P((float,float)); -#endif - -/* float versions of fdlibm kernel functions */ -extern float __kernel_sinf __P((float,float,int)); -extern float __kernel_cosf __P((float,float)); -extern float __kernel_tanf __P((float,float,int)); -extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const int32_t*)); - -/* The original code used statements like - n0 = ((*(int*)&one)>>29)^1; * index of high word * - ix0 = *(n0+(int*)&x); * high word of x * - ix1 = *((1-n0)+(int*)&x); * low word of x * - to dig two 32 bit words out of the 64 bit IEEE floating point - value. That is non-ANSI, and, moreover, the gcc instruction - scheduler gets it wrong. We instead use the following macros. - Unlike the original code, we determine the endianness at compile - time, not at run time; I don't see much benefit to selecting - endianness at run time. */ - -#ifndef __IEEE_BIG_ENDIAN -#ifndef __IEEE_LITTLE_ENDIAN - #error Must define endianness -#endif -#endif - -/* A union which permits us to convert between a double and two 32 bit - ints. */ - -#ifdef __IEEE_BIG_ENDIAN - -typedef union -{ - double value; - struct - { - uint32_t msw; - uint32_t lsw; - } parts; -} ieee_double_shape_type; - -#endif - -#ifdef __IEEE_LITTLE_ENDIAN - -typedef union -{ - double value; - struct - { - uint32_t lsw; - uint32_t msw; - } parts; -} ieee_double_shape_type; - -#endif - -/* Get two 32 bit ints from a double. */ - -#define EXTRACT_WORDS(ix0,ix1,d) \ -do { \ - ieee_double_shape_type ew_u; \ - ew_u.value = (d); \ - (ix0) = ew_u.parts.msw; \ - (ix1) = ew_u.parts.lsw; \ -} while (0) - -/* Get the more significant 32 bit int from a double. */ - -#define GET_HIGH_WORD(i,d) \ -do { \ - ieee_double_shape_type gh_u; \ - gh_u.value = (d); \ - (i) = gh_u.parts.msw; \ -} while (0) - -/* Get the less significant 32 bit int from a double. */ - -#define GET_LOW_WORD(i,d) \ -do { \ - ieee_double_shape_type gl_u; \ - gl_u.value = (d); \ - (i) = gl_u.parts.lsw; \ -} while (0) - -/* Set a double from two 32 bit ints. */ - -#define INSERT_WORDS(d,ix0,ix1) \ -do { \ - ieee_double_shape_type iw_u; \ - iw_u.parts.msw = (ix0); \ - iw_u.parts.lsw = (ix1); \ - (d) = iw_u.value; \ -} while (0) - -/* Set the more significant 32 bits of a double from an int. */ - -#define SET_HIGH_WORD(d,v) \ -do { \ - ieee_double_shape_type sh_u; \ - sh_u.value = (d); \ - sh_u.parts.msw = (v); \ - (d) = sh_u.value; \ -} while (0) - -/* Set the less significant 32 bits of a double from an int. */ - -#define SET_LOW_WORD(d,v) \ -do { \ - ieee_double_shape_type sl_u; \ - sl_u.value = (d); \ - sl_u.parts.lsw = (v); \ - (d) = sl_u.value; \ -} while (0) - -/* A union which permits us to convert between a float and a 32 bit - int. */ - -typedef union -{ - float value; - uint32_t word; -} ieee_float_shape_type; - -/* Get a 32 bit int from a float. */ - -#define GET_FLOAT_WORD(i,d) \ -do { \ - ieee_float_shape_type gf_u; \ - gf_u.value = (d); \ - (i) = gf_u.word; \ -} while (0) - -/* Set a float from a 32 bit int. */ - -#define SET_FLOAT_WORD(d,i) \ -do { \ - ieee_float_shape_type sf_u; \ - sf_u.word = (i); \ - (d) = sf_u.value; \ -} while (0) - -#ifdef __cplusplus -} -#endif - diff --git a/libjava/java/lang/ieeefp.h b/libjava/java/lang/ieeefp.h deleted file mode 100644 index 3638d54..0000000 --- a/libjava/java/lang/ieeefp.h +++ /dev/null @@ -1,163 +0,0 @@ -#ifndef __IEEE_BIG_ENDIAN -#ifndef __IEEE_LITTLE_ENDIAN - -#ifdef __alpha__ -#define __IEEE_LITTLE_ENDIAN -#endif - -#if defined(__arm__) || defined(__thumb__) -/* ARM traditionally used big-endian words; and within those words the - byte ordering was big or little endian depending upon the target. - Modern floating-point formats are naturally ordered; in this case - __VFP_FP__ will be defined, even if soft-float. */ -#ifdef __VFP_FP__ -#ifdef __ARMEL__ -#define __IEEE_LITTLE_ENDIAN -#else -#define __IEEE_BIG_ENDIAN -#endif -#else -#define __IEEE_BIG_ENDIAN -#ifdef __ARMEL__ -#define __IEEE_BYTES_LITTLE_ENDIAN -#endif -#endif -#endif - -#ifdef __hppa__ -#define __IEEE_BIG_ENDIAN -#endif - -#if defined (__sparc) || defined (__sparc__) -#define __IEEE_BIG_ENDIAN -#endif - -#ifdef __m32r__ -#ifdef __LITTLE_ENDIAN__ -#define __IEEE_LITTLE_ENDIAN -#else -#define __IEEE_BIG_ENDIAN -#endif -#endif - -#if defined(__m68k__) || defined(__mc68000__) -#define __IEEE_BIG_ENDIAN -#endif - -#if defined (__H8300__) || defined (__H8300H__) -#define __IEEE_BIG_ENDIAN -#define __SMALL_BITFIELDS -#define _DOUBLE_IS_32BITS -#endif - -#ifdef __H8500__ -#define __IEEE_BIG_ENDIAN -#define __SMALL_BITFIELDS -#define _DOUBLE_IS_32BITS -#endif - -#ifdef __sh__ -#ifdef __LITTLE_ENDIAN__ -#define __IEEE_LITTLE_ENDIAN -#else -#define __IEEE_BIG_ENDIAN -#endif - -#ifdef __SH3E__ -#define _DOUBLE_IS_32BITS -#endif -#endif - -#ifdef _AM29K -#define __IEEE_BIG_ENDIAN -#endif - -#ifdef __i386__ -#define __IEEE_LITTLE_ENDIAN -#endif - -#ifdef __x86_64__ -#define __IEEE_LITTLE_ENDIAN -#endif - -#ifdef __i960__ -#define __IEEE_LITTLE_ENDIAN -#endif - -#ifdef __MIPSEL__ -#define __IEEE_LITTLE_ENDIAN -#endif - -#ifdef __MIPSEB__ -#define __IEEE_BIG_ENDIAN -#endif - -#ifdef __pj__ -#ifdef __pjl__ -#define __IEEE_LITTLE_ENDIAN -#else -#define __IEEE_BIG_ENDIAN -#endif -#endif - -/* necv70 was __IEEE_LITTLE_ENDIAN. */ - -#ifdef __W65__ -#define __IEEE_LITTLE_ENDIAN -#define __SMALL_BITFIELDS -#define _DOUBLE_IS_32BITS -#endif - -#if defined(__Z8001__) || defined(__Z8002__) -#define __IEEE_BIG_ENDIAN -#endif - -#ifdef __m88k__ -#define __IEEE_BIG_ENDIAN -#endif - -#ifdef __v800 -#define __IEEE_LITTLE_ENDIAN -#endif - -#if defined (__PPC__) || defined (__ppc__) || defined (__ppc64__) -#if (defined(_BIG_ENDIAN) && _BIG_ENDIAN) || (defined(_AIX) && _AIX) \ - || defined (__APPLE__) -#define __IEEE_BIG_ENDIAN -#else -#if (defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN) || (defined(__sun__) && __sun__) || (defined(__WIN32__) && __WIN32__) -#define __IEEE_LITTLE_ENDIAN -#endif -#endif -#endif - -#ifdef __fr30__ -#define __IEEE_BIG_ENDIAN -#endif - -#ifdef __mcore__ -#define __IEEE_BIG_ENDIAN -#endif - - -#ifdef __ia64__ -#ifdef __BIG_ENDIAN__ -#define __IEEE_BIG_ENDIAN -#else -#define __IEEE_LITTLE_ENDIAN -#endif -#endif - -#ifdef __s390__ -#define __IEEE_BIG_ENDIAN -#endif - -#ifndef __IEEE_BIG_ENDIAN -#ifndef __IEEE_LITTLE_ENDIAN -#error Endianess not declared!! -#endif /* not __IEEE_LITTLE_ENDIAN */ -#endif /* not __IEEE_BIG_ENDIAN */ - -#endif /* not __IEEE_LITTLE_ENDIAN */ -#endif /* not __IEEE_BIG_ENDIAN */ - diff --git a/libjava/java/lang/k_cos.c b/libjava/java/lang/k_cos.c deleted file mode 100644 index acf50a8..0000000 --- a/libjava/java/lang/k_cos.c +++ /dev/null @@ -1,96 +0,0 @@ - -/* @(#)k_cos.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* - * __kernel_cos( x, y ) - * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164 - * Input x is assumed to be bounded by ~pi/4 in magnitude. - * Input y is the tail of x. - * - * Algorithm - * 1. Since cos(-x) = cos(x), we need only to consider positive x. - * 2. if x < 2^-27 (hx<0x3e400000 0), return 1 with inexact if x!=0. - * 3. cos(x) is approximated by a polynomial of degree 14 on - * [0,pi/4] - * 4 14 - * cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x - * where the remez error is - * - * | 2 4 6 8 10 12 14 | -58 - * |cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x +C6*x )| <= 2 - * | | - * - * 4 6 8 10 12 14 - * 4. let r = C1*x +C2*x +C3*x +C4*x +C5*x +C6*x , then - * cos(x) = 1 - x*x/2 + r - * since cos(x+y) ~ cos(x) - sin(x)*y - * ~ cos(x) - x*y, - * a correction term is necessary in cos(x) and hence - * cos(x+y) = 1 - (x*x/2 - (r - x*y)) - * For better accuracy when x > 0.3, let qx = |x|/4 with - * the last 32 bits mask off, and if x > 0.78125, let qx = 0.28125. - * Then - * cos(x+y) = (1-qx) - ((x*x/2-qx) - (r-x*y)). - * Note that 1-qx and (x*x/2-qx) is EXACT here, and the - * magnitude of the latter is at least a quarter of x*x/2, - * thus, reducing the rounding error in the subtraction. - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double -#else -static double -#endif -one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ -C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */ -C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */ -C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */ -C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */ -C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */ -C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ - -#ifdef __STDC__ - double __kernel_cos(double x, double y) -#else - double __kernel_cos(x, y) - double x,y; -#endif -{ - double a,hz,z,r,qx; - int32_t ix; - GET_HIGH_WORD(ix,x); - ix &= 0x7fffffff; /* ix = |x|'s high word*/ - if(ix<0x3e400000) { /* if x < 2**27 */ - if(((int)x)==0) return one; /* generate inexact */ - } - z = x*x; - r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6))))); - if(ix < 0x3FD33333) /* if |x| < 0.3 */ - return one - (0.5*z - (z*r - x*y)); - else { - if(ix > 0x3fe90000) { /* x > 0.78125 */ - qx = 0.28125; - } else { - INSERT_WORDS(qx,ix-0x00200000,0); /* x/4 */ - } - hz = 0.5*z-qx; - a = one-qx; - return a - (hz - (z*r-x*y)); - } -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/k_rem_pio2.c b/libjava/java/lang/k_rem_pio2.c deleted file mode 100644 index 2f4ca17..0000000 --- a/libjava/java/lang/k_rem_pio2.c +++ /dev/null @@ -1,320 +0,0 @@ - -/* @(#)k_rem_pio2.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* - * __kernel_rem_pio2(x,y,e0,nx,prec,ipio2) - * double x[],y[]; int e0,nx,prec; int ipio2[]; - * - * __kernel_rem_pio2 return the last three digits of N with - * y = x - N*pi/2 - * so that |y| < pi/2. - * - * The method is to compute the integer (mod 8) and fraction parts of - * (2/pi)*x without doing the full multiplication. In general we - * skip the part of the product that are known to be a huge integer ( - * more accurately, = 0 mod 8 ). Thus the number of operations are - * independent of the exponent of the input. - * - * (2/pi) is represented by an array of 24-bit integers in ipio2[]. - * - * Input parameters: - * x[] The input value (must be positive) is broken into nx - * pieces of 24-bit integers in double precision format. - * x[i] will be the i-th 24 bit of x. The scaled exponent - * of x[0] is given in input parameter e0 (i.e., x[0]*2^e0 - * match x's up to 24 bits. - * - * Example of breaking a double positive z into x[0]+x[1]+x[2]: - * e0 = ilogb(z)-23 - * z = scalbn(z,-e0) - * for i = 0,1,2 - * x[i] = floor(z) - * z = (z-x[i])*2**24 - * - * - * y[] ouput result in an array of double precision numbers. - * The dimension of y[] is: - * 24-bit precision 1 - * 53-bit precision 2 - * 64-bit precision 2 - * 113-bit precision 3 - * The actual value is the sum of them. Thus for 113-bit - * precison, one may have to do something like: - * - * long double t,w,r_head, r_tail; - * t = (long double)y[2] + (long double)y[1]; - * w = (long double)y[0]; - * r_head = t+w; - * r_tail = w - (r_head - t); - * - * e0 The exponent of x[0] - * - * nx dimension of x[] - * - * prec an integer indicating the precision: - * 0 24 bits (single) - * 1 53 bits (double) - * 2 64 bits (extended) - * 3 113 bits (quad) - * - * ipio2[] - * integer array, contains the (24*i)-th to (24*i+23)-th - * bit of 2/pi after binary point. The corresponding - * floating value is - * - * ipio2[i] * 2^(-24(i+1)). - * - * External function: - * double scalbn(), floor(); - * - * - * Here is the description of some local variables: - * - * jk jk+1 is the initial number of terms of ipio2[] needed - * in the computation. The recommended value is 2,3,4, - * 6 for single, double, extended,and quad. - * - * jz local integer variable indicating the number of - * terms of ipio2[] used. - * - * jx nx - 1 - * - * jv index for pointing to the suitable ipio2[] for the - * computation. In general, we want - * ( 2^e0*x[0] * ipio2[jv-1]*2^(-24jv) )/8 - * is an integer. Thus - * e0-3-24*jv >= 0 or (e0-3)/24 >= jv - * Hence jv = max(0,(e0-3)/24). - * - * jp jp+1 is the number of terms in PIo2[] needed, jp = jk. - * - * q[] double array with integral value, representing the - * 24-bits chunk of the product of x and 2/pi. - * - * q0 the corresponding exponent of q[0]. Note that the - * exponent for q[i] would be q0-24*i. - * - * PIo2[] double precision array, obtained by cutting pi/2 - * into 24 bits chunks. - * - * f[] ipio2[] in floating point - * - * iq[] integer array by breaking up q[] in 24-bits chunk. - * - * fq[] final product of x*(2/pi) in fq[0],..,fq[jk] - * - * ih integer. If >0 it indicates q[] is >= 0.5, hence - * it also indicates the *sign* of the result. - * - */ - - -/* - * Constants: - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const int init_jk[] = {2,3,4,6}; /* initial value for jk */ -#else -static int init_jk[] = {2,3,4,6}; -#endif - -#ifdef __STDC__ -static const double PIo2[] = { -#else -static double PIo2[] = { -#endif - 1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */ - 7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */ - 5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */ - 3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */ - 1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */ - 1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */ - 2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */ - 2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */ -}; - -#ifdef __STDC__ -static const double -#else -static double -#endif -zero = 0.0, -one = 1.0, -two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */ -twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */ - -#ifdef __STDC__ - int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2) -#else - int __kernel_rem_pio2(x,y,e0,nx,prec,ipio2) - double x[], y[]; int e0,nx,prec; int32_t ipio2[]; -#endif -{ - int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; - double z,fw,f[20],fq[20],q[20]; - - /* initialize jk*/ - jk = init_jk[prec]; - jp = jk; - - /* determine jx,jv,q0, note that 3>q0 */ - jx = nx-1; - jv = (e0-3)/24; if(jv<0) jv=0; - q0 = e0-24*(jv+1); - - /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */ - j = jv-jx; m = jx+jk; - for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (double) ipio2[j]; - - /* compute q[0],q[1],...q[jk] */ - for (i=0;i<=jk;i++) { - for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw; - } - - jz = jk; -recompute: - /* distill q[] into iq[] reversingly */ - for(i=0,j=jz,z=q[jz];j>0;i++,j--) { - fw = (double)((int32_t)(twon24* z)); - iq[i] = (int32_t)(z-two24*fw); - z = q[j-1]+fw; - } - - /* compute n */ - z = scalbn(z,(int)q0); /* actual value of z */ - z -= 8.0*floor(z*0.125); /* trim off integer >= 8 */ - n = (int32_t) z; - z -= (double)n; - ih = 0; - if(q0>0) { /* need iq[jz-1] to determine n */ - i = (iq[jz-1]>>(24-q0)); n += i; - iq[jz-1] -= i<<(24-q0); - ih = iq[jz-1]>>(23-q0); - } - else if(q0==0) ih = iq[jz-1]>>23; - else if(z>=0.5) ih=2; - - if(ih>0) { /* q > 0.5 */ - n += 1; carry = 0; - for(i=0;i<jz ;i++) { /* compute 1-q */ - j = iq[i]; - if(carry==0) { - if(j!=0) { - carry = 1; iq[i] = 0x1000000- j; - } - } else iq[i] = 0xffffff - j; - } - if(q0>0) { /* rare case: chance is 1 in 12 */ - switch(q0) { - case 1: - iq[jz-1] &= 0x7fffff; break; - case 2: - iq[jz-1] &= 0x3fffff; break; - } - } - if(ih==2) { - z = one - z; - if(carry!=0) z -= scalbn(one,(int)q0); - } - } - - /* check if recomputation is needed */ - if(z==zero) { - j = 0; - for (i=jz-1;i>=jk;i--) j |= iq[i]; - if(j==0) { /* need recomputation */ - for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */ - - for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */ - f[jx+i] = (double) ipio2[jv+i]; - for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; - q[i] = fw; - } - jz += k; - goto recompute; - } - } - - /* chop off zero terms */ - if(z==0.0) { - jz -= 1; q0 -= 24; - while(iq[jz]==0) { jz--; q0-=24;} - } else { /* break z into 24-bit if necessary */ - z = scalbn(z,-(int)q0); - if(z>=two24) { - fw = (double)((int32_t)(twon24*z)); - iq[jz] = (int32_t)(z-two24*fw); - jz += 1; q0 += 24; - iq[jz] = (int32_t) fw; - } else iq[jz] = (int32_t) z ; - } - - /* convert integer "bit" chunk to floating-point value */ - fw = scalbn(one,(int)q0); - for(i=jz;i>=0;i--) { - q[i] = fw*(double)iq[i]; fw*=twon24; - } - - /* compute PIo2[0,...,jp]*q[jz,...,0] */ - for(i=jz;i>=0;i--) { - for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k]; - fq[jz-i] = fw; - } - - /* compress fq[] into y[] */ - switch(prec) { - case 0: - fw = 0.0; - for (i=jz;i>=0;i--) fw += fq[i]; - y[0] = (ih==0)? fw: -fw; - break; - case 1: - case 2: - fw = 0.0; - for (i=jz;i>=0;i--) fw += fq[i]; - y[0] = (ih==0)? fw: -fw; - fw = fq[0]-fw; - for (i=1;i<=jz;i++) fw += fq[i]; - y[1] = (ih==0)? fw: -fw; - break; - case 3: /* painful */ - for (i=jz;i>0;i--) { - fw = fq[i-1]+fq[i]; - fq[i] += fq[i-1]-fw; - fq[i-1] = fw; - } - for (i=jz;i>1;i--) { - fw = fq[i-1]+fq[i]; - fq[i] += fq[i-1]-fw; - fq[i-1] = fw; - } - for (fw=0.0,i=jz;i>=2;i--) fw += fq[i]; - if(ih==0) { - y[0] = fq[0]; y[1] = fq[1]; y[2] = fw; - } else { - y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw; - } - } - return n&7; -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/k_sin.c b/libjava/java/lang/k_sin.c deleted file mode 100644 index b4ad387..0000000 --- a/libjava/java/lang/k_sin.c +++ /dev/null @@ -1,79 +0,0 @@ - -/* @(#)k_sin.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* __kernel_sin( x, y, iy) - * kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.7854 - * Input x is assumed to be bounded by ~pi/4 in magnitude. - * Input y is the tail of x. - * Input iy indicates whether y is 0. (if iy=0, y assume to be 0). - * - * Algorithm - * 1. Since sin(-x) = -sin(x), we need only to consider positive x. - * 2. if x < 2^-27 (hx<0x3e400000 0), return x with inexact if x!=0. - * 3. sin(x) is approximated by a polynomial of degree 13 on - * [0,pi/4] - * 3 13 - * sin(x) ~ x + S1*x + ... + S6*x - * where - * - * |sin(x) 2 4 6 8 10 12 | -58 - * |----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x +S6*x )| <= 2 - * | x | - * - * 4. sin(x+y) = sin(x) + sin'(x')*y - * ~ sin(x) + (1-x*x/2)*y - * For better accuracy, let - * 3 2 2 2 2 - * r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6)))) - * then 3 2 - * sin(x) = x + (S1*x + (x *(r-y/2)+y)) - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double -#else -static double -#endif -half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ -S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */ -S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */ -S3 = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */ -S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */ -S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */ -S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */ - -#ifdef __STDC__ - double __kernel_sin(double x, double y, int iy) -#else - double __kernel_sin(x, y, iy) - double x,y; int iy; /* iy=0 if y is zero */ -#endif -{ - double z,r,v; - int32_t ix; - GET_HIGH_WORD(ix,x); - ix &= 0x7fffffff; /* high word of x */ - if(ix<0x3e400000) /* |x| < 2**-27 */ - {if((int)x==0) return x;} /* generate inexact */ - z = x*x; - v = z*x; - r = S2+z*(S3+z*(S4+z*(S5+z*S6))); - if(iy==0) return x+v*(S1+z*r); - else return x-((z*(half*y-v*r)-y)-v*S1); -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/k_tan.c b/libjava/java/lang/k_tan.c deleted file mode 100644 index a1067a7..0000000 --- a/libjava/java/lang/k_tan.c +++ /dev/null @@ -1,132 +0,0 @@ - -/* @(#)k_tan.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* __kernel_tan( x, y, k ) - * kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854 - * Input x is assumed to be bounded by ~pi/4 in magnitude. - * Input y is the tail of x. - * Input k indicates whether tan (if k=1) or - * -1/tan (if k= -1) is returned. - * - * Algorithm - * 1. Since tan(-x) = -tan(x), we need only to consider positive x. - * 2. if x < 2^-28 (hx<0x3e300000 0), return x with inexact if x!=0. - * 3. tan(x) is approximated by a odd polynomial of degree 27 on - * [0,0.67434] - * 3 27 - * tan(x) ~ x + T1*x + ... + T13*x - * where - * - * |tan(x) 2 4 26 | -59.2 - * |----- - (1+T1*x +T2*x +.... +T13*x )| <= 2 - * | x | - * - * Note: tan(x+y) = tan(x) + tan'(x)*y - * ~ tan(x) + (1+x*x)*y - * Therefore, for better accuracy in computing tan(x+y), let - * 3 2 2 2 2 - * r = x *(T2+x *(T3+x *(...+x *(T12+x *T13)))) - * then - * 3 2 - * tan(x+y) = x + (T1*x + (x *(r+y)+y)) - * - * 4. For x in [0.67434,pi/4], let y = pi/4 - x, then - * tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y)) - * = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y))) - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double -#else -static double -#endif -one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ -pio4 = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */ -pio4lo= 3.06161699786838301793e-17, /* 0x3C81A626, 0x33145C07 */ -T[] = { - 3.33333333333334091986e-01, /* 0x3FD55555, 0x55555563 */ - 1.33333333333201242699e-01, /* 0x3FC11111, 0x1110FE7A */ - 5.39682539762260521377e-02, /* 0x3FABA1BA, 0x1BB341FE */ - 2.18694882948595424599e-02, /* 0x3F9664F4, 0x8406D637 */ - 8.86323982359930005737e-03, /* 0x3F8226E3, 0xE96E8493 */ - 3.59207910759131235356e-03, /* 0x3F6D6D22, 0xC9560328 */ - 1.45620945432529025516e-03, /* 0x3F57DBC8, 0xFEE08315 */ - 5.88041240820264096874e-04, /* 0x3F4344D8, 0xF2F26501 */ - 2.46463134818469906812e-04, /* 0x3F3026F7, 0x1A8D1068 */ - 7.81794442939557092300e-05, /* 0x3F147E88, 0xA03792A6 */ - 7.14072491382608190305e-05, /* 0x3F12B80F, 0x32F0A7E9 */ - -1.85586374855275456654e-05, /* 0xBEF375CB, 0xDB605373 */ - 2.59073051863633712884e-05, /* 0x3EFB2A70, 0x74BF7AD4 */ -}; - -#ifdef __STDC__ - double __kernel_tan(double x, double y, int iy) -#else - double __kernel_tan(x, y, iy) - double x,y; int iy; -#endif -{ - double z,r,v,w,s; - int32_t ix,hx; - GET_HIGH_WORD(hx,x); - ix = hx&0x7fffffff; /* high word of |x| */ - if(ix<0x3e300000) /* x < 2**-28 */ - {if((int)x==0) { /* generate inexact */ - uint32_t low; - GET_LOW_WORD(low,x); - if(((ix|low)|(iy+1))==0) return one/fabs(x); - else return (iy==1)? x: -one/x; - } - } - if(ix>=0x3FE59428) { /* |x|>=0.6744 */ - if(hx<0) {x = -x; y = -y;} - z = pio4-x; - w = pio4lo-y; - x = z+w; y = 0.0; - } - z = x*x; - w = z*z; - /* Break x^5*(T[1]+x^2*T[2]+...) into - * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) + - * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12])) - */ - r = T[1]+w*(T[3]+w*(T[5]+w*(T[7]+w*(T[9]+w*T[11])))); - v = z*(T[2]+w*(T[4]+w*(T[6]+w*(T[8]+w*(T[10]+w*T[12]))))); - s = z*x; - r = y + z*(s*(r+v)+y); - r += T[0]*s; - w = x+r; - if(ix>=0x3FE59428) { - v = (double)iy; - return (double)(1-((hx>>30)&2))*(v-2.0*(x-(w*w/(w+v)-r))); - } - if(iy==1) return w; - else { /* if allow error up to 2 ulp, - simply return -1.0/(x+r) here */ - /* compute -1.0/(x+r) accurately */ - double a,t; - z = w; - SET_LOW_WORD(z,0); - v = r-(z - x); /* z+v = r+x */ - t = a = -1.0/w; /* a = -1.0/w */ - SET_LOW_WORD(t,0); - s = 1.0+t*z; - return t+a*(s+t*v); - } -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/mprec.c b/libjava/java/lang/mprec.c deleted file mode 100644 index 00679ed..0000000 --- a/libjava/java/lang/mprec.c +++ /dev/null @@ -1,958 +0,0 @@ -/**************************************************************** - * - * The author of this software is David M. Gay. - * - * Copyright (c) 1991 by AT&T. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose without fee is hereby granted, provided that this entire notice - * is included in all copies of any software which is or includes a copy - * or modification of this software and in all copies of the supporting - * documentation for such software. - * - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY - * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. - * - ***************************************************************/ - -/* Please send bug reports to - David M. Gay - AT&T Bell Laboratories, Room 2C-463 - 600 Mountain Avenue - Murray Hill, NJ 07974-2070 - U.S.A. - dmg@research.att.com or research!dmg - */ - -/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. - * - * This strtod returns a nearest machine number to the input decimal - * string (or sets errno to ERANGE). With IEEE arithmetic, ties are - * broken by the IEEE round-even rule. Otherwise ties are broken by - * biased rounding (add half and chop). - * - * Inspired loosely by William D. Clinger's paper "How to Read Floating - * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. - * - * Modifications: - * - * 1. We only require IEEE, IBM, or VAX double-precision - * arithmetic (not IEEE double-extended). - * 2. We get by with floating-point arithmetic in a case that - * Clinger missed -- when we're computing d * 10^n - * for a small integer d and the integer n is not too - * much larger than 22 (the maximum integer k for which - * we can represent 10^k exactly), we may be able to - * compute (d*10^k) * 10^(e-k) with just one roundoff. - * 3. Rather than a bit-at-a-time adjustment of the binary - * result in the hard case, we use floating-point - * arithmetic to determine the adjustment to within - * one bit; only in really hard cases do we need to - * compute a second residual. - * 4. Because of 3., we don't need a large table of powers of 10 - * for ten-to-e (just some small tables, e.g. of 10^k - * for 0 <= k <= 22). - */ - -/* - * #define IEEE_8087 for IEEE-arithmetic machines where the least - * significant byte has the lowest address. - * #define IEEE_MC68k for IEEE-arithmetic machines where the most - * significant byte has the lowest address. - * #define Sudden_Underflow for IEEE-format machines without gradual - * underflow (i.e., that flush to zero on underflow). - * #define IBM for IBM mainframe-style floating-point arithmetic. - * #define VAX for VAX-style floating-point arithmetic. - * #define Unsigned_Shifts if >> does treats its left operand as unsigned. - * #define No_leftright to omit left-right logic in fast floating-point - * computation of dtoa. - * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3. - * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines - * that use extended-precision instructions to compute rounded - * products and quotients) with IBM. - * #define ROUND_BIASED for IEEE-format with biased rounding. - * #define Inaccurate_Divide for IEEE-format with correctly rounded - * products but inaccurate quotients, e.g., for Intel i860. - * #define Just_16 to store 16 bits per 32-bit long when doing high-precision - * integer arithmetic. Whether this speeds things up or slows things - * down depends on the machine and the number being converted. - */ - -#include <stdlib.h> -#include <string.h> -#include <java-assert.h> -#include "mprec.h" - -/* reent.c knows this value */ -#define _Kmax 15 -#include <stdio.h> - -_Jv_Bigint * -_DEFUN (Balloc, (ptr, k), struct _Jv_reent *ptr _AND int k) -{ - _Jv_Bigint *rv = NULL; - - int i = 0; - int j = 1; - - JvAssert ((1 << k) < MAX_BIGNUM_WDS); - - while ((ptr->_allocation_map & j) && i < MAX_BIGNUMS) - i++, j <<= 1; - - JvAssert (i < MAX_BIGNUMS); - - if (i >= MAX_BIGNUMS) - return NULL; - - ptr->_allocation_map |= j; - rv = &ptr->_freelist[i]; - - rv->_k = k; - rv->_maxwds = 32; - - return rv; -} - - -void -_DEFUN (Bfree, (ptr, v), struct _Jv_reent *ptr _AND _Jv_Bigint * v) -{ - long i; - - i = v - ptr->_freelist; - - JvAssert (i >= 0 && i < MAX_BIGNUMS); - - if (i >= 0 && i < MAX_BIGNUMS) - ptr->_allocation_map &= ~ (1 << i); -} - - -_Jv_Bigint * -_DEFUN (multadd, (ptr, b, m, a), - struct _Jv_reent *ptr _AND - _Jv_Bigint * b _AND - int m _AND - int a) -{ - int i, wds; - unsigned long *x, y; -#ifdef Pack_32 - unsigned long xi, z; -#endif - _Jv_Bigint *b1; - - wds = b->_wds; - x = b->_x; - i = 0; - do - { -#ifdef Pack_32 - xi = *x; - y = (xi & 0xffff) * m + a; - z = (xi >> 16) * m + (y >> 16); - a = (int) (z >> 16); - *x++ = (z << 16) + (y & 0xffff); -#else - y = *x * m + a; - a = (int) (y >> 16); - *x++ = y & 0xffff; -#endif - } - while (++i < wds); - if (a) - { - if (wds >= b->_maxwds) - { - b1 = Balloc (ptr, b->_k + 1); - Bcopy (b1, b); - Bfree (ptr, b); - b = b1; - } - b->_x[wds++] = a; - b->_wds = wds; - } - return b; -} - -_Jv_Bigint * -_DEFUN (s2b, (ptr, s, nd0, nd, y9), - struct _Jv_reent * ptr _AND - _CONST char *s _AND - int nd0 _AND - int nd _AND - unsigned long y9) -{ - _Jv_Bigint *b; - int i, k; - long x, y; - - x = (nd + 8) / 9; - for (k = 0, y = 1; x > y; y <<= 1, k++); -#ifdef Pack_32 - b = Balloc (ptr, k); - b->_x[0] = y9; - b->_wds = 1; -#else - b = Balloc (ptr, k + 1); - b->_x[0] = y9 & 0xffff; - b->_wds = (b->_x[1] = y9 >> 16) ? 2 : 1; -#endif - - i = 9; - if (9 < nd0) - { - s += 9; - do - b = multadd (ptr, b, 10, *s++ - '0'); - while (++i < nd0); - s++; - } - else - s += 10; - for (; i < nd; i++) - b = multadd (ptr, b, 10, *s++ - '0'); - return b; -} - -int -_DEFUN (hi0bits, - (x), register unsigned long x) -{ - register int k = 0; - - if (!(x & 0xffff0000)) - { - k = 16; - x <<= 16; - } - if (!(x & 0xff000000)) - { - k += 8; - x <<= 8; - } - if (!(x & 0xf0000000)) - { - k += 4; - x <<= 4; - } - if (!(x & 0xc0000000)) - { - k += 2; - x <<= 2; - } - if (!(x & 0x80000000)) - { - k++; - if (!(x & 0x40000000)) - return 32; - } - return k; -} - -int -_DEFUN (lo0bits, (y), unsigned long *y) -{ - register int k; - register unsigned long x = *y; - - if (x & 7) - { - if (x & 1) - return 0; - if (x & 2) - { - *y = x >> 1; - return 1; - } - *y = x >> 2; - return 2; - } - k = 0; - if (!(x & 0xffff)) - { - k = 16; - x >>= 16; - } - if (!(x & 0xff)) - { - k += 8; - x >>= 8; - } - if (!(x & 0xf)) - { - k += 4; - x >>= 4; - } - if (!(x & 0x3)) - { - k += 2; - x >>= 2; - } - if (!(x & 1)) - { - k++; - x >>= 1; - if (!(x & 1)) - return 32; - } - *y = x; - return k; -} - -_Jv_Bigint * -_DEFUN (i2b, (ptr, i), struct _Jv_reent * ptr _AND int i) -{ - _Jv_Bigint *b; - - b = Balloc (ptr, 1); - b->_x[0] = i; - b->_wds = 1; - return b; -} - -_Jv_Bigint * -_DEFUN (mult, (ptr, a, b), struct _Jv_reent * ptr _AND _Jv_Bigint * a _AND _Jv_Bigint * b) -{ - _Jv_Bigint *c; - int k, wa, wb, wc; - unsigned long carry, y, z; - unsigned long *x, *xa, *xae, *xb, *xbe, *xc, *xc0; -#ifdef Pack_32 - unsigned long z2; -#endif - - if (a->_wds < b->_wds) - { - c = a; - a = b; - b = c; - } - k = a->_k; - wa = a->_wds; - wb = b->_wds; - wc = wa + wb; - if (wc > a->_maxwds) - k++; - c = Balloc (ptr, k); - for (x = c->_x, xa = x + wc; x < xa; x++) - *x = 0; - xa = a->_x; - xae = xa + wa; - xb = b->_x; - xbe = xb + wb; - xc0 = c->_x; -#ifdef Pack_32 - for (; xb < xbe; xb++, xc0++) - { - if ((y = *xb & 0xffff)) - { - x = xa; - xc = xc0; - carry = 0; - do - { - z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; - carry = z >> 16; - z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; - carry = z2 >> 16; - Storeinc (xc, z2, z); - } - while (x < xae); - *xc = carry; - } - if ((y = *xb >> 16)) - { - x = xa; - xc = xc0; - carry = 0; - z2 = *xc; - do - { - z = (*x & 0xffff) * y + (*xc >> 16) + carry; - carry = z >> 16; - Storeinc (xc, z, z2); - z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; - carry = z2 >> 16; - } - while (x < xae); - *xc = z2; - } - } -#else - for (; xb < xbe; xc0++) - { - if ((y = *xb++)) - { - x = xa; - xc = xc0; - carry = 0; - do - { - z = *x++ * y + *xc + carry; - carry = z >> 16; - *xc++ = z & 0xffff; - } - while (x < xae); - *xc = carry; - } - } -#endif - for (xc0 = c->_x, xc = xc0 + wc; wc > 0 && !*--xc; --wc); - c->_wds = wc; - return c; -} - -_Jv_Bigint * -_DEFUN (pow5mult, - (ptr, b, k), struct _Jv_reent * ptr _AND _Jv_Bigint * b _AND int k) -{ - _Jv_Bigint *b1, *p5, *p51; - int i; - static _CONST int p05[3] = {5, 25, 125}; - - if ((i = k & 3)) - b = multadd (ptr, b, p05[i - 1], 0); - - if (!(k >>= 2)) - return b; - if (!(p5 = ptr->_p5s)) - { - /* first time */ - p5 = ptr->_p5s = i2b (ptr, 625); - p5->_next = 0; - } - for (;;) - { - if (k & 1) - { - b1 = mult (ptr, b, p5); - Bfree (ptr, b); - b = b1; - } - if (!(k >>= 1)) - break; - if (!(p51 = p5->_next)) - { - p51 = p5->_next = mult (ptr, p5, p5); - p51->_next = 0; - } - p5 = p51; - } - return b; -} - -_Jv_Bigint * -_DEFUN (lshift, (ptr, b, k), struct _Jv_reent * ptr _AND _Jv_Bigint * b _AND int k) -{ - int i, k1, n, n1; - _Jv_Bigint *b1; - unsigned long *x, *x1, *xe, z; - -#ifdef Pack_32 - n = k >> 5; -#else - n = k >> 4; -#endif - k1 = b->_k; - n1 = n + b->_wds + 1; - for (i = b->_maxwds; n1 > i; i <<= 1) - k1++; - b1 = Balloc (ptr, k1); - x1 = b1->_x; - for (i = 0; i < n; i++) - *x1++ = 0; - x = b->_x; - xe = x + b->_wds; -#ifdef Pack_32 - if (k &= 0x1f) - { - k1 = 32 - k; - z = 0; - do - { - *x1++ = *x << k | z; - z = *x++ >> k1; - } - while (x < xe); - if ((*x1 = z)) - ++n1; - } -#else - if (k &= 0xf) - { - k1 = 16 - k; - z = 0; - do - { - *x1++ = (*x << k & 0xffff) | z; - z = *x++ >> k1; - } - while (x < xe); - if ((*x1 = z)) - ++n1; - } -#endif - else - do - *x1++ = *x++; - while (x < xe); - b1->_wds = n1 - 1; - Bfree (ptr, b); - return b1; -} - -int -_DEFUN (cmp, (a, b), _Jv_Bigint * a _AND _Jv_Bigint * b) -{ - unsigned long *xa, *xa0, *xb, *xb0; - int i, j; - - i = a->_wds; - j = b->_wds; -#ifdef DEBUG - if (i > 1 && !a->_x[i - 1]) - Bug ("cmp called with a->_x[a->_wds-1] == 0"); - if (j > 1 && !b->_x[j - 1]) - Bug ("cmp called with b->_x[b->_wds-1] == 0"); -#endif - if (i -= j) - return i; - xa0 = a->_x; - xa = xa0 + j; - xb0 = b->_x; - xb = xb0 + j; - for (;;) - { - if (*--xa != *--xb) - return *xa < *xb ? -1 : 1; - if (xa <= xa0) - break; - } - return 0; -} - -_Jv_Bigint * -_DEFUN (diff, (ptr, a, b), struct _Jv_reent * ptr _AND - _Jv_Bigint * a _AND _Jv_Bigint * b) -{ - _Jv_Bigint *c; - int i, wa, wb; - long borrow, y; /* We need signed shifts here. */ - unsigned long *xa, *xae, *xb, *xbe, *xc; -#ifdef Pack_32 - long z; -#endif - - i = cmp (a, b); - if (!i) - { - c = Balloc (ptr, 0); - c->_wds = 1; - c->_x[0] = 0; - return c; - } - if (i < 0) - { - c = a; - a = b; - b = c; - i = 1; - } - else - i = 0; - c = Balloc (ptr, a->_k); - c->_sign = i; - wa = a->_wds; - xa = a->_x; - xae = xa + wa; - wb = b->_wds; - xb = b->_x; - xbe = xb + wb; - xc = c->_x; - borrow = 0; -#ifdef Pack_32 - do - { - y = (*xa & 0xffff) - (*xb & 0xffff) + borrow; - borrow = y >> 16; - Sign_Extend (borrow, y); - z = (*xa++ >> 16) - (*xb++ >> 16) + borrow; - borrow = z >> 16; - Sign_Extend (borrow, z); - Storeinc (xc, z, y); - } - while (xb < xbe); - while (xa < xae) - { - y = (*xa & 0xffff) + borrow; - borrow = y >> 16; - Sign_Extend (borrow, y); - z = (*xa++ >> 16) + borrow; - borrow = z >> 16; - Sign_Extend (borrow, z); - Storeinc (xc, z, y); - } -#else - do - { - y = *xa++ - *xb++ + borrow; - borrow = y >> 16; - Sign_Extend (borrow, y); - *xc++ = y & 0xffff; - } - while (xb < xbe); - while (xa < xae) - { - y = *xa++ + borrow; - borrow = y >> 16; - Sign_Extend (borrow, y); - *xc++ = y & 0xffff; - } -#endif - while (!*--xc) - wa--; - c->_wds = wa; - return c; -} - -double -_DEFUN (ulp, (_x), double _x) -{ - union double_union x, a; - register long L; - - x.d = _x; - - L = (word0 (x) & Exp_mask) - (P - 1) * Exp_msk1; -#ifndef Sudden_Underflow - if (L > 0) - { -#endif -#ifdef IBM - L |= Exp_msk1 >> 4; -#endif - word0 (a) = L; -#ifndef _DOUBLE_IS_32BITS - word1 (a) = 0; -#endif - -#ifndef Sudden_Underflow - } - else - { - L = -L >> Exp_shift; - if (L < Exp_shift) - { - word0 (a) = 0x80000 >> L; -#ifndef _DOUBLE_IS_32BITS - word1 (a) = 0; -#endif - } - else - { - word0 (a) = 0; - L -= Exp_shift; -#ifndef _DOUBLE_IS_32BITS - word1 (a) = L >= 31 ? 1 : 1 << (31 - L); -#endif - } - } -#endif - return a.d; -} - -double -_DEFUN (b2d, (a, e), - _Jv_Bigint * a _AND int *e) -{ - unsigned long *xa, *xa0, w, y, z; - int k; - union double_union d; -#ifdef VAX - unsigned long d0, d1; -#else -#define d0 word0(d) -#define d1 word1(d) -#endif - - xa0 = a->_x; - xa = xa0 + a->_wds; - y = *--xa; -#ifdef DEBUG - if (!y) - Bug ("zero y in b2d"); -#endif - k = hi0bits (y); - *e = 32 - k; -#ifdef Pack_32 - if (k < Ebits) - { - d0 = Exp_1 | y >> (Ebits - k); - w = xa > xa0 ? *--xa : 0; -#ifndef _DOUBLE_IS_32BITS - d1 = y << (32 - Ebits + k) | w >> (Ebits - k); -#endif - goto ret_d; - } - z = xa > xa0 ? *--xa : 0; - if (k -= Ebits) - { - d0 = Exp_1 | y << k | z >> (32 - k); - y = xa > xa0 ? *--xa : 0; -#ifndef _DOUBLE_IS_32BITS - d1 = z << k | y >> (32 - k); -#endif - } - else - { - d0 = Exp_1 | y; -#ifndef _DOUBLE_IS_32BITS - d1 = z; -#endif - } -#else - if (k < Ebits + 16) - { - z = xa > xa0 ? *--xa : 0; - d0 = Exp_1 | y << (k - Ebits) | z >> (Ebits + 16 - k); - w = xa > xa0 ? *--xa : 0; - y = xa > xa0 ? *--xa : 0; - d1 = z << (k + 16 - Ebits) | w << (k - Ebits) | y >> (16 + Ebits - k); - goto ret_d; - } - z = xa > xa0 ? *--xa : 0; - w = xa > xa0 ? *--xa : 0; - k -= Ebits + 16; - d0 = Exp_1 | y << (k + 16) | z << k | w >> (16 - k); - y = xa > xa0 ? *--xa : 0; - d1 = w << (k + 16) | y << k; -#endif -ret_d: -#ifdef VAX - word0 (d) = d0 >> 16 | d0 << 16; - word1 (d) = d1 >> 16 | d1 << 16; -#else -#undef d0 -#undef d1 -#endif - return d.d; -} - -_Jv_Bigint * -_DEFUN (d2b, - (ptr, _d, e, bits), - struct _Jv_reent * ptr _AND - double _d _AND - int *e _AND - int *bits) - -{ - union double_union d; - _Jv_Bigint *b; - int de, i, k; - unsigned long *x, y, z; -#ifdef VAX - unsigned long d0, d1; - d.d = _d; - d0 = word0 (d) >> 16 | word0 (d) << 16; - d1 = word1 (d) >> 16 | word1 (d) << 16; -#else -#define d0 word0(d) -#define d1 word1(d) - d.d = _d; -#endif - -#ifdef Pack_32 - b = Balloc (ptr, 1); -#else - b = Balloc (ptr, 2); -#endif - x = b->_x; - - z = d0 & Frac_mask; - d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ -#ifdef Sudden_Underflow - de = (int) (d0 >> Exp_shift); -#ifndef IBM - z |= Exp_msk11; -#endif -#else - if ((de = (int) (d0 >> Exp_shift))) - z |= Exp_msk1; -#endif -#ifdef Pack_32 -#ifndef _DOUBLE_IS_32BITS - if ((y = d1)) - { - if ((k = lo0bits (&y))) - { - x[0] = y | z << (32 - k); - z >>= k; - } - else - x[0] = y; - i = b->_wds = (x[1] = z) ? 2 : 1; - } - else -#endif - { -#ifdef DEBUG - if (!z) - Bug ("Zero passed to d2b"); -#endif - k = lo0bits (&z); - x[0] = z; - i = b->_wds = 1; -#ifndef _DOUBLE_IS_32BITS - k += 32; -#endif - } -#else - if ((y = d1)) - { - if ((k = lo0bits (&y))) - if (k >= 16) - { - x[0] = y | (z << (32 - k) & 0xffff); - x[1] = z >> (k - 16) & 0xffff; - x[2] = z >> k; - i = 2; - } - else - { - x[0] = y & 0xffff; - x[1] = (y >> 16 | z << (16 - k)) & 0xffff; - x[2] = z >> k & 0xffff; - x[3] = z >> (k + 16); - i = 3; - } - else - { - x[0] = y & 0xffff; - x[1] = y >> 16; - x[2] = z & 0xffff; - x[3] = z >> 16; - i = 3; - } - } - else - { -#ifdef DEBUG - if (!z) - Bug ("Zero passed to d2b"); -#endif - k = lo0bits (&z); - if (k >= 16) - { - x[0] = z; - i = 0; - } - else - { - x[0] = z & 0xffff; - x[1] = z >> 16; - i = 1; - } - k += 32; - } - while (!x[i]) - --i; - b->_wds = i + 1; -#endif -#ifndef Sudden_Underflow - if (de) - { -#endif -#ifdef IBM - *e = (de - Bias - (P - 1) << 2) + k; - *bits = 4 * P + 8 - k - hi0bits (word0 (d) & Frac_mask); -#else - *e = de - Bias - (P - 1) + k; - *bits = P - k; -#endif -#ifndef Sudden_Underflow - } - else - { - *e = de - Bias - (P - 1) + 1 + k; -#ifdef Pack_32 - *bits = 32 * i - hi0bits (x[i - 1]); -#else - *bits = (i + 2) * 16 - hi0bits (x[i]); -#endif - } -#endif - return b; -} -#undef d0 -#undef d1 - -double -_DEFUN (ratio, (a, b), _Jv_Bigint * a _AND _Jv_Bigint * b) - -{ - union double_union da, db; - int k, ka, kb; - - da.d = b2d (a, &ka); - db.d = b2d (b, &kb); -#ifdef Pack_32 - k = ka - kb + 32 * (a->_wds - b->_wds); -#else - k = ka - kb + 16 * (a->_wds - b->_wds); -#endif -#ifdef IBM - if (k > 0) - { - word0 (da) += (k >> 2) * Exp_msk1; - if (k &= 3) - da.d *= 1 << k; - } - else - { - k = -k; - word0 (db) += (k >> 2) * Exp_msk1; - if (k &= 3) - db.d *= 1 << k; - } -#else - if (k > 0) - word0 (da) += k * Exp_msk1; - else - { - k = -k; - word0 (db) += k * Exp_msk1; - } -#endif - return da.d / db.d; -} - - -_CONST double - tens[] = -{ - 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - 1e20, 1e21, 1e22, 1e23, 1e24 - -}; - -#if !defined(_DOUBLE_IS_32BITS) && !defined(__v800) -_CONST double bigtens[] = -{1e16, 1e32, 1e64, 1e128, 1e256}; - -_CONST double tinytens[] = -{1e-16, 1e-32, 1e-64, 1e-128, 1e-256}; -#else -_CONST double bigtens[] = -{1e16, 1e32}; - -_CONST double tinytens[] = -{1e-16, 1e-32}; -#endif - - diff --git a/libjava/java/lang/mprec.h b/libjava/java/lang/mprec.h deleted file mode 100644 index 26472a2..0000000 --- a/libjava/java/lang/mprec.h +++ /dev/null @@ -1,397 +0,0 @@ -/**************************************************************** - * - * The author of this software is David M. Gay. - * - * Copyright (c) 1991, 2000 by AT&T. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose without fee is hereby granted, provided that this entire notice - * is included in all copies of any software which is or includes a copy - * or modification of this software and in all copies of the supporting - * documentation for such software. - * - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY - * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. - * - ***************************************************************/ - -/* Please send bug reports to - David M. Gay - AT&T Bell Laboratories, Room 2C-463 - 600 Mountain Avenue - Murray Hill, NJ 07974-2070 - U.S.A. - dmg@research.att.com or research!dmg - */ - -#include <config.h> -#include "ieeefp.h" - -#if defined HAVE_STDINT_H -#include <stdint.h> -#elif defined HAVE_INTTYPES_H -#include <inttypes.h> -#endif - -#if defined HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif - -#if defined HAVE_SYS_CONFIG_H -#include <sys/config.h> -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* ISO C99 int type declarations */ - -#if !defined HAVE_INT32_DEFINED && defined HAVE_BSD_INT32_DEFINED -typedef u_int32_t uint32_t; -#endif - -#if !defined HAVE_BSD_INT32_DEFINED && !defined HAVE_INT32_DEFINED -/* FIXME this could have problems with systems that don't define SI to be 4 */ -typedef int int32_t __attribute__((mode(SI))); - -/* This is a blatant hack: on Solaris 2.5, pthread.h defines uint32_t - in pthread.h, which we sometimes include. We protect our - definition the same way Solaris 2.5 does, to avoid redefining it. */ -# ifndef _UINT32_T -typedef unsigned int uint32_t __attribute__((mode(SI))); -# endif -#endif - - /* These typedefs are true for the targets running Java. */ - -#ifdef __IEEE_LITTLE_ENDIAN -#define IEEE_8087 -#endif - -#ifdef __IEEE_BIG_ENDIAN -#define IEEE_MC68k -#endif - -#ifdef __Z8000__ -#define Just_16 -#endif - -#ifdef DEBUG -#include "stdio.h" -#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} -#endif - - -#ifdef Unsigned_Shifts -#define Sign_Extend(a,b) if (b < 0) a |= (uint32_t)0xffff0000; -#else -#define Sign_Extend(a,b) /*no-op*/ -#endif - -#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 -Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. -#endif - -/* If we are going to examine or modify specific bits in a double using - the word0 and/or word1 macros, then we must wrap the double inside - a union. This is necessary to avoid undefined behavior according to - the ANSI C spec. */ -union double_union -{ - double d; - uint32_t i[2]; -}; - -#ifdef IEEE_8087 -#define word0(x) (x.i[1]) -#define word1(x) (x.i[0]) -#else -#define word0(x) (x.i[0]) -#define word1(x) (x.i[1]) -#endif - -/* The following definition of Storeinc is appropriate for MIPS processors. - * An alternative that might be better on some machines is - * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) - */ -#if defined(IEEE_8087) + defined(VAX) -#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \ -((unsigned short *)a)[0] = (unsigned short)c, a++) -#else -#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \ -((unsigned short *)a)[1] = (unsigned short)c, a++) -#endif - -/* #define P DBL_MANT_DIG */ -/* Ten_pmax = floor(P*log(2)/log(5)) */ -/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ -/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ -/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ - -#if defined(IEEE_8087) + defined(IEEE_MC68k) -#if defined (_DOUBLE_IS_32BITS) -#define Exp_shift 23 -#define Exp_shift1 23 -#define Exp_msk1 ((uint32_t)0x00800000L) -#define Exp_msk11 ((uint32_t)0x00800000L) -#define Exp_mask ((uint32_t)0x7f800000L) -#define P 24 -#define Bias 127 -#if 0 -#define IEEE_Arith /* it is, but the code doesn't handle IEEE singles yet */ -#endif -#define Emin (-126) -#define Exp_1 ((uint32_t)0x3f800000L) -#define Exp_11 ((uint32_t)0x3f800000L) -#define Ebits 8 -#define Frac_mask ((uint32_t)0x007fffffL) -#define Frac_mask1 ((uint32_t)0x007fffffL) -#define Ten_pmax 10 -#define Sign_bit ((uint32_t)0x80000000L) -#define Ten_pmax 10 -#define Bletch 2 -#define Bndry_mask ((uint32_t)0x007fffffL) -#define Bndry_mask1 ((uint32_t)0x007fffffL) -#define LSB 1 -#define Sign_bit ((uint32_t)0x80000000L) -#define Log2P 1 -#define Tiny0 0 -#define Tiny1 1 -#define Quick_max 5 -#define Int_max 6 -#define Infinite(x) (word0(x) == ((uint32_t)0x7f800000L)) -#undef word0 -#undef word1 - -#define word0(x) (x.i[0]) -#define word1(x) 0 -#else - -#define Exp_shift 20 -#define Exp_shift1 20 -#define Exp_msk1 ((uint32_t)0x100000L) -#define Exp_msk11 ((uint32_t)0x100000L) -#define Exp_mask ((uint32_t)0x7ff00000L) -#define P 53 -#define Bias 1023 -#define IEEE_Arith -#define Emin (-1022) -#define Exp_1 ((uint32_t)0x3ff00000L) -#define Exp_11 ((uint32_t)0x3ff00000L) -#define Ebits 11 -#define Frac_mask ((uint32_t)0xfffffL) -#define Frac_mask1 ((uint32_t)0xfffffL) -#define Ten_pmax 22 -#define Bletch 0x10 -#define Bndry_mask ((uint32_t)0xfffffL) -#define Bndry_mask1 ((uint32_t)0xfffffL) -#define LSB 1 -#define Sign_bit ((uint32_t)0x80000000L) -#define Log2P 1 -#define Tiny0 0 -#define Tiny1 1 -#define Quick_max 14 -#define Int_max 14 -#define Infinite(x) (word0(x) == ((uint32_t)0x7ff00000L)) /* sufficient test for here */ -#endif - -#else -#undef Sudden_Underflow -#define Sudden_Underflow -#ifdef IBM -#define Exp_shift 24 -#define Exp_shift1 24 -#define Exp_msk1 ((uint32_t)0x1000000L) -#define Exp_msk11 ((uint32_t)0x1000000L) -#define Exp_mask ((uint32_t)0x7f000000L) -#define P 14 -#define Bias 65 -#define Exp_1 ((uint32_t)0x41000000L) -#define Exp_11 ((uint32_t)0x41000000L) -#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ -#define Frac_mask ((uint32_t)0xffffffL) -#define Frac_mask1 ((uint32_t)0xffffffL) -#define Bletch 4 -#define Ten_pmax 22 -#define Bndry_mask ((uint32_t)0xefffffL) -#define Bndry_mask1 ((uint32_t)0xffffffL) -#define LSB 1 -#define Sign_bit ((uint32_t)0x80000000L) -#define Log2P 4 -#define Tiny0 ((uint32_t)0x100000L) -#define Tiny1 0 -#define Quick_max 14 -#define Int_max 15 -#else /* VAX */ -#define Exp_shift 23 -#define Exp_shift1 7 -#define Exp_msk1 0x80 -#define Exp_msk11 ((uint32_t)0x800000L) -#define Exp_mask ((uint32_t)0x7f80L) -#define P 56 -#define Bias 129 -#define Exp_1 ((uint32_t)0x40800000L) -#define Exp_11 ((uint32_t)0x4080L) -#define Ebits 8 -#define Frac_mask ((uint32_t)0x7fffffL) -#define Frac_mask1 ((uint32_t)0xffff007fL) -#define Ten_pmax 24 -#define Bletch 2 -#define Bndry_mask ((uint32_t)0xffff007fL) -#define Bndry_mask1 ((uint32_t)0xffff007fL) -#define LSB ((uint32_t)0x10000L) -#define Sign_bit ((uint32_t)0x8000L) -#define Log2P 1 -#define Tiny0 0x80 -#define Tiny1 0 -#define Quick_max 15 -#define Int_max 15 -#endif -#endif - -#ifndef IEEE_Arith -#define ROUND_BIASED -#endif - -#ifdef RND_PRODQUOT -#define rounded_product(a,b) a = rnd_prod(a, b) -#define rounded_quotient(a,b) a = rnd_quot(a, b) -#ifdef KR_headers -extern double rnd_prod(), rnd_quot(); -#else -extern double rnd_prod(double, double), rnd_quot(double, double); -#endif -#else -#define rounded_product(a,b) a *= b -#define rounded_quotient(a,b) a /= b -#endif - -#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) -#define Big1 ((uint32_t)0xffffffffL) - -#ifndef Just_16 -/* When Pack_32 is not defined, we store 16 bits per 32-bit long. - * This makes some inner loops simpler and sometimes saves work - * during multiplications, but it often seems to make things slightly - * slower. Hence the default is now to store 32 bits per long. - */ - -#ifndef Pack_32 -#if SIZEOF_VOID_P != 8 -#define Pack_32 -#endif -#endif -#endif - - -#define MAX_BIGNUMS 16 -#define MAX_BIGNUM_WDS 32 - -struct _Jv_Bigint -{ - struct _Jv_Bigint *_next; - int _k, _maxwds, _sign, _wds; - unsigned long _x[MAX_BIGNUM_WDS]; -}; - - -#define _PTR void * -#define _AND , -#define _NOARGS void -#define _CONST const -#define _VOLATILE volatile -#define _SIGNED signed -#define _DOTS , ... -#define _VOID void -#define _EXFUN(name, proto) name proto -#define _DEFUN(name, arglist, args) name(args) -#define _DEFUN_VOID(name) name(_NOARGS) -#define _CAST_VOID (void) - - -struct _Jv_reent -{ - /* local copy of errno */ - int _errno; - - /* used by mprec routines */ - struct _Jv_Bigint *_result; - int _result_k; - struct _Jv_Bigint *_p5s; - - struct _Jv_Bigint _freelist[MAX_BIGNUMS]; - int _allocation_map; - - int num; -}; - - -typedef struct _Jv_Bigint _Jv_Bigint; - -#define Balloc _Jv_Balloc -#define Bfree _Jv_Bfree -#define multadd _Jv_multadd -#define s2b _Jv_s2b -#define lo0bits _Jv_lo0bits -#define hi0bits _Jv_hi0bits -#define i2b _Jv_i2b -#define mult _Jv_mult -#define pow5mult _Jv_pow5mult -#define lshift _Jv_lshift -#define cmp _Jv__mcmp -#define diff _Jv__mdiff -#define ulp _Jv_ulp -#define b2d _Jv_b2d -#define d2b _Jv_d2b -#define ratio _Jv_ratio - -#define tens _Jv__mprec_tens -#define bigtens _Jv__mprec_bigtens -#define tinytens _Jv__mprec_tinytens - -#define _dtoa _Jv_dtoa -#define _dtoa_r _Jv_dtoa_r -#define _strtod_r _Jv_strtod_r - -extern double _EXFUN(_strtod_r, (struct _Jv_reent *ptr, const char *s00, char **se)); -extern char* _EXFUN(_dtoa_r, (struct _Jv_reent *ptr, double d, - int mode, int ndigits, int *decpt, int *sign, - char **rve, int float_type)); -void _EXFUN(_dtoa, (double d, int mode, int ndigits, int *decpt, int *sign, - char **rve, char *buf, int float_type)); - -double _EXFUN(ulp,(double x)); -double _EXFUN(b2d,(_Jv_Bigint *a , int *e)); -_Jv_Bigint * _EXFUN(Balloc,(struct _Jv_reent *p, int k)); -void _EXFUN(Bfree,(struct _Jv_reent *p, _Jv_Bigint *v)); -_Jv_Bigint * _EXFUN(multadd,(struct _Jv_reent *p, _Jv_Bigint *, int, int)); -_Jv_Bigint * _EXFUN(s2b,(struct _Jv_reent *, const char*, int, int, unsigned long)); -_Jv_Bigint * _EXFUN(i2b,(struct _Jv_reent *,int)); -_Jv_Bigint * _EXFUN(mult, (struct _Jv_reent *, _Jv_Bigint *, _Jv_Bigint *)); -_Jv_Bigint * _EXFUN(pow5mult, (struct _Jv_reent *, _Jv_Bigint *, int k)); -int _EXFUN(hi0bits,(unsigned long)); -int _EXFUN(lo0bits,(unsigned long *)); -_Jv_Bigint * _EXFUN(d2b,(struct _Jv_reent *p, double d, int *e, int *bits)); -_Jv_Bigint * _EXFUN(lshift,(struct _Jv_reent *p, _Jv_Bigint *b, int k)); -_Jv_Bigint * _EXFUN(diff,(struct _Jv_reent *p, _Jv_Bigint *a, _Jv_Bigint *b)); -int _EXFUN(cmp,(_Jv_Bigint *a, _Jv_Bigint *b)); - -double _EXFUN(ratio,(_Jv_Bigint *a, _Jv_Bigint *b)); -#define Bcopy(x,y) memcpy((char *)&x->_sign, (char *)&y->_sign, y->_wds*sizeof(long) + 2*sizeof(int)) - -#if defined(_DOUBLE_IS_32BITS) && defined(__v800) -#define n_bigtens 2 -#else -#define n_bigtens 5 -#endif - -extern _CONST double tinytens[]; -extern _CONST double bigtens[]; -extern _CONST double tens[]; - -#ifdef __cplusplus -} -#endif diff --git a/libjava/java/lang/ref/PhantomReference.java b/libjava/java/lang/ref/PhantomReference.java deleted file mode 100644 index 4d929c2..0000000 --- a/libjava/java/lang/ref/PhantomReference.java +++ /dev/null @@ -1,73 +0,0 @@ -/* java.lang.ref.PhantomReference - Copyright (C) 1999 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang.ref; - -/** - * A phantom reference is useful, to get notified, when an object got - * finalized. You can't access that object though, since it is - * finalized. This is the reason, why <code>get()</code> always - * returns null. - * - * @author Jochen Hoenicke - */ -public class PhantomReference - extends Reference -{ - /** - * Creates a new phantom reference. - * @param referent the object that should be watched. - * @param q the queue that should be notified, if the referent was - * finalized. This mustn't be <code>null</code>. - * @exception NullPointerException if q is null. - */ - public PhantomReference(Object referent, ReferenceQueue q) - { - super(referent, q); - } - - /** - * Returns the object, this reference refers to. - * @return <code>null</code>, since the refered object may be - * finalized and thus not accessible. - */ - public Object get() - { - return null; - } -} diff --git a/libjava/java/lang/ref/ReferenceQueue.java b/libjava/java/lang/ref/ReferenceQueue.java deleted file mode 100644 index f4729f2..0000000 --- a/libjava/java/lang/ref/ReferenceQueue.java +++ /dev/null @@ -1,145 +0,0 @@ -/* java.lang.ref.ReferenceQueue - Copyright (C) 1999 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang.ref; - -/** - * This is the queue, where references can enqueue themselve on. Each - * reference may be registered to a queue at initialization time and - * will be appended to the queue, when the enqueue method is called. - * - * The enqueue method may be automatically called by the garbage - * collector if it detects, that the object is only reachable through - * the Reference objects. - * - * @author Jochen Hoenicke - * @see Reference#enqueue() - */ -public class ReferenceQueue -{ - /** - * This is a linked list of references. If this is null, the list is - * empty. Otherwise this points to the first reference on the queue. - * The first reference will point to the next reference via the - * <code>nextOnQueue</code> field. The last reference will point to - * itself (not to null, since <code>nextOnQueue</code> is used to - * determine if a reference is enqueued). - */ - private Reference first; - - /** - * Creates a new empty reference queue. - */ - public ReferenceQueue() - { - } - - /** - * Checks if there is a reference on the queue, returning it - * immediately. The reference will be dequeued. - * - * @return a reference on the queue, if there is one, - * <code>null</code> otherwise. - */ - public synchronized Reference poll() - { - return dequeue(); - } - - /** - * This is called by reference to enqueue itself on this queue. - * @param ref the reference that should be enqueued. - */ - synchronized void enqueue(Reference ref) - { - /* last reference will point to itself */ - ref.nextOnQueue = first == null ? ref : first; - first = ref; - /* this wakes only one remove thread. */ - notify(); - } - - /** - * Remove a reference from the queue, if there is one. - * @return the first element of the queue, or null if there isn't any. - */ - private Reference dequeue() - { - if (first == null) - return null; - - Reference result = first; - first = (first == first.nextOnQueue) ? null : first.nextOnQueue; - result.nextOnQueue = null; - return result; - } - - /** - * Removes a reference from the queue, blocking for <code>timeout</code> - * until a reference is enqueued. - * @param timeout the timeout period in milliseconds, <code>0</code> means - * wait forever. - * @return the reference removed from the queue, or - * <code>null</code> if timeout period expired. - * @exception InterruptedException if the wait was interrupted. - */ - public synchronized Reference remove(long timeout) - throws InterruptedException - { - if (first == null) - { - wait(timeout); - } - - return dequeue(); - } - - - /** - * Removes a reference from the queue, blocking until a reference is - * enqueued. - * - * @return the reference removed from the queue. - * @exception InterruptedException if the wait was interrupted. - */ - public Reference remove() - throws InterruptedException - { - return remove(0L); - } -} diff --git a/libjava/java/lang/ref/SoftReference.java b/libjava/java/lang/ref/SoftReference.java deleted file mode 100644 index 97395ea..0000000 --- a/libjava/java/lang/ref/SoftReference.java +++ /dev/null @@ -1,84 +0,0 @@ -/* java.lang.ref.SoftReference - Copyright (C) 1999 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang.ref; - -/** - * A soft reference will be cleared, if the object is only softly - * reachable and the garbage collection needs more memory. The garbage - * collection will use an intelligent strategy to determine which soft - * references it should clear. This makes a soft reference ideal for - * caches.<br> - * - * @author Jochen Hoenicke - */ -public class SoftReference - extends Reference -{ - /** - * Create a new soft reference, that is not registered to any queue. - * @param referent the object we refer to. - */ - public SoftReference(Object referent) - { - super(referent); - } - - /** - * Create a new soft reference. - * @param referent the object we refer to. - * @param q the reference queue to register on. - * @exception NullPointerException if q is null. - */ - public SoftReference(Object referent, ReferenceQueue q) - { - super(referent, q); - } - - /** - * Returns the object, this reference refers to. - * @return the object, this reference refers to, or null if the - * reference was cleared. - */ - public Object get() - { - /* Why is this overloaded??? - * Maybe for a kind of LRU strategy. */ - return super.get(); - } -} diff --git a/libjava/java/lang/ref/WeakReference.java b/libjava/java/lang/ref/WeakReference.java deleted file mode 100644 index 9f758ca..0000000 --- a/libjava/java/lang/ref/WeakReference.java +++ /dev/null @@ -1,79 +0,0 @@ -/* java.lang.ref.WeakReference - Copyright (C) 1999 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang.ref; - -/** - * A weak reference will be cleared, if the object is only weakly - * reachable. It is useful for lookup tables, where you aren't - * interested in an entry, if the key isn't reachable anymore. - * <code>WeakHashtable</code> is a complete implementation of such a - * table. <br> - * - * It is also useful to make objects unique: You create a set of weak - * references to those objects, and when you create a new object you - * look in this set, if the object already exists and return it. If - * an object is not referenced anymore, the reference will - * automatically cleared, and you may remove it from the set. <br> - * - * @author Jochen Hoenicke - * @see java.util.WeakHashtable - */ -public class WeakReference - extends Reference -{ - /** - * Create a new weak reference, that is not registered to any queue. - * @param referent the object we refer to. - */ - public WeakReference(Object referent) - { - super(referent); - } - - /** - * Create a new weak reference. - * @param referent the object we refer to. - * @param q the reference queue to register on. - * @exception NullPointerException if q is null. - */ - public WeakReference(Object referent, ReferenceQueue q) - { - super(referent, q); - } -} diff --git a/libjava/java/lang/reflect/AccessibleObject.java b/libjava/java/lang/reflect/AccessibleObject.java deleted file mode 100644 index 24418c9..0000000 --- a/libjava/java/lang/reflect/AccessibleObject.java +++ /dev/null @@ -1,159 +0,0 @@ -/* java.lang.reflect.AccessibleObject - Copyright (C) 2001, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang.reflect; - -/** - * This class is the superclass of various reflection classes, and - * allows sufficiently trusted code to bypass normal restrictions to - * do necessary things like invoke private methods outside of the - * class during Serialization. If you don't have a good reason - * to mess with this, don't try. Fortunately, there are adequate - * security checks before you can set a reflection object as accessible. - * - * @author Tom Tromey (tromey@cygnus.com) - * @author Eric Blake (ebb9@email.byu.edu) - * @see Field - * @see Constructor - * @see Method - * @see ReflectPermission - * @since 1.2 - * @status updated to 1.4 - */ -public class AccessibleObject -{ - /** - * True if this object is marked accessible, which means the reflected - * object bypasses normal security checks. - */ - // default visibility for use by inherited classes - boolean flag = false; - - /** - * Only the three reflection classes that extend this can create an - * accessible object. This is not serializable for security reasons. - */ - protected AccessibleObject() - { - } - - /** - * Return the accessibility status of this object. - * - * @return true if this object bypasses security checks - */ - public boolean isAccessible() - { - return flag; - } - - /** - * Convenience method to set the flag on a number of objects with a single - * security check. If a security manager exists, it is checked for - * <code>ReflectPermission("suppressAccessChecks")</code>.<p> - * - * It is forbidden to set the accessibility flag to true on any constructor - * for java.lang.Class. This will result in a SecurityException. If the - * SecurityException is thrown for any of the passed AccessibleObjects, - * the accessibility flag will be set on AccessibleObjects in the array prior - * to the one which resulted in the exception. - * - * @param array the array of accessible objects - * @param flag the desired state of accessibility, true to bypass security - * @throws NullPointerException if array is null - * @throws SecurityException if the request is denied - * @see SecurityManager#checkPermission(java.security.Permission) - * @see RuntimePermission - */ - public static void setAccessible(AccessibleObject[] array, boolean flag) - { - checkPermission(); - for (int i = 0; i < array.length; i++) - array[i].secureSetAccessible(flag); - } - - /** - * Sets the accessibility flag for this reflection object. If a security - * manager exists, it is checked for - * <code>ReflectPermission("suppressAccessChecks")</code>.<p> - * - * It is forbidden to set the accessibility flag to true on any constructor for - * java.lang.Class. This will result in a SecurityException. - * - * @param flag the desired state of accessibility, true to bypass security - * @throws NullPointerException if array is null - * @throws SecurityException if the request is denied - * @see SecurityManager#checkPermission(java.security.Permission) - * @see RuntimePermission - */ - public void setAccessible(boolean flag) - { - checkPermission(); - secureSetAccessible(flag); - } - - /** - * Performs the specified security check, for - * <code>ReflectPermission("suppressAccessChecks")</code>. - * - * @throws SecurityException if permission is denied - */ - private static void checkPermission() - { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) - sm.checkPermission(new ReflectPermission("suppressAccessChecks")); - } - - /** - * Performs the actual accessibility change, this must always be invoked - * after calling checkPermission. - * - * @param flag the desired status - * @throws SecurityException if flag is true and this is a constructor - * for <code>java.lang.Class</code>. - */ - private void secureSetAccessible(boolean flag) - { - if (flag && - (this instanceof Constructor - && ((Constructor) this).getDeclaringClass() == Class.class)) - throw new SecurityException("Cannot make object accessible: " + this); - this.flag = flag; - } -} diff --git a/libjava/java/lang/reflect/InvocationHandler.java b/libjava/java/lang/reflect/InvocationHandler.java deleted file mode 100644 index 208e621..0000000 --- a/libjava/java/lang/reflect/InvocationHandler.java +++ /dev/null @@ -1,137 +0,0 @@ -/* java.lang.reflect.InvocationHandler - dynamically executes methods in - proxy instances - Copyright (C) 2001 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang.reflect; - -/** - * This interface defines an invocation handler. Suppose you are using - * reflection, and found a method that requires that its parameter - * be an object of a given interface. You want to call this method, - * but have no idea what classes implement that interface. So, you can - * create a {@link Proxy} instance, a convenient way to dynamically - * generate a class that meets all the necessary properties of that - * interface. But in order for the proxy instance to do any good, it - * needs to know what to do when interface methods are invoked! So, - * this interface is basically a cool wrapper that provides runtime - * code generation needed by proxy instances. - * - * <p>While this interface was designed for use by Proxy, it will also - * work on any object in general.</p> - * - * <p>Hints for implementing this class:</p> - * - * <ul> - * <li>Don't forget that Object.equals, Object.hashCode, and - * Object.toString will call this handler. In particular, - * a naive call to proxy.equals, proxy.hashCode, or proxy.toString - * will put you in an infinite loop. And remember that string - * concatenation also invokes toString.</li> - * <li>Obey the contract of the Method object you are handling, or - * the proxy instance will be forced to throw a - * {@link NullPointerException}, {@link ClassCastException}, - * or {@link UndeclaredThrowableException}.</li> - * <li>Be prepared to wrap/unwrap primitives as necessary.</li> - * <li>The Method object may be owned by a different interface than - * what was actually used as the qualifying type of the method - * invocation in the Java source code. This means that it might - * not always be safe to throw an exception listed as belonging - * to the method's throws clause.</li> - * </ul> - * - * <p><small>For a fun time, create an InvocationHandler that handles the - * methods of a proxy instance of the InvocationHandler interface!</small></p> - * - * @see Proxy - * @see UndeclaredThrowableException - * - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.3 - * @status updated to 1.4 - */ -public interface InvocationHandler -{ - /** - * When a method is invoked on a proxy instance, it is wrapped and - * this method is called instead, so that you may decide at runtime - * how the original method should behave. - * - * @param proxy the instance that the wrapped method should be - * invoked on. When this method is called by a Proxy object, - * `proxy' will be an instance of {@link Proxy}, and oddly enough, - * <code>Proxy.getInvocationHandler(proxy)</code> will return - * <code>this</code>! - * @param method the reflected method to invoke on the proxy. - * When this method is called by a Proxy object, 'method' - * will be the reflection object owned by the declaring - * class or interface, which may be a supertype of the - * interfaces the proxy directly implements. - * @param args the arguments passed to the original method, or - * <code>null</code> if the method takes no arguments. - * (But also be prepared to handle a 0-length array). - * Arguments of primitive type, such as <code>boolean</code> - * or <code>int</code>, are wrapped in the appropriate - * class such as {@link Boolean} or {@link Integer}. - * @return whatever is necessary to return from the wrapped method. - * If the wrapped method is <code>void</code>, the proxy - * instance will ignore it. If the wrapped method returns - * a primitive, this must be the correct wrapper type whose value - * is exactly assignable to the appropriate type (no widening - * will be performed); a null object in this case causes a - * {@link NullPointerException}. In all remaining cases, if - * the returned object is not assignment compatible to the - * declared type of the original method, the proxy instance - * will generate a {@link ClassCastException}. - * @throws Throwable this interface is listed as throwing anything, - * but the implementation should only throw unchecked - * exceptions and exceptions listed in the throws clause of - * all methods being overridden by the proxy instance. If - * something is thrown that is not compatible with the throws - * clause of all overridden methods, the proxy instance will - * wrap the exception in an UndeclaredThrowableException. - * Note that an exception listed in the throws clause of the - * `method' parameter might not be declared in additional - * interfaces also implemented by the proxy object. - * - * @see Proxy - * @see UndeclaredThrowableException - */ - Object invoke(Object proxy, Method method, Object[] args) - throws Throwable; - -} diff --git a/libjava/java/lang/reflect/InvocationTargetException.java b/libjava/java/lang/reflect/InvocationTargetException.java deleted file mode 100644 index af79d3a..0000000 --- a/libjava/java/lang/reflect/InvocationTargetException.java +++ /dev/null @@ -1,123 +0,0 @@ -/* InvocationTargetException.java -- Wrapper exception for reflection - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang.reflect; - -/** - * InvocationTargetException is sort of a way to "wrap" whatever exception - * comes up when a method or constructor is called via Reflection. As of - * JDK 1.4, it was retrofitted to match the exception chaining of all other - * exceptions, but <code>getTargetException()</code> still works. - * - * @author John Keiser - * @author Tom Tromey (tromey@cygnus.com) - * @author Eric Blake (ebb9@email.byu.edu) - * @see Method#invoke(Object,Object[]) - * @see Constructor#newInstance(Object[]) - * @since 1.1 - * @status updated to 1.4 - */ -public class InvocationTargetException extends Exception -{ - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = 4085088731926701167L; - - /** - * The chained exception. This field is only around for serial compatibility. - * - * @serial the chained exception - */ - private final Throwable target; - - /** - * Construct an exception with null as the cause. The cause is initialized - * to null. - */ - protected InvocationTargetException() - { - this(null, null); - } - - /** - * Create an <code>InvocationTargetException</code> using another - * exception. - * - * @param targetException the exception to wrap - */ - public InvocationTargetException(Throwable targetException) - { - this(targetException, null); - } - - /** - * Create an <code>InvocationTargetException</code> using another - * exception and an error message. - * - * @param targetException the exception to wrap - * @param err an extra reason for the exception-throwing - */ - public InvocationTargetException(Throwable targetException, String err) - { - super(err, targetException); - target = targetException; - } - - /** - * Get the wrapped (targeted) exception. - * - * @return the targeted exception - * @see #getCause() - */ - public Throwable getTargetException() - { - return target; - } - - /** - * Returns the cause of this exception (which may be null). - * - * @return the cause - * @since 1.4 - */ - public Throwable getCause() - { - return target; - } -} diff --git a/libjava/java/lang/reflect/Member.java b/libjava/java/lang/reflect/Member.java deleted file mode 100644 index 9983b27..0000000 --- a/libjava/java/lang/reflect/Member.java +++ /dev/null @@ -1,100 +0,0 @@ -/* java.lang.reflect.Member - common query methods in reflection - Copyright (C) 1998, 1999, 2001, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang.reflect; - -/** - * Member is an interface that represents any member of a class (field or - * method) or a constructor. You can get information about the declaring - * class, name or modifiers of the member with this interface. - * - * @author John Keiser - * @author Per Bothner (bothner@cygnus.com) - * @author Eric Blake (ebb9@email.byu.edu) - * @see Class - * @see Field - * @see Method - * @see Constructor - * @since 1.1 - * @status updated to 1.4 - */ -public interface Member -{ - /** - * Represents all members, whether public, private, protected or - * package-protected, but only which are declared in this class. - * Used in SecurityManager.checkMemberAccess() to determine the - * type of members to access. - * @see SecurityManager#checkMemberAccess() - */ - int DECLARED = 1; - - /** - * Represents public members only, but includes all inherited members. - * Used in SecurityManager.checkMemberAccess() to determine the type of - * members to access. - * @see SecurityManager#checkMemberAccess() - */ - int PUBLIC = 0; - - /** - * Gets the class that declared this member. This is not the class where - * this method was called, or even the class where this Member object - * came to life, but the class that declares the member this represents. - * - * @return the class that declared this member - */ - Class getDeclaringClass(); - - /** - * Gets the simple name of this member. This will be a valid Java - * identifier, with no qualification. - * - * @return the name of this member - */ - String getName(); - - /** - * Gets the modifiers this member uses. Use the <code>Modifier</code> - * class to interpret the values. - * - * @return an integer representing the modifiers to this Member - * @see Modifier - */ - int getModifiers(); -} diff --git a/libjava/java/lang/reflect/Proxy.java b/libjava/java/lang/reflect/Proxy.java deleted file mode 100644 index dc1ac87..0000000 --- a/libjava/java/lang/reflect/Proxy.java +++ /dev/null @@ -1,1615 +0,0 @@ -/* Proxy.java -- build a proxy class that implements reflected interfaces - Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang.reflect; - -import gnu.classpath.Configuration; -import gnu.java.lang.reflect.TypeSignature; - -import java.io.Serializable; -import java.security.ProtectionDomain; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * This class allows you to dynamically create an instance of any (or - * even multiple) interfaces by reflection, and decide at runtime - * how that instance will behave by giving it an appropriate - * {@link InvocationHandler}. Proxy classes serialize specially, so - * that the proxy object can be reused between VMs, without requiring - * a persistent copy of the generated class code. - * - * <h3>Creation</h3> - * To create a proxy for some interface Foo: - * - * <pre> - * InvocationHandler handler = new MyInvocationHandler(...); - * Class proxyClass = Proxy.getProxyClass( - * Foo.class.getClassLoader(), new Class[] { Foo.class }); - * Foo f = (Foo) proxyClass - * .getConstructor(new Class[] { InvocationHandler.class }) - * .newInstance(new Object[] { handler }); - * </pre> - * or more simply: - * <pre> - * Foo f = (Foo) Proxy.newProxyInstance(Foo.class.getClassLoader(), - * new Class[] { Foo.class }, - * handler); - * </pre> - * - * <h3>Dynamic Proxy Classes</h3> - * A dynamic proxy class is created at runtime, and has the following - * properties: - * <ul> - * <li>The class is <code>public</code> and <code>final</code>, - * and is neither <code>abstract</code> nor an inner class.</li> - * <li>The class has no canonical name (there is no formula you can use - * to determine or generate its name), but begins with the - * sequence "$Proxy". Abuse this knowledge at your own peril. - * (For now, '$' in user identifiers is legal, but it may not - * be that way forever. You weren't using '$' in your - * identifiers, were you?)</li> - * <li>The class extends Proxy, and explicitly implements all the - * interfaces specified at creation, in order (this is important - * for determining how method invocation is resolved). Note that - * a proxy class implements {@link Serializable}, at least - * implicitly, since Proxy does, but true serial behavior - * depends on using a serializable invocation handler as well.</li> - * <li>If at least one interface is non-public, the proxy class - * will be in the same package. Otherwise, the package is - * unspecified. This will work even if the package is sealed - * from user-generated classes, because Proxy classes are - * generated by a trusted source. Meanwhile, the proxy class - * belongs to the classloader you designated.</li> - * <li>Reflection works as expected: {@link Class#getInterfaces()} and - * {@link Class#getMethods()} work as they do on normal classes.</li> - * <li>The method {@link #isProxyClass()} will distinguish between - * true proxy classes and user extensions of this class. It only - * returns true for classes created by {@link #getProxyClass}.</li> - * <li>The {@link ProtectionDomain} of a proxy class is the same as for - * bootstrap classes, such as Object or Proxy, since it is created by - * a trusted source. This protection domain will typically be granted - * {@link java.security.AllPermission}. But this is not a security - * risk, since there are adequate permissions on reflection, which is - * the only way to create an instance of the proxy class.</li> - * <li>The proxy class contains a single constructor, which takes as - * its only argument an {@link InvocationHandler}. The method - * {@link #newInstance} is shorthand to do the necessary - * reflection.</li> - * </ul> - * - * <h3>Proxy Instances</h3> - * A proxy instance is an instance of a proxy class. It has the - * following properties, many of which follow from the properties of a - * proxy class listed above: - * <ul> - * <li>For a proxy class with Foo listed as one of its interfaces, the - * expression <code>proxy instanceof Foo</code> will return true, - * and the expression <code>(Foo) proxy</code> will succeed without - * a {@link ClassCastException}.</li> - * <li>Each proxy instance has an invocation handler, which can be - * accessed by {@link #getInvocationHandler(Object)}. Any call - * to an interface method, including {@link Object#hashcode()}, - * {@link Object#equals(Object)}, or {@link Object#toString()}, - * but excluding the public final methods of Object, will be - * encoded and passed to the {@link InvocationHandler#invoke} - * method of this handler.</li> - * </ul> - * - * <h3>Inheritance Issues</h3> - * A proxy class may inherit a method from more than one interface. - * The order in which interfaces are listed matters, because it determines - * which reflected {@link Method} object will be passed to the invocation - * handler. This means that the dynamically generated class cannot - * determine through which interface a method is being invoked.<p> - * - * In short, if a method is declared in Object (namely, hashCode, - * equals, or toString), then Object will be used; otherwise, the - * leftmost interface that inherits or declares a method will be used, - * even if it has a more permissive throws clause than what the proxy - * class is allowed. Thus, in the invocation handler, it is not always - * safe to assume that every class listed in the throws clause of the - * passed Method object can safely be thrown; fortunately, the Proxy - * instance is robust enough to wrap all illegal checked exceptions in - * {@link UndeclaredThrowableException}. - * - * @see InvocationHandler - * @see UndeclaredThrowableException - * @see Class - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.3 - * @status updated to 1.4, except for the use of ProtectionDomain - */ -public class Proxy implements Serializable -{ - /** - * Compatible with JDK 1.3+. - */ - private static final long serialVersionUID = -2222568056686623797L; - - /** - * Map of ProxyType to proxy class. - * - * @XXX This prevents proxy classes from being garbage collected. - * java.util.WeakHashSet is not appropriate, because that collects the - * keys, but we are interested in collecting the elements. - */ - private static final Map proxyClasses = new HashMap(); - - /** - * The invocation handler for this proxy instance. For Proxy, this - * field is unused, but it appears here in order to be serialized in all - * proxy classes. - * - * <em>NOTE</em>: This implementation is more secure for proxy classes - * than what Sun specifies. Sun does not require h to be immutable, but - * this means you could change h after the fact by reflection. However, - * by making h immutable, we may break non-proxy classes which extend - * Proxy. - * @serial invocation handler associated with this proxy instance - */ - protected InvocationHandler h; - - /** - * Constructs a new Proxy from a subclass (usually a proxy class), - * with the specified invocation handler. - * - * <em>NOTE</em>: This throws a NullPointerException if you attempt - * to create a proxy instance with a null handler using reflection. - * This behavior is not yet specified by Sun; see Sun Bug 4487672. - * - * @param handler the invocation handler, may be null if the subclass - * is not a proxy class - * @throws NullPointerException if handler is null and this is a proxy - * instance - */ - protected Proxy(InvocationHandler handler) - { - if (handler == null && isProxyClass(getClass())) - throw new NullPointerException("invalid handler"); - h = handler; - } - - /** - * Returns the proxy {@link Class} for the given ClassLoader and array - * of interfaces, dynamically generating it if necessary. - * - * <p>There are several restrictions on this method, the violation of - * which will result in an IllegalArgumentException or - * NullPointerException:</p> - * - * <ul> - * <li>All objects in `interfaces' must represent distinct interfaces. - * Classes, primitive types, null, and duplicates are forbidden.</li> - * <li>The interfaces must be visible in the specified ClassLoader. - * In other words, for each interface i: - * <code>Class.forName(i.getName(), false, loader) == i</code> - * must be true.</li> - * <li>All non-public interfaces (if any) must reside in the same - * package, or the proxy class would be non-instantiable. If - * there are no non-public interfaces, the package of the proxy - * class is unspecified.</li> - * <li>All interfaces must be compatible - if two declare a method - * with the same name and parameters, the return type must be - * the same and the throws clause of the proxy class will be - * the maximal subset of subclasses of the throws clauses for - * each method that is overridden.</li> - * <li>VM constraints limit the number of interfaces a proxy class - * may directly implement (however, the indirect inheritance - * of {@link Serializable} does not count against this limit). - * Even though most VMs can theoretically have 65535 - * superinterfaces for a class, the actual limit is smaller - * because a class's constant pool is limited to 65535 entries, - * and not all entries can be interfaces.</li> - * </ul> - * - * <p>Note that different orders of interfaces produce distinct classes.</p> - * - * @param loader the class loader to define the proxy class in; null - * implies the bootstrap class loader - * @param interfaces the array of interfaces the proxy class implements, - * may be empty, but not null - * @return the Class object of the proxy class - * @throws IllegalArgumentException if the constraints above were - * violated, except for problems with null - * @throws NullPointerException if `interfaces' is null or contains - * a null entry - */ - // synchronized so that we aren't trying to build the same class - // simultaneously in two threads - public static synchronized Class getProxyClass(ClassLoader loader, - Class[] interfaces) - { - interfaces = (Class[]) interfaces.clone(); - ProxyType pt = new ProxyType(loader, interfaces); - Class clazz = (Class) proxyClasses.get(pt); - if (clazz == null) - { - if (Configuration.HAVE_NATIVE_GET_PROXY_CLASS) - clazz = getProxyClass0(loader, interfaces); - else - { - ProxyData data = (Configuration.HAVE_NATIVE_GET_PROXY_DATA - ? getProxyData0(loader, interfaces) - : ProxyData.getProxyData(pt)); - - clazz = (Configuration.HAVE_NATIVE_GENERATE_PROXY_CLASS - ? generateProxyClass0(loader, data) - : new ClassFactory(data).generate(loader)); - } - - Object check = proxyClasses.put(pt, clazz); - // assert check == null && clazz != null; - if (check != null || clazz == null) - throw new InternalError(/*"Fatal flaw in getProxyClass"*/); - } - return clazz; - } - - /** - * Combines several methods into one. This is equivalent to: - * <pre> - * Proxy.getProxyClass(loader, interfaces) - * .getConstructor(new Class[] {InvocationHandler.class}) - * .newInstance(new Object[] {handler}); - * </pre> - * except that it will not fail with the normal problems caused - * by reflection. It can still fail for the same reasons documented - * in getProxyClass, or if handler is null. - * - * @param loader the class loader to define the proxy class in; null - * implies the bootstrap class loader - * @param interfaces the array of interfaces the proxy class implements, - * may be empty, but not null - * @param handler the invocation handler, may not be null - * @return a proxy instance implementing the specified interfaces - * @throws IllegalArgumentException if the constraints for getProxyClass - * were violated, except for problems with null - * @throws NullPointerException if `interfaces' is null or contains - * a null entry, or if handler is null - * @see #getProxyClass(ClassLoader, Class[]) - * @see Class#getConstructor(Class[]) - * @see Constructor#newInstance(Object[]) - */ - public static Object newProxyInstance(ClassLoader loader, - Class[] interfaces, - InvocationHandler handler) - { - try - { - // getProxyClass() and Proxy() throw the necessary exceptions - return getProxyClass(loader, interfaces) - .getConstructor(new Class[] {InvocationHandler.class}) - .newInstance(new Object[] {handler}); - } - catch (RuntimeException e) - { - // Let IllegalArgumentException, NullPointerException escape. - // assert e instanceof IllegalArgumentException - // || e instanceof NullPointerException; - throw e; - } - catch (InvocationTargetException e) - { - // Let wrapped NullPointerException escape. - // assert e.getTargetException() instanceof NullPointerException - throw (NullPointerException) e.getCause(); - } - catch (Exception e) - { - // Covers InstantiationException, IllegalAccessException, - // NoSuchMethodException, none of which should be generated - // if the proxy class was generated correctly. - // assert false; - throw (Error) new InternalError("Unexpected: " + e).initCause(e); - } - } - - /** - * Returns true if and only if the Class object is a dynamically created - * proxy class (created by <code>getProxyClass</code> or by the - * syntactic sugar of <code>newProxyInstance</code>). - * - * <p>This check is secure (in other words, it is not simply - * <code>clazz.getSuperclass() == Proxy.class</code>), it will not - * be spoofed by non-proxy classes that extend Proxy. - * - * @param clazz the class to check, must not be null - * @return true if the class represents a proxy class - * @throws NullPointerException if clazz is null - */ - // This is synchronized on the off chance that another thread is - // trying to add a class to the map at the same time we read it. - public static synchronized boolean isProxyClass(Class clazz) - { - if (! Proxy.class.isAssignableFrom(clazz)) - return false; - // This is a linear search, even though we could do an O(1) search - // using new ProxyType(clazz.getClassLoader(), clazz.getInterfaces()). - return proxyClasses.containsValue(clazz); - } - - /** - * Returns the invocation handler for the given proxy instance.<p> - * - * <em>NOTE</em>: We guarantee a non-null result if successful, - * but Sun allows the creation of a proxy instance with a null - * handler. See the comments for {@link #Proxy(InvocationHandler)}. - * - * @param proxy the proxy instance, must not be null - * @return the invocation handler, guaranteed non-null. - * @throws IllegalArgumentException if - * <code>Proxy.isProxyClass(proxy.getClass())</code> returns false. - * @throws NullPointerException if proxy is null - */ - public static InvocationHandler getInvocationHandler(Object proxy) - { - if (! isProxyClass(proxy.getClass())) - throw new IllegalArgumentException("not a proxy instance"); - return ((Proxy) proxy).h; - } - - /** - * Optional native method to replace (and speed up) the pure Java - * implementation of getProxyClass. Only needed if - * Configuration.HAVE_NATIVE_GET_PROXY_CLASS is true, this does the - * work of both getProxyData0 and generateProxyClass0 with no - * intermediate form in Java. The native code may safely assume that - * this class must be created, and does not already exist. - * - * @param loader the class loader to define the proxy class in; null - * implies the bootstrap class loader - * @param interfaces the interfaces the class will extend - * @return the generated proxy class - * @throws IllegalArgumentException if the constraints for getProxyClass - * were violated, except for problems with null - * @throws NullPointerException if `interfaces' is null or contains - * a null entry, or if handler is null - * @see Configuration#HAVE_NATIVE_GET_PROXY_CLASS - * @see #getProxyClass(ClassLoader, Class[]) - * @see #getProxyData0(ClassLoader, Class[]) - * @see #generateProxyClass0(ProxyData) - */ - private static native Class getProxyClass0(ClassLoader loader, - Class[] interfaces); - - /** - * Optional native method to replace (and speed up) the pure Java - * implementation of getProxyData. Only needed if - * Configuration.HAVE_NATIVE_GET_PROXY_DATA is true. The native code - * may safely assume that a new ProxyData object must be created which - * does not duplicate any existing ones. - * - * @param loader the class loader to define the proxy class in; null - * implies the bootstrap class loader - * @param interfaces the interfaces the class will extend - * @return all data that is required to make this proxy class - * @throws IllegalArgumentException if the constraints for getProxyClass - * were violated, except for problems with null - * @throws NullPointerException if `interfaces' is null or contains - * a null entry, or if handler is null - * @see Configuration.HAVE_NATIVE_GET_PROXY_DATA - * @see #getProxyClass(ClassLoader, Class[]) - * @see #getProxyClass0(ClassLoader, Class[]) - * @see ProxyType#getProxyData() - */ - private static native ProxyData getProxyData0(ClassLoader loader, - Class[] interfaces); - - /** - * Optional native method to replace (and speed up) the pure Java - * implementation of generateProxyClass. Only needed if - * Configuration.HAVE_NATIVE_GENERATE_PROXY_CLASS is true. The native - * code may safely assume that a new Class must be created, and that - * the ProxyData object does not describe any existing class. - * - * @param loader the class loader to define the proxy class in; null - * implies the bootstrap class loader - * @param data the struct of information to convert to a Class. This - * has already been verified for all problems except exceeding - * VM limitations - * @return the newly generated class - * @throws IllegalArgumentException if VM limitations are exceeded - * @see #getProxyClass(ClassLoader, Class[]) - * @see #getProxyClass0(ClassLoader, Class[]) - * @see ProxyData#generateProxyClass(ClassLoader) - */ - private static native Class generateProxyClass0(ClassLoader loader, - ProxyData data); - - /** - * Helper class for mapping unique ClassLoader and interface combinations - * to proxy classes. - * - * @author Eric Blake (ebb9@email.byu.edu) - */ - private static final class ProxyType - { - /** - * Store the class loader (may be null) - */ - final ClassLoader loader; - - /** - * Store the interfaces (never null, all elements are interfaces) - */ - final Class[] interfaces; - - /** - * Construct the helper object. - * - * @param loader the class loader to define the proxy class in; null - * implies the bootstrap class loader - * @param interfaces an array of interfaces - */ - ProxyType(ClassLoader loader, Class[] interfaces) - { - if (loader == null) - loader = ClassLoader.getSystemClassLoader(); - this.loader = loader; - this.interfaces = interfaces; - } - - /** - * Calculates the hash code. - * - * @return a combination of the classloader and interfaces hashcodes. - */ - public int hashCode() - { - //loader is always not null - int hash = loader.hashCode(); - for (int i = 0; i < interfaces.length; i++) - hash = hash * 31 + interfaces[i].hashCode(); - return hash; - } - - // A more comprehensive comparison of two arrays, - // ignore array element order, and - // ignore redundant elements - private static boolean sameTypes(Class arr1[], Class arr2[]) { - if (arr1.length == 1 && arr2.length == 1) { - return arr1[0] == arr2[0]; - } - - // total occurrance of elements of arr1 in arr2 - int total_occ_of_arr1_in_arr2 = 0; - each_type: - for (int i = arr1.length; --i >= 0; ) - { - Class t = arr1[i]; - for (int j = i; --j >= 0; ) - { - if (t == arr1[j]) - { //found duplicate type - continue each_type; - } - } - - // count c(a unique element of arr1)'s - // occurrences in arr2 - int occ_in_arr2 = 0; - for (int j = arr2.length; --j >= 0; ) - { - if (t == arr2[j]) - { - ++occ_in_arr2; - } - } - if (occ_in_arr2 == 0) - { // t does not occur in arr2 - return false; - } - - total_occ_of_arr1_in_arr2 += occ_in_arr2; - } - // now, each element of arr2 must have been visited - return total_occ_of_arr1_in_arr2 == arr2.length; - } - - /** - * Calculates equality. - * - * @param the object to compare to - * @return true if it is a ProxyType with same data - */ - public boolean equals(Object other) - { - ProxyType pt = (ProxyType) other; - if (loader != pt.loader || interfaces.length != pt.interfaces.length) - return false; - return sameTypes(interfaces, pt.interfaces); - } - } // class ProxyType - - /** - * Helper class which allows hashing of a method name and signature - * without worrying about return type, declaring class, or throws clause, - * and which reduces the maximally common throws clause between two methods - * - * @author Eric Blake (ebb9@email.byu.edu) - */ - private static final class ProxySignature - { - /** - * The core signatures which all Proxy instances handle. - */ - static final HashMap coreMethods = new HashMap(); - static - { - try - { - ProxySignature sig - = new ProxySignature(Object.class - .getMethod("equals", - new Class[] {Object.class})); - coreMethods.put(sig, sig); - sig = new ProxySignature(Object.class.getMethod("hashCode", null)); - coreMethods.put(sig, sig); - sig = new ProxySignature(Object.class.getMethod("toString", null)); - coreMethods.put(sig, sig); - } - catch (Exception e) - { - // assert false; - throw (Error) new InternalError("Unexpected: " + e).initCause(e); - } - } - - /** - * The underlying Method object, never null - */ - final Method method; - - /** - * The set of compatible thrown exceptions, may be empty - */ - final Set exceptions = new HashSet(); - - /** - * Construct a signature - * - * @param method the Method this signature is based on, never null - */ - ProxySignature(Method method) - { - this.method = method; - Class[] exc = method.getExceptionTypes(); - int i = exc.length; - while (--i >= 0) - { - // discard unchecked exceptions - if (Error.class.isAssignableFrom(exc[i]) - || RuntimeException.class.isAssignableFrom(exc[i])) - continue; - exceptions.add(exc[i]); - } - } - - /** - * Given a method, make sure it's return type is identical - * to this, and adjust this signature's throws clause appropriately - * - * @param other the signature to merge in - * @throws IllegalArgumentException if the return types conflict - */ - void checkCompatibility(ProxySignature other) - { - if (method.getReturnType() != other.method.getReturnType()) - throw new IllegalArgumentException("incompatible return types: " - + method + ", " + other.method); - - // if you can think of a more efficient way than this O(n^2) search, - // implement it! - int size1 = exceptions.size(); - int size2 = other.exceptions.size(); - boolean[] valid1 = new boolean[size1]; - boolean[] valid2 = new boolean[size2]; - Iterator itr = exceptions.iterator(); - int pos = size1; - while (--pos >= 0) - { - Class c1 = (Class) itr.next(); - Iterator itr2 = other.exceptions.iterator(); - int pos2 = size2; - while (--pos2 >= 0) - { - Class c2 = (Class) itr2.next(); - if (c2.isAssignableFrom(c1)) - valid1[pos] = true; - if (c1.isAssignableFrom(c2)) - valid2[pos2] = true; - } - } - pos = size1; - itr = exceptions.iterator(); - while (--pos >= 0) - { - itr.next(); - if (! valid1[pos]) - itr.remove(); - } - pos = size2; - itr = other.exceptions.iterator(); - while (--pos >= 0) - { - itr.next(); - if (! valid2[pos]) - itr.remove(); - } - exceptions.addAll(other.exceptions); - } - - /** - * Calculates the hash code. - * - * @return a combination of name and parameter types - */ - public int hashCode() - { - int hash = method.getName().hashCode(); - Class[] types = method.getParameterTypes(); - for (int i = 0; i < types.length; i++) - hash = hash * 31 + types[i].hashCode(); - return hash; - } - - /** - * Calculates equality. - * - * @param the object to compare to - * @return true if it is a ProxySignature with same data - */ - public boolean equals(Object other) - { - ProxySignature ps = (ProxySignature) other; - Class[] types1 = method.getParameterTypes(); - Class[] types2 = ps.method.getParameterTypes(); - if (! method.getName().equals(ps.method.getName()) - || types1.length != types2.length) - return false; - int i = types1.length; - while (--i >= 0) - if (types1[i] != types2[i]) - return false; - return true; - } - } // class ProxySignature - - /** - * A flat representation of all data needed to generate bytecode/instantiate - * a proxy class. This is basically a struct. - * - * @author Eric Blake (ebb9@email.byu.edu) - */ - private static final class ProxyData - { - /** - * The package this class is in <b>including the trailing dot</b> - * or an empty string for the unnamed (aka default) package. - */ - String pack; - - /** - * The interfaces this class implements. Non-null, but possibly empty. - */ - Class[] interfaces; - - /** - * The Method objects this class must pass as the second argument to - * invoke (also useful for determining what methods this class has). - * Non-null, non-empty (includes at least Object.hashCode, Object.equals, - * and Object.toString). - */ - Method[] methods; - - /** - * The exceptions that do not need to be wrapped in - * UndeclaredThrowableException. exceptions[i] is the same as, or a - * subset of subclasses, of methods[i].getExceptionTypes(), depending on - * compatible throws clauses with multiple inheritance. It is unspecified - * if these lists include or exclude subclasses of Error and - * RuntimeException, but excluding them is harmless and generates a - * smaller class. - */ - Class[][] exceptions; - - /** - * For unique id's - */ - private static int count; - - /** - * The id of this proxy class - */ - final int id = count++; - - /** - * Construct a ProxyData with uninitialized data members. - */ - ProxyData() - { - } - - /** - * Return the name of a package (including the trailing dot) - * given the name of a class. - * Returns an empty string if no package. We use this in preference to - * using Class.getPackage() to avoid problems with ClassLoaders - * that don't set the package. - */ - private static String getPackage(Class k) - { - String name = k.getName(); - int idx = name.lastIndexOf('.'); - return name.substring(0, idx + 1); - } - - /** - * Verifies that the arguments are legal, and sets up remaining data - * This should only be called when a class must be generated, as - * it is expensive. - * - * @param pt the ProxyType to convert to ProxyData - * @return the flattened, verified ProxyData structure for use in - * class generation - * @throws IllegalArgumentException if `interfaces' contains - * non-interfaces or incompatible combinations, and verify is true - * @throws NullPointerException if interfaces is null or contains null - */ - static ProxyData getProxyData(ProxyType pt) - { - Map method_set = (Map) ProxySignature.coreMethods.clone(); - boolean in_package = false; // true if we encounter non-public interface - - ProxyData data = new ProxyData(); - data.interfaces = pt.interfaces; - - // if interfaces is too large, we croak later on when the constant - // pool overflows - int i = data.interfaces.length; - while (--i >= 0) - { - Class inter = data.interfaces[i]; - if (! inter.isInterface()) - throw new IllegalArgumentException("not an interface: " + inter); - try - { - if (Class.forName(inter.getName(), false, pt.loader) != inter) - throw new IllegalArgumentException("not accessible in " - + "classloader: " + inter); - } - catch (ClassNotFoundException e) - { - throw new IllegalArgumentException("not accessible in " - + "classloader: " + inter); - } - if (! Modifier.isPublic(inter.getModifiers())) - if (in_package) - { - String p = getPackage(inter); - if (! data.pack.equals(p)) - throw new IllegalArgumentException("non-public interfaces " - + "from different " - + "packages"); - } - else - { - in_package = true; - data.pack = getPackage(inter); - } - for (int j = i-1; j >= 0; j--) - if (data.interfaces[j] == inter) - throw new IllegalArgumentException("duplicate interface: " - + inter); - Method[] methods = inter.getMethods(); - int j = methods.length; - while (--j >= 0) - { - ProxySignature sig = new ProxySignature(methods[j]); - ProxySignature old = (ProxySignature) method_set.put(sig, sig); - if (old != null) - sig.checkCompatibility(old); - } - } - - i = method_set.size(); - data.methods = new Method[i]; - data.exceptions = new Class[i][]; - Iterator itr = method_set.values().iterator(); - while (--i >= 0) - { - ProxySignature sig = (ProxySignature) itr.next(); - data.methods[i] = sig.method; - data.exceptions[i] = (Class[]) sig.exceptions - .toArray(new Class[sig.exceptions.size()]); - } - return data; - } - } // class ProxyData - - /** - * Does all the work of building a class. By making this a nested class, - * this code is not loaded in memory if the VM has a native - * implementation instead. - * - * @author Eric Blake (ebb9@email.byu.edu) - */ - private static final class ClassFactory - { - /** Constants for assisting the compilation */ - private static final byte POOL = 0; - private static final byte FIELD = 1; - private static final byte METHOD = 2; - private static final byte INTERFACE = 3; - private static final String CTOR_SIG - = "(Ljava/lang/reflect/InvocationHandler;)V"; - private static final String INVOKE_SIG = "(Ljava/lang/Object;" - + "Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;"; - - /** Bytecodes for insertion in the class definition byte[] */ - private static final char ACONST_NULL = 1; - private static final char ICONST_0 = 3; - private static final char BIPUSH = 16; - private static final char SIPUSH = 17; - private static final char ILOAD = 21; - private static final char ILOAD_0 = 26; - private static final char ALOAD_0 = 42; - private static final char ALOAD_1 = 43; - private static final char AALOAD = 50; - private static final char AASTORE = 83; - private static final char DUP = 89; - private static final char DUP_X1 = 90; - private static final char SWAP = 95; - private static final char IRETURN = 172; - private static final char LRETURN = 173; - private static final char FRETURN = 174; - private static final char DRETURN = 175; - private static final char ARETURN = 176; - private static final char RETURN = 177; - private static final char GETSTATIC = 178; - private static final char GETFIELD = 180; - private static final char INVOKEVIRTUAL = 182; - private static final char INVOKESPECIAL = 183; - private static final char INVOKESTATIC = 184; - private static final char INVOKEINTERFACE = 185; - private static final char NEW = 187; - private static final char ANEWARRAY = 189; - private static final char ATHROW = 191; - private static final char CHECKCAST = 192; - - // Implementation note: we use StringBuffers to hold the byte data, since - // they automatically grow. However, we only use the low 8 bits of - // every char in the array, so we are using twice the necessary memory - // for the ease StringBuffer provides. - - /** The constant pool. */ - private final StringBuffer pool = new StringBuffer(); - /** The rest of the class data. */ - private final StringBuffer stream = new StringBuffer(); - - /** Map of strings to byte sequences, to minimize size of pool. */ - private final Map poolEntries = new HashMap(); - - /** The VM name of this proxy class. */ - private final String qualName; - - /** - * The Method objects the proxy class refers to when calling the - * invocation handler. - */ - private final Method[] methods; - - /** - * Initializes the buffers with the bytecode contents for a proxy class. - * - * @param data the remainder of the class data - * @throws IllegalArgumentException if anything else goes wrong this - * late in the game; as far as I can tell, this will only happen - * if the constant pool overflows, which is possible even when - * the user doesn't exceed the 65535 interface limit - */ - ClassFactory(ProxyData data) - { - methods = data.methods; - - // magic = 0xcafebabe - // minor_version = 0 - // major_version = 46 - // constant_pool_count: place-holder for now - pool.append("\u00ca\u00fe\u00ba\u00be\0\0\0\56\0\0"); - // constant_pool[], filled in as we go - - // access_flags - putU2(Modifier.SUPER | Modifier.FINAL | Modifier.PUBLIC); - // this_class - qualName = (data.pack + "$Proxy" + data.id); - putU2(classInfo(TypeSignature.getEncodingOfClass(qualName, false))); - // super_class - putU2(classInfo("java/lang/reflect/Proxy")); - - // interfaces_count - putU2(data.interfaces.length); - // interfaces[] - for (int i = 0; i < data.interfaces.length; i++) - putU2(classInfo(data.interfaces[i])); - - // Recall that Proxy classes serialize specially, so we do not need - // to worry about a <clinit> method for this field. Instead, we - // just assign it by reflection after the class is successfully loaded. - // fields_count - private static Method[] m; - putU2(1); - // fields[] - // m.access_flags - putU2(Modifier.PRIVATE | Modifier.STATIC); - // m.name_index - putU2(utf8Info("m")); - // m.descriptor_index - putU2(utf8Info("[Ljava/lang/reflect/Method;")); - // m.attributes_count - putU2(0); - // m.attributes[] - - // methods_count - # handler methods, plus <init> - putU2(methods.length + 1); - // methods[] - // <init>.access_flags - putU2(Modifier.PUBLIC); - // <init>.name_index - putU2(utf8Info("<init>")); - // <init>.descriptor_index - putU2(utf8Info(CTOR_SIG)); - // <init>.attributes_count - only Code is needed - putU2(1); - // <init>.Code.attribute_name_index - putU2(utf8Info("Code")); - // <init>.Code.attribute_length = 18 - // <init>.Code.info: - // $Proxynn(InvocationHandler h) { super(h); } - // <init>.Code.max_stack = 2 - // <init>.Code.max_locals = 2 - // <init>.Code.code_length = 6 - // <init>.Code.code[] - stream.append("\0\0\0\22\0\2\0\2\0\0\0\6" + ALOAD_0 + ALOAD_1 - + INVOKESPECIAL); - putU2(refInfo(METHOD, "java/lang/reflect/Proxy", "<init>", CTOR_SIG)); - // <init>.Code.exception_table_length = 0 - // <init>.Code.exception_table[] - // <init>.Code.attributes_count = 0 - // <init>.Code.attributes[] - stream.append(RETURN + "\0\0\0\0"); - - for (int i = methods.length - 1; i >= 0; i--) - emitMethod(i, data.exceptions[i]); - - // attributes_count - putU2(0); - // attributes[] - empty; omit SourceFile attribute - // XXX should we mark this with a Synthetic attribute? - } - - /** - * Produce the bytecode for a single method. - * - * @param i the index of the method we are building - * @param e the exceptions possible for the method - */ - private void emitMethod(int i, Class[] e) - { - // First, we precalculate the method length and other information. - - Method m = methods[i]; - Class[] paramtypes = m.getParameterTypes(); - int wrap_overhead = 0; // max words taken by wrapped primitive - int param_count = 1; // 1 for this - int code_length = 16; // aload_0, getfield, aload_0, getstatic, const, - // aaload, const/aconst_null, invokeinterface - if (i > 5) - { - if (i > Byte.MAX_VALUE) - code_length += 2; // sipush - else - code_length++; // bipush - } - if (paramtypes.length > 0) - { - code_length += 3; // anewarray - if (paramtypes.length > Byte.MAX_VALUE) - code_length += 2; // sipush - else if (paramtypes.length > 5) - code_length++; // bipush - for (int j = 0; j < paramtypes.length; j++) - { - code_length += 4; // dup, const, load, store - Class type = paramtypes[j]; - if (j > 5) - { - if (j > Byte.MAX_VALUE) - code_length += 2; // sipush - else - code_length++; // bipush - } - if (param_count >= 4) - code_length++; // 2-byte load - param_count++; - if (type.isPrimitive()) - { - code_length += 7; // new, dup, invokespecial - if (type == long.class || type == double.class) - { - wrap_overhead = 3; - param_count++; - } - else if (wrap_overhead < 2) - wrap_overhead = 2; - } - } - } - int end_pc = code_length; - Class ret_type = m.getReturnType(); - if (ret_type == void.class) - code_length++; // return - else if (ret_type.isPrimitive()) - code_length += 7; // cast, invokevirtual, return - else - code_length += 4; // cast, return - int exception_count = 0; - boolean throws_throwable = false; - for (int j = 0; j < e.length; j++) - if (e[j] == Throwable.class) - { - throws_throwable = true; - break; - } - if (! throws_throwable) - { - exception_count = e.length + 3; // Throwable, Error, RuntimeException - code_length += 9; // new, dup_x1, swap, invokespecial, athrow - } - int handler_pc = code_length - 1; - StringBuffer signature = new StringBuffer("("); - for (int j = 0; j < paramtypes.length; j++) - signature.append(TypeSignature.getEncodingOfClass(paramtypes[j])); - signature.append(")").append(TypeSignature.getEncodingOfClass(ret_type)); - - // Now we have enough information to emit the method. - - // handler.access_flags - putU2(Modifier.PUBLIC | Modifier.FINAL); - // handler.name_index - putU2(utf8Info(m.getName())); - // handler.descriptor_index - putU2(utf8Info(signature.toString())); - // handler.attributes_count - Code is necessary, Exceptions possible - putU2(e.length > 0 ? 2 : 1); - - // handler.Code.info: - // type name(args) { - // try { - // return (type) h.invoke(this, methods[i], new Object[] {args}); - // } catch (<declared Exceptions> e) { - // throw e; - // } catch (Throwable t) { - // throw new UndeclaredThrowableException(t); - // } - // } - // Special cases: - // if arg_n is primitive, wrap it - // if method throws Throwable, try-catch is not needed - // if method returns void, return statement not needed - // if method returns primitive, unwrap it - // save space by sharing code for all the declared handlers - - // handler.Code.attribute_name_index - putU2(utf8Info("Code")); - // handler.Code.attribute_length - putU4(12 + code_length + 8 * exception_count); - // handler.Code.max_stack - putU2(param_count == 1 ? 4 : 7 + wrap_overhead); - // handler.Code.max_locals - putU2(param_count); - // handler.Code.code_length - putU4(code_length); - // handler.Code.code[] - putU1(ALOAD_0); - putU1(GETFIELD); - putU2(refInfo(FIELD, "java/lang/reflect/Proxy", "h", - "Ljava/lang/reflect/InvocationHandler;")); - putU1(ALOAD_0); - putU1(GETSTATIC); - putU2(refInfo(FIELD, TypeSignature.getEncodingOfClass(qualName, false), - "m", "[Ljava/lang/reflect/Method;")); - putConst(i); - putU1(AALOAD); - if (paramtypes.length > 0) - { - putConst(paramtypes.length); - putU1(ANEWARRAY); - putU2(classInfo("java/lang/Object")); - param_count = 1; - for (int j = 0; j < paramtypes.length; j++, param_count++) - { - putU1(DUP); - putConst(j); - if (paramtypes[j].isPrimitive()) - { - putU1(NEW); - putU2(classInfo(wrapper(paramtypes[j]))); - putU1(DUP); - } - putLoad(param_count, paramtypes[j]); - if (paramtypes[j].isPrimitive()) - { - putU1(INVOKESPECIAL); - putU2(refInfo(METHOD, wrapper(paramtypes[j]), "<init>", - '(' + (TypeSignature - .getEncodingOfClass(paramtypes[j]) - + ")V"))); - if (paramtypes[j] == long.class - || paramtypes[j] == double.class) - param_count++; - } - putU1(AASTORE); - } - } - else - putU1(ACONST_NULL); - putU1(INVOKEINTERFACE); - putU2(refInfo(INTERFACE, "java/lang/reflect/InvocationHandler", - "invoke", INVOKE_SIG)); - putU1(4); // InvocationHandler, this, Method, Object[] - putU1(0); - if (ret_type == void.class) - putU1(RETURN); - else if (ret_type.isPrimitive()) - { - putU1(CHECKCAST); - putU2(classInfo(wrapper(ret_type))); - putU1(INVOKEVIRTUAL); - putU2(refInfo(METHOD, wrapper(ret_type), - ret_type.getName() + "Value", - "()" + TypeSignature.getEncodingOfClass(ret_type))); - if (ret_type == long.class) - putU1(LRETURN); - else if (ret_type == float.class) - putU1(FRETURN); - else if (ret_type == double.class) - putU1(DRETURN); - else - putU1(IRETURN); - } - else - { - putU1(CHECKCAST); - putU2(classInfo(ret_type)); - putU1(ARETURN); - } - if (! throws_throwable) - { - putU1(NEW); - putU2(classInfo("java/lang/reflect/UndeclaredThrowableException")); - putU1(DUP_X1); - putU1(SWAP); - putU1(INVOKESPECIAL); - putU2(refInfo(METHOD, - "java/lang/reflect/UndeclaredThrowableException", - "<init>", "(Ljava/lang/Throwable;)V")); - putU1(ATHROW); - } - - // handler.Code.exception_table_length - putU2(exception_count); - // handler.Code.exception_table[] - if (! throws_throwable) - { - // handler.Code.exception_table.start_pc - putU2(0); - // handler.Code.exception_table.end_pc - putU2(end_pc); - // handler.Code.exception_table.handler_pc - putU2(handler_pc); - // handler.Code.exception_table.catch_type - putU2(classInfo("java/lang/Error")); - // handler.Code.exception_table.start_pc - putU2(0); - // handler.Code.exception_table.end_pc - putU2(end_pc); - // handler.Code.exception_table.handler_pc - putU2(handler_pc); - // handler.Code.exception_table.catch_type - putU2(classInfo("java/lang/RuntimeException")); - for (int j = 0; j < e.length; j++) - { - // handler.Code.exception_table.start_pc - putU2(0); - // handler.Code.exception_table.end_pc - putU2(end_pc); - // handler.Code.exception_table.handler_pc - putU2(handler_pc); - // handler.Code.exception_table.catch_type - putU2(classInfo(e[j])); - } - // handler.Code.exception_table.start_pc - putU2(0); - // handler.Code.exception_table.end_pc - putU2(end_pc); - // handler.Code.exception_table.handler_pc - - // -8 for undeclared handler, which falls thru to normal one - putU2(handler_pc - 8); - // handler.Code.exception_table.catch_type - putU2(0); - } - // handler.Code.attributes_count - putU2(0); - // handler.Code.attributes[] - - if (e.length > 0) - { - // handler.Exceptions.attribute_name_index - putU2(utf8Info("Exceptions")); - // handler.Exceptions.attribute_length - putU4(2 * e.length + 2); - // handler.Exceptions.number_of_exceptions - putU2(e.length); - // handler.Exceptions.exception_index_table[] - for (int j = 0; j < e.length; j++) - putU2(classInfo(e[j])); - } - } - - /** - * Creates the Class object that corresponds to the bytecode buffers - * built when this object was constructed. - * - * @param loader the class loader to define the proxy class in; null - * implies the bootstrap class loader - * @return the proxy class Class object - */ - Class generate(ClassLoader loader) - { - byte[] bytecode = new byte[pool.length() + stream.length()]; - // More efficient to bypass calling charAt() repetitively. - char[] c = pool.toString().toCharArray(); - int i = c.length; - while (--i >= 0) - bytecode[i] = (byte) c[i]; - c = stream.toString().toCharArray(); - i = c.length; - int j = bytecode.length; - while (i > 0) - bytecode[--j] = (byte) c[--i]; - - // Patch the constant pool size, which we left at 0 earlier. - int count = poolEntries.size() + 1; - bytecode[8] = (byte) (count >> 8); - bytecode[9] = (byte) count; - - try - { - Class vmClassLoader = Class.forName("java.lang.VMClassLoader"); - Class[] types = {ClassLoader.class, String.class, - byte[].class, int.class, int.class, - ProtectionDomain.class }; - Method m = vmClassLoader.getDeclaredMethod("defineClass", types); - // We can bypass the security check of setAccessible(true), since - // we're in the same package. - m.flag = true; - - Object[] args = {loader, qualName, bytecode, new Integer(0), - new Integer(bytecode.length), - Object.class.getProtectionDomain() }; - Class clazz = (Class) m.invoke(null, args); - - // Finally, initialize the m field of the proxy class, before - // returning it. - Field f = clazz.getDeclaredField("m"); - f.flag = true; - // we can share the array, because it is not publicized - f.set(null, methods); - - return clazz; - } - catch (Exception e) - { - // assert false; - throw (Error) new InternalError("Unexpected: " + e).initCause(e); - } - } - - /** - * Put a single byte on the stream. - * - * @param i the information to add (only lowest 8 bits are used) - */ - private void putU1(int i) - { - stream.append((char) i); - } - - /** - * Put two bytes on the stream. - * - * @param i the information to add (only lowest 16 bits are used) - */ - private void putU2(int i) - { - stream.append((char) (i >> 8)).append((char) i); - } - - /** - * Put four bytes on the stream. - * - * @param i the information to add (treated as unsigned) - */ - private void putU4(int i) - { - stream.append((char) (i >> 24)).append((char) (i >> 16)); - stream.append((char) (i >> 8)).append((char) i); - } - - /** - * Put bytecode to load a constant integer on the stream. This only - * needs to work for values less than Short.MAX_VALUE. - * - * @param i the int to add - */ - private void putConst(int i) - { - if (i >= -1 && i <= 5) - putU1(ICONST_0 + i); - else if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) - { - putU1(BIPUSH); - putU1(i); - } - else - { - putU1(SIPUSH); - putU2(i); - } - } - - /** - * Put bytecode to load a given local variable on the stream. - * - * @param i the slot to load - * @param type the base type of the load - */ - private void putLoad(int i, Class type) - { - int offset = 0; - if (type == long.class) - offset = 1; - else if (type == float.class) - offset = 2; - else if (type == double.class) - offset = 3; - else if (! type.isPrimitive()) - offset = 4; - if (i < 4) - putU1(ILOAD_0 + 4 * offset + i); - else - { - putU1(ILOAD + offset); - putU1(i); - } - } - - /** - * Given a primitive type, return its wrapper class name. - * - * @param clazz the primitive type (but not void.class) - * @return the internal form of the wrapper class name - */ - private String wrapper(Class clazz) - { - if (clazz == boolean.class) - return "java/lang/Boolean"; - if (clazz == byte.class) - return "java/lang/Byte"; - if (clazz == short.class) - return "java/lang/Short"; - if (clazz == char.class) - return "java/lang/Character"; - if (clazz == int.class) - return "java/lang/Integer"; - if (clazz == long.class) - return "java/lang/Long"; - if (clazz == float.class) - return "java/lang/Float"; - if (clazz == double.class) - return "java/lang/Double"; - // assert false; - return null; - } - - /** - * Returns the entry of this String in the Constant pool, adding it - * if necessary. - * - * @param str the String to resolve - * @return the index of the String in the constant pool - */ - private char utf8Info(String str) - { - String utf8 = toUtf8(str); - int len = utf8.length(); - return poolIndex("\1" + (char) (len >> 8) + (char) (len & 0xff) + utf8); - } - - /** - * Returns the entry of the appropriate class info structure in the - * Constant pool, adding it if necessary. - * - * @param name the class name, in internal form - * @return the index of the ClassInfo in the constant pool - */ - private char classInfo(String name) - { - char index = utf8Info(name); - char[] c = {7, (char) (index >> 8), (char) (index & 0xff)}; - return poolIndex(new String(c)); - } - - /** - * Returns the entry of the appropriate class info structure in the - * Constant pool, adding it if necessary. - * - * @param clazz the class type - * @return the index of the ClassInfo in the constant pool - */ - private char classInfo(Class clazz) - { - return classInfo(TypeSignature.getEncodingOfClass(clazz.getName(), - false)); - } - - /** - * Returns the entry of the appropriate fieldref, methodref, or - * interfacemethodref info structure in the Constant pool, adding it - * if necessary. - * - * @param structure FIELD, METHOD, or INTERFACE - * @param clazz the class name, in internal form - * @param name the simple reference name - * @param type the type of the reference - * @return the index of the appropriate Info structure in the constant pool - */ - private char refInfo(byte structure, String clazz, String name, - String type) - { - char cindex = classInfo(clazz); - char ntindex = nameAndTypeInfo(name, type); - // relies on FIELD == 1, METHOD == 2, INTERFACE == 3 - char[] c = {(char) (structure + 8), - (char) (cindex >> 8), (char) (cindex & 0xff), - (char) (ntindex >> 8), (char) (ntindex & 0xff)}; - return poolIndex(new String(c)); - } - - /** - * Returns the entry of the appropriate nameAndTyperef info structure - * in the Constant pool, adding it if necessary. - * - * @param name the simple name - * @param type the reference type - * @return the index of the NameAndTypeInfo structure in the constant pool - */ - private char nameAndTypeInfo(String name, String type) - { - char nindex = utf8Info(name); - char tindex = utf8Info(type); - char[] c = {12, (char) (nindex >> 8), (char) (nindex & 0xff), - (char) (tindex >> 8), (char) (tindex & 0xff)}; - return poolIndex(new String(c)); - } - - /** - * Converts a regular string to a UTF8 string, where the upper byte - * of every char is 0, and '\\u0000' is not in the string. This is - * basically to use a String as a fancy byte[], and while it is less - * efficient in memory use, it is easier for hashing. - * - * @param str the original, in straight unicode - * @return a modified string, in UTF8 format in the low bytes - */ - private String toUtf8(String str) - { - final char[] ca = str.toCharArray(); - final int len = ca.length; - - // Avoid object creation, if str is already fits UTF8. - int i; - for (i = 0; i < len; i++) - if (ca[i] == 0 || ca[i] > '\u007f') - break; - if (i == len) - return str; - - final StringBuffer sb = new StringBuffer(str); - sb.setLength(i); - for ( ; i < len; i++) - { - final char c = ca[i]; - if (c > 0 && c <= '\u007f') - sb.append(c); - else if (c <= '\u07ff') // includes '\0' - { - sb.append((char) (0xc0 | (c >> 6))); - sb.append((char) (0x80 | (c & 0x6f))); - } - else - { - sb.append((char) (0xe0 | (c >> 12))); - sb.append((char) (0x80 | ((c >> 6) & 0x6f))); - sb.append((char) (0x80 | (c & 0x6f))); - } - } - return sb.toString(); - } - - /** - * Returns the location of a byte sequence (conveniently wrapped in - * a String with all characters between \u0001 and \u00ff inclusive) - * in the constant pool, adding it if necessary. - * - * @param sequence the byte sequence to look for - * @return the index of the sequence - * @throws IllegalArgumentException if this would make the constant - * pool overflow - */ - private char poolIndex(String sequence) - { - Integer i = (Integer) poolEntries.get(sequence); - if (i == null) - { - // pool starts at index 1 - int size = poolEntries.size() + 1; - if (size >= 65535) - throw new IllegalArgumentException("exceeds VM limitations"); - i = new Integer(size); - poolEntries.put(sequence, i); - pool.append(sequence); - } - return (char) i.intValue(); - } - } // class ClassFactory -} diff --git a/libjava/java/lang/reflect/ReflectPermission.java b/libjava/java/lang/reflect/ReflectPermission.java deleted file mode 100644 index 56eccf8..0000000 --- a/libjava/java/lang/reflect/ReflectPermission.java +++ /dev/null @@ -1,102 +0,0 @@ -/* ReflectPermission.java - named permission for reflaction - Copyright (C) 2000, 2001, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package java.lang.reflect; - -import java.security.BasicPermission; - -/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3 - * "The Java Language Specification", ISBN 0-201-63451-1 - * plus online API docs for JDK 1.2 beta from http://www.javasoft.com. - */ - -/** - * This class implements permissions for reflection. This is a named - * permission, and the only defined name is suppressAccessChecks, which - * allows suppression of normal Java objects when using reflection. - * - * <table> - * <tr> - * <th>Permission Target Name</th> - * <th>What Permission Allows</th> - * <th>Risk of Allowing Permission</th> - * </tr> - * <tr> - * <td><code>suppressAccessChecks</code></td> - * <td>Ability to access fields, invoke methods, and construct objects - * via reflection, including non-public members in contexts where - * such access is not legal at compile-time.</td> - * <td>This is dangerous. It exposes possibly confidential information, - * and malicious code could interfere with the internals of the Virtual - * Machine by corrupting private data.</td> - * </tr> - * </table> - * - * @author Tom Tromey (tromey@redhat.com) - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.2 - * @status updated to 1.4 - */ -public final class ReflectPermission - extends BasicPermission -{ - /** - * Compatible with JDK 1.2. - */ - private static final long serialVersionUID = 7412737110241507485L; - - /** - * Construct a ReflectPermission with the given name. - * - * @param name The permission name - */ - public ReflectPermission(String name) - { - super(name); - } - - /** - * Construct a ReflectPermission with the given name. - * - * @param name The permission name - * @param actions The actions; this is ignored and should be null - */ - public ReflectPermission(String name, String actions) - { - super(name, actions); - } -} diff --git a/libjava/java/lang/reflect/UndeclaredThrowableException.java b/libjava/java/lang/reflect/UndeclaredThrowableException.java deleted file mode 100644 index 6d5a800..0000000 --- a/libjava/java/lang/reflect/UndeclaredThrowableException.java +++ /dev/null @@ -1,128 +0,0 @@ -/* UndeclaredThrowableException.java -- wraps an undeclared checked exception - thrown by a Proxy invocation handler - Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.lang.reflect; - -/** - * This exception class is thrown by a {@link Proxy} instance if - * the {@link InvocationHandler#invoke(Object, Method, Object[]) invoke} - * method of that instance's InvocationHandler attempts to throw an - * exception that not declared by the throws clauses of all of the - * interface methods that the proxy instance is implementing. - * - * <p>When thrown by Proxy, this class will always wrap a checked - * exception, never {@link Error} or {@link RuntimeException}, - * which are unchecked. - * - * @author Eric Blake (ebb9@email.byu.edu) - * @see Proxy - * @see InvocationHandler - * @since 1.3 - * @status updated to 1.4 - */ -public class UndeclaredThrowableException extends RuntimeException -{ - /** - * Compatible with JDK 1.3+. - */ - private static final long serialVersionUID = 330127114055056639L; - - /** - * The immutable exception that this wraps. This field is redundant - * with {@link Throwable#cause}, but is necessary for serial compatibility. - * - * @serial the chained exception - */ - private final Throwable undeclaredThrowable; - - /** - * Wraps the given checked exception into a RuntimeException, with no - * detail message. {@link Throwable#initCause(Throwable)} will fail - * on this instance. - * - * @param cause the undeclared throwable that caused this exception, - * may be null - */ - public UndeclaredThrowableException(Throwable cause) - { - this(cause, null); - } - - /** - * Wraps the given checked exception into a RuntimeException, with the - * specified detail message. {@link Throwable#initCause(Throwable)} will - * fail on this instance. - * - * @param cause the undeclared throwable that caused this exception, - * may be null - * @param message the message, may be null - */ - public UndeclaredThrowableException(Throwable cause, String message) - { - super(message, cause); - undeclaredThrowable = cause; - } - - /** - * Returns the cause of this exception. If this exception was created - * by a {@link Proxy} instance, it will be a non-null checked - * exception. This method pre-dates exception chaining, and is now - * simply a longer way to call <code>getCause()</code>. - * - * @return the cause of this exception, may be null - * @see #getCause() - */ - public Throwable getUndeclaredThrowable() - { - return undeclaredThrowable; - } - - /** - * Returns the cause of this exception. If this exception was created - * by a {@link Proxy} instance, it will be a non-null checked - * exception. - * - * @return the cause of this exception, may be null - * @since 1.4 - */ - public Throwable getCause() - { - return undeclaredThrowable; - } -} diff --git a/libjava/java/lang/s_atan.c b/libjava/java/lang/s_atan.c deleted file mode 100644 index 2ee7458..0000000 --- a/libjava/java/lang/s_atan.c +++ /dev/null @@ -1,181 +0,0 @@ - -/* @(#)s_atan.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ - -/* -FUNCTION - <<atan>>, <<atanf>>---arc tangent - -INDEX - atan -INDEX - atanf - -ANSI_SYNOPSIS - #include <math.h> - double atan(double <[x]>); - float atanf(float <[x]>); - -TRAD_SYNOPSIS - #include <math.h> - double atan(<[x]>); - double <[x]>; - - float atanf(<[x]>); - float <[x]>; - -DESCRIPTION - -<<atan>> computes the inverse tangent (arc tangent) of the input value. - -<<atanf>> is identical to <<atan>>, save that it operates on <<floats>>. - -RETURNS -@ifinfo -<<atan>> returns a value in radians, in the range of -pi/2 to pi/2. -@end ifinfo -@tex -<<atan>> returns a value in radians, in the range of $-\pi/2$ to $\pi/2$. -@end tex - -PORTABILITY -<<atan>> is ANSI C. <<atanf>> is an extension. - -*/ - -/* atan(x) - * Method - * 1. Reduce x to positive by atan(x) = -atan(-x). - * 2. According to the integer k=4t+0.25 chopped, t=x, the argument - * is further reduced to one of the following intervals and the - * arctangent of t is evaluated by the corresponding formula: - * - * [0,7/16] atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...) - * [7/16,11/16] atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) ) - * [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) ) - * [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) ) - * [39/16,INF] atan(x) = atan(INF) + atan( -1/t ) - * - * Constants: - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double atanhi[] = { -#else -static double atanhi[] = { -#endif - 4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */ - 7.85398163397448278999e-01, /* atan(1.0)hi 0x3FE921FB, 0x54442D18 */ - 9.82793723247329054082e-01, /* atan(1.5)hi 0x3FEF730B, 0xD281F69B */ - 1.57079632679489655800e+00, /* atan(inf)hi 0x3FF921FB, 0x54442D18 */ -}; - -#ifdef __STDC__ -static const double atanlo[] = { -#else -static double atanlo[] = { -#endif - 2.26987774529616870924e-17, /* atan(0.5)lo 0x3C7A2B7F, 0x222F65E2 */ - 3.06161699786838301793e-17, /* atan(1.0)lo 0x3C81A626, 0x33145C07 */ - 1.39033110312309984516e-17, /* atan(1.5)lo 0x3C700788, 0x7AF0CBBD */ - 6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */ -}; - -#ifdef __STDC__ -static const double aT[] = { -#else -static double aT[] = { -#endif - 3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */ - -1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */ - 1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */ - -1.11111104054623557880e-01, /* 0xBFBC71C6, 0xFE231671 */ - 9.09088713343650656196e-02, /* 0x3FB745CD, 0xC54C206E */ - -7.69187620504482999495e-02, /* 0xBFB3B0F2, 0xAF749A6D */ - 6.66107313738753120669e-02, /* 0x3FB10D66, 0xA0D03D51 */ - -5.83357013379057348645e-02, /* 0xBFADDE2D, 0x52DEFD9A */ - 4.97687799461593236017e-02, /* 0x3FA97B4B, 0x24760DEB */ - -3.65315727442169155270e-02, /* 0xBFA2B444, 0x2C6A6C2F */ - 1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */ -}; - -#ifdef __STDC__ - static const double -#else - static double -#endif -one = 1.0, -huge = 1.0e300; - -#ifdef __STDC__ - double atan(double x) -#else - double atan(x) - double x; -#endif -{ - double w,s1,s2,z; - int32_t ix,hx,id; - - GET_HIGH_WORD(hx,x); - ix = hx&0x7fffffff; - if(ix>=0x44100000) { /* if |x| >= 2^66 */ - uint32_t low; - GET_LOW_WORD(low,x); - if(ix>0x7ff00000|| - (ix==0x7ff00000&&(low!=0))) - return x+x; /* NaN */ - if(hx>0) return atanhi[3]+atanlo[3]; - else return -atanhi[3]-atanlo[3]; - } if (ix < 0x3fdc0000) { /* |x| < 0.4375 */ - if (ix < 0x3e200000) { /* |x| < 2^-29 */ - if(huge+x>one) return x; /* raise inexact */ - } - id = -1; - } else { - x = fabs(x); - if (ix < 0x3ff30000) { /* |x| < 1.1875 */ - if (ix < 0x3fe60000) { /* 7/16 <=|x|<11/16 */ - id = 0; x = (2.0*x-one)/(2.0+x); - } else { /* 11/16<=|x|< 19/16 */ - id = 1; x = (x-one)/(x+one); - } - } else { - if (ix < 0x40038000) { /* |x| < 2.4375 */ - id = 2; x = (x-1.5)/(one+1.5*x); - } else { /* 2.4375 <= |x| < 2^66 */ - id = 3; x = -1.0/x; - } - }} - /* end of argument reduction */ - z = x*x; - w = z*z; - /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */ - s1 = z*(aT[0]+w*(aT[2]+w*(aT[4]+w*(aT[6]+w*(aT[8]+w*aT[10]))))); - s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9])))); - if (id<0) return x - x*(s1+s2); - else { - z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x); - return (hx<0)? -z:z; - } -} - -#endif /* _DOUBLE_IS_32BITS */ diff --git a/libjava/java/lang/s_ceil.c b/libjava/java/lang/s_ceil.c deleted file mode 100644 index 250373b..0000000 --- a/libjava/java/lang/s_ceil.c +++ /dev/null @@ -1,80 +0,0 @@ - -/* @(#)s_ceil.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* - * ceil(x) - * Return x rounded toward -inf to integral value - * Method: - * Bit twiddling. - * Exception: - * Inexact flag raised if x not equal to ceil(x). - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double huge = 1.0e300; -#else -static double huge = 1.0e300; -#endif - -#ifdef __STDC__ - double ceil(double x) -#else - double ceil(x) - double x; -#endif -{ - int32_t i0,i1,j0; - uint32_t i,j; - EXTRACT_WORDS(i0,i1,x); - j0 = ((i0>>20)&0x7ff)-0x3ff; - if(j0<20) { - if(j0<0) { /* raise inexact if x != 0 */ - if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */ - if(i0<0) {i0=0x80000000;i1=0;} - else if((i0|i1)!=0) { i0=0x3ff00000;i1=0;} - } - } else { - i = (0x000fffff)>>j0; - if(((i0&i)|i1)==0) return x; /* x is integral */ - if(huge+x>0.0) { /* raise inexact flag */ - if(i0>0) i0 += (0x00100000)>>j0; - i0 &= (~i); i1=0; - } - } - } else if (j0>51) { - if(j0==0x400) return x+x; /* inf or NaN */ - else return x; /* x is integral */ - } else { - i = ((uint32_t)(0xffffffff))>>(j0-20); - if((i1&i)==0) return x; /* x is integral */ - if(huge+x>0.0) { /* raise inexact flag */ - if(i0>0) { - if(j0==20) i0+=1; - else { - j = i1 + (1<<(52-j0)); - if(j<(uint32_t)i1) i0+=1; /* got a carry */ - i1 = j; - } - } - i1 &= (~i); - } - } - INSERT_WORDS(x,i0,i1); - return x; -} - -#endif /* _DOUBLE_IS_32BITS */ diff --git a/libjava/java/lang/s_copysign.c b/libjava/java/lang/s_copysign.c deleted file mode 100644 index 4804df1..0000000 --- a/libjava/java/lang/s_copysign.c +++ /dev/null @@ -1,82 +0,0 @@ - -/* @(#)s_copysign.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* -FUNCTION -<<copysign>>, <<copysignf>>---sign of <[y]>, magnitude of <[x]> - -INDEX - copysign -INDEX - copysignf - -ANSI_SYNOPSIS - #include <math.h> - double copysign (double <[x]>, double <[y]>); - float copysignf (float <[x]>, float <[y]>); - -TRAD_SYNOPSIS - #include <math.h> - double copysign (<[x]>, <[y]>) - double <[x]>; - double <[y]>; - - float copysignf (<[x]>, <[y]>) - float <[x]>; - float <[y]>; - -DESCRIPTION -<<copysign>> constructs a number with the magnitude (absolute value) -of its first argument, <[x]>, and the sign of its second argument, -<[y]>. - -<<copysignf>> does the same thing; the two functions differ only in -the type of their arguments and result. - -RETURNS -<<copysign>> returns a <<double>> with the magnitude of -<[x]> and the sign of <[y]>. -<<copysignf>> returns a <<float>> with the magnitude of -<[x]> and the sign of <[y]>. - -PORTABILITY -<<copysign>> is not required by either ANSI C or the System V Interface -Definition (Issue 2). - -*/ - -/* - * copysign(double x, double y) - * copysign(x,y) returns a value with the magnitude of x and - * with the sign bit of y. - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double copysign(double x, double y) -#else - double copysign(x,y) - double x,y; -#endif -{ - uint32_t hx,hy; - GET_HIGH_WORD(hx,x); - GET_HIGH_WORD(hy,y); - SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000)); - return x; -} - -#endif /* _DOUBLE_IS_32BITS */ diff --git a/libjava/java/lang/s_cos.c b/libjava/java/lang/s_cos.c deleted file mode 100644 index be1538d..0000000 --- a/libjava/java/lang/s_cos.c +++ /dev/null @@ -1,82 +0,0 @@ - -/* @(#)s_cos.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* cos(x) - * Return cosine function of x. - * - * kernel function: - * __kernel_sin ... sine function on [-pi/4,pi/4] - * __kernel_cos ... cosine function on [-pi/4,pi/4] - * __ieee754_rem_pio2 ... argument reduction routine - * - * Method. - * Let S,C and T denote the sin, cos and tan respectively on - * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 - * in [-pi/4 , +pi/4], and let n = k mod 4. - * We have - * - * n sin(x) cos(x) tan(x) - * ---------------------------------------------------------- - * 0 S C T - * 1 C -S -1/T - * 2 -S -C T - * 3 -C S -1/T - * ---------------------------------------------------------- - * - * Special cases: - * Let trig be any of sin, cos, or tan. - * trig(+-INF) is NaN, with signals; - * trig(NaN) is that NaN; - * - * Accuracy: - * TRIG(x) returns trig(x) nearly rounded - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double cos(double x) -#else - double cos(x) - double x; -#endif -{ - double y[2],z=0.0; - int32_t n,ix; - - /* High word of x. */ - GET_HIGH_WORD(ix,x); - - /* |x| ~< pi/4 */ - ix &= 0x7fffffff; - if(ix <= 0x3fe921fb) return __kernel_cos(x,z); - - /* cos(Inf or NaN) is NaN */ - else if (ix>=0x7ff00000) return x-x; - - /* argument reduction needed */ - else { - n = __ieee754_rem_pio2(x,y); - switch(n&3) { - case 0: return __kernel_cos(y[0],y[1]); - case 1: return -__kernel_sin(y[0],y[1],1); - case 2: return -__kernel_cos(y[0],y[1]); - default: - return __kernel_sin(y[0],y[1],1); - } - } -} - -#endif /* _DOUBLE_IS_32BITS */ diff --git a/libjava/java/lang/s_fabs.c b/libjava/java/lang/s_fabs.c deleted file mode 100644 index dfee33f..0000000 --- a/libjava/java/lang/s_fabs.c +++ /dev/null @@ -1,73 +0,0 @@ - -/* @(#)s_fabs.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* -FUNCTION - <<fabs>>, <<fabsf>>---absolute value (magnitude) -INDEX - fabs -INDEX - fabsf - -ANSI_SYNOPSIS - #include <math.h> - double fabs(double <[x]>); - float fabsf(float <[x]>); - -TRAD_SYNOPSIS - #include <math.h> - double fabs(<[x]>) - double <[x]>; - - float fabsf(<[x]>) - float <[x]>; - -DESCRIPTION -<<fabs>> and <<fabsf>> calculate -@tex -$|x|$, -@end tex -the absolute value (magnitude) of the argument <[x]>, by direct -manipulation of the bit representation of <[x]>. - -RETURNS -The calculated value is returned. No errors are detected. - -PORTABILITY -<<fabs>> is ANSI. -<<fabsf>> is an extension. - -*/ - -/* - * fabs(x) returns the absolute value of x. - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double fabs(double x) -#else - double fabs(x) - double x; -#endif -{ - uint32_t high; - GET_HIGH_WORD(high,x); - SET_HIGH_WORD(x,high&0x7fffffff); - return x; -} - -#endif /* _DOUBLE_IS_32BITS */ diff --git a/libjava/java/lang/s_floor.c b/libjava/java/lang/s_floor.c deleted file mode 100644 index 77e39cb..0000000 --- a/libjava/java/lang/s_floor.c +++ /dev/null @@ -1,134 +0,0 @@ - -/* @(#)s_floor.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* -FUNCTION -<<floor>>, <<floorf>>, <<ceil>>, <<ceilf>>---floor and ceiling -INDEX - floor -INDEX - floorf -INDEX - ceil -INDEX - ceilf - -ANSI_SYNOPSIS - #include <math.h> - double floor(double <[x]>); - float floorf(float <[x]>); - double ceil(double <[x]>); - float ceilf(float <[x]>); - -TRAD_SYNOPSIS - #include <math.h> - double floor(<[x]>) - double <[x]>; - float floorf(<[x]>) - float <[x]>; - double ceil(<[x]>) - double <[x]>; - float ceilf(<[x]>) - float <[x]>; - -DESCRIPTION -<<floor>> and <<floorf>> find -@tex -$\lfloor x \rfloor$, -@end tex -the nearest integer less than or equal to <[x]>. -<<ceil>> and <<ceilf>> find -@tex -$\lceil x\rceil$, -@end tex -the nearest integer greater than or equal to <[x]>. - -RETURNS -<<floor>> and <<ceil>> return the integer result as a double. -<<floorf>> and <<ceilf>> return the integer result as a float. - -PORTABILITY -<<floor>> and <<ceil>> are ANSI. -<<floorf>> and <<ceilf>> are extensions. - - -*/ - -/* - * floor(x) - * Return x rounded toward -inf to integral value - * Method: - * Bit twiddling. - * Exception: - * Inexact flag raised if x not equal to floor(x). - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double huge = 1.0e300; -#else -static double huge = 1.0e300; -#endif - -#ifdef __STDC__ - double floor(double x) -#else - double floor(x) - double x; -#endif -{ - int32_t i0,i1,j0; - uint32_t i,j; - EXTRACT_WORDS(i0,i1,x); - j0 = ((i0>>20)&0x7ff)-0x3ff; - if(j0<20) { - if(j0<0) { /* raise inexact if x != 0 */ - if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */ - if(i0>=0) {i0=i1=0;} - else if(((i0&0x7fffffff)|i1)!=0) - { i0=0xbff00000;i1=0;} - } - } else { - i = (0x000fffff)>>j0; - if(((i0&i)|i1)==0) return x; /* x is integral */ - if(huge+x>0.0) { /* raise inexact flag */ - if(i0<0) i0 += (0x00100000)>>j0; - i0 &= (~i); i1=0; - } - } - } else if (j0>51) { - if(j0==0x400) return x+x; /* inf or NaN */ - else return x; /* x is integral */ - } else { - i = ((uint32_t)(0xffffffff))>>(j0-20); - if((i1&i)==0) return x; /* x is integral */ - if(huge+x>0.0) { /* raise inexact flag */ - if(i0<0) { - if(j0==20) i0+=1; - else { - j = i1+(1<<(52-j0)); - if(j<(uint32_t)i1) i0 +=1 ; /* got a carry */ - i1=j; - } - } - i1 &= (~i); - } - } - INSERT_WORDS(x,i0,i1); - return x; -} - -#endif /* _DOUBLE_IS_32BITS */ diff --git a/libjava/java/lang/s_rint.c b/libjava/java/lang/s_rint.c deleted file mode 100644 index 5d3f811..0000000 --- a/libjava/java/lang/s_rint.c +++ /dev/null @@ -1,87 +0,0 @@ - -/* @(#)s_rint.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* - * rint(x) - * Return x rounded to integral value according to the prevailing - * rounding mode. - * Method: - * Using floating addition. - * Exception: - * Inexact flag raised if x not equal to rint(x). - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double -#else -static double -#endif -TWO52[2]={ - 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ - -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ -}; - -#ifdef __STDC__ - double rint(double x) -#else - double rint(x) - double x; -#endif -{ - int32_t i0,j0,sx; - uint32_t i,i1; - double t; - volatile double w; - EXTRACT_WORDS(i0,i1,x); - sx = (i0>>31)&1; - j0 = ((i0>>20)&0x7ff)-0x3ff; - if(j0<20) { - if(j0<0) { - if(((i0&0x7fffffff)|i1)==0) return x; - i1 |= (i0&0x0fffff); - i0 &= 0xfffe0000; - i0 |= ((i1|-i1)>>12)&0x80000; - SET_HIGH_WORD(x,i0); - w = TWO52[sx]+x; - t = w-TWO52[sx]; - GET_HIGH_WORD(i0,t); - SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31)); - return t; - } else { - i = (0x000fffff)>>j0; - if(((i0&i)|i1)==0) return x; /* x is integral */ - i>>=1; - if(((i0&i)|i1)!=0) { - if(j0==19) i1 = 0x40000000; else - i0 = (i0&(~i))|((0x20000)>>j0); - } - } - } else if (j0>51) { - if(j0==0x400) return x+x; /* inf or NaN */ - else return x; /* x is integral */ - } else { - i = ((uint32_t)(0xffffffff))>>(j0-20); - if((i1&i)==0) return x; /* x is integral */ - i>>=1; - if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20)); - } - INSERT_WORDS(x,i0,i1); - w = TWO52[sx]+x; - return w-TWO52[sx]; -} - -#endif /* _DOUBLE_IS_32BITS */ diff --git a/libjava/java/lang/s_scalbn.c b/libjava/java/lang/s_scalbn.c deleted file mode 100644 index 36ee889..0000000 --- a/libjava/java/lang/s_scalbn.c +++ /dev/null @@ -1,104 +0,0 @@ - -/* @(#)s_scalbn.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* -FUNCTION -<<scalbn>>, <<scalbnf>>---scale by integer -INDEX - scalbn -INDEX - scalbnf - -ANSI_SYNOPSIS - #include <math.h> - double scalbn(double <[x]>, int <[y]>); - float scalbnf(float <[x]>, int <[y]>); - -TRAD_SYNOPSIS - #include <math.h> - double scalbn(<[x]>,<[y]>) - double <[x]>; - int <[y]>; - float scalbnf(<[x]>,<[y]>) - float <[x]>; - int <[y]>; - -DESCRIPTION -<<scalbn>> and <<scalbnf>> scale <[x]> by <[n]>, returning <[x]> times -2 to the power <[n]>. The result is computed by manipulating the -exponent, rather than by actually performing an exponentiation or -multiplication. - -RETURNS -<[x]> times 2 to the power <[n]>. - -PORTABILITY -Neither <<scalbn>> nor <<scalbnf>> is required by ANSI C or by the System V -Interface Definition (Issue 2). - -*/ - -/* - * scalbn (double x, int n) - * scalbn(x,n) returns x* 2**n computed by exponent - * manipulation rather than by actually performing an - * exponentiation or a multiplication. - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ -static const double -#else -static double -#endif -two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ -twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ -huge = 1.0e+300, -tiny = 1.0e-300; - -#ifdef __STDC__ - double scalbn (double x, int n) -#else - double scalbn (x,n) - double x; int n; -#endif -{ - int32_t k,hx,lx; - EXTRACT_WORDS(hx,lx,x); - k = (hx&0x7ff00000)>>20; /* extract exponent */ - if (k==0) { /* 0 or subnormal x */ - if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ - x *= two54; - GET_HIGH_WORD(hx,x); - k = ((hx&0x7ff00000)>>20) - 54; - if (n< -50000) return tiny*x; /*underflow*/ - } - if (k==0x7ff) return x+x; /* NaN or Inf */ - k = k+n; - if (k > 0x7fe) return huge*copysign(huge,x); /* overflow */ - if (k > 0) /* normal result */ - {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;} - if (k <= -54) { - if (n > 50000) /* in case integer overflow in n+k */ - return huge*copysign(huge,x); /*overflow*/ - else return tiny*copysign(tiny,x); /*underflow*/ - } - k += 54; /* subnormal result */ - SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); - return x*twom54; -} - -#endif /* _DOUBLE_IS_32BITS */ diff --git a/libjava/java/lang/s_sin.c b/libjava/java/lang/s_sin.c deleted file mode 100644 index d315455..0000000 --- a/libjava/java/lang/s_sin.c +++ /dev/null @@ -1,132 +0,0 @@ - -/* @(#)s_sin.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* -FUNCTION - <<sin>>, <<sinf>>, <<cos>>, <<cosf>>---sine or cosine -INDEX -sin -INDEX -sinf -INDEX -cos -INDEX -cosf -ANSI_SYNOPSIS - #include <math.h> - double sin(double <[x]>); - float sinf(float <[x]>); - double cos(double <[x]>); - float cosf(float <[x]>); - -TRAD_SYNOPSIS - #include <math.h> - double sin(<[x]>) - double <[x]>; - float sinf(<[x]>) - float <[x]>; - - double cos(<[x]>) - double <[x]>; - float cosf(<[x]>) - float <[x]>; - -DESCRIPTION - <<sin>> and <<cos>> compute (respectively) the sine and cosine - of the argument <[x]>. Angles are specified in radians. - - <<sinf>> and <<cosf>> are identical, save that they take and - return <<float>> values. - - -RETURNS - The sine or cosine of <[x]> is returned. - -PORTABILITY - <<sin>> and <<cos>> are ANSI C. - <<sinf>> and <<cosf>> are extensions. - -QUICKREF - sin ansi pure - sinf - pure -*/ - -/* sin(x) - * Return sine function of x. - * - * kernel function: - * __kernel_sin ... sine function on [-pi/4,pi/4] - * __kernel_cos ... cose function on [-pi/4,pi/4] - * __ieee754_rem_pio2 ... argument reduction routine - * - * Method. - * Let S,C and T denote the sin, cos and tan respectively on - * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 - * in [-pi/4 , +pi/4], and let n = k mod 4. - * We have - * - * n sin(x) cos(x) tan(x) - * ---------------------------------------------------------- - * 0 S C T - * 1 C -S -1/T - * 2 -S -C T - * 3 -C S -1/T - * ---------------------------------------------------------- - * - * Special cases: - * Let trig be any of sin, cos, or tan. - * trig(+-INF) is NaN, with signals; - * trig(NaN) is that NaN; - * - * Accuracy: - * TRIG(x) returns trig(x) nearly rounded - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double sin(double x) -#else - double sin(x) - double x; -#endif -{ - double y[2],z=0.0; - int32_t n,ix; - - /* High word of x. */ - GET_HIGH_WORD(ix,x); - - /* |x| ~< pi/4 */ - ix &= 0x7fffffff; - if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0); - - /* sin(Inf or NaN) is NaN */ - else if (ix>=0x7ff00000) return x-x; - - /* argument reduction needed */ - else { - n = __ieee754_rem_pio2(x,y); - switch(n&3) { - case 0: return __kernel_sin(y[0],y[1],1); - case 1: return __kernel_cos(y[0],y[1]); - case 2: return -__kernel_sin(y[0],y[1],1); - default: - return -__kernel_cos(y[0],y[1]); - } - } -} - -#endif /* _DOUBLE_IS_32BITS */ diff --git a/libjava/java/lang/s_tan.c b/libjava/java/lang/s_tan.c deleted file mode 100644 index 20995fc..0000000 --- a/libjava/java/lang/s_tan.c +++ /dev/null @@ -1,114 +0,0 @@ - -/* @(#)s_tan.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - - -/* - -FUNCTION - <<tan>>, <<tanf>>---tangent - -INDEX -tan -INDEX -tanf - -ANSI_SYNOPSIS - #include <math.h> - double tan(double <[x]>); - float tanf(float <[x]>); - -TRAD_SYNOPSIS - #include <math.h> - double tan(<[x]>) - double <[x]>; - - float tanf(<[x]>) - float <[x]>; - - -DESCRIPTION -<<tan>> computes the tangent of the argument <[x]>. -Angles are specified in radians. - -<<tanf>> is identical, save that it takes and returns <<float>> values. - -RETURNS -The tangent of <[x]> is returned. - -PORTABILITY -<<tan>> is ANSI. <<tanf>> is an extension. -*/ - -/* tan(x) - * Return tangent function of x. - * - * kernel function: - * __kernel_tan ... tangent function on [-pi/4,pi/4] - * __ieee754_rem_pio2 ... argument reduction routine - * - * Method. - * Let S,C and T denote the sin, cos and tan respectively on - * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 - * in [-pi/4 , +pi/4], and let n = k mod 4. - * We have - * - * n sin(x) cos(x) tan(x) - * ---------------------------------------------------------- - * 0 S C T - * 1 C -S -1/T - * 2 -S -C T - * 3 -C S -1/T - * ---------------------------------------------------------- - * - * Special cases: - * Let trig be any of sin, cos, or tan. - * trig(+-INF) is NaN, with signals; - * trig(NaN) is that NaN; - * - * Accuracy: - * TRIG(x) returns trig(x) nearly rounded - */ - -#include "fdlibm.h" - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double tan(double x) -#else - double tan(x) - double x; -#endif -{ - double y[2],z=0.0; - int32_t n,ix; - - /* High word of x. */ - GET_HIGH_WORD(ix,x); - - /* |x| ~< pi/4 */ - ix &= 0x7fffffff; - if(ix <= 0x3fe921fb) return __kernel_tan(x,z,1); - - /* tan(Inf or NaN) is NaN */ - else if (ix>=0x7ff00000) return x-x; /* NaN */ - - /* argument reduction needed */ - else { - n = __ieee754_rem_pio2(x,y); - return __kernel_tan(y[0],y[1],1-((n&1)<<1)); /* 1 -- n even - -1 -- n odd */ - } -} - -#endif /* _DOUBLE_IS_32BITS */ diff --git a/libjava/java/lang/sf_fabs.c b/libjava/java/lang/sf_fabs.c deleted file mode 100644 index 34f88af..0000000 --- a/libjava/java/lang/sf_fabs.c +++ /dev/null @@ -1,47 +0,0 @@ -/* sf_fabs.c -- float version of s_fabs.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* - * fabsf(x) returns the absolute value of x. - */ - -#include "fdlibm.h" - -#ifdef __STDC__ - float fabsf(float x) -#else - float fabsf(x) - float x; -#endif -{ - uint32_t ix; - GET_FLOAT_WORD(ix,x); - SET_FLOAT_WORD(x,ix&0x7fffffff); - return x; -} - -#ifdef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double fabs(double x) -#else - double fabs(x) - double x; -#endif -{ - return (double) fabsf((float) x); -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/sf_rint.c b/libjava/java/lang/sf_rint.c deleted file mode 100644 index f442072..0000000 --- a/libjava/java/lang/sf_rint.c +++ /dev/null @@ -1,80 +0,0 @@ -/* sf_rint.c -- float version of s_rint.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "fdlibm.h" - -#ifdef __STDC__ -static const float -#else -static float -#endif -TWO23[2]={ - 8.3886080000e+06, /* 0x4b000000 */ - -8.3886080000e+06, /* 0xcb000000 */ -}; - -#ifdef __STDC__ - float rintf(float x) -#else - float rintf(x) - float x; -#endif -{ - int32_t i0,j0,sx; - uint32_t i,i1; - float w,t; - GET_FLOAT_WORD(i0,x); - sx = (i0>>31)&1; - j0 = ((i0>>23)&0xff)-0x7f; - if(j0<23) { - if(j0<0) { - if((i0&0x7fffffff)==0) return x; - i1 = (i0&0x07fffff); - i0 &= 0xfff00000; - i0 |= ((i1|-i1)>>9)&0x400000; - SET_FLOAT_WORD(x,i0); - w = TWO23[sx]+x; - t = w-TWO23[sx]; - GET_FLOAT_WORD(i0,t); - SET_FLOAT_WORD(t,(i0&0x7fffffff)|(sx<<31)); - return t; - } else { - i = (0x007fffff)>>j0; - if((i0&i)==0) return x; /* x is integral */ - i>>=1; - if((i0&i)!=0) i0 = (i0&(~i))|((0x100000)>>j0); - } - } else { - if(j0==0x80) return x+x; /* inf or NaN */ - else return x; /* x is integral */ - } - SET_FLOAT_WORD(x,i0); - w = TWO23[sx]+x; - return w-TWO23[sx]; -} - -#ifdef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double rint(double x) -#else - double rint(x) - double x; -#endif -{ - return (double) rintf((float) x); -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/strtod.c b/libjava/java/lang/strtod.c deleted file mode 100644 index b3e0912..0000000 --- a/libjava/java/lang/strtod.c +++ /dev/null @@ -1,719 +0,0 @@ -/* -FUNCTION - <<strtod>>, <<strtodf>>---string to double or float - -INDEX - strtod -INDEX - _strtod_r -INDEX - strtodf - -ANSI_SYNOPSIS - #include <stdlib.h> - double strtod(const char *<[str]>, char **<[tail]>); - float strtodf(const char *<[str]>, char **<[tail]>); - - double _strtod_r(void *<[reent]>, - const char *<[str]>, char **<[tail]>); - -TRAD_SYNOPSIS - #include <stdlib.h> - double strtod(<[str]>,<[tail]>) - char *<[str]>; - char **<[tail]>; - - float strtodf(<[str]>,<[tail]>) - char *<[str]>; - char **<[tail]>; - - double _strtod_r(<[reent]>,<[str]>,<[tail]>) - char *<[reent]>; - char *<[str]>; - char **<[tail]>; - -DESCRIPTION - The function <<strtod>> parses the character string <[str]>, - producing a substring which can be converted to a double - value. The substring converted is the longest initial - subsequence of <[str]>, beginning with the first - non-whitespace character, that has the format: - .[+|-]<[digits]>[.][<[digits]>][(e|E)[+|-]<[digits]>] - The substring contains no characters if <[str]> is empty, consists - entirely of whitespace, or if the first non-whitespace - character is something other than <<+>>, <<->>, <<.>>, or a - digit. If the substring is empty, no conversion is done, and - the value of <[str]> is stored in <<*<[tail]>>>. Otherwise, - the substring is converted, and a pointer to the final string - (which will contain at least the terminating null character of - <[str]>) is stored in <<*<[tail]>>>. If you want no - assignment to <<*<[tail]>>>, pass a null pointer as <[tail]>. - <<strtodf>> is identical to <<strtod>> except for its return type. - - This implementation returns the nearest machine number to the - input decimal string. Ties are broken by using the IEEE - round-even rule. - - The alternate function <<_strtod_r>> is a reentrant version. - The extra argument <[reent]> is a pointer to a reentrancy structure. - -RETURNS - <<strtod>> returns the converted substring value, if any. If - no conversion could be performed, 0 is returned. If the - correct value is out of the range of representable values, - plus or minus <<HUGE_VAL>> is returned, and <<ERANGE>> is - stored in errno. If the correct value would cause underflow, 0 - is returned and <<ERANGE>> is stored in errno. - -Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, -<<lseek>>, <<read>>, <<sbrk>>, <<write>>. -*/ - -/**************************************************************** - * - * The author of this software is David M. Gay. - * - * Copyright (c) 1991 by AT&T. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose without fee is hereby granted, provided that this entire notice - * is included in all copies of any software which is or includes a copy - * or modification of this software and in all copies of the supporting - * documentation for such software. - * - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY - * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. - * - ***************************************************************/ - -/* Please send bug reports to - David M. Gay - AT&T Bell Laboratories, Room 2C-463 - 600 Mountain Avenue - Murray Hill, NJ 07974-2070 - U.S.A. - dmg@research.att.com or research!dmg - */ - -#include <string.h> -#include <float.h> -#include <errno.h> -#include "mprec.h" - -double -_DEFUN (_strtod_r, (ptr, s00, se), - struct _Jv_reent *ptr _AND - _CONST char *s00 _AND - char **se) -{ - int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, e1, esign, i, j, - k, nd, nd0, nf, nz, nz0, sign; - int digits = 0; /* Number of digits found in fraction part. */ - long e; - _CONST char *s, *s0, *s1; - double aadj, aadj1, adj; - long L; - unsigned long y, z; - union double_union rv, rv0; - - _Jv_Bigint *bb = NULL, *bb1, *bd = NULL, *bd0, *bs = NULL, *delta = NULL; - sign = nz0 = nz = 0; - rv.d = 0.; - for (s = s00;; s++) - switch (*s) - { - case '-': - sign = 1; - /* no break */ - case '+': - if (*++s) - goto break2; - /* no break */ - case 0: - s = s00; - goto ret; - case '\t': - case '\n': - case '\v': - case '\f': - case '\r': - case ' ': - continue; - default: - goto break2; - } -break2: - if (*s == '0') - { - digits++; - nz0 = 1; - while (*++s == '0') - digits++; - if (!*s) - goto ret; - } - s0 = s; - y = z = 0; - for (nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) - { - digits++; - if (nd < 9) - y = 10 * y + c - '0'; - else if (nd < 16) - z = 10 * z + c - '0'; - } - nd0 = nd; - if (c == '.') - { - c = *++s; - if (!nd) - { - for (; c == '0'; c = *++s) - { - digits++; - nz++; - } - if (c > '0' && c <= '9') - { - digits++; - s0 = s; - nf += nz; - nz = 0; - goto have_dig; - } - goto dig_done; - } - for (; c >= '0' && c <= '9'; c = *++s) - { - digits++; - have_dig: - nz++; - if (c -= '0') - { - nf += nz; - for (i = 1; i < nz; i++) - if (nd++ < 9) - y *= 10; - else if (nd <= DBL_DIG + 1) - z *= 10; - if (nd++ < 9) - y = 10 * y + c; - else if (nd <= DBL_DIG + 1) - z = 10 * z + c; - nz = 0; - } - } - } -dig_done: - e = 0; - if (c == 'e' || c == 'E') - { - if (!nd && !nz && !nz0) - { - s = s00; - goto ret; - } - s00 = s; - esign = 0; - switch (c = *++s) - { - case '-': - esign = 1; - case '+': - c = *++s; - } - if (c >= '0' && c <= '9') - { - while (c == '0') - c = *++s; - if (c > '0' && c <= '9') - { - e = c - '0'; - s1 = s; - while ((c = *++s) >= '0' && c <= '9') - e = 10 * e + c - '0'; - if (s - s1 > 8) - /* Avoid confusion from exponents - * so large that e might overflow. - */ - e = 9999999L; - if (esign) - e = -e; - } - } - else - { - /* No exponent after an 'E' : that's an error. */ - ptr->_errno = EINVAL; - e = 0; - s = s00; - goto ret; - } - } - if (!nd) - { - if (!nz && !nz0) - s = s00; - goto ret; - } - e1 = e -= nf; - - /* Now we have nd0 digits, starting at s0, followed by a - * decimal point, followed by nd-nd0 digits. The number we're - * after is the integer represented by those digits times - * 10**e */ - - if (!nd0) - nd0 = nd; - k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; - rv.d = y; - if (k > 9) - rv.d = tens[k - 9] * rv.d + z; - bd0 = 0; - if (nd <= DBL_DIG -#ifndef RND_PRODQUOT - && FLT_ROUNDS == 1 -#endif - ) - { - if (!e) - goto ret; - if (e > 0) - { - if (e <= Ten_pmax) - { -#ifdef VAX - goto vax_ovfl_check; -#else - /* rv.d = */ rounded_product (rv.d, tens[e]); - goto ret; -#endif - } - i = DBL_DIG - nd; - if (e <= Ten_pmax + i) - { - /* A fancier test would sometimes let us do - * this for larger i values. - */ - e -= i; - rv.d *= tens[i]; -#ifdef VAX - /* VAX exponent range is so narrow we must - * worry about overflow here... - */ - vax_ovfl_check: - word0 (rv) -= P * Exp_msk1; - /* rv.d = */ rounded_product (rv.d, tens[e]); - if ((word0 (rv) & Exp_mask) - > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P)) - goto ovfl; - word0 (rv) += P * Exp_msk1; -#else - /* rv.d = */ rounded_product (rv.d, tens[e]); -#endif - goto ret; - } - } -#ifndef Inaccurate_Divide - else if (e >= -Ten_pmax) - { - /* rv.d = */ rounded_quotient (rv.d, tens[-e]); - goto ret; - } -#endif - } - e1 += nd - k; - - /* Get starting approximation = rv.d * 10**e1 */ - - if (e1 > 0) - { - if ((i = e1 & 15)) - rv.d *= tens[i]; - - if (e1 &= ~15) - { - if (e1 > DBL_MAX_10_EXP) - { - ovfl: - ptr->_errno = ERANGE; - - /* Force result to IEEE infinity. */ - word0 (rv) = Exp_mask; - word1 (rv) = 0; - - if (bd0) - goto retfree; - goto ret; - } - if (e1 >>= 4) - { - for (j = 0; e1 > 1; j++, e1 >>= 1) - if (e1 & 1) - rv.d *= bigtens[j]; - /* The last multiplication could overflow. */ - word0 (rv) -= P * Exp_msk1; - rv.d *= bigtens[j]; - if ((z = word0 (rv) & Exp_mask) - > Exp_msk1 * (DBL_MAX_EXP + Bias - P)) - goto ovfl; - if (z > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P)) - { - /* set to largest number */ - /* (Can't trust DBL_MAX) */ - word0 (rv) = Big0; -#ifndef _DOUBLE_IS_32BITS - word1 (rv) = Big1; -#endif - } - else - word0 (rv) += P * Exp_msk1; - } - - } - } - else if (e1 < 0) - { - e1 = -e1; - if ((i = e1 & 15)) - rv.d /= tens[i]; - if (e1 &= ~15) - { - e1 >>= 4; - if (e1 >= 1 << n_bigtens) - goto undfl; - for (j = 0; e1 > 1; j++, e1 >>= 1) - if (e1 & 1) - rv.d *= tinytens[j]; - /* The last multiplication could underflow. */ - rv0.d = rv.d; - rv.d *= tinytens[j]; - if (!rv.d) - { - rv.d = 2. * rv0.d; - rv.d *= tinytens[j]; - if (!rv.d) - { - undfl: - rv.d = 0.; - ptr->_errno = ERANGE; - if (bd0) - goto retfree; - goto ret; - } -#ifndef _DOUBLE_IS_32BITS - word0 (rv) = Tiny0; - word1 (rv) = Tiny1; -#else - word0 (rv) = Tiny1; -#endif - /* The refinement below will clean - * this approximation up. - */ - } - } - } - - /* Now the hard part -- adjusting rv to the correct value.*/ - - /* Put digits into bd: true value = bd * 10^e */ - - bd0 = s2b (ptr, s0, nd0, nd, y); - - for (;;) - { - bd = Balloc (ptr, bd0->_k); - Bcopy (bd, bd0); - bb = d2b (ptr, rv.d, &bbe, &bbbits); /* rv.d = bb * 2^bbe */ - bs = i2b (ptr, 1); - - if (e >= 0) - { - bb2 = bb5 = 0; - bd2 = bd5 = e; - } - else - { - bb2 = bb5 = -e; - bd2 = bd5 = 0; - } - if (bbe >= 0) - bb2 += bbe; - else - bd2 -= bbe; - bs2 = bb2; -#ifdef Sudden_Underflow -#ifdef IBM - j = 1 + 4 * P - 3 - bbbits + ((bbe + bbbits - 1) & 3); -#else - j = P + 1 - bbbits; -#endif -#else - i = bbe + bbbits - 1; /* logb(rv.d) */ - if (i < Emin) /* denormal */ - j = bbe + (P - Emin); - else - j = P + 1 - bbbits; -#endif - bb2 += j; - bd2 += j; - i = bb2 < bd2 ? bb2 : bd2; - if (i > bs2) - i = bs2; - if (i > 0) - { - bb2 -= i; - bd2 -= i; - bs2 -= i; - } - if (bb5 > 0) - { - bs = pow5mult (ptr, bs, bb5); - bb1 = mult (ptr, bs, bb); - Bfree (ptr, bb); - bb = bb1; - } - if (bb2 > 0) - bb = lshift (ptr, bb, bb2); - if (bd5 > 0) - bd = pow5mult (ptr, bd, bd5); - if (bd2 > 0) - bd = lshift (ptr, bd, bd2); - if (bs2 > 0) - bs = lshift (ptr, bs, bs2); - delta = diff (ptr, bb, bd); - dsign = delta->_sign; - delta->_sign = 0; - i = cmp (delta, bs); - if (i < 0) - { - /* Error is less than half an ulp -- check for - * special case of mantissa a power of two. - */ - if (dsign || word1 (rv) || word0 (rv) & Bndry_mask) - break; - delta = lshift (ptr, delta, Log2P); - if (cmp (delta, bs) > 0) - goto drop_down; - break; - } - if (i == 0) - { - /* exactly half-way between */ - if (dsign) - { - if ((word0 (rv) & Bndry_mask1) == Bndry_mask1 - && word1 (rv) == 0xffffffff) - { - /*boundary case -- increment exponent*/ - word0 (rv) = (word0 (rv) & Exp_mask) - + Exp_msk1 -#ifdef IBM - | Exp_msk1 >> 4 -#endif - ; -#ifndef _DOUBLE_IS_32BITS - word1 (rv) = 0; -#endif - break; - } - } - else if (!(word0 (rv) & Bndry_mask) && !word1 (rv)) - { - drop_down: - /* boundary case -- decrement exponent */ -#ifdef Sudden_Underflow - L = word0 (rv) & Exp_mask; -#ifdef IBM - if (L < Exp_msk1) -#else - if (L <= Exp_msk1) -#endif - goto undfl; - L -= Exp_msk1; -#else - L = (word0 (rv) & Exp_mask) - Exp_msk1; -#endif - word0 (rv) = L | Bndry_mask1; -#ifndef _DOUBLE_IS_32BITS - word1 (rv) = 0xffffffff; -#endif -#ifdef IBM - goto cont; -#else - break; -#endif - } -#ifndef ROUND_BIASED - if (!(word1 (rv) & LSB)) - break; -#endif - if (dsign) - rv.d += ulp (rv.d); -#ifndef ROUND_BIASED - else - { - rv.d -= ulp (rv.d); -#ifndef Sudden_Underflow - if (!rv.d) - goto undfl; -#endif - } -#endif - break; - } - if ((aadj = ratio (delta, bs)) <= 2.) - { - if (dsign) - aadj = aadj1 = 1.; - else if (word1 (rv) || word0 (rv) & Bndry_mask) - { -#ifndef Sudden_Underflow - if (word1 (rv) == Tiny1 && !word0 (rv)) - goto undfl; -#endif - aadj = 1.; - aadj1 = -1.; - } - else - { - /* special case -- power of FLT_RADIX to be */ - /* rounded down... */ - - if (aadj < 2. / FLT_RADIX) - aadj = 1. / FLT_RADIX; - else - aadj *= 0.5; - aadj1 = -aadj; - } - } - else - { - aadj *= 0.5; - aadj1 = dsign ? aadj : -aadj; -#ifdef Check_FLT_ROUNDS - switch (FLT_ROUNDS) - { - case 2: /* towards +infinity */ - aadj1 -= 0.5; - break; - case 0: /* towards 0 */ - case 3: /* towards -infinity */ - aadj1 += 0.5; - } -#else - if (FLT_ROUNDS == 0) - aadj1 += 0.5; -#endif - } - y = word0 (rv) & Exp_mask; - - /* Check for overflow */ - - if (y == Exp_msk1 * (DBL_MAX_EXP + Bias - 1)) - { - rv0.d = rv.d; - word0 (rv) -= P * Exp_msk1; - adj = aadj1 * ulp (rv.d); - rv.d += adj; - if ((word0 (rv) & Exp_mask) >= - Exp_msk1 * (DBL_MAX_EXP + Bias - P)) - { - if (word0 (rv0) == Big0 && word1 (rv0) == Big1) - goto ovfl; -#ifdef _DOUBLE_IS_32BITS - word0 (rv) = Big1; -#else - word0 (rv) = Big0; - word1 (rv) = Big1; -#endif - goto cont; - } - else - word0 (rv) += P * Exp_msk1; - } - else - { -#ifdef Sudden_Underflow - if ((word0 (rv) & Exp_mask) <= P * Exp_msk1) - { - rv0.d = rv.d; - word0 (rv) += P * Exp_msk1; - adj = aadj1 * ulp (rv.d); - rv.d += adj; -#ifdef IBM - if ((word0 (rv) & Exp_mask) < P * Exp_msk1) -#else - if ((word0 (rv) & Exp_mask) <= P * Exp_msk1) -#endif - { - if (word0 (rv0) == Tiny0 - && word1 (rv0) == Tiny1) - goto undfl; - word0 (rv) = Tiny0; - word1 (rv) = Tiny1; - goto cont; - } - else - word0 (rv) -= P * Exp_msk1; - } - else - { - adj = aadj1 * ulp (rv.d); - rv.d += adj; - } -#else - /* Compute adj so that the IEEE rounding rules will - * correctly round rv.d + adj in some half-way cases. - * If rv.d * ulp(rv.d) is denormalized (i.e., - * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid - * trouble from bits lost to denormalization; - * example: 1.2e-307 . - */ - if (y <= (P - 1) * Exp_msk1 && aadj >= 1.) - { - aadj1 = (double) (int) (aadj + 0.5); - if (!dsign) - aadj1 = -aadj1; - } - adj = aadj1 * ulp (rv.d); - rv.d += adj; -#endif - } - z = word0 (rv) & Exp_mask; - if (y == z) - { - /* Can we stop now? */ - L = aadj; - aadj -= L; - /* The tolerances below are conservative. */ - if (dsign || word1 (rv) || word0 (rv) & Bndry_mask) - { - if (aadj < .4999999 || aadj > .5000001) - break; - } - else if (aadj < .4999999 / FLT_RADIX) - break; - } - cont: - Bfree (ptr, bb); - Bfree (ptr, bd); - Bfree (ptr, bs); - Bfree (ptr, delta); - } -retfree: - Bfree (ptr, bb); - Bfree (ptr, bd); - Bfree (ptr, bs); - Bfree (ptr, bd0); - Bfree (ptr, delta); -ret: - if (se) - *se = (char *) s; - if (digits == 0) - ptr->_errno = EINVAL; - return sign ? -rv.d : rv.d; -} - diff --git a/libjava/java/lang/w_acos.c b/libjava/java/lang/w_acos.c deleted file mode 100644 index c9ca99c..0000000 --- a/libjava/java/lang/w_acos.c +++ /dev/null @@ -1,118 +0,0 @@ - -/* @(#)w_acos.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* -FUNCTION - <<acos>>, <<acosf>>---arc cosine - -INDEX - acos -INDEX - acosf - -ANSI_SYNOPSIS - #include <math.h> - double acos(double <[x]>); - float acosf(float <[x]>); - -TRAD_SYNOPSIS - #include <math.h> - double acos(<[x]>) - double <[x]>; - - float acosf(<[x]>) - float <[x]>; - - - -DESCRIPTION - - <<acos>> computes the inverse cosine (arc cosine) of the input value. - Arguments to <<acos>> must be in the range @minus{}1 to 1. - - <<acosf>> is identical to <<acos>>, except that it performs - its calculations on <<floats>>. - -RETURNS - @ifinfo - <<acos>> and <<acosf>> return values in radians, in the range of 0 to pi. - @end ifinfo - @tex - <<acos>> and <<acosf>> return values in radians, in the range of <<0>> to $\pi$. - @end tex - - If <[x]> is not between @minus{}1 and 1, the returned value is NaN - (not a number) the global variable <<errno>> is set to <<EDOM>>, and a - <<DOMAIN error>> message is sent as standard error output. - - You can modify error handling for these functions using <<matherr>>. - - -QUICKREF ANSI SVID POSIX RENTRANT - acos y,y,y,m - acosf n,n,n,m - -MATHREF - acos, [-1,1], acos(arg),,, - acos, NAN, arg,DOMAIN,EDOM - -MATHREF - acosf, [-1,1], acosf(arg),,, - acosf, NAN, argf,DOMAIN,EDOM - -*/ - -/* - * wrap_acos(x) - */ - -#include "fdlibm.h" -#include <errno.h> - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double acos(double x) /* wrapper acos */ -#else - double acos(x) /* wrapper acos */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_acos(x); -#else - double z; - struct exception exc; - z = __ieee754_acos(x); - if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; - if(fabs(x)>1.0) { - /* acos(|x|>1) */ - exc.type = DOMAIN; - exc.name = "acos"; - exc.err = 0; - exc.arg1 = exc.arg2 = x; - exc.retval = 0.0; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - errno = EDOM; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } else - return z; -#endif -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/w_asin.c b/libjava/java/lang/w_asin.c deleted file mode 100644 index f6cb271..0000000 --- a/libjava/java/lang/w_asin.c +++ /dev/null @@ -1,121 +0,0 @@ - -/* @(#)w_asin.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ - -/* -FUNCTION - <<asin>>, <<asinf>>---arc sine - -INDEX - asin -INDEX - asinf - -ANSI_SYNOPSIS - #include <math.h> - double asin(double <[x]>); - float asinf(float <[x]>); - -TRAD_SYNOPSIS - #include <math.h> - double asin(<[x]>) - double <[x]>; - - float asinf(<[x]>) - float <[x]>; - - -DESCRIPTION - -<<asin>> computes the inverse sine (arc sine) of the argument <[x]>. -Arguments to <<asin>> must be in the range @minus{}1 to 1. - -<<asinf>> is identical to <<asin>>, other than taking and -returning floats. - -You can modify error handling for these routines using <<matherr>>. - -RETURNS -@ifinfo -<<asin>> returns values in radians, in the range of -pi/2 to pi/2. -@end ifinfo -@tex -<<asin>> returns values in radians, in the range of $-\pi/2$ to $\pi/2$. -@end tex - -If <[x]> is not in the range @minus{}1 to 1, <<asin>> and <<asinf>> -return NaN (not a number), set the global variable <<errno>> to -<<EDOM>>, and issue a <<DOMAIN error>> message. - -You can change this error treatment using <<matherr>>. - -QUICKREF ANSI SVID POSIX RENTRANT - asin y,y,y,m - asinf n,n,n,m - -MATHREF - asin, -1<=arg<=1, asin(arg),,, - asin, NAN, arg,EDOM, DOMAIN - -MATHREF - asinf, -1<=arg<=1, asin(arg),,, - asinf, NAN, arg,EDOM, DOMAIN - - -*/ - -/* - * wrapper asin(x) - */ - - -#include "fdlibm.h" -#include <errno.h> - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double asin(double x) /* wrapper asin */ -#else - double asin(x) /* wrapper asin */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_asin(x); -#else - double z; - struct exception exc; - z = __ieee754_asin(x); - if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; - if(fabs(x)>1.0) { - /* asin(|x|>1) */ - exc.type = DOMAIN; - exc.name = "asin"; - exc.err = 0; - exc.arg1 = exc.arg2 = x; - exc.retval = 0.0; - if(_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - errno = EDOM; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } else - return z; -#endif -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/w_atan2.c b/libjava/java/lang/w_atan2.c deleted file mode 100644 index 91742c7..0000000 --- a/libjava/java/lang/w_atan2.c +++ /dev/null @@ -1,117 +0,0 @@ - -/* @(#)w_atan2.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - */ - -/* -FUNCTION - <<atan2>>, <<atan2f>>---arc tangent of y/x - -INDEX - atan2 -INDEX - atan2f - -ANSI_SYNOPSIS - #include <math.h> - double atan2(double <[y]>,double <[x]>); - float atan2f(float <[y]>,float <[x]>); - -TRAD_SYNOPSIS - #include <math.h> - double atan2(<[y]>,<[x]>); - double <[y]>; - double <[x]>; - - float atan2f(<[y]>,<[x]>); - float <[y]>; - float <[x]>; - -DESCRIPTION - -<<atan2>> computes the inverse tangent (arc tangent) of <[y]>/<[x]>. -<<atan2>> produces the correct result even for angles near -@ifinfo -pi/2 or -pi/2 -@end ifinfo -@tex -$\pi/2$ or $-\pi/2$ -@end tex -(that is, when <[x]> is near 0). - -<<atan2f>> is identical to <<atan2>>, save that it takes and returns -<<float>>. - -RETURNS -<<atan2>> and <<atan2f>> return a value in radians, in the range of -@ifinfo --pi to pi. -@end ifinfo -@tex -$-\pi$ to $\pi$. -@end tex - -If both <[x]> and <[y]> are 0.0, <<atan2>> causes a <<DOMAIN>> error. - -You can modify error handling for these functions using <<matherr>>. - -PORTABILITY -<<atan2>> is ANSI C. <<atan2f>> is an extension. - - -*/ - -/* - * wrapper atan2(y,x) - */ - -#include "fdlibm.h" -#include <errno.h> - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double atan2(double y, double x) /* wrapper atan2 */ -#else - double atan2(y,x) /* wrapper atan2 */ - double y,x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_atan2(y,x); -#else - double z; - struct exception exc; - z = __ieee754_atan2(y,x); - if(_LIB_VERSION == _IEEE_||isnan(x)||isnan(y)) return z; - if(x==0.0&&y==0.0) { - /* atan2(+-0,+-0) */ - exc.arg1 = y; - exc.arg2 = x; - exc.type = DOMAIN; - exc.name = "atan2"; - exc.err = 0; - exc.retval = 0.0; - if(_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - errno = EDOM; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } else - return z; -#endif -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/w_exp.c b/libjava/java/lang/w_exp.c deleted file mode 100644 index 45e087b..0000000 --- a/libjava/java/lang/w_exp.c +++ /dev/null @@ -1,140 +0,0 @@ - -/* @(#)w_exp.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* -FUNCTION - <<exp>>, <<expf>>---exponential -INDEX - exp -INDEX - expf - -ANSI_SYNOPSIS - #include <math.h> - double exp(double <[x]>); - float expf(float <[x]>); - -TRAD_SYNOPSIS - #include <math.h> - double exp(<[x]>); - double <[x]>; - - float expf(<[x]>); - float <[x]>; - -DESCRIPTION - <<exp>> and <<expf>> calculate the exponential of <[x]>, that is, - @ifinfo - e raised to the power <[x]> (where e - @end ifinfo - @tex - $e^x$ (where $e$ - @end tex - is the base of the natural system of logarithms, approximately 2.71828). - - You can use the (non-ANSI) function <<matherr>> to specify - error handling for these functions. - -RETURNS - On success, <<exp>> and <<expf>> return the calculated value. - If the result underflows, the returned value is <<0>>. If the - result overflows, the returned value is <<HUGE_VAL>>. In - either case, <<errno>> is set to <<ERANGE>>. - -PORTABILITY - <<exp>> is ANSI C. <<expf>> is an extension. - -*/ - -/* - * wrapper exp(x) - */ - -#include "fdlibm.h" -#include <errno.h> - -#ifndef _DOUBLE_IS_32BITS - -#ifndef _IEEE_LIBM - -#ifdef __STDC__ -static const double -#else -static double -#endif -o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */ -u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */ - -#endif - -#ifdef __STDC__ - double exp(double x) /* wrapper exp */ -#else - double exp(x) /* wrapper exp */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_exp(x); -#else - double z; - struct exception exc; - z = __ieee754_exp(x); - if(_LIB_VERSION == _IEEE_) return z; - if(finite(x)) { - if(x>o_threshold) { - /* exp(finite) overflow */ -#ifndef HUGE_VAL -#define HUGE_VAL inf - double inf = 0.0; - - SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ -#endif - exc.type = OVERFLOW; - exc.name = "exp"; - exc.err = 0; - exc.arg1 = exc.arg2 = x; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } else if(x<u_threshold) { - /* exp(finite) underflow */ - exc.type = UNDERFLOW; - exc.name = "exp"; - exc.err = 0; - exc.arg1 = exc.arg2 = x; - exc.retval = 0.0; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } - } - return z; -#endif -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/w_fmod.c b/libjava/java/lang/w_fmod.c deleted file mode 100644 index b6b36cb..0000000 --- a/libjava/java/lang/w_fmod.c +++ /dev/null @@ -1,107 +0,0 @@ - -/* @(#)w_fmod.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* -FUNCTION -<<fmod>>, <<fmodf>>---floating-point remainder (modulo) - -INDEX -fmod -INDEX -fmodf - -ANSI_SYNOPSIS -#include <math.h> -double fmod(double <[x]>, double <[y]>) -float fmodf(float <[x]>, float <[y]>) - -TRAD_SYNOPSIS -#include <math.h> -double fmod(<[x]>, <[y]>) -double (<[x]>, <[y]>); - -float fmodf(<[x]>, <[y]>) -float (<[x]>, <[y]>); - -DESCRIPTION -The <<fmod>> and <<fmodf>> functions compute the floating-point -remainder of <[x]>/<[y]> (<[x]> modulo <[y]>). - -RETURNS -The <<fmod>> function returns the value -@ifinfo -<[x]>-<[i]>*<[y]>, -@end ifinfo -@tex -$x-i\times y$, -@end tex -for the largest integer <[i]> such that, if <[y]> is nonzero, the -result has the same sign as <[x]> and magnitude less than the -magnitude of <[y]>. - -<<fmod(<[x]>,0)>> returns NaN, and sets <<errno>> to <<EDOM>>. - -You can modify error treatment for these functions using <<matherr>>. - -PORTABILITY -<<fmod>> is ANSI C. <<fmodf>> is an extension. -*/ - -/* - * wrapper fmod(x,y) - */ - -#include "fdlibm.h" -#include <errno.h> - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double fmod(double x, double y) /* wrapper fmod */ -#else - double fmod(x,y) /* wrapper fmod */ - double x,y; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_fmod(x,y); -#else - double z; - struct exception exc; - z = __ieee754_fmod(x,y); - if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z; - if(y==0.0) { - /* fmod(x,0) */ - exc.type = DOMAIN; - exc.name = "fmod"; - exc.arg1 = x; - exc.arg2 = y; - exc.err = 0; - if (_LIB_VERSION == _SVID_) - exc.retval = x; - else - exc.retval = 0.0/0.0; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - errno = EDOM; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } else - return z; -#endif -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/w_log.c b/libjava/java/lang/w_log.c deleted file mode 100644 index dcc8b97..0000000 --- a/libjava/java/lang/w_log.c +++ /dev/null @@ -1,115 +0,0 @@ - -/* @(#)w_log.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* -FUNCTION - <<log>>, <<logf>>---natural logarithms - -INDEX - log -INDEX - logf - -ANSI_SYNOPSIS - #include <math.h> - double log(double <[x]>); - float logf(float <[x]>); - -TRAD_SYNOPSIS - #include <math.h> - double log(<[x]>); - double <[x]>; - - float logf(<[x]>); - float <[x]>; - -DESCRIPTION -Return the natural logarithm of <[x]>, that is, its logarithm base e -(where e is the base of the natural system of logarithms, 2.71828@dots{}). -<<log>> and <<logf>> are identical save for the return and argument types. - -You can use the (non-ANSI) function <<matherr>> to specify error -handling for these functions. - -RETURNS -Normally, returns the calculated value. When <[x]> is zero, the -returned value is <<-HUGE_VAL>> and <<errno>> is set to <<ERANGE>>. -When <[x]> is negative, the returned value is <<-HUGE_VAL>> and -<<errno>> is set to <<EDOM>>. You can control the error behavior via -<<matherr>>. - -PORTABILITY -<<log>> is ANSI, <<logf>> is an extension. -*/ - -/* - * wrapper log(x) - */ - -#include "fdlibm.h" -#include <errno.h> - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double log(double x) /* wrapper log */ -#else - double log(x) /* wrapper log */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_log(x); -#else - double z; - struct exception exc; - z = __ieee754_log(x); - if(_LIB_VERSION == _IEEE_ || isnan(x) || x > 0.0) return z; -#ifndef HUGE_VAL -#define HUGE_VAL inf - double inf = 0.0; - - SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ -#endif - exc.name = "log"; - exc.err = 0; - exc.arg1 = x; - exc.arg2 = x; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if(x==0.0) { - /* log(0) */ - exc.type = SING; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = EDOM; - } - } else { - /* log(x<0) */ - exc.type = DOMAIN; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - errno = EDOM; - } - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; -#endif -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ diff --git a/libjava/java/lang/w_pow.c b/libjava/java/lang/w_pow.c deleted file mode 100644 index 3df099a..0000000 --- a/libjava/java/lang/w_pow.c +++ /dev/null @@ -1,231 +0,0 @@ - - -/* @(#)w_pow.c 5.2 93/10/01 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* -FUNCTION - <<pow>>, <<powf>>---x to the power y -INDEX - pow -INDEX - powf - - -ANSI_SYNOPSIS - #include <math.h> - double pow(double <[x]>, double <[y]>); - float pow(float <[x]>, float <[y]>); - -TRAD_SYNOPSIS - #include <math.h> - double pow(<[x]>, <[y]>); - double <[x]>, <[y]>; - - float pow(<[x]>, <[y]>); - float <[x]>, <[y]>; - -DESCRIPTION - <<pow>> and <<powf>> calculate <[x]> raised to the exp1.0nt <[y]>. - @tex - (That is, $x^y$.) - @end tex - -RETURNS - On success, <<pow>> and <<powf>> return the value calculated. - - When the argument values would produce overflow, <<pow>> - returns <<HUGE_VAL>> and set <<errno>> to <<ERANGE>>. If the - argument <[x]> passed to <<pow>> or <<powf>> is a negative - noninteger, and <[y]> is also not an integer, then <<errno>> - is set to <<EDOM>>. If <[x]> and <[y]> are both 0, then - <<pow>> and <<powf>> return <<1>>. - - You can modify error handling for these functions using <<matherr>>. - -PORTABILITY - <<pow>> is ANSI C. <<powf>> is an extension. */ - -/* - * wrapper pow(x,y) return x**y - */ - -#include "fdlibm.h" -#include <errno.h> - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double pow(double x, double y) /* wrapper pow */ -#else - double pow(x,y) /* wrapper pow */ - double x,y; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_pow(x,y); -#else - double z; -#ifndef HUGE_VAL -#define HUGE_VAL inf - double inf = 0.0; - - SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ -#endif - struct exception exc; - z=__ieee754_pow(x,y); - if(_LIB_VERSION == _IEEE_|| isnan(y)) return z; - if(isnan(x)) { - if(y==0.0) { - /* pow(NaN,0.0) */ - /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */ - exc.type = DOMAIN; - exc.name = "pow"; - exc.err = 0; - exc.arg1 = x; - exc.arg2 = y; - exc.retval = x; - if (_LIB_VERSION == _IEEE_ || - _LIB_VERSION == _POSIX_) exc.retval = 1.0; - else if (!matherr(&exc)) { - errno = EDOM; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } else - return z; - } - if(x==0.0){ - if(y==0.0) { - /* pow(0.0,0.0) */ - /* error only if _LIB_VERSION == _SVID_ */ - exc.type = DOMAIN; - exc.name = "pow"; - exc.err = 0; - exc.arg1 = x; - exc.arg2 = y; - exc.retval = 0.0; - if (_LIB_VERSION != _SVID_) exc.retval = 1.0; - else if (!matherr(&exc)) { - errno = EDOM; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } - if(finite(y)&&y<0.0) { - /* 0**neg */ - exc.type = DOMAIN; - exc.name = "pow"; - exc.err = 0; - exc.arg1 = x; - exc.arg2 = y; - if (_LIB_VERSION == _SVID_) - exc.retval = 0.0; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - errno = EDOM; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } - return z; - } - if(!finite(z)) { - if(finite(x)&&finite(y)) { - if(isnan(z)) { - /* neg**non-integral */ - exc.type = DOMAIN; - exc.name = "pow"; - exc.err = 0; - exc.arg1 = x; - exc.arg2 = y; - if (_LIB_VERSION == _SVID_) - exc.retval = 0.0; - else - exc.retval = 0.0/0.0; /* X/Open allow NaN */ - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - errno = EDOM; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } else { - /* pow(x,y) overflow */ - exc.type = OVERFLOW; - exc.name = "pow"; - exc.err = 0; - exc.arg1 = x; - exc.arg2 = y; - if (_LIB_VERSION == _SVID_) { - exc.retval = HUGE; - y *= 0.5; - if(x<0.0&&rint(y)!=y) exc.retval = -HUGE; - } else { - exc.retval = HUGE_VAL; - y *= 0.5; - if(x<0.0&&rint(y)!=y) exc.retval = -HUGE_VAL; - } - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } - } - } - if(z==0.0&&finite(x)&&finite(y)) { - /* pow(x,y) underflow */ - exc.type = UNDERFLOW; - exc.name = "pow"; - exc.err = 0; - exc.arg1 = x; - exc.arg2 = y; - exc.retval = 0.0; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } - return z; -#endif -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ - - - - - - - - - - - - - - diff --git a/libjava/java/lang/w_remainder.c b/libjava/java/lang/w_remainder.c deleted file mode 100644 index a06be0e..0000000 --- a/libjava/java/lang/w_remainder.c +++ /dev/null @@ -1,119 +0,0 @@ - -/* @(#)w_remainder.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* -FUNCTION -<<rint>>, <<rintf>>, <<remainder>>, <<remainderf>>---round and remainder -INDEX - rint -INDEX - rintf -INDEX - remainder -INDEX - remainderf - -ANSI_SYNOPSIS - #include <math.h> - double rint(double <[x]>); - float rintf(float <[x]>); - double remainder(double <[x]>, double <[y]>); - float remainderf(float <[x]>, float <[y]>); - -TRAD_SYNOPSIS - #include <math.h> - double rint(<[x]>) - double <[x]>; - float rintf(<[x]>) - float <[x]>; - double remainder(<[x]>,<[y]>) - double <[x]>, <[y]>; - float remainderf(<[x]>,<[y]>) - float <[x]>, <[y]>; - -DESCRIPTION -<<rint>> and <<rintf>> returns their argument rounded to the nearest -integer. <<remainder>> and <<remainderf>> find the remainder of -<[x]>/<[y]>; this value is in the range -<[y]>/2 .. +<[y]>/2. - -RETURNS -<<rint>> and <<remainder>> return the integer result as a double. - -PORTABILITY -<<rint>> and <<remainder>> are System V release 4. <<rintf>> and -<<remainderf>> are extensions. - -*/ - -/* - * wrapper remainder(x,p) - */ - -#include "fdlibm.h" -#include <errno.h> - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double remainder(double x, double y) /* wrapper remainder */ -#else - double remainder(x,y) /* wrapper remainder */ - double x,y; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_remainder(x,y); -#else - double z; - struct exception exc; - z = __ieee754_remainder(x,y); - if(_LIB_VERSION == _IEEE_ || isnan(y)) return z; - if(y==0.0) { - /* remainder(x,0) */ - exc.type = DOMAIN; - exc.name = "remainder"; - exc.err = 0; - exc.arg1 = x; - exc.arg2 = y; - exc.retval = 0.0/0.0; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - errno = EDOM; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } else - return z; -#endif -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ - - - - - - - - - - - - - - - - - diff --git a/libjava/java/lang/w_sqrt.c b/libjava/java/lang/w_sqrt.c deleted file mode 100644 index 23a793c..0000000 --- a/libjava/java/lang/w_sqrt.c +++ /dev/null @@ -1,93 +0,0 @@ - -/* @(#)w_sqrt.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* -FUNCTION - <<sqrt>>, <<sqrtf>>---positive square root - -INDEX - sqrt -INDEX - sqrtf - -ANSI_SYNOPSIS - #include <math.h> - double sqrt(double <[x]>); - float sqrtf(float <[x]>); - -TRAD_SYNOPSIS - #include <math.h> - double sqrt(<[x]>); - float sqrtf(<[x]>); - -DESCRIPTION - <<sqrt>> computes the positive square root of the argument. - You can modify error handling for this function with - <<matherr>>. - -RETURNS - On success, the square root is returned. If <[x]> is real and - positive, then the result is positive. If <[x]> is real and - negative, the global value <<errno>> is set to <<EDOM>> (domain error). - - -PORTABILITY - <<sqrt>> is ANSI C. <<sqrtf>> is an extension. -*/ - -/* - * wrapper sqrt(x) - */ - -#include "fdlibm.h" -#include <errno.h> - -#ifndef _DOUBLE_IS_32BITS - -#ifdef __STDC__ - double sqrt(double x) /* wrapper sqrt */ -#else - double sqrt(x) /* wrapper sqrt */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_sqrt(x); -#else - struct exception exc; - double z; - z = __ieee754_sqrt(x); - if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; - if(x<0.0) { - exc.type = DOMAIN; - exc.name = "sqrt"; - exc.err = 0; - exc.arg1 = exc.arg2 = x; - if (_LIB_VERSION == _SVID_) - exc.retval = 0.0; - else - exc.retval = 0.0/0.0; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - errno = EDOM; - } - if (exc.err != 0) - errno = exc.err; - return exc.retval; - } else - return z; -#endif -} - -#endif /* defined(_DOUBLE_IS_32BITS) */ |