8145468: update java.lang APIs with new deprecations
Reviewed-by: alanb, psandoz, lancea, forax, scolebourne, chegar, martin
--- a/jdk/src/java.base/share/classes/java/lang/Boolean.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/Boolean.java Mon Apr 18 14:10:14 2016 -0700
@@ -79,13 +79,16 @@
* Allocates a {@code Boolean} object representing the
* {@code value} argument.
*
- * <p><b>Note: It is rarely appropriate to use this constructor.
- * Unless a <i>new</i> instance is required, the static factory
- * {@link #valueOf(boolean)} is generally a better choice. It is
- * likely to yield significantly better space and time performance.</b>
+ * @param value the value of the {@code Boolean}.
*
- * @param value the value of the {@code Boolean}.
+ * @deprecated
+ * It is rarely appropriate to use this constructor. The static factory
+ * {@link #valueOf(boolean)} is generally a better choice, as it is
+ * likely to yield significantly better space and time performance.
+ * Also consider using the final fields {@link #TRUE} and {@link #FALSE}
+ * if possible.
*/
+ @Deprecated(since="9")
public Boolean(boolean value) {
this.value = value;
}
@@ -94,15 +97,18 @@
* Allocates a {@code Boolean} object representing the value
* {@code true} if the string argument is not {@code null}
* and is equal, ignoring case, to the string {@code "true"}.
- * Otherwise, allocate a {@code Boolean} object representing the
- * value {@code false}. Examples:<p>
- * {@code new Boolean("True")} produces a {@code Boolean} object
- * that represents {@code true}.<br>
- * {@code new Boolean("yes")} produces a {@code Boolean} object
- * that represents {@code false}.
+ * Otherwise, allocates a {@code Boolean} object representing the
+ * value {@code false}.
*
* @param s the string to be converted to a {@code Boolean}.
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor.
+ * Use {@link #parseBoolean(String)} to convert a string to a
+ * {@code boolean} primitive, or use {@link #valueOf(String)}
+ * to convert a string to a {@code Boolean} object.
*/
+ @Deprecated(since="9")
public Boolean(String s) {
this(parseBoolean(s));
}
--- a/jdk/src/java.base/share/classes/java/lang/Byte.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/Byte.java Mon Apr 18 14:10:14 2016 -0700
@@ -297,7 +297,13 @@
*
* @param value the value to be represented by the
* {@code Byte}.
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor. The static factory
+ * {@link #valueOf(byte)} is generally a better choice, as it is
+ * likely to yield significantly better space and time performance.
*/
+ @Deprecated(since="9")
public Byte(byte value) {
this.value = value;
}
@@ -311,10 +317,16 @@
*
* @param s the {@code String} to be converted to a
* {@code Byte}
- * @throws NumberFormatException If the {@code String}
+ * @throws NumberFormatException if the {@code String}
* does not contain a parsable {@code byte}.
- * @see java.lang.Byte#parseByte(java.lang.String, int)
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor.
+ * Use {@link #parseByte(String)} to convert a string to a
+ * {@code byte} primitive, or use {@link #valueOf(String)}
+ * to convert a string to a {@code Byte} object.
*/
+ @Deprecated(since="9")
public Byte(String s) throws NumberFormatException {
this.value = parseByte(s, 10);
}
--- a/jdk/src/java.base/share/classes/java/lang/Character.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/Character.java Mon Apr 18 14:10:14 2016 -0700
@@ -1256,14 +1256,14 @@
new UnicodeBlock("SPECIALS");
/**
- * @deprecated As of J2SE 5, use {@link #HIGH_SURROGATES},
- * {@link #HIGH_PRIVATE_USE_SURROGATES}, and
- * {@link #LOW_SURROGATES}. These new constants match
- * the block definitions of the Unicode Standard.
- * The {@link #of(char)} and {@link #of(int)} methods
- * return the new constants, not SURROGATES_AREA.
- */
- @Deprecated
+ * @deprecated
+ * Instead of {@code SURROGATES_AREA}, use {@link #HIGH_SURROGATES},
+ * {@link #HIGH_PRIVATE_USE_SURROGATES}, and {@link #LOW_SURROGATES}.
+ * These constants match the block definitions of the Unicode Standard.
+ * The {@link #of(char)} and {@link #of(int)} methods return the
+ * standard constants.
+ */
+ @Deprecated(since="1.5")
public static final UnicodeBlock SURROGATES_AREA =
new UnicodeBlock("SURROGATES_AREA");
@@ -7451,7 +7451,13 @@
*
* @param value the value to be represented by the
* {@code Character} object.
- */
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor. The static factory
+ * {@link #valueOf(char)} is generally a better choice, as it is
+ * likely to yield significantly better space and time performance.
+ */
+ @Deprecated(since="9")
public Character(char value) {
this.value = value;
}
@@ -8799,7 +8805,7 @@
* @since 1.0.2
* @deprecated Replaced by isJavaIdentifierStart(char).
*/
- @Deprecated
+ @Deprecated(since="1.1")
public static boolean isJavaLetter(char ch) {
return isJavaIdentifierStart(ch);
}
@@ -8835,7 +8841,7 @@
* @since 1.0.2
* @deprecated Replaced by isJavaIdentifierPart(char).
*/
- @Deprecated
+ @Deprecated(since="1.1")
public static boolean isJavaLetterOrDigit(char ch) {
return isJavaIdentifierPart(ch);
}
@@ -9580,7 +9586,7 @@
* @see Character#isWhitespace(char)
* @deprecated Replaced by isWhitespace(char).
*/
- @Deprecated
+ @Deprecated(since="1.1")
public static boolean isSpace(char ch) {
return (ch <= 0x0020) &&
(((((1L << 0x0009) |
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java Mon Apr 18 14:10:14 2016 -0700
@@ -727,7 +727,7 @@
* @deprecated Replaced by {@link #defineClass(String, byte[], int, int)
* defineClass(String, byte[], int, int)}
*/
- @Deprecated
+ @Deprecated(since="1.1")
protected final Class<?> defineClass(byte[] b, int off, int len)
throws ClassFormatError
{
@@ -2012,7 +2012,7 @@
*
* @since 1.2
*/
- @Deprecated
+ @Deprecated(since="9")
protected Package getPackage(String name) {
Package pkg = getDefinedPackage(name);
if (pkg == null) {
--- a/jdk/src/java.base/share/classes/java/lang/Double.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/Double.java Mon Apr 18 14:10:14 2016 -0700
@@ -589,7 +589,13 @@
* represents the primitive {@code double} argument.
*
* @param value the value to be represented by the {@code Double}.
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor. The static factory
+ * {@link #valueOf(double)} is generally a better choice, as it is
+ * likely to yield significantly better space and time performance.
*/
+ @Deprecated(since="9")
public Double(double value) {
this.value = value;
}
@@ -601,10 +607,16 @@
* {@code double} value as if by the {@code valueOf} method.
*
* @param s a string to be converted to a {@code Double}.
- * @throws NumberFormatException if the string does not contain a
+ * @throws NumberFormatException if the string does not contain a
* parsable number.
- * @see java.lang.Double#valueOf(java.lang.String)
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor.
+ * Use {@link #parseDouble(String)} to convert a string to a
+ * {@code double} primitive, or use {@link #valueOf(String)}
+ * to convert a string to a {@code Double} object.
*/
+ @Deprecated(since="9")
public Double(String s) throws NumberFormatException {
value = parseDouble(s);
}
--- a/jdk/src/java.base/share/classes/java/lang/Float.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/Float.java Mon Apr 18 14:10:14 2016 -0700
@@ -502,7 +502,13 @@
* represents the primitive {@code float} argument.
*
* @param value the value to be represented by the {@code Float}.
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor. The static factory
+ * {@link #valueOf(float)} is generally a better choice, as it is
+ * likely to yield significantly better space and time performance.
*/
+ @Deprecated(since="9")
public Float(float value) {
this.value = value;
}
@@ -512,7 +518,13 @@
* represents the argument converted to type {@code float}.
*
* @param value the value to be represented by the {@code Float}.
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor. Instead, use the
+ * static factory method {@link #valueOf(float)} method as follows:
+ * {@code Float.valueOf((float)value)}.
*/
+ @Deprecated(since="9")
public Float(double value) {
this.value = (float)value;
}
@@ -523,11 +535,17 @@
* represented by the string. The string is converted to a
* {@code float} value as if by the {@code valueOf} method.
*
- * @param s a string to be converted to a {@code Float}.
- * @throws NumberFormatException if the string does not contain a
- * parsable number.
- * @see java.lang.Float#valueOf(java.lang.String)
+ * @param s a string to be converted to a {@code Float}.
+ * @throws NumberFormatException if the string does not contain a
+ * parsable number.
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor.
+ * Use {@link #parseFloat(String)} to convert a string to a
+ * {@code float} primitive, or use {@link #valueOf(String)}
+ * to convert a string to a {@code Float} object.
*/
+ @Deprecated(since="9")
public Float(String s) throws NumberFormatException {
value = parseFloat(s);
}
--- a/jdk/src/java.base/share/classes/java/lang/Integer.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/Integer.java Mon Apr 18 14:10:14 2016 -0700
@@ -1106,7 +1106,13 @@
*
* @param value the value to be represented by the
* {@code Integer} object.
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor. The static factory
+ * {@link #valueOf(int)} is generally a better choice, as it is
+ * likely to yield significantly better space and time performance.
*/
+ @Deprecated(since="9")
public Integer(int value) {
this.value = value;
}
@@ -1118,12 +1124,17 @@
* {@code int} value in exactly the manner used by the
* {@code parseInt} method for radix 10.
*
- * @param s the {@code String} to be converted to an
- * {@code Integer}.
- * @exception NumberFormatException if the {@code String} does not
- * contain a parsable integer.
- * @see java.lang.Integer#parseInt(java.lang.String, int)
+ * @param s the {@code String} to be converted to an {@code Integer}.
+ * @throws NumberFormatException if the {@code String} does not
+ * contain a parsable integer.
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor.
+ * Use {@link #parseInt(String)} to convert a string to a
+ * {@code int} primitive, or use {@link #valueOf(String)}
+ * to convert a string to an {@code Integer} object.
*/
+ @Deprecated(since="9")
public Integer(String s) throws NumberFormatException {
this.value = parseInt(s, 10);
}
--- a/jdk/src/java.base/share/classes/java/lang/Long.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/Long.java Mon Apr 18 14:10:14 2016 -0700
@@ -1340,7 +1340,13 @@
*
* @param value the value to be represented by the
* {@code Long} object.
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor. The static factory
+ * {@link #valueOf(long)} is generally a better choice, as it is
+ * likely to yield significantly better space and time performance.
*/
+ @Deprecated(since="9")
public Long(long value) {
this.value = value;
}
@@ -1356,8 +1362,14 @@
* {@code Long}.
* @throws NumberFormatException if the {@code String} does not
* contain a parsable {@code long}.
- * @see java.lang.Long#parseLong(java.lang.String, int)
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor.
+ * Use {@link #parseLong(String)} to convert a string to a
+ * {@code long} primitive, or use {@link #valueOf(String)}
+ * to convert a string to a {@code Long} object.
*/
+ @Deprecated(since="9")
public Long(String s) throws NumberFormatException {
this.value = parseLong(s, 10);
}
--- a/jdk/src/java.base/share/classes/java/lang/Package.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/Package.java Mon Apr 18 14:10:14 2016 -0700
@@ -333,7 +333,7 @@
* @see ClassLoader#getDefinedPackage
*/
@CallerSensitive
- @Deprecated
+ @Deprecated(since="9")
@SuppressWarnings("deprecation")
public static Package getPackage(String name) {
ClassLoader l = ClassLoader.getClassLoader(Reflection.getCallerClass());
--- a/jdk/src/java.base/share/classes/java/lang/Runtime.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java Mon Apr 18 14:10:14 2016 -0700
@@ -289,6 +289,7 @@
* finalizers being called on live objects while other threads are
* concurrently manipulating those objects, resulting in erratic
* behavior or deadlock.
+ * This method is subject to removal in a future version of Java SE.
*
* @throws SecurityException
* if a security manager exists and its {@code checkExit}
@@ -299,7 +300,7 @@
* @see java.lang.SecurityManager#checkExit(int)
* @since 1.1
*/
- @Deprecated
+ @Deprecated(since="1.2", forRemoval=true)
public static void runFinalizersOnExit(boolean value) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
@@ -894,8 +895,9 @@
* stream in the local encoding into a character stream in Unicode is via
* the {@code InputStreamReader} and {@code BufferedReader}
* classes.
+ * This method is subject to removal in a future version of Java SE.
*/
- @Deprecated
+ @Deprecated(since="1.1", forRemoval=true)
public InputStream getLocalizedInputStream(InputStream in) {
return in;
}
@@ -915,6 +917,7 @@
* Unicode character stream into a byte stream in the local encoding is via
* the {@code OutputStreamWriter}, {@code BufferedWriter}, and
* {@code PrintWriter} classes.
+ * This method is subject to removal in a future version of Java SE.
*
* @param out OutputStream to localize
* @return a localized output stream
@@ -923,7 +926,7 @@
* @see java.io.OutputStreamWriter#OutputStreamWriter(java.io.OutputStream)
* @see java.io.PrintWriter#PrintWriter(java.io.OutputStream)
*/
- @Deprecated
+ @Deprecated(since="1.1", forRemoval=true)
public OutputStream getLocalizedOutputStream(OutputStream out) {
return out;
}
--- a/jdk/src/java.base/share/classes/java/lang/SecurityManager.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/SecurityManager.java Mon Apr 18 14:10:14 2016 -0700
@@ -229,7 +229,7 @@
* It is recommended that the <code>checkPermission</code>
* call be used instead.
*/
- @Deprecated
+ @Deprecated(since="1.2")
protected boolean inCheck;
/*
@@ -262,7 +262,7 @@
* It is recommended that the <code>checkPermission</code>
* call be used instead.
*/
- @Deprecated
+ @Deprecated(since="1.2")
public boolean getInCheck() {
return inCheck;
}
@@ -345,7 +345,7 @@
* @see java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
* @see #checkPermission(java.security.Permission) checkPermission
*/
- @Deprecated
+ @Deprecated(since="1.2")
protected ClassLoader currentClassLoader() {
ClassLoader cl = currentClassLoader0();
if ((cl != null) && hasAllPermission())
@@ -391,7 +391,7 @@
* @see java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
* @see #checkPermission(java.security.Permission) checkPermission
*/
- @Deprecated
+ @Deprecated(since="1.2")
protected Class<?> currentLoadedClass() {
Class<?> c = currentLoadedClass0();
if ((c != null) && hasAllPermission())
@@ -411,7 +411,7 @@
* call be used instead.
*
*/
- @Deprecated
+ @Deprecated(since="1.2")
protected native int classDepth(String name);
/**
@@ -449,7 +449,7 @@
* @see java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
* @see #checkPermission(java.security.Permission) checkPermission
*/
- @Deprecated
+ @Deprecated(since="1.2")
protected int classLoaderDepth() {
int depth = classLoaderDepth0();
if (depth != -1) {
@@ -474,7 +474,7 @@
* It is recommended that the <code>checkPermission</code>
* call be used instead.
*/
- @Deprecated
+ @Deprecated(since="1.2")
protected boolean inClass(String name) {
return classDepth(name) >= 0;
}
@@ -491,7 +491,7 @@
* call be used instead.
* @see #currentClassLoader() currentClassLoader
*/
- @Deprecated
+ @Deprecated(since="1.2")
protected boolean inClassLoader() {
return currentClassLoader() != null;
}
@@ -1217,7 +1217,7 @@
* @deprecated Use #checkPermission(java.security.Permission) instead
* @see #checkPermission(java.security.Permission) checkPermission
*/
- @Deprecated
+ @Deprecated(since="1.4")
public void checkMulticast(InetAddress maddr, byte ttl) {
String host = maddr.getHostAddress();
if (!host.startsWith("[") && host.indexOf(':') != -1) {
@@ -1297,9 +1297,10 @@
* was trusted to bring up a top-level window. The method has been
* obsoleted and code should instead use {@link #checkPermission}
* to check {@code AWTPermission("showWindowWithoutWarningBanner")}.
+ * This method is subject to removal in a future version of Java SE.
* @see #checkPermission(java.security.Permission) checkPermission
*/
- @Deprecated
+ @Deprecated(since="1.8", forRemoval=true)
public boolean checkTopLevelWindow(Object window) {
if (window == null) {
throw new NullPointerException("window can't be null");
@@ -1340,9 +1341,10 @@
* thread could access the system clipboard. The method has been
* obsoleted and code should instead use {@link #checkPermission}
* to check {@code AWTPermission("accessClipboard")}.
+ * This method is subject to removal in a future version of Java SE.
* @see #checkPermission(java.security.Permission) checkPermission
*/
- @Deprecated
+ @Deprecated(since="1.8", forRemoval=true)
public void checkSystemClipboardAccess() {
checkPermission(SecurityConstants.ALL_PERMISSION);
}
@@ -1358,9 +1360,10 @@
* thread could access the AWT event queue. The method has been
* obsoleted and code should instead use {@link #checkPermission}
* to check {@code AWTPermission("accessEventQueue")}.
+ * This method is subject to removal in a future version of Java SE.
* @see #checkPermission(java.security.Permission) checkPermission
*/
- @Deprecated
+ @Deprecated(since="1.8", forRemoval=true)
public void checkAwtEventQueueAccess() {
checkPermission(SecurityConstants.ALL_PERMISSION);
}
@@ -1626,12 +1629,13 @@
* Users of this method should instead invoke {@link #checkPermission}
* directly. This method will be changed in a future release
* to check the permission {@code java.security.AllPermission}.
+ * This method is subject to removal in a future version of Java SE.
*
* @see java.lang.reflect.Member
* @since 1.1
* @see #checkPermission(java.security.Permission) checkPermission
*/
- @Deprecated
+ @Deprecated(since="1.8", forRemoval=true)
@CallerSensitive
public void checkMemberAccess(Class<?> clazz, int which) {
if (clazz == null) {
--- a/jdk/src/java.base/share/classes/java/lang/Short.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/Short.java Mon Apr 18 14:10:14 2016 -0700
@@ -302,7 +302,13 @@
*
* @param value the value to be represented by the
* {@code Short}.
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor. The static factory
+ * {@link #valueOf(short)} is generally a better choice, as it is
+ * likely to yield significantly better space and time performance.
*/
+ @Deprecated(since="9")
public Short(short value) {
this.value = value;
}
@@ -318,8 +324,14 @@
* {@code Short}
* @throws NumberFormatException If the {@code String}
* does not contain a parsable {@code short}.
- * @see java.lang.Short#parseShort(java.lang.String, int)
+ *
+ * @deprecated
+ * It is rarely appropriate to use this constructor.
+ * Use {@link #parseShort(String)} to convert a string to a
+ * {@code short} primitive, or use {@link #valueOf(String)}
+ * to convert a string to a {@code Short} object.
*/
+ @Deprecated(since="9")
public Short(String s) throws NumberFormatException {
this.value = parseShort(s, 10);
}
--- a/jdk/src/java.base/share/classes/java/lang/String.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/String.java Mon Apr 18 14:10:14 2016 -0700
@@ -363,7 +363,7 @@
* @see #String(byte[], java.nio.charset.Charset)
* @see #String(byte[])
*/
- @Deprecated
+ @Deprecated(since="1.1")
public String(byte ascii[], int hibyte, int offset, int count) {
checkBoundsOffCount(offset, count, ascii.length);
if (count == 0) {
@@ -415,7 +415,7 @@
* @see #String(byte[], java.nio.charset.Charset)
* @see #String(byte[])
*/
- @Deprecated
+ @Deprecated(since="1.1")
public String(byte ascii[], int hibyte) {
this(ascii, hibyte, 0, ascii.length);
}
@@ -911,7 +911,7 @@
* dst.length}
* </ul>
*/
- @Deprecated
+ @Deprecated(since="1.1")
public void getBytes(int srcBegin, int srcEnd, byte dst[], int dstBegin) {
checkBoundsBeginEnd(srcBegin, srcEnd, length());
Objects.requireNonNull(dst);
--- a/jdk/src/java.base/share/classes/java/lang/System.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/System.java Mon Apr 18 14:10:14 2016 -0700
@@ -1715,6 +1715,7 @@
* finalizers being called on live objects while other threads are
* concurrently manipulating those objects, resulting in erratic
* behavior or deadlock.
+ * This method is subject to removal in a future version of Java SE.
* @param value indicating enabling or disabling of finalization
* @throws SecurityException
* if a security manager exists and its <code>checkExit</code>
@@ -1725,7 +1726,7 @@
* @see java.lang.SecurityManager#checkExit(int)
* @since 1.1
*/
- @Deprecated
+ @Deprecated(since="1.2", forRemoval=true)
public static void runFinalizersOnExit(boolean value) {
Runtime.runFinalizersOnExit(value);
}
--- a/jdk/src/java.base/share/classes/java/lang/Thread.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/Thread.java Mon Apr 18 14:10:14 2016 -0700
@@ -890,7 +890,7 @@
* <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
*/
- @Deprecated
+ @Deprecated(since="1.2")
public final void stop() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
@@ -922,8 +922,9 @@
* For more information, see
* <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
+ * This method is subject to removal in a future version of Java SE.
*/
- @Deprecated
+ @Deprecated(since="1.2", forRemoval=true)
public final synchronized void stop(Throwable obj) {
throw new UnsupportedOperationException();
}
@@ -1043,9 +1044,10 @@
* "frozen" processes. For more information, see
* <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">
* Why are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
+ * This method is subject to removal in a future version of Java SE.
* @throws NoSuchMethodError always
*/
- @Deprecated
+ @Deprecated(since="1.5", forRemoval=true)
public void destroy() {
throw new NoSuchMethodError();
}
@@ -1083,7 +1085,7 @@
* <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
*/
- @Deprecated
+ @Deprecated(since="1.2")
public final void suspend() {
checkAccess();
suspend0();
@@ -1109,7 +1111,7 @@
* <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">Why
* are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
*/
- @Deprecated
+ @Deprecated(since="1.2")
public final void resume() {
checkAccess();
resume0();
@@ -1270,8 +1272,10 @@
* @deprecated The definition of this call depends on {@link #suspend},
* which is deprecated. Further, the results of this call
* were never well-defined.
+ * This method is subject to removal in a future version of Java SE.
+ * @see StackWalker
*/
- @Deprecated
+ @Deprecated(since="1.2", forRemoval=true)
public native int countStackFrames();
/**
--- a/jdk/src/java.base/share/classes/java/lang/ThreadGroup.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/ThreadGroup.java Mon Apr 18 14:10:14 2016 -0700
@@ -607,7 +607,7 @@
* @deprecated This method is inherently unsafe. See
* {@link Thread#stop} for details.
*/
- @Deprecated
+ @Deprecated(since="1.2")
public final void stop() {
if (stopOrSuspend(false))
Thread.currentThread().stop();
@@ -669,7 +669,7 @@
* @deprecated This method is inherently deadlock-prone. See
* {@link Thread#suspend} for details.
*/
- @Deprecated
+ @Deprecated(since="1.2")
@SuppressWarnings("deprecation")
public final void suspend() {
if (stopOrSuspend(true))
@@ -732,7 +732,7 @@
* both of which have been deprecated, as they are inherently
* deadlock-prone. See {@link Thread#suspend} for details.
*/
- @Deprecated
+ @Deprecated(since="1.2")
@SuppressWarnings("deprecation")
public final void resume() {
int ngroupsSnapshot;
@@ -1073,7 +1073,7 @@
* which is deprecated. Further, the behavior of this call
* was never specified.
*/
- @Deprecated
+ @Deprecated(since="1.2")
public boolean allowThreadSuspension(boolean b) {
this.vmAllowSuspension = b;
if (!b) {
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java Mon Apr 18 14:10:14 2016 -0700
@@ -733,6 +733,7 @@
}
@Override
+ @SuppressWarnings("deprecation")
public int hashCode() {
// Avoid autoboxing getReferenceKind(), since this is used early and will force
// early initialization of Byte$ByteCache
--- a/jdk/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java Mon Apr 18 14:10:14 2016 -0700
@@ -1750,7 +1750,7 @@
* Get or assign the index for a CONSTANT_Float entry.
*/
public short getFloat(float f) {
- return getValue(new Float(f));
+ return getValue(f);
}
/**
--- a/jdk/src/java.base/share/classes/java/text/ChoiceFormat.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/text/ChoiceFormat.java Mon Apr 18 14:10:14 2016 -0700
@@ -437,7 +437,7 @@
if (status.index == start) {
status.errorIndex = furthest;
}
- return new Double(bestNumber);
+ return Double.valueOf(bestNumber);
}
/**
--- a/jdk/src/java.base/share/classes/java/text/DecimalFormat.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/text/DecimalFormat.java Mon Apr 18 14:10:14 2016 -0700
@@ -1996,7 +1996,7 @@
// special case NaN
if (text.regionMatches(pos.index, symbols.getNaN(), 0, symbols.getNaN().length())) {
pos.index = pos.index + symbols.getNaN().length();
- return new Double(Double.NaN);
+ return Double.valueOf(Double.NaN);
}
boolean[] status = new boolean[STATUS_LENGTH];
@@ -2007,19 +2007,19 @@
// special case INFINITY
if (status[STATUS_INFINITE]) {
if (status[STATUS_POSITIVE] == (multiplier >= 0)) {
- return new Double(Double.POSITIVE_INFINITY);
+ return Double.valueOf(Double.POSITIVE_INFINITY);
} else {
- return new Double(Double.NEGATIVE_INFINITY);
+ return Double.valueOf(Double.NEGATIVE_INFINITY);
}
}
if (multiplier == 0) {
if (digitList.isZero()) {
- return new Double(Double.NaN);
+ return Double.valueOf(Double.NaN);
} else if (status[STATUS_POSITIVE]) {
- return new Double(Double.POSITIVE_INFINITY);
+ return Double.valueOf(Double.POSITIVE_INFINITY);
} else {
- return new Double(Double.NEGATIVE_INFINITY);
+ return Double.valueOf(Double.NEGATIVE_INFINITY);
}
}
@@ -2093,8 +2093,8 @@
!isParseIntegerOnly();
}
- return gotDouble ?
- (Number)new Double(doubleResult) : (Number)Long.valueOf(longResult);
+ // cast inside of ?: because of binary numeric promotion, JLS 15.25
+ return gotDouble ? (Number)doubleResult : (Number)longResult;
}
}
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java Mon Apr 18 14:10:14 2016 -0700
@@ -455,7 +455,7 @@
s = v1 * v1 + v2 * v2;
} while (s >= 1 || s == 0);
double multiplier = StrictMath.sqrt(-2 * StrictMath.log(s)/s);
- nextLocalGaussian.set(new Double(v2 * multiplier));
+ nextLocalGaussian.set(Double.valueOf(v2 * multiplier));
return v1 * multiplier;
}
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java Mon Apr 18 14:10:14 2016 -0700
@@ -70,6 +70,7 @@
* @author Eric Bruneton
* @author Eugene Kuleshov
*/
+@SuppressWarnings("deprecation") // for Integer(int) constructor
public interface Opcodes {
// ASM API versions
@@ -176,6 +177,8 @@
*/
int F_SAME1 = 4;
+ // For reference comparison purposes, construct new instances
+ // instead of using valueOf() or autoboxing.
Integer TOP = new Integer(0);
Integer INTEGER = new Integer(1);
Integer FLOAT = new Integer(2);
--- a/jdk/src/java.base/unix/classes/sun/nio/ch/InheritedChannel.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/unix/classes/sun/nio/ch/InheritedChannel.java Mon Apr 18 14:10:14 2016 -0700
@@ -168,7 +168,7 @@
Class<?> paramTypes[] = { int.class };
Constructor<?> ctr = Reflect.lookupConstructor("java.io.FileDescriptor",
paramTypes);
- Object args[] = { new Integer(fdVal) };
+ Object args[] = { Integer.valueOf(fdVal) };
FileDescriptor fd = (FileDescriptor)Reflect.invoke(ctr, args);
--- a/jdk/src/java.base/windows/classes/java/net/DualStackPlainDatagramSocketImpl.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/windows/classes/java/net/DualStackPlainDatagramSocketImpl.java Mon Apr 18 14:10:14 2016 -0700
@@ -220,7 +220,7 @@
case IP_TOS :
case SO_RCVBUF :
case SO_SNDBUF :
- returnValue = new Integer(value);
+ returnValue = Integer.valueOf(value);
break;
default: /* shouldn't get here */
throw new SocketException("Option not supported");
--- a/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java Mon Apr 18 14:10:14 2016 -0700
@@ -87,13 +87,13 @@
private static final class FdMap extends HashMap<Integer, MapEntry> {
static final long serialVersionUID = 0L;
private MapEntry get(int desc) {
- return get(new Integer(desc));
+ return get(Integer.valueOf(desc));
}
private MapEntry put(SelectionKeyImpl ski) {
- return put(new Integer(ski.channel.getFDVal()), new MapEntry(ski));
+ return put(Integer.valueOf(ski.channel.getFDVal()), new MapEntry(ski));
}
private MapEntry remove(SelectionKeyImpl ski) {
- Integer fd = new Integer(ski.channel.getFDVal());
+ Integer fd = Integer.valueOf(ski.channel.getFDVal());
MapEntry x = get(fd);
if ((x != null) && (x.ski.channel == ski.channel))
return remove(fd);
--- a/jdk/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java Mon Apr 18 14:10:14 2016 -0700
@@ -134,7 +134,7 @@
Character arg;
for (int i = 0; i < args.length; i++) {
if ((args[i].length() >= 2) && (args[i].startsWith("-"))) {
- arg = new Character(args[i].charAt(1));
+ arg = Character.valueOf(args[i].charAt(1));
switch (arg.charValue()) {
case 'c':
action = 'c';
--- a/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/CachedRowSetImpl.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/java.sql.rowset/share/classes/com/sun/rowset/CachedRowSetImpl.java Mon Apr 18 14:10:14 2016 -0700
@@ -1963,7 +1963,7 @@
return (float)0;
}
try {
- return ((new Float(value.toString())).floatValue());
+ return Float.parseFloat(value.toString());
} catch (NumberFormatException ex) {
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.floatfail").toString(),
new Object[] {value.toString().trim(), columnIndex}));
@@ -2007,7 +2007,7 @@
return (double)0;
}
try {
- return ((new Double(value.toString().trim())).doubleValue());
+ return Double.parseDouble(value.toString().trim());
} catch (NumberFormatException ex) {
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.doublefail").toString(),
new Object[] {value.toString().trim(), columnIndex}));
@@ -4017,9 +4017,9 @@
return new BigDecimal(srcObj.toString().trim());
case java.sql.Types.REAL:
case java.sql.Types.FLOAT:
- return new Float(srcObj.toString().trim());
+ return Float.valueOf(srcObj.toString().trim());
case java.sql.Types.DOUBLE:
- return new Double(srcObj.toString().trim());
+ return Double.valueOf(srcObj.toString().trim());
case java.sql.Types.CHAR:
case java.sql.Types.VARCHAR:
case java.sql.Types.LONGVARCHAR:
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jstat/ExpressionExecuter.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jstat/ExpressionExecuter.java Mon Apr 18 14:10:14 2016 -0700
@@ -83,14 +83,14 @@
if (op == null) {
return evaluate(l);
} else {
- Double lval = new Double(((Number)evaluate(l)).doubleValue());
- Double rval = new Double(((Number)evaluate(r)).doubleValue());
- double result = op.eval(lval.doubleValue(), rval.doubleValue());
+ double lval = ((Number)evaluate(l)).doubleValue();
+ double rval = ((Number)evaluate(r)).doubleValue();
+ double result = op.eval(lval, rval);
if (debug) {
System.out.println("Performed Operation: " + lval + op + rval
+ " = " + result);
}
- return new Double(result);
+ return Double.valueOf(result);
}
}
}
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jstat/ExpressionResolver.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jstat/ExpressionResolver.java Mon Apr 18 14:10:14 2016 -0700
@@ -71,7 +71,7 @@
if (m == null) {
System.err.println("Warning: Unresolved Symbol: "
+ id.getName() + " substituted NaN");
- return new Literal(new Double(Double.NaN));
+ return new Literal(Double.valueOf(Double.NaN));
}
if (m.getVariability() == Variability.CONSTANT) {
if (debug) {
@@ -105,7 +105,7 @@
Literal rl = (Literal)r;
boolean warn = false;
- Double nan = new Double(Double.NaN);
+ Double nan = Double.valueOf(Double.NaN);
if (ll.getValue() instanceof String) {
warn = true; ll.setValue(nan);
}
@@ -129,7 +129,7 @@
+ " (right = " + rn.doubleValue() + ")"
+ " to literal value " + result);
}
- return new Literal(new Double(result));
+ return new Literal(Double.valueOf(result));
}
}
--- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jstat/Parser.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jstat/Parser.java Mon Apr 18 14:10:14 2016 -0700
@@ -324,7 +324,7 @@
case StreamTokenizer.TT_NUMBER:
double literal = lookahead.nval;
matchNumber();
- e = new Literal(new Double(literal));
+ e = new Literal(Double.valueOf(literal));
log(pdebug, "Parsed: number -> " + literal);
break;
default:
@@ -360,7 +360,7 @@
e1.setOperator(op);
e1.setRight(e);
log(pdebug, "Parsed: unary -> " + e1);
- e1.setLeft(new Literal(new Double(0)));
+ e1.setLeft(new Literal(Double.valueOf(0)));
e = e1;
}
}
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java Mon Apr 18 14:10:14 2016 -0700
@@ -478,7 +478,7 @@
ThreadGroupReference tg = it.nextThreadGroup();
++cnt;
MessageOutput.println("thread group number description name",
- new Object [] { new Integer (cnt),
+ new Object [] { Integer.valueOf(cnt),
Env.description(tg),
tg.name()});
}
@@ -1014,7 +1014,7 @@
return MessageOutput.format("locationString",
new Object [] {loc.declaringType().name(),
loc.method().name(),
- new Integer (loc.lineNumber()),
+ Integer.valueOf(loc.lineNumber()),
Long.valueOf(loc.codeIndex())});
}
@@ -1467,7 +1467,7 @@
MessageOutput.println("Line number information not available for");
} else if (Env.sourceLine(loc, lineno) == null) {
MessageOutput.println("is an invalid line number for",
- new Object [] {new Integer (lineno),
+ new Object [] {Integer.valueOf(lineno),
refType.name()});
} else {
for (int i = startLine; i <= endLine; i++) {
@@ -1477,11 +1477,11 @@
}
if (i == lineno) {
MessageOutput.println("source line number current line and line",
- new Object [] {new Integer (i),
+ new Object [] {Integer.valueOf(i),
sourceLine});
} else {
MessageOutput.println("source line number and line",
- new Object [] {new Integer (i),
+ new Object [] {Integer.valueOf(i),
sourceLine});
}
}
@@ -1725,7 +1725,7 @@
} else {
MessageOutput.println("Owned by:",
new Object [] {owner.name(),
- new Integer (object.entryCount())});
+ Integer.valueOf(object.entryCount())});
}
List<ThreadReference> waiters = object.waitingThreads();
if (waiters.size() == 0) {
--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/MessageOutput.java Mon Apr 18 20:58:30 2016 +0100
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/MessageOutput.java Mon Apr 18 14:10:14 2016 -0700
@@ -198,7 +198,7 @@
(MessageOutput.format("jdb prompt thread name and current stack frame",
new Object [] {
threadInfo.getThread().name(),
- new Integer (threadInfo.getCurrentFrameIndex() + 1)}));
+ Integer.valueOf(threadInfo.getCurrentFrameIndex() + 1)}));
}
System.out.flush();
}