diff options
author | aclement <aclement> | 2005-09-13 14:24:48 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-09-13 14:24:48 +0000 |
commit | a058bd9ae17ca3570ca53ff7d0feaaa2daf1102a (patch) | |
tree | fdf3b0af18db0c3a5bf0d598ffef0830d67dd5d1 | |
parent | 056db42f1697ed27a47e04759bfb8162acd92590 (diff) | |
download | aspectj-a058bd9ae17ca3570ca53ff7d0feaaa2daf1102a.tar.gz aspectj-a058bd9ae17ca3570ca53ff7d0feaaa2daf1102a.zip |
test and fix for pr106554: staticinitialization and PTW
-rw-r--r-- | tests/bugs150/pr106554/A.aj | 24 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/patterns/PerTypeWithin.java | 6 |
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/bugs150/pr106554/A.aj b/tests/bugs150/pr106554/A.aj new file mode 100644 index 000000000..ad657d701 --- /dev/null +++ b/tests/bugs150/pr106554/A.aj @@ -0,0 +1,24 @@ +public aspect A { + interface I { + // These fields will have their initialization logic stuffed in a static + // initializer in A$I + public static final String[] str = new String[] { "a","b"}; + public static final String[] str2 = str; + } + + static Class[] classes = { I.class }; + + static Object f = new Integer(1); + + public static void main(String args[]) { + System.out.println("test = "+f); + System.err.println("A:"+A.aspectOf()); + } +} + +aspect StopsInit pertypewithin(A) { + // These should match nothing in A$I + before() : staticinitialization(*) {} + before() : set(* *) && within(A$I) {} + before() : get(* *) && within(A$I) {} +} diff --git a/weaver/src/org/aspectj/weaver/patterns/PerTypeWithin.java b/weaver/src/org/aspectj/weaver/patterns/PerTypeWithin.java index 60f4faf65..f952f1461 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PerTypeWithin.java +++ b/weaver/src/org/aspectj/weaver/patterns/PerTypeWithin.java @@ -84,6 +84,12 @@ public class PerTypeWithin extends PerClause { shadow.getSourceLocation(),true,new ISourceLocation[]{getSourceLocation()}); shadow.getIWorld().getMessageHandler().handleMessage(msg); } + + // See pr106554 - we can't put advice calls in an interface when the advice is defined + // in a pertypewithin aspect - the JPs only exist in the static initializer and can't + // call the localAspectOf() method. + if (enclosingType.isInterface()) return FuzzyBoolean.NO; + typePattern.resolve(shadow.getIWorld()); return isWithinType(enclosingType); } |