OSDN Git Service

* java/lang/Byte.java: Remove redundant instanceof and null checks.
authorbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Feb 2001 02:56:38 +0000 (02:56 +0000)
committerbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Feb 2001 02:56:38 +0000 (02:56 +0000)
* java/lang/Integer.java: Likewise.
* java/lang/Long.java: Likewise.
* java/lang/Short.java: Likewise.
* java/lang/Double.java: Likewise.
(doubleToRawLongBits): New method.
* java/lang/Float.java: As above.
(floatToRawIntBits): New method.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39556 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/java/lang/Byte.java
libjava/java/lang/Double.java
libjava/java/lang/Float.java
libjava/java/lang/Integer.java
libjava/java/lang/Long.java
libjava/java/lang/Short.java

index 7c9ca24..981c0ed 100644 (file)
@@ -1,3 +1,14 @@
+2001-02-08  Bryce McKinlay  <bryce@albatross.co.nz>
+
+       * java/lang/Byte.java: Remove redundant instanceof and null checks.
+       * java/lang/Integer.java: Likewise.
+       * java/lang/Long.java: Likewise.
+       * java/lang/Short.java: Likewise.
+       * java/lang/Double.java: Likewise.
+       (doubleToRawLongBits): New method.
+       * java/lang/Float.java: As above.
+       (floatToRawIntBits): New method.
+
 2001-02-08  Tom Tromey  <tromey@redhat.com>
 
        * java/lang/Float.java (parseFloat): New method.
index 78f34aa..347e252 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -115,17 +115,15 @@ public final class Byte extends Number implements Comparable
   }
 
   // Added in JDK 1.2
-  public int compareTo(Object o) throws ClassCastException
+  /** @throws ClassCastException */
+  public int compareTo(Object o)
   {
-    if (o instanceof Byte)
-      return this.value - ((Byte) o).value;
-    else
-      throw new ClassCastException();
+    return this.value - ((Byte) o).value;
   }
 
   public boolean equals(Object obj)
   {
-    return obj != null && (obj instanceof Byte) && ((Byte)obj).value == value;
+    return (obj instanceof Byte) && ((Byte)obj).value == value;
   }
 
   // Verified that hashCode is returns plain value (see Boolean_1 test).
index 8de429e..a656b51 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -54,9 +54,6 @@ public final class Double extends Number implements Comparable
 
   public boolean equals (Object obj)
   {
-    if (obj == null)
-      return false;
-
     if (!(obj instanceof Double))
       return false;
 
@@ -108,12 +105,8 @@ public final class Double extends Number implements Comparable
     return toString (v, false);
   }
 
-  public static Double valueOf (String s) throws NullPointerException, 
-    NumberFormatException
+  public static Double valueOf (String s) throws NumberFormatException
   {
-    if (s == null)
-      throw new NullPointerException ();
-
     return new Double (parseDouble (s));
   }
 
@@ -146,6 +139,12 @@ public final class Double extends Number implements Comparable
 
   public static native long doubleToLongBits (double value);
 
+  public static long doubleToRawLongBits (double value)
+  {
+    // FIXME: Check that this is correct with respect to NaN values.
+    return doubleToLongBits (value);
+  }
+
   public static native double longBitsToDouble (long bits);
 
   public int compareTo (Double d)
index 4a1f7fe..f15b06d 100644 (file)
@@ -64,9 +64,6 @@ public final class Float extends Number implements Comparable
 
   public boolean equals (Object obj)
   {
-    if (obj == null)
-      return false;
-
     if (!(obj instanceof Float))
       return false;
 
@@ -115,12 +112,8 @@ public final class Float extends Number implements Comparable
     return Double.toString ((double) v, true);
   } 
 
-  public static Float valueOf (String s) throws NullPointerException, 
-    NumberFormatException
+  public static Float valueOf (String s) throws NumberFormatException
   {
-    if (s == null)
-      throw new NullPointerException ();
-
     return new Float (Double.valueOf (s).floatValue ());
   }
 
