import org.aspectj.weaver.patterns.Pointcut;
/**
- * Advice implemented for bcel.
+ * Advice implemented for BCEL
*
* @author Erik Hilsdale
* @author Jim Hugunin
+ * @author Andy Clement
*/
class BcelAdvice extends Advice {
- private Test pointcutTest;
+
+ /**
+ * If a match is not entirely statically determinable, this captures the runtime test that must succeed in order for the advice
+ * to run.
+ */
+ private Test runtimeTest;
private ExposedState exposedState;
- public BcelAdvice(AjAttribute.AdviceAttribute attribute, Pointcut pointcut, Member signature, ResolvedType concreteAspect) {
- super(attribute, pointcut, shrink(attribute.getKind(), concreteAspect, signature));// (signature==null?null:signature.slimline
- // ()));
+ public BcelAdvice(AjAttribute.AdviceAttribute attribute, Pointcut pointcut, Member adviceSignature, ResolvedType concreteAspect) {
+ super(attribute, pointcut, simplify(attribute.getKind(), adviceSignature));
this.concreteAspect = concreteAspect;
}
/**
- * We don't always need to represent the signature with a heavyweight BcelMethod object - only if its around advice and inlining
- * is active
- *
- * @param concreteAspect
- * @param attribute
+ * A heavyweight BcelMethod object is only required for around advice that will be inlined. For other kinds of advice it is
+ * possible to save some space.
*/
- private static Member shrink(AdviceKind kind, ResolvedType concreteAspect, Member m) {
- if (m == null)
- return null;
- UnresolvedType dType = m.getDeclaringType();
- // if it isnt around advice or it is but inlining is turned off then shrink it to a ResolvedMemberImpl
- if (kind != AdviceKind.Around || ((dType instanceof ResolvedType) && ((ResolvedType) dType).getWorld().isXnoInline())) {
- if (m instanceof BcelMethod) {
- BcelMethod bm = (BcelMethod) m;
- if (bm.getMethod() != null && bm.getMethod().getAnnotations() != null)
- return m;
- 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;
+ private static Member simplify(AdviceKind kind, Member adviceSignature) {
+ if (adviceSignature != null) {
+ UnresolvedType adviceDeclaringType = adviceSignature.getDeclaringType();
+ // if it isnt around advice or it is but inlining is turned off then shrink it to a ResolvedMemberImpl
+ if (kind != AdviceKind.Around
+ || ((adviceDeclaringType instanceof ResolvedType) && ((ResolvedType) adviceDeclaringType).getWorld()
+ .isXnoInline())) {
+ if (adviceSignature instanceof BcelMethod) {
+ BcelMethod bm = (BcelMethod) adviceSignature;
+ 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()
+ // );
+ simplermember.setParameterNames(bm.getParameterNames());
+ return simplermember;
+ }
}
}
- return m;
+ return adviceSignature;
}
- /**
- * For testing only
- */
- public BcelAdvice(AdviceKind kind, Pointcut pointcut, Member signature, int extraArgumentFlags, int start, int end,
- ISourceContext sourceContext, ResolvedType concreteAspect) {
- this(new AjAttribute.AdviceAttribute(kind, pointcut, extraArgumentFlags, start, end, sourceContext), pointcut, signature,
- concreteAspect);
- thrownExceptions = Collections.EMPTY_LIST; // !!! interaction with unit tests
- }
-
- // ---- implementations of ShadowMunger's methods
-
public ShadowMunger concretize(ResolvedType fromType, World world, PerClause clause) {
suppressLintWarnings(world);
ShadowMunger ret = super.concretize(fromType, world, clause);
World world = shadow.getIWorld();
suppressLintWarnings(world);
- pointcutTest = getPointcut().findResidue(shadow, exposedState);
+ runtimeTest = getPointcut().findResidue(shadow, exposedState);
clearLintSuppressions(world, this.suppressedLintKinds);
// these initializations won't be performed by findResidue, but need to be
}
if ((getExtraParameterFlags() & ThisJoinPoint) != 0) {
- boolean hasGuardTest = pointcutTest != Literal.TRUE && getKind() != AdviceKind.Around;
+ boolean hasGuardTest = runtimeTest != Literal.TRUE && getKind() != AdviceKind.Around;
boolean isAround = getKind() == AdviceKind.Around;
((BcelShadow) shadow).requireThisJoinPoint(hasGuardTest, isAround);
((BcelShadow) shadow).getEnclosingClass().warnOnAddedStaticInitializer(shadow, getSourceLocation());
}
private boolean canInline(Shadow s) {
- if (attribute.isProceedInInners())
+ if (attribute.isProceedInInners()) {
return false;
+ }
// XXX this guard seems to only be needed for bad test cases
- if (concreteAspect == null || concreteAspect.isMissing())
+ if (concreteAspect == null || concreteAspect.isMissing()) {
return false;
+ }
- if (concreteAspect.getWorld().isXnoInline())
+ if (concreteAspect.getWorld().isXnoInline()) {
return false;
+ }
// System.err.println("isWoven? " + ((BcelObjectType)concreteAspect).getLazyClassGen().getWeaverState());
BcelObjectType boType = BcelWorld.getBcelObjectType(concreteAspect);
if (boType == null) {
// PerObjectInterfaceTypeMunger.registerAsAdvisedBy(s.getTargetVar().getType(), getConcreteAspect());
// }
// }
- if (pointcutTest == Literal.FALSE) { // not usually allowed, except in one case (260384)
+ if (runtimeTest == Literal.FALSE) { // not usually allowed, except in one case (260384)
Member sig = shadow.getSignature();
if (sig.getArity() == 0 && shadow.getKind() == Shadow.MethodCall && sig.getName().charAt(0) == 'c'
&& sig.getReturnType().equals(ResolvedType.OBJECT) && sig.getName().equals("clone")) {
// ---- implementations
private Collection collectCheckedExceptions(UnresolvedType[] excs) {
- if (excs == null || excs.length == 0)
+ if (excs == null || excs.length == 0) {
return Collections.EMPTY_LIST;
+ }
Collection ret = new ArrayList();
World world = concreteAspect.getWorld();
// return true;
// }
- return pointcutTest != null && !(pointcutTest == Literal.TRUE);// || pointcutTest == Literal.NO_TEST);
+ return runtimeTest != null && !(runtimeTest == Literal.TRUE);// || pointcutTest == Literal.NO_TEST);
}
/**
final boolean isAnnotationStyleAspect = getConcreteAspect() != null && getConcreteAspect().isAnnotationStyleAspect() && x;
boolean previousIsClosure = false;
for (int i = 0, len = exposedState.size(); i < len; i++) {
- if (exposedState.isErroneousVar(i))
+ if (exposedState.isErroneousVar(i)) {
continue; // Erroneous vars have already had error msgs reported!
+ }
BcelVar v = (BcelVar) exposedState.get(i);
if (v == null) {
Member sig = getSignature();
if (sig instanceof ResolvedMember) {
ResolvedMember rsig = (ResolvedMember) sig;
- if (rsig.hasBackingGenericMember())
+ if (rsig.hasBackingGenericMember()) {
return rsig.getBackingGenericMember();
+ }
}
return sig;
}
public InstructionList getTestInstructions(BcelShadow shadow, InstructionHandle sk, InstructionHandle fk, InstructionHandle next) {
// System.err.println("test: " + pointcutTest);
- return BcelRenderer.renderTest(shadow.getFactory(), shadow.getWorld(), pointcutTest, sk, fk, next);
+ return BcelRenderer.renderTest(shadow.getFactory(), shadow.getWorld(), runtimeTest, sk, fk, next);
}
public int compareTo(Object other) {
- if (!(other instanceof BcelAdvice))
+ if (!(other instanceof BcelAdvice)) {
return 0;
+ }
BcelAdvice o = (BcelAdvice) other;
// System.err.println("compareTo: " + this + ", " + o);
if (kind.getPrecedence() != o.kind.getPrecedence()) {
- if (kind.getPrecedence() > o.kind.getPrecedence())
+ if (kind.getPrecedence() > o.kind.getPrecedence()) {
return +1;
- else
+ } else {
return -1;
+ }
}
if (kind.isCflow()) {
// System.err.println(" " + o + " innerCflowEntries " + o.innerCflowEntries);
boolean isBelow = (kind == AdviceKind.CflowBelowEntry);
- if (this.innerCflowEntries.contains(o))
+ if (this.innerCflowEntries.contains(o)) {
return isBelow ? +1 : -1;
- else if (o.innerCflowEntries.contains(this))
+ } else if (o.innerCflowEntries.contains(this)) {
return isBelow ? -1 : +1;
- else
+ } else {
return 0;
+ }
}
if (kind.isPerEntry() || kind == AdviceKind.Softener) {
World world = concreteAspect.getWorld();
int ret = concreteAspect.getWorld().compareByPrecedence(concreteAspect, o.concreteAspect);
- if (ret != 0)
+ if (ret != 0) {
return ret;
+ }
ResolvedType declaringAspect = getDeclaringAspect().resolve(world);
ResolvedType o_declaringAspect = o.getDeclaringAspect().resolve(world);
}
// System.out.println("vars: " + Arrays.asList(exposedState.vars));
- if (exposedState == null)
+ if (exposedState == null) {
return BcelVar.NONE;
+ }
int len = exposedState.vars.length;
BcelVar[] ret = new BcelVar[len];
for (int i = 0; i < len; i++) {
protected void clearLintSuppressions(World inWorld, Collection toClear) {
inWorld.getLint().clearSuppressions(toClear);
}
+
+ /**
+ * For testing only
+ */
+ public BcelAdvice(AdviceKind kind, Pointcut pointcut, Member signature, int extraArgumentFlags, int start, int end,
+ ISourceContext sourceContext, ResolvedType concreteAspect) {
+ this(new AjAttribute.AdviceAttribute(kind, pointcut, extraArgumentFlags, start, end, sourceContext), pointcut, signature,
+ concreteAspect);
+ thrownExceptions = Collections.EMPTY_LIST; // !!! interaction with unit tests
+ }
+
}
\ No newline at end of file
package org.aspectj.weaver.bcel;
import java.io.ByteArrayInputStream;
+import java.io.DataOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import org.aspectj.apache.bcel.classfile.ClassParser;
import org.aspectj.apache.bcel.classfile.JavaClass;
-import org.aspectj.asm.AsmManager;
-import org.aspectj.asm.IHierarchy;
-import org.aspectj.asm.IProgramElement;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.Message;
public class BcelWeaver {
public static final String CLOSURE_CLASS_PREFIX = "$Ajc";
-
public static final String SYNTHETIC_CLASS_POSTFIX = "$ajc";
- private final BcelWorld world;
+ private static Trace trace = TraceFactory.getTraceFactory().getTrace(BcelWeaver.class);
+
+ private transient final BcelWorld world;
private final CrosscuttingMembersSet xcutSet;
private boolean inReweavableMode = false;
- private static Trace trace = TraceFactory.getTraceFactory().getTrace(BcelWeaver.class);
+ // 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 shadowMungerList = null; // setup by prepareForWeave
+ private transient List typeMungerList = null; // setup by prepareForWeave
+ private transient List lateTypeMungerList = null; // setup by prepareForWeave
+ private transient List declareParentsList = null; // setup by prepareForWeave
- public BcelWeaver(BcelWorld world) {
- super();
- if (trace.isTraceEnabled())
- trace.enter("<init>", this, world);
- this.world = world;
- this.xcutSet = world.getCrosscuttingMembersSet();
- if (trace.isTraceEnabled())
- trace.exit("<init>");
- }
-
- // ---- fields
- // private Map sourceJavaClasses = new HashMap(); /* String ->
- // UnwovenClassFile */
- private List addedClasses = new ArrayList(); /* List<UnwovenClassFile> */
- private List deletedTypenames = new ArrayList(); /* List<String> */
- // private Map resources = new HashMap(); /* String -> UnwovenClassFile */
private Manifest manifest = null;
private boolean needToReweaveWorld = false;
private boolean isBatchWeave = true;
- private List shadowMungerList = null; // setup by prepareForWeave
- private List typeMungerList = null; // setup by prepareForWeave
- private List lateTypeMungerList = null; // setup by prepareForWeave
- private List declareParentsList = null; // setup by prepareForWeave
private ZipOutputStream zipOutputStream;
private CustomMungerFactory customMungerFactory;
- // ----
+ // ---
+
+ public BcelWeaver(BcelWorld world) {
+ super();
+ if (trace.isTraceEnabled()) {
+ trace.enter("<init>", this, world);
+ }
+ this.world = world;
+ this.xcutSet = world.getCrosscuttingMembersSet();
+ if (trace.isTraceEnabled()) {
+ trace.exit("<init>");
+ }
+ }
// only called for testing
- public void setShadowMungers(List l) {
- shadowMungerList = l;
+ public void setShadowMungers(List shadowMungers) {
+ shadowMungerList = shadowMungers;
}
/**
* @return aspect
*/
public ResolvedType addLibraryAspect(String aspectName) {
- if (trace.isTraceEnabled())
+ if (trace.isTraceEnabled()) {
trace.enter("addLibraryAspect", this, aspectName);
+ }
// 1 - resolve as is
UnresolvedType unresolvedT = UnresolvedType.forName(aspectName);
// => mainly for nothing for LTW - pbly for something in incremental
// build...
xcutSet.addOrReplaceAspect(type);
- if (trace.isTraceEnabled())
+ if (trace.isTraceEnabled()) {
trace.exit("addLibraryAspect", type);
+ }
if (type.getSuperclass().isAspect()) {
// If the supertype includes ITDs and the user has not included
// that aspect in the aop.xml, they will
} else {
// FIXME AV - better warning upon no such aspect from aop.xml
RuntimeException ex = new RuntimeException("Cannot register non aspect: " + type.getName() + " , " + aspectName);
- if (trace.isTraceEnabled())
+ if (trace.isTraceEnabled()) {
trace.exit("addLibraryAspect", ex);
+ }
throw ex;
}
}
try {
while (true) {
ZipEntry entry = inStream.getNextEntry();
- if (entry == null)
+ if (entry == null) {
break;
+ }
if (entry.isDirectory() || !entry.getName().endsWith(".class")) {
continue;
}
public void prepareForWeave() {
- if (trace.isTraceEnabled())
+ if (trace.isTraceEnabled()) {
trace.enter("prepareForWeave", this);
+ }
needToReweaveWorld = xcutSet.hasChangedSinceLastReset();
// update mungers
for (Iterator i = deletedTypenames.iterator(); i.hasNext();) {
String name = (String) i.next();
- if (xcutSet.deleteAspect(UnresolvedType.forName(name)))
+ if (xcutSet.deleteAspect(UnresolvedType.forName(name))) {
needToReweaveWorld = true;
+ }
}
shadowMungerList = xcutSet.getShadowMungers();
public int compare(Object o1, Object o2) {
ShadowMunger sm1 = (ShadowMunger) o1;
ShadowMunger sm2 = (ShadowMunger) o2;
- if (sm1.getSourceLocation() == null)
+ if (sm1.getSourceLocation() == null) {
return (sm2.getSourceLocation() == null ? 0 : 1);
- if (sm2.getSourceLocation() == null)
+ }
+ if (sm2.getSourceLocation() == null) {
return -1;
+ }
return (sm2.getSourceLocation().getOffset() - sm1.getSourceLocation().getOffset());
}
});
- if (inReweavableMode)
+ if (inReweavableMode) {
world.showMessage(IMessage.INFO, WeaverMessages.format(WeaverMessages.REWEAVABLE_MODE), null, null);
+ }
- if (trace.isTraceEnabled())
+ if (trace.isTraceEnabled()) {
trace.exit("prepareForWeave");
+ }
}
private void addCustomMungers() {
shadowMungerList.addAll(shadowMungers);
}
Collection/* ConcreteTypeMunger */typeMungers = customMungerFactory.createCustomTypeMungers(type);
- if (typeMungers != null)
+ if (typeMungers != null) {
typeMungerList.addAll(typeMungers);
+ }
}
}
}
private Pointcut shareEntriesFromMap(Pointcut p, Map pcMap) {
// some things cant be shared...
- if (p instanceof NameBindingPointcut)
+ if (p instanceof NameBindingPointcut) {
return p;
- if (p instanceof IfPointcut)
+ }
+ if (p instanceof IfPointcut) {
return p;
- if (p instanceof ConcreteCflowPointcut)
+ }
+ if (p instanceof ConcreteCflowPointcut) {
return p;
+ }
if (p instanceof AndPointcut) {
AndPointcut apc = (AndPointcut) p;
Pointcut left = shareEntriesFromMap(apc.getLeft(), pcMap);
// join point kinds in
// common.
private void validateBindings(Pointcut dnfPointcut, Pointcut userPointcut, int numFormals, String[] names) {
- if (numFormals == 0)
+ if (numFormals == 0) {
return; // nothing to check
- if (dnfPointcut.couldMatchKinds() == Shadow.NO_SHADOW_KINDS_BITS)
+ }
+ if (dnfPointcut.couldMatchKinds() == Shadow.NO_SHADOW_KINDS_BITS) {
return; // cant have problems if you dont match!
+ }
if (dnfPointcut instanceof OrPointcut) {
OrPointcut orBasedDNFPointcut = (OrPointcut) dnfPointcut;
Pointcut[] leftBindings = new Pointcut[numFormals];
Pointcut[] newRightBindings = new Pointcut[numFormals];
validateOrBranch((OrPointcut) left, userPointcut, numFormals, names, leftBindings, newRightBindings);
} else {
- if (left.couldMatchKinds() != Shadow.NO_SHADOW_KINDS_BITS)
+ if (left.couldMatchKinds() != Shadow.NO_SHADOW_KINDS_BITS) {
validateSingleBranch(left, userPointcut, numFormals, names, leftBindings);
+ }
}
if (right instanceof OrPointcut) {
Pointcut[] newLeftBindings = new Pointcut[numFormals];
validateOrBranch((OrPointcut) right, userPointcut, numFormals, names, newLeftBindings, rightBindings);
} else {
- if (right.couldMatchKinds() != Shadow.NO_SHADOW_KINDS_BITS)
+ if (right.couldMatchKinds() != Shadow.NO_SHADOW_KINDS_BITS) {
validateSingleBranch(right, userPointcut, numFormals, names, rightBindings);
+ }
}
int kindsInCommon = left.couldMatchKinds() & right.couldMatchKinds();
if (kindsInCommon != Shadow.NO_SHADOW_KINDS_BITS && couldEverMatchSameJoinPoints(left, right)) {
ambiguousNames.add(names[i]);
}
}
- if (!ambiguousNames.isEmpty())
+ if (!ambiguousNames.isEmpty()) {
raiseAmbiguityInDisjunctionError(userPointcut, ambiguousNames);
+ }
}
}
NotPointcut not = (NotPointcut) pc;
if (not.getNegatedPointcut() instanceof NameBindingPointcut) {
NameBindingPointcut nnbp = (NameBindingPointcut) not.getNegatedPointcut();
- if (!nnbp.getBindingAnnotationTypePatterns().isEmpty() && !nnbp.getBindingTypePatterns().isEmpty())
+ if (!nnbp.getBindingAnnotationTypePatterns().isEmpty() && !nnbp.getBindingTypePatterns().isEmpty()) {
raiseNegationBindingError(userPointcut);
+ }
}
} else if (pc instanceof AndPointcut) {
AndPointcut and = (AndPointcut) pc;
if (left instanceof OrPointcut) {
OrPointcut leftOrPointcut = (OrPointcut) left;
- if (couldEverMatchSameJoinPoints(leftOrPointcut.getLeft(), right))
+ if (couldEverMatchSameJoinPoints(leftOrPointcut.getLeft(), right)) {
return true;
- if (couldEverMatchSameJoinPoints(leftOrPointcut.getRight(), right))
+ }
+ if (couldEverMatchSameJoinPoints(leftOrPointcut.getRight(), right)) {
return true;
+ }
return false;
}
if (right instanceof OrPointcut) {
OrPointcut rightOrPointcut = (OrPointcut) right;
- if (couldEverMatchSameJoinPoints(left, rightOrPointcut.getLeft()))
+ if (couldEverMatchSameJoinPoints(left, rightOrPointcut.getLeft())) {
return true;
- if (couldEverMatchSameJoinPoints(left, rightOrPointcut.getRight()))
+ }
+ if (couldEverMatchSameJoinPoints(left, rightOrPointcut.getRight())) {
return true;
+ }
return false;
}
WithinPointcut leftWithin = (WithinPointcut) findFirstPointcutIn(left, WithinPointcut.class);
WithinPointcut rightWithin = (WithinPointcut) findFirstPointcutIn(right, WithinPointcut.class);
if ((leftWithin != null) && (rightWithin != null)) {
- if (!leftWithin.couldEverMatchSameJoinPointsAs(rightWithin))
+ if (!leftWithin.couldEverMatchSameJoinPointsAs(rightWithin)) {
return false;
+ }
}
// look for kinded
KindedPointcut leftKind = (KindedPointcut) findFirstPointcutIn(left, KindedPointcut.class);
KindedPointcut rightKind = (KindedPointcut) findFirstPointcutIn(right, KindedPointcut.class);
if ((leftKind != null) && (rightKind != null)) {
- if (!leftKind.couldEverMatchSameJoinPointsAs(rightKind))
+ if (!leftKind.couldEverMatchSameJoinPointsAs(rightKind)) {
return false;
+ }
}
return true;
}
private Pointcut findFirstPointcutIn(Pointcut toSearch, Class toLookFor) {
- if (toSearch instanceof NotPointcut)
+ if (toSearch instanceof NotPointcut) {
return null;
- if (toLookFor.isInstance(toSearch))
+ }
+ if (toLookFor.isInstance(toSearch)) {
return toSearch;
+ }
if (toSearch instanceof AndPointcut) {
AndPointcut apc = (AndPointcut) toSearch;
Pointcut left = findFirstPointcutIn(apc.getLeft(), toLookFor);
- if (left != null)
+ if (left != null) {
return left;
+ }
return findFirstPointcutIn(apc.getRight(), toLookFor);
}
return null;
// variation of "weave" that sources class files from an external source.
public Collection weave(IClassFileProvider input) throws IOException {
- if (trace.isTraceEnabled())
+ if (trace.isTraceEnabled()) {
trace.enter("weave", this, input);
+ }
ContextToken weaveToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING, "");
Collection wovenClassNames = new ArrayList();
IWeaveRequestor requestor = input.getRequestor();
// error will be reported again from
// the eclipse source type) - pr113531
ReferenceTypeDelegate theDelegate = ((ReferenceType) theType).getDelegate();
- if (theDelegate.getClass().getName().endsWith("EclipseSourceType"))
+ if (theDelegate.getClass().getName().endsWith("EclipseSourceType")) {
continue;
+ }
throw new BCException("Can't find bcel delegate for " + className + " type=" + theType.getClass());
}
// TODO urgh - put a method on the interface to check this,
// string compare is hideous
- if (theDelegate.getClass().getName().endsWith("EclipseSourceType"))
+ if (theDelegate.getClass().getName().endsWith("EclipseSourceType")) {
continue;
+ }
throw new BCException("Can't find bcel delegate for " + className + " type=" + theType.getClass());
}
}
CompilationAndWeavingContext.leavingPhase(classToken);
- addedClasses = new ArrayList();
- deletedTypenames = new ArrayList();
+ addedClasses.clear();
+ deletedTypenames.clear();
requestor.weaveCompleted();
CompilationAndWeavingContext.leavingPhase(weaveToken);
- if (trace.isTraceEnabled())
+ if (trace.isTraceEnabled()) {
trace.exit("weave", wovenClassNames);
+ }
return wovenClassNames;
}
}
public boolean equals(Object obj) {
- if (!(obj instanceof AdviceLocation))
+ if (!(obj instanceof AdviceLocation)) {
return false;
+ }
AdviceLocation other = (AdviceLocation) obj;
- if (this.lineNo != other.lineNo)
+ if (this.lineNo != other.lineNo) {
return false;
- if (!this.inAspect.equals(other.inAspect))
+ }
+ if (!this.inAspect.equals(other.inAspect)) {
return false;
+ }
return true;
}
if (!xcutSet.containsAspect(rtx)) {
world.showMessage(IMessage.ERROR, WeaverMessages.format(
WeaverMessages.REWEAVABLE_ASPECT_NOT_REGISTERED, requiredTypeName, className), null, null);
- } else if (!world.getMessageHandler().isIgnoring(IMessage.INFO))
+ } else if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) {
world.showMessage(IMessage.INFO, WeaverMessages.format(WeaverMessages.VERIFIED_REWEAVABLE_TYPE,
requiredTypeName, rtx.getSourceLocation().getSourceFile()), null, null);
+ }
alreadyConfirmedReweavableState.add(requiredTypeName);
}
}
* algorithm is optimal ??
*/
public void weaveParentTypeMungers(ResolvedType onType) {
- if (onType.isRawType())
+ if (onType.isRawType()) {
onType = onType.getGenericType();
+ }
onType.clearInterTypeMungers();
List decpToRepeat = new ArrayList();
List newParents = p.findMatchingNewParents(onType, true);
if (!newParents.isEmpty()) {
didSomething = true;
- BcelObjectType classType = BcelWorld.getBcelObjectType(onType);
+ BcelWorld.getBcelObjectType(onType);
// System.err.println("need to do declare parents for: " + onType);
for (Iterator j = newParents.iterator(); j.hasNext();) {
ResolvedType newParent = (ResolvedType) j.next();
public void weaveNormalTypeMungers(ResolvedType onType) {
ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_TYPE_MUNGERS, onType
.getName());
- if (onType.isRawType() || onType.isParameterizedType())
+ if (onType.isRawType() || onType.isParameterizedType()) {
onType = onType.getGenericType();
+ }
for (Iterator i = typeMungerList.iterator(); i.hasNext();) {
ConcreteTypeMunger m = (ConcreteTypeMunger) i.next();
if (!m.isLateMunger() && m.matches(onType)) {
private LazyClassGen weave(UnwovenClassFile classFile, BcelObjectType classType, boolean dump) throws IOException {
if (classType.isSynthetic()) { // Don't touch synthetic classes
- if (dump)
+ if (dump) {
dumpUnchanged(classFile);
+ }
return null;
}
try {
boolean isChanged = false;
- if (mightNeedToWeave)
+ if (mightNeedToWeave) {
isChanged = BcelClassWeaver.weave(world, clazz, shadowMungers, typeMungers, lateTypeMungerList,
inReweavableMode);
+ }
- if (mightNeedBridgeMethods)
+ if (mightNeedBridgeMethods) {
isChanged = BcelClassWeaver.calculateAnyRequiredBridgeMethods(world, clazz) || isChanged;
+ }
if (isChanged) {
- if (dump)
+ if (dump) {
dump(classFile, clazz);
+ }
return clazz;
}
} catch (RuntimeException re) {
}
world.demote();
// this is very odd return behavior trying to keep everyone happy
-/*
- // can we remove it from the model now? we know it contains no relationship endpoints...
- AsmManager asm = world.getModelAsAsmManager();
- if (asm != null) {
- IHierarchy model = asm.getHierarchy();
- if (!classType.isAspect()) {
-
- String pkgname = classType.getResolvedTypeX().getPackageName();
- String tname = classType.getResolvedTypeX().getSimpleBaseName();
- IProgramElement typeElement = model.findElementForType(pkgname, tname);
- if (typeElement != null) {
- Set deleted = new HashSet();
- deleted.add(asm.getCanonicalFilePath(typeElement.getSourceLocation().getSourceFile()));
-
- model.updateHandleMap(deleted);
- IProgramElement parent = typeElement.getParent();
- // parent may have children: PACKAGE DECL, IMPORT-REFEFERENCE, TYPE_DECL
- if (parent != null) {
- typeElement.getParent().removeChild(typeElement);
- // System.out.println("Removing " + classType.getResolvedTypeX().getName() + "? "
- // + );
- }
- }
- }
- }
-*/
+ /*
+ * // can we remove it from the model now? we know it contains no relationship endpoints... AsmManager asm =
+ * world.getModelAsAsmManager(); if (asm != null) { IHierarchy model = asm.getHierarchy(); if (!classType.isAspect()) {
+ *
+ * String pkgname = classType.getResolvedTypeX().getPackageName(); String tname =
+ * classType.getResolvedTypeX().getSimpleBaseName(); IProgramElement typeElement = model.findElementForType(pkgname, tname);
+ * if (typeElement != null) { Set deleted = new HashSet();
+ * deleted.add(asm.getCanonicalFilePath(typeElement.getSourceLocation().getSourceFile()));
+ *
+ * model.updateHandleMap(deleted); IProgramElement parent = typeElement.getParent(); // parent may have children: PACKAGE
+ * DECL, IMPORT-REFEFERENCE, TYPE_DECL if (parent != null) { typeElement.getParent().removeChild(typeElement); //
+ * System.out.println("Removing " + classType.getResolvedTypeX().getName() + "? " // + ); } } } }
+ */
if (dump) {
dumpUnchanged(classFile);
return clazz;
}
private List fastMatch(List list, ResolvedType type) {
- if (list == null)
+ if (list == null) {
return Collections.EMPTY_LIST;
+ }
// here we do the coarsest grained fast match with no kind constraints
// this will remove all obvious non-matches and see if we need to do any
}
public void tidyUp() {
- if (trace.isTraceEnabled())
+ if (trace.isTraceEnabled()) {
trace.enter("tidyUp", this);
+ }
shadowMungerList = null; // setup by prepareForWeave
typeMungerList = null; // setup by prepareForWeave
lateTypeMungerList = null; // setup by prepareForWeave
declareParentsList = null; // setup by prepareForWeave
- if (trace.isTraceEnabled())
+ if (trace.isTraceEnabled()) {
trace.exit("tidyUp");
+ }
+ }
+
+ public void write(DataOutputStream dos) throws IOException {
+ xcutSet.write(dos);
}
}