7088952: Add size in bytes constant "BYTES" to primitive type wrapper types
Summary: Adds a constant BYTES to each of the primitive wrapper classes (Byte, Character, Double, Float, Integer, Long, Short) with the calculation Primitive.SIZE / Byte.SIZE already made.
Reviewed-by: dholmes
--- a/jdk/src/share/classes/java/lang/Byte.java Wed Nov 14 07:08:50 2012 -0800
+++ b/jdk/src/share/classes/java/lang/Byte.java Tue Nov 13 20:02:39 2012 -0800
@@ -507,6 +507,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 = SIZE / Byte.SIZE;
+
/** use serialVersionUID from JDK 1.1. for interoperability */
private static final long serialVersionUID = -7183698231559129828L;
}
--- a/jdk/src/share/classes/java/lang/Character.java Wed Nov 14 07:08:50 2012 -0800
+++ b/jdk/src/share/classes/java/lang/Character.java Tue Nov 13 20:02:39 2012 -0800
@@ -7171,6 +7171,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 <tt>char</tt> value.
*
--- a/jdk/src/share/classes/java/lang/Double.java Wed Nov 14 07:08:50 2012 -0800
+++ b/jdk/src/share/classes/java/lang/Double.java Tue Nov 13 20:02:39 2012 -0800
@@ -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}.
*
--- a/jdk/src/share/classes/java/lang/Float.java Wed Nov 14 07:08:50 2012 -0800
+++ b/jdk/src/share/classes/java/lang/Float.java Tue Nov 13 20:02:39 2012 -0800
@@ -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}.
*
--- a/jdk/src/share/classes/java/lang/Integer.java Wed Nov 14 07:08:50 2012 -0800
+++ b/jdk/src/share/classes/java/lang/Integer.java Tue Nov 13 20:02:39 2012 -0800
@@ -1298,6 +1298,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
--- a/jdk/src/share/classes/java/lang/Long.java Wed Nov 14 07:08:50 2012 -0800
+++ b/jdk/src/share/classes/java/lang/Long.java Tue Nov 13 20:02:39 2012 -0800
@@ -1320,6 +1320,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
--- a/jdk/src/share/classes/java/lang/Short.java Wed Nov 14 07:08:50 2012 -0800
+++ b/jdk/src/share/classes/java/lang/Short.java Tue Nov 13 20:02:39 2012 -0800
@@ -471,6 +471,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.
*