Skip to content

8380567: DynamicCallSiteDesc.bootstrapMethod should return DirectMethodHandleDesc#30351

Open
liach wants to merge 1 commit intoopenjdk:masterfrom
liachmodded:fix/dcsd-bsm-return
Open

8380567: DynamicCallSiteDesc.bootstrapMethod should return DirectMethodHandleDesc#30351
liach wants to merge 1 commit intoopenjdk:masterfrom
liachmodded:fix/dcsd-bsm-return

Conversation

@liach
Copy link
Member

@liach liach commented Mar 21, 2026

We should fix the return type of DynamicCallSiteDesc.bootstrapMethod; luckily we can do this without breaking binary compatibility.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8380568 to be approved

Issues

  • JDK-8380567: DynamicCallSiteDesc.bootstrapMethod should return DirectMethodHandleDesc (Bug - P4)
  • JDK-8380568: DynamicCallSiteDesc.bootstrapMethod should return DirectMethodHandleDesc (CSR)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30351/head:pull/30351
$ git checkout pull/30351

Update a local copy of the PR:
$ git checkout pull/30351
$ git pull https://git.openjdk.org/jdk.git pull/30351/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30351

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30351.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 21, 2026

👋 Welcome back liach! 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
Copy link

openjdk bot commented Mar 21, 2026

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title 8380567 8380567: DynamicCallSiteDesc.bootstrapMethod should return DirectMethodHandleDesc Mar 21, 2026
@openjdk openjdk bot added csr Pull request needs approved CSR before integration core-libs core-libs-dev@openjdk.org labels Mar 21, 2026
@openjdk
Copy link

openjdk bot commented Mar 21, 2026

@liach The following label will be automatically applied to this pull request:

  • core-libs

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

@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 21, 2026
@mlbridge
Copy link

mlbridge bot commented Mar 21, 2026

Webrevs

Comment on lines +305 to +307
sealed interface BootstrapMethodHook {
MethodHandleDesc bootstrapMethod();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish there was a way to declare required bridge overloads without needing interfaces such as these (which only works for public instance methods), or needing some sort of post‑compilation bytecode rewriting (which works for any method, but significantly complicates the build steps).

Copy link
Member Author

@liach liach Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think it's in the interest of us to expand the language here. This trick actually should be perfectly legal to avoid NoSuchMethodError for all compliant Java SE implementations (see the CSR for details)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add a comment here though to make the purpose of this BootstrapMethodHook clearer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the notes in DynamicCllSiteDesc.bootstrapMethod() is sufficient to explain this situation.

*/
public MethodHandleDesc bootstrapMethod() { return bootstrapMethod; }
@Override
public DirectMethodHandleDesc bootstrapMethod() { return bootstrapMethod; }
Copy link

@ExE-Boss ExE-Boss Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this might’ve been originally declared as a MethodHandleDesc with the expectation that the bootstrap method could potentially use a constant dynamic in some future JVM.

Copy link
Member Author

@liach liach Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlikely, an entry in the BootstrapMethods table most likely will stay a MH constant plus a list of argument constants. Such a refactor would also hurt DynmicConstantDesc.

Comment on lines +213 to +221
* @implSpec
* The {@code DynamicCallSiteDesc} class must support an invocation
* referencing the method with signature {@code MethodHandleDesc
* bootstrapMethod()} to support linking from pre-existing binaries.
*
* @implNote
* An implementation of {@code DynamicCallSiteDesc} in Java may declare a
* non-exported supertype declaring the method above to support reference
* to that method (JLS {@jls 13.4.12}).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these @implSpec and @implNote tags really needed? For users they will be quite confusing.

And DynamicCallSiteDesc is final, so this would mostly be relevant for re-implementations of the JDK (?) or rewrites of this class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, implSpec and implNote are for implementations of the Java SE Platform. Rules concerning subclasses in public are part of the regular API specifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org csr Pull request needs approved CSR before integration rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants