So we hope for Objects.requireNonNull to be inlined most of the times.
It would be nice if @ForceInline annotation was accessible outside
java.lang.invoke package, so methods like requireNonNull could benefit
from it too. With modules, such platform annotations could be made
public and put into a package (java.lang.internal) that is not exported
to the world.
I don't think @ForceInline is the right solution here.
I'd be happy to get rid of it in java.lang.invoke code as well :-)
Instead, JIT inlining heuristics should be tuned to favor inlining
trivial and small methods.
There's -XX:MaxInlineSize(=35) flag in HotSpot. With current inlining
heuristics, C1 & C2 should almost always inline the method.
Best regards,
Vladimir Ivanov