diff --git a/src/share/classes/java/lang/Byte.java b/src/share/classes/java/lang/Byte.java index c4dd62ecf6d3884c069189ee9daa632d29385a15..43a558ade4383e64faf7dc73d5221d75203fd949 100644 --- a/src/share/classes/java/lang/Byte.java +++ b/src/share/classes/java/lang/Byte.java @@ -507,6 +507,14 @@ public final class Byte extends Number implements Comparable { */ 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; } diff --git a/src/share/classes/java/lang/Character.java b/src/share/classes/java/lang/Character.java index 03134d06dbda5229e9ac1f9063111dde9e2ae7e3..0f440067b450ec4992cd1f162d14f335fe3cb2a5 100644 --- a/src/share/classes/java/lang/Character.java +++ b/src/share/classes/java/lang/Character.java @@ -7170,6 +7170,14 @@ class Character implements java.io.Serializable, Comparable { */ 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. diff --git a/src/share/classes/java/lang/Double.java b/src/share/classes/java/lang/Double.java index 040cca7003355dd2bb8a117180a8131866d67d05..a20f79e6cb3e9d45c9e84181ad94b95fffed527b 100644 --- a/src/share/classes/java/lang/Double.java +++ b/src/share/classes/java/lang/Double.java @@ -122,6 +122,13 @@ public final class Double extends Number implements Comparable { */ 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}. diff --git a/src/share/classes/java/lang/Float.java b/src/share/classes/java/lang/Float.java index 1e8f6e354a9fb107d98c031e75a80d4e3b43e089..0c071e2b0f46a30ce73503b2e1462cf3610bdcfb 100644 --- a/src/share/classes/java/lang/Float.java +++ b/src/share/classes/java/lang/Float.java @@ -120,6 +120,13 @@ public final class Float extends Number implements Comparable { */ 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}. diff --git a/src/share/classes/java/lang/Integer.java b/src/share/classes/java/lang/Integer.java index 50627e9913309f12dfec97e5079634b045334348..3496d039c1c31bf93708a509bb7133bf6648abea 100644 --- a/src/share/classes/java/lang/Integer.java +++ b/src/share/classes/java/lang/Integer.java @@ -1297,6 +1297,14 @@ public final class Integer extends Number implements Comparable { */ 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 diff --git a/src/share/classes/java/lang/Long.java b/src/share/classes/java/lang/Long.java index 9197a6d1e2662b6dc7c1ba6077fabf517aa1b9b0..6509f88f177f950e28f705306221ae9b8ce15cfe 100644 --- a/src/share/classes/java/lang/Long.java +++ b/src/share/classes/java/lang/Long.java @@ -1319,6 +1319,14 @@ public final class Long extends Number implements Comparable { */ 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 diff --git a/src/share/classes/java/lang/Short.java b/src/share/classes/java/lang/Short.java index f117095abe21ff3fc0c2672cff390e715ce87d6d..6042b13f9051b196e488a0862ffcee88db6399f9 100644 --- a/src/share/classes/java/lang/Short.java +++ b/src/share/classes/java/lang/Short.java @@ -470,6 +470,14 @@ public final class Short extends Number implements Comparable { */ 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.