--- old/src/share/classes/java/lang/Boolean.java 2011-09-20 12:56:28.000000000 -0700 +++ new/src/share/classes/java/lang/Boolean.java 2011-09-20 12:56:28.000000000 -0700 @@ -200,6 +200,18 @@ } /** + * Returns a hash code for a {@code boolean} value; compatible with + * {@code Boolean.hashCode()}. + * + * @since 1.8 + * + * @return a hash code value for a {@code boolean} value. + */ + public static int hashCode(boolean value) { + return value ? 1231 : 1237; + } + + /** * Returns {@code true} if and only if the argument is not * {@code null} and is a {@code Boolean} object that * represents the same {@code boolean} value as this object. --- old/src/share/classes/java/lang/Byte.java 2011-09-20 12:56:29.000000000 -0700 +++ new/src/share/classes/java/lang/Byte.java 2011-09-20 12:56:29.000000000 -0700 @@ -62,6 +62,18 @@ public static final Class TYPE = (Class) Class.getPrimitiveClass("byte"); /** + * Returns a hash code for a {@code byte} value; compatible with + * {@code Byte.hashCode()}. + * + * @since 1.8 + * + * @return a hash code value for a {@code byte} value. + */ + public static int hashCode(byte value) { + return (int)value; + } + + /** * Returns a new {@code String} object representing the * specified {@code byte}. The radix is assumed to be 10. * @@ -452,6 +464,14 @@ */ public static final int SIZE = 8; + /** + * The number of bytes used to represent a {@code byte} value in two's + * complement binary form. + * + * @since 1.8 + */ + public static final int BYTES = Byte.SIZE / Byte.SIZE; + /** use serialVersionUID from JDK 1.1. for interoperability */ private static final long serialVersionUID = -7183698231559129828L; } --- old/src/share/classes/java/lang/Character.java 2011-09-20 12:56:30.000000000 -0700 +++ new/src/share/classes/java/lang/Character.java 2011-09-20 12:56:30.000000000 -0700 @@ -4409,6 +4409,18 @@ } /** + * Returns a hash code for a {@code char} value; compatible with + * {@code Character.hashCode()}. + * + * @since 1.8 + * + * @return a hash code value for a {@code char} value. + */ + public static int hashCode(char value) { + return (int)value; + } + + /** * Compares this object against the specified object. * The result is {@code true} if and only if the argument is not * {@code null} and is a {@code Character} object that @@ -6974,6 +6986,14 @@ public static final int SIZE = 16; /** + * The number of bytes used to represent a {@code char} value in unsigned + * binary form. + * + * @since 1.8 + */ + public static final int BYTES = SIZE / Byte.SIZE; + + /** * Returns the value obtained by reversing the order of the bytes in the * specified char value. * --- old/src/share/classes/java/lang/Double.java 2011-09-20 12:56:31.000000000 -0700 +++ new/src/share/classes/java/lang/Double.java 2011-09-20 12:56:31.000000000 -0700 @@ -123,6 +123,13 @@ public static final int SIZE = 64; /** + * The number of bytes used to represent a {@code double} value. + * + * @since 1.8 + */ + public static final int BYTES = SIZE / Byte.SIZE; + + /** * The {@code Class} instance representing the primitive type * {@code double}. * @@ -730,6 +737,19 @@ long bits = doubleToLongBits(value); return (int)(bits ^ (bits >>> 32)); } + + /** + * Returns a hash code for a {@code double} value; compatible with + * {@code Double.hashCode()}. + * + * @since 1.8 + * + * @return a hash code value for a {@code double} value. + */ + public static int hashCode(double value) { + long bits = doubleToLongBits(value); + return (int)(bits ^ (bits >>> 32)); + } /** * Compares this object against the specified object. The result --- old/src/share/classes/java/lang/Float.java 2011-09-20 12:56:32.000000000 -0700 +++ new/src/share/classes/java/lang/Float.java 2011-09-20 12:56:32.000000000 -0700 @@ -121,6 +121,13 @@ public static final int SIZE = 32; /** + * The number of bytes used to represent a {@code float} value. + * + * @since 1.8 + */ + public static final int BYTES = SIZE / Byte.SIZE; + + /** * The {@code Class} instance representing the primitive type * {@code float}. * @@ -637,6 +644,18 @@ return floatToIntBits(value); } + /** + * Returns a hash code for a {@code float} value; compatible with + * {@code Float.hashCode()}. + * + * @since 1.8 + * + * @return a hash code value for a {@code float} value. + */ + public static int hashCode(float value) { + return floatToIntBits(value); + } + /** * Compares this object against the specified object. The result --- old/src/share/classes/java/lang/Integer.java 2011-09-20 12:56:33.000000000 -0700 +++ new/src/share/classes/java/lang/Integer.java 2011-09-20 12:56:33.000000000 -0700 @@ -756,6 +756,18 @@ } /** + * Returns a hash code for a {@code int} value; compatible with + * {@code Integer.hashCode()}. + * + * @since 1.8 + * + * @return a hash code value for a {@code int} value. + */ + public static int hashCode(int value) { + return value; + } + + /** * Compares this object to the specified object. The result is * {@code true} if and only if the argument is not * {@code null} and is an {@code Integer} object that @@ -1035,6 +1047,14 @@ public static final int SIZE = 32; /** + * The number of bytes used to represent a {@code int} value in two's + * complement binary form. + * + * @since 1.8 + */ + public static final int BYTES = SIZE / Byte.SIZE; + + /** * Returns an {@code int} value with at most a single one-bit, in the * position of the highest-order ("leftmost") one-bit in the specified * {@code int} value. Returns zero if the specified value has no --- old/src/share/classes/java/lang/Long.java 2011-09-20 12:56:34.000000000 -0700 +++ new/src/share/classes/java/lang/Long.java 2011-09-20 12:56:34.000000000 -0700 @@ -786,6 +786,18 @@ } /** + * Returns a hash code for a {@code long} value; compatible with + * {@code Long.hashCode()}. + * + * @since 1.8 + * + * @return a hash code value for a {@code long} value. + */ + public static int hashCode(long value) { + return (int)(value ^ (value >>> 32)); + } + + /** * Compares this object to the specified object. The result is * {@code true} if and only if the argument is not * {@code null} and is a {@code Long} object that @@ -982,6 +994,14 @@ public static final int SIZE = 64; /** + * The number of bytes used to represent a {@code long} value in two's + * complement binary form. + * + * @since 1.8 + */ + public static final int BYTES = SIZE / Byte.SIZE; + + /** * Returns a {@code long} value with at most a single one-bit, in the * position of the highest-order ("leftmost") one-bit in the specified * {@code long} value. Returns zero if the specified value has no --- old/src/share/classes/java/lang/Short.java 2011-09-20 12:56:35.000000000 -0700 +++ new/src/share/classes/java/lang/Short.java 2011-09-20 12:56:35.000000000 -0700 @@ -398,6 +398,18 @@ } /** + * Returns a hash code for a {@code short} value; compatible with + * {@code Short.hashCode()}. + * + * @since 1.8 + * + * @return a hash code value for a {@code short} value. + */ + public static int hashCode(short value) { + return (int)value; + } + + /** * Compares this object to the specified object. The result is * {@code true} if and only if the argument is not * {@code null} and is a {@code Short} object that @@ -457,6 +469,14 @@ public static final int SIZE = 16; /** + * The number of bytes used to represent a {@code short} value in two's + * complement binary form. + * + * @since 1.8 + */ + public static final int BYTES = SIZE / Byte.SIZE; + + /** * Returns the value obtained by reversing the order of the bytes in the * two's complement representation of the specified {@code short} value. *