How can I add method parameter names to a method, when none exists?
There are some examples on how to retrieve these names, if they exist, with a method like this:
CtMethod m;
CodeAttribute codeAttribute = m.getMethodInfo().getCodeAttribute();
if (codeAttribute != null) {
LocalVariableAttribute table = (LocalVariableAttribute) codeAttribute.getAttribute(LocalVariableAttribute.tag);
if (table != null)
for (int i = 0; i < table.tableLength(); i++)
m.getMethodInfo().getConstPool().getUtf8Info(table.nameIndex(i));
}
This will give all the parameter names of a method, if they exist.
How can I do the reverse?
Aucun commentaire:
Enregistrer un commentaire