/** * {@inheritDoc} */ public final String getTypeSignature() { return type.getSignature(); }
/** * @return true if the supplied aspect is already in the list of those affecting this type */ public boolean isAspectAlreadyApplied(ResolvedType someAspect) { String someAspectSignature = someAspect.getSignature(); for (String aspectSignature : aspectsAffectingType) { if (aspectSignature.equals(someAspectSignature)) { return true; } } return false; }
public void demote(ResolvedType type) { String key = type.getSignature(); if (debugDemotion) { addedSinceLastDemote.remove(key); } tMap.remove(key); insertInExpendableMap(key, type); }
/** * a parameterized signature starts with a "P" in place of the "L", see the * comment on signatures in UnresolvedType. * * @param aGenericType * @param someParameters * @return */ private static String makeParameterizedSignature(ResolvedType aGenericType, ResolvedType[] someParameters) { String rawSignature = aGenericType.getErasureSignature(); StringBuffer ret = new StringBuffer(); ret.append(PARAMETERIZED_TYPE_IDENTIFIER); ret.append(rawSignature.substring(1, rawSignature.length() - 1)); ret.append("<"); for (int i = 0; i < someParameters.length; i++) { ret.append(someParameters[i].getSignature()); } ret.append(">;"); return ret.toString(); }
public AnnotationAccessFieldVar(AnnotationAccessVar aav, ResolvedType annoFieldOfInterest, String name) { super(annoFieldOfInterest, 0); this.annoAccessor = aav; this.name = name; String sig = annoFieldOfInterest.getSignature(); if (sig.length() == 1) { switch (sig.charAt(0)) { case 'I': elementValueType = ElementValue.PRIMITIVE_INT; break; default: throw new IllegalStateException(sig); } } else if (sig.equals("Ljava/lang/String;")) { elementValueType = ElementValue.STRING; } else if (annoFieldOfInterest.isEnum()) { elementValueType = ElementValue.ENUM_CONSTANT; } else { throw new IllegalStateException(sig); } this.annoFieldOfInterest = annoFieldOfInterest; }
private void moveToNextNewOne() { while (index < len) { ResolvedType interfaceType = array[index]; if (!wantGenerics && interfaceType.isParameterizedOrGenericType()) { interfaceType = interfaceType.getRawType(); } String signature = interfaceType.getSignature(); if (!alreadySeen.contains(signature)) { break; } index++; } }
@Override public final boolean isAssignableFrom(ResolvedType other) { if (!other.isPrimitiveType()) { if (!world.isInJava5Mode()) { return false; } return validBoxing.contains(this.getSignature() + other.getSignature()); } return assignTable[((Primitive) other).index][index]; }
private Set<String> findAspectsForMungers(LazyMethodGen mg) { Set<String> aspectsAffectingType = new HashSet<String>(); for (BcelShadow shadow : mg.matchedShadows) { for (ShadowMunger munger : shadow.getMungers()) { if (munger instanceof BcelAdvice) { BcelAdvice bcelAdvice = (BcelAdvice) munger; if (bcelAdvice.getConcreteAspect() != null) { aspectsAffectingType.add(bcelAdvice.getConcreteAspect().getSignature()); } } else { // It is a 'Checker' - we don't need to remember aspects // that only contributed Checkers... } } } return aspectsAffectingType; }
public ResolvedType next() { if (index < len) { ResolvedType oo = array[index++]; if (!wantGenerics && (oo.isParameterizedType() || oo.isGenericType())) { oo = oo.getRawType(); } alreadySeen.add(oo.getSignature()); moveToNextNewOne(); return oo; } else { throw new NoSuchElementException(); } }
public static ResolvedMember createHandlerMember(Class exceptionType, Class inType, World inWorld) { return new ResolvedMemberImpl(org.aspectj.weaver.Member.HANDLER, toResolvedType(inType, (IReflectionWorld) inWorld), Modifier.STATIC, "<catch>", "(" + inWorld.resolve(exceptionType.getName()).getSignature() + ")V"); }
@Override public AnnotationAJ getAnnotationOfType(UnresolvedType ofType) { unpackAnnotations(false); if (annotationFinder == null || annotationTypes == null) { return null; } for (ResolvedType type : annotationTypes) { if (type.getSignature().equals(ofType.getSignature())) { return annotationFinder.getAnnotationOfType(ofType, reflectMember); } } return null; }
/** * @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; }
/** * Some TypeFactory operations create resolved types directly, but these won't be in the typeMap - this resolution process puts * them there. Resolved types are also told their world which is needed for the special autoboxing resolved types. */ public ResolvedType resolve(ResolvedType ty) { if (ty.isTypeVariableReference()) { return ty; // until type variables have proper sigs... } ResolvedType resolved = typeMap.get(ty.getSignature()); if (resolved == null) { resolved = ensureRawTypeIfNecessary(ty); typeMap.put(ty.getSignature(), resolved); resolved = ty; } resolved.world = this; return resolved; }
/** * 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; } } }
public static ResolvedType makeArray(ResolvedType type, int dim) { if (dim == 0) { return type; } ResolvedType array = new ArrayReferenceType("[" + type.getSignature(), "[" + type.getErasureSignature(), type.getWorld(), type); return makeArray(array, dim - 1); }
public void insertLoad(InstructionList il, InstructionFactory fact) { InstructionList loadInstructions = new InstructionList(); loadInstructions.append(fact.createInvoke(getType().getName(), "aspectOf", "()" + getType().getSignature(), Constants.INVOKESTATIC)); il.insert(loadInstructions); // throw new IllegalStateException(); // il.insert(createLoad(fact)); }
} 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());
private boolean implementsSerializable(ResolvedType aType) { if (aType.getSignature().equals(UnresolvedType.SERIALIZABLE.getSignature())) { return true; } ResolvedType[] interfaces = aType.getDeclaredInterfaces(); for (int i = 0; i < interfaces.length; i++) { if (interfaces[i].isMissing()) { continue; } if (implementsSerializable(interfaces[i])) { return true; } } ResolvedType superType = aType.getSuperclass(); if (superType != null && !superType.isMissing()) { return implementsSerializable(superType); } return false; }
/** * Must take into account generic signature */ public ResolvedType getSuperclass() { if (isObject) { return null; } ResolvedType supertype = superTypeReference.get(); if (supertype == null) { ensureGenericSignatureUnpacked(); if (superclassSignature == null) { if (superclassName == null) { superclassName = javaClass.getSuperclassName(); } superclassSignature = getResolvedTypeX().getWorld().resolve(UnresolvedType.forName(superclassName)).getSignature(); } World world = getResolvedTypeX().getWorld(); supertype = world.resolve(UnresolvedType.forSignature(superclassSignature)); superTypeReference = new WeakReference<ResolvedType>(supertype); } return supertype; }
/** * 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; }