[lworld] RFR: 8273301: [lworld] Bootstrap of instance-capturing lambda fails for reference favoring primitive types.

Jesper Steen Møller jespersm at openjdk.java.net
Wed Sep 29 22:36:56 UTC 2021

On Fri, 17 Sep 2021 00:12:18 GMT, Mandy Chung <mchung at openjdk.org> wrote:

>> Fix the test by adjusting bootstrap parameters, like it was fixed in JDK-8271583.
> I discussed with Dan offline to follow up my question in what cases javac should emit `(LFoo;)LR;` vs `(QFoo;)LR;`.   For the lambda case, having the receiver type as `QFoo;` is a good thing to do as it's an instance method of the enclosing class. 
> For a method reference `o::m` where `o` is of primitive reference type, the factory type would be `(LFoo;)LR;`.   I have a test case that verifies the emitted code is:
> 28: invokedynamic #38,  0             // InvokeDynamic #1:get:(LX;)Ljava/util/function/Supplier;
> In short, it's good to fix javac to emit `QFoo;` as the receiver type if it's a primitive class.

@mlchung : I've tested, and can confirm that both [your fix](https://bugs.openjdk.java.net/browse/JDK-8273301?focusedCommentId=14447307&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14447307) on the lambda side of things and my fix on the compiler side (this PR) will make the attached test case pass. 

However, from your comments above, quoting a discussion with Dan, I'm suggesting that javac is tightened up, as the smaller fix, so to speak, i.e. that we integrate this PR.

I then suggest that your fix should be brought under the JDK-8174983 umbrella, since the L->Q and Q->L conversions are conceptually similar, and thus useful for other users of LambdaMetafactory.

If you agree, @sadayapalam can review this bug as it.


PR: https://git.openjdk.java.net/valhalla/pull/545

More information about the valhalla-dev mailing list