Following are the two cases of Methods which I invoke using reflection
actualoutput = mgenerateouput.invoke(outputclassinst,obj);
obj is Object array Type which contains Section Type object in obj[0]
Case 1:
public Student[] expectedOutputString(Section sec){
//Object arra[] = Section.makeSection((String[])params[0]);
ReportCard rc = new ReportCard();
Student[] exOut = rc.orderClass(sec);
return exOut;
}
it’s working in first case perfect but in second case below when i declare parameter type as Object i get IllegalArgumentException.
Case 2:
public Student[] expectedOutputString(Object params[]){
//Object arra[] = Section.makeSection((String[])params[0]);
ReportCard rc = new ReportCard();
Student[] exOut = rc.orderClass((Section)params[0]);
return exOut;
}
[
Code 2 does not declare the parameter as Object but as Object[], i.e. array of objects. So your obj[0] must be an array of objects, too.
Edit: Or the other way around: Code 2 should expect an Object instead of Object[].