From 78218f298883071c44f91fea30d8c2916f2da6df Mon Sep 17 00:00:00 2001 From: cpovirk Date: Mon, 26 Aug 2024 08:44:16 -0700 Subject: [PATCH] Write more about `withSignature`. (prompted by unknown commit) PiperOrigin-RevId: 667597716 --- docs/bugpattern/WithSignatureDiscouraged.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 docs/bugpattern/WithSignatureDiscouraged.md diff --git a/docs/bugpattern/WithSignatureDiscouraged.md b/docs/bugpattern/WithSignatureDiscouraged.md new file mode 100644 index 00000000000..1bd1c378697 --- /dev/null +++ b/docs/bugpattern/WithSignatureDiscouraged.md @@ -0,0 +1,12 @@ +`withSignature` replies on the string representation of internal classes in the +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`.