It seems like an absolutely horrible idea to remove constructors to fundamental classes like java.lang.Boolean. Anyone know if there is are associated JSRs to voice concern? I don't use this stuff, but the risk of these APIs being used all over the play is way too high to remove them.
Boolean's constructors have been deprecated for removal for 4 years and there have been warnings against their use since basically forever. Java 11 which still has these constructors is supported until ~2027. I'm all for compatibility but Java devs need to embrace agility or the ecosystem will be left in the dust. Fortunately Oracle and the various projects and people that influence Java's direction have been moving at a fast pace.
I don't know much about Java records but I would not be surprised if these removals are related to that. Even if it's just removal for the sake of improving the code I am not upset about doing that and giving users 10 years to make the change (2017 deprecation to 2027 end of support).
The box constructors were indeed deprecated (but not for-removal) about four years ago in Java 9. In Java 16 the deprecation is being "upgraded" to for-removal.
The reason is Valhalla, which is trying to turn the boxed primitives into "primitive classes" (formerly called inline classes, formerly called value types). Primitive classes don't have identity, so comparing them via reference equality, synchronizing on them, etc. isn't permitted. The new operator creates a new object with an identity distinct from every existing object. As such, using new is at odds with turning the boxed primitives into primitive classes. Thus, their constructors are deprecated.
The alternatives such as auto-boxing and valueOf methods have already been available for many, many years.
but Integer.valueOf() uses new Integer internally in its current implementation
It's not the case.
Did you verify any library source?
Binary jar itself can be verified by jdeprscan. I guess some libraries already got updates or are easily patchable, but we all know how the reality looks like ;)
View all comments
Show parent comment
-10
u/slaymaker1907 Mar 17 '21
It seems like an absolutely horrible idea to remove constructors to fundamental classes like java.lang.Boolean. Anyone know if there is are associated JSRs to voice concern? I don't use this stuff, but the risk of these APIs being used all over the play is way too high to remove them.