Source code analysis: calls to wrapper class constructors
daniel.smith at oracle.com
Wed Oct 21 14:32:31 UTC 2020
> On Oct 19, 2020, at 6:01 PM, Dan Smith <daniel.smith at oracle.com> wrote:
> In the context of the Warnings for Value-Based Classes JEP, we're looking for usages of the deprecated wrapper class constructors ('new Integer(...)', 'new Double(...)', etc.). When do these get used? How often is this motivated by wanting a unique object vs. legacy code that has no particular reason not to use 'valueOf'?
> We've got some investigations going on at Oracle, including looking at some open-source projects, but I'm interested in examples from other companies/projects as well. Please investigate and share what you find!
> I'll reply in a few days with our analysis for the code we look at.
Some initial areas of particular concern:
- How disruptive will it be if legacy jar files stop running on the JVM? How often will projects in, say, 2023 depend on binaries that haven't been recompiled since 9, when the constructors were deprecated? (We've seen evidence that many projects—a lot of Apache APIs for example—fixed up their code in response to the deprecation warnings.)
- How disruptive will it be if programs need to update their older shaded sources (repackaged sources copied from another project) before they can compile? These sources are more likely to go unmaintained, preserving 'new Integer' calls from years ago.
More information about the valhalla-spec-observers