Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8354335

No longer deprecate wrapper class constructors for removal

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • 25
    • 25
    • core-libs

      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.

      Given these changes, it is no longer necessary for the wrapper class constructors to be deprecated "for removal", and they can revert to simply being deprecated. (After they have permanently become value classes, we can revisit whether to un-deprecate them completely.)

            rriggs Roger Riggs
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: