Byte.java: Remove redundant instanceof and null checks.

* 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.

From-SVN: r39556
This commit is contained in:
Bryce McKinlay 2001-02-09 02:56:38 +00:00 committed by Bryce McKinlay
parent 1c8b24ad46
commit c97036e4c3
7 changed files with 50 additions and 51 deletions

View 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.

View 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).

View 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)

View 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);

View 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();

View 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;

View 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).