Imported GNU Classpath 0.19 + gcj-import-20051115.

* sources.am: Regenerated.
       * Makefile.in: Likewise.
       * scripts/makemake.tcl: Use glob -nocomplain.

From-SVN: r107049
This commit is contained in:
Mark Wielaard 2005-11-15 23:20:01 +00:00
parent 02e549bfaa
commit 8f523f3a10
1241 changed files with 97711 additions and 25284 deletions

View file

@ -76,6 +76,19 @@ public final class Short extends Number implements Comparable
*/
public static final Class TYPE = VMClassLoader.getPrimitiveClass('S');
/**
* The number of bits needed to represent a <code>short</code>.
* @since 1.5
*/
public static final int SIZE = 16;
// This caches some Short values, and is used by boxing conversions
// via valueOf(). We must cache at least -128..127; these constants
// control how much we actually cache.
private static final int MIN_CACHE = -128;
private static final int MAX_CACHE = 127;
private static Short[] shortCache = new Short[MAX_CACHE - MIN_CACHE + 1];
/**
* The immutable value of this Short.
*
@ -188,6 +201,28 @@ public final class Short extends Number implements Comparable
return new Short(parseShort(s, 10));
}
/**
* Returns a <code>Short</code> object wrapping the value.
* In contrast to the <code>Short</code> constructor, this method
* will cache some values. It is used by boxing conversion.
*
* @param val the value to wrap
* @return the <code>Short</code>
*
* @since 1.5
*/
public static Short valueOf(short val)
{
if (val < MIN_CACHE || val > MAX_CACHE)
return new Short(val);
synchronized (shortCache)
{
if (shortCache[val - MIN_CACHE] == null)
shortCache[val - MIN_CACHE] = new Short(val);
return shortCache[val - MIN_CACHE];
}
}
/**
* Convert the specified <code>String</code> into a <code>Short</code>.
* The <code>String</code> may represent decimal, hexadecimal, or
@ -350,4 +385,13 @@ public final class Short extends Number implements Comparable
{
return compareTo((Short)o);
}
/**
* Reverse the bytes in val.
* @since 1.5
*/
public static short reverseBytes(short val)
{
return (short) (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
}
}