Timeline for wrapper class constructor removal from JDK?

Dan Smith daniel.smith at oracle.com
Wed Feb 21 20:30:46 UTC 2024


I got this question about the fate of wrapper class constructors, and it's worth broadcasting the reply:

> On Feb 21, 2024, at 8:59 AM, Kurt Alfred Kluever <kak at google.com> wrote:
> 
> I'm wondering if there's any ETA for when the wrapper class constructors will be actually removed from the JDK?
> 
> More info: I'm an engineer on the Java Core Libraries team at Google. I've mostly scrubbed our own depot of the wrapper class constructors (using ErrorProne's BoxedPrimitiveConstructor refactoring), but the situation for third party libraries is much much worse. We have literally hundreds of third party libraries using these constructors.
> 
> And of course, most of these libraries are legacy / unmaintained upstream. We can locally patch some of them, try to upstream some fixes, but the sheer number of libraries is making me fairly nervous about trying to eventually update our JDK to a version w/o these constructors.
> 
> Any insight about when we should expect the removal would be helpful in terms of planning.


Yes, when we did JEP 390 [1], we understood that there would continue to be class files in the wild calling 'new java/lang/Integer' and those class files would need to continue to work. The JEP refers to "Tooling to support execution of binaries that are unable to update their usages of wrapper class constructors" as future work. We envisioned some sort of bytecode rewriting capability to clean up these class files.

Since then, we've updated our construction approach for value classes (see [2]), and it is no longer the case that 'new java/lang/Integer' in bytecode is incompatible with a value class Integer. Thus, we no longer need any special tooling—the stale binaries will just continue working!

That said, these old classes will stop working if we ever go through with the threatened removal, as advertised by JEP 390. It probably makes sense to roll that back and just treat these constructors as normal @Deprecated APIs, with no specific plans for future removal.

[1] https://openjdk.org/jeps/390
[2] https://openjdk.org/jeps/401#Value-object-construction



More information about the valhalla-spec-observers mailing list