hg: valhalla/valhalla: 8198748: [lworld] Javac should insert null checks at casts to value types.
john.r.rose at oracle.com
Mon Mar 12 07:19:09 UTC 2018
On Mar 11, 2018, at 11:59 PM, Remi Forax <forax at univ-mlv.fr> wrote:
> There is already a code path in the compiler to generate nullchecks using getClass() + pop,
> i think you should reuse this code instead of adding another way to do a nullcheck.
> And with my hat of backporter/bytecode analyzer writer, adding a new runtime dependency, here, to Objects.requireNonNull, makes things more complex because some analyzers may have to be enhanced to recognize this new pattern.
So the getClass hack has a foothold that's it's not going to give
up easily to the legitimate heir, Os.rNN.
It won't matter in the long run, if we manage to convince ourselves
to fold the null check into the checkcast instruction, somehow.
(Maybe with a prefix, maybe with classfile version sensitivity.)
More information about the valhalla-dev