The jmpq jumps to the PatchingStub and is patched at runtime to a mov (see Runtime1::patch_code) with the correct field offset.
I think there are multiple ways to fix this:
1) We could omit the explicit null check when the receiver is unresolved at compile time and only insert the check after patching. This is complex and would require lots of changes to the patching code.
2) We could deoptimize if the class is not loaded and the receiver is null by setting CodeEmitInfo::_deoptimize_on_exception = true for the load:
http://cr.openjdk.java.net/~thartmann/8173373/webrev.00/ This has the disadvantage that we call Runtime1::predicate_failed_trap() which sets the nmethod to non-entrant.
3) We could emit an explicit null check if the receiver is not resolved at compile time and call the deoptimize stub with Action_none if the check fails:
http://cr.openjdk.java.net/~thartmann/8173373/webrev.01/ This way we don't make the nmethod non-entrant but have an explicit instead of an implicit null check.
Re:  RFR(S): 8173373: C1: NPE is thrown instead of LinkageError when accessing inaccessible field on NULL receiver
On 31.01.2017 13:25, Vladimir Ivanov wrote:
> Good catch!
>> I missed that the problem also affects putfield (of course). I extended the test accordingly and added the same fix to LIRGenerator::do_StoreField():
>> http://cr.openjdk.java.net/~thartmann/8173373/webrev.03/ >
> Can you try to factor new code into a helper method?