/** * see ResolvedTypeMunger.parameterizedFor(ResolvedType) */ @Override public ResolvedTypeMunger parameterizedFor(ResolvedType target) { ResolvedType genericType = target; if (target.isRawType() || target.isParameterizedType()) { genericType = genericType.getGenericType(); } ResolvedMember parameterizedSignature = null; // If we are parameterizing it for a generic type, we just need to 'swap the letters' from the ones used // in the original ITD declaration to the ones used in the actual target type declaration. if (target.isGenericType()) { TypeVariable vars[] = target.getTypeVariables(); UnresolvedTypeVariableReferenceType[] varRefs = new UnresolvedTypeVariableReferenceType[vars.length]; for (int i = 0; i < vars.length; i++) { varRefs[i] = new UnresolvedTypeVariableReferenceType(vars[i]); } parameterizedSignature = getSignature().parameterizedWith(varRefs, genericType, true, typeVariableAliases); } else { // For raw and 'normal' parameterized targets (e.g. Interface, Interface<String>) parameterizedSignature = getSignature().parameterizedWith(target.getTypeParameters(), genericType, target.isParameterizedType(), typeVariableAliases); } NewConstructorTypeMunger nctm = new NewConstructorTypeMunger(parameterizedSignature, syntheticConstructor, explicitConstructor, getSuperMethodsCalled(), typeVariableAliases); nctm.setSourceLocation(getSourceLocation()); return nctm; }
@Override public ResolvedMember getMatchingSyntheticMember(Member member, ResolvedType aspectType) { ResolvedMember ret = getSyntheticConstructor(); if (ResolvedType.matches(ret, member)) { return getSignature(); } return super.getMatchingSyntheticMember(member, aspectType); }
public static ResolvedTypeMunger readConstructor(VersionedDataInputStream s, ISourceContext context) throws IOException { ISourceLocation sloc = null; ResolvedMember sig = ResolvedMemberImpl.readResolvedMember(s, context); ResolvedMember syntheticCtor = ResolvedMemberImpl.readResolvedMember(s, context); ResolvedMember explicitCtor = ResolvedMemberImpl.readResolvedMember(s, context); Set superMethodsCalled = readSuperMethodsCalled(s); sloc = readSourceLocation(s); List typeVarAliases = readInTypeAliases(s); ResolvedTypeMunger munger = new NewConstructorTypeMunger(sig, syntheticCtor, explicitCtor, superMethodsCalled, typeVarAliases); if (sloc != null) { munger.setSourceLocation(sloc); } return munger; }
final InstructionFactory fact = currentClass.getFactory(); ResolvedMember newConstructorMember = newConstructorTypeMunger.getSyntheticConstructor(); ResolvedType onType = newConstructorMember.getDeclaringType().resolve(weaver.getWorld()); if (onType.isRawType()) { ResolvedMember explicitConstructor = newConstructorTypeMunger.getExplicitConstructor(); mg.setEffectiveSignature(newConstructorTypeMunger.getSignature(), Shadow.ConstructorExecution, true); newConstructorTypeMunger.getSignature().getParameterTypes()); AnnotationAJ annotationsOnRealMember[] = null; ResolvedMember realMember = getRealMemberForITDFromAspect(aspectType, interMethodDispatcher, true); UnresolvedType[] declaredParams = newConstructorTypeMunger.getSignature().getParameterTypes(); Type[] paramTypes = mg.getArgumentTypes(); int frameIndex = 1;
public void check(World world) { if (getSignature().getDeclaringType().resolve(world).isAspect()) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.ITD_CONS_ON_ASPECT), getSignature() .getSourceLocation(), null); } }
public static ResolvedTypeMunger read(VersionedDataInputStream s, ISourceContext context) throws IOException { Kind kind = Kind.read(s); if (kind == Field) { return NewFieldTypeMunger.readField(s, context); } else if (kind == Method) { return NewMethodTypeMunger.readMethod(s, context); } else if (kind == Constructor) { return NewConstructorTypeMunger.readConstructor(s, context); } else if (kind == MethodDelegate) { return MethodDelegateTypeMunger.readMethod(s, context, false); } else if (kind == FieldHost) { return MethodDelegateTypeMunger.FieldHostTypeMunger.readFieldHost(s, context); } else if (kind == MethodDelegate2) { return MethodDelegateTypeMunger.readMethod(s, context, true); } else if (kind == InnerClass) { return NewMemberClassTypeMunger.readInnerClass(s, context); } else { throw new RuntimeException("unimplemented"); } }
/** * Equivalence can be true for an EclipseTypeMunger and a BcelTypeMunger that represent the same transformation (just at * different points in the pipeline). */ public boolean equivalentTo(Object other) { if (!(other instanceof ConcreteTypeMunger)) { return false; } ConcreteTypeMunger o = (ConcreteTypeMunger) other; ResolvedTypeMunger otherTypeMunger = o.getMunger(); ResolvedTypeMunger thisTypeMunger = getMunger(); if (thisTypeMunger instanceof NewConstructorTypeMunger && otherTypeMunger instanceof NewConstructorTypeMunger) { return (((NewConstructorTypeMunger) otherTypeMunger).equivalentTo(thisTypeMunger)) && ((o.getAspectType() == null) ? (getAspectType() == null) : o.getAspectType().equals(getAspectType())); } else { return ((otherTypeMunger == null) ? (thisTypeMunger == null) : otherTypeMunger.equals(thisTypeMunger)) && ((o.getAspectType() == null) ? (getAspectType() == null) : o.getAspectType().equals(getAspectType())); } }
public LazyMethodGen locateAnnotationHolderForMethodCtorMunger(LazyClassGen clazz, ConcreteTypeMunger methodCtorMunger) { ResolvedTypeMunger rtMunger = methodCtorMunger.getMunger(); ResolvedMember lookingFor = null; if (rtMunger instanceof NewMethodTypeMunger) { NewMethodTypeMunger nftm = (NewMethodTypeMunger) rtMunger; lookingFor = AjcMemberMaker.interMethodDispatcher(nftm.getSignature(), methodCtorMunger.getAspectType()); } else if (rtMunger instanceof NewConstructorTypeMunger) { NewConstructorTypeMunger nftm = (NewConstructorTypeMunger) rtMunger; lookingFor = AjcMemberMaker.postIntroducedConstructor(methodCtorMunger.getAspectType(), nftm.getSignature() .getDeclaringType(), nftm.getSignature().getParameterTypes()); } else { throw new BCException("Not sure what this is: " + methodCtorMunger); } String name = lookingFor.getName(); String paramSignature = lookingFor.getParameterSignature(); for (LazyMethodGen member : clazz.getMethodGens()) { if (member.getName().equals(name) && member.getParameterSignature().equals(paramSignature)) { return member; } } return null; }
} else if (element.getMunger() instanceof NewConstructorTypeMunger) { NewConstructorTypeMunger nctm = (NewConstructorTypeMunger) element.getMunger(); itdMatch = declA.matches(nctm.getSignature(), world);