Summary
Undo the change from JEP 390 that marked constructors of the primitive wrapper classes as "deprecated for removal". Revert them to simply "deprecated".
Problem
The constructors of primitive wrapper classes like Integer have been deprecated since Java 9, because they force the creation of wrapper objects with new identities, and it has long been discouraged to depend on the identity of a wrapper object.
In JEP 390, it was anticipated that the coming Value Classes and Objects feature would make this situation worse: when Integer became a value class, legacy binaries that had invoked a constructor would fail with a LinkageError. In anticipation of this problem, JEP 390 upgraded the deprecation of these constructors to "for removal", with the expectation that they would eventually be made private.
The design of Value Classes and Objects has since evolved, and it is no longer the case that making Integer a value class will break legacy binaries.
In fact, making Integer a value class will eliminate the motivation for deprecating these constructors in the first place: it will no longer be the case that constructor invocation will force the creation of new identities—value objects don't have identity.
Under the status quo, users are getting urgent warnings about a future change that we no longer intend to make.
Solution
Revert the wrapper class constructors to be simply "deprecated" in Java 25.
(After these classes have permanently become value classes, we can revisit whether to un-deprecate the constructors completely.)
Specification
Diff of java.lang.Integer
is below. Similar changes to be made to all of java.lang.Byte
, java.lang.Short
, java.lang.Long
, java.lang.Float
, java.lang.Double
, java.lang.Character
, and java.lang.Boolean
.
diff --git a/src/java.base/share/classes/java/lang/Integer.java b/src/java.base/share/classes/java/lang/Integer.java
index a6bf739220f..78e124c2ea5 100644
--- a/src/java.base/share/classes/java/lang/Integer.java
+++ b/src/java.base/share/classes/java/lang/Integer.java
@@ -1024,7 +1024,7 @@ public static Integer valueOf(int i) {
* {@link #valueOf(int)} is generally a better choice, as it is
* likely to yield significantly better space and time performance.
*/
- @Deprecated(since="9", forRemoval = true)
+ @Deprecated(since="9")
public Integer(int value) {
this.value = value;
}
@@ -1046,7 +1046,7 @@ public Integer(int value) {
* {@code int} primitive, or use {@link #valueOf(String)}
* to convert a string to an {@code Integer} object.
*/
- @Deprecated(since="9", forRemoval = true)
+ @Deprecated(since="9")
public Integer(String s) throws NumberFormatException {
this.value = parseInt(s, 10);
}
- csr of
-
JDK-8354335 No longer deprecate wrapper class constructors for removal
-
- Open
-