[jdk18] RFR: 8278373: JavacTrees.searchMethod finds incorrect match [v2]

Jan Lahoda jlahoda at openjdk.java.net
Wed Jan 5 14:37:02 UTC 2022


> Currently, when javac encounters a javadoc reference, like `@see PrintStream#println(int)`, will first try to find a method `println` in `PrintStream` using subtyping on the argument types, which may find another overload of the method with an argument that is a subtype of `int` - like `println(double)`. Consequently, the link in the javadoc may be to a wrong method.
> 
> In this patch, the proposal is to use the subtype search only as a backup option, using the existing check based on `isSameType` first, and only doing an inexact match using subtyping if the more exact match fails to find a method. This fallback should help possible existing broken references to still work as before, while the preferred use of the more exact match should select the correct method in usual correct cases.
> 
> This patch fixes some instances of incorrect references in the JDK's javadoc, a diff of the generated javadocs for the JDK mainline is here:
> http://cr.openjdk.java.net/~jlahoda/8278373/JDK-8278373.diff

Jan Lahoda has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:

 - Merge branch 'master' into JDK-8278373
 - Adding new test cases as suggested on the code review.
 - 8278373: JavacTypes.searchMethod finds incorrect match

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk18/pull/79/files
  - new: https://git.openjdk.java.net/jdk18/pull/79/files/8c0ad7f0..0c88aa60

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk18&pr=79&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk18&pr=79&range=00-01

  Stats: 137 lines in 5 files changed: 116 ins; 8 del; 13 mod
  Patch: https://git.openjdk.java.net/jdk18/pull/79.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk18 pull/79/head:pull/79

PR: https://git.openjdk.java.net/jdk18/pull/79


More information about the compiler-dev mailing list