Instruction i = ih.getInstruction();
if (i instanceof FieldInstruction) {
FieldInstruction fi = (FieldInstruction) i;
-
-
-
+
if (i instanceof PUTFIELD || i instanceof PUTSTATIC) {
// check for sets of constant fields. We first check the previous
// instruction. If the previous instruction is a LD_WHATEVER (push
// it's final, so it's the set of a final constant, so it's
// not a join point according to 1.0.6 and 1.1.
} else {
- match(
- BcelShadow.makeFieldSet(world, mg, ih, enclosingShadow),
- shadowAccumulator);
+ matchSetInstruction(mg, ih, enclosingShadow, shadowAccumulator);
}
} else {
- match(
- BcelShadow.makeFieldSet(world, mg, ih, enclosingShadow),
- shadowAccumulator);
+ matchSetInstruction(mg, ih, enclosingShadow, shadowAccumulator);
}
} else {
- match(
- BcelShadow.makeFieldGet(world, mg, ih, enclosingShadow),
- shadowAccumulator);
+ matchGetInstruction(mg, ih, enclosingShadow, shadowAccumulator);
}
} else if (i instanceof InvokeInstruction) {
InvokeInstruction ii = (InvokeInstruction) i;
}
}
+
+ private void matchSetInstruction(LazyMethodGen mg, InstructionHandle ih, BcelShadow enclosingShadow, List shadowAccumulator) {
+ FieldInstruction fi = (FieldInstruction) ih.getInstruction();
+ Member field = world.makeFieldSignature(clazz, fi);
+ ResolvedMember resolvedField = field.resolve(world);
+ if (resolvedField == null) {
+ // we can't find the field, so it's not a join point.
+ return;
+ } else if (Modifier.isFinal(resolvedField.getModifiers()) &&
+ Utility.isConstantPushInstruction(ih.getPrev().getInstruction()))
+ {
+ // it's the set of a final constant, so it's
+ // not a join point according to 1.0.6 and 1.1.
+ return;
+ } else if (resolvedField.isSynthetic()) {
+ // sets of synthetics aren't join points in 1.1
+ return;
+ } else {
+ match(BcelShadow.makeFieldSet(world, mg, ih, enclosingShadow), shadowAccumulator);
+ }
+ }
+
+ private void matchGetInstruction(LazyMethodGen mg, InstructionHandle ih, BcelShadow enclosingShadow, List shadowAccumulator) {
+ FieldInstruction fi = (FieldInstruction) ih.getInstruction();
+ Member field = world.makeFieldSignature(clazz, fi);
+ ResolvedMember resolvedField = field.resolve(world);
+ if (resolvedField == null) {
+ // we can't find the field, so it's not a join point.
+ return;
+ } else if (resolvedField.isSynthetic()) {
+ // sets of synthetics aren't join points in 1.1
+ return;
+ } else {
+ match(BcelShadow.makeFieldGet(world, mg, ih, enclosingShadow), shadowAccumulator);
+ }
+ }
+
private void matchInvokeInstruction(LazyMethodGen mg,
InstructionHandle ih,
InvokeInstruction invoke,
import java.util.Iterator;
import java.util.List;
+import org.apache.bcel.classfile.Attribute;
import org.apache.bcel.classfile.Field;
+import org.apache.bcel.classfile.Synthetic;
import org.aspectj.weaver.AjAttribute;
import org.aspectj.weaver.BCException;
import org.aspectj.weaver.ResolvedMember;
private Field field;
private boolean isAjSynthetic;
+ private boolean isSynthetic = false;
BcelField(BcelObjectType declaringType, Field field) {
super(
// ----
private void unpackAttributes(World world) {
- List as = BcelAttributes.readAjAttributes(field.getAttributes(), getSourceContext(world));
+ Attribute[] attrs = field.getAttributes();
+ List as = BcelAttributes.readAjAttributes(attrs, getSourceContext(world));
for (Iterator iter = as.iterator(); iter.hasNext();) {
AjAttribute a = (AjAttribute) iter.next();
if (a instanceof AjAttribute.AjSynthetic) {
}
}
isAjSynthetic = false;
+
+
+ for (int i = attrs.length - 1; i >= 0; i--) {
+ if (attrs[i] instanceof Synthetic) isSynthetic = true;
+ }
}
+
+
public boolean isAjSynthetic() {
return isAjSynthetic; // || getName().startsWith(NameMangler.PREFIX);
}
+
+ public boolean isSynthetic() {
+ return isSynthetic;
+ }
}