I am trying to list down variables inside my jar file using javaassit. I want to check if the field in a class file is of type collection. I am using "Collection.class.isAssignableForm", but it does not work because field.getType().getCLass() returns class as CtCLassType. Is there a way to check if a CtClass field is of type Collection ? In the similar way how to check if that field type is Serializable ?
CtClass loClass = ClassPool.getDefault().get(lsClassName);
CtField[] loFields = loClass.getDeclaredFields();
// iterate over fields
for(CtField field: loFields){
// this does not work
Collection.class.isAssignableForm(field.getType().getCLass());
}
Any help is much appreciated.
try to convert it into a Class first?