MethodHandle/VarHandle type mismatch
Reports MethodHandle
and VarHandle
factory method calls that don't match any method or field.
Also reports arguments to MethodHandle.invoke()
and similar methods, that don't match the MethodHandle
signature and arguments to VarHandle.set()
that don't match the VarHandle
type.
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
JavaLangInvokeHandleSignature- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
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
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Java, 242.22892 |