ResolvedType type = (ResolvedType) i.getType(); if (type instanceof ReferenceType) { ReferenceTypeDelegate delegate = ((ReferenceType) type).getDelegate(); if (delegate instanceof ReflectionBasedReferenceTypeDelegate) { try {
/** * When the world is operating in 1.5 mode, the TypeMap should only contain RAW types and never directly generic types. The RAW * type will contain a reference to the generic type. * * @param type a possibly generic type for which the raw needs creating as it is not currently in the world * @return a type suitable for putting into the world */ private ResolvedType ensureRawTypeIfNecessary(ResolvedType type) { if (!isInJava5Mode() || type.isRawType()) { return type; } // Key requirement here is if it is generic, create a RAW entry to be put in the map that points to it if (type instanceof ReferenceType && ((ReferenceType) type).getDelegate() != null && type.isGenericType()) { ReferenceType rawType = new ReferenceType(type.getSignature(), this); rawType.typeKind = UnresolvedType.TypeKind.RAW; ReferenceTypeDelegate delegate = ((ReferenceType) type).getDelegate(); rawType.setDelegate(delegate); rawType.setGenericType((ReferenceType) type); return rawType; } // probably parameterized... return type; }
ResolvedType[] delegateInterfaces = getDelegate() .getDeclaredInterfaces(); if (isRawType()) { if (newInterfaces != null) {// debug 375777 throw new IllegalStateException( "The raw type should never be accumulating new interfaces, they should be on the generic type. Type is " + this.getName()); if (isParameterizedType()) { getMemberParameterizationMap()).resolve(world); } else { interfaces[i] = delegateInterfaces[i]; interfaces); return interfaces; } else if (isRawType()) { UnresolvedType[] paramTypes = getTypesForMemberParameterization(); interfaces = new ResolvedType[delegateInterfaces.length]; for (int i = 0, max = interfaces.length; i < max; i++) { getWorld()); } else if (interfaces[i].isParameterizedType()) { UnresolvedType[] toUseForParameterization = determineThoseTypesToUse( interfaces[i], paramTypes); interfaces[i] = interfaces[i] if (getDelegate().isCacheable()) {
ReferenceType derivative = derivativeRef.get(); if (derivative != null) { derivative.setDelegate(delegate); } else { forRemoval.add(derivativeRef); if (isRawType() && getGenericType() != null) { ReferenceType genType = (ReferenceType) getGenericType(); if (genType.getDelegate() != delegate) { // avoids circular updates genType.setDelegate(delegate); clearParameterizationCaches(); ensureConsistent();
@Override public ResolvedMember[] getDeclaredFields() { if (parameterizedFields != null) { return parameterizedFields; } if (isParameterizedType() || isRawType()) { ResolvedMember[] delegateFields = getDelegate().getDeclaredFields(); parameterizedFields = new ResolvedMember[delegateFields.length]; for (int i = 0; i < delegateFields.length; i++) { parameterizedFields[i] = delegateFields[i].parameterizedWith( getTypesForMemberParameterization(), this, isParameterizedType()); } return parameterizedFields; } else { return getDelegate().getDeclaredFields(); } }
@Override public void ensureConsistent() { annotations = null; annotationTypes = null; newSuperclass = null; bits = 0; // clears the hierarchy complete tag (amongst other things) newInterfaces = null; typeVariables = null; parameterizedInterfaces.clear(); superclassReference = new WeakReference<ResolvedType>(null); if (getDelegate() != null) { delegate.ensureConsistent(); } if (isParameterizedOrRawType()) { ReferenceType genericType = getGenericType(); if (genericType != null) { genericType.ensureConsistent(); } } }
/** * Constructor used when creating a parameterized type. */ public ReferenceType(ResolvedType theGenericType, ResolvedType[] theParameters, World aWorld) { super(makeParameterizedSignature(theGenericType, theParameters), theGenericType.signatureErasure, aWorld); ReferenceType genericReferenceType = (ReferenceType) theGenericType; this.typeParameters = theParameters; this.genericType = genericReferenceType; this.typeKind = TypeKind.PARAMETERIZED; this.delegate = genericReferenceType.getDelegate(); genericReferenceType.addDependentType(this); }
@Override public void addParent(ResolvedType newParent) { if (this.isRawType()) { throw new IllegalStateException( "The raw type should never be accumulating new interfaces, they should be on the generic type. Type is " + this.getName()); newInterfaces[0] = newParent; } else { ResolvedType[] existing = getDelegate().getDeclaredInterfaces(); if (existing != null) { for (int i = 0; i < existing.length; i++) { newInterfaces = newNewInterfaces; if (this.isGenericType()) { synchronized (derivativeTypes) { for (WeakReference<ReferenceType> derivativeTypeRef : derivativeTypes) {
if (this.isParameterizedType() && newSuperclass.isParameterizedType()) { return newSuperclass.parameterize( getMemberParameterizationMap()).resolve(getWorld()); if (getDelegate().isCacheable()) { superclassReference = new WeakReference<ResolvedType>(ret); ret = getDelegate().getSuperclass(); } finally { world.setTypeVariableLookupScope(null); if (this.isParameterizedType() && ret.isParameterizedType()) { ret = ret.parameterize(getMemberParameterizationMap()).resolve( getWorld()); if (getDelegate().isCacheable()) { superclassReference = new WeakReference<ResolvedType>(ret);
@Override public boolean isGenericType() { return !isParameterizedType() && !isRawType() && getDelegate().isGeneric(); }
ReferenceType simpleOrRawType = new ReferenceType(erasedSignature, this); if (ty.needsModifiableDelegate()) { simpleOrRawType.setNeedsModifiableDelegate(true); if (simpleOrRawType.hasNewInterfaces()) { // debug 375777 throw new IllegalStateException( "Simple type promoted forced to raw, but it had new interfaces/superclass. Type is " + simpleOrRawType.getName()); simpleOrRawType.setDelegate(delegate); genericType.setDelegate(delegate); simpleOrRawType.setGenericType(genericType); return simpleOrRawType; } else { simpleOrRawType.setDelegate(delegate); return simpleOrRawType;
@Override public PerClause getPerClause() { PerClause pclause = getDelegate().getPerClause(); if (pclause != null && isParameterizedType()) { // could cache the // result here... Map<String, UnresolvedType> parameterizationMap = getAjMemberParameterizationMap(); pclause = (PerClause) pclause.parameterizeWith(parameterizationMap, world); } return pclause; }
if ("Lorg/aspectj/lang/annotation/DeclareAnnotation;".equals(constantValue)) { msgHandler.handleMessage(new Message( "Found @DeclareAnnotation while current release does not support it (see '" + type.getName() + "')", IMessage.WARNING, null, type.getSourceLocation())); ReferenceTypeDelegate delegate = type.getDelegate(); if (delegate instanceof BcelObjectType) { wvinfo = ((BcelObjectType) delegate).getWeaverVersionAttribute(); msgHandler.handleMessage(new Message("Found @DeclarePrecedence on a non @Aspect type '" + type.getName() + "'", IMessage.WARNING, null, type.getSourceLocation())); if (!type.isAnnotationStyleAspect() && !isCodeStyleAspect) { msgHandler.handleMessage(new Message("Found @AspectJ annotations in a non @Aspect type '" + type.getName() + "'", IMessage.WARNING, null, type.getSourceLocation()));
if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) { world.getMessageHandler().handleMessage( MessageUtil.info("Type '" + resolvedClassType.getName() + "' not woven due to exclusion via XML weaver exclude section")); List<ConcreteTypeMunger> typeMungers = classType.getResolvedTypeX().getInterTypeMungers(); resolvedClassType.checkInterTypeMungers(); && resolvedClassType.getInterTypeMungersIncludingSupers().size() > 0; if (world.isMinimalModel() && model != null && !classType.isAspect()) { AspectJElementHierarchy hierarchy = (AspectJElementHierarchy) model.getHierarchy(); String pkgname = classType.getResolvedTypeX().getPackageName(); String tname = classType.getResolvedTypeX().getSimpleBaseName(); IProgramElement typeElement = hierarchy.findElementForType(pkgname, tname); if (typeElement != null && hasInnerType(typeElement)) {
@Override public ResolvedMember[] getDeclaredPointcuts() { if (parameterizedPointcuts != null) { return parameterizedPointcuts; } if (isParameterizedType()) { ResolvedMember[] delegatePointcuts = getDelegate() .getDeclaredPointcuts(); parameterizedPointcuts = new ResolvedMember[delegatePointcuts.length]; for (int i = 0; i < delegatePointcuts.length; i++) { parameterizedPointcuts[i] = delegatePointcuts[i] .parameterizedWith(getTypesForMemberParameterization(), this, isParameterizedType()); } return parameterizedPointcuts; } else { return getDelegate().getDeclaredPointcuts(); } }
@Override public Collection<Declare> getDeclares() { if (parameterizedDeclares != null) { return parameterizedDeclares; } Collection<Declare> declares = null; if (ajMembersNeedParameterization()) { Collection<Declare> genericDeclares = getDelegate().getDeclares(); parameterizedDeclares = new ArrayList<Declare>(); Map<String, UnresolvedType> parameterizationMap = getAjMemberParameterizationMap(); for (Declare declareStatement : genericDeclares) { parameterizedDeclares.add(declareStatement.parameterizeWith( parameterizationMap, world)); } declares = parameterizedDeclares; } else { declares = getDelegate().getDeclares(); } for (Declare d : declares) { d.setDeclaringType(this); } return declares; }
@Override public ResolvedType[] getAnnotationTypes() { if (getDelegate() == null) { throw new BCException("Unexpected null delegate for type " + this.getName()); } if (annotationTypes == null) { // there are no extras: return getDelegate().getAnnotationTypes(); } else { ResolvedType[] delegateAnnotationTypes = getDelegate() .getAnnotationTypes(); ResolvedType[] result = new ResolvedType[annotationTypes.length + delegateAnnotationTypes.length]; System.arraycopy(delegateAnnotationTypes, 0, result, 0, delegateAnnotationTypes.length); System.arraycopy(annotationTypes, 0, result, delegateAnnotationTypes.length, annotationTypes.length); return result; } }
return GenericSignature.FormalTypeParameter.NONE; } else { throw new BCException("Whilst processing type '" + this.resolvedTypeX.getSignature() + "' - cannot cast the outer type to a reference type. Signature=" + outerClassType.getSignature() + " toString()=" + outerClassType.toString()+" class=" + outerClassType.getClassName()); ReferenceTypeDelegate outerDelegate = outer.getDelegate(); AbstractReferenceTypeDelegate outerObjectType = (AbstractReferenceTypeDelegate) outerDelegate; if (outerObjectType.isNested()) {
public void setGenericType(ReferenceType rt) { genericType = rt; // Should we 'promote' this reference type from simple to raw? // makes sense if someone is specifying that it has a generic form if (typeKind == TypeKind.SIMPLE) { typeKind = TypeKind.RAW; signatureErasure = signature; if (newInterfaces != null) { // debug 375777 throw new IllegalStateException( "Simple type promoted to raw, but simple type had new interfaces/superclass. Type is " + this.getName()); } } if (typeKind == TypeKind.RAW) { genericType.addDependentType(this); } if (isRawType()) { genericType.rawType = this; } if (this.isRawType() && rt.isRawType()) { new RuntimeException( "PR341926 diagnostics: Incorrect setup for a generic type, raw type should not point to raw: " + this.getName()).printStackTrace(); } }
ReferenceType existingType = ((ReferenceType)baseType).findDerivativeType(resolvedParameters); pType = existingType; } else { pType =new ReferenceType(baseType, resolvedParameters, inAWorld); return (ReferenceType) pType.resolve(inAWorld);