In Java SE 8, the
java.lang.reflect.Proxy(InvocationHandler)
constructor throws a NullPointerException if the InvocationHandler
parameter is null. In prior versions of Java, the constructor returned
a proxy object but generated a NullPointerException when you used the proxy.
Java 8 introduced a similar behavior change for Constructor.newInstance(InvocationHandler).
In Java 8, when the InvocationHandler is null, the newInstance method throws an InvocationTargetException instead of returning
an unusable proxy object.
This rule flags calls to java.lang.reflect.Proxy(InvocationHandler)
and Constructor.newInstance(InvocationHandler) constructors. Review the flagged code and either
ensure that the handler is never null or change the code to use the
newProxyInstance factory method, which throws a NullPointerException
in both Java 7 and 8.
For additional information about the java.lang.reflect.Proxy(InvocationHandler)
class,
see the
Class java.lang.reflect.Proxy Java documentation.