src/share/classes/java/lang/Long.java
Print this page
rev 4568 : 7088952: Add "BYTES" constant to primitive wrapper classes
7088913: Add compatible static hashCode(primitive) to primitive wrapper classes
Reviewed-by: smarks
*** 784,793 ****
--- 784,805 ----
public int hashCode() {
return (int)(value ^ (value >>> 32));
}
/**
+ * 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
* contains the same {@code long} value as this object.
*
*** 980,989 ****
--- 992,1009 ----
* @since 1.5
*/
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
* one-bits in its two's complement binary representation, that is, if it
* is equal to zero.