String fieldName = (fieldchild.getAttribute("Name")); //gives field name : opcode
String fieldCustomID = (fieldchild.getAttribute("ID")); //gives id: 2022
String classTypeofField = IdNameMappingList.get(fieldCustomID).toString(); //give class name OpCodeClass
FieldSpec fieldSpec = FieldSpec.builder(**some code**, fieldName)
.build();
Should give something like :
OpCodeClass opcode;
Any other work around is also appreciated.
Try ClassName.get("com.company.app", classTypeofField)
, replacing the package name with that of the class.