public void addAnnotation(AnnotationAJ annotation) { realMember.addAnnotation(annotation); }
public boolean canBeParameterized() { return realMember.canBeParameterized(); }
public int compareTo(Member other) { return realMember.compareTo(other); }
ResolvedType fromType = world.resolve(introduced.getDeclaringType(), munger.getSourceLocation()); if (fromType.isRawType()) { fromType = fromType.getGenericType(); Type bcelReturnType = BcelWorld.makeBcelType(introduced.getReturnType()); List<LazyMethodGen> existingMethods = gen.getMethodGens(); for (LazyMethodGen m : existingMethods) { if (m.getName().equals(introduced.getName()) && m.getParameterSignature().equals(introduced.getParameterSignature()) && m.getReturnType().equals(bcelReturnType)) { isOK = true; + introduced.getDeclaringType() + "'", weaver.getLazyClassGen().getType().getSourceLocation(), true, new ISourceLocation[] { munger.getSourceLocation() }); weaver.getWorld().getMessageHandler().handleMessage(msg); LazyMethodGen mg = new LazyMethodGen(introduced.getModifiers() - Modifier.ABSTRACT, bcelReturnType, introduced.getName(), BcelWorld.makeBcelTypes(introduced.getParameterTypes()), BcelWorld.makeBcelTypesAsClassNames(introduced.getExceptions()), gen); ResolvedType toLookOn = weaver.getWorld().lookupOrCreateName(introduced.getDeclaringType()); if (fromType.isRawType()) { toLookOn = fromType.getGenericType(); if (introduced.getName().equals(m.getName()) && introduced.getSignature().equals(m.getSignature())) { annotationsOnRealMember = m.getAnnotations(); break;
UnresolvedType memberHostType = declaredSig.getDeclaringType(); boolean containsKey = mapToAnnotationHolder.containsKey(rm); ResolvedMember realAnnotationHolder = mapToAnnotationHolder.get(rm); String methodName = declaredSig.getName(); if (rm.getKind() == Member.FIELD) { if (methodName.startsWith("ajc$inlineAccessField")) { realAnnotationHolder = world.resolve(rm); } else if (rm.getKind() == Member.METHOD && !rm.isAbstract()) { if (methodName.startsWith("ajc$inlineAccessMethod") || methodName.startsWith("ajc$superDispatch")) { realAnnotationHolder = world.resolve(declaredSig); } else { ResolvedMember realthing = AjcMemberMaker.interMethodDispatcher(rm.resolve(world), memberHostType).resolve(world); realAnnotationHolder = findResolvedMemberNamed(memberHostType.resolve(world), realthing.getName(),realthing.getParameterTypes()); if (realAnnotationHolder == null) { throw new UnsupportedOperationException( } else if (rm.getKind() == Member.CONSTRUCTOR) { ResolvedMember realThing = AjcMemberMaker.postIntroducedConstructor(memberHostType.resolve(world),rm.getDeclaringType(), rm.getParameterTypes()); realAnnotationHolder = world.resolve(realThing); AnnotationAJ[] annotations; if (realAnnotationHolder!=null) { annotationTypes = realAnnotationHolder.getAnnotationTypes(); annotations = realAnnotationHolder.getAnnotations(); if (annotationTypes==null) { annotationTypes = ResolvedType.EMPTY_ARRAY;
if (Modifier.isFinal(parent.getModifiers())) { ResolvedType nonItdDeclaringType = child.getDeclaringType().resolve(world); WeaverStateInfo wsi = nonItdDeclaringType.getWeaverState(); if (wsi != null) { if (parent.equalsApartFromDeclaringType(transformer.getSignature())) { return true; child.getSourceLocation(), null); return false; if (world.isInJava5Mode() && parent.getKind() == Member.METHOD) { ResolvedType rtParentReturnType = parent.resolve(world).getGenericReturnType().resolve(world); ResolvedType rtChildReturnType = child.resolve(world).getGenericReturnType().resolve(world); incompatibleReturnTypes = !rtParentReturnType.isAssignableFrom(rtChildReturnType); ResolvedType rtParentReturnType = parent.resolve(world).getGenericReturnType().resolve(world); ResolvedType rtChildReturnType = child.resolve(world).getGenericReturnType().resolve(world); child.getSourceLocation(), parent.getSourceLocation()); return false; if (parent.getKind() == Member.POINTCUT) { UnresolvedType[] pTypes = parent.getParameterTypes(); UnresolvedType[] cTypes = child.getParameterTypes(); if (!Arrays.equals(pTypes, cTypes)) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.ITD_PARAM_TYPE_MISMATCH, parent, child),
ResolvedMember unMangledInterMethod = munger.getSignature().resolve(world); ResolvedType onType = world.resolve(unMangledInterMethod.getDeclaringType(), munger.getSourceLocation()); if (onType.isRawType()) { onType = onType.getGenericType(); && classGen.getLazyMethodGen(unMangledInterMethod.getName(), unMangledInterMethod.getSignature(), true) != null) { annotationsOnRealMember = realMember.getAnnotations(); if (!onInterface && !Modifier.isAbstract(mangledInterMethod.getModifiers())) { InstructionList body = newMethod.getBody(); InstructionFactory fact = classGen.getFactory(); int pos = 0; if (!Modifier.isStatic(unMangledInterMethod.getModifiers())) { body.append(InstructionFactory.createThis()); pos++; Type[] paramTypes = BcelWorld.makeBcelTypes(mangledInterMethod.getParameterTypes()); for (int i = 0, len = paramTypes.length; i < len; i++) { Type paramType = paramTypes[i]; body.append(InstructionFactory.createReturn(BcelWorld.makeBcelType(mangledInterMethod.getReturnType()))); String basicSignature = mangledInterMethod.getSignature(); String genericSignature = ((ResolvedMemberImpl) mangledInterMethod).getSignatureForAttribute(); if (!basicSignature.equals(genericSignature)) {
ResolvedType onType = weaver.getWorld().resolve(field.getDeclaringType(), munger.getSourceLocation()); if (onType.isRawType()) { onType = onType.getGenericType(); annotationsOnRealMember = realMember.getAnnotations(); String basicSignature = field.getSignature(); String genericSignature = field.getReturnType().resolve(weaver.getWorld()).getSignatureForAttribute(); if (Modifier.isStatic(field.getModifiers())) { throw new RuntimeException("unimplemented"); if (fieldgen.getName().equals(field.getName())) { alreadyExists=true; break; String fieldName = newField.getName(); Type fieldType = BcelWorld.makeBcelType(field.getType()); if (!alreadyExists) { weaver.addInitializer(this); String basicSignature = field.getSignature(); String genericSignature = field.getReturnType().resolve(weaver.getWorld()).getSignatureForAttribute(); InstructionList il = new InstructionList(); InstructionFactory fact = gen.getFactory(); if (Modifier.isStatic(field.getModifiers())) { il.append(fact.createFieldAccess(gen.getClassName(), fieldName, fieldType, Constants.GETSTATIC));
.postIntroducedConstructor(typeMunger.getAspectType(), fakerm.getDeclaringType(), fakerm.getParameterTypes()) : AjcMemberMaker.interMethodDispatcher(fakerm, typeMunger.getAspectType())); if (fakerm.getName().equals(getSignature().getName()) && fakerm.getParameterSignature().equals(getSignature().getParameterSignature())) { relevantType = typeMunger.getAspectType(); foundMember = rmm; return foundMember.getAnnotationTypes(); return foundMember.getAnnotationTypes();
boolean foundMatch = false; for (int i = 0; i < ms.length && !foundMatch; i++) { if (ms[i].isAbstract() && ms[i].getParameterTypes().length == 0 && ms[i].getName().equals(k)) { String s = ms[i].getAnnotationDefaultValue(); if (s != null && s.equals(v)) { foundMatch = true; boolean foundMatch = false; for (int i = 0; i < ms.length && !foundMatch; i++) { if (ms[i].isAbstract() && ms[i].getParameterTypes().length == 0 && ms[i].getName().equals(k)) { String s = ms[i].getAnnotationDefaultValue(); if (s != null && s.equals(v)) { foundMatch = true;
for (int i = 0; i < allMethods.length; i++) { ResolvedMember candidate = allMethods[i]; if (candidate.getName().equals(methodName)) { if (candidate.getArity() == params.length) { candidates.add(candidate); UnresolvedType[] candidateParams = candidate.getParameterTypes(); for (int p = 0; p < candidateParams.length; p++) { if (!candidateParams[p].getErasureSignature().equals(params[p].getErasureSignature())) {
if (annotationField.getType().equals(annoFieldOfInterest)) { countOfType++; for (ResolvedMember annotationField : annotationFields) { if (countOfType > 1) { if (!annotationField.getName().equals(name)) { continue; if (!annotationField.getType().getSignature().equals(annoFieldOfInterest.getSignature())) { continue; if (annotationField.getType().getSignature().equals("I")) { int ivalue = Integer.parseInt(annotationField.getAnnotationDefaultValue()); il.append(fact.createConstant(ivalue)); foundValueInAnnotationUsage = true; break; } else if (annotationField.getType().getSignature().equals("Ljava/lang/String;")) { String svalue = annotationField.getAnnotationDefaultValue(); il.append(fact.createConstant(svalue)); foundValueInAnnotationUsage = true; break; } else { String dvalue = annotationField.getAnnotationDefaultValue();
BcelWorld.fromBcel(method.getReturnType()),method.getName(), BcelWorld.fromBcel(method.getArgumentTypes()),UnresolvedType.forNames(method.getDeclaredExceptions())); resolvedmember.setAnnotationTypes(method.getAnnotationTypes()); resolvedmember.setAnnotations(method.getAnnotations()); resolvedmember.addAnnotation(decam.getAnnotation()); resolvedmember.addAnnotation(decam.getAnnotation()); AsmRelationshipProvider.addDeclareAnnotationMethodRelationship(decam.getSourceLocation(),
ResolvedType onType = newConstructorMember.getDeclaringType().resolve(weaver.getWorld()); if (onType.isRawType()) { onType = onType.getGenericType(); newConstructorTypeMunger.getSignature().getParameterTypes()); AnnotationAJ annotationsOnRealMember[] = null; ResolvedMember realMember = getRealMemberForITDFromAspect(aspectType, interMethodDispatcher, true); annotationsOnRealMember = realMember.getAnnotations(); UnresolvedType[] declaredParams = newConstructorTypeMunger.getSignature().getParameterTypes(); Type[] paramTypes = mg.getArgumentTypes(); int frameIndex = 1; UnresolvedType[] superParamTypes = explicitConstructor.getParameterTypes();
/** * @return the type of the annotation */ public ResolvedType getAnnotationType() { if (annotationType == null) { String annotationMethod = annotationMethods.get(0); for (Iterator<ResolvedMember> iter = containingAspect.getMethods(true, true); iter.hasNext();) { ResolvedMember member = iter.next(); if (member.getName().equals(annotationMethod)) { ResolvedType[] annoTypes = member.getAnnotationTypes(); if (annoTypes == null) { // if weaving broken code, this can happen return null; } int idx = 0; if (annoTypes[0].getSignature().equals("Lorg/aspectj/internal/lang/annotation/ajcDeclareAnnotation;")) { idx = 1; } annotationType = annoTypes[idx]; break; } } } return annotationType; }
/** * The annotation specified in the declare @type is stored against a simple method of the form "ajc$declare_<NN>", this method * finds that method and retrieves the annotation */ private void ensureAnnotationDiscovered() { if (annotation != null) { return; } String annotationMethod = annotationMethods.get(0); for (Iterator<ResolvedMember> iter = containingAspect.getMethods(true, true); iter.hasNext();) { ResolvedMember member = iter.next(); if (member.getName().equals(annotationMethod)) { AnnotationAJ[] annos = member.getAnnotations(); if (annos == null) { // if weaving broken code, this can happen return; } int idx = 0; if (annos.length > 0 && annos[0].getType().getSignature().equals("Lorg/aspectj/internal/lang/annotation/ajcDeclareAnnotation;")) { idx = 1; } annotation = annos[idx]; break; } } }
/** * Apply the specified declare @field construct to any matching fields in the specified type. * @param deca the declare annotation targeting fields * @param type the type to check for members matching the declare annotation * @return true if something matched and the type was modified */ private boolean applyDeclareAtField(DeclareAnnotation deca, ResolvedType type) { boolean changedType = false; ResolvedMember[] fields = type.getDeclaredFields(); for (ResolvedMember field: fields) { if (deca.matches(field, this)) { AnnotationAJ anno = deca.getAnnotation(); if (!field.hasAnnotation(anno.getType())) { field.addAnnotation(anno); changedType=true; } } } return changedType; }
isChanged = true; AsmRelationshipProvider.addDeclareAnnotationRelationship(asmManager, decaMC.getSourceLocation(), unMangledInterMethod.getSourceLocation(), false); reportMethodCtorWeavingMessage(clazz, unMangledInterMethod, decaMC, -1); modificationOccured = true; unMangledInterMethod.addAnnotation(decaMC.getAnnotation()); AsmRelationshipProvider.addDeclareAnnotationRelationship(asmManager, decaMC.getSourceLocation(), unMangledInterMethod.getSourceLocation(), false); isChanged = true; modificationOccured = true;
public AnnotationAJ[] getAnnotations() { return realMember.getAnnotations(); }
public ResolvedType[] getAnnotationTypes() { return realMember.getAnnotationTypes(); }