This inspection detects the case where the signature of a MethodHandle or the type of a VarHandle doesn't match the actual method or field.

It also checks that the arguments provided to MethodHandle.invoke(), VarHandle.set(), etc match the method signature/field type.

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");


  // the argument should be String.class
  VarHandle vh = MethodHandles.lookup().findVarHandle(
      MyClass.class, "text", int.class);


  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