private JRealClassType createType(CompiledClass compiledClass,
CollectClassData classData, CollectClassData enclosingClassData) {
int access = classData.getAccess();
String qname = compiledClass.getSourceName();
String className = Shared.getShortName(qname);
JRealClassType resultType = null;
String jpkgName = compiledClass.getPackageName();
JPackage pkg = typeOracle.getOrCreatePackage(jpkgName);
boolean isIntf = (access & Opcodes.ACC_INTERFACE) != 0;
boolean isLocalType = classData.hasNoExternalName();
String enclosingTypeName = null;
if (enclosingClassData != null) {
enclosingTypeName = InternalName.toSourceName(InternalName.getClassName(enclosingClassData.getName()));
}
if ((access & Opcodes.ACC_ANNOTATION) != 0) {
resultType = new JAnnotationType(typeOracle, pkg, enclosingTypeName,
false, className, true);
} else if ((access & Opcodes.ACC_ENUM) != 0) {
resultType = new JEnumType(typeOracle, pkg, enclosingTypeName,
isLocalType, className, isIntf);
} else {
JTypeParameter[] typeParams = getTypeParametersForClass(classData);
if ((typeParams != null && typeParams.length > 0)
|| nonStaticInsideGeneric(classData, enclosingClassData)) {
resultType = new JGenericType(typeOracle, pkg, enclosingTypeName,
isLocalType, className, isIntf, typeParams);
} else {
resultType = new JRealClassType(typeOracle, pkg, enclosingTypeName,
isLocalType, className, isIntf);
}
}
/*
* Declare type parameters for all methods; we must do this during the first
* pass.
*/
// if (typeDecl.methods != null) {
// for (AbstractMethodDeclaration method : typeDecl.methods) {
// declareTypeParameters(method.typeParameters());
// }
// }
/*
* Add modifiers since these are needed for
* TypeOracle.getParameterizedType's error checking code.
*/
resultType.addModifierBits(mapBits(ASM_TO_SHARED_MODIFIERS, access));
if (isIntf) {
// Always add implicit modifiers on interfaces.
resultType.addModifierBits(Shared.MOD_STATIC | Shared.MOD_ABSTRACT);
}
return resultType;
}