Forbidden API Checker allows to define custom signatures files. Depending on the type of task (Ant, Maven, or Gradle), you can add them via references to local files from your project directory. Maven also supports to refer to them using Maven coordinates.
The syntax of those files is: Each line that is not empty, does not start with a
#
or @
symbol is treated as a signature. The following types
of signatures are supported:
java.lang.String
sun.misc.**
("**
" matches against package
boundaries).package.Class#fieldName
#
and a method name including method parameters: java.lang.String#concat(java.lang.String)
– All method parameters need to use fully qualified class names!
To refer to instance constructors, use the method name <init>
,
e.g. java.lang.Integer#<init>(int)
.The error message displayed when the signature matches can be given at the end of each
signature line using "@
" as separator:
java.lang.String @ You are crazy that you disallow strings
To not repeat the same message after each signature, you can prepend signatures
with a default message. Use a line starting with "@defaultMessage
".
@defaultMessage You are crazy that you disallow substrings java.lang.String#substring(int) java.lang.String#substring(int,int)