The documentation for
Class#newInstance includes the following
Note that this method propagates any exception thrown by the nullary constructor, including a checked exception. Use of this method effectively bypasses the compile-time exception checking that would otherwise be performed by the compiler. The
Constructor.newInstancemethod avoids this problem by wrapping any exception thrown by the constructor in a (checked)
myClass.getConstructor().newInstance() to calling
myClass.newInstance() directly. The
Class#newInstance method is slated for
deprecation in JDK 9.
Suppress false positives by adding an
@SuppressWarnings("ClassNewInstance") annotation to the enclosing element.