Java: Adjust the prioritisation between MaD and source dispatch. #11392
+3
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
When we have a combination of a good manual model for a callable and low confidence in the virtual dispatch to source targets, then we want to only use the model and disregard the source dispatch.
Selecting these cases involves a good deal of heuristics, and this PR tweaks this by allowing source dispatch to implementations of interfaces (with suitable flow models) unless those interfaces are from a different project, i.e. typically some interface in a library that the code depends on.
The reasoning is that if a library interface has flow models then it's likely because it comes with typically used default implementations of that interface, which makes any custom implementations unlikely dispatch targets if we don't have other indications that such a custom implementation might be in use at the call site.
Within a library that defines an interface, source dispatch happens as usual with the exception of a selection of core jdk interfaces for which we always want to use the flow models.