typeClass = ClassUtils.forName(type.getName(), this.matchClass.getClassLoader());
protected boolean ajMembersNeedParameterization() { if (isParameterizedType()) { return true; } ResolvedType superclass = getSuperclass(); if (superclass != null && !superclass.isMissing()) { return superclass.ajMembersNeedParameterization(); } return false; }
public void clearInterTypeMungers() { if (isRawType()) { ResolvedType genericType = getGenericType(); if (genericType.isRawType()) { // ERROR SITUATION: PR341926 // For some reason the raw type is pointing to another raw form (possibly itself) System.err.println("DebugFor341926: Type " + this.getName() + " has an incorrect generic form"); } else { genericType.clearInterTypeMungers(); } } // interTypeMungers.clear(); // BUG? Why can't this be clear() instead: 293620 c6 interTypeMungers = new ArrayList<ConcreteTypeMunger>(); }
munger = fillInAnyTypeParameters(munger); if (clashesWithExistingMember(munger, getMethods(true, false))) { // ITDs checked below return; if (this.isInterface()) { if (clashesWithExistingMember(munger, Arrays.asList(world.getCoreType(OBJECT).getDeclaredMethods()).iterator())) { return; if (clashesWithExistingMember(munger, Arrays.asList(getDeclaredFields()).iterator())) { return; sb.append("Cannot handle two aspects both attempting to use new style ITDs for the same named field "); sb.append("on the same target type. Please recompile at least one aspect with '-Xset:itdVersion=1'."); sb.append(" Aspects involved: " + munger.getAspectType().getName() + " and " + typeMunger.getAspectType().getName() + "."); sb.append(" Field is named '" + existing.getSignature().getName() + "'"); getWorld().getMessageHandler().handleMessage( new Message(sb.toString(), getSourceLocation(), true)); return; if (clashesWithExistingMember(munger, Arrays.asList(getDeclaredMethods()).iterator())) { return; if (conflictingSignature(existingMunger.getSignature(), munger.getSignature(),v2itds)) { if (isVisible(munger.getSignature().getModifiers(), munger.getAspectType(), existingMunger.getAspectType())) {
if (targetType.equals(world.getCoreType(UnresolvedType.OBJECT))) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.DECP_OBJECT), this.getSourceLocation(), null); return null; if (parentType.isParameterizedType() || parentType.isRawType()) { if (parentType.isAssignableFrom(targetType)) { return null; // already a parent if (reportErrors && isWildChild && targetType.isEnum()) { world.getLint().enumAsTargetForDecpIgnored.signal(targetType.toString(), getSourceLocation()); if (reportErrors && isWildChild && targetType.isAnnotation()) { world.getLint().annotationAsTargetForDecpIgnored.signal(targetType.toString(), getSourceLocation()); if (targetType.isEnum() && parentType.isInterface()) { if (reportErrors && !isWildChild) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CANT_DECP_ON_ENUM_TO_IMPL_INTERFACE, if (targetType.isAnnotation() && parentType.isInterface()) { if (reportErrors && !isWildChild) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CANT_DECP_ON_ANNOTATION_TO_IMPL_INTERFACE, if (targetType.isEnum() && parentType.isClass()) { if (reportErrors && !isWildChild) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CANT_DECP_ON_ENUM_TO_EXTEND_CLASS, if (targetType.isAnnotation() && parentType.isClass()) { if (reportErrors && !isWildChild) {
public boolean matches(ResolvedType matchType, ResolvedType aspectType) { if (onType == null) { onType = matchType.getWorld().resolve(getDeclaringType()); if (onType.isRawType()) { onType = onType.getGenericType(); } } // System.err.println("matching: " + this + " to " + matchType + " onType = " + onType); if (matchType.equals(onType)) { if (!onType.isExposedToWeaver()) { // if the onType is an interface, and it already has the member we are about // to munge, then this is ok... boolean ok = (onType.isInterface() && (onType.lookupMemberWithSupersAndITDs(getSignature()) != null)); if (!ok && onType.getWeaverState() == null) { if (matchType.getWorld().getLint().typeNotExposedToWeaver.isEnabled()) { matchType.getWorld().getLint().typeNotExposedToWeaver.signal(matchType.getName(), signature .getSourceLocation()); } } } return true; } // System.err.println("NO MATCH DIRECT"); if (onType.isInterface()) { return matchType.isTopmostImplementor(onType); } else { return false; } }
TypePattern typePattern = parseTypePattern(decpPattern, struct); ResolvedType fieldType = UnresolvedType.forSignature(struct.field.getSignature()).resolve( struct.enclosingType.getWorld()); if (fieldType.isParameterizedOrRawType()) { fieldType = fieldType.getGenericType(); if (fieldType.isInterface()) { TypePattern parent = parseTypePattern(fieldType.getName(), struct); FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0]; IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings); ResolvedType impl = struct.enclosingType.getWorld().resolve(defaultImplClassName, false); ResolvedMember[] mm = impl.getDeclaredMethods(); int implModifiers = impl.getModifiers(); boolean defaultVisibilityImpl = !(Modifier.isPrivate(implModifiers) || Modifier.isProtected(implModifiers) || Modifier.isPublic(implModifiers)); if (!fieldType.isAssignableFrom(impl)) { reportError("@DeclareParents: defaultImpl=\"" + defaultImplClassName + "\" does not implement the interface '" + fieldType.toString() + "'", struct); Iterator<ResolvedMember> methodIterator = fieldType.getMethodsIncludingIntertypeDeclarations(false, true); while (methodIterator.hasNext()) { ResolvedMember method = methodIterator.next(); mdtm.setSourceLocation(struct.enclosingType.getSourceLocation()); struct.ajAttributes.add(new AjAttribute.TypeMunger(mdtm));
World world = struct.enclosingType.getWorld(); NameValuePair declareMixinPatternNameValuePair = getAnnotationElement(declareMixinAnnotation, VALUE); if (methodReturnType.isParameterizedOrRawType()) { methodReturnType = methodReturnType.getGenericType(); if (methodReturnType.isPrimitiveType()) { reportError(getMethodForMessage(struct) + ": factory methods for a mixin cannot return void or a primitive type", struct); if (ajInterfaceType.isMissing() || !ajInterfaceType.isInterface()) { reportError( "Types listed in the 'interfaces' DeclareMixin annotation value must be valid interfaces. This is invalid: " + ajInterfaceType.getName(), struct); // TODO better error location, use the method position return false; if (!ajInterfaceType.isAssignableFrom(methodReturnType)) { reportError(getMethodForMessage(struct) + ": factory method does not return something that implements '" + ajInterfaceType.getName() + "'", struct); return false; TypePattern newParent = parseTypePattern(ajInterfaceType.getName(), struct); newParents.add(newParent); if (methodReturnType.isClass()) { reportError( getMethodForMessage(struct) TypePattern newParent = parseTypePattern(methodReturnType.getName(), struct);
public List<ResolvedMember> getExposedPointcuts() { List<ResolvedMember> ret = new ArrayList<ResolvedMember>(); if (getSuperclass() != null) { ret.addAll(getSuperclass().getExposedPointcuts()); } for (ResolvedType type : getDeclaredInterfaces()) { addPointcutsResolvingConflicts(ret, Arrays.asList(type.getDeclaredPointcuts()), false); } addPointcutsResolvingConflicts(ret, Arrays.asList(getDeclaredPointcuts()), true); for (ResolvedMember member : ret) { ResolvedPointcutDefinition inherited = (ResolvedPointcutDefinition) member; if (inherited != null && inherited.isAbstract()) { if (!this.isAbstract()) { getWorld().showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.POINCUT_NOT_CONCRETE, inherited, this.getName()), inherited.getSourceLocation(), this.getSourceLocation()); } } } return ret; }
if (conflictingSignature(existingMember, typeTransformerSignature,v2itds)) { if (isVisible(existingMember.getModifiers(), this, typeTransformer.getAspectType())) { int c = compareMemberPrecedence(typeTransformerSignature, existingMember); if (typeTransformerTargetType.isInterface()) { ResolvedType existingMemberType = existingMember.getDeclaringType().resolve(world); if ((rtm instanceof NewMethodTypeMunger) && !typeTransformerTargetType.equals(existingMemberType)) { checkLegalOverride(typeTransformerSignature, existingMember, 0x10, typeTransformer.getAspectType()); return true; } else if (c > 0) { checkLegalOverride(existingMember, typeTransformerSignature, 0x01, typeTransformer.getAspectType()); WeaverStateInfo wsi = declaringRt.getWeaverState(); if (wsi != null) { List<ConcreteTypeMunger> mungersAffectingThisType = wsi.getTypeMungers(declaringRt); && ctMunger.aspectType.equals(typeTransformer.getAspectType())) { isDuplicateOfPreviousITD = true; String aspectName = typeTransformer.getAspectType().getName(); ISourceLocation typeTransformerLocation = typeTransformer.getSourceLocation(); ISourceLocation existingMemberLocation = existingMember.getSourceLocation(); getWorld().getMessageHandler().handleMessage(new Message(msg, typeTransformerLocation, true)); getWorld().getMessageHandler()
if (ResolvedType.isMissing(onType)) { return; if (searchType.isTypeVariableReference()) { searchType = ((TypeVariableReference) searchType).getTypeVariable().getFirstBound().resolve(scope.getWorld()); ResolvedPointcutDefinition pointcutDef = searchType.findPointcut(name); UnresolvedType declaringType = searchType.getDeclaringType(); if (declaringType == null) { break; pointcutDef = searchType.findPointcut(name); if (pointcutDef != null) { scope.message(IMessage.ERROR, this, "can't make static reference to abstract pointcut"); return; } else if (!searchType.isAbstract()) { scope.message(IMessage.ERROR, this, "can't use abstract pointcut in concrete context"); return; ResolvedType underlyingGenericType = ((ResolvedType) onType).getGenericType(); TypeVariable[] tVars = underlyingGenericType.getTypeVariables(); ResolvedType[] typeParams = ((ResolvedType) onType).getResolvedTypeParameters(); for (int i = 0; i < tVars.length; i++) { typeVariableMap.put(tVars[i].getName(), typeParams[i]); if (parameterTypes[i].isTypeVariableReference() && p.getExactType().isTypeVariableReference()) { UnresolvedType One = ((TypeVariableReference) parameterTypes[i]).getTypeVariable().getFirstBound();
public static void appendConversion(InstructionList il, InstructionFactory fact, ResolvedType fromType, ResolvedType toType) { if (!toType.isConvertableFrom(fromType) && !fromType.isConvertableFrom(toType)) { throw new BCException("can't convert from " + fromType + " to " + toType); World w = toType.getWorld(); if (w == null) { // dbg349636 throw new IllegalStateException("Debug349636: Unexpectedly found world null for type " + toType.getName()); if (toType.needsNoConversionFrom(fromType)) { return; if (toType.needsNoConversionFrom(fromType) && !(toType.isPrimitiveType() ^ fromType.isPrimitiveType())) { return; if (toType.equals(UnresolvedType.VOID)) { il.append(InstructionFactory.createPop(fromType.getSize())); } else if (fromType.equals(UnresolvedType.VOID)) { } else if (fromType.equals(UnresolvedType.OBJECT)) { Type to = BcelWorld.makeBcelType(toType); if (toType.isPrimitiveType()) { String name = toType.toString() + "Value"; il.append(fact.createInvoke("org.aspectj.runtime.internal.Conversions", name, to, new Type[] { Type.OBJECT }, Constants.INVOKESTATIC)); } else if (toType.equals(UnresolvedType.OBJECT)) { String name = fromType.toString() + "Object"; il.append(fact.createInvoke("org.aspectj.runtime.internal.Conversions", name, Type.OBJECT, new Type[] { from },
if (typeToVerify.equals(ResolvedType.OBJECT)) { return true; ResolvedType newParentGenericType = newParent.getGenericType(); Iterator<ResolvedType> iter = typeToVerify.getDirectSupertypes(); while (iter.hasNext()) { ResolvedType supertype = iter.next(); if (((supertype.isRawType() && newParent.isParameterizedType()) || (supertype.isParameterizedType() && newParent .isRawType())) && newParentGenericType.equals(supertype.getGenericType())) { new Message(WeaverMessages.format(WeaverMessages.CANT_DECP_MULTIPLE_PARAMETERIZATIONS, newParent.getName(), typeToVerify.getName(), supertype.getName()), getSourceLocation(), true, new ISourceLocation[] { typeToVerify.getSourceLocation() })); return false; if (supertype.isParameterizedType()) { ResolvedType generictype = supertype.getGenericType(); if (generictype.isAssignableFrom(newParentGenericType) && !supertype.isAssignableFrom(newParent)) { world.getMessageHandler().handleMessage( new Message(WeaverMessages.format(WeaverMessages.CANT_DECP_MULTIPLE_PARAMETERIZATIONS, newParent .getName(), typeToVerify.getName(), supertype.getName()), getSourceLocation(), true, new ISourceLocation[] { typeToVerify.getSourceLocation() })); return false;
.getWorld() .getMessageHandler() .handleMessage( searchStart = onType.resolve(searchStart.getWorld()); if (searchStart.isMissing()) { return Pointcut.makeMatchesNothing(Pointcut.CONCRETE); if (declaringType.isParameterizedType()) { TypeVariable[] tvs = declaringType.getGenericType().getTypeVariables(); String typeVariableName = ((TypeVariableReference) onType).getTypeVariable().getName(); for (int i = 0; i < tvs.length; i++) { if (tvs[i].getName().equals(typeVariableName)) { ResolvedType realOnType = declaringType.getTypeParameters()[i].resolve(declaringType.getWorld()); onType = realOnType; searchStart = realOnType; pointcutDec = declaringType.findPointcut(name); boolean foundMatchingPointcut = (pointcutDec != null && Modifier.isPrivate(pointcutDec.getModifiers())); if (!foundMatchingPointcut) { pointcutDec = searchStart.findPointcut(name); if (pointcutDec == null) { searchStart .getWorld() .getMessageHandler() .handleMessage( MessageUtil.error( WeaverMessages.format(WeaverMessages.CANT_FIND_POINTCUT, name, searchStart.getName()), getSourceLocation()));
collector.addAll(Arrays.asList(resolvedType.getDeclaredMethods())); if (!resolvedType.isInterface() && !resolvedType.equals(ResolvedType.OBJECT)) { ResolvedType superType = resolvedType.getSuperclass(); if (superType != null && !superType.isMissing()) { if (!genericsAware && superType.isParameterizedOrGenericType()) { superType = superType.getRawType(); addAndRecurse(knowninterfaces, collector, superType, includeITDs, allowMissing, genericsAware); ResolvedType[] interfaces = resolvedType.getDeclaredInterfaces(); for (int i = 0; i < interfaces.length; i++) { ResolvedType iface = interfaces[i]; if (!genericsAware && iface.isParameterizedOrGenericType()) { iface = iface.getRawType(); ConcreteTypeMunger munger = resolvedType.interTypeMungers.get(j); if (munger.getMunger() != null && munger.getMunger().getKind() == ResolvedTypeMunger.Parent && ((NewParentTypeMunger) munger.getMunger()).getNewParent().equals(iface) // pr171953 ) { shouldSkip = true; if (!shouldSkip && !knowninterfaces.contains(iface.getSignature())) { knowninterfaces.add(iface.getSignature()); if (allowMissing && iface.isMissing()) { if (iface instanceof MissingResolvedTypeWithKnownSignature) { ((MissingResolvedTypeWithKnownSignature) iface).raiseWarningOnMissingInterfaceWhilstFindingMethods(); addAndRecurse(knowninterfaces, collector, iface, includeITDs, allowMissing, genericsAware);
WeaverStateInfo typeWeaverState = weaver.getLazyClassGen().getType().getWeaverState(); if (typeWeaverState != null && typeWeaverState.isAspectAlreadyApplied(getAspectType())) { return false; NewParentTypeMunger nptMunger = (NewParentTypeMunger) munger; declaringAspect = nptMunger.getDeclaringType(); if (declaringAspect.isParameterizedOrGenericType()) { declaringAspect = declaringAspect.getRawType(); if (!thisAspect.equals(declaringAspect)) { IProgramElement thisAspectNode = model.getHierarchy().findElementForType(thisAspect.getPackageName(), thisAspect.getClassName()); Map<String, List<String>> declareParentsMap = thisAspectNode.getDeclareParentsMap(); if (declareParentsMap == null) { String tname = target.getName(); String pname = newParent.getName(); List<String> newparents = declareParentsMap.get(tname); if (newparents == null) { String tName = weaver.getLazyClassGen().getType().getSourceLocation().getSourceFile().getName(); if (tName.indexOf("no debug info available") != -1) { tName = "no debug info available"; } else { tName = getShortname(weaver.getLazyClassGen().getType().getSourceLocation().getSourceFile().getPath()); String fName = getShortname(getAspectType().getSourceLocation().getSourceFile().getPath()); if (munger.getKind().equals(ResolvedTypeMunger.Parent)) {
ResolvedType resolvedExtraParameterType = getExtraParameterType().resolve(world); ResolvedType shadowReturnType = shadow.getReturnType().resolve(world); boolean matches = (resolvedExtraParameterType.isConvertableFrom(shadowReturnType) && shadow.getKind() .hasReturnValue()); if (matches && resolvedExtraParameterType.isParameterizedType()) { maybeIssueUncheckedMatchWarning(resolvedExtraParameterType, shadowReturnType, shadow, world); } else if (hasExtraParameter() && kind == AdviceKind.AfterThrowing) { // pr119749 ResolvedType exceptionType = getExtraParameterType().resolve(world); if (!exceptionType.isCheckedException() || exceptionType.getName().equals("java.lang.Exception")) { // pr292239 return true; for (int i = 0; i < shadowThrows.length && !matches; i++) { ResolvedType type = shadowThrows[i].resolve(world); if (exceptionType.isAssignableFrom(type)) { matches = true; if (world.resolve(shadow.getEnclosingType()).isGroovyObject()) { return false; return false; } else if (shadow.getKind() == Shadow.StaticInitialization && shadow.getEnclosingType().resolve(world).isInterface()) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.AROUND_ON_INTERFACE_STATICINIT, shadow .getEnclosingType().getName()), getSourceLocation(), shadow.getSourceLocation()); if (shadowReturnType.isParameterizedType() && adviceReturnType.isRawType()) { // Set ResolvedType shadowReturnGenericType = shadowReturnType.getGenericType(); // Set
/** * Check if any parent aspects of the supplied aspect have unresolved dependencies (and so * should cause this aspect to be turned off). * @param aspectType the aspect whose parents should be checked * @return true if this aspect should be excluded because of a parents' missing dependencies */ private boolean excludeDueToParentAspectHavingUnresolvedDependency(ResolvedType aspectType) { ResolvedType parent = aspectType.getSuperclass(); boolean excludeDueToParent = false; while (parent != null) { if (parent.isAspect() && parent.isAbstract() && world.hasUnsatisfiedDependency(parent)) { if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) { world.getMessageHandler().handleMessage( MessageUtil.info("deactivating aspect '" + aspectType.getName() + "' as the parent aspect '"+parent.getName()+ "' has unsatisfied dependencies")); } excludeDueToParent = true; } parent = parent.getSuperclass(); } return excludeDueToParent; }
ResolvedType superclassType = resolvedTypeToWeave.getSuperclass(); String superclassTypename = (superclassType == null ? null : superclassType.getName()); if (superclassType != null && !superclassType.isTypeHierarchyComplete() && superclassType.isExposedToWeaver() && typesForWeaving.contains(superclassTypename)) { weaveParentsFor(typesForWeaving, superclassTypename, superclassType); ResolvedType[] interfaceTypes = resolvedTypeToWeave.getDeclaredInterfaces(); for (ResolvedType resolvedSuperInterface : interfaceTypes) { if (!resolvedSuperInterface.isTypeHierarchyComplete()) { String interfaceTypename = resolvedSuperInterface.getName(); if (resolvedSuperInterface.isExposedToWeaver()) { // typesForWeaving.contains(interfaceTypename)) { weaveParentsFor(typesForWeaving, interfaceTypename, resolvedSuperInterface); resolvedTypeToWeave.getName()); if (!resolvedTypeToWeave.isTypeHierarchyComplete()) { weaveParentTypeMungers(resolvedTypeToWeave); resolvedTypeToWeave.tagAsTypeHierarchyComplete();
protected void collectInterTypeMungers(List<ConcreteTypeMunger> collector) { for (Iterator<ResolvedType> iter = getDirectSupertypes(); iter.hasNext();) { ResolvedType superType = iter.next(); if (superType == null) { throw new BCException("UnexpectedProblem: a supertype in the hierarchy for " + this.getName() + " is null"); superType.collectInterTypeMungers(collector); for (ConcreteTypeMunger myMunger : getInterTypeMungers()) { if (conflictingSignature(myMunger.getSignature(), superMunger.getSignature())) { iter1.remove(); continue outer; for (Iterator<ResolvedMember> iter = getMethods(true, true); iter.hasNext();) { ResolvedMember method = iter.next(); if (conflictingSignature(method, superMunger.getSignature())) { iter1.remove(); continue outer; collector.addAll(getInterTypeMungers());