aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authorjhugunin <jhugunin>2003-07-24 21:37:04 +0000
committerjhugunin <jhugunin>2003-07-24 21:37:04 +0000
commit8060fec634b2f790599cbb71e660d8a0c2231e43 (patch)
treecde41c10c5b84b4e8efacadbb26962b9c7097104 /weaver
parent01b77ac07d292a8bdafc9c10112f4f89bae204ec (diff)
downloadaspectj-8060fec634b2f790599cbb71e660d8a0c2231e43.tar.gz
aspectj-8060fec634b2f790599cbb71e660d8a0c2231e43.zip
fix and moved test for Bugzilla Bug 39711
Class Literals as non final fields
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedMember.java5
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java53
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelField.java17
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelMethod.java2
4 files changed, 63 insertions, 14 deletions
diff --git a/weaver/src/org/aspectj/weaver/ResolvedMember.java b/weaver/src/org/aspectj/weaver/ResolvedMember.java
index b457db0b4..60164e167 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedMember.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedMember.java
@@ -88,6 +88,10 @@ public class ResolvedMember extends Member implements IHasPosition {
return true;
}
+ public boolean isSynthetic() {
+ return false;
+ }
+
public void write(DataOutputStream s) throws IOException {
getKind().write(s);
getDeclaringType().write(s);
@@ -194,6 +198,5 @@ public class ResolvedMember extends Member implements IHasPosition {
public void setCheckedExceptions(TypeX[] checkedExceptions) {
this.checkedExceptions = checkedExceptions;
}
-
}
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
index 97c8fbdae..5595b45db 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
@@ -833,9 +833,7 @@ class BcelClassWeaver implements IClassWeaver {
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
@@ -852,19 +850,13 @@ class BcelClassWeaver implements IClassWeaver {
// 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;
@@ -907,6 +899,43 @@ class BcelClassWeaver implements IClassWeaver {
}
}
+
+ 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,
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelField.java b/weaver/src/org/aspectj/weaver/bcel/BcelField.java
index 72cc5bd0f..f4b93d952 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelField.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelField.java
@@ -16,7 +16,9 @@ package org.aspectj.weaver.bcel;
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;
@@ -27,6 +29,7 @@ final class BcelField extends ResolvedMember {
private Field field;
private boolean isAjSynthetic;
+ private boolean isSynthetic = false;
BcelField(BcelObjectType declaringType, Field field) {
super(
@@ -43,7 +46,8 @@ final class BcelField extends ResolvedMember {
// ----
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) {
@@ -53,9 +57,20 @@ final class BcelField extends ResolvedMember {
}
}
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;
+ }
}
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
index 788258010..a2a4a5fc2 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
@@ -103,6 +103,8 @@ final class BcelMethod extends ResolvedMember {
return isAjSynthetic; // || getName().startsWith(NameMangler.PREFIX);
}
+ //FIXME needs an isSynthetic method
+
public ShadowMunger getAssociatedShadowMunger() {
return associatedShadowMunger;
}