The inspection checks that the arguments provided to MethodHandle.invoke(), VarHandle.set(), and similar methods match the method handle signature and var handle type.

The signature of the method handle is specified in Lookup.findVirtual(), Lookup.findGetter(), etc.

The type of the var handle is specified in Lookup.findVarHandle(), MethodHandles.arrayElementVarHandle(), etc.

Examples:


  MethodHandle mh = MethodHandles.lookup().findVirtual(
    MyClass.class, "foo", MethodType.methodType(void.class, int.class));
  // the argument should be an int value
  mh.invoke(myObj, "abc");

  VarHandle vh = MethodHandles.lookup().findVarHandle(
    MyClass.class, "text", String.class);
  // the argument should be a String value
  vh.set(myObj, 42);

New in 2017.2