*/
public class AtAjAttributes {
- private final static List EMPTY_LIST = new ArrayList();
+ private final static List<AjAttribute> NO_ATTRIBUTES = Collections.emptyList();
private final static String[] EMPTY_STRINGS = new String[0];
private final static String VALUE = "value";
private final static String ARGNAMES = "argNames";
/**
* The list of AjAttribute.XXX that we are populating from the @AJ read
*/
- List ajAttributes = new ArrayList();
+ List<AjAttribute> ajAttributes = new ArrayList<AjAttribute>();
/**
* The resolved type (class) for which we are reading @AJ for (be it class, method, field annotations)
IMessageHandler msgHandler, boolean isCodeStyleAspect) {
boolean ignoreThisClass = javaClass.getClassName().charAt(0) == 'o'
&& javaClass.getClassName().startsWith("org.aspectj.lang.annotation");
- if (ignoreThisClass)
- return EMPTY_LIST;
+ if (ignoreThisClass) {
+ return NO_ATTRIBUTES;
+ }
boolean containsPointcut = false;
boolean containsAnnotationClassReference = false;
Constant[] cpool = javaClass.getConstantPool().getConstantPool();
}
}
if (!containsAnnotationClassReference)
- return EMPTY_LIST;
+ return NO_ATTRIBUTES;
AjAttributeStruct struct = new AjAttributeStruct(type, context, msgHandler);
Attribute[] attributes = javaClass.getAttributes();
msgHandler.handleMessage(new Message("Found @DeclarePrecedence on a non @Aspect type '" + type.getName() + "'",
IMessage.WARNING, null, type.getSourceLocation()));
// bypass what we have read
- return EMPTY_LIST;
+ return NO_ATTRIBUTES;
}
// the following block will not detect @Pointcut in non @Aspect types
// for optimization purpose
if (!(hasAtAspectAnnotation || isCodeStyleAspect) && !containsPointcut) {
- return EMPTY_LIST;
+ return NO_ATTRIBUTES;
}
// FIXME AV - turn on when ajcMightHaveAspect
// supplied as just the class return value of the annotated method
ElementNameValuePairGen interfaceListSpecified = getAnnotationElement(declareMixinAnnotation, "interfaces");
- List newParents = new ArrayList(1);
- List newInterfaceTypes = new ArrayList(1);
+ List<TypePattern> newParents = new ArrayList<TypePattern>(1);
+ List<ResolvedType> newInterfaceTypes = new ArrayList<ResolvedType>(1);
if (interfaceListSpecified != null) {
ArrayElementValueGen arrayOfInterfaceTypes = (ArrayElementValueGen) interfaceListSpecified.getValue();
int numberOfTypes = arrayOfInterfaceTypes.getElementValuesArraySize();
throw new UnreadableDebugInfoException();
}
- List bindings = new ArrayList();
+ List<FormalBinding> bindings = new ArrayList<FormalBinding>();
for (int i = 0; i < argumentNames.length; i++) {
String argumentName = argumentNames[i];
UnresolvedType argumentType = UnresolvedType.forSignature(method.getArgumentTypes()[i].getSignature());
}
}
- return (FormalBinding[]) bindings.toArray(new FormalBinding[] {});
+ return bindings.toArray(new FormalBinding[] {});
}
// FIXME alex deal with exclude index
* Return the argNames set for an annotation or null if it is not specified.
*/
private static String getArgNamesValue(AnnotationGen anno) {
- for (Iterator iterator1 = anno.getValues().iterator(); iterator1.hasNext();) {
- ElementNameValuePairGen element = (ElementNameValuePairGen) iterator1.next();
+ List<ElementNameValuePairGen> elements = anno.getValues();
+ for (ElementNameValuePairGen element : elements) {
if (ARGNAMES.equals(element.getNameString())) {
return element.getValue().stringifyValue();
}
}
final int startAtStackIndex = method.isStatic() ? 0 : 1;
- final List arguments = new ArrayList();
+ final List<MethodArgument> arguments = new ArrayList<MethodArgument>();
LocalVariableTable lt = method.getLocalVariableTable();
if (lt != null) {
for (int j = 0; j < lt.getLocalVariableTable().length; j++) {
// No debug info, do we have an annotation value we can rely on?
if (argNamesFromAnnotation != null) {
StringTokenizer st = new StringTokenizer(argNamesFromAnnotation, " ,");
- List args = new ArrayList();
+ List<String> args = new ArrayList<String>();
while (st.hasMoreTokens()) {
args.add(st.nextToken());
}
+ shortString.toString() + "'", methodStruct);
return EMPTY_STRINGS;
}
- return (String[]) args.toArray(new String[] {});
+ return args.toArray(new String[] {});
}
}
});
String[] argumentNames = new String[arguments.size()];
int i = 0;
- for (Iterator iterator = arguments.iterator(); iterator.hasNext(); i++) {
- MethodArgument methodArgument = (MethodArgument) iterator.next();
- argumentNames[i] = methodArgument.name;
+ for (MethodArgument methodArgument : arguments) {
+ argumentNames[i++] = methodArgument.name;
}
return argumentNames;
}
m_binding = binding;
}
+ @Override
public Pointcut getPointcut() {
if (m_lazyPointcut == null && m_pointcutUnresolved != null) {
m_lazyPointcut = m_pointcutUnresolved.resolve(m_binding);
}
}
- private static void reportError(String message, IMessageHandler handler, ISourceLocation sourceLocation) {
- if (!handler.isIgnoring(IMessage.ERROR)) {
- handler.handleMessage(new Message(message, sourceLocation, true));
- }
- }
+ // private static void reportError(String message, IMessageHandler handler, ISourceLocation sourceLocation) {
+ // if (!handler.isIgnoring(IMessage.ERROR)) {
+ // handler.handleMessage(new Message(message, sourceLocation, true));
+ // }
+ // }
/**
* Report a warning
import org.aspectj.weaver.BCException;
import org.aspectj.weaver.IEclipseSourceContext;
import org.aspectj.weaver.ISourceContext;
+import org.aspectj.weaver.Lint;
import org.aspectj.weaver.Member;
import org.aspectj.weaver.ReferenceType;
import org.aspectj.weaver.ReferenceTypeDelegate;
return adviceSignature;
}
+ @Override
public ShadowMunger concretize(ResolvedType fromType, World world, PerClause clause) {
suppressLintWarnings(world);
ShadowMunger ret = super.concretize(fromType, world, clause);
return ret;
}
+ @Override
public ShadowMunger parameterizeWith(ResolvedType declaringType, Map typeVariableMap) {
Pointcut pc = getPointcut().parameterizeWith(typeVariableMap, declaringType.getWorld());
return ret;
}
+ @Override
public boolean match(Shadow shadow, World world) {
suppressLintWarnings(world);
boolean ret = super.match(shadow, world);
return ret;
}
+ @Override
public void specializeOn(Shadow shadow) {
if (getKind() == AdviceKind.Around) {
((BcelShadow) shadow).initializeForAroundClosure();
return boType.getLazyClassGen().isWoven();
}
+ @Override
public boolean implementOn(Shadow s) {
hasMatchedAtLeastOnce = true;
BcelShadow shadow = (BcelShadow) s;
private Collection thrownExceptions = null;
+ @Override
public Collection getThrownExceptions() {
if (thrownExceptions == null) {
// ??? can we really lump in Around here, how does this interact with Throwable
*
* @return
*/
+ @Override
public boolean mustCheckExceptions() {
if (getConcreteAspect() == null) {
return true;
}
// only call me after prepare has been called
+ @Override
public boolean hasDynamicTests() {
// if (hasExtraParameter() && getKind() == AdviceKind.AfterReturning) {
// UnresolvedType extraParameterType = getExtraParameterType();
return new InstructionList(Utility.createInvoke(shadow.getFactory(), shadow.getWorld(), getOriginalSignature()));
}
+ @Override
public Member getOriginalSignature() {
Member sig = getSignature();
if (sig instanceof ResolvedMember) {
if (signature instanceof BcelMethod) {
this.suppressedLintKinds = Utility.getSuppressedWarnings(signature.getAnnotations(), inWorld.getLint());
} else {
- this.suppressedLintKinds = Collections.EMPTY_LIST;
+ this.suppressedLintKinds = Collections.emptyList();
}
}
inWorld.getLint().suppressKinds(suppressedLintKinds);
}
- protected void clearLintSuppressions(World inWorld, Collection toClear) {
+ protected void clearLintSuppressions(World inWorld, Collection<Lint.Kind> toClear) {
inWorld.getLint().clearSuppressions(toClear);
}
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
/**
* {@inheritDoc}
*/
+ @Override
public Set<String> getTargets() {
if (!type.equals(UnresolvedType.AT_TARGET)) {
return Collections.emptySet();
}
- List values = bcelAnnotation.getValues();
- ElementNameValuePairGen envp = (ElementNameValuePairGen) values.get(0);
+ List<ElementNameValuePairGen> values = bcelAnnotation.getValues();
+ ElementNameValuePairGen envp = values.get(0);
ArrayElementValueGen aev = (ArrayElementValueGen) envp.getValue();
ElementValueGen[] evs = aev.getElementValuesArray();
- Set targets = new HashSet();
+ Set<String> targets = new HashSet<String>();
for (int i = 0; i < evs.length; i++) {
EnumElementValueGen ev = (EnumElementValueGen) evs[i];
targets.add(ev.getEnumValueString());
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasNameValuePair(String name, String value) {
return bcelAnnotation.hasNameValuePair(name, value);
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean hasNamedValue(String name) {
return bcelAnnotation.hasNamedValue(name);
}
/**
* {@inheritDoc}
*/
+ @Override
public String stringify() {
StringBuffer sb = new StringBuffer();
sb.append("@").append(type.getClassName());
- List values = bcelAnnotation.getValues();
+ List<ElementNameValuePairGen> values = bcelAnnotation.getValues();
if (values != null && values.size() != 0) {
sb.append("(");
- for (Iterator iterator = values.iterator(); iterator.hasNext();) {
- ElementNameValuePairGen nvPair = (ElementNameValuePairGen) iterator.next();
+ for (ElementNameValuePairGen nvPair : values) {
sb.append(nvPair.getNameString()).append("=").append(nvPair.getValue().stringifyValue());
}
sb.append(")");
/**
* {@inheritDoc}
*/
+ @Override
public boolean isRuntimeVisible() {
return this.bcelAnnotation.isRuntimeVisible();
}
* {@inheritDoc}
*/
public String getStringFormOfValue(String name) {
- List annotationValues = this.bcelAnnotation.getValues();
+ List<ElementNameValuePairGen> annotationValues = this.bcelAnnotation.getValues();
if (annotationValues == null || annotationValues.size() == 0) {
return null;
} else {
- for (Iterator iterator = annotationValues.iterator(); iterator.hasNext();) {
- ElementNameValuePairGen nvPair = (ElementNameValuePairGen) iterator.next();
+ for (ElementNameValuePairGen nvPair : annotationValues) {
if (nvPair.getNameString().equals(name)) {
return nvPair.getValue().stringifyValue();
}
if (annotationsToAdd == null)
annotationsToAdd = new ArrayList();
- AnnotationGen a = ((BcelAnnotation) decaM.getAnnotationX()).getBcelAnnotation();
+ AnnotationGen a = ((BcelAnnotation) decaM.getAnnotation()).getBcelAnnotation();
AnnotationGen ag = new AnnotationGen(a, clazz.getConstantPool(), true);
annotationsToAdd.add(ag);
- mg.addAnnotation(decaM.getAnnotationX());
+ mg.addAnnotation(decaM.getAnnotation());
AsmRelationshipProvider.addDeclareAnnotationMethodRelationship(decaM.getSourceLocation(), clazz
.getName(), mg.getMemberView(), world.getModelAsAsmManager());// getMethod());
if (annotationsToAdd == null) {
annotationsToAdd = new ArrayList();
}
- AnnotationGen a = ((BcelAnnotation) decaM.getAnnotationX()).getBcelAnnotation();
+ AnnotationGen a = ((BcelAnnotation) decaM.getAnnotation()).getBcelAnnotation();
// create copy to get the annotation type into the right constant pool
AnnotationGen ag = new AnnotationGen(a, clazz.getConstantPool(), true);
annotationsToAdd.add(ag);
- mg.addAnnotation(decaM.getAnnotationX());
+ mg.addAnnotation(decaM.getAnnotation());
AsmRelationshipProvider.addDeclareAnnotationMethodRelationship(decaM.getSourceLocation(), clazz
.getName(), mg.getMemberView(), world.getModelAsAsmManager());// getMethod());
isChanged = true;
LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors))
continue; // skip this one...
- annotationHolder.addAnnotation(decaF.getAnnotationX());
+ annotationHolder.addAnnotation(decaF.getAnnotation());
AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(), decaF
.getSourceLocation(), itdIsActually.getSourceLocation());
isChanged = true;
LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, fieldMunger);
if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors))
continue; // skip this one...
- annotationHolder.addAnnotation(decaF.getAnnotationX());
+ annotationHolder.addAnnotation(decaF.getAnnotation());
AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(), decaF
.getSourceLocation(), itdIsActually.getSourceLocation());
isChanged = true;
|| doesAlreadyHaveAnnotation(annotationHolder, unMangledInterMethod, decaMC, reportedErrors)) {
continue; // skip this one...
}
- annotationHolder.addAnnotation(decaMC.getAnnotationX());
+ annotationHolder.addAnnotation(decaMC.getAnnotation());
isChanged = true;
AsmRelationshipProvider.addDeclareAnnotationRelationship(asmManager, decaMC.getSourceLocation(),
unMangledInterMethod.getSourceLocation());
LazyMethodGen annotationHolder = locateAnnotationHolderForFieldMunger(clazz, methodctorMunger);
if (doesAlreadyHaveAnnotation(annotationHolder, unMangledInterMethod, decaMC, reportedErrors))
continue; // skip this one...
- annotationHolder.addAnnotation(decaMC.getAnnotationX());
- unMangledInterMethod.addAnnotation(decaMC.getAnnotationX());
+ annotationHolder.addAnnotation(decaMC.getAnnotation());
+ unMangledInterMethod.addAnnotation(decaMC.getAnnotation());
AsmRelationshipProvider.addDeclareAnnotationRelationship(asmManager, decaMC.getSourceLocation(),
unMangledInterMethod.getSourceLocation());
isChanged = true;
private boolean dontAddTwice(DeclareAnnotation decaF, AnnotationAJ[] dontAddMeTwice) {
for (int i = 0; i < dontAddMeTwice.length; i++) {
AnnotationAJ ann = dontAddMeTwice[i];
- if (ann != null && decaF.getAnnotationX().getTypeName().equals(ann.getTypeName())) {
+ if (ann != null && decaF.getAnnotation().getTypeName().equals(ann.getTypeName())) {
// dontAddMeTwice[i] = null; // incase it really has been added
// twice!
return true;
// go through all the declare @field statements
for (Iterator iter = decaFs.iterator(); iter.hasNext();) {
DeclareAnnotation decaF = (DeclareAnnotation) iter.next();
- if (decaF.getAnnotationX() == null) {
+ if (decaF.getAnnotation() == null) {
return false;
}
if (decaF.matches(aBcelField, world)) {
continue;
}
- if (decaF.getAnnotationX().isRuntimeVisible()) { // isAnnotationWithRuntimeRetention
+ if (decaF.getAnnotation().isRuntimeVisible()) { // isAnnotationWithRuntimeRetention
// (
// clazz
// .
// myGen.addAnnotation(ag);
// Field newField = myGen.getField();
- aBcelField.addAnnotation(decaF.getAnnotationX());
+ aBcelField.addAnnotation(decaF.getAnnotation());
// clazz.replaceField(fields[fieldCounter],
// newField);
// fields[fieldCounter]=newField;
} else {
- aBcelField.addAnnotation(decaF.getAnnotationX());
+ aBcelField.addAnnotation(decaF.getAnnotation());
}
}
unusedDecafs.remove(decaF);
continue; // skip this one...
}
- aBcelField.addAnnotation(decaF.getAnnotationX());
+ aBcelField.addAnnotation(decaF.getAnnotation());
AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(), decaF
.getSourceLocation(), clazz.getName(), aBcelField);
isChanged = true;
private void unpackAttributes(World world) {
Attribute[] attrs = field.getAttributes();
if (attrs != null && attrs.length > 0) {
- List as = Utility.readAjAttributes(getDeclaringType().getClassName(), attrs, getSourceContext(world), world,
- (bcelObjectType != null ? bcelObjectType.getWeaverVersionAttribute() : WeaverVersionInfo.CURRENT));
+ List<AjAttribute> as = Utility.readAjAttributes(getDeclaringType().getClassName(), attrs, getSourceContext(world),
+ world, (bcelObjectType != null ? bcelObjectType.getWeaverVersionAttribute() : WeaverVersionInfo.CURRENT));
as.addAll(AtAjAttributes.readAj5FieldAttributes(field, this, world.resolve(getDeclaringType()),
getSourceContext(world), world.getMessageHandler()));
- for (Iterator iter = as.iterator(); iter.hasNext();) {
- AjAttribute a = (AjAttribute) iter.next();
+ for (AjAttribute a : as) {
if (a instanceof AjAttribute.AjSynthetic) {
isAjSynthetic = true;
} else {
}
+ @Override
public String[] getParameterNames() {
determineParameterNames();
return super.getParameterNames();
|| typename.startsWith("org.aspectj.lang.annotation.After")) {
AnnotationGen a = ((BcelAnnotation) annotationX).getBcelAnnotation();
if (a != null) {
- List values = a.getValues();
- for (Iterator iterator = values.iterator(); iterator.hasNext();) {
- ElementNameValuePairGen nvPair = (ElementNameValuePairGen) iterator.next();
+ List<ElementNameValuePairGen> values = a.getValues();
+ for (ElementNameValuePairGen nvPair : values) {
if (nvPair.getNameString().equals("argNames")) {
String argNames = nvPair.getValue().stringifyValue();
StringTokenizer argNameTokenizer = new StringTokenizer(argNames, " ,");
- List argsList = new ArrayList();
+ List<String> argsList = new ArrayList<String>();
while (argNameTokenizer.hasMoreTokens()) {
argsList.add(argNameTokenizer.nextToken());
}
while (argsList.size() < requiredCount) {
argsList.add("arg" + argsList.size());
}
- setParameterNames((String[]) argsList.toArray(new String[] {}));
+ setParameterNames(argsList.toArray(new String[] {}));
return;
}
}
// return null;
// }
+ @Override
public String getAnnotationDefaultValue() {
Attribute[] attrs = method.getAttributes();
for (int i = 0; i < attrs.length; i++) {
// for testing - use with the method above
public String[] getAttributeNames(boolean onlyIncludeAjOnes) {
Attribute[] as = method.getAttributes();
- List names = new ArrayList();
+ List<String> names = new ArrayList<String>();
// String[] strs = new String[as.length];
for (int j = 0; j < as.length; j++) {
- if (!onlyIncludeAjOnes || as[j].getName().startsWith(AjAttribute.AttributePrefix))
+ if (!onlyIncludeAjOnes || as[j].getName().startsWith(AjAttribute.AttributePrefix)) {
names.add(as[j].getName());
+ }
}
- return (String[]) names.toArray(new String[] {});
+ return names.toArray(new String[] {});
}
+ @Override
public boolean isAjSynthetic() {
return (bitflags & IS_AJ_SYNTHETIC) != 0;
}
// FIXME ??? needs an isSynthetic method
+ @Override
public ShadowMunger getAssociatedShadowMunger() {
return associatedShadowMunger;
}
+ @Override
public AjAttribute.EffectiveSignatureAttribute getEffectiveSignature() {
return effectiveSignature;
}
}
}
+ @Override
public ISourceLocation getSourceLocation() {
ISourceLocation ret = super.getSourceLocation();
if ((ret == null || ret.getLine() == 0) && hasDeclarationLineNumberInfo()) {
return ret;
}
+ @Override
public MemberKind getKind() {
if (associatedShadowMunger != null) {
return ADVICE;
}
}
+ @Override
public boolean hasAnnotation(UnresolvedType ofType) {
ensureAnnotationsRetrieved();
for (Iterator iter = annotationTypes.iterator(); iter.hasNext();) {
return false;
}
+ @Override
public AnnotationAJ[] getAnnotations() {
ensureAnnotationsRetrieved();
if ((bitflags & HAS_ANNOTATIONS) != 0) {
}
}
+ @Override
public ResolvedType[] getAnnotationTypes() {
ensureAnnotationsRetrieved();
ResolvedType[] ret = new ResolvedType[annotationTypes.size()];
return ret;
}
+ @Override
public AnnotationAJ getAnnotationOfType(UnresolvedType ofType) {
ensureAnnotationsRetrieved();
if ((bitflags & HAS_ANNOTATIONS) == 0)
return null;
}
+ @Override
public void addAnnotation(AnnotationAJ annotation) {
ensureAnnotationsRetrieved();
if ((bitflags & HAS_ANNOTATIONS) == 0) {
}
}
+ @Override
public AnnotationAJ[][] getParameterAnnotations() {
ensureParameterAnnotationsRetrieved();
return parameterAnnotations;
}
+ @Override
public ResolvedType[][] getParameterAnnotationTypes() {
ensureParameterAnnotationsRetrieved();
return parameterAnnotationTypes;
* A method can be parameterized if it has one or more generic parameters. A generic parameter (type variable parameter) is
* identified by the prefix "T"
*/
+ @Override
public boolean canBeParameterized() {
unpackGenericSignature();
return (bitflags & CAN_BE_PARAMETERIZED) != 0;
}
+ @Override
public UnresolvedType[] getGenericParameterTypes() {
unpackGenericSignature();
return genericParameterTypes;
/**
* Return the parameterized/generic return type or the normal return type if the method is not generic.
*/
+ @Override
public UnresolvedType getGenericReturnType() {
unpackGenericSignature();
return genericReturnType;
}
}
+ @Override
public void evictWeavingState() {
if (method != null) {
unpackGenericSignature();
}
}
+ @Override
public boolean isSynthetic() {
if ((bitflags & KNOW_IF_SYNTHETIC) == 0) {
workOutIfSynthetic();
// which proved expensive. Currently used within
// CrosscuttingMembers.replaceWith() to decide if we need
// to do a full build
+ @Override
public boolean isEquivalentTo(Object other) {
if (!(other instanceof BcelMethod))
return false;
*
* @return true if this BcelMethod represents the default constructor
*/
+ @Override
public boolean isDefaultConstructor() {
boolean mightBe = !hasDeclarationLineNumberInfo() && name.equals("<init>") && parameterTypes.length == 0;
if (mightBe) {
import org.aspectj.weaver.AnnotationTargetKind;
import org.aspectj.weaver.BCException;
import org.aspectj.weaver.BindingScope;
+import org.aspectj.weaver.ConcreteTypeMunger;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.ReferenceType;
import org.aspectj.weaver.ResolvedMember;
private ResolvedMember[] privilegedAccess = null;
private WeaverStateInfo weaverState = null;
private PerClause perClause = null;
- private List typeMungers = Collections.EMPTY_LIST;
- private List declares = Collections.EMPTY_LIST;
+ private List<ConcreteTypeMunger> typeMungers = Collections.emptyList();
+ private List<Declare> declares = Collections.emptyList();
private GenericSignature.FormalTypeParameter[] formalsForResolution = null;
private String declaredSignature = null;
bitflag |= UNPACKED_AJATTRIBUTES;
IMessageHandler msgHandler = getResolvedTypeX().getWorld().getMessageHandler();
// Pass in empty list that can store things for readAj5 to process
- List l = Utility.readAjAttributes(className, javaClass.getAttributes(), getResolvedTypeX().getSourceContext(),
+ List<AjAttribute> l = Utility.readAjAttributes(className, javaClass.getAttributes(), getResolvedTypeX().getSourceContext(),
getResolvedTypeX().getWorld(), AjAttribute.WeaverVersionInfo.UNKNOWN);
List pointcuts = new ArrayList();
typeMungers = new ArrayList();
}
- private AjAttribute.Aspect processAttributes(List attributeList, List pointcuts, boolean fromAnnotations) {
+ private AjAttribute.Aspect processAttributes(List<AjAttribute> attributeList, List<ResolvedPointcutDefinition> pointcuts,
+ boolean fromAnnotations) {
AjAttribute.Aspect deferredAspectAttribute = null;
- for (Iterator iter = attributeList.iterator(); iter.hasNext();) {
- AjAttribute a = (AjAttribute) iter.next();
- // System.err.println("unpacking: " + this + " and " + a);
+ for (AjAttribute a : attributeList) {
if (a instanceof AjAttribute.Aspect) {
if (fromAnnotations) {
deferredAspectAttribute = (AjAttribute.Aspect) a;
bitflag |= DISCOVERED_ANNOTATION_TARGET_KINDS;
annotationTargetKinds = null; // null means we have no idea or the
// @Target annotation hasn't been used
- List targetKinds = new ArrayList();
+ List<AnnotationTargetKind> targetKinds = new ArrayList<AnnotationTargetKind>();
if (isAnnotation()) {
AnnotationAJ[] annotationsOnThisType = getAnnotations();
for (int i = 0; i < annotationsOnThisType.length; i++) {
AnnotationAJ a = annotationsOnThisType[i];
if (a.getTypeName().equals(UnresolvedType.AT_TARGET.getName())) {
- Set targets = a.getTargets();
+ Set<String> targets = a.getTargets();
if (targets != null) {
- for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
- String targetKind = (String) iterator.next();
+ for (String targetKind : targets) {
if (targetKind.equals("ANNOTATION_TYPE")) {
targetKinds.add(AnnotationTargetKind.ANNOTATION_TYPE);
} else if (targetKind.equals("CONSTRUCTOR")) {
}
if (!targetKinds.isEmpty()) {
annotationTargetKinds = new AnnotationTargetKind[targetKinds.size()];
- return (AnnotationTargetKind[]) targetKinds.toArray(annotationTargetKinds);
+ return targetKinds.toArray(annotationTargetKinds);
}
}
return annotationTargetKinds;
public BcelShadow copyInto(LazyMethodGen recipient, BcelShadow enclosing) {
BcelShadow s = new BcelShadow(world, getKind(), getSignature(), recipient, enclosing);
if (mungers.size() > 0) {
- List src = mungers;
- if (s.mungers == Collections.EMPTY_LIST)
- s.mungers = new ArrayList();
- List dest = s.mungers;
-
- for (Iterator i = src.iterator(); i.hasNext();) {
+ List<ShadowMunger> src = mungers;
+ if (s.mungers == Collections.EMPTY_LIST) {
+ s.mungers = new ArrayList<ShadowMunger>();
+ }
+ List<ShadowMunger> dest = s.mungers;
+ for (Iterator<ShadowMunger> i = src.iterator(); i.hasNext();) {
dest.add(i.next());
}
}
}
// records advice that is stopping us doing the lazyTjp optimization
- private List badAdvice = null;
+ private List<BcelAdvice> badAdvice = null;
public void addAdvicePreventingLazyTjp(BcelAdvice advice) {
if (badAdvice == null)
- badAdvice = new ArrayList();
+ badAdvice = new ArrayList<BcelAdvice>();
badAdvice.add(advice);
}
// something stopped us making it a lazy tjp
// can't build tjp lazily, no suitable test...
int valid = 0;
- for (Iterator iter = badAdvice.iterator(); iter.hasNext();) {
- BcelAdvice element = (BcelAdvice) iter.next();
+ for (Iterator<BcelAdvice> iter = badAdvice.iterator(); iter.hasNext();) {
+ BcelAdvice element = iter.next();
ISourceLocation sLoc = element.getSourceLocation();
if (sLoc != null && sLoc.getLine() > 0)
valid++;
if (valid != 0) {
ISourceLocation[] badLocs = new ISourceLocation[valid];
int i = 0;
- for (Iterator iter = badAdvice.iterator(); iter.hasNext();) {
- BcelAdvice element = (BcelAdvice) iter.next();
+ for (Iterator<BcelAdvice> iter = badAdvice.iterator(); iter.hasNext();) {
+ BcelAdvice element = iter.next();
ISourceLocation sLoc = element.getSourceLocation();
if (sLoc != null)
badLocs[i++] = sLoc;
private BcelVar thisVar = null;
private BcelVar targetVar = null;
private BcelVar[] argVars = null;
- private Map/* <UnresolvedType,BcelVar> */kindedAnnotationVars = null;
- private Map/* <UnresolvedType,BcelVar> */thisAnnotationVars = null;
- private Map/* <UnresolvedType,BcelVar> */targetAnnotationVars = null;
+ private Map/* <UnresolvedType,BcelVar> */<ResolvedType, AnnotationAccessVar> kindedAnnotationVars = null;
+ private Map/* <UnresolvedType,BcelVar> */<ResolvedType, TypeAnnotationAccessVar> thisAnnotationVars = null;
+ private Map/* <UnresolvedType,BcelVar> */<ResolvedType, TypeAnnotationAccessVar> targetAnnotationVars = null;
private Map/* <UnresolvedType,BcelVar> */[] argAnnotationVars = null;
- private Map/* <UnresolvedType,BcelVar> */withinAnnotationVars = null;
- private Map/* <UnresolvedType,BcelVar> */withincodeAnnotationVars = null;
+ private Map/* <UnresolvedType,BcelVar> */<ResolvedType, AnnotationAccessVar> withinAnnotationVars = null;
+ private Map/* <UnresolvedType,BcelVar> */<ResolvedType, AnnotationAccessVar> withincodeAnnotationVars = null;
private boolean allArgVarsInitialized = false;
public Var getThisVar() {
}
initializeThisAnnotationVars(); // FIXME asc Why bother with this if we always return one?
// Even if we can't find one, we have to return one as we might have this annotation at runtime
- Var v = (Var) thisAnnotationVars.get(forAnnotationType);
+ Var v = thisAnnotationVars.get(forAnnotationType);
if (v == null)
v = new TypeAnnotationAccessVar(forAnnotationType.resolve(world), (BcelVar) getThisVar());
return v;
throw new IllegalStateException("no target");
}
initializeTargetAnnotationVars(); // FIXME asc why bother with this if we always return one?
- Var v = (Var) targetAnnotationVars.get(forAnnotationType);
+ Var v = targetAnnotationVars.get(forAnnotationType);
// Even if we can't find one, we have to return one as we might have this annotation at runtime
if (v == null)
v = new TypeAnnotationAccessVar(forAnnotationType.resolve(world), (BcelVar) getTargetVar());
public Var getKindedAnnotationVar(UnresolvedType forAnnotationType) {
initializeKindedAnnotationVars();
- return (Var) kindedAnnotationVars.get(forAnnotationType);
+ return kindedAnnotationVars.get(forAnnotationType);
}
public Var getWithinAnnotationVar(UnresolvedType forAnnotationType) {
initializeWithinAnnotationVars();
- return (Var) withinAnnotationVars.get(forAnnotationType);
+ return withinAnnotationVars.get(forAnnotationType);
}
public Var getWithinCodeAnnotationVar(UnresolvedType forAnnotationType) {
initializeWithinCodeAnnotationVars();
- return (Var) withincodeAnnotationVars.get(forAnnotationType);
+ return withincodeAnnotationVars.get(forAnnotationType);
}
// reflective thisJoinPoint support
public void initializeThisAnnotationVars() {
if (thisAnnotationVars != null)
return;
- thisAnnotationVars = new HashMap();
+ thisAnnotationVars = new HashMap<ResolvedType, TypeAnnotationAccessVar>();
// populate..
}
initializeThisAnnotationVars();
targetAnnotationVars = thisAnnotationVars;
} else {
- targetAnnotationVars = new HashMap();
+ targetAnnotationVars = new HashMap<ResolvedType, TypeAnnotationAccessVar>();
ResolvedType[] rtx = this.getTargetType().resolve(world).getAnnotationTypes(); // what about annotations we havent
// gotten yet but we will get in
// subclasses?
}
// check the ITD'd dooberries
- List mungers = relevantType.resolve(world).getInterTypeMungers();
- for (Iterator iter = mungers.iterator(); iter.hasNext();) {
- ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) iter.next();
+ List<ConcreteTypeMunger> mungers = relevantType.resolve(world).getInterTypeMungers();
+ for (ConcreteTypeMunger typeMunger : mungers) {
if (typeMunger.getMunger() instanceof NewMethodTypeMunger || typeMunger.getMunger() instanceof NewConstructorTypeMunger) {
ResolvedMember fakerm = typeMunger.getSignature();
if (fakerm.getName().equals(getSignature().getName())
foundMember = AjcMemberMaker.interConstructor(relevantType, foundMember, typeMunger.getAspectType());
} else {
foundMember = AjcMemberMaker.interMethod(foundMember, typeMunger.getAspectType(), false);
+ // ResolvedMember o = AjcMemberMaker.interMethodBody(fakerm, typeMunger.getAspectType());
+ // // Object os = o.getAnnotations();
+ // ResolvedMember foundMember2 = findMethod(typeMunger.getAspectType(), o);
+ // Object os2 = foundMember2.getAnnotations();
+ // int stop = 1;
+ // foundMember = foundMember2;
+ // foundMember = AjcMemberMaker.interMethod(foundMember, typeMunger.getAspectType());
}
// in the above.. what about if it's on an Interface? Can that happen?
// then the last arg of the above should be true
protected ResolvedType[] getAnnotations(ResolvedMember foundMember, Member relevantMember, ResolvedType relevantType) {
if (foundMember == null) {
// check the ITD'd dooberries
- List mungers = relevantType.resolve(world).getInterTypeMungers();
- for (Iterator iter = mungers.iterator(); iter.hasNext();) {
+ List<ConcreteTypeMunger> mungers = relevantType.resolve(world).getInterTypeMungers();
+ for (Iterator<ConcreteTypeMunger> iter = mungers.iterator(); iter.hasNext();) {
Object munger = iter.next();
ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) munger;
if (typeMunger.getMunger() instanceof NewMethodTypeMunger
if (kindedAnnotationVars != null) {
return;
}
- kindedAnnotationVars = new HashMap();
+ kindedAnnotationVars = new HashMap<ResolvedType, AnnotationAccessVar>();
ResolvedType[] annotations = null;
Member shadowSignature = getSignature();
if (annotationHolder == null) {
// check the ITD'd dooberries
- List mungers = relevantType.resolve(world).getInterTypeMungers();
- for (Iterator iter = mungers.iterator(); iter.hasNext();) {
- BcelTypeMunger typeMunger = (BcelTypeMunger) iter.next();
+ List<BcelTypeMunger> mungers = relevantType.resolve(world).getInterTypeMungers();
+ for (BcelTypeMunger typeMunger : mungers) {
+ // for (Iterator<ConcreteTypeMunger> iter = mungers.iterator(); iter.hasNext();) {
+ // BcelTypeMunger typeMunger = (BcelTypeMunger) iter.next();
if (typeMunger.getMunger() instanceof NewFieldTypeMunger) {
ResolvedMember fakerm = typeMunger.getSignature();
// if (fakerm.hasAnnotations())
} else if (getKind() == Shadow.MethodExecution || getKind() == Shadow.ConstructorExecution
|| getKind() == Shadow.AdviceExecution) {
- // ResolvedMember rm[] = relevantType.getDeclaredMethods();
- ResolvedMember foundMember = findMethod2(relevantType.getDeclaredMethods(), getSignature());
+ ResolvedMember foundMember = findMethod2(relevantType.getDeclaredMethods(), getSignature());
annotations = getAnnotations(foundMember, shadowSignature, relevantType);
- annotationHolder = foundMember;
annotationHolder = getRelevantMember(foundMember, annotationHolder, relevantType);
+ UnresolvedType ut = annotationHolder.getDeclaringType();
+ relevantType = ut.resolve(world);
} else if (getKind() == Shadow.ExceptionHandler) {
relevantType = getSignature().getParameterTypes()[0].resolve(world);
throw new BCException("Could not discover annotations for shadow: " + getKind());
}
- for (int i = 0; i < annotations.length; i++) {
- ResolvedType annotationType = annotations[i];
+ for (ResolvedType annotationType : annotations) {
AnnotationAccessVar accessVar = new AnnotationAccessVar(getKind(), annotationType.resolve(world), relevantType,
annotationHolder);
kindedAnnotationVars.put(annotationType, accessVar);
}
}
- // FIXME asc whats the real diff between this one and the version in findMethod()?
- ResolvedMember findMethod2(ResolvedMember rm[], Member sig) {
- ResolvedMember found = null;
- // String searchString = getSignature().getName()+getSignature().getParameterSignature();
- for (int i = 0; i < rm.length && found == null; i++) {
- ResolvedMember member = rm[i];
- if (member.getName().equals(sig.getName()) && member.getParameterSignature().equals(sig.getParameterSignature()))
- found = member;
+ private ResolvedMember findMethod2(ResolvedMember members[], Member sig) {
+ String signatureName = sig.getName();
+ String parameterSignature = sig.getParameterSignature();
+ for (ResolvedMember member : members) {
+ if (member.getName().equals(signatureName) && member.getParameterSignature().equals(parameterSignature)) {
+ return member;
+ }
}
- return found;
+ return null;
}
private ResolvedMember findMethod(ResolvedType aspectType, ResolvedMember ajcMethod) {
public void initializeWithinAnnotationVars() {
if (withinAnnotationVars != null)
return;
- withinAnnotationVars = new HashMap();
+ withinAnnotationVars = new HashMap<ResolvedType, AnnotationAccessVar>();
ResolvedType[] annotations = getEnclosingType().resolve(world).getAnnotationTypes();
for (int i = 0; i < annotations.length; i++) {
public void initializeWithinCodeAnnotationVars() {
if (withincodeAnnotationVars != null)
return;
- withincodeAnnotationVars = new HashMap();
+ withincodeAnnotationVars = new HashMap<ResolvedType, AnnotationAccessVar>();
// For some shadow we are interested in annotations on the method containing that shadow.
ResolvedType[] annotations = getEnclosingMethod().getMemberView().getAnnotationTypes();
* We also need to bind the return value into a returning parameter, if the advice specified one.
*/
public void weaveAfterReturning(BcelAdvice munger) {
- List returns = findReturnInstructions();
+ List<InstructionHandle> returns = findReturnInstructions();
boolean hasReturnInstructions = !returns.isEmpty();
// list of instructions that handle the actual return from the join point
if (hasReturnInstructions) {
InstructionHandle gotoTarget = advice.getStart();
- for (Iterator i = returns.iterator(); i.hasNext();) {
- InstructionHandle ih = (InstructionHandle) i.next();
+ for (Iterator<InstructionHandle> i = returns.iterator(); i.hasNext();) {
+ InstructionHandle ih = i.next();
retargetReturnInstruction(munger.hasExtraParameter(), returnValueVar, gotoTarget, ih);
}
}
/**
* @return a list of all the return instructions in the range of this shadow
*/
- private List findReturnInstructions() {
- List returns = new ArrayList();
+ private List<InstructionHandle> findReturnInstructions() {
+ List<InstructionHandle> returns = new ArrayList<InstructionHandle>();
for (InstructionHandle ih = range.getStart(); ih != range.getEnd(); ih = ih.getNext()) {
if (ih.getInstruction().isReturnInstruction()) {
returns.add(ih);
* @param returnInstructions instruction list into which the return instructions should be generated
* @return the variable holding the return value, if needed
*/
- private BcelVar generateReturnInstructions(List returns, InstructionList returnInstructions) {
+ private BcelVar generateReturnInstructions(List<InstructionHandle> returns, InstructionList returnInstructions) {
BcelVar returnValueVar = null;
if (this.hasANonVoidReturnType()) {
// Find the last *correct* return - this is a method with a non-void return type
Instruction newReturnInstruction = null;
int i = returns.size() - 1;
while (newReturnInstruction == null && i >= 0) {
- InstructionHandle ih = (InstructionHandle) returns.get(i);
+ InstructionHandle ih = returns.get(i);
if (ih.getInstruction().opcode != Constants.RETURN) {
newReturnInstruction = Utility.copyInstruction(ih.getInstruction());
}
returnValueVar.appendLoad(returnInstructions, getFactory());
returnInstructions.append(newReturnInstruction);
} else {
- InstructionHandle lastReturnHandle = (InstructionHandle) returns.get(returns.size() - 1);
+ InstructionHandle lastReturnHandle = returns.get(returns.size() - 1);
Instruction newReturnInstruction = Utility.copyInstruction(lastReturnHandle.getInstruction());
returnInstructions.append(newReturnInstruction);
}
// Parameters are: this if there is one, target if there is one and its different to this, then original arguments
// at the shadow, then tjp
String extractedShadowMethodName = NameMangler.aroundShadowMethodName(getSignature(), shadowClass.getNewGeneratedNameTag());
- List parameterNames = new ArrayList();
+ List<String> parameterNames = new ArrayList<String>();
LazyMethodGen extractedShadowMethod = extractShadowInstructionsIntoNewMethod(extractedShadowMethodName, Modifier.PRIVATE,
munger.getSourceLocation(), parameterNames);
- List argsToCallLocalAdviceMethodWith = new ArrayList();
- List proceedVarList = new ArrayList();
+ List<BcelVar> argsToCallLocalAdviceMethodWith = new ArrayList<BcelVar>();
+ List<BcelVar> proceedVarList = new ArrayList<BcelVar>();
int extraParamOffset = 0;
// Create the extra parameters that are needed for passing to proceed
InstructionList advice = new InstructionList();
// InstructionHandle adviceMethodInvocation;
{
- for (Iterator i = argsToCallLocalAdviceMethodWith.iterator(); i.hasNext();) {
- BcelVar var = (BcelVar) i.next();
+ for (Iterator<BcelVar> i = argsToCallLocalAdviceMethodWith.iterator(); i.hasNext();) {
+ BcelVar var = i.next();
var.appendLoad(advice, fact);
}
// ??? we don't actually need to push NULL for the closure if we take care
// no parameter names specified
argumentName = new StringBuffer("unknown").append(argNumber).toString();
} else {
- argumentName = (String) parameterNames.get(argNumber);
+ argumentName = parameterNames.get(argNumber);
}
String argumentSignature = args[argNumber].getSignature();
LocalVariableTag lvt = new LocalVariableTag(argumentSignature, argumentName, slot, 0);
}
private InstructionList getRedoneProceedCall(InstructionFactory fact, LazyMethodGen callbackMethod, BcelAdvice munger,
- LazyMethodGen localAdviceMethod, List argVarList) {
+ LazyMethodGen localAdviceMethod, List<BcelVar> argVarList) {
InstructionList ret = new InstructionList();
// we have on stack all the arguments for the ADVICE call.
// we have in frame somewhere all the arguments for the non-advice call.
// throw new RuntimeException("unimplemented");
proceedVars[proceedMap.get(i)].appendLoadAndConvert(ret, fact, stateTypeX);
} else {
- ((BcelVar) argVarList.get(i)).appendLoad(ret, fact);
+ argVarList.get(i).appendLoad(ret, fact);
}
}
*
*/
private InstructionList getRedoneProceedCallForAnnotationStyle(InstructionFactory fact, LazyMethodGen callbackMethod,
- BcelAdvice munger, LazyMethodGen localAdviceMethod, List argVarList, boolean isProceedWithArgs) {
+ BcelAdvice munger, LazyMethodGen localAdviceMethod, List<BcelVar> argVarList, boolean isProceedWithArgs) {
InstructionList ret = new InstructionList();
// store the Object[] array on stack if proceed with args
int linenumber = getSourceLine();
// MOVE OUT ALL THE INSTRUCTIONS IN MY SHADOW INTO ANOTHER METHOD!
LazyMethodGen callbackMethod = extractShadowInstructionsIntoNewMethod(NameMangler.aroundShadowMethodName(getSignature(),
- getEnclosingClass().getNewGeneratedNameTag()), 0, munger.getSourceLocation(), new ArrayList());
+ getEnclosingClass().getNewGeneratedNameTag()), 0, munger.getSourceLocation(), new ArrayList<String>());
BcelVar[] adviceVars = munger.getExposedStateAsBcelVars(true);
* @param adviceSourceLocation source location of the advice affecting the shadow
*/
LazyMethodGen extractShadowInstructionsIntoNewMethod(String extractedMethodName, int extractedMethodVisibilityModifier,
- ISourceLocation adviceSourceLocation, List parameterNames) {
+ ISourceLocation adviceSourceLocation, List<String> parameterNames) {
// LazyMethodGen.assertGoodBody(range.getBody(), extractedMethodName);
if (!getKind().allowsExtraction()) {
throw new BCException("Attempt to extract method from a shadow kind (" + getKind()
* The new method always static. It may take some extra arguments: this, target. If it's argsOnStack, then it must take both
* this/target If it's argsOnFrame, it shares this and target. ??? rewrite this to do less array munging, please
*/
- private LazyMethodGen createShadowMethodGen(String newMethodName, int visibilityModifier, List parameterNames) {
+ private LazyMethodGen createShadowMethodGen(String newMethodName, int visibilityModifier, List<String> parameterNames) {
Type[] shadowParameterTypes = BcelWorld.makeBcelTypes(getArgTypes());
int modifiers = Modifier.FINAL | Modifier.STATIC | visibilityModifier;
if (targetVar != null && targetVar != thisVar) {
// private Map /*String,UnwovenClassFile*/sourceJavaClasses = new HashMap();
// private Map /*String,UnwovenClassFile*/resources = new HashMap();
- private transient List /* UnwovenClassFile */addedClasses = new ArrayList();
- private transient List /* String */deletedTypenames = new ArrayList();
+ private transient List<UnwovenClassFile> addedClasses = new ArrayList<UnwovenClassFile>();
+ private transient List<String> deletedTypenames = new ArrayList<String>();
private transient List shadowMungerList = null; // setup by prepareForWeave
private transient List typeMungerList = null; // setup by prepareForWeave
private transient List lateTypeMungerList = null; // setup by prepareForWeave
* @throws IOException
*/
public void addLibraryJarFile(File inFile) throws IOException {
- List addedAspects = null;
+ List<ResolvedType> addedAspects = null;
if (inFile.isDirectory()) {
addedAspects = addAspectsFromDirectory(inFile);
} else {
addedAspects = addAspectsFromJarFile(inFile);
}
- for (Iterator i = addedAspects.iterator(); i.hasNext();) {
- ResolvedType aspectX = (ResolvedType) i.next();
+ for (Iterator<ResolvedType> i = addedAspects.iterator(); i.hasNext();) {
+ ResolvedType aspectX = i.next();
xcutSet.addOrReplaceAspect(aspectX);
}
}
- private List addAspectsFromJarFile(File inFile) throws FileNotFoundException, IOException {
+ private List<ResolvedType> addAspectsFromJarFile(File inFile) throws FileNotFoundException, IOException {
ZipInputStream inStream = new ZipInputStream(new FileInputStream(inFile)); // ??? buffered
- List addedAspects = new ArrayList();
+ List<ResolvedType> addedAspects = new ArrayList<ResolvedType>();
try {
while (true) {
ZipEntry entry = inStream.getNextEntry();
return addedAspects;
}
- private List addAspectsFromDirectory(File dir) throws FileNotFoundException, IOException {
- List addedAspects = new ArrayList();
+ private List<ResolvedType> addAspectsFromDirectory(File dir) throws FileNotFoundException, IOException {
+ List<ResolvedType> addedAspects = new ArrayList<ResolvedType>();
File[] classFiles = FileUtil.listFiles(dir, new FileFilter() {
public boolean accept(File pathname) {
return addedAspects;
}
- private void addIfAspect(byte[] bytes, String name, List toList, File dir) throws IOException {
+ private void addIfAspect(byte[] bytes, String name, List<ResolvedType> toList, File dir) throws IOException {
ClassParser parser = new ClassParser(new ByteArrayInputStream(bytes), name);
JavaClass jc = parser.parse();
ResolvedType type = world.addSourceObjectType(jc).getResolvedTypeX();
* subdirectories) are considered resources and are also copied.
*
*/
- public List addDirectoryContents(File inFile, File outDir) throws IOException {
- List addedClassFiles = new ArrayList();
+ public List<UnwovenClassFile> addDirectoryContents(File inFile, File outDir) throws IOException {
+ List<UnwovenClassFile> addedClassFiles = new ArrayList<UnwovenClassFile>();
// Get a list of all files (i.e. everything that isnt a directory)
File[] files = FileUtil.listFiles(inFile, new FileFilter() {
/**
* Adds all class files in the jar
*/
- public List addJarFile(File inFile, File outDir, boolean canBeDirectory) {
+ public List<UnwovenClassFile> addJarFile(File inFile, File outDir, boolean canBeDirectory) {
// System.err.println("? addJarFile(" + inFile + ", " + outDir + ")");
- List addedClassFiles = new ArrayList();
+ List<UnwovenClassFile> addedClassFiles = new ArrayList<UnwovenClassFile>();
needToReweaveWorld = true;
JarFile inJar = null;
needToReweaveWorld = xcutSet.hasChangedSinceLastReset();
// update mungers
- for (Iterator i = addedClasses.iterator(); i.hasNext();) {
- UnwovenClassFile jc = (UnwovenClassFile) i.next();
+ for (Iterator<UnwovenClassFile> i = addedClasses.iterator(); i.hasNext();) {
+ UnwovenClassFile jc = i.next();
String name = jc.getClassName();
ResolvedType type = world.resolve(name);
// System.err.println("added: " + type + " aspect? " +
}
}
- for (Iterator i = deletedTypenames.iterator(); i.hasNext();) {
- String name = (String) i.next();
+ for (Iterator<String> i = deletedTypenames.iterator(); i.hasNext();) {
+ String name = i.next();
if (xcutSet.deleteAspect(UnresolvedType.forName(name))) {
needToReweaveWorld = true;
}
private void addCustomMungers() {
if (customMungerFactory != null) {
- for (Iterator i = addedClasses.iterator(); i.hasNext();) {
- UnwovenClassFile jc = (UnwovenClassFile) i.next();
+ for (Iterator<UnwovenClassFile> i = addedClasses.iterator(); i.hasNext();) {
+ UnwovenClassFile jc = i.next();
String name = jc.getClassName();
ResolvedType type = world.resolve(name);
if (type.isAspect()) {
// across the set of pointcuts....
// Use a map from key based on pc equality, to value based on
// pc identity.
- Map/* <Pointcut,Pointcut> */pcMap = new HashMap();
+ Map/* <Pointcut,Pointcut> */<Pointcut, Pointcut> pcMap = new HashMap<Pointcut, Pointcut>();
for (Iterator iter = shadowMungers.iterator(); iter.hasNext();) {
ShadowMunger munger = (ShadowMunger) iter.next();
Pointcut p = munger.getPointcut();
}
}
- private Pointcut shareEntriesFromMap(Pointcut p, Map pcMap) {
+ private Pointcut shareEntriesFromMap(Pointcut p, Map<Pointcut, Pointcut> pcMap) {
// some things cant be shared...
if (p instanceof NameBindingPointcut) {
return p;
} else {
// primitive pcd
if (pcMap.containsKey(p)) { // based on equality
- return (Pointcut) pcMap.get(p); // same instance (identity)
+ return pcMap.get(p); // same instance (identity)
} else {
pcMap.put(p, p);
return p;
// we know that every branch binds every formal, so there is no
// ambiguity
// if each branch binds it in exactly the same way...
- List ambiguousNames = new ArrayList();
+ List<String> ambiguousNames = new ArrayList<String>();
for (int i = 0; i < numFormals; i++) {
if (leftBindings[i] == null) {
if (rightBindings[i] != null) {
/**
* @param userPointcut
*/
- private void raiseAmbiguityInDisjunctionError(Pointcut userPointcut, List names) {
+ private void raiseAmbiguityInDisjunctionError(Pointcut userPointcut, List<String> names) {
StringBuffer formalNames = new StringBuffer(names.get(0).toString());
for (int i = 1; i < names.size(); i++) {
formalNames.append(", ");
// ---- weaving
// Used by some test cases only...
- public Collection weave(File file) throws IOException {
+ public Collection<String> weave(File file) throws IOException {
OutputStream os = FileUtil.makeOutputStream(file);
this.zipOutputStream = new ZipOutputStream(os);
prepareForWeave();
- Collection c = weave(new IClassFileProvider() {
+ Collection<String> c = weave(new IClassFileProvider() {
public boolean isApplyAtAspectJMungersOnly() {
return false;
}
- public Iterator getClassFileIterator() {
+ public Iterator<UnwovenClassFile> getClassFileIterator() {
return addedClasses.iterator();
}
// }
// variation of "weave" that sources class files from an external source.
- public Collection weave(IClassFileProvider input) throws IOException {
+ public Collection<String> weave(IClassFileProvider input) throws IOException {
if (trace.isTraceEnabled()) {
trace.enter("weave", this, input);
}
ContextToken weaveToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING, "");
- Collection wovenClassNames = new ArrayList();
+ Collection<String> wovenClassNames = new ArrayList<String>();
IWeaveRequestor requestor = input.getRequestor();
- for (Iterator i = input.getClassFileIterator(); i.hasNext();) {
- UnwovenClassFile classFile = (UnwovenClassFile) i.next();
+ for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
+ UnwovenClassFile classFile = i.next();
if (world.getModel() != null /* AsmManager.isCreatingModel() */&& !isBatchWeave) {
// remove all relationships where this file being woven is the
// target of the relationship
// Go through the types and ensure any 'damaged' during compile time are
// repaired prior to weaving
- for (Iterator i = input.getClassFileIterator(); i.hasNext();) {
- UnwovenClassFile classFile = (UnwovenClassFile) i.next();
+ for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
+ UnwovenClassFile classFile = i.next();
String className = classFile.getClassName();
ResolvedType theType = world.resolve(className);
if (theType != null) {
requestor.weavingAspects();
// ContextToken aspectToken =
CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_ASPECTS, "");
- for (Iterator i = input.getClassFileIterator(); i.hasNext();) {
- UnwovenClassFile classFile = (UnwovenClassFile) i.next();
+ for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
+ UnwovenClassFile classFile = i.next();
String className = classFile.getClassName();
ResolvedType theType = world.resolve(className);
if (theType.isAnnotationStyleAspect()) {
CompilationAndWeavingContext.PROCESSING_REWEAVABLE_STATE, "");
prepareToProcessReweavableState();
// clear all state from files we'll be reweaving
- for (Iterator i = input.getClassFileIterator(); i.hasNext();) {
- UnwovenClassFile classFile = (UnwovenClassFile) i.next();
+ for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
+ UnwovenClassFile classFile = i.next();
String className = classFile.getClassName();
BcelObjectType classType = getClassType(className);
// encountered).
// For class A, the order is superclasses of A then superinterfaces of A
// (and this mechanism is applied recursively)
- List typesToProcess = new ArrayList();
- for (Iterator iter = input.getClassFileIterator(); iter.hasNext();) {
- UnwovenClassFile clf = (UnwovenClassFile) iter.next();
+ List<String> typesToProcess = new ArrayList<String>();
+ for (Iterator<UnwovenClassFile> iter = input.getClassFileIterator(); iter.hasNext();) {
+ UnwovenClassFile clf = iter.next();
typesToProcess.add(clf.getClassName());
}
while (typesToProcess.size() > 0) {
- weaveParentsFor(typesToProcess, (String) typesToProcess.get(0));
+ weaveParentsFor(typesToProcess, typesToProcess.get(0));
}
- for (Iterator i = input.getClassFileIterator(); i.hasNext();) {
- UnwovenClassFile classFile = (UnwovenClassFile) i.next();
+ for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
+ UnwovenClassFile classFile = i.next();
String className = classFile.getClassName();
addNormalTypeMungers(className);
}
requestor.weavingAspects();
ContextToken aspectToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_ASPECTS, "");
// first weave into aspects
- for (Iterator i = input.getClassFileIterator(); i.hasNext();) {
- UnwovenClassFile classFile = (UnwovenClassFile) i.next();
+ for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
+ UnwovenClassFile classFile = i.next();
String className = classFile.getClassName();
ResolvedType theType = world.resolve(className);
if (theType.isAspect()) {
requestor.weavingClasses();
ContextToken classToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_CLASSES, "");
// then weave into non-aspects
- for (Iterator i = input.getClassFileIterator(); i.hasNext();) {
- UnwovenClassFile classFile = (UnwovenClassFile) i.next();
+ for (Iterator<UnwovenClassFile> i = input.getClassFileIterator(); i.hasNext();) {
+ UnwovenClassFile classFile = i.next();
String className = classFile.getClassName();
ResolvedType theType = world.resolve(className);
if (!theType.isAspect()) {
// put out a warning
if (world.isInJava5Mode() && world.getLint().adviceDidNotMatch.isEnabled()) {
List l = world.getCrosscuttingMembersSet().getShadowMungers();
- Set alreadyWarnedLocations = new HashSet();
+ Set<AdviceLocation> alreadyWarnedLocations = new HashSet<AdviceLocation>();
for (Iterator iter = l.iterator(); iter.hasNext();) {
ShadowMunger element = (ShadowMunger) iter.next();
* A>B>C and only give A and C to the weaver, it may choose to weave them in either order - but you'll probably have other
* problems if you are supplying partial hierarchies like that !
*/
- private void weaveParentsFor(List typesForWeaving, String typeToWeave) {
+ private void weaveParentsFor(List<String> typesForWeaving, String typeToWeave) {
// Look at the supertype first
ResolvedType rtx = world.resolve(typeToWeave);
ResolvedType superType = rtx.getSuperclass();
if (aspectsPreviouslyInWorld != null) {
// keep track of them just to ensure unique missing aspect error
// reporting
- Set alreadyConfirmedReweavableState = new HashSet();
+ Set<String> alreadyConfirmedReweavableState = new HashSet<String>();
for (Iterator iter = aspectsPreviouslyInWorld.iterator(); iter.hasNext();) {
String requiredTypeName = (String) iter.next();
if (!alreadyConfirmedReweavableState.contains(requiredTypeName)) {
}
onType.clearInterTypeMungers();
- List decpToRepeat = new ArrayList();
+ List<DeclareParents> decpToRepeat = new ArrayList<DeclareParents>();
boolean aParentChangeOccurred = false;
boolean anAnnotationChangeOccurred = false;
while ((aParentChangeOccurred || anAnnotationChangeOccurred) && !decpToRepeat.isEmpty()) {
anAnnotationChangeOccurred = aParentChangeOccurred = false;
- List decpToRepeatNextTime = new ArrayList();
- for (Iterator iter = decpToRepeat.iterator(); iter.hasNext();) {
- DeclareParents decp = (DeclareParents) iter.next();
+ List<DeclareParents> decpToRepeatNextTime = new ArrayList<DeclareParents>();
+ for (Iterator<DeclareParents> iter = decpToRepeat.iterator(); iter.hasNext();) {
+ DeclareParents decp = iter.next();
boolean typeChanged = applyDeclareParents(decp, onType);
if (typeChanged) {
aParentChangeOccurred = true;
private boolean applyDeclareAtType(DeclareAnnotation decA, ResolvedType onType, boolean reportProblems) {
boolean didSomething = false;
if (decA.matches(onType)) {
- AnnotationAJ theAnnotation = decA.getAnnotationX();
+ AnnotationAJ theAnnotation = decA.getAnnotation();
// can be null for broken code!
if (theAnnotation == null) {
return false;
return false;
}
- AnnotationAJ annoX = decA.getAnnotationX();
+ AnnotationAJ annoX = decA.getAnnotation();
// check the annotation is suitable for the target
boolean problemReported = verifyTargetIsOK(decA, onType, annoX, reportProblems);
return null;
}
- List shadowMungers = fastMatch(shadowMungerList, classType.getResolvedTypeX());
+ List<ShadowMunger> shadowMungers = fastMatch(shadowMungerList, classType.getResolvedTypeX());
List typeMungers = classType.getResolvedTypeX().getInterTypeMungers();
classType.getResolvedTypeX().checkInterTypeMungers();
zipOutputStream.closeEntry();
}
- private List fastMatch(List list, ResolvedType type) {
+ private List<ShadowMunger> fastMatch(List list, ResolvedType type) {
if (list == null) {
return Collections.EMPTY_LIST;
}
// weaving
FastMatchInfo info = new FastMatchInfo(type, null);
- List result = new ArrayList();
+ List<ShadowMunger> result = new ArrayList<ShadowMunger>();
Iterator iter = list.iterator();
while (iter.hasNext()) {
ShadowMunger munger = (ShadowMunger) iter.next();
throw new RuntimeException("Shadow.determineRelKind: What the hell is it? " + ak);
}
+ @Override
public void reportMatch(ShadowMunger munger, Shadow shadow) {
if (getCrossReferenceHandler() != null) {
getCrossReferenceHandler().addCrossReference(munger.getSourceLocation(), // What is being applied
return nice.toString();
}
- private static List makeDefaultClasspath(String cp) {
- List classPath = new ArrayList();
+ private static List<String> makeDefaultClasspath(String cp) {
+ List<String> classPath = new ArrayList<String>();
classPath.addAll(getPathEntries(cp));
classPath.addAll(getPathEntries(ClassPath.getClassPath()));
return classPath;
}
- private static List getPathEntries(String s) {
- List ret = new ArrayList();
+ private static List<String> getPathEntries(String s) {
+ List<String> ret = new ArrayList<String>();
StringTokenizer tok = new StringTokenizer(s, File.pathSeparator);
-
- while (tok.hasMoreTokens())
+ while (tok.hasMoreTokens()) {
ret.add(tok.nextToken());
-
+ }
return ret;
}
return resolve(fromBcel(t));
}
+ @Override
protected ReferenceTypeDelegate resolveDelegate(ReferenceType ty) {
String name = ty.getName();
ensureAdvancedConfigurationProcessed();
return MemberImpl.method(declaringType, modifier, name, signature);
}
+ @Override
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("BcelWorld(");
* The aim of this method is to make sure a particular type is 'ok'. Some operations on the delegate for a type modify it and
* this method is intended to undo that... see pr85132
*/
+ @Override
public void validateType(UnresolvedType type) {
ResolvedType result = typeMap.get(type.getSignature());
if (result == null)
boolean didSomething = false;
if (decA.matches(onType)) {
- if (onType.hasAnnotation(decA.getAnnotationX().getType())) {
+ if (onType.hasAnnotation(decA.getAnnotation().getType())) {
// already has it
return false;
}
- AnnotationAJ annoX = decA.getAnnotationX();
+ AnnotationAJ annoX = decA.getAnnotation();
// check the annotation is suitable for the target
boolean isOK = checkTargetOK(decA, onType, annoX);
protected void weaveInterTypeDeclarations(ResolvedType onType) {
List declareParentsList = getCrosscuttingMembersSet().getDeclareParents();
- if (onType.isRawType())
+ if (onType.isRawType()) {
onType = onType.getGenericType();
+ }
onType.clearInterTypeMungers();
List decpToRepeat = new ArrayList();
}
}
+ @Override
public IWeavingSupport getWeavingSupport() {
return bcelWeavingSupport;
}
+ @Override
public void reportCheckerMatch(Checker checker, Shadow shadow) {
IMessage iMessage = new Message(checker.getMessage(), shadow.toString(), checker.isError() ? IMessage.ERROR
: IMessage.WARNING, shadow.getSourceLocation(), null, new ISourceLocation[] { checker.getSourceLocation() }, true,
this.isXmlConfiguredWorld = b;
}
+ @Override
public boolean isXmlConfigured() {
return isXmlConfiguredWorld && xmlConfiguration != null;
}
+ @Override
public boolean isAspectIncluded(ResolvedType aspectType) {
if (!isXmlConfigured()) {
return true;
return xmlConfiguration.specifiesInclusionOfAspect(aspectType.getName());
}
+ @Override
public TypePattern getAspectScope(ResolvedType declaringType) {
return xmlConfiguration.getScopeFor(declaringType.getName());
}
int highestLineNumber = 0; // ---- JSR 45 info
- private final SortedMap /* <String, InlinedSourceFileInfo> */inlinedFiles = new TreeMap();
+ private final SortedMap<String, InlinedSourceFileInfo> inlinedFiles = new TreeMap<String, InlinedSourceFileInfo>();
private boolean regenerateGenericSignatureAttribute = false;
private final World world;
private final String packageName = null;
- private final List /* BcelField */fields = new ArrayList();
- private final List /* LazyMethodGen */methodGens = new ArrayList();
- private final List /* LazyClassGen */classGens = new ArrayList();
- private final List /* AnnotationGen */annotations = new ArrayList();
+ private final List fields = new ArrayList();
+ private final List<LazyMethodGen> methodGens = new ArrayList<LazyMethodGen>();
+ private final List<LazyClassGen> classGens = new ArrayList<LazyClassGen>();
+ private final List<AnnotationGen> annotations = new ArrayList<AnnotationGen>();
private int childCounter = 0;
private final InstructionFactory fact;
void calculateSourceDebugExtensionOffsets() {
int i = roundUpToHundreds(highestLineNumber);
- for (Iterator iter = inlinedFiles.values().iterator(); iter.hasNext();) {
- InlinedSourceFileInfo element = (InlinedSourceFileInfo) iter.next();
+ for (InlinedSourceFileInfo element : inlinedFiles.values()) {
element.offset = i;
i = roundUpToHundreds(i + element.highestLineNumber);
}
}
int getSourceDebugExtensionOffset(String fullpath) {
- return ((InlinedSourceFileInfo) inlinedFiles.get(fullpath)).offset;
+ return inlinedFiles.get(fullpath).offset;
}
// private Unknown getSourceDebugExtensionAttribute() {
return world;
}
- public List getMethodGens() {
+ public List<LazyMethodGen> getMethodGens() {
return methodGens; // ???Collections.unmodifiableList(methodGens);
}
- public List/* BcelField */getFieldGens() {
+ public List<BcelField> getFieldGens() {
return fields;
- // return myGen.getFields();
}
- // public Field getField(String name) {
- // Field[] allFields = myGen.getFields();
- // if (allFields==null) return null;
- // for (int i = 0; i < allFields.length; i++) {
- // Field field = allFields[i];
- // if (field.getName().equals(name)) return field;
- // }
- // return null;
- // }
-
private void writeBack(BcelWorld world) {
if (getConstantPool().getSize() > Short.MAX_VALUE) {
reportClassTooBigProblem();
}
if (annotations.size() > 0) {
- for (Iterator iter = annotations.iterator(); iter.hasNext();) {
- AnnotationGen element = (AnnotationGen) iter.next();
+ for (AnnotationGen element : annotations) {
myGen.addAnnotation(element);
}
// Attribute[] annAttributes =
int len = methodGens.size();
myGen.setMethods(Method.NoMethods);
- for (int i = 0; i < len; i++) {
- LazyMethodGen gen = (LazyMethodGen) methodGens.get(i);
+ for (LazyMethodGen gen : methodGens) {
// we skip empty clinits
- if (isEmptyClinit(gen))
+ if (isEmptyClinit(gen)) {
continue;
+ }
myGen.addMethod(gen.getMethod());
}
}
// non-recursive, may be a bug, ha ha.
- private List getClassGens() {
- List ret = new ArrayList();
+ private List<LazyClassGen> getClassGens() {
+ List<LazyClassGen> ret = new ArrayList<LazyClassGen>();
ret.add(this);
ret.addAll(classGens);
return ret;
public List getChildClasses(BcelWorld world) {
if (classGens.isEmpty())
return Collections.EMPTY_LIST;
- List ret = new ArrayList();
- for (Iterator i = classGens.iterator(); i.hasNext();) {
- LazyClassGen clazz = (LazyClassGen) i.next();
+ List<UnwovenClassFile.ChildClass> ret = new ArrayList<UnwovenClassFile.ChildClass>();
+ for (LazyClassGen clazz : classGens) {
byte[] bytes = clazz.getJavaClass(world).getBytes();
String name = clazz.getName();
int index = name.lastIndexOf('$');
return ret;
}
+ @Override
public String toString() {
return toShortString();
}
}
public LazyMethodGen getStaticInitializer() {
- for (Iterator i = methodGens.iterator(); i.hasNext();) {
- LazyMethodGen gen = (LazyMethodGen) i.next();
+ for (LazyMethodGen gen : methodGens) {
// OPTIMIZE persist kind of member into the gen object? for clinit
if (gen.getName().equals("<clinit>"))
return gen;
private String[] declaredExceptions;
private InstructionList body; // leaving null for abstracts
private List attributes;
- private List newAnnotations;
+ private List<AnnotationAJ> newAnnotations;
private AnnotationAJ[][] newParameterAnnotations;
private final LazyClassGen enclosingClass;
private BcelMethod memberView;
initialize();
if (memberView == null) {
// If member view is null, we manage them in newAnnotations
- if (newAnnotations == null)
- newAnnotations = new ArrayList();
+ if (newAnnotations == null) {
+ newAnnotations = new ArrayList<AnnotationAJ>();
+ }
newAnnotations.add(ax);
} else {
memberView.addAnnotation(ax);
}
}
- public boolean hasAnnotation(UnresolvedType annotationTypeX) {
+ public boolean hasAnnotation(UnresolvedType annotationType) {
initialize();
if (memberView == null) {
// Check local annotations first
if (newAnnotations != null) {
- for (Iterator iter = newAnnotations.iterator(); iter.hasNext();) {
- AnnotationAJ element = (AnnotationAJ) iter.next();
- if (element.getTypeSignature().equals(annotationTypeX.getSignature())) {
+ for (AnnotationAJ annotation : newAnnotations) {
+ if (annotation.getTypeSignature().equals(annotationType.getSignature())) {
return true;
}
}
}
memberView = new BcelMethod(getEnclosingClass().getBcelObjectType(), getMethod());
- return memberView.hasAnnotation(annotationTypeX);
+ return memberView.hasAnnotation(annotationType);
}
- return memberView.hasAnnotation(annotationTypeX);
+ return memberView.hasAnnotation(annotationType);
}
private void initialize() {
// =============================
+ @Override
public String toString() {
BcelObjectType bot = enclosingClass.getBcelObjectType();
WeaverVersionInfo weaverVersion = (bot == null ? WeaverVersionInfo.CURRENT : bot.getWeaverVersionAttribute());
import java.io.File;
import java.io.IOException;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.aspectj.apache.bcel.classfile.JavaClass;
protected byte[] bytes;
// protected JavaClass javaClass = null;
// protected byte[] writtenBytes = null;
- protected List /* ChildClass */writtenChildClasses = Collections.EMPTY_LIST;
+ protected List<ChildClass> writtenChildClasses = Collections.emptyList();
protected String className = null;
public UnwovenClassFile(String filename, byte[] bytes) {
// writtenBytes = bytes;
}
- private void writeChildClasses(List childClasses) throws IOException {
+ private void writeChildClasses(List<ChildClass> childClasses) throws IOException {
// ??? we only really need to delete writtenChildClasses whose
// ??? names aren't in childClasses; however, it's unclear
// ??? how much that will affect performance
childClasses.removeAll(writtenChildClasses); // XXX is this right
- for (Iterator iter = childClasses.iterator(); iter.hasNext();) {
- ChildClass childClass = (ChildClass) iter.next();
+ for (ChildClass childClass : childClasses) {
writeChildClassFile(childClass.name, childClass.bytes);
-
}
writtenChildClasses = childClasses;
}
protected void deleteAllChildClasses() {
- for (Iterator iter = writtenChildClasses.iterator(); iter.hasNext();) {
- ChildClass childClass = (ChildClass) iter.next();
+ for (ChildClass childClass : writtenChildClasses) {
deleteChildClassFile(childClass.name);
}
}
return className;
}
+ @Override
public String toString() {
return "UnwovenClassFile(" + filename + ", " + getClassName() + ")";
}
this.bytes = bytes;
}
+ @Override
public boolean equals(Object other) {
if (!(other instanceof ChildClass))
return false;
return o.name.equals(name) && unchanged(o.bytes, bytes);
}
+ @Override
public int hashCode() {
return name.hashCode();
}
+ @Override
public String toString() {
return "(ChildClass " + name + ")";
}
public class Utility {
- public static List readAjAttributes(String classname, Attribute[] as, ISourceContext context, World w,
+ public static List<AjAttribute> readAjAttributes(String classname, Attribute[] as, ISourceContext context, World w,
AjAttribute.WeaverVersionInfo version) {
- List l = new ArrayList();
+ List<AjAttribute> l = new ArrayList<AjAttribute>();
// first pass, look for version
- List forSecondPass = new ArrayList();
+ List<Unknown> forSecondPass = new ArrayList<Unknown>();
for (int i = as.length - 1; i >= 0; i--) {
Attribute a = as[i];
if (a instanceof Unknown) {
+ " is version " + version.toString());
}
}
- forSecondPass.add(a);
+ forSecondPass.add(u);
}
}
}
}
+ // FIXASC why going backwards? is it important
for (int i = forSecondPass.size() - 1; i >= 0; i--) {
- Unknown a = (Unknown) forSecondPass.get(i);
+ Unknown a = forSecondPass.get(i);
String name = a.getName();
AjAttribute attr = AjAttribute.read(version, name, a.getBytes(), context, w);
- if (attr != null)
+ if (attr != null) {
l.add(attr);
+ }
}
return l;
}
/*
- * Ensure we report a nice source location - particular in the case where
- * the source info is missing (binary weave).
+ * Ensure we report a nice source location - particular in the case where the source info is missing (binary weave).
*/
public static String beautifyLocation(ISourceLocation isl) {
StringBuffer nice = new StringBuffer();
// Lookup table, for converting between pairs of types, it gives
// us the method name in the Conversions class
- private static Hashtable validBoxing = new Hashtable();
+ private static Hashtable<String, String> validBoxing = new Hashtable<String, String>();
static {
validBoxing.put("Ljava/lang/Byte;B", "byteObject");
// before the call...
Type from = BcelWorld.makeBcelType(fromType);
Type to = BcelWorld.makeBcelType(toType);
- String name = (String) validBoxing.get(toType.getSignature() + fromType.getSignature());
+ String name = validBoxing.get(toType.getSignature() + fromType.getSignature());
if (toType.isPrimitiveType()) {
il.append(fact.createInvoke("org.aspectj.runtime.internal.Conversions", name, to, new Type[] { Type.OBJECT },
Constants.INVOKESTATIC));
}
/**
- * replace an instruction handle with another instruction, in this case, a
- * branch instruction.
+ * replace an instruction handle with another instruction, in this case, a branch instruction.
*
* @param ih the instruction handle to replace.
* @param branchInstruction the branch instruction to replace ih with
}
/**
- * delete an instruction handle and retarget all targeters of the deleted
- * instruction to the next instruction. Obviously, this should not be used
- * to delete a control transfer instruction unless you know what you're
- * doing.
+ * delete an instruction handle and retarget all targeters of the deleted instruction to the next instruction. Obviously, this
+ * should not be used to delete a control transfer instruction unless you know what you're doing.
*
* @param ih the instruction handle to delete.
* @param enclosingMethod where to find ih's instruction list.
}
/**
- * delete an instruction handle and retarget all targeters of the deleted
- * instruction to the provided target.
+ * delete an instruction handle and retarget all targeters of the deleted instruction to the provided target.
*
* @param ih the instruction handle to delete
* @param retargetTo the instruction handle to retarget targeters of ih to.
/**
* Fix for Bugzilla #39479, #40109 patch contributed by Andy Clement
*
- * Need to manually copy Select instructions - if we rely on the the 'fresh'
- * object created by copy(), the InstructionHandle array 'targets' inside
- * the Select object will not have been deep copied, so modifying targets in
- * fresh will modify the original Select - not what we want ! (It is a bug
- * in BCEL to do with cloning Select objects).
+ * Need to manually copy Select instructions - if we rely on the the 'fresh' object created by copy(), the InstructionHandle
+ * array 'targets' inside the Select object will not have been deep copied, so modifying targets in fresh will modify the
+ * original Select - not what we want ! (It is a bug in BCEL to do with cloning Select objects).
*
* <pre>
* declare error:
}
/**
- * Checks for suppression specified on the member or on the declaring type
- * of that member
+ * Checks for suppression specified on the member or on the declaring type of that member
*/
public static boolean isSuppressing(Member member, String lintkey) {
boolean isSuppressing = Utils.isSuppressing(member.getAnnotations(), lintkey);
return false;
}
- public static List/* Lint.Kind */getSuppressedWarnings(AnnotationAJ[] anns, Lint lint) {
- if (anns == null)
+ public static List<Lint.Kind> getSuppressedWarnings(AnnotationAJ[] anns, Lint lint) {
+ if (anns == null) {
return Collections.EMPTY_LIST;
+ }
// Go through the annotation types
- List suppressedWarnings = new ArrayList();
+ List<Lint.Kind> suppressedWarnings = new ArrayList<Lint.Kind>();
boolean found = false;
for (int i = 0; !found && i < anns.length; i++) {
// Check for the SuppressAjWarnings annotation
// 1. there are no values specified (i.e. @SuppressAjWarnings)
// 2. there are values specified (i.e. @SuppressAjWarnings("A")
// or @SuppressAjWarnings({"A","B"})
- List vals = ((BcelAnnotation) anns[i]).getBcelAnnotation().getValues();
+ List<ElementNameValuePairGen> vals = ((BcelAnnotation) anns[i]).getBcelAnnotation().getValues();
if (vals == null || vals.isEmpty()) { // (1)
suppressedWarnings.addAll(lint.allKinds());
} else { // (2)