public Imports getImports(ClassFile cf) {
Imports imports = new Imports(cf.getPackageName());
ConstantPool pool = cf.getPool();
for (int i = 0; i < pool.size(); i++) {
ConstantPoolInfo cpi = pool.get(i);
if (cpi != null) {
if (cpi.getType() == ConstantPoolInfo.CLASS) {
// there can be array definitions here, too
JavaType cls = new JavaType(cpi.getValue());
imports.addType(cls.getType());
} else if (cpi.getType() == ConstantPoolInfo.NAME_AND_TYPE) {
NameAndTypeInfo nati = (NameAndTypeInfo) cpi;
Descriptor desc = nati.getDescriptor();
if (!desc.getReturn().isPrimitive()) {
imports.addType(desc.getReturn().getType());
}