@@ -152,6 +145,13 @@ public final class Float extends Number implements Comparable
   }
 
   public static native int floatToIntBits (float value);
+  
+  public static int floatToRawIntBits (float value)
+  {
+    // FIXME: Is this supposed to be different? NaN values seem to be handled
+    // the same in the JDK.
+    return floatToIntBits (value);
+  }
 
   public static native float intBitsToFloat (int bits);
 
index 163c850..2cf7bb4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -86,11 +86,9 @@ public final class Integer extends Number implements Comparable
   }
 
   // Added in JDK 1.2
-  public int compareTo(Object o) throws ClassCastException
+  /** @throws ClassCastException */
+  public int compareTo(Object o)
   {
-    if (!(o instanceof Integer))
-      throw new ClassCastException();
-
     return this.compareTo((Integer) o);
   }
 
@@ -101,7 +99,7 @@ public final class Integer extends Number implements Comparable
     int radix = 10;
     final int len;
 
-    if (str == null || (len = str.length()) == 0)
+    if ((len = str.length()) == 0)
       throw new NumberFormatException();
 
     // Negative numbers are always radix 10.
@@ -140,8 +138,7 @@ public final class Integer extends Number implements Comparable
 
   public boolean equals(Object obj)
   {
-    return (obj != null && (obj instanceof Integer)
-            && ((Integer) obj).value == value);
+    return (obj instanceof Integer && ((Integer) obj).value == value);
   }
 
   public static Integer getInteger(String prop)
@@ -181,7 +178,7 @@ public final class Integer extends Number implements Comparable
   {
     final int len;
 
-    if (str == null || (len = str.length()) == 0 ||
+    if ((len = str.length()) == 0 ||
         radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
       throw new NumberFormatException();
 
index e6872db..cb2cec2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -86,11 +86,9 @@ public final class Long extends Number implements Comparable
   }
 
   // Added in JDK 1.2
-  public int compareTo(Object o) throws ClassCastException
+  /** @throws ClassCastException */
+  public int compareTo(Object o)
   {
-    if (!(o instanceof Long))
-      throw new ClassCastException();
-
     return this.compareTo((Long) o);
   }
 
@@ -102,7 +100,7 @@ public final class Long extends Number implements Comparable
     int radix = 10;
     final int len;
 
-    if (str == null || (len = str.length()) == 0)
+    if ((len = str.length()) == 0)
       throw new NumberFormatException();
 
     // Negative numbers are always radix 10.
@@ -141,8 +139,7 @@ public final class Long extends Number implements Comparable
 
   public boolean equals(Object obj)
   {
-    return (obj != null && (obj instanceof Long)
-            && ((Long) obj).value == value);
+    return (obj instanceof Long && ((Long) obj).value == value);
   }
 
   public static Long getLong(String prop)
@@ -183,8 +180,8 @@ public final class Long extends Number implements Comparable
   {
     final int len;
 
-    if (str == null || (len = str.length()) == 0 ||
-        radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
+    if ((len = str.length()) == 0 || radix < Character.MIN_RADIX 
+         || radix > Character.MAX_RADIX)
       throw new NumberFormatException();
 
     boolean isNeg = false;
index 6733607..66eb4fd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -115,18 +115,15 @@ public final class Short extends Number implements Comparable
   }
 
   // Added in JDK 1.2
-  public int compareTo(Object o) throws ClassCastException
+  /** @throws ClassCastException */
+  public int compareTo(Object o)
   {
-    if (o instanceof Short)
-      return this.value - ((Short) o).value;
-    else
-      throw new ClassCastException();
+    return this.value - ((Short) o).value;
   }
 
   public boolean equals(Object obj)
   {
-    return (obj != null && (obj instanceof Short)
-           && ((Short) obj).value == value);
+    return (obj instanceof Short) && ((Short) obj).value == value;
   }
 
   // Verified that hashCode is returns plain value (see Short_1 test).