// Build a search list for type parameters to find their definition,
// resolving enclosing classes as we go up.
TypeParameterLookup typeParamLookup = new TypeParameterLookup();
typeParamLookup.pushEnclosingScopes(type);
CollectClassData classData = classMapType.get(type);
assert classData != null;
int access = classData.getAccess();
assert (!classData.getClassType().hasNoExternalName());
logger = logger.branch(TreeLogger.SPAM, "Found type '"
+ type.getQualifiedSourceName() + "'", null);
// Handle package-info classes.
if (isPackageInfoTypeName(type.getSimpleSourceName())) {
return resolvePackage(logger, type, classData.getAnnotations());
}
// Resolve annotations
Map<Class<? extends Annotation>, Annotation> declaredAnnotations = new HashMap<Class<? extends Annotation>, Annotation>();
resolveAnnotations(logger, classData.getAnnotations(), declaredAnnotations);
addAnnotations(type, declaredAnnotations);
String signature = classData.getSignature();
if (signature != null) {
// If we have a signature, use it for superclass and interfaces
SignatureReader reader = new SignatureReader(signature);
ResolveClassSignature classResolver = new ResolveClassSignature(resolver,
binaryMapper, logger, type, typeParamLookup);
reader.accept(classResolver);
classResolver.finish();
} else {
// Set the super type for non-interfaces
if ((access & Opcodes.ACC_INTERFACE) == 0) {
String superName = classData.getSuperName();
if (superName != null) {
JClassType superType = binaryMapper.get(superName);
if (superType == null || !resolveClass(logger, superType)) {
logger.log(TreeLogger.WARN, "Unable to resolve supertype "
+ superName);
return false;
}
setSuperClass(type, (JClassType) possiblySubstituteRawType(superType));
}
}
// Set interfaces
for (String intfName : classData.getInterfaces()) {
JClassType intf = binaryMapper.get(intfName);
if (intf == null || !resolveClass(logger, intf)) {
logger.log(TreeLogger.WARN, "Unable to resolve interface " + intfName);
return false;
}
addImplementedInterface(type,
(JClassType) possiblySubstituteRawType(intf));
}
}
if (((access & Opcodes.ACC_INTERFACE) == 0) && type.getSuperclass() == null) {
// Only Object or interfaces should not have a superclass
assert "java/lang/Object".equals(classData.getName());
}
// Process methods
for (CollectMethodData method : classData.getMethods()) {
if (!resolveMethod(logger, type, method, typeParamLookup)) {
logger.log(TreeLogger.WARN, "Unable to resolve method " + method);
return false;
}
}
// Process fields
// Track the next enum ordinal across resolveField calls.
int[] nextEnumOrdinal = new int[]{0};
for (CollectFieldData field : classData.getFields()) {
if (!resolveField(logger, type, field, typeParamLookup, nextEnumOrdinal)) {
logger.log(TreeLogger.WARN, "Unable to resolve field " + field);
return false;
}
}