提交 20e8a8fd 编写于 作者: D darcy

6628737: Specification of wrapper class valueOf static factories should require caching

Reviewed-by: mr
上级 f949d246
...@@ -90,8 +90,8 @@ public final class Byte extends Number implements Comparable<Byte> { ...@@ -90,8 +90,8 @@ public final class Byte extends Number implements Comparable<Byte> {
* If a new {@code Byte} instance is not required, this method * If a new {@code Byte} instance is not required, this method
* should generally be used in preference to the constructor * should generally be used in preference to the constructor
* {@link #Byte(byte)}, as this method is likely to yield * {@link #Byte(byte)}, as this method is likely to yield
* significantly better space and time performance by caching * significantly better space and time performance since
* frequently requested values. * all byte values are cached.
* *
* @param b a byte value. * @param b a byte value.
* @return a {@code Byte} instance representing {@code b}. * @return a {@code Byte} instance representing {@code b}.
......
...@@ -2571,6 +2571,10 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara ...@@ -2571,6 +2571,10 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
* significantly better space and time performance by caching * significantly better space and time performance by caching
* frequently requested values. * frequently requested values.
* *
* This method will always cache values in the range '&#92;u0000'
* to '&#92;u007f'", inclusive, and may cache other values outside
* of this range.
*
* @param c a char value. * @param c a char value.
* @return a <tt>Character</tt> instance representing <tt>c</tt>. * @return a <tt>Character</tt> instance representing <tt>c</tt>.
* @since 1.5 * @since 1.5
......
...@@ -638,6 +638,9 @@ public final class Integer extends Number implements Comparable<Integer> { ...@@ -638,6 +638,9 @@ public final class Integer extends Number implements Comparable<Integer> {
* to yield significantly better space and time performance by * to yield significantly better space and time performance by
* caching frequently requested values. * caching frequently requested values.
* *
* This method will always cache values in the range -128 to 127,
* inclusive, and may cache other values outside of this range.
*
* @param i an {@code int} value. * @param i an {@code int} value.
* @return an {@code Integer} instance representing {@code i}. * @return an {@code Integer} instance representing {@code i}.
* @since 1.5 * @since 1.5
......
...@@ -560,6 +560,11 @@ public final class Long extends Number implements Comparable<Long> { ...@@ -560,6 +560,11 @@ public final class Long extends Number implements Comparable<Long> {
* significantly better space and time performance by caching * significantly better space and time performance by caching
* frequently requested values. * frequently requested values.
* *
* Note that unlike the {@linkplain Integer#valueOf(int)
* corresponding method} in the {@code Integer} class, this method
* is <em>not</em> required to cache values within a particular
* range.
*
* @param l a long value. * @param l a long value.
* @return a {@code Long} instance representing {@code l}. * @return a {@code Long} instance representing {@code l}.
* @since 1.5 * @since 1.5
......
...@@ -219,6 +219,9 @@ public final class Short extends Number implements Comparable<Short> { ...@@ -219,6 +219,9 @@ public final class Short extends Number implements Comparable<Short> {
* significantly better space and time performance by caching * significantly better space and time performance by caching
* frequently requested values. * frequently requested values.
* *
* This method will always cache values in the range -128 to 127,
* inclusive, and may cache other values outside of this range.
*
* @param s a short value. * @param s a short value.
* @return a {@code Short} instance representing {@code s}. * @return a {@code Short} instance representing {@code s}.
* @since 1.5 * @since 1.5
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册