According to the JavaDocs, the newInstance()
Method of java.lang.Class
is not intented to return null.
But my code seems to prove the opposite. Why?
public Assessment createAssessment() {
Class<? extends Assessment> assessmentClass = (Class<? extends Assessment>) assessmentClassDataTable.getRowData();
try {
System.out.println("ASSESSMENTCLASS " + assessmentClass);
// -> 'ASSESSMENTCLASS class my.model.ManualSelectAssessment'
Assessment a = assessmentClass.newInstance();
System.out.println("ASSESSMENT " + a);
// -> 'ASSESSMENT null'
return a;
} catch (Exception e) {
Application.handleError(e);
}
return null;
}
It returns null.