Thanks for reaching us.
Indeed, this won’t work. You cannot use the
AbstractMethodDetection abstract class when writing custom rules. This class is not exposed in the SonarJava plugin API. The only classes you are allowed to access and use should be part of the
For the time being, there is no easy way to identify a method call or method declaration in a custom rules, except writing the logic of checking manually parameters and symbols. We however thought about adding such feature in the API, feel free to vote on the following ticket: SONARJAVA-2357
Now, if you just want to disallow some method invocations or declaration, you may still give a try to the template rule squid:S2253 - Track uses of disallowed methods.
Thanks to you I also had a look at all the custom rules targeting java from the example, and fixed one which was indeed using an unexposed utility class. Maybe that’s what caused you trouble. I also identified and fixed a more annoying issue regarding loading of rule metadata. I therefore strongly encourage you to re-download/update the template.
Finally, about what you are saying:
Which documentation are you referring to?
I would gladly try to improve it in order to make it clearer.