This is a follow up to: How to get the line number of a method?
I have a java.lang.reflect.Field
instance and want to know at which line the declaration was made of in the declaring class.
Currently I have a CtField
but it lacks a getLineNumber()
method ...
public static int getLineNumberOf(Class<?> type,Field field){
ClassPool cp = ClassPool.getDefault();
CtClass ctClass = cp.getCtClass(type.getName());
CtField ctField = ctClass.getDeclaredField(field.getName());
ctField.getLineNumber();
// ^^^^^^^^^^^^^^ that one is missing
}
What is the right way to get the line number?
Aucun commentaire:
Enregistrer un commentaire