Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK-8274848: LambdaMetaFactory::metafactory on REF_invokeSpecial impl method has incorrect behavior #5901

Closed
wants to merge 6 commits into from

Conversation

mlchung
Copy link
Member

@mlchung mlchung commented Oct 11, 2021

Classes compiled prior to the nestmate support will generate REF_invokeSpecial if the implementation method is a private instance method. Since a lambda proxy class is a hidden class, a nestmate of the host class, it can invoke the private implementation method but it has to use REF_invokeVirtual or REF_invokeInterface. In order to support the old classes running on the new runtime, LMF implementation adjusts the reference kind from REF_invokeSpecial to REF_invokeVirtual/REF_invokeInterface.

This PR fixes the check properly to ensure the adjustment is only made if the implementation method is private method in the host class.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8274848: LambdaMetaFactory::metafactory on REF_invokeSpecial impl method has incorrect behavior

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5901/head:pull/5901
$ git checkout pull/5901

Update a local copy of the PR:
$ git checkout pull/5901
$ git pull https://git.openjdk.java.net/jdk pull/5901/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5901

View PR using the GUI difftool:
$ git pr show -t 5901

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5901.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Oct 11, 2021

👋 Welcome back mchung! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr label Oct 11, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 11, 2021

@mlchung The following labels will be automatically applied to this pull request:

  • core-libs
  • jdk

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added jdk core-libs labels Oct 11, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Oct 11, 2021

Webrevs

@AlanBateman
Copy link
Contributor

@AlanBateman AlanBateman commented Oct 12, 2021

/label remove jdk

@openjdk openjdk bot removed the jdk label Oct 12, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 12, 2021

@AlanBateman
The jdk label was successfully removed.

filelist Outdated Show resolved Hide resolved
@dansmithcode
Copy link

@dansmithcode dansmithcode commented Oct 25, 2021

Source changes look good.

The test seems like way too much overhead for this small thing. Looks like a lot of the ASM code is just to verify that javac generates the test case you expect? I'd suggest invoking the LMF API directly instead, testing both private and non-private invokespecial MethodHandles, just making sure the rules can be used without error.

(I don't just mean this as a stylistic comment. I think it's important to decouple LMF testing from various javac behaviors for different javac versions and flags, because that's going to change. LMF has its own spec that can be tested independently.)

@mlchung
Copy link
Member Author

@mlchung mlchung commented Oct 27, 2021

I'd suggest invoking the LMF API directly instead, testing both private and non-private invokespecial MethodHandles, just making sure the rules can be used without error.

That's a good idea. I updated the test and see what you think.

@openjdk
Copy link

@openjdk openjdk bot commented Oct 27, 2021

⚠️ @mlchung This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

@openjdk
Copy link

@openjdk openjdk bot commented Oct 28, 2021

@mlchung This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8274848: LambdaMetaFactory::metafactory on REF_invokeSpecial impl method has incorrect behavior

Reviewed-by: psandoz, dlsmith

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 51 new commits pushed to the master branch:

  • c6339cb: 8271820: Implementation of JEP 416: Reimplement Core Reflection with Method Handle
  • 5a768f7: 8276054: JMH benchmarks for Fences
  • 6d8fa8f: 8255286: Implement ParametersTypeData::print_data_on fully
  • 63b9f8c: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert.
  • cb989cf: 8275052: AArch64: Severe AES/GCM slowdown on MacOS for short blocks
  • c92f230: 8276110: Problemlist javax/swing/JMenu/4515762/bug4515762.java for macos12
  • 309acbf: 8275703: System.loadLibrary fails on Big Sur for libraries hidden from filesystem
  • abe52ae: 8275518: accessibility issue in Inet6Address docs
  • 85d8cd8: 8276100: Remove G1SegmentedArray constructor name parameter
  • a343fa8: 8275865: Print deoptimization statistics in product builds
  • ... and 41 more: https://git.openjdk.java.net/jdk/compare/337a9b73a75981d14eb4125e4354edda8d541361...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Oct 28, 2021
@dansmithcode
Copy link

@dansmithcode dansmithcode commented Oct 28, 2021

Ahhh, much nicer. Thanks for updating the test.

@openjdk
Copy link

@openjdk openjdk bot commented Oct 28, 2021

@dansmithcode Unknown command approve - for a list of valid commands use /help.

@mlchung
Copy link
Member Author

@mlchung mlchung commented Oct 28, 2021

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Oct 28, 2021

Going to push as commit 21da218.
Since your change was applied there have been 52 commits pushed to the master branch:

  • 48f3fca: 8275308: Add valueOf(Runtime.Version) factory to SourceVersion
  • c6339cb: 8271820: Implementation of JEP 416: Reimplement Core Reflection with Method Handle
  • 5a768f7: 8276054: JMH benchmarks for Fences
  • 6d8fa8f: 8255286: Implement ParametersTypeData::print_data_on fully
  • 63b9f8c: 8153490: Cannot setBytes() if incoming buffer's length is bigger than number of elements we want to insert.
  • cb989cf: 8275052: AArch64: Severe AES/GCM slowdown on MacOS for short blocks
  • c92f230: 8276110: Problemlist javax/swing/JMenu/4515762/bug4515762.java for macos12
  • 309acbf: 8275703: System.loadLibrary fails on Big Sur for libraries hidden from filesystem
  • abe52ae: 8275518: accessibility issue in Inet6Address docs
  • 85d8cd8: 8276100: Remove G1SegmentedArray constructor name parameter
  • ... and 42 more: https://git.openjdk.java.net/jdk/compare/337a9b73a75981d14eb4125e4354edda8d541361...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Oct 28, 2021
@openjdk openjdk bot added integrated and removed ready labels Oct 28, 2021
@openjdk openjdk bot removed the rfr label Oct 28, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 28, 2021

@mlchung Pushed as commit 21da218.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@mlchung mlchung deleted the invokespecial branch Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs integrated
4 participants