aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authorjhugunin <jhugunin>2002-12-17 19:44:10 +0000
committerjhugunin <jhugunin>2002-12-17 19:44:10 +0000
commiteddbb2567fdc715d0371e3b0c2563dadf5c6b034 (patch)
tree7be5a19951d18a7309e5e6d5ab2c97823ff6366c /weaver
parentdc91b4a21b412d2b30277d37922459132426f602 (diff)
downloadaspectj-eddbb2567fdc715d0371e3b0c2563dadf5c6b034.tar.gz
aspectj-eddbb2567fdc715d0371e3b0c2563dadf5c6b034.zip
more bug fixes
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/Shadow.java8
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java31
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelShadow.java11
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/Utility.java3
4 files changed, 45 insertions, 8 deletions
diff --git a/weaver/src/org/aspectj/weaver/Shadow.java b/weaver/src/org/aspectj/weaver/Shadow.java
index 22f86deb9..fd5c37fa7 100644
--- a/weaver/src/org/aspectj/weaver/Shadow.java
+++ b/weaver/src/org/aspectj/weaver/Shadow.java
@@ -50,13 +50,19 @@ public abstract class Shadow {
public final boolean hasTarget() {
return !(getSignature().isStatic() || (getKind() == ConstructorCall)
- || (getKind() == PreInitialization));
+ || (getKind() == PreInitialization));
}
public final TypeX getTargetType() {
if (!hasTarget()) return ResolvedTypeX.MISSING;
return getSignature().getDeclaringType();
}
+
+ public TypeX[] getArgTypes() {
+ if (getKind() == FieldSet) return new TypeX[] { getSignature().getReturnType() };
+ return getSignature().getParameterTypes();
+ }
+
public TypeX getArgType(int arg) {
if (getKind() == FieldSet) return getSignature().getReturnType();
return getSignature().getParameterTypes()[arg];
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
index 74d2ace0f..a56b7d139 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
@@ -13,6 +13,7 @@
package org.aspectj.weaver.bcel;
+import java.lang.reflect.Modifier;
import java.util.*;
import org.apache.bcel.Constants;
@@ -764,10 +765,34 @@ class BcelClassWeaver implements IClassWeaver {
Instruction i = ih.getInstruction();
if (i instanceof FieldInstruction) {
FieldInstruction fi = (FieldInstruction) i;
+
+
+
if (i instanceof PUTFIELD || i instanceof PUTSTATIC) {
- match(
- BcelShadow.makeFieldSet(world, mg, ih, enclosingShadow),
- shadowAccumulator);
+ // check for sets of constant fields. We first check the previous
+ // instruction. If the previous instruction is a LD_WHATEVER (push
+ // constant on the stack) then we must resolve the field to determine
+ // if it's final. If it is final, then we don't generate a shadow.
+ InstructionHandle prevHandle = ih.getPrev();
+ Instruction prevI = prevHandle.getInstruction();
+ if (Utility.isConstantPushInstruction(prevI)) {
+ Member field = world.makeFieldSignature(clazz, (FieldInstruction) i);
+ ResolvedMember resolvedField = field.resolve(world);
+ if (resolvedField == null) {
+ // we can't find the field, so it's not a join point.
+ } else if (Modifier.isFinal(resolvedField.getModifiers())) {
+ // 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);
+ }
+ } else {
+ match(
+ BcelShadow.makeFieldSet(world, mg, ih, enclosingShadow),
+ shadowAccumulator);
+ }
} else {
match(
BcelShadow.makeFieldGet(world, mg, ih, enclosingShadow),
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
index acc8f96f1..5f77b50ef 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
@@ -162,9 +162,12 @@ public class BcelShadow extends Shadow {
retargetFrom(dupHandle, nextHandle);
retargetFrom(endHandle, nextHandle);
} else {
- // XXX we want to fail gracefully here. This should not be picked out as a join point,
- // probably. So change BcelClassWeaver.match appropriately.
- throw new RuntimeException("Unhandled kind of new");
+ endHandle = newHandle;
+ nextHandle = endHandle.getNext();
+ retargetFrom(newHandle, nextHandle);
+ // add a POP here... we found a NEW w/o a dup or anything else, so
+ // we must be in statement context.
+ getRange().insert(getFactory().POP, Range.OutsideAfter);
}
// assert (dupHandle.getInstruction() instanceof DUP);
@@ -1669,7 +1672,7 @@ public class BcelShadow extends Shadow {
* ??? rewrite this to do less array munging, please
*/
private LazyMethodGen createMethodGen(String newMethodName) {
- Type[] parameterTypes = world.makeBcelTypes(getSignature().getParameterTypes());
+ Type[] parameterTypes = world.makeBcelTypes(getArgTypes());
int modifiers = Modifier.FINAL;
// XXX some bug
diff --git a/weaver/src/org/aspectj/weaver/bcel/Utility.java b/weaver/src/org/aspectj/weaver/bcel/Utility.java
index 9da48c01f..dc8dde9b8 100644
--- a/weaver/src/org/aspectj/weaver/bcel/Utility.java
+++ b/weaver/src/org/aspectj/weaver/bcel/Utility.java
@@ -439,4 +439,7 @@ public class Utility {
return ret;
}
+ public static boolean isConstantPushInstruction(Instruction i) {
+ return (i instanceof ConstantPushInstruction) || (i instanceof LDC);
+ }
}