8380567: DynamicCallSiteDesc.bootstrapMethod should return DirectMethodHandleDesc#30351
8380567: DynamicCallSiteDesc.bootstrapMethod should return DirectMethodHandleDesc#30351liach wants to merge 1 commit intoopenjdk:masterfrom
Conversation
|
👋 Welcome back liach! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
| sealed interface BootstrapMethodHook { | ||
| MethodHandleDesc bootstrapMethod(); | ||
| } |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Would it make sense to add a comment here though to make the purpose of this BootstrapMethodHook clearer?
There was a problem hiding this comment.
I think the notes in DynamicCllSiteDesc.bootstrapMethod() is sufficient to explain this situation.
| */ | ||
| public MethodHandleDesc bootstrapMethod() { return bootstrapMethod; } | ||
| @Override | ||
| public DirectMethodHandleDesc bootstrapMethod() { return bootstrapMethod; } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| * @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}). |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Yes, implSpec and implNote are for implementations of the Java SE Platform. Rules concerning subclasses in public are part of the regular API specifications.
We should fix the return type of
DynamicCallSiteDesc.bootstrapMethod; luckily we can do this without breaking binary compatibility.Progress
Issues
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30351/head:pull/30351$ git checkout pull/30351Update a local copy of the PR:
$ git checkout pull/30351$ git pull https://git.openjdk.org/jdk.git pull/30351/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 30351View PR using the GUI difftool:
$ git pr show -t 30351Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30351.diff
Using Webrev
Link to Webrev Comment