Class InvocationMatcher


  • public final class InvocationMatcher
    extends Object
    Matches a method or constructor call against a particular overload. Use parse(String) to create one. For example,
         java.lang.String#toString()   // match calls to toString on String instances
         _#toString()                  // match calls to toString on any receiver
         _#_()                         // match all calls to a method with no parameters
         _#toString(_*)                // match calls to a "toString" method with any number of parameters
         _#eq(_, _)                    // match calls to an "eq" method that has 2 parameters of unspecified type
         _#eq(java.lang.String, _)     // like the previous, but the first parameter must be String
         java.util.ArrayList#new(int)  // match constructor calls of this overload of the ArrayList constructor
     

    The receiver matcher (first half) is matched against the static type of the receiver of the call, and not the declaration site of the method, unless the called method is static, or a constructor.

    The parameters are matched against the declared parameters types of the called overload, and not the actual argument types. In particular, for vararg methods, the signature should mention a single parameter, with an array type.

    For example Integer.valueOf('0') will be matched by _#valueOf(int) but not _#valueOf(char), which is an overload that does not exist (the char is widened to an int, so the int overload is selected).

    Full EBNF grammar

    (no whitespace is tolerated anywhere):

    
     sig         ::= type '#' method_name param_list
     type        ::= qname ( '[]' )* | '_'
     method_name ::= '_' | ident | 'new'
     param_list  ::= '(_*)' | '(' type (',' type )* ')'
     qname       ::= java binary name