src/share/classes/java/lang/Byte.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

@@ -60,10 +60,22 @@
      * {@code byte}.
      */
     public static final Class<Byte>     TYPE = (Class<Byte>) 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.
      *
      * @param b the {@code byte} to be converted
      * @return the string representation of the specified {@code byte}

@@ -450,8 +462,16 @@
      *
      * @since 1.5
      */
     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;
 }