for (int i = 0; i < annos.length; i++) {
AnnotationGen annotation = ((BcelAnnotation) annos[i]).getBcelAnnotation();
if (annotation.getTypeSignature().equals(annotationOfInterestSignature)) {
- List vals = annotation.getValues();
+ List<NameValuePair> vals = annotation.getValues();
boolean doneAndDusted = false;
- for (Iterator iterator = vals.iterator(); iterator.hasNext();) {
- NameValuePair object = (NameValuePair) iterator.next();
+ for (Iterator<NameValuePair> iterator = vals.iterator(); iterator.hasNext();) {
+ NameValuePair object = iterator.next();
Object o = object.getValue();
if (o instanceof EnumElementValue) {
EnumElementValue v = (EnumElementValue) object.getValue();
// il.append(fact.createGetStatic(rt.getName(), v.getEnumValueString(), Type.getType(rt.getSignature())));
// doneAndDusted = true;
// }
- int stop = 1;
}
}
if (!doneAndDusted) {
- ResolvedMember[] annotationFields = toType.getWorld().resolve(
- UnresolvedType.forSignature(annotation.getTypeSignature())).getDeclaredMethods();
+ ResolvedMember[] annotationFields = toType.getWorld()
+ .resolve(UnresolvedType.forSignature(annotation.getTypeSignature())).getDeclaredMethods();
// ResolvedMember[] fs = rt.getDeclaredFields();
for (int ii = 0; ii < annotationFields.length; ii++) {
private static class AjAttributeFieldStruct extends AjAttributeStruct {
final Field field;
- final BcelField bField;
+
+ // final BcelField bField;
public AjAttributeFieldStruct(Field field, BcelField bField, ResolvedType type, ISourceContext sourceContext,
IMessageHandler messageHandler) {
super(type, sourceContext, messageHandler);
this.field = field;
- this.bField = bField;
+ // this.bField = bField;
}
}
msgHandler.handleMessage(new Message(WeaverMessages.format(WeaverMessages.RETURNING_FORMAL_NOT_DECLARED_IN_ADVICE,
e.getFormalName()), IMessage.ERROR, null, bMethod.getSourceLocation()));
} catch (ThrownFormalNotDeclaredInAdviceSignatureException e) {
- msgHandler.handleMessage(new Message(WeaverMessages.format(WeaverMessages.THROWN_FORMAL_NOT_DECLARED_IN_ADVICE, e
- .getFormalName()), IMessage.ERROR, null, bMethod.getSourceLocation()));
+ msgHandler.handleMessage(new Message(WeaverMessages.format(WeaverMessages.THROWN_FORMAL_NOT_DECLARED_IN_ADVICE,
+ e.getFormalName()), IMessage.ERROR, null, bMethod.getSourceLocation()));
}
}
hasAtAspectJAnnotation = hasAtAspectJAnnotation || hasAtAspectJAnnotationMustReturnVoid;
FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0];
IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings);
// first add the declare implements like
- List parents = new ArrayList(1);
+ List<TypePattern> parents = new ArrayList<TypePattern>(1);
parents.add(parent);
DeclareParents dp = new DeclareParents(typePattern, parents, false);
dp.resolve(binding); // resolves the parent and child parts
// The factory method for building the implementation is the
// one attached to the annotation:
- Method implementationFactory = struct.method;
+ // Method implementationFactory = struct.method;
boolean hasAtLeastOneMethod = false;
- for (Iterator iterator = newInterfaceTypes.iterator(); iterator.hasNext();) {
- ResolvedType typeForDelegation = (ResolvedType) iterator.next();
+ for (Iterator<ResolvedType> iterator = newInterfaceTypes.iterator(); iterator.hasNext();) {
+ ResolvedType typeForDelegation = iterator.next();
// TODO check for overlapping interfaces. Eg. A implements I, I extends J - if they specify interfaces={I,J} we dont
// want to do any methods twice
ResolvedMember[] methods = typeForDelegation.getMethodsWithoutIterator(true, false, false).toArray(
}
setIgnoreUnboundBindingNames(pc, bindings);
- ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(), struct.bMethod
- .getDeclarationOffset());
+ ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
+ struct.bMethod.getDeclarationOffset());
struct.ajAttributes.add(new AjAttribute.AdviceAttribute(AdviceKind.Before, pc, extraArgument, sl.getOffset(), sl
.getOffset() + 1,// FIXME AVASM
struct.context));
}
setIgnoreUnboundBindingNames(pc, bindings);
- ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(), struct.bMethod
- .getDeclarationOffset());
+ ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
+ struct.bMethod.getDeclarationOffset());
struct.ajAttributes.add(new AjAttribute.AdviceAttribute(AdviceKind.After, pc, extraArgument, sl.getOffset(), sl
.getOffset() + 1,// FIXME AVASM
struct.context));
}
setIgnoreUnboundBindingNames(pc, bindings);
- ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(), struct.bMethod
- .getDeclarationOffset());
+ ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
+ struct.bMethod.getDeclarationOffset());
struct.ajAttributes.add(new AjAttribute.AdviceAttribute(AdviceKind.AfterReturning, pc, extraArgument, sl.getOffset(),
sl.getOffset() + 1,// FIXME AVASM
struct.context));
}
setIgnoreUnboundBindingNames(pc, bindings);
- ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(), struct.bMethod
- .getDeclarationOffset());
+ ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
+ struct.bMethod.getDeclarationOffset());
struct.ajAttributes.add(new AjAttribute.AdviceAttribute(AdviceKind.AfterThrowing, pc, extraArgument, sl.getOffset(), sl
.getOffset() + 1, struct.context));
return true;
}
setIgnoreUnboundBindingNames(pc, bindings);
- ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(), struct.bMethod
- .getDeclarationOffset());
+ ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(),
+ struct.bMethod.getDeclarationOffset());
struct.ajAttributes.add(new AjAttribute.AdviceAttribute(AdviceKind.Around, pc, extraArgument, sl.getOffset(), sl
.getOffset() + 1,// FIXME AVASM
struct.context));
*/
private static AnnotationGen getAnnotation(RuntimeAnnos rvs, UnresolvedType annotationType) {
final String annotationTypeName = annotationType.getName();
- for (Iterator iterator = rvs.getAnnotations().iterator(); iterator.hasNext();) {
- AnnotationGen rv = (AnnotationGen) iterator.next();
+ for (AnnotationGen rv : rvs.getAnnotations()) {
if (annotationTypeName.equals(rv.getTypeName())) {
return rv;
}
* @return annotation NVP
*/
private static NameValuePair getAnnotationElement(AnnotationGen annotation, String elementName) {
- for (Iterator iterator1 = annotation.getValues().iterator(); iterator1.hasNext();) {
- NameValuePair element = (NameValuePair) iterator1.next();
+ for (NameValuePair element : annotation.getValues()) {
if (elementName.equals(element.getNameString())) {
return element;
}
}
// sort by index
- Collections.sort(arguments, new Comparator() {
- public int compare(Object o, Object o1) {
- MethodArgument mo = (MethodArgument) o;
- MethodArgument mo1 = (MethodArgument) o1;
+ Collections.sort(arguments, new Comparator<MethodArgument>() {
+ public int compare(MethodArgument mo, MethodArgument mo1) {
if (mo.indexOnStack == mo1.indexOnStack) {
return 0;
} else if (mo.indexOnStack > mo1.indexOnStack) {
private static void setIgnoreUnboundBindingNames(Pointcut pointcut, FormalBinding[] bindings) {
// register ImplicitBindings as to be ignored since unbound
// TODO is it likely to fail in a bad way if f.e. this(jp) etc ?
- List ignores = new ArrayList();
+ List<String> ignores = new ArrayList<String>();
for (int i = 0; i < bindings.length; i++) {
FormalBinding formalBinding = bindings[i];
if (formalBinding instanceof FormalBinding.ImplicitFormalBinding) {
ignores.add(formalBinding.getName());
}
}
- pointcut.m_ignoreUnboundBindingForNames = (String[]) ignores.toArray(new String[ignores.size()]);
+ pointcut.m_ignoreUnboundBindingForNames = ignores.toArray(new String[ignores.size()]);
}
/**
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
* Wrapper member cache, key is wrapper name. This structure is queried when regular shadow matching in the advice body
* (call/get/set) occurs
*/
- private Map m_inlineAccessorBcelMethods;
+ private Map<String, ResolvedMember> m_inlineAccessorBcelMethods;
/**
* The aspect we act for
/**
* The wrapper method we need to add. Those are added at the end of the munging
*/
- private Set m_inlineAccessorMethodGens;
+ private Set<LazyMethodGen> inlineAccessorMethodGens;
public BcelAccessForInlineMunger(ResolvedType aspectType) {
super(null, aspectType);
@Override
public boolean munge(BcelClassWeaver weaver) {
m_aspectGen = weaver.getLazyClassGen();
- m_inlineAccessorBcelMethods = new HashMap(0);
- m_inlineAccessorMethodGens = new HashSet();
+ m_inlineAccessorBcelMethods = new HashMap<String, ResolvedMember>(0);
+ inlineAccessorMethodGens = new HashSet<LazyMethodGen>();
// look for all @Around advices
- for (Iterator iterator = m_aspectGen.getMethodGens().iterator(); iterator.hasNext();) {
- LazyMethodGen methodGen = (LazyMethodGen) iterator.next();
+ for (LazyMethodGen methodGen : m_aspectGen.getMethodGens()) {
if (methodGen.hasAnnotation(UnresolvedType.forName("org/aspectj/lang/annotation/Around"))) {
openAroundAdvice(methodGen);
}
}
// add the accessors
- for (Iterator iterator = m_inlineAccessorMethodGens.iterator(); iterator.hasNext();) {
- LazyMethodGen lazyMethodGen = (LazyMethodGen) iterator.next();
+ for (LazyMethodGen lazyMethodGen : inlineAccessorMethodGens) {
m_aspectGen.addMethodGen(lazyMethodGen);
}
// flush some
- m_inlineAccessorMethodGens = null;
+ inlineAccessorMethodGens = null;
// we keep m_inlineAccessorsResolvedMembers for shadow matching
return true;
*/
@Override
public ResolvedMember getMatchingSyntheticMember(Member member) {
- return (ResolvedMember) m_inlineAccessorBcelMethods.get(member.getName());
+ return m_inlineAccessorBcelMethods.get(member.getName());
}
@Override
ResolvedType callee = m_aspectGen.getWorld().resolve(UnresolvedType.forName(invoke.getClassName(cpg)));
// look in the whole method list and not just declared for super calls and alike
- List methods = callee.getMethodsWithoutIterator(false, true, false);
- for (Iterator iter = methods.iterator(); iter.hasNext();) {
- ResolvedMember resolvedMember = (ResolvedMember) iter.next();
+ List<ResolvedMember> methods = callee.getMethodsWithoutIterator(false, true, false);
+ for (ResolvedMember resolvedMember : methods) {
if (invoke.getName(cpg).equals(resolvedMember.getName())
&& invoke.getSignature(cpg).equals(resolvedMember.getSignature()) && !resolvedMember.isPublic()) {
if ("<init>".equals(invoke.getName(cpg))) {
// && aspectType.getSuperclass().getName().equals(resolvedMember.getDeclaringType().getName())) {
ResolvedMember accessor = createOrGetInlineAccessorForSuperDispatch(resolvedMember);
InvokeInstruction newInst = factory.createInvoke(aspectType.getName(), accessor.getName(),
- BcelWorld.makeBcelType(accessor.getReturnType()), BcelWorld.makeBcelTypes(accessor
- .getParameterTypes()), Constants.INVOKEVIRTUAL);
+ BcelWorld.makeBcelType(accessor.getReturnType()),
+ BcelWorld.makeBcelTypes(accessor.getParameterTypes()), Constants.INVOKEVIRTUAL);
curr.setInstruction(newInst);
} else {
ResolvedMember accessor = createOrGetInlineAccessorForMethod(resolvedMember);
InvokeInstruction newInst = factory.createInvoke(aspectType.getName(), accessor.getName(),
- BcelWorld.makeBcelType(accessor.getReturnType()), BcelWorld.makeBcelTypes(accessor
- .getParameterTypes()), Constants.INVOKESTATIC);
+ BcelWorld.makeBcelType(accessor.getReturnType()),
+ BcelWorld.makeBcelTypes(accessor.getParameterTypes()), Constants.INVOKESTATIC);
curr.setInstruction(newInst);
}
}
} else {
accessor = createOrGetInlineAccessorForFieldSet(resolvedMember);
}
- InvokeInstruction newInst = factory.createInvoke(aspectType.getName(), accessor.getName(), BcelWorld
- .makeBcelType(accessor.getReturnType()), BcelWorld.makeBcelTypes(accessor.getParameterTypes()),
- Constants.INVOKESTATIC);
+ InvokeInstruction newInst = factory.createInvoke(aspectType.getName(), accessor.getName(),
+ BcelWorld.makeBcelType(accessor.getReturnType()),
+ BcelWorld.makeBcelTypes(accessor.getParameterTypes()), Constants.INVOKESTATIC);
curr.setInstruction(newInst);
break;// ok we found a matching callee member and swapped the instruction with the accessor
private ResolvedMember createOrGetInlineAccessorForMethod(ResolvedMember resolvedMember) {
String accessor = NameMangler.inlineAccessMethodForMethod(resolvedMember.getName(), resolvedMember.getDeclaringType(),
aspectType);
- ResolvedMember inlineAccessor = (ResolvedMember) m_inlineAccessorBcelMethods.get(accessor);
+ ResolvedMember inlineAccessor = m_inlineAccessorBcelMethods.get(accessor);
if (inlineAccessor == null) {
// add static method to aspect
inlineAccessor = AjcMemberMaker.inlineAccessMethodForMethod(aspectType, resolvedMember);
method.addAttribute(Utility.bcelAttribute(new AjAttribute.EffectiveSignatureAttribute(resolvedMember,
Shadow.MethodCall, false), m_aspectGen.getConstantPool()));
- m_inlineAccessorMethodGens.add(method);
+ inlineAccessorMethodGens.add(method);
InstructionList il = method.getBody();
int register = 0;
*/
private ResolvedMember createOrGetInlineAccessorForSuperDispatch(ResolvedMember resolvedMember) {
String accessor = NameMangler.superDispatchMethod(aspectType, resolvedMember.getName());
- ResolvedMember inlineAccessor = (ResolvedMember) m_inlineAccessorBcelMethods.get(accessor);
+ ResolvedMember inlineAccessor = m_inlineAccessorBcelMethods.get(accessor);
if (inlineAccessor == null) {
// add super accessor method to class:
inlineAccessor = AjcMemberMaker.superAccessMethod(aspectType, resolvedMember);
method.addAttribute(Utility.bcelAttribute(new AjAttribute.EffectiveSignatureAttribute(resolvedMember,
Shadow.MethodCall, false), m_aspectGen.getConstantPool()));
- m_inlineAccessorMethodGens.add(method);
+ inlineAccessorMethodGens.add(method);
InstructionList il = method.getBody();
il.append(InstructionConstants.ALOAD_0);
private ResolvedMember createOrGetInlineAccessorForFieldGet(ResolvedMember resolvedMember) {
String accessor = NameMangler.inlineAccessMethodForFieldGet(resolvedMember.getName(), resolvedMember.getDeclaringType(),
aspectType);
- ResolvedMember inlineAccessor = (ResolvedMember) m_inlineAccessorBcelMethods.get(accessor);
+ ResolvedMember inlineAccessor = m_inlineAccessorBcelMethods.get(accessor);
if (inlineAccessor == null) {
// add static method to aspect
inlineAccessor = AjcMemberMaker.inlineAccessMethodForFieldGet(aspectType, resolvedMember);
method.addAttribute(Utility.bcelAttribute(new AjAttribute.EffectiveSignatureAttribute(resolvedMember, Shadow.FieldGet,
false), m_aspectGen.getConstantPool()));
- m_inlineAccessorMethodGens.add(method);
+ inlineAccessorMethodGens.add(method);
InstructionList il = method.getBody();
if (Modifier.isStatic(resolvedMember.getModifiers())) {
private ResolvedMember createOrGetInlineAccessorForFieldSet(ResolvedMember resolvedMember) {
String accessor = NameMangler.inlineAccessMethodForFieldSet(resolvedMember.getName(), resolvedMember.getDeclaringType(),
aspectType);
- ResolvedMember inlineAccessor = (ResolvedMember) m_inlineAccessorBcelMethods.get(accessor);
+ ResolvedMember inlineAccessor = m_inlineAccessorBcelMethods.get(accessor);
if (inlineAccessor == null) {
// add static method to aspect
inlineAccessor = AjcMemberMaker.inlineAccessMethodForFieldSet(aspectType, resolvedMember);
method.addAttribute(Utility.bcelAttribute(new AjAttribute.EffectiveSignatureAttribute(resolvedMember, Shadow.FieldSet,
false), m_aspectGen.getConstantPool()));
- m_inlineAccessorMethodGens.add(method);
+ inlineAccessorMethodGens.add(method);
InstructionList il = method.getBody();
if (Modifier.isStatic(resolvedMember.getModifiers())) {
if (bm.getMethod() != null && bm.getMethod().getAnnotations() != null) {
return adviceSignature;
}
- ResolvedMemberImpl simplermember = new ResolvedMemberImpl(bm.getKind(), bm.getDeclaringType(), bm
- .getModifiers(), bm.getReturnType(), bm.getName(), bm.getParameterTypes());// ,bm.getExceptions(),bm.getBackingGenericMember()
+ ResolvedMemberImpl simplermember = new ResolvedMemberImpl(bm.getKind(), bm.getDeclaringType(),
+ bm.getModifiers(), bm.getReturnType(), bm.getName(), bm.getParameterTypes());// ,bm.getExceptions(),bm.getBackingGenericMember()
// );
simplermember.setParameterNames(bm.getParameterNames());
return simplermember;
}
@Override
- public ShadowMunger parameterizeWith(ResolvedType declaringType, Map typeVariableMap) {
+ public ShadowMunger parameterizeWith(ResolvedType declaringType, Map<String, UnresolvedType> typeVariableMap) {
Pointcut pc = getPointcut().parameterizeWith(typeVariableMap, declaringType.getWorld());
BcelAdvice ret = null;
if (resolvedMember instanceof BcelMethod && shadow.getEnclosingShadow() instanceof BcelShadow) {
Member enclosingMember = shadow.getEnclosingShadow().getSignature();
if (enclosingMember instanceof BcelMethod) {
- removeUnnecessaryProblems((BcelMethod) enclosingMember, ((BcelMethod) resolvedMember)
- .getDeclarationLineNumber());
+ removeUnnecessaryProblems((BcelMethod) enclosingMember,
+ ((BcelMethod) resolvedMember).getDeclarationLineNumber());
}
}
}
if (shadow.getIWorld().isJoinpointSynchronizationEnabled() && shadow.getKind() == Shadow.MethodExecution
&& (s.getSignature().getModifiers() & Modifier.SYNCHRONIZED) != 0) {
- shadow.getIWorld().getLint().advisingSynchronizedMethods.signal(new String[] { shadow.toString() }, shadow
- .getSourceLocation(), new ISourceLocation[] { getSourceLocation() });
+ shadow.getIWorld().getLint().advisingSynchronizedMethods.signal(new String[] { shadow.toString() },
+ shadow.getSourceLocation(), new ISourceLocation[] { getSourceLocation() });
}
// FIXME AV - see #75442, this logic is not enough so for now comment it out until we fix the bug
LazyClassGen enclosingClass = shadow.getEnclosingClass();
if (enclosingClass != null && enclosingClass.isInterface() && shadow.getEnclosingMethod().getName().charAt(0) == '<') {
// Do not add methods with bodies to an interface (252198, 163005)
- shadow.getWorld().getLint().cannotAdviseJoinpointInInterfaceWithAroundAdvice.signal(shadow.toString(), shadow
- .getSourceLocation());
+ shadow.getWorld().getLint().cannotAdviseJoinpointInInterfaceWithAroundAdvice.signal(shadow.toString(),
+ shadow.getSourceLocation());
return false;
}
if (!canInline(s)) {
for (int i = 0, len = excs.length; i < len; i++) {
ResolvedType t = world.resolve(excs[i], true);
if (t.isMissing()) {
- world.getLint().cantFindType.signal(WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_EXCEPTION_TYPE, excs[i]
- .getName()), getSourceLocation());
+ world.getLint().cantFindType
+ .signal(WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_EXCEPTION_TYPE, excs[i].getName()),
+ getSourceLocation());
// IMessage msg = new Message(
// WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_EXCEPTION_TYPE,excs[i].getName()),
// "",IMessage.ERROR,getSourceLocation(),null,null);
if (hasExtraParameter() && getKind() == AdviceKind.AfterReturning) {
UnresolvedType extraParameterType = getExtraParameterType();
if (!extraParameterType.equals(UnresolvedType.OBJECT) && !extraParameterType.isPrimitiveType()) {
- il.append(BcelRenderer.renderTest(fact, world, Test.makeInstanceof(extraArgVar, getExtraParameterType().resolve(
- world)), null, ifNoAdvice, null));
+ il.append(BcelRenderer.renderTest(fact, world,
+ Test.makeInstanceof(extraArgVar, getExtraParameterType().resolve(world)), null, ifNoAdvice, null));
}
}
il.append(getAdviceArgSetup(shadow, extraArgVar, null));
// BcelWorld.makeBcelType(targetAspectField.getType()),
// Constants.GETSTATIC));
// }
- //
+ //
// System.err.println("BcelAdvice: " + exposedState);
if (exposedState.getAspectInstance() != null) {
// make sure we are in an around, since we deal with the closure, not the arg here
if (getKind() != AdviceKind.Around) {
previousIsClosure = false;
- getConcreteAspect().getWorld().getMessageHandler().handleMessage(
- new Message("use of ProceedingJoinPoint is allowed only on around advice (" + "arg " + i
- + " in " + toString() + ")", this.getSourceLocation(), true));
+ getConcreteAspect()
+ .getWorld()
+ .getMessageHandler()
+ .handleMessage(
+ new Message("use of ProceedingJoinPoint is allowed only on around advice (" + "arg "
+ + i + " in " + toString() + ")", this.getSourceLocation(), true));
// try to avoid verify error and pass in null
il.append(InstructionConstants.ACONST_NULL);
} else {
extraVar.appendLoadAndConvert(il, fact, getExtraParameterType().resolve(world));
} else {
previousIsClosure = false;
- getConcreteAspect().getWorld().getMessageHandler().handleMessage(
- new Message("use of ProceedingJoinPoint is allowed only on around advice (" + "arg " + i + " in "
- + toString() + ")", this.getSourceLocation(), true));
+ getConcreteAspect()
+ .getWorld()
+ .getMessageHandler()
+ .handleMessage(
+ new Message("use of ProceedingJoinPoint is allowed only on around advice (" + "arg " + i
+ + " in " + toString() + ")", this.getSourceLocation(), true));
// try to avoid verify error and pass in null
il.append(InstructionConstants.ACONST_NULL);
}
private static Trace trace = TraceFactory.getTraceFactory().getTrace(BcelClassWeaver.class);
public static boolean weave(BcelWorld world, LazyClassGen clazz, List<ShadowMunger> shadowMungers,
- List<ConcreteTypeMunger> typeMungers, List lateTypeMungers, boolean inReweavableMode) {
+ List<ConcreteTypeMunger> typeMungers, List<ConcreteTypeMunger> lateTypeMungers, boolean inReweavableMode) {
BcelClassWeaver classWeaver = new BcelClassWeaver(world, clazz, shadowMungers, typeMungers, lateTypeMungers);
classWeaver.setReweavableMode(inReweavableMode);
boolean b = classWeaver.weave();
private final LazyClassGen clazz;
private final List<ShadowMunger> shadowMungers;
private final List<ConcreteTypeMunger> typeMungers;
- private final List lateTypeMungers;
+ private final List<ConcreteTypeMunger> lateTypeMungers;
private List<ShadowMunger>[] indexedShadowMungers;
private boolean canMatchBodyShadows = false;
private final List<BcelShadow> initializationShadows = new ArrayList<BcelShadow>();
private BcelClassWeaver(BcelWorld world, LazyClassGen clazz, List<ShadowMunger> shadowMungers,
- List<ConcreteTypeMunger> typeMungers, List lateTypeMungers) {
+ List<ConcreteTypeMunger> typeMungers, List<ConcreteTypeMunger> lateTypeMungers) {
super();
this.world = world;
this.clazz = clazz;
mods = mods - Modifier.ABSTRACT;
}
- LazyMethodGen ret = new LazyMethodGen(mods, BcelWorld.makeBcelType(member.getReturnType()), member.getName(), BcelWorld
- .makeBcelTypes(member.getParameterTypes()), UnresolvedType.getNames(member.getExceptions()), gen);
+ LazyMethodGen ret = new LazyMethodGen(mods, BcelWorld.makeBcelType(member.getReturnType()), member.getName(),
+ BcelWorld.makeBcelTypes(member.getParameterTypes()), UnresolvedType.getNames(member.getExceptions()), gen);
// 43972 : Static crosscutting makes interfaces unusable for javac
// ret.makeSynthetic();
if (whatToBridgeTo == null) {
whatToBridgeTo = new ResolvedMemberImpl(Member.METHOD, whatToBridgeToMethodGen.getEnclosingClass().getType(),
- whatToBridgeToMethodGen.getAccessFlags(), whatToBridgeToMethodGen.getName(), whatToBridgeToMethodGen
- .getSignature());
+ whatToBridgeToMethodGen.getAccessFlags(), whatToBridgeToMethodGen.getName(),
+ whatToBridgeToMethodGen.getSignature());
}
// The bridge method in this type will have the same signature as the one in the supertype
LazyMethodGen bridgeMethod = makeBridgeMethod(clazz, theBridgeMethod);
*/
public boolean weave() {
if (clazz.isWoven() && !clazz.isReweavable()) {
- world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.ALREADY_WOVEN, clazz.getType().getName()), ty
- .getSourceLocation(), null);
+ world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.ALREADY_WOVEN, clazz.getType().getName()),
+ ty.getSourceLocation(), null);
return false;
}
System.err.println("Bridging:checking superinterface " + interfaces[j]);
}
ResolvedType interfaceType = world.resolve(interfaces[j]);
- overriddenMethod = checkForOverride(interfaceType, name, psig, rsig, bridgeToCandidate.getAccessFlags(), clazz
- .getPackageName(), bm);
+ overriddenMethod = checkForOverride(interfaceType, name, psig, rsig, bridgeToCandidate.getAccessFlags(),
+ clazz.getPackageName(), bm);
if (overriddenMethod != null) {
String key = new StringBuffer().append(overriddenMethod.getName())
.append(overriddenMethod.getSignatureErased()).toString(); // pr
annotationsToAdd.add(ag);
mg.addAnnotation(decaM.getAnnotation());
- AsmRelationshipProvider.addDeclareAnnotationMethodRelationship(decaM.getSourceLocation(), clazz
- .getName(), mg.getMemberView(), world.getModelAsAsmManager());// getMethod());
+ AsmRelationshipProvider.addDeclareAnnotationMethodRelationship(decaM.getSourceLocation(),
+ clazz.getName(), mg.getMemberView(), world.getModelAsAsmManager());// getMethod());
reportMethodCtorWeavingMessage(clazz, mg.getMemberView(), decaM, mg.getDeclarationLineNumber());
isChanged = true;
modificationOccured = true;
AnnotationGen ag = new AnnotationGen(a, clazz.getConstantPool(), true);
annotationsToAdd.add(ag);
mg.addAnnotation(decaM.getAnnotation());
- AsmRelationshipProvider.addDeclareAnnotationMethodRelationship(decaM.getSourceLocation(), clazz
- .getName(), mg.getMemberView(), world.getModelAsAsmManager());// getMethod());
+ AsmRelationshipProvider.addDeclareAnnotationMethodRelationship(decaM.getSourceLocation(),
+ clazz.getName(), mg.getMemberView(), world.getModelAsAsmManager());// getMethod());
isChanged = true;
modificationOccured = true;
forRemoval.add(decaM);
}
}
getWorld().getMessageHandler().handleMessage(
- WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ANNOTATES, new String[] { sig.toString(),
- loc.toString(), decaM.getAnnotationString(),
- methodName.startsWith("<init>") ? "constructor" : "method", decaM.getAspect().toString(),
- Utility.beautifyLocation(decaM.getSourceLocation()) }));
+ WeaveMessage.constructWeavingMessage(
+ WeaveMessage.WEAVEMESSAGE_ANNOTATES,
+ new String[] { sig.toString(), loc.toString(), decaM.getAnnotationString(),
+ methodName.startsWith("<init>") ? "constructor" : "method", decaM.getAspect().toString(),
+ Utility.beautifyLocation(decaM.getSourceLocation()) }));
}
}
continue; // skip this one...
}
annotationHolder.addAnnotation(decaF.getAnnotation());
- AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(), decaF
- .getSourceLocation(), itdIsActually.getSourceLocation());
+ AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
+ decaF.getSourceLocation(), itdIsActually.getSourceLocation());
isChanged = true;
modificationOccured = true;
continue; // skip this one...
}
annotationHolder.addAnnotation(decaF.getAnnotation());
- AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(), decaF
- .getSourceLocation(), itdIsActually.getSourceLocation());
+ AsmRelationshipProvider.addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
+ decaF.getSourceLocation(), itdIsActually.getSourceLocation());
isChanged = true;
modificationOccured = true;
forRemoval.add(decaF);
}
}
- AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(), decaF
- .getSourceLocation(), clazz.getName(), aBcelField);
+ AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(),
+ decaF.getSourceLocation(), clazz.getName(), aBcelField);
reportFieldAnnotationWeavingMessage(clazz, fields, fieldCounter, decaF);
isChanged = true;
modificationOccured = true;
continue; // skip this one...
}
aBcelField.addAnnotation(decaF.getAnnotation());
- AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(), decaF
- .getSourceLocation(), clazz.getName(), aBcelField);
+ AsmRelationshipProvider.addDeclareAnnotationFieldRelationship(world.getModelAsAsmManager(),
+ decaF.getSourceLocation(), clazz.getName(), aBcelField);
isChanged = true;
modificationOccured = true;
forRemoval.add(decaF);
if (!itdMatch) {
IMessage message = null;
if (isDeclareAtField) {
- message = new Message("The field '" + declA.getSignaturePattern().toString() + "' does not exist", declA
- .getSourceLocation(), true);
+ message = new Message("The field '" + declA.getSignaturePattern().toString() + "' does not exist",
+ declA.getSourceLocation(), true);
} else {
- message = new Message("The method '" + declA.getSignaturePattern().toString() + "' does not exist", declA
- .getSourceLocation(), true);
+ message = new Message("The method '" + declA.getSignaturePattern().toString() + "' does not exist",
+ declA.getSourceLocation(), true);
}
world.getMessageHandler().handleMessage(message);
}
if (!getWorld().getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) {
BcelField theField = (BcelField) fields.get(fieldCounter);
world.getMessageHandler().handleMessage(
- WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ANNOTATES, new String[] {
- theField.getFieldAsIs().toString() + "' of type '" + clazz.getName(), clazz.getFileName(),
- decaF.getAnnotationString(), "field", decaF.getAspect().toString(),
- Utility.beautifyLocation(decaF.getSourceLocation()) }));
+ WeaveMessage.constructWeavingMessage(
+ WeaveMessage.WEAVEMESSAGE_ANNOTATES,
+ new String[] { theField.getFieldAsIs().toString() + "' of type '" + clazz.getName(),
+ clazz.getFileName(), decaF.getAnnotationString(), "field", decaF.getAspect().toString(),
+ Utility.beautifyLocation(decaF.getSourceLocation()) }));
}
}
if (!reportedProblems.contains(uniqueID)) {
reportedProblems.add(uniqueID);
world.getLint().elementAlreadyAnnotated.signal(new String[] { rm.toString(),
- deca.getAnnotationType().toString() }, rm.getSourceLocation(), new ISourceLocation[] { deca
- .getSourceLocation() });
+ deca.getAnnotationType().toString() }, rm.getSourceLocation(),
+ new ISourceLocation[] { deca.getSourceLocation() });
}
}
return true;
reportedProblems.add(uniqueID);
reportedProblems.add(new Integer(itdfieldsig.hashCode() * deca.hashCode()));
world.getLint().elementAlreadyAnnotated.signal(new String[] { itdfieldsig.toString(),
- deca.getAnnotationType().toString() }, rm.getSourceLocation(), new ISourceLocation[] { deca
- .getSourceLocation() });
+ deca.getAnnotationType().toString() }, rm.getSourceLocation(),
+ new ISourceLocation[] { deca.getSourceLocation() });
}
}
return true;
// return new BcelVar(typeX.resolve(world),
// genTempVarIndex(typeX.getSize()));
// }
- //
+ //
// private int genTempVarIndex(int size) {
// return enclosingMethod.allocateLocal(size);
// }
// will ensure monitorexit is called. Content on the finally
// block seems to
// be always:
- //
+ //
// E1: ALOAD_1
// MONITOREXIT
// ATHROW
// 32: dup <-- partTwo (branch target)
// 33: astore_0
// 34: monitorenter
- //
+ //
// plus exceptiontable entry!
// 8 13 20 Class java/lang/ClassNotFoundException
Type classType = BcelWorld.makeBcelType(synchronizedMethod.getEnclosingClass().getType());
InstructionHandle catchInstruction = prepend.getEnd();
prepend.append(InstructionFactory.createDup(1));
- prepend.append(fact.createPutStatic(synchronizedMethod.getEnclosingClass().getType().getName(), fieldname, Type
- .getType(Class.class)));
+ prepend.append(fact.createPutStatic(synchronizedMethod.getEnclosingClass().getType().getName(), fieldname,
+ Type.getType(Class.class)));
prepend.append(InstructionFactory.createBranchInstruction(Constants.GOTO, parttwo.getStart()));
// start of catch block
catchBlockForLiteralLoadingFail.append(fact.createNew((ObjectType) Type.getType(NoClassDefFoundError.class)));
catchBlockForLiteralLoadingFail.append(InstructionFactory.createDup_1(1));
catchBlockForLiteralLoadingFail.append(InstructionFactory.SWAP);
- catchBlockForLiteralLoadingFail.append(fact.createInvoke("java.lang.Throwable", "getMessage", Type
- .getType(String.class), new Type[] {}, Constants.INVOKEVIRTUAL));
+ catchBlockForLiteralLoadingFail.append(fact.createInvoke("java.lang.Throwable", "getMessage",
+ Type.getType(String.class), new Type[] {}, Constants.INVOKEVIRTUAL));
catchBlockForLiteralLoadingFail.append(fact.createInvoke("java.lang.NoClassDefFoundError", "<init>", Type.VOID,
new Type[] { Type.getType(String.class) }, Constants.INVOKESPECIAL));
catchBlockForLiteralLoadingFail.append(InstructionFactory.ATHROW);
// will ensure monitorexit is called. Content on the finally
// block seems to
// be always:
- //
+ //
// E1: ALOAD_1
// MONITOREXIT
// ATHROW
synchronizedMethod.getBody().append(finallyBlock);
synchronizedMethod.addExceptionHandler(tryPosition, catchPosition, finallyStart, null/* ==finally */, false);
- synchronizedMethod.addExceptionHandler(tryInstruction, catchInstruction, catchBlockStart, (ObjectType) Type
- .getType(ClassNotFoundException.class), true);
+ synchronizedMethod.addExceptionHandler(tryInstruction, catchInstruction, catchBlockStart,
+ (ObjectType) Type.getType(ClassNotFoundException.class), true);
synchronizedMethod.addExceptionHandler(finallyStart, finallyStart.getNext(), finallyStart, null, false);
}
} else {
// will ensure monitorexit is called. Content on the finally block
// seems to
// be always:
- //
+ //
// E1: ALOAD_1
// MONITOREXIT
// ATHROW
LocalVariableTag lvTag = (LocalVariableTag) old;
LocalVariableTag lvTagFresh = (LocalVariableTag) fresh;
if (lvTag.getSlot() == 0) {
- fresh = new LocalVariableTag(lvTag.getRealType().getSignature(), "ajc$aspectInstance", frameEnv
- .get(lvTag.getSlot()), 0);
+ fresh = new LocalVariableTag(lvTag.getRealType().getSignature(), "ajc$aspectInstance",
+ frameEnv.get(lvTag.getSlot()), 0);
} else {
// // Do not move it - when copying the code from the aspect to the affected target, 'this' is
// // going to change from aspect to affected type. So just fix the type
// InstructionList newList = new InstructionList();
//
// Map srcToDest = new HashMap();
- //
+ //
// // first pass: copy the instructions directly, populate the srcToDest
// map,
// // fix frame instructions
// }
// srcToDest.put(src, dest);
// }
- //
+ //
// // second pass: retarget branch instructions, copy ranges and tags
// Map tagMap = new HashMap();
// for (InstructionHandle dest = newList.getStart(), src =
// dest != null;
// dest = dest.getNext(), src = src.getNext()) {
// Instruction inst = dest.getInstruction();
- //
+ //
// // retarget branches
// if (inst instanceof InstructionBranch) {
// InstructionBranch branch = (InstructionBranch) inst;
// }
// }
// }
- //
+ //
// //copy over tags and range attributes
// Iterator tIter = src.getTargeters().iterator();
//
annotations = theRealMember.getAnnotationTypes();
}
} else if (rm.getKind() == Member.CONSTRUCTOR) {
- ResolvedMember realThing = AjcMemberMaker.postIntroducedConstructor(memberHostType.resolve(world), rm
- .getDeclaringType(), rm.getParameterTypes());
+ ResolvedMember realThing = AjcMemberMaker.postIntroducedConstructor(memberHostType.resolve(world),
+ rm.getDeclaringType(), rm.getParameterTypes());
ResolvedMember resolvedDooberry = world.resolve(realThing);
// AMC temp guard for M4
if (resolvedDooberry == null) {
import java.util.Map;
import java.util.Set;
import java.util.jar.Attributes;
+import java.util.jar.Attributes.Name;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
-import java.util.jar.Attributes.Name;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
// These four are setup by prepareForWeave
private transient List<ShadowMunger> shadowMungerList = null;
private transient List<ConcreteTypeMunger> typeMungerList = null;
- private transient List lateTypeMungerList = null;
+ private transient List<ConcreteTypeMunger> lateTypeMungerList = null;
private transient List declareParentsList = null;
private Manifest manifest = null;
* @param userPointcut
*/
private void raiseUnboundFormalError(String name, Pointcut userPointcut) {
- world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.UNBOUND_FORMAL, name), userPointcut
- .getSourceLocation(), null);
+ world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.UNBOUND_FORMAL, name),
+ userPointcut.getSourceLocation(), null);
}
public void addManifest(Manifest newManifest) {
ResolvedType rtx = world.resolve(UnresolvedType.forSignature(requiredTypeSignature), true);
boolean exists = !rtx.isMissing();
if (!exists) {
- world.getLint().missingAspectForReweaving.signal(new String[] { rtx.getName(), className }, classType
- .getSourceLocation(), null);
+ world.getLint().missingAspectForReweaving.signal(new String[] { rtx.getName(), className },
+ classType.getSourceLocation(), null);
// world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.MISSING_REWEAVABLE_TYPE,
// requiredTypeName, className), classType.getSourceLocation(), null);
} else {
world.showMessage(IMessage.ERROR, WeaverMessages.format(
WeaverMessages.REWEAVABLE_ASPECT_NOT_REGISTERED, rtx.getName(), className), null, null);
} else if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) {
- world.showMessage(IMessage.INFO, WeaverMessages.format(WeaverMessages.VERIFIED_REWEAVABLE_TYPE, rtx
- .getName(), rtx.getSourceLocation().getSourceFile()), null, null);
+ world.showMessage(IMessage.INFO, WeaverMessages.format(WeaverMessages.VERIFIED_REWEAVABLE_TYPE,
+ rtx.getName(), rtx.getSourceLocation().getSourceFile()), null, null);
}
}
alreadyConfirmedReweavableState.add(requiredTypeSignature);
}
public UnwovenClassFile[] getClassFilesFor(LazyClassGen clazz) {
- List childClasses = clazz.getChildClasses(world);
+ List<UnwovenClassFile.ChildClass> childClasses = clazz.getChildClasses(world);
UnwovenClassFile[] ret = new UnwovenClassFile[1 + childClasses.size()];
ret[0] = new UnwovenClassFile(clazz.getFileName(), clazz.getClassName(), clazz.getJavaClassBytesIncludingReweavable(world));
int index = 1;
- for (Iterator iter = childClasses.iterator(); iter.hasNext();) {
- UnwovenClassFile.ChildClass element = (UnwovenClassFile.ChildClass) iter.next();
+ for (Iterator<UnwovenClassFile.ChildClass> iter = childClasses.iterator(); iter.hasNext();) {
+ UnwovenClassFile.ChildClass element = iter.next();
UnwovenClassFile childClass = new UnwovenClassFile(clazz.getFileName() + "$" + element.name, element.bytes);
ret[index++] = childClass;
}
// TAG: WeavingMessage
if (!getWorld().getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) {
getWorld().getMessageHandler().handleMessage(
- WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ANNOTATES, new String[] {
- onType.toString(), Utility.beautifyLocation(onType.getSourceLocation()),
- decA.getAnnotationString(), "type", decA.getAspect().toString(),
- Utility.beautifyLocation(decA.getSourceLocation()) }));
+ WeaveMessage.constructWeavingMessage(
+ WeaveMessage.WEAVEMESSAGE_ANNOTATES,
+ new String[] { onType.toString(), Utility.beautifyLocation(onType.getSourceLocation()),
+ decA.getAnnotationString(), "type", decA.getAspect().toString(),
+ Utility.beautifyLocation(decA.getSourceLocation()) }));
}
didSomething = true;
ResolvedTypeMunger newAnnotationTM = new AnnotationOnTypeMunger(annoX);
if (outputProblems) {
if (decA.isExactPattern()) {
world.getMessageHandler().handleMessage(
- MessageUtil.error(WeaverMessages.format(WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION,
- onType.getName(), annoX.getTypeName(), annoX.getValidTargets()), decA.getSourceLocation()));
+ MessageUtil.error(
+ WeaverMessages.format(WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION,
+ onType.getName(), annoX.getTypeName(), annoX.getValidTargets()),
+ decA.getSourceLocation()));
} else {
if (world.getLint().invalidTargetForAnnotation.isEnabled()) {
world.getLint().invalidTargetForAnnotation.signal(new String[] { onType.getName(), annoX.getTypeName(),
- annoX.getValidTargets() }, decA.getSourceLocation(), new ISourceLocation[] { onType
- .getSourceLocation() });
+ annoX.getValidTargets() }, decA.getSourceLocation(),
+ new ISourceLocation[] { onType.getSourceLocation() });
}
}
}
}
public void weaveNormalTypeMungers(ResolvedType onType) {
- ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_TYPE_MUNGERS, onType
- .getName());
+ ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_TYPE_MUNGERS,
+ onType.getName());
if (onType.isRawType() || onType.isParameterizedType()) {
onType = onType.getGenericType();
}
if (zipOutputStream != null) {
String mainClassName = classFile.getJavaClass().getClassName();
writeZipEntry(getEntryName(mainClassName), clazz.getJavaClass(world).getBytes());
- if (!clazz.getChildClasses(world).isEmpty()) {
- for (Iterator i = clazz.getChildClasses(world).iterator(); i.hasNext();) {
- UnwovenClassFile.ChildClass c = (UnwovenClassFile.ChildClass) i.next();
+ List<UnwovenClassFile.ChildClass> childClasses = clazz.getChildClasses(world);
+ if (!childClasses.isEmpty()) {
+ for (Iterator<UnwovenClassFile.ChildClass> i = childClasses.iterator(); i.hasNext();) {
+ UnwovenClassFile.ChildClass c = i.next();
writeZipEntry(getEntryName(mainClassName + "$" + c.name), c.bytes);
}
}
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.SourceLocation;
import org.aspectj.weaver.AjAttribute;
+import org.aspectj.weaver.AjAttribute.WeaverVersionInfo;
import org.aspectj.weaver.BCException;
import org.aspectj.weaver.Member;
import org.aspectj.weaver.NameMangler;
import org.aspectj.weaver.SignatureUtils;
import org.aspectj.weaver.TypeVariable;
import org.aspectj.weaver.UnresolvedType;
+import org.aspectj.weaver.UnresolvedType.TypeKind;
import org.aspectj.weaver.WeaverMessages;
import org.aspectj.weaver.WeaverStateInfo;
import org.aspectj.weaver.World;
-import org.aspectj.weaver.AjAttribute.WeaverVersionInfo;
-import org.aspectj.weaver.UnresolvedType.TypeKind;
import org.aspectj.weaver.bcel.asm.AsmDetector;
import org.aspectj.weaver.bcel.asm.StackMapAdder;
serialVersionUIDRequiresInitialization = true;
// warn about what we've done?
if (world.getLint().calculatingSerialVersionUID.isEnabled()) {
- world.getLint().calculatingSerialVersionUID.signal(new String[] { getClassName(),
- Long.toString(calculatedSerialVersionUID) + "L" }, null, null);
+ world.getLint().calculatingSerialVersionUID.signal(
+ new String[] { getClassName(), Long.toString(calculatedSerialVersionUID) + "L" }, null, null);
}
}
}
// create an empty myGen so that we can give back a return value that
// doesn't upset the
// rest of the process.
- myGen = new ClassGen(myGen.getClassName(), myGen.getSuperclassName(), myGen.getFileName(), myGen.getModifiers(), myGen
- .getInterfaceNames());
+ myGen = new ClassGen(myGen.getClassName(), myGen.getSuperclassName(), myGen.getFileName(), myGen.getModifiers(),
+ myGen.getInterfaceNames());
// raise an error against this compilation unit.
getWorld().showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CLASS_TOO_BIG, this.getClassName()),
new SourceLocation(new File(myGen.getFileName()), 0), null);
return ret;
}
- public List getChildClasses(BcelWorld world) {
+ public List<UnwovenClassFile.ChildClass> getChildClasses(BcelWorld world) {
if (classGens.isEmpty()) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
List<UnwovenClassFile.ChildClass> ret = new ArrayList<UnwovenClassFile.ChildClass>();
for (LazyClassGen clazz : classGens) {
// System.err.println(" looking for " + end);
while (ih != end) {
// System.err.println(" ih " + ih);
- if (!Range.isRangeHandle(ih))
+ if (!Range.isRangeHandle(ih)) {
return false;
+ }
ih = ih.getNext();
}
return true;
}
static InstructionHandle genStart(InstructionList body, InstructionHandle ih) {
- if (ih == null)
+ if (ih == null) {
return genStart(body);
+ }
InstructionHandle freshIh = body.insert(ih, Range.RANGEINSTRUCTION);
setLineNumberFromNext(freshIh);
return freshIh;
}
static InstructionHandle genEnd(InstructionList body, InstructionHandle ih) {
- if (ih == null)
+ if (ih == null) {
return genEnd(body);
+ }
return body.append(ih, Range.RANGEINSTRUCTION);
}
protected void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih, InstructionList new_il) {
old_ih.removeTargeter(this);
- if (new_ih != null)
+ if (new_ih != null) {
new_ih.addTargeter(this);
+ }
body = new_il;
if (old_ih == start) {
}
public static final boolean isRangeHandle(InstructionHandle ih) {
- if (ih == null)
+ if (ih == null) {
return false;
+ }
return ih.getInstruction() == Range.RANGEINSTRUCTION;
}
protected static final Range getRange(InstructionHandle ih) {
// assert isRangeHandle(ih)
Range ret = null;
- Iterator tIter = ih.getTargeters().iterator();
+ Iterator<InstructionTargeter> tIter = ih.getTargeters().iterator();
while (tIter.hasNext()) {
- InstructionTargeter targeter = (InstructionTargeter) tIter.next();
+ InstructionTargeter targeter = tIter.next();
if (targeter instanceof Range) {
Range r = (Range) targeter;
- if (r.getStart() != ih && r.getEnd() != ih)
+ if (r.getStart() != ih && r.getEnd() != ih) {
continue;
- if (ret != null)
+ }
+ if (ret != null) {
throw new BCException("multiple ranges on same range handle: " + ret + ", " + targeter);
+ }
ret = r;
}
}
// now go through again and update variable slots that have been altered as a result
// of remapping...
for (InstructionHandle newIh = freshBody.getStart(); newIh != freshBody.getEnd(); newIh = newIh.getNext()) {
- Iterator tIter = newIh.getTargeters().iterator();
+ Iterator<InstructionTargeter> tIter = newIh.getTargeters().iterator();
while (tIter.hasNext()) {
- InstructionTargeter source = (InstructionTargeter) tIter.next();
+ InstructionTargeter source = tIter.next();
if (source instanceof LocalVariableTag) {
LocalVariableTag lvt = (LocalVariableTag) source;
if (!lvt.isRemapped() && remap.hasKey(lvt.getSlot())) {
import org.aspectj.apache.bcel.generic.Type;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.weaver.AjAttribute;
+import org.aspectj.weaver.AjAttribute.WeaverVersionInfo;
import org.aspectj.weaver.AnnotationAJ;
import org.aspectj.weaver.BCException;
import org.aspectj.weaver.ConstantPoolReader;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.Utils;
import org.aspectj.weaver.World;
-import org.aspectj.weaver.AjAttribute.WeaverVersionInfo;
public class Utility {
kind = Constants.INVOKESPECIAL;
}
- return fact.createInvoke(signature.getDeclaringType().getName(), signature.getName(), BcelWorld.makeBcelType(signature
- .getReturnType()), BcelWorld.makeBcelTypes(signature.getParameterTypes()), kind);
+ return fact.createInvoke(signature.getDeclaringType().getName(), signature.getName(),
+ BcelWorld.makeBcelType(signature.getReturnType()), BcelWorld.makeBcelTypes(signature.getParameterTypes()), kind);
}
// XXX don't need the world now
kind = Constants.GETFIELD;
}
- return fact.createFieldAccess(signature.getDeclaringType().getName(), signature.getName(), BcelWorld.makeBcelType(signature
- .getReturnType()), kind);
+ return fact.createFieldAccess(signature.getDeclaringType().getName(), signature.getName(),
+ BcelWorld.makeBcelType(signature.getReturnType()), kind);
}
public static Instruction createSet(InstructionFactory fact, Member signature) {
kind = Constants.PUTFIELD;
}
- return fact.createFieldAccess(signature.getDeclaringType().getName(), signature.getName(), BcelWorld.makeBcelType(signature
- .getReturnType()), kind);
+ return fact.createFieldAccess(signature.getDeclaringType().getName(), signature.getName(),
+ BcelWorld.makeBcelType(signature.getReturnType()), kind);
}
public static Instruction createInstanceof(InstructionFactory fact, ReferenceType t) {
* @return
*/
public static Instruction createInvoke(InstructionFactory fact, short kind, Member member) {
- return fact.createInvoke(member.getDeclaringType().getName(), member.getName(), BcelWorld.makeBcelType(member
- .getReturnType()), BcelWorld.makeBcelTypes(member.getParameterTypes()), kind);
+ return fact.createInvoke(member.getDeclaringType().getName(), member.getName(),
+ BcelWorld.makeBcelType(member.getReturnType()), BcelWorld.makeBcelTypes(member.getParameterTypes()), kind);
}
private static String[] argNames = new String[] { "arg0", "arg1", "arg2", "arg3", "arg4" };
// tail recursion...
// public static int getSourceLine(InstructionHandle ih) {
// if (ih == null) return -1;
- //
+ //
// InstructionTargeter[] ts = ih.getTargeters();
// if (ts != null) {
// for (int j = ts.length - 1; j >= 0; j--) {
if (ih == null) {
return -1;
}
- Iterator tIter = ih.getTargeters().iterator();
+ Iterator<InstructionTargeter> tIter = ih.getTargeters().iterator();
while (tIter.hasNext()) {
- InstructionTargeter t = (InstructionTargeter) tIter.next();
+ InstructionTargeter t = tIter.next();
if (t instanceof LineNumberTag) {
return ((LineNumberTag) t).getLineNumber();
}
public static List<Lint.Kind> getSuppressedWarnings(AnnotationAJ[] anns, Lint lint) {
if (anns == null) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
// Go through the annotation types
List<Lint.Kind> suppressedWarnings = new ArrayList<Lint.Kind>();