Why is Class.newInstance() deprecated in Java 9?
I read Javadoc 9:
Deprecated. 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.newInstance method avoids this problem by wrapping any exception thrown by the constructor in a (checked) InvocationTargetException.
but I'm not sure I quite understood it...
"Propagates any exception thrown by the nullary constructor" - wouldn't it be correct? Maybe there are a lot of points I'm missing.
Aucun commentaire:
Enregistrer un commentaire