jeudi 5 mai 2016

When does Class.newInstance() return null?

I am having a weird issue in a legacy code where the following line is returning null

Class.forName(className).newInstance();

I understand that it will throw ClassNotFoundException if the class name is not found but I am not sure when it can return null?

I went through the documentation but couldn't find anything that could cause newInstance() method to return null.

Am I missing something here or is there a use case where this call can return null?





Aucun commentaire:

Enregistrer un commentaire