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

Write more about withSignature. #4550

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/bugpattern/WithSignatureDiscouraged.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
`withSignature` replies on the string representation of internal classes in the
Copy link
Contributor

Choose a reason for hiding this comment

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

s/replies/relies/? :)

javac implementation. Those string representations are not necessarily stable
across versions of javac, and they can change when a method is annotated with
type-use annotations.

Additionally, `withSignature` currently has at least one undocumented behavioral
quirk.

The most reasonable use case for `withSignature` is for methods that declare or
use type variables, which are difficult or impossible to express with the rest
of the `MethodMatchers` API. Still, where practical, prefer to write your own
matching code instead of using `withSignature`.
Loading