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

Mandy Chung mchung at openjdk.java.net
Wed Sep 29 23:50:38 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.

Thanks for confirming it.  I also create JDK-8274399 to fix the runtime.

> 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.

Yes, we agree that it's good to fix javac as well.   You need @sadayapalam to review your PR before integration.  I recalled Srikanath was on vacation and I'm not sure whether he's back.
> 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.

It's related to JDK-8174983.  We can fix JDK-8274399 in lworld branch while JDK-8174983 can be fixed separately in the main line.

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

Yes I agree.


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

More information about the valhalla-dev mailing list