summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/java/lang/Byte.java
diff options
context:
space:
mode:
authormark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-15 23:20:01 +0000
committermark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-15 23:20:01 +0000
commit3b3101d8b5ae4f08a16c0b7111da6cad41bbd282 (patch)
treea5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/java/lang/Byte.java
parent7e55c49d7d91ef9f09e93c1100119b1ab3652446 (diff)
downloadppe42-gcc-3b3101d8b5ae4f08a16c0b7111da6cad41bbd282.tar.gz
ppe42-gcc-3b3101d8b5ae4f08a16c0b7111da6cad41bbd282.zip
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated. * Makefile.in: Likewise. * scripts/makemake.tcl: Use glob -nocomplain. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107049 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/java/lang/Byte.java')
-rw-r--r--libjava/classpath/java/lang/Byte.java32
1 files changed, 31 insertions, 1 deletions
diff --git a/libjava/classpath/java/lang/Byte.java b/libjava/classpath/java/lang/Byte.java
index 338e2167aa1..2560bfcffc3 100644
--- a/libjava/classpath/java/lang/Byte.java
+++ b/libjava/classpath/java/lang/Byte.java
@@ -50,7 +50,7 @@ package java.lang;
* @author Per Bothner
* @author Eric Blake (ebb9@email.byu.edu)
* @since 1.1
- * @status updated to 1.4
+ * @status updated to 1.5
*/
public final class Byte extends Number implements Comparable
{
@@ -78,6 +78,16 @@ public final class Byte extends Number implements Comparable
public static final Class TYPE = VMClassLoader.getPrimitiveClass('B');
/**
+ * The number of bits needed to represent a <code>byte</code>.
+ * @since 1.5
+ */
+ public static final int SIZE = 8;
+
+ // This caches Byte values, and is used by boxing conversions via
+ // valueOf(). We're required to cache all possible values here.
+ private static Byte[] byteCache = new Byte[MAX_VALUE - MIN_VALUE + 1];
+
+ /**
* The immutable value of this Byte.
*
* @serial the wrapped byte
@@ -192,6 +202,26 @@ public final class Byte extends Number implements Comparable
}
/**
+ * Returns a <code>Byte</code> object wrapping the value.
+ * In contrast to the <code>Byte</code> constructor, this method
+ * will cache some values. It is used by boxing conversion.
+ *
+ * @param val the value to wrap
+ * @return the <code>Byte</code>
+ *
+ * @since 1.5
+ */
+ public static Byte valueOf(byte val)
+ {
+ synchronized (byteCache)
+ {
+ if (byteCache[val - MIN_VALUE] == null)
+ byteCache[val - MIN_VALUE] = new Byte(val);
+ return byteCache[val - MIN_VALUE];
+ }
+ }
+
+ /**
* Convert the specified <code>String</code> into a <code>Byte</code>.
* The <code>String</code> may represent decimal, hexadecimal, or
* octal numbers.
OpenPOWER on IntegriCloud