RFR JDK-8244961: MethodHandles::privateLookupIn throws NPE when called during initPhase2

Mandy Chung mandy.chung at oracle.com
Thu May 14 21:58:06 UTC 2020



On 5/14/20 1:52 PM, Chris Hegarty wrote:
> Hi Mandy,
>
>> On 14 May 2020, at 21:12, Mandy Chung <mandy.chung at oracle.com> wrote:
>>
>> MethodHandles::privateLookupIn should prepare for being called during early startup when the module of java.base classes are not yet assigned.  This bug is uncovered by panama prototype converting NIO to use memory access API.
>>
>> The fix is very simple and move the call to Module::isNamed only if the caller module and target module are different:
>> http://cr.openjdk.java.net/~mchung/jdk15/webrevs/8244961/webrev.00/
> LGTM.

Thanks.
>
> In this case both the caller and target modules are, well.. , null (at this point of initialization). So your change should avoid tripping up on this and resulting in a NPE.    I am surprised that nothing else has run into this before, but the code executed this early on is somewhat limited.

JDK 9 jigsaw cleaned up various bootstrapping issues that enables early 
startup to use lambdas.   This is very early during VM initialization 
and those code path may still be pre-JDK 9 code and not surprised that 
it does not use VarHandle/MethodHandle yet until this panama change.

Mandy



More information about the core-libs-dev mailing list