summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Jones <cbj@gnu.org>2001-06-25 04:43:56 +0000
committerBrian Jones <cbj@gnu.org>2001-06-25 04:43:56 +0000
commitc91e001c1848e4d310474d87489d027c794fd6d7 (patch)
tree9373829c484899ed1ef77e1c8ece45b4ee2509ba
parenta894ae6f805b85cbaad4bf533fb99384c8d28855 (diff)
downloadclasspath-c91e001c1848e4d310474d87489d027c794fd6d7.tar.gz
* acconfig.h: added HAVE_INT32_DEFINED and HAVE_BSD_INT32_DEFINED
* doc/hacking.texinfo: fixed typo * configure.in: rename --enable-libgcj-debug to --enable-debug. Created new option --enable-load-library potentially to be used to limit all System.loadLibrary() calls in class initializers. Added more header checks and define HAVE_INT32_DEFINED or HAVE_BSD_INT32_DEFINED similarly to gcj. Renamed libgcj-debug to the neutral sounding debug. Checks for more headers. * gnu/classpath/Configuration.java.in: INIT_LOAD_LIBRARY added. Should be helpful for more directly using classpath code in gcj. * TODO: added URL to javadoc docs for writing serial tags * java/lang/Double.java: merged with gcj version, credit to Andrew Haley. (byteValue): added missing function (shortValue): added missing function (compareTo): properly return 0 if both values are NaN * java/lang/Float.java: merged with gcj version, credit to Andrew Haley. (Float): removed NullPointerException from throws clause (toString): calls Double.toString (valueOf): removed NullPointerException from throws clause (floatToRawIntBits): new native method (parseFloat): removed NullPointerException from throws clause. Calls Double.parseDouble now. * native/jni/java_lang_Float.c (*): aligned with gcj implementation * native/jni/java_lang_Double.c (*): aligned with gcj implementation * lib/Makefile.am: changed to handle separate builddir * lib/gen-classlib.sh.in: changed to handle separate builddir * lib/mkdep.pl.in: changed to handle separate builddir * lib/standard.omit: changed to handle regex of separate builddir * native/jni/Makefile.am: include $(top_builddir)/include instead of $(top_srcdir). Additions to javalang shared library. * native/jni/awt/Makefile.am: include $(top_builddir)/include instead of $(top_srcdir).
-rw-r--r--ChangeLog45
-rw-r--r--TODO3
-rw-r--r--acconfig.h6
-rw-r--r--configure.in48
-rw-r--r--doc/hacking.texinfo2
-rw-r--r--gnu/classpath/Configuration.java.in25
-rw-r--r--java/lang/Double.java791
-rw-r--r--java/lang/Float.java33
-rw-r--r--lib/Makefile.am21
-rwxr-xr-xlib/gen-classlist.sh.in4
-rwxr-xr-xlib/mkdep.pl.in38
-rw-r--r--lib/standard.omit40
-rw-r--r--native/jni/Makefile.am10
-rw-r--r--native/jni/awt/Makefile.am2
-rw-r--r--native/jni/java_lang_Double.c268
-rw-r--r--native/jni/java_lang_Float.c120
16 files changed, 840 insertions, 616 deletions
diff --git a/ChangeLog b/ChangeLog
index 47ce7dbc1..121c7ebd9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,48 @@
+2001-06-25 Brian Jones <cbj@gnu.org>
+
+ * native/jni/mprec.h: new file from gcj
+ * native/jni/mprec.c: new file from gcj
+ * native/jni/fdlibm.h: new file from gcj
+ * native/jni/ieeefp.h: new file from gcj
+ * native/jni/java-assert.h: new file from gcj
+ * native/jni/dtoa.c: new file from gcj
+ * native/jni/jcl.c: copy of file in native/jni/lib/
+ * native/jni/jcl.h: copy of file in native/jni/lib/
+ * acconfig.h: added HAVE_INT32_DEFINED and HAVE_BSD_INT32_DEFINED
+ * doc/hacking.texinfo: fixed typo
+ * configure.in: rename --enable-libgcj-debug to --enable-debug.
+ Created new option --enable-load-library potentially to be used
+ to limit all System.loadLibrary() calls in class initializers.
+ Added more header checks and define HAVE_INT32_DEFINED
+ or HAVE_BSD_INT32_DEFINED similarly to gcj. Renamed libgcj-debug
+ to the neutral sounding debug. Checks for more headers.
+ * gnu/classpath/Configuration.java.in: INIT_LOAD_LIBRARY added.
+ Should be helpful for more directly using classpath code in gcj.
+ * TODO: added URL to javadoc docs for writing serial tags
+ * java/lang/Double.java: merged with gcj version, credit to
+ Andrew Haley.
+ (byteValue): added missing function
+ (shortValue): added missing function
+ (compareTo): properly return 0 if both values are NaN
+ * java/lang/Float.java: merged with gcj version, credit to
+ Andrew Haley.
+ (Float): removed NullPointerException from throws clause
+ (toString): calls Double.toString
+ (valueOf): removed NullPointerException from throws clause
+ (floatToRawIntBits): new native method
+ (parseFloat): removed NullPointerException from throws clause.
+ Calls Double.parseDouble now.
+ * native/jni/java_lang_Float.c (*): aligned with gcj implementation
+ * native/jni/java_lang_Double.c (*): aligned with gcj implementation
+ * lib/Makefile.am: changed to handle separate builddir
+ * lib/gen-classlib.sh.in: changed to handle separate builddir
+ * lib/mkdep.pl.in: changed to handle separate builddir
+ * lib/standard.omit: changed to handle regex of separate builddir
+ * native/jni/Makefile.am: include $(top_builddir)/include instead
+ of $(top_srcdir). Additions to javalang shared library.
+ * native/jni/awt/Makefile.am: include $(top_builddir)/include
+ instead of $(top_srcdir).
+
2001-06-13 Tom Tromey <tromey@redhat.com>
* java/util/Date.java (toLocaleString): Deprecated.
diff --git a/TODO b/TODO
index 81ee89aa1..be73ccd21 100644
--- a/TODO
+++ b/TODO
@@ -130,7 +130,8 @@ standard.
-- Audit the code to identify methods that do not have Javadoc comments
and/or comments that are incomplete. All input parameters, return
values, etc should be documentes. Also look for Javadoc comments on
- variables that are serializable.
+ variables that are serializable. See http://java.sun.com/j2se/javadoc/writingdoccomments/index.html#tag
+ for details of what should be where in comments.
-- Figure out a way to generate a hardcopy manual for the Java class
library from the embedded Javadocs. This probably involves writing
diff --git a/acconfig.h b/acconfig.h
index fcde42237..96f423e24 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -21,6 +21,12 @@
/* Define as 1 if building with debugging code included, this is not -g */
#define DEBUG 0
+/* Define if you have int32_t and uint32_t */
+#undef HAVE_INT32_DEFINED
+
+/* Define if you have u_int32_t */
+#undef HAVE_BSD_INT32_DEFINED
+
/************************************************************************
* Leave the blank line there, required by autoheader.
************************************************************************/
diff --git a/configure.in b/configure.in
index 3ad3f1630..0db706026 100644
--- a/configure.in
+++ b/configure.in
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(native/java.net/javanet.c)
+AC_INIT(java/lang/System.java)
AC_CANONICAL_HOST
@@ -31,7 +31,11 @@ AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_HEADER_STDC
-AC_CHECK_HEADERS(unistd.h)
+AC_CHECK_HEADERS(unistd.h sys/types.h sys/config.h inttypes.h stdint.h)
+AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED))
+AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED))
+AC_EGREP_HEADER(u_int32_t, sys/types.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED))
+AC_EGREP_HEADER(u_int32_t, sys/config.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED))
AC_C_CONST
AC_CHECK_FUNCS(gethostname socket strerror fork pipe execve strtod atof)
AC_HEADER_TIME
@@ -202,15 +206,37 @@ dnl these statements should be optimized out of the bytecode
dnl produced by an optimizing Java compiler and not hinder
dnl performance.
dnl -----------------------------------------------------------
-LIBGCJDEBUG="false"
-AC_ARG_ENABLE(libgcj-debug,
-[ --enable-libgcj-debug enable runtime debugging code],
- if test "$enable_libgcj_debug" = yes; then
- AC_DEFINE(DEBUG)
- LIBGCJDEBUG="true"
- fi
-])
-AC_SUBST(LIBGCJDEBUG)
+AC_ARG_ENABLE(debug,
+[ --enable-debug enable runtime debugging code],
+[case "${enableval}" in
+ yes)
+ LIBDEBUG="true"
+ AC_DEFINE(DEBUG)
+ ;;
+ no) LIBDEBUG="false" ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
+esac],
+[LIBDEBUG="false"])
+AC_SUBST(LIBDEBUG)
+
+dnl -----------------------------------------------------------
+
+
+dnl -----------------------------------------------------------
+dnl Enable execution of all static initializer loadLibrary()
+dnl calls at compile time. By default most people will not
+dnl want to disable this, but some VMs (gcj) don't need or want
+dnl them.
+dnl -----------------------------------------------------------
+AC_ARG_ENABLE(load-library,
+[ --enable-load-library [default=yes]],
+[case "${enableval}" in
+ yes) INIT_LOAD_LIBRARY="true" ;;
+ no) INIT_LOAD_LIBRARY="false" ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-load-library) ;;
+esac],
+[INIT_LOAD_LIBRARY="true"])
+AC_SUBST(INIT_LOAD_LIBRARY)
dnl -----------------------------------------------------------
diff --git a/doc/hacking.texinfo b/doc/hacking.texinfo
index 357b23291..5dd7863f6 100644
--- a/doc/hacking.texinfo
+++ b/doc/hacking.texinfo
@@ -138,7 +138,7 @@ with a special exception included to allow linking with non-GPL licensed
works as long as no other license would restrict such linking. To
preserve freedom for all users and to maintain uniform licensing of
Classpath, we will not accept code into the main distribution that is
-not licensed under these terms. The license can be read from the any
+not licensed under these terms. The license can be read from any
alpha release distributed from @uref{ftp://alpha.gnu.org/gnu/classpath/}
or by obtaining a copy of the current CVS tree.
diff --git a/gnu/classpath/Configuration.java.in b/gnu/classpath/Configuration.java.in
index 5b9781cdd..09aed1feb 100644
--- a/gnu/classpath/Configuration.java.in
+++ b/gnu/classpath/Configuration.java.in
@@ -32,10 +32,23 @@ package gnu.classpath;
*/
public interface Configuration
{
- // The value of DEBUG is substituted according to whether the
- // "--enable-libgcj-debug" argument was passed to configure. Code
- // which is made conditional based on the value of this flag will
- // be removed by the optimizer in a non-debug build.
-
- boolean DEBUG = @LIBGCJDEBUG@;
+ /**
+ * The value of DEBUG is substituted according to whether the
+ * "--enable-debug" argument was passed to configure. Code
+ * which is made conditional based on the value of this flag will
+ * be removed by the optimizer in a non-debug build.
+ */
+ boolean DEBUG = @LIBDEBUG@;
+
+ /**
+ * The value of LOAD_LIBRARY is substituted according to whether the
+ * "--enable-load-library" argument was passed to configure. By
+ * default, configure should define this is as true and typically a
+ * user would use "--disable-load-library" to avert loading
+ * libraries static initializers of all classes. Code which is made
+ * conditional based on the value of this flag will be removed by
+ * the optimizer in a non-debug build.
+ */
+ boolean INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@;
+
}
diff --git a/java/lang/Double.java b/java/lang/Double.java
index 644abeb12..e3400d99c 100644
--- a/java/lang/Double.java
+++ b/java/lang/Double.java
@@ -27,6 +27,7 @@ executable file might be covered by the GNU General Public License. */
package java.lang;
+import gnu.classpath.Configuration;
/**
* Instances of class <code>Double</code> represent primitive
@@ -36,402 +37,464 @@ package java.lang;
* related to doubles.
*
* @author Paul Fisher
+ * @author Andrew Haley <aph@cygnus.com>
* @since JDK 1.0
*/
public final class Double extends Number implements Comparable
{
- /**
- * The minimum positive value a <code>double</code> may represent
- * is 5e-324.
- */
- public static final double MIN_VALUE = 5e-324;
+ /**
+ * The minimum positive value a <code>double</code> may represent
+ * is 5e-324.
+ */
+ public static final double MIN_VALUE = 5e-324;
+
+ /**
+ * The maximum positive value a <code>double</code> may represent
+ * is 1.7976931348623157e+308.
+ */
+ public static final double MAX_VALUE = 1.7976931348623157e+308;
- /**
- * The maximum positive value a <code>double</code> may represent
- * is 1.7976931348623157e+308.
- */
- public static final double MAX_VALUE = 1.7976931348623157e+308;
+ /**
+ * The value of a double representation -1.0/0.0, negative
+ * infinity.
+ */
+ public static final double NEGATIVE_INFINITY = -1.0d/0.0d;
- /**
- * The value of a double representation -1.0/0.0, negative infinity.
- */
- public static final double NEGATIVE_INFINITY = -1.0/0.0;
+ /**
+ * The value of a double representing 1.0/0.0, positive infinity.
+ */
+ public static final double POSITIVE_INFINITY = 1.0d/0.0d;
- /**
- * The value of a double representing 1.0/0.0, positive infinity.
- */
- public static final double POSITIVE_INFINITY = 1.0/0.0;
+ /**
+ * All IEEE 754 values of NaN have the same value in Java.
+ */
+ public static final double NaN = 0.0d/0.0d;
- /**
- * All IEEE 754 values of NaN have the same value in Java.
- */
- public static final double NaN = 0.0/0.0;
+ /**
+ * The primitive type <code>double</code> is represented by this
+ * <code>Class</code> object.
+ */
+ public static final Class TYPE = VMClassLoader.getPrimitiveClass("double");
- /**
- * The primitive type <code>double</code> is represented by this
- * <code>Class</code> object.
- */
- public static final Class TYPE = VMClassLoader.getPrimitiveClass("double");
+ private double value;
- private double value;
-
- /**
- * Load native routines necessary for this class.
- */
- static
- {
+ /**
+ * Load native routines necessary for this class.
+ */
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ {
System.loadLibrary("javalang");
- }
+ initIDs();
+ }
+ }
- /**
- * Create a <code>Double</code> from the primitive <code>double</code>
- * specified.
- *
- * @param value the <code>double</code> argument
- */
- public Double(double value) {
- this.value = value;
- }
+ /**
+ * Create a <code>Double</code> from the primitive <code>double</code>
+ * specified.
+ *
+ * @param value the <code>double</code> argument
+ */
+ public Double(double value) {
+ this.value = value;
+ }
- /**
- * Create a <code>Double</code> from the specified <code>String</code>.
- *
- * This method calls <code>Double.parseDouble()</code>.
- *
- * @exception NumberFormatException when the <code>String</code> cannot
- * be parsed into a <code>Float</code>.
- * @exception NullPointerException when the argument is <code>null</code>.
- * @param s the <code>String</code> to convert
- * @see #parseDouble(java.lang.String)
- */
- public Double(String s) throws NumberFormatException, NullPointerException
- {
- value = parseDouble(s);
- }
+ /**
+ * Create a <code>Double</code> from the specified
+ * <code>String</code>.
+ *
+ * This method calls <code>Double.parseDouble()</code>.
+ *
+ * @exception NumberFormatException when the <code>String</code> cannot
+ * be parsed into a <code>Float</code>.
+ * @param s the <code>String</code> to convert
+ * @see #parseDouble(java.lang.String)
+ */
+ public Double(String s) throws NumberFormatException
+ {
+ value = parseDouble(s);
+ }
- /**
- * Convert the <code>double</code> value of this <code>Double</code>
- * to a <code>String</code>. This method calls
- * <code>Double.toString(double)</code> to do its dirty work.
- *
- * @return the <code>String</code> representation of this <code>Double</code>.
- * @see #toString(double)
- */
- public String toString()
- {
- return toString(value);
- }
+ /**
+ * Convert the <code>double</code> value of this <code>Double</code>
+ * to a <code>String</code>. This method calls
+ * <code>Double.toString(double)</code> to do its dirty work.
+ *
+ * @return the <code>String</code> representation of this <code>Double</code>.
+ * @see #toString(double)
+ */
+ public String toString()
+ {
+ return toString(value);
+ }
- /**
- * If the <code>Object</code> is not <code>null</code>, is an
- * <code>instanceof</code> <code>Double</code>, and represents
- * the same primitive <code>double</code> value return
- * <code>true</code>. Otherwise <code>false</code> is returned.
- *
- * @param obj the object to compare to
- * @return whether the objects are semantically equal.
- */
- public boolean equals(Object obj)
- {
- return (obj instanceof Double && ((Double)obj).value == value);
- }
+ /**
+ * If the <code>Object</code> is not <code>null</code>, is an
+ * <code>instanceof</code> <code>Double</code>, and represents
+ * the same primitive <code>double</code> value return
+ * <code>true</code>. Otherwise <code>false</code> is returned.
+ *
+ * @param obj the object to compare to
+ * @return whether the objects are semantically equal.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof Double))
+ return false;
- /**
- * The hashcode is the value of the expression: <br>
- * <br>
- * <code>(int)(v^(v>>>32))</code><br>
- * <br>
- * where v is defined by: <br>
- * <code>long v = Double.doubleToLongBits(this.longValue());</code><br>
- */
- public int hashCode()
- {
- long v = doubleToLongBits(value);
- return (int)(v^(v>>>32));
- }
-
- /**
- * Return the value of this <code>Double</code> when cast to an
- * <code>int</code>.
- */
- public int intValue()
- {
- return (int)value;
- }
+ Double d = (Double) obj;
+
+ return doubleToLongBits (value) == doubleToLongBits (d.doubleValue ());
+ }
- /**
- * Return the value of this <code>Double</code> when cast to a
- * <code>long</code>.
- */
- public long longValue()
- {
- return (long)value;
- }
+ /**
+ * The hashcode is the value of the expression: <br>
+ * <br>
+ * <code>(int)(v^(v>>>32))</code><br>
+ * <br>
+ * where v is defined by: <br>
+ * <code>long v = Double.doubleToLongBits(this.longValue());</code><br>
+ */
+ public int hashCode()
+ {
+ long v = doubleToLongBits(value);
+ return (int)(v ^ (v >>> 32));
+ }
- /**
- * Return the value of this <code>Double</code> when cast to a
- * <code>float</code>.
- */
- public float floatValue()
- {
- return (float)value;
- }
+ /**
+ * Return the value of this <code>Double</code> when cast to an
+ * <code>int</code>.
+ */
+ public int intValue()
+ {
+ return (int)value;
+ }
- /**
- * Return the primitive <code>double</code> value represented by this
- * <code>Double</code>.
- */
- public double doubleValue()
- {
- return value;
- }
+ /**
+ * Return the value of this <code>Double</code> when cast to a
+ * <code>long</code>.
+ */
+ public long longValue()
+ {
+ return (long)value;
+ }
+ /**
+ * Return the value of this <code>Double</code> when cast to a
+ * <code>float</code>.
+ */
+ public float floatValue()
+ {
+ return (float)value;
+ }
+
+ /**
+ * Return the primitive <code>double</code> value represented by this
+ * <code>Double</code>.
+ */
+ public double doubleValue()
+ {
+ return value;
+ }
+
+ /**
+ * Return the value of this <code>Double</code> when cast to a
+ * <code>byte</code>.
+ */
+ public byte byteValue ()
+ {
+ return (byte) value;
+ }
+
+ /**
+ * Return the value of this <code>Double</code> when cast to a
+ * <code>short</code>.
+ */
+ public short shortValue ()
+ {
+ return (short) value;
+ }
- /**
- * Return the result of calling <code>new Double(java.lang.String)</code>.
- *
- * @param s the <code>String</code> to convert to a <code>Double</code>.
- * @return a new <code>Double</code> representing the <code>String</code>'s
- * numeric value.
- *
- * @exception NullPointerException thrown if <code>String</code> is
- * <code>null</code>.
- * @exception NumberFormatException thrown if <code>String</code> cannot
- * be parsed as a <code>double</code>.
- * @see #Double(java.lang.String)
- * @see #parseDouble(java.lang.String)
- */
- public static Double valueOf(String s)
- throws NumberFormatException, NullPointerException
- {
- return new Double(s);
- }
+ /**
+ * Return the result of calling <code>new Double(java.lang.String)</code>.
+ *
+ * @param s the <code>String</code> to convert to a <code>Double</code>.
+ * @return a new <code>Double</code> representing the <code>String</code>'s
+ * numeric value.
+ *
+ * @exception NullPointerException thrown if <code>String</code> is
+ * <code>null</code>.
+ * @exception NumberFormatException thrown if <code>String</code> cannot
+ * be parsed as a <code>double</code>.
+ * @see #Double(java.lang.String)
+ * @see #parseDouble(java.lang.String)
+ */
+ public static Double valueOf(String s)
+ throws NumberFormatException
+ {
+ return new Double(s);
+ }
- /**
- * Return <code>true</code> if the value of this <code>Double</code>
- * is the same as <code>NaN</code>, otherwise return <code>false</code>.
- * @return whether this <code>Double</code> is <code>NaN</code>.
- */
- public boolean isNaN()
- {
- return isNaN(value);
- }
+ /**
+ * Return <code>true</code> if the value of this <code>Double</code>
+ * is the same as <code>NaN</code>, otherwise return <code>false</code>.
+ * @return whether this <code>Double</code> is <code>NaN</code>.
+ */
+ public boolean isNaN()
+ {
+ return isNaN(value);
+ }
- /**
- * Return <code>true</code> if the <code>double</code> has the same
- * value as <code>NaN</code>, otherwise return <code>false</code>.
- *
- * @param d the <code>double</code> to compare
- * @return whether the argument is <code>NaN</code>.
- */
- public static boolean isNaN(double d)
- {
- return (doubleToLongBits(d) == 0x7ff8000000000000L);
- }
+ /**
+ * Return <code>true</code> if the <code>double</code> has the same
+ * value as <code>NaN</code>, otherwise return <code>false</code>.
+ *
+ * @param d the <code>double</code> to compare
+ * @return whether the argument is <code>NaN</code>.
+ */
+ public static boolean isNaN(double d)
+ {
+ return (doubleToLongBits(d) == 0x7ff8000000000000L);
+ }
- /**
- * Return <code>true</code> if the value of this <code>Double</code>
- * is the same as <code>NEGATIVE_INFINITY</code> or
- * <code>POSITIVE_INFINITY</code>, otherwise return <code>false</code>.
- *
- * @return whether this <code>Double</code> is (-/+) infinity.
- */
- public boolean isInfinite()
- {
- return isInfinite(value);
- }
+ /**
+ * Return <code>true</code> if the value of this <code>Double</code>
+ * is the same as <code>NEGATIVE_INFINITY</code> or
+ * <code>POSITIVE_INFINITY</code>, otherwise return <code>false</code>.
+ *
+ * @return whether this <code>Double</code> is (-/+) infinity.
+ */
+ public boolean isInfinite()
+ {
+ return isInfinite(value);
+ }
- /**
- * Return <code>true</code> if the <code>double</code> has a value
- * equal to either <code>NEGATIVE_INFINITY</code> or
- * <code>POSITIVE_INFINITY</code>, otherwise return <code>false</code>.
- *
- * @param d the <code>double</code> to compare
- * @return whether the argument is (-/+) infinity.
- */
- public static boolean isInfinite(double d)
- {
- return (d == POSITIVE_INFINITY || d == NEGATIVE_INFINITY);
- }
+ /**
+ * Return <code>true</code> if the <code>double</code> has a value
+ * equal to either <code>NEGATIVE_INFINITY</code> or
+ * <code>POSITIVE_INFINITY</code>, otherwise return <code>false</code>.
+ *
+ * @param d the <code>double</code> to compare
+ * @return whether the argument is (-/+) infinity.
+ */
+ public static boolean isInfinite(double d)
+ {
+ return (d == POSITIVE_INFINITY || d == NEGATIVE_INFINITY);
+ }
- /**
- * Returns 0 if the <code>double</code> value of the argument is
- * equal to the value of this <code>Double</code>. Returns a number
- * less than zero if the value of this <code>Double</code> is less
- * than the <code>double</code> value of the argument, and returns a
- * number greater than zero if the value of this <code>Double</code>
- * is greater than the <code>double</code> value of the argument.
- * <br>
- * <code>Double.NaN</code> is greater than any number other than itself,
- * even <code>Double.POSITIVE_INFINITY</code>.
- * <br>
- * <code>0.0d</code> is greater than <code>-0.0d</code>.
- *
- * @param o the Object to compare to.
- * @return 0 if the <code>Double</code>s are the same, &lt; 0 if this
- * <code>Double</code> is less than the <code>Double</code> in
- * in question, or &gt; 0 if it is greater.
- */
- public int compareTo(Double d)
- {
- double x = d.doubleValue();
+ /**
+ * Returns 0 if the <code>double</code> value of the argument is
+ * equal to the value of this <code>Double</code>. Returns a number
+ * less than zero if the value of this <code>Double</code> is less
+ * than the <code>double</code> value of the argument, and returns a
+ * number greater than zero if the value of this <code>Double</code>
+ * is greater than the <code>double</code> value of the argument.
+ * <br>
+ * <code>Double.NaN</code> is greater than any number other than itself,
+ * even <code>Double.POSITIVE_INFINITY</code>.
+ * <br>
+ * <code>0.0d</code> is greater than <code>-0.0d</code>.
+ *
+ * @param o the Object to compare to.
+ * @return 0 if the <code>Double</code>s are the same, &lt; 0 if this
+ * <code>Double</code> is less than the <code>Double</code> in
+ * in question, or &gt; 0 if it is greater.
+ * @since 1.2
+ */
+ public int compareTo(Double d)
+ {
+ double x = d.doubleValue();
- if (value == NaN)
- return (x == NaN) ? 0 : 1;
- if ((value == 0.0d) && (x == -0.0d))
- return 1;
- if ((value == -0.0d) && (x == 0.0d))
- return -1;
+ if (isNaN (value))
+ return isNaN(x) ? 0 : 1;
+ if ((value == 0.0d) && (x == -0.0d))
+ return 1;
+ if ((value == -0.0d) && (x == 0.0d))
+ return -1;
+ if (value == x)
+ return 0;
- return ((value - x) > 0) ? 1 : -1;
- }
+ return (value > x) ? 1 : -1;
+ }
- /**
- * Compares the specified <code>Object</code> to this <code>Double</code>
- * if and only if the <code>Object</code> is an instanceof
- * <code>Double</code>.
- *
- * @param o the Object to compare to.
- * @return 0 if the <code>Double</code>s are the same, &lt; 0 if this
- * <code>Double</code> is less than the <code>Double</code> in
- * in question, or &gt; 0 if it is greater.
- * @throws ClassCastException if the argument is not a <code>Double</code>
- */
- public int compareTo(Object o)
- {
- return compareTo((Double)o);
- }
+ /**
+ * Compares the specified <code>Object</code> to this <code>Double</code>
+ * if and only if the <code>Object</code> is an instanceof
+ * <code>Double</code>.
+ *
+ * @param o the Object to compare to.
+ * @return 0 if the <code>Double</code>s are the same, &lt; 0 if this
+ * <code>Double</code> is less than the <code>Double</code> in
+ * in question, or &gt; 0 if it is greater.
+ * @throws ClassCastException if the argument is not a <code>Double</code>
+ */
+ public int compareTo(Object o)
+ {
+ return compareTo((Double)o);
+ }
+
+ /**
+ * Convert the <code>double</code> to a <code>String</code>.
+ * <P>
+ *
+ * Floating-point string representation is fairly complex: here is a
+ * rundown of the possible values. "<CODE>[-]</CODE>" indicates that a
+ * negative sign will be printed if the value (or exponent) is negative.
+ * "<CODE>&lt;number&gt;</CODE>" means a string of digits (0-9).
+ * "<CODE>&lt;digit&gt;</CODE>" means a single digit (0-9).
+ * <P>
+ *
+ * <TABLE BORDER=1>
+ * <TR><TH>Value of Float</TH><TH>String Representation</TH></TR>
+ * <TR>
+ * <TD>[+-] 0</TD>
+ * <TD>[<CODE>-</CODE>]<CODE>0.0</CODE></TD>
+ * </TR>
+ * <TR>
+ * <TD>Between [+-] 10<SUP>-3</SUP> and 10<SUP>7</SUP></TD>
+ * <TD><CODE>[-]number.number</CODE></TD>
+ * </TR>
+ * <TR>
+ * <TD>Other numeric value</TD>
+ * <TD><CODE>[-]&lt;digit&gt;.&lt;number&gt;E[-]&lt;number&gt;</CODE></TD>
+ * </TR>
+ * <TR>
+ * <TD>[+-] infinity</TD>
+ * <TD><CODE>[-]Infinity</CODE></TD>
+ * </TR>
+ * <TR>
+ * <TD>NaN</TD>
+ * <TD><CODE>NaN</CODE></TD>
+ * </TR>
+ * </TABLE>
+ *
+ * Yes, negative zero <EM>is</EM> a possible value. Note that there is
+ * <EM>always</EM> a <CODE>.</CODE> and at least one digit printed after
+ * it: even if the number is 3, it will be printed as <CODE>3.0</CODE>.
+ * After the ".", all digits will be printed except trailing zeros. No
+ * truncation or rounding is done by this function.
+ *
+ *
+ * @XXX specify where we are not in accord with the spec.
+ *
+ * @param d the <code>double</code> to convert
+ * @return the <code>String</code> representing the <code>double</code>.
+ */
+ public static String toString(double d)
+ {
+ return toString (d, false);
+ }
+
+ static native String toString(double d, boolean isFloat);
+
+ /**
+ * Return the long bits of the specified <code>double</code>.
+ * The result of this function can be used as the argument to
+ * <code>Double.longBitsToDouble(long)</code> to obtain the
+ * original <code>double</code> value.
+ *
+ * @param value the <code>double</code> to convert
+ * @return the bits of the <code>double</code>.
+ */
+ public static native long doubleToLongBits(double value);
- /**
- * Convert the <code>double</code> to a <code>String</code>.
- * <P>
- *
- * Floating-point string representation is fairly complex: here is a
- * rundown of the possible values. "<CODE>[-]</CODE>" indicates that a
- * negative sign will be printed if the value (or exponent) is negative.
- * "<CODE>&lt;number&gt;</CODE>" means a string of digits (0-9).
- * "<CODE>&lt;digit&gt;</CODE>" means a single digit (0-9).
- * <P>
- *
- * <TABLE BORDER=1>
- * <TR><TH>Value of Float</TH><TH>String Representation</TH></TR>
- * <TR>
- * <TD>[+-] 0</TD>
- * <TD>[<CODE>-</CODE>]<CODE>0.0</CODE></TD>
- * </TR>
- * <TR>
- * <TD>Between [+-] 10<SUP>-3</SUP> and 10<SUP>7</SUP></TD>
- * <TD><CODE>[-]number.number</CODE></TD>
- * </TR>
- * <TR>
- * <TD>Other numeric value</TD>
- * <TD><CODE>[-]&lt;digit&gt;.&lt;number&gt;E[-]&lt;number&gt;</CODE></TD>
- * </TR>
- * <TR>
- * <TD>[+-] infinity</TD>
- * <TD><CODE>[-]Infinity</CODE></TD>
- * </TR>
- * <TR>
- * <TD>NaN</TD>
- * <TD><CODE>NaN</CODE></TD>
- * </TR>
- * </TABLE>
- *
- * Yes, negative zero <EM>is</EM> a possible value. Note that there is
- * <EM>always</EM> a <CODE>.</CODE> and at least one digit printed after
- * it: even if the number is 3, it will be printed as <CODE>3.0</CODE>.
- * After the ".", all digits will be printed except trailing zeros. No
- * truncation or rounding is done by this function.
- *
- *
- * @XXX specify where we are not in accord with the spec.
- *
- * @param d the <code>double</code> to convert
- * @return the <code>String</code> representing the <code>double</code>.
- */
- public native static String toString(double d);
+ /**
+ * Return the long bits of the specified <code>double</code>.
+ * The result of this function can be used as the argument to
+ * <code>Double.longBitsToDouble(long)</code> to obtain the
+ * original <code>double</code> value. This method differs from
+ * <code>doubleToLongBits</code> in that it does not collapse
+ * NaN values.
+ *
+ * @param value the <code>double</code> to convert
+ * @return the bits of the <code>double</code>.
+ */
+ public static native long doubleToRawLongBits(double value);
+
+ /**
+ * Return the <code>double</code> represented by the long
+ * bits specified.
+ *
+ * @param bits the long bits representing a <code>double</code>
+ * @return the <code>double</code> represented by the bits.
+ */
+ public static native double longBitsToDouble(long bits);
- /**
- * Return the long bits of the specified <code>double</code>.
- * The result of this function can be used as the argument to
- * <code>Double.longBitsToDouble(long)</code> to obtain the
- * original <code>double</code> value.
- *
- * @param value the <code>double</code> to convert
- * @return the bits of the <code>double</code>.
- */
- public native static long doubleToLongBits(double value);
+ /**
+ * Parse the specified <code>String</code> as a <code>double</code>.
+ * <P>
+ *
+ * The number is really read as <em>n * 10<sup>exponent</sup></em>. The
+ * first number is <em>n</em>, and if there is an "<code>E</code>"
+ * ("<code>e</code>" is also acceptable), then the integer after that is
+ * the exponent.
+ * <P>
+ *
+ * Here are the possible forms the number can take:
+ * <BR>
+ * <TABLE BORDER=1>
+ * <TR><TH>Form</TH><TH>Examples</TH></TR>
+ * <TR><TD><CODE>[+-]&lt;number&gt;[.]</CODE></TD><TD>345., -10, 12</TD></TR>
+ * <TR><TD><CODE>[+-]&lt;number&gt;.&lt;number&gt;</CODE></TD><TD>40.2, 80.00, -12.30</TD></TR>
+ * <TR><TD><CODE>[+-]&lt;number&gt;[.]E[+-]&lt;number&gt;</CODE></TD><TD>80E12, -12e+7, 4.E-123</TD></TR>
+ * <TR><TD><CODE>[+-]&lt;number&gt;.&lt;number&gt;E[+-]&lt;number&gt;</CODE></TD><TD>6.02e-22, -40.2E+6, 12.3e9</TD></TR>
+ * </TABLE>
+ *
+ * "<code>[+-]</code>" means either a plus or minus sign may go there, or
+ * neither, in which case + is assumed.
+ * <BR>
+ * "<code>[.]</code>" means a dot may be placed here, but is optional.
+ * <BR>
+ * "<code>&lt;number&gt;</code>" means a string of digits (0-9), basically
+ * an integer. "<code>&lt;number&gt;.&lt;number&gt;</code>" is basically
+ * a real number, a floating-point value.
+ * <P>
+ *
+ * Remember that a <code>double</code> has a limited range. If the
+ * number you specify is greater than <code>Double.MAX_VALUE</code> or less
+ * than <code>-Double.MAX_VALUE</code>, it will be set at
+ * <code>Double.POSITIVE_INFINITY</code> or
+ * <code>Double.NEGATIVE_INFINITY</code>, respectively.
+ * <P>
+ *
+ * Note also that <code>double</code> does not have perfect precision. Many
+ * numbers cannot be precisely represented. The number you specify
+ * will be rounded to the nearest representable value. <code>Double.MIN_VALUE</code> is
+ * the margin of error for <code>double</code> values.
+ * <P>
+ *
+ * If an unexpected character is found in the <code>String</code>, a
+ * <code>NumberFormatException</code> will be thrown. Spaces are not
+ * allowed, and will cause the same exception.
+ *
+ * @XXX specify where/how we are not in accord with the spec.
+ *
+ * @param str the <code>String</code> to convert
+ * @return the value of the <code>String</code> as a <code>double</code>.
+ * @exception NumberFormatException when the string cannot be parsed to a
+ * <code>double</code>.
+ * @exception NullPointerException when the string is null.
+ * @see #MIN_VALUE
+ * @see #MAX_VALUE
+ * @see #POSITIVE_INFINITY
+ * @see #NEGATIVE_INFINITY
+ * @since 1.2
+ */
+ public static double parseDouble (String s)
+ throws NumberFormatException
+ {
+ String t = s.trim();
+ return parseDouble0 (t);
+ }
- /**
- * Return the <code>double</code> represented by the long
- * bits specified.
- *
- * @param bits the long bits representing a <code>double</code>
- * @return the <code>double</code> represented by the bits.
- */
- public native static double longBitsToDouble(long bits);
+ private static native double parseDouble0 (String s)
+ throws NumberFormatException;
- /**
- * Parse the specified <code>String</code> as a <code>double</code>.
- * <P>
- *
- * The number is really read as <em>n * 10<sup>exponent</sup></em>. The
- * first number is <em>n</em>, and if there is an "<code>E</code>"
- * ("<code>e</code>" is also acceptable), then the integer after that is
- * the exponent.
- * <P>
- *
- * Here are the possible forms the number can take:
- * <BR>
- * <TABLE BORDER=1>
- * <TR><TH>Form</TH><TH>Examples</TH></TR>
- * <TR><TD><CODE>[+-]&lt;number&gt;[.]</CODE></TD><TD>345., -10, 12</TD></TR>
- * <TR><TD><CODE>[+-]&lt;number&gt;.&lt;number&gt;</CODE></TD><TD>40.2, 80.00, -12.30</TD></TR>
- * <TR><TD><CODE>[+-]&lt;number&gt;[.]E[+-]&lt;number&gt;</CODE></TD><TD>80E12, -12e+7, 4.E-123</TD></TR>
- * <TR><TD><CODE>[+-]&lt;number&gt;.&lt;number&gt;E[+-]&lt;number&gt;</CODE></TD><TD>6.02e-22, -40.2E+6, 12.3e9</TD></TR>
- * </TABLE>
- *
- * "<code>[+-]</code>" means either a plus or minus sign may go there, or
- * neither, in which case + is assumed.
- * <BR>
- * "<code>[.]</code>" means a dot may be placed here, but is optional.
- * <BR>
- * "<code>&lt;number&gt;</code>" means a string of digits (0-9), basically
- * an integer. "<code>&lt;number&gt;.&lt;number&gt;</code>" is basically
- * a real number, a floating-point value.
- * <P>
- *
- * Remember that a <code>double</code> has a limited range. If the
- * number you specify is greater than <code>Double.MAX_VALUE</code> or less
- * than <code>-Double.MAX_VALUE</code>, it will be set at
- * <code>Double.POSITIVE_INFINITY</code> or
- * <code>Double.NEGATIVE_INFINITY</code>, respectively.
- * <P>
- *
- * Note also that <code>double</code> does not have perfect precision. Many
- * numbers cannot be precisely represented. The number you specify
- * will be rounded to the nearest representable value. <code>Double.MIN_VALUE</code> is
- * the margin of error for <code>double</code> values.
- * <P>
- *
- * If an unexpected character is found in the <code>String</code>, a
- * <code>NumberFormatException</code> will be thrown. Spaces are not
- * allowed, and will cause the same exception.
- *
- * @XXX specify where/how we are not in accord with the spec.
- *
- * @param str the <code>String</code> to convert
- * @return the value of the <code>String</code> as a <code>double</code>.
- * @exception NumberFormatException when the string cannot be parsed to a
- * <code>double</code>.
- * @exception NullPointerException when the string is null.
- * @since JDK 1.2
- * @see #MIN_VALUE
- * @see #MAX_VALUE
- * @see #POSITIVE_INFINITY
- * @see #NEGATIVE_INFINITY
- */
- public native static double parseDouble(String str)
- throws NumberFormatException, NullPointerException;
+ /**
+ * Initialize JNI cache. This method is called only by the
+ * static initializer when using JNI.
+ */
+ private static native void initIDs ();
}
diff --git a/java/lang/Float.java b/java/lang/Float.java
index c4fffe51d..169e7ce40 100644
--- a/java/lang/Float.java
+++ b/java/lang/Float.java
@@ -35,6 +35,7 @@ package java.lang;
* related to floats.
*
* @author Paul Fisher
+ * @author Andrew Haley <aph@cygnus.com>
* @since JDK 1.0
*/
public final class Float extends Number implements Comparable
@@ -108,11 +109,10 @@ public final class Float extends Number implements Comparable
*
* @exception NumberFormatException when the <code>String</code> cannot
* be parsed into a <code>Float</code>.
- * @exception NullPointerException when the argument is <code>null</code>.
* @param s the <code>String</code> to convert
* @see #parseFloat(java.lang.String)
*/
- public Float(String s) throws NumberFormatException, NullPointerException
+ public Float(String s) throws NumberFormatException
{
value = parseFloat(s);
}
@@ -236,7 +236,10 @@ public final class Float extends Number implements Comparable
* @param f the <code>float</code> to convert
* @return the <code>String</code> representing the <code>float</code>.
*/
- public native static String toString(float f);
+ public static String toString(float f)
+ {
+ return Double.toString ((double)f, true);
+ }
/**
* Return the result of calling <code>new Float(java.lang.String)</code>.
@@ -245,15 +248,13 @@ public final class Float extends Number implements Comparable
* @return a new <code>Float</code> representing the <code>String</code>'s
* numeric value.
*
- * @exception NullPointerException thrown if <code>String</code> is
- * <code>null</code>.
* @exception NumberFormatException thrown if <code>String</code> cannot
* be parsed as a <code>double</code>.
* @see #Float(java.lang.String)
* @see #parseFloat(java.lang.String)
*/
public static Float valueOf(String s)
- throws NumberFormatException, NullPointerException
+ throws NumberFormatException
{
return new Float(s);
}
@@ -317,6 +318,19 @@ public final class Float extends Number implements Comparable
public native static int floatToIntBits(float value);
/**
+ * Return the int bits of the specified <code>float</code>.
+ * The result of this function can be used as the argument to
+ * <code>Float.intBitsToFloat(long)</code> to obtain the
+ * original <code>float</code> value. The difference between
+ * this function and <code>floatToIntBits</code> is that this
+ * function does not collapse NaN values.
+ *
+ * @param value the <code>float</code> to convert
+ * @return the bits of the <code>float</code>.
+ */
+ public native static int floatToRawIntBits(float value);
+
+ /**
* Return the <code>float</code> represented by the long
* bits specified.
*
@@ -378,15 +392,16 @@ public final class Float extends Number implements Comparable
* @return the value of the <code>String</code> as a <code>float</code>.
* @exception NumberFormatException when the string cannot be parsed to a
* <code>float</code>.
- * @exception NullPointerException when the String is null.
* @since JDK 1.2
* @see #MIN_VALUE
* @see #MAX_VALUE
* @see #POSITIVE_INFINITY
* @see #NEGATIVE_INFINITY
*/
- public native static float parseFloat(String s)
- throws NumberFormatException, NullPointerException;
+ public static float parseFloat(String s)
+ throws NumberFormatException {
+ return (float)Double.parseDouble(s);
+ }
/**
* Returns 0 if the <code>float</code> value of the argument is
diff --git a/lib/Makefile.am b/lib/Makefile.am
index a7fbb1922..f705320c1 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -3,6 +3,7 @@
# --cbj
## used by automake to generate Makefile.in
+PERL = @PERL@
MAKEFILE_DEPEND = makefile.dep
HEADERS_DEPEND = headers.dep
CLASSES_DEPEND = classes.dep
@@ -109,9 +110,9 @@ else
if USER_SPECIFIED_JIKES
if USER_SPECIFIED_CLASSLIB
-JAVAC = @JIKES@ -nowarn +CSO +F $(ARG_CLASSPATH_JAVAC) ..:../vm/current:.:@USER_CLASSLIB@ -d . @classes
+JAVAC = @JIKES@ -nowarn +F $(ARG_CLASSPATH_JAVAC) $(top_srcdir):$(top_builddir)/vm/current:.:@USER_CLASSLIB@ -d . @classes
else
-JAVAC = @JIKES@ -nowarn +CSO +M +F $(ARG_CLASSPATH_JAVAC) ..:../vm/current:. -d . @classes
+JAVAC = @JIKES@ -nowarn +F $(ARG_CLASSPATH_JAVAC) $(top_srcdir):$(top_builddir)/vm/current:. -d . @classes
endif
else
@@ -204,11 +205,11 @@ glibj.zip: classes compile-classes $(MAKEFILE_DEPEND)
$(ZIP) -r -D glibj.zip gnu java javax > /dev/null
classes: gen-classlist.sh standard.omit $(top_srcdir)/java $(top_srcdir)/javax $(top_srcdir)/gnu
- $(SHELL) -c "cd $(top_srcdir)/lib && ./gen-classlist.sh standard"
+ top_builddir=$(top_builddir) $(SHELL) ./gen-classlist.sh standard
.PHONY: dep
dep: classes
- $(SHELL) -c "cd $(top_srcdir)/lib; ./mkdep.pl -s"
+ top_srcdir=@top_srcdir@ $(PERL) ./mkdep.pl -s
#.PHONY: compile-classes
compile-classes: classes $(JAVA_DEPEND) $(JAVA_SRCS) Makefile
@@ -216,18 +217,18 @@ compile-classes: classes $(JAVA_DEPEND) $(JAVA_SRCS) Makefile
touch compile-classes
$(MAKEFILE_DEPEND): compile-classes
- $(SHELL) -c "cd $(top_srcdir)/lib && ./mkdep.pl -d"
- $(SHELL) -c "cd $(top_srcdir)/lib && find -regex ".*\.u$" -exec rm \{\} \;
+ top_srcdir=@top_srcdir@ $(PERL) ./mkdep.pl -d
+ $(SHELL) -c find -regex ".*\.u$$" -exec rm \{\} \; > /dev/null
$(HEADERS_DEPEND): classes
- if ! [ -e $(top_srcdir)/include ]; then -mkdir $(top_srcdir)/include; fi
- $(SHELL) -c "cd $(top_srcdir)/lib && ./mkdep.pl -h"
+ if ! [ -e $(top_builddir)/include ]; then -mkdir $(top_builddir)/include; fi
+ top_srcdir=@top_srcdir@ $(PERL) ./mkdep.pl -h
$(CLASSES_DEPEND): classes
- $(SHELL) -c "cd $(top_srcdir)/lib && ./mkdep.pl -c"
+ top_srcdir=@top_srcdir@ $(PERL) ./mkdep.pl -c
$(JAVA_DEPEND): classes
- $(SHELL) -c "cd $(top_srcdir)/lib && ./mkdep.pl -j"
+ top_srcdir=@top_srcdir@ $(PERL) ./mkdep.pl -j
## neither developer nor maintainer...
diff --git a/lib/gen-classlist.sh.in b/lib/gen-classlist.sh.in
index 038da2718..572290190 100755
--- a/lib/gen-classlist.sh.in
+++ b/lib/gen-classlist.sh.in
@@ -1,4 +1,4 @@
#! @SH@
# @configure_input@
-@FIND@ @top_srcdir@/java @top_srcdir@/gnu @top_srcdir@/vm/current -follow -type f -print | grep '\.java$' > @top_srcdir@/lib/classes
-for filexp in `cat @top_srcdir@/lib/$1.omit` ; do { grep -v ${filexp} < @top_srcdir@/lib/classes > @top_srcdir@/lib/classes.new ; mv @top_srcdir@/lib/classes.new @top_srcdir@/lib/classes ; } ; done
+@FIND@ @top_srcdir@/java @top_srcdir@/gnu ${top_builddir}/java ${top_builddir}/gnu ${top_builddir}/vm/current -follow -type f -print | grep '\.java$' > ${top_builddir}/lib/classes
+for filexp in `cat @top_srcdir@/lib/$1.omit` ; do { grep -v ${filexp} < ${top_builddir}/lib/classes > ${top_builddir}/lib/classes.new ; mv ${top_builddir}/lib/classes.new ${top_builddir}/lib/classes ; } ; done
diff --git a/lib/mkdep.pl.in b/lib/mkdep.pl.in
index 972433622..c5a9c1fa7 100755
--- a/lib/mkdep.pl.in
+++ b/lib/mkdep.pl.in
@@ -62,7 +62,17 @@ use vars qw ( $classout $headerout @dirs @deps @natives $dir $dep $depout );
sub writeNativeFile
{
my ($i, $j, $k, $l) = "";
-
+ my $top_srcdir = "../";
+ if (defined $ENV{'top_srcdir'}) {
+ $top_srcdir = $ENV{'top_srcdir'};
+ }
+ my $top_srcdir_regex = $top_srcdir;
+ if ($top_srcdir_regex !~ /.*\/$/) {
+ $top_srcdir_regex .= '/';
+ }
+ $top_srcdir_regex =~ s/\./\\\./g; # replace . with \.
+ $top_srcdir_regex =~ s/\//\\\//g; # replace / with \/
+# print "regex is $top_srcdir_regex\n";
open(MAKEDEP, ">$headerout") || die "Could not open file ", $headerout;
# the HEADERS = ... stuff
@@ -72,18 +82,20 @@ sub writeNativeFile
foreach $i (0 .. $#natives-1)
{
$j = $natives[$i];
- $j =~ s/^\.\.\///; # remove ../
+ $j =~ s/^$top_srcdir_regex//; # remove ../ or similar
+ $j =~ s/^(\.\.\/)+//g; # remove all preceding ../
$j =~ s/^vm\/current\///; # remove vm/current/
$j =~ s/\//_/g; # replace / with _
$j =~ s/\.java$/\.h/; # replace .java with .h
- print MAKEDEP " ../include/", $j, " \\", "\n";
+ print MAKEDEP " \$(top_builddir)/include/", $j, " \\", "\n";
}
$j = $natives[$#natives];
- $j =~ s/^\.\.\///; # remove ../
+ $j =~ s/^$top_srcdir_regex//; # remove ../
+ $j =~ s/^(\.\.\/)+//g; # remove all preceding ../
$j =~ s/^vm\/current\///; # remove vm/current/
$j =~ s/\//_/g; # replace / with _
$j =~ s/\.java/\.h/; # replace .java with .h
- print MAKEDEP " ../include/", $j, "\n\n";
+ print MAKEDEP " \$(top_builddir)/include/", $j, "\n\n";
# print rules to make .h files
# y/x.h : z/x.class
@@ -98,7 +110,8 @@ sub writeNativeFile
foreach $i (0 .. $#natives-1)
{
$j = $natives[$i];
- $j =~ s/^\.\.\///; # remove ../
+ $j =~ s/^$top_srcdir_regex//; # remove ../
+ $j =~ s/^(\.\.\/)+//g; # remove all preceding ../
$j =~ s/^vm\/current\///; # remove vm/current/
# $k = $l = $j;
$l = $j;
@@ -111,27 +124,28 @@ sub writeNativeFile
$l =~ s/\.java$//; # remove .class
$l =~ s/\//\./g; # replace / with .
- print MAKEDEP "../include/", $j, " : ", $k, "\n";
+ print MAKEDEP "\$(top_builddir)/include/", $j, " : ", $k, "\n";
print MAKEDEP "\t\$(JAVAH) ", $l, "\n";
- print MAKEDEP "\tmv ", $j, " \$(top_srcdir)/include\n\n";
+ print MAKEDEP "\tmv ", $j, " \$(top_builddir)/include\n\n";
}
$j = $natives[$#natives];
- $j =~ s/^\.\.\///; # remove ../
+ $j =~ s/^$top_srcdir_regex//; # remove ../
+ $j =~ s/^(\.\.\/)+//g; # remove all preceding ../
$j =~ s/^vm\/current\///; # remove vm/current/
# $k = $l = $j;
$l = $j;
$j =~ s/\//_/g; # replace / with _
$j =~ s/\.java/\.h/; # replace .java with .h
- $k = $natives[$i]; # the original .java file
+ $k = $natives[$#natives]; # the original .java file
# $k =~ s/\.java$/\.class/; # replace .java with .class
$l =~ s/\.java$//; # remove .class
$l =~ s/\//\./g; # replace / with .
- print MAKEDEP "../include/", $j, " : ", $k, "\n";
+ print MAKEDEP "\$(top_builddir)/include/", $j, " : ", $k, "\n";
print MAKEDEP "\t\$(JAVAH) ", $l, "\n";
- print MAKEDEP "\tmv ", $j, " \$(top_srcdir)/include\n\n";
+ print MAKEDEP "\tmv ", $j, " \$(top_builddir)/include\n\n";
}
close(MAKEDEP);
}
diff --git a/lib/standard.omit b/lib/standard.omit
index 021f0e2c4..54b85fc2a 100644
--- a/lib/standard.omit
+++ b/lib/standard.omit
@@ -1,20 +1,20 @@
-^../java/net/Authenticator.java$
-^../java/net/JarURLConnection.java$
-^../java/lang/RuntimePermission.java$
-^../java/text/MessageFormat.java$
-^../gnu/test/.*$
-^../gnu/java/awt/peer/gtk/TestAWT.java$
-^../gnu/java/awt/peer/gtk/Test.java$
-^../gnu/javax/swing/plaf/gtk/.*$
-^../java/awt/datatransfer/DataFlavor.java$
-^../java/awt/AWTEvent.java$
-^../java/awt/ImageMediaEntry.java$
-^../java/awt/MediaEntry.java$
-^../java/awt/MediaTracker.java$
-^../java/awt/event/InputMethodEvent.java$
-^../java/awt/event/InputMethodListener.java$
-^../java/awt/event/InvocationEvent.java$
-^../java/util/jar/JarEntry.java$
-^../java/util/jar/JarFile.java$
-^../java/util/jar/JarInputStream.java$
-^../java/util/jar/JarOutputStream.java$
+../java/net/Authenticator.java$
+../java/net/JarURLConnection.java$
+../java/lang/RuntimePermission.java$
+../java/text/MessageFormat.java$
+../gnu/test/.*$
+../gnu/java/awt/peer/gtk/TestAWT.java$
+../gnu/java/awt/peer/gtk/Test.java$
+../gnu/javax/swing/plaf/gtk/.*$
+../java/awt/datatransfer/DataFlavor.java$
+../java/awt/AWTEvent.java$
+../java/awt/ImageMediaEntry.java$
+../java/awt/MediaEntry.java$
+../java/awt/MediaTracker.java$
+../java/awt/event/InputMethodEvent.java$
+../java/awt/event/InputMethodListener.java$
+../java/awt/event/InvocationEvent.java$
+../java/util/jar/JarEntry.java$
+../java/util/jar/JarFile.java$
+../java/util/jar/JarInputStream.java$
+../java/util/jar/JarOutputStream.java$
diff --git a/native/jni/Makefile.am b/native/jni/Makefile.am
index 19698e6eb..975492d25 100644
--- a/native/jni/Makefile.am
+++ b/native/jni/Makefile.am
@@ -20,8 +20,11 @@ libjavaio_la_SOURCES = \
java_io_ObjectInputStream.c
libjavalang_la_SOURCES = \
- javalang.c \
- javalang.h \
+ mprec.h \
+ mprec.c \
+ fdlibm.h \
+ jcl.h \
+ jcl.c \
java_lang_System.c \
java_lang_Object.c \
java_lang_Float.c \
@@ -55,7 +58,8 @@ libjavanet_la_LDFLAGS = -version-info @LIBVERSION@
libjavautil_la_LDFLAGS = -version-info @LIBVERSION@
INCLUDES += @EXTRA_INCLUDES@ \
- -I$(top_srcdir)/include
+ -I$(top_srcdir)/native/lib/ \
+ -I$(top_builddir)/include
if JAPHAR
install-data-local :
diff --git a/native/jni/awt/Makefile.am b/native/jni/awt/Makefile.am
index 7867f3247..49802199d 100644
--- a/native/jni/awt/Makefile.am
+++ b/native/jni/awt/Makefile.am
@@ -39,7 +39,7 @@ libgtkpeer_la_LDFLAGS = -version-info @LIBVERSION@ @GTK_LIBS@ @GLIB_LIBS@ @LIBAR
INCLUDES += @EXTRA_INCLUDES@ \
@GTK_CFLAGS@ \
@LIBART_CFLAGS@ \
- -I$(top_srcdir)/include
+ -I$(top_builddir)/include
if JAPHAR
install-data-local :
diff --git a/native/jni/java_lang_Double.c b/native/jni/java_lang_Double.c
index 2da3090aa..c6add5f30 100644
--- a/native/jni/java_lang_Double.c
+++ b/native/jni/java_lang_Double.c
@@ -26,23 +26,85 @@ executable file might be covered by the GNU General Public License. */
#include <config.h>
-#include <stdlib.h> /* for strtod() */
-#include <math.h> /* for HUGE_VAL */
+#include <stdlib.h>
+#include <string.h>
+
+#include "mprec.h"
+#include "fdlibm.h"
+#include "jcl.h"
-#include "javalang.h"
#include "java_lang_Double.h"
+
+/*
+ * Class: java_lang_Double
+ * Method: initIDs
+ * Signature: ()
+ */
+jmethodID isNaNID;
+jdouble NEGATIVE_INFINITY;
+jdouble POSITIVE_INFINITY;
+
+JNIEXPORT void JNICALL Java_java_lang_Double_initIDs
+ (JNIEnv *env, jclass cls)
+{
+ jfieldID negInfID;
+ jfieldID posInfID;
+
+ isNaNID = (*env)->GetStaticMethodID(env, cls, "isNaN", "(D)Z)");
+ if (isNaNID == NULL)
+ {
+ DBG("unable to determine method id of isNaN\n")
+ return;
+ }
+ negInfID = (*env)->GetFieldID(env, cls, "NEGATIVE_INFINITY", "D");
+ if (negInfID == NULL)
+ {
+ DBG("unable to determine field id of NEGATIVE_INFINITY\n")
+ return;
+ }
+ posInfID = (*env)->GetFieldID(env, cls, "POSITIVE_INFINITY", "D");
+ if (posInfID == NULL)
+ {
+ DBG("unable to determine field id of POSITIVE_INFINITY\n")
+ return;
+ }
+ POSITIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, posInfID);
+ NEGATIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, negInfID);
+}
+
/*
* Class: java_lang_Double
* Method: doubleToLongBits
* Signature: (D)J
*/
JNIEXPORT jlong JNICALL Java_java_lang_Double_doubleToLongBits
- (JNIEnv * env, jclass thisClass, jdouble doubleValue)
+ (JNIEnv * env, jclass cls, jdouble doubleValue)
+{
+ jvalue val;
+ jlong e, f;
+ val.d = doubleValue;
+
+ e = val.j & 0x7ff0000000000000LL;
+ f = val.j & 0x000fffffffffffffLL;
+
+ if (e == 0x7ff0000000000000LL && f != 0L)
+ val.j = 0x7ff8000000000000LL;
+
+ return val.j;
+}
+
+/*
+ * Class: java_lang_Double
+ * Method: doubleToRawLongBits
+ * Signature: (D)J
+ */
+JNIEXPORT jlong JNICALL Java_java_lang_Double_doubleToRawLongBits
+ (JNIEnv * env, jclass cls, jdouble doubleValue)
{
- jvalue val;
- val.d = doubleValue;
- return val.j;
+ jvalue val;
+ val.d = doubleValue;
+ return val.j;
}
/*
@@ -51,11 +113,11 @@ JNIEXPORT jlong JNICALL Java_java_lang_Double_doubleToLongBits
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL Java_java_lang_Double_longBitsToDouble
- (JNIEnv * env, jclass thisClass, jlong longValue)
+ (JNIEnv * env, jclass cls, jlong longValue)
{
- jvalue val;
- val.j = longValue;
- return val.d;
+ jvalue val;
+ val.j = longValue;
+ return val.d;
}
/*
@@ -64,86 +126,130 @@ JNIEXPORT jdouble JNICALL Java_java_lang_Double_longBitsToDouble
* Signature: (D)Ljava/lang/String
*/
JNIEXPORT jstring JNICALL Java_java_lang_Double_toString
- (JNIEnv * env, jclass thisClass, jdouble d)
+ (JNIEnv * env, jclass cls, jdouble value, jboolean isFloat)
{
- char buf[1024];
- jstring retval;
+ char buffer[50], result[50];
+ int decpt, sign;
+ char *s, *d;
+ int i;
- sprintf((char*)&buf, "%G", d);
- retval = (*env)->NewStringUTF(env, buf);
- return retval;
-}
+ if ((*env)->CallStaticBooleanMethod(env, cls, isNaNID, value))
+ return (*env)->NewStringUTF(env, "NaN");
+
+ if (value == POSITIVE_INFINITY)
+ return (*env)->NewStringUTF(env, "Infinity");
-/*
- * Class: java_lang_Double
- * Method: parseDouble
- * Signature: (Ljava/lang/String)D
- */
-JNIEXPORT jdouble JNICALL Java_java_lang_Double_parseDouble
- (JNIEnv * env, jclass thisClass, jstring s)
-{
- const char *nptr;
- char *endptr, *myptr;
- jvalue val;
+ if (value == NEGATIVE_INFINITY)
+ return (*env)->NewStringUTF(env, "-Infinity");
- if (s == NULL)
- {
- _javalang_ThrowException(env, "java/lang/NullPointerException", "null argument");
- return 0.0;
- }
+ _dtoa (value, 0, 20, &decpt, &sign, NULL, buffer, (int)isFloat);
- nptr = (char*)((*env)->GetStringUTFChars(env, s, 0));
- if (nptr == NULL)
- {
- _javalang_ThrowException(env, "java/lang/NullPointerException", "null returned by GetStringUTFChars");
- return 0.0;
- }
-#if defined(HAVE_STRTOD)
- val.d = strtod(nptr, &endptr);
+ value = fabs (value);
+ s = buffer;
+ d = result;
- /* to catch non-white space characters after conversion */
- myptr = endptr;
- while ((myptr) && (*myptr != 0)) /* the null character */
- {
- switch (*myptr)
- {
- case ' ':
- case '\t':
- case '\r':
- case '\n':
- case 'f':
- case 'F':
- case 'd':
- case 'D':
- myptr++;
- break;
- default:
- (*env)->ReleaseStringUTFChars(env, s, nptr);
- _javalang_ThrowException(env, "java/lang/NumberFormatException", "bad number format for floating point literal");
- return 0.0;
- break;
- }
- }
+ if (sign)
+ *d++ = '-';
- if ((val.d == 0) && (nptr == endptr))
+ if (value >= 1e-3 && value < 1e7 || value == 0)
+ {
+ if (decpt <= 0)
+ *d++ = '0';
+ else
{
- (*env)->ReleaseStringUTFChars(env, s, nptr);
- _javalang_ThrowException(env, "java/lang/NumberFormatException", "no conversion performed, possible underflow");
- return 0.0;
+ for (i = 0; i < decpt; i++)
+ if (*s)
+ *d++ = *s++;
+ else
+ *d++ = '0';
}
- if ((val.d == -HUGE_VAL) || (val.d == HUGE_VAL))
+
+ *d++ = '.';
+
+ if (*s == 0)
{
- (*env)->ReleaseStringUTFChars(env, s, nptr);
- _javalang_ThrowException(env, "java/lang/NumberFormatException", "conversion would cause overflow");
- return 0.0;
+ *d++ = '0';
+ decpt++;
}
-#else
- val.d = atof(nptr);
-#endif
-
- (*env)->ReleaseStringUTFChars(env, s, nptr);
- return val.d;
+
+ while (decpt++ < 0)
+ *d++ = '0';
+
+ while (*s)
+ *d++ = *s++;
+
+ *d = 0;
+
+ return (*env)->NewStringUTF(env, result);
+ }
+
+ *d++ = *s++;
+ decpt--;
+ *d++ = '.';
+
+ if (*s == 0)
+ *d++ = '0';
+
+ while (*s)
+ *d++ = *s++;
+
+ *d++ = 'E';
+
+ if (decpt < 0)
+ {
+ *d++ = '-';
+ decpt = -decpt;
+ }
+
+ {
+ char exp[4];
+ char *e = exp + sizeof exp;
+
+ *--e = 0;
+ do
+ {
+ *--e = '0' + decpt % 10;
+ decpt /= 10;
+ }
+ while (decpt > 0);
+
+ while (*e)
+ *d++ = *e++;
+ }
+
+ *d = 0;
+
+ return (*env)->NewStringUTF(env, result);
+}
+
+/*
+ * Class: java_lang_Double
+ * Method: parseDouble
+ * Signature: (Ljava/lang/String)D
+ */
+JNIEXPORT jdouble JNICALL Java_java_lang_Double_parseDouble0
+ (JNIEnv * env, jclass cls, jstring str)
+{
+ jboolean isCopy;
+ int length;
+ char *buf, *endptr;
+ jdouble val;
+
+ buf = (*env)->GetStringUTFChars(env, str, &isCopy);
+ if (buf == NULL)
+ {
+ return 0.0; /* OutOfMemoryError already thrown */
+ }
+
+ if (strlen(buf) > 0)
+ {
+ struct _Jv_reent reent;
+ memset (&reent, 0, sizeof reent);
+
+ val = _strtod_r (&reent, buf, &endptr);
+ if (endptr == buf + strlen(buf))
+ return val;
+ }
+ JCL_ThrowException(env, "java/lang/NumberFormatException", "unable to parse double");
}
-
-
diff --git a/native/jni/java_lang_Float.c b/native/jni/java_lang_Float.c
index 7a7d3fee6..3c93d6ce2 100644
--- a/native/jni/java_lang_Float.c
+++ b/native/jni/java_lang_Float.c
@@ -26,10 +26,7 @@ executable file might be covered by the GNU General Public License. */
#include <config.h>
-#include <stdlib.h> /* for strtod() */
-#include <math.h> /* for HUGE_VAL */
-#include "javalang.h"
#include "java_lang_Float.h"
/*
@@ -38,110 +35,43 @@ executable file might be covered by the GNU General Public License. */
* Signature: (F)I
*/
JNIEXPORT jint JNICALL Java_java_lang_Float_floatToIntBits
- (JNIEnv * env, jclass thisClass, jfloat floatValue)
+ (JNIEnv * env, jclass cls, jfloat value)
{
- jvalue val;
- val.f = floatValue;
- return val.i;
+ jvalue u;
+ jint e, f;
+ u.f = value;
+ e = u.i & 0x7f800000;
+ f = u.i & 0x007fffff;
+
+ if (e == 0x7f800000 && f != 0)
+ u.i = 0x7fc00000;
+
+ return u.i;
}
/*
* Class: java_lang_Float
- * Method: intBitsToFloat
- * Signature: (I)F
- */
-JNIEXPORT jfloat JNICALL Java_java_lang_Float_intBitsToFloat
- (JNIEnv * env, jclass thisClass, jint intValue)
-{
- jvalue val;
- val.i = intValue;
- return val.f;
-}
-
-/*
- * Class: java_lang_Float
- * Method: toString(float f)
- * Signature: (F)Ljava/lang/String
+ * Method: floatToRawIntBits
+ * Signature: (F)I
*/
-JNIEXPORT jstring JNICALL Java_java_lang_Float_toString
- (JNIEnv * env, jclass thisClass, jfloat f)
+JNIEXPORT jint JNICALL Java_java_lang_Float_floatToRawIntBits
+ (JNIEnv * env, jclass cls, jfloat value)
{
- char buf[1024];
- jstring retval;
-
- sprintf((char*)&buf, "%G", f);
- retval = (*env)->NewStringUTF(env, buf);
- return retval;
+ jvalue u;
+ u.f = value;
+ return u.i;
}
/*
* Class: java_lang_Float
- * Method: parseFloat
- * Signature: (Ljava/lang/String)F
+ * Method: intBitsToFloat
+ * Signature: (I)F
*/
-JNIEXPORT jfloat JNICALL Java_java_lang_Float_parseFloat
- (JNIEnv * env, jclass thisClass, jstring s)
+JNIEXPORT jfloat JNICALL Java_java_lang_Float_intBitsToFloat
+ (JNIEnv * env, jclass cls, jint bits)
{
- const char *nptr;
- char *endptr, *myptr;
- jvalue val;
-
- if (s == NULL)
- {
- _javalang_ThrowException(env, "java/lang/NullPointerException", "null argument");
- return 0.0;
- }
-
- nptr = (char*)((*env)->GetStringUTFChars(env, s, 0));
- if (nptr == NULL)
- {
- _javalang_ThrowException(env, "java/lang/NullPointerException", "null returned by GetStringUTFChars");
- return 0.0;
- }
-#if defined(HAVE_STRTOD)
- val.d = strtod(nptr, &endptr);
-
-
- /* to catch non-white space characters after conversion */
- myptr = endptr;
- while ((myptr) && (*myptr != 0)) /* the null character */
- {
- switch (*myptr)
- {
- case ' ':
- case '\t':
- case '\r':
- case '\n':
- case 'f':
- case 'F':
- myptr++;
- break;
- default:
- (*env)->ReleaseStringUTFChars(env, s, nptr);
- _javalang_ThrowException(env, "java/lang/NumberFormatException", "bad number format for float");
- return 0.0;
- break;
- }
- }
-
- if ((val.d == 0) && (nptr == endptr))
- {
- (*env)->ReleaseStringUTFChars(env, s, nptr);
- _javalang_ThrowException(env, "java/lang/NumberFormatException", "no conversion performed, possible underflow");
- return 0.0;
- }
- if ((val.d == -HUGE_VAL) || (val.d == HUGE_VAL))
- {
- (*env)->ReleaseStringUTFChars(env, s, nptr);
- _javalang_ThrowException(env, "java/lang/NumberFormatException", "conversion would cause overflow");
- return 0.0;
- }
-#else
- val.d = atof(nptr);
-#endif
-
- (*env)->ReleaseStringUTFChars(env, s, nptr);
- return val.f;
+ jvalue u;
+ u.i = bits;
+ return u.f;
}
-