Inspectopedia 2025.2 Help

Suspicious 'InvocationHandler' implementation

Reports implementations of InvocationHandler that do not proxy standard Object methods like hashCode(), equals(), and toString().

Failing to handle these methods might cause unexpected problems upon calling them on a proxy instance.

Example:

InvocationHandler myHandler = (proxy, method, params) -> { System.out.println("Hello World!"); return null; }; Runnable myProxy = (Runnable) Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class[] {Runnable.class}, myHandler );

This code snippet is designed to only proxy the Runnable.run() method. However, calls to any Object methods, like hashCode(), are proxied as well. This can lead to problems like a NullPointerException, for example, when adding myProxy to a HashSet.

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.

SuspiciousInvocationHandlerImplementation
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.

Settings or Preferences | Editor | Inspections | Java | Probable bugs

New in 2020.2

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection SuspiciousInvocationHandlerImplementation

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.2, Qodana for JVM 2025.2,

Last modified: 18 September 2025