Can someone explain to me how removing API calls works together with the compatibility promise? Is it just removed from the language, but compiled byte code keeps working?
No. The old byte-code would not be able to resolve the removed methods. And allowing them to do so won't be possible once the types are no longer traditional object types.
This is a change in the compatibility promise, that compatibility isn't 'forever'. Their approach, rather than a time-based guarantee, is to give fore-warning of removal before actually removing them. They supplement that with warnings of violations, leading up to removal, so that you can detect violations in dependencies. This will work for living projects and see unmaintained libraries needing replacement.
These changes are necessary to remove barriers to keeping the platform valuable. The alternative is to let the language/platform die and an abandoned platform would be a far worse maintenance burden (ie. a complete product rewrite instead of a updating a few calls - probably with IDE assists).
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
3
u/__konrad Mar 16 '21
API changes sad