diff options
author | acolyer <acolyer> | 2005-03-10 09:39:56 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-03-10 09:39:56 +0000 |
commit | 983eb455bf4617debc32779d5ae6d29e4b40e232 (patch) | |
tree | 63a4eda102a36b59778db0393af601e084aa9998 | |
parent | 63f9352372d564ea837feaa459cbddc76afbaa0d (diff) | |
download | aspectj-983eb455bf4617debc32779d5ae6d29e4b40e232.tar.gz aspectj-983eb455bf4617debc32779d5ae6d29e4b40e232.zip |
fixes for annotation type pattern bugs uncovered in 150 tests
59 files changed, 146 insertions, 32 deletions
diff --git a/ajde/testdata/DuplicateManifestTest/aspectjar.jar b/ajde/testdata/DuplicateManifestTest/aspectjar.jar Binary files differindex 3ae297a46..4d7da738a 100644 --- a/ajde/testdata/DuplicateManifestTest/aspectjar.jar +++ b/ajde/testdata/DuplicateManifestTest/aspectjar.jar diff --git a/ajde/testdata/DuplicateManifestTest/injar.jar b/ajde/testdata/DuplicateManifestTest/injar.jar Binary files differindex 712255876..7f1ec16af 100644 --- a/ajde/testdata/DuplicateManifestTest/injar.jar +++ b/ajde/testdata/DuplicateManifestTest/injar.jar diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice.jar Binary files differindex f838dce1c..f80d8575d 100644 --- a/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice.jar +++ b/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice.jar diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice_nodebug.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice_nodebug.jar Binary files differindex f838dce1c..309273883 100644 --- a/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice_nodebug.jar +++ b/ajde/testdata/WeaveInfoMessagesTest/AspectAdvice_nodebug.jar diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare.jar Binary files differindex a40ef7e96..abf2675f5 100644 --- a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare.jar +++ b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare.jar diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft.jar Binary files differindex b606ea4a9..2caea1f7c 100644 --- a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft.jar +++ b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft.jar diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft_nodebug.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft_nodebug.jar Binary files differindex 6afbc5e23..2caea1f7c 100644 --- a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft_nodebug.jar +++ b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclareSoft_nodebug.jar diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare_nodebug.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare_nodebug.jar Binary files differindex 330b9962a..348f63857 100644 --- a/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare_nodebug.jar +++ b/ajde/testdata/WeaveInfoMessagesTest/AspectDeclare_nodebug.jar diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectITD.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectITD.jar Binary files differindex 40abc4487..a18806b8a 100644 --- a/ajde/testdata/WeaveInfoMessagesTest/AspectITD.jar +++ b/ajde/testdata/WeaveInfoMessagesTest/AspectITD.jar diff --git a/ajde/testdata/WeaveInfoMessagesTest/AspectITD_nodebug.jar b/ajde/testdata/WeaveInfoMessagesTest/AspectITD_nodebug.jar Binary files differindex 40abc4487..a18806b8a 100644 --- a/ajde/testdata/WeaveInfoMessagesTest/AspectITD_nodebug.jar +++ b/ajde/testdata/WeaveInfoMessagesTest/AspectITD_nodebug.jar diff --git a/ajde/testdata/WeaveInfoMessagesTest/Simple.jar b/ajde/testdata/WeaveInfoMessagesTest/Simple.jar Binary files differindex d589430a0..e9353128d 100644 --- a/ajde/testdata/WeaveInfoMessagesTest/Simple.jar +++ b/ajde/testdata/WeaveInfoMessagesTest/Simple.jar diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar Binary files differindex 8a3a18c3d..267314581 100644 --- a/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar +++ b/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar Binary files differindex 4506909e3..0bce4dfde 100644 --- a/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar +++ b/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar Binary files differindex 4c3e5d4f3..d18a9bb6f 100644 --- a/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar +++ b/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar diff --git a/tests/bugs/StringToString/helloworld.jar b/tests/bugs/StringToString/helloworld.jar Binary files differindex 28c795faa..06fd1c15d 100644 --- a/tests/bugs/StringToString/helloworld.jar +++ b/tests/bugs/StringToString/helloworld.jar diff --git a/tests/bugs/serialVersionUID/injar.jar b/tests/bugs/serialVersionUID/injar.jar Binary files differindex 91e89e700..75a50e57e 100644 --- a/tests/bugs/serialVersionUID/injar.jar +++ b/tests/bugs/serialVersionUID/injar.jar diff --git a/tests/java5/annotations/ajdkExamples/AnnotationsInSignaturePatterns.aj b/tests/java5/annotations/ajdkExamples/AnnotationsInSignaturePatterns.aj index 066eaef84..86bfbe415 100644 --- a/tests/java5/annotations/ajdkExamples/AnnotationsInSignaturePatterns.aj +++ b/tests/java5/annotations/ajdkExamples/AnnotationsInSignaturePatterns.aj @@ -1,4 +1,4 @@ -import org.xyz.*; +import org.xyz.*; import anns.*; //import org.abc.*; import java.util.List; diff --git a/tests/java5/annotations/ajdkExamples/AnnotationsInTypePatterns.aj b/tests/java5/annotations/ajdkExamples/AnnotationsInTypePatterns.aj index 2348bce73..37469f5e7 100644 --- a/tests/java5/annotations/ajdkExamples/AnnotationsInTypePatterns.aj +++ b/tests/java5/annotations/ajdkExamples/AnnotationsInTypePatterns.aj @@ -1,4 +1,4 @@ -import org.xyz.*; +import org.xyz.*; import anns.*; import org.abc.*; import java.lang.annotation.Inherited; diff --git a/tests/java5/annotations/ajdkExamples/Cachable.java b/tests/java5/annotations/ajdkExamples/Cachable.java deleted file mode 100644 index 9cff589ce..000000000 --- a/tests/java5/annotations/ajdkExamples/Cachable.java +++ /dev/null @@ -1 +0,0 @@ -public @interface Cachable {}
\ No newline at end of file diff --git a/tests/java5/annotations/ajdkExamples/Immutable.java b/tests/java5/annotations/ajdkExamples/Immutable.java deleted file mode 100644 index 6a81edf5c..000000000 --- a/tests/java5/annotations/ajdkExamples/Immutable.java +++ /dev/null @@ -1 +0,0 @@ -public @interface Immutable {}
\ No newline at end of file diff --git a/tests/java5/annotations/ajdkExamples/Persisted.java b/tests/java5/annotations/ajdkExamples/Persisted.java deleted file mode 100644 index 28eb9a4ae..000000000 --- a/tests/java5/annotations/ajdkExamples/Persisted.java +++ /dev/null @@ -1 +0,0 @@ -public @interface Persisted {}
\ No newline at end of file diff --git a/tests/java5/annotations/ajdkExamples/SensitiveData.java b/tests/java5/annotations/ajdkExamples/SensitiveData.java deleted file mode 100644 index 71a64d4de..000000000 --- a/tests/java5/annotations/ajdkExamples/SensitiveData.java +++ /dev/null @@ -1 +0,0 @@ -public @interface SensitiveData {}
\ No newline at end of file diff --git a/tests/java5/annotations/ajdkExamples/Transaction.java b/tests/java5/annotations/ajdkExamples/Transaction.java deleted file mode 100644 index e41e0dd98..000000000 --- a/tests/java5/annotations/ajdkExamples/Transaction.java +++ /dev/null @@ -1 +0,0 @@ -public @interface Transaction {}
\ No newline at end of file diff --git a/tests/java5/annotations/ajdkExamples/anns/Cachable.java b/tests/java5/annotations/ajdkExamples/anns/Cachable.java new file mode 100644 index 000000000..9e83a32de --- /dev/null +++ b/tests/java5/annotations/ajdkExamples/anns/Cachable.java @@ -0,0 +1,2 @@ +package anns; +public @interface Cachable {}
\ No newline at end of file diff --git a/tests/java5/annotations/ajdkExamples/anns/Immutable.java b/tests/java5/annotations/ajdkExamples/anns/Immutable.java new file mode 100644 index 000000000..ce513836f --- /dev/null +++ b/tests/java5/annotations/ajdkExamples/anns/Immutable.java @@ -0,0 +1,2 @@ +package anns; +public @interface Immutable {}
\ No newline at end of file diff --git a/tests/java5/annotations/ajdkExamples/NonPersistent.java b/tests/java5/annotations/ajdkExamples/anns/NonPersistent.java index 6510066c1..88fea3793 100644 --- a/tests/java5/annotations/ajdkExamples/NonPersistent.java +++ b/tests/java5/annotations/ajdkExamples/anns/NonPersistent.java @@ -1,3 +1,4 @@ +package anns; import java.lang.annotation.Inherited; @Inherited diff --git a/tests/java5/annotations/ajdkExamples/anns/Persisted.java b/tests/java5/annotations/ajdkExamples/anns/Persisted.java new file mode 100644 index 000000000..6ddf03086 --- /dev/null +++ b/tests/java5/annotations/ajdkExamples/anns/Persisted.java @@ -0,0 +1,2 @@ +package anns; +public @interface Persisted {}
\ No newline at end of file diff --git a/tests/java5/annotations/ajdkExamples/anns/SensitiveData.java b/tests/java5/annotations/ajdkExamples/anns/SensitiveData.java new file mode 100644 index 000000000..3919a9177 --- /dev/null +++ b/tests/java5/annotations/ajdkExamples/anns/SensitiveData.java @@ -0,0 +1,2 @@ +package anns; +public @interface SensitiveData {}
\ No newline at end of file diff --git a/tests/java5/annotations/ajdkExamples/anns/Transaction.java b/tests/java5/annotations/ajdkExamples/anns/Transaction.java new file mode 100644 index 000000000..37124cbef --- /dev/null +++ b/tests/java5/annotations/ajdkExamples/anns/Transaction.java @@ -0,0 +1,2 @@ +package anns; +public @interface Transaction {}
\ No newline at end of file diff --git a/tests/java5/annotations/ajdkExamples/org/abc/Types.java b/tests/java5/annotations/ajdkExamples/org/abc/Types.java index b0ed7f8e0..ba8b20140 100644 --- a/tests/java5/annotations/ajdkExamples/org/abc/Types.java +++ b/tests/java5/annotations/ajdkExamples/org/abc/Types.java @@ -1,4 +1,4 @@ - +package org.abc; import anns.*; class E {} @Immutable diff --git a/tests/java5/annotations/ajdkExamples/org/xyz/OrgXYZAnnotation.java b/tests/java5/annotations/ajdkExamples/org/xyz/OrgXYZAnnotation.java index 963617cbb..04f5e4a2d 100644 --- a/tests/java5/annotations/ajdkExamples/org/xyz/OrgXYZAnnotation.java +++ b/tests/java5/annotations/ajdkExamples/org/xyz/OrgXYZAnnotation.java @@ -1 +1,2 @@ +package org.xyz; public @interface OrgXYZAnnotation {}
\ No newline at end of file diff --git a/tests/java5/annotations/ajdkExamples/org/xyz/SignatureTypes.java b/tests/java5/annotations/ajdkExamples/org/xyz/SignatureTypes.java index d37157439..ae94e447c 100644 --- a/tests/java5/annotations/ajdkExamples/org/xyz/SignatureTypes.java +++ b/tests/java5/annotations/ajdkExamples/org/xyz/SignatureTypes.java @@ -1,3 +1,4 @@ +package org.xyz; import anns.*; import java.util.List; import java.util.ArrayList; diff --git a/tests/java5/annotations/ajdkExamples/org/xyz/Types.java b/tests/java5/annotations/ajdkExamples/org/xyz/Types.java index 4d0339328..769f02bfc 100644 --- a/tests/java5/annotations/ajdkExamples/org/xyz/Types.java +++ b/tests/java5/annotations/ajdkExamples/org/xyz/Types.java @@ -1,4 +1,4 @@ - +package org.xyz; import anns.*; @Immutable class C {} diff --git a/tests/new/options11/aspectlib1.jar b/tests/new/options11/aspectlib1.jar Binary files differindex 9a66d122d..680a8f76d 100644 --- a/tests/new/options11/aspectlib1.jar +++ b/tests/new/options11/aspectlib1.jar diff --git a/tests/new/options11/aspectlib2.jar b/tests/new/options11/aspectlib2.jar Binary files differindex fd8451d86..cab875dee 100644 --- a/tests/new/options11/aspectlib2.jar +++ b/tests/new/options11/aspectlib2.jar diff --git a/tests/new/options11/injar.jar b/tests/new/options11/injar.jar Binary files differindex fe0827863..429473b8e 100644 --- a/tests/new/options11/injar.jar +++ b/tests/new/options11/injar.jar diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 1cda2c53f..4ef1703da 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -1052,7 +1052,7 @@ </ajc-test> <ajc-test dir="java5/annotations/ajdkExamples" title="ajdk: annotation type pattern matching"> - <compile files="AnnotationsInTypePatterns.aj,org/xyz/OrgXYZAnnotation.java,org/xyz/Types.java,org/abc/Types.java,Immutable.java,NonPersistent.java" options="-1.5"> + <compile files="AnnotationsInTypePatterns.aj,org/xyz/OrgXYZAnnotation.java,org/xyz/Types.java,org/abc/Types.java,anns/Immutable.java,anns/NonPersistent.java" options="-1.5"> <message kind="warning" line="23" text="(@Immutable *)"/> <message kind="warning" line="32" text="(@Immutable *)"/> <message kind="warning" line="3" text="(@Immutable *)"/> @@ -1064,8 +1064,8 @@ <message kind="warning" line="5" text="(!@Immutable *)"/> <message kind="warning" line="6" text="(!@Immutable *)"/> <message kind="warning" line="2" text="(!@Immutable *)"/> - <message kind="warning" line="1" text="(!@Immutable *)"/> - <message kind="warning" line="4" text="(!@Immutable *)"/> + <message kind="warning" line="2" text="(!@Immutable *)"/> + <message kind="warning" line="5" text="(!@Immutable *)"/> <message kind="warning" line="3" text="@Immutable (org.xyz.* || org.abc.*)"/> <message kind="warning" line="5" text="@Immutable (org.xyz.* || org.abc.*)"/> <message kind="warning" line="8" text="@Immutable (org.xyz.* || org.abc.*)"/> @@ -1076,22 +1076,23 @@ <message kind="warning" line="8" text="@(Immutable || NonPersistent) org.xyz..*"/> <message kind="warning" line="8" text="@Immutable @NonPersistent org.xyz..*"/> <message kind="warning" line="6" text="@(@Inherited *) org.xyz..*"/> + <message kind="warning" line="8" text="@(@Inherited *) org.xyz..*"/> </compile> </ajc-test> <ajc-test dir="java5/annotations/ajdkExamples" title="ajdk: annotations in sig patterns"> - <compile files="AnnotationsInSignaturePatterns.aj,Cachable.java,SensitiveData.java,Persisted.java,Classified.java,Immutable.java,Secure.java,Catastrophic.java,Oneway.java,Transaction.java,org/xyz/SignatureTypes.java" options="-1.5"> + <compile files="AnnotationsInSignaturePatterns.aj,anns/Cachable.java,anns/SensitiveData.java,anns/Persisted.java,Classified.java,anns/Immutable.java,Secure.java,Catastrophic.java,Oneway.java,anns/Transaction.java,org/xyz/SignatureTypes.java" options="-1.5"> <message kind="warning" line="32" text="@SensitiveData * *"/> - <message kind="warning" line="6" text="@SensitiveData * *"/> - <message kind="warning" line="12" text="@SensitiveData * *"/> - <message kind="warning" line="6" text="@SensitiveData List org.xyz..*.*"/> - <message kind="warning" line="10" text="(@SensitiveData *) org.xyz..*.*"/> - <message kind="warning" line="12" text="(@SensitiveData *) org.xyz..*.*"/> + <message kind="warning" line="7" text="@SensitiveData * *"/> + <message kind="warning" line="13" text="@SensitiveData * *"/> + <message kind="warning" line="7" text="@SensitiveData List org.xyz..*.*"/> + <message kind="warning" line="11" text="(@SensitiveData *) org.xyz..*.*"/> + <message kind="warning" line="13" text="(@SensitiveData *) org.xyz..*.*"/> <message kind="warning" line="50" text="@Foo (@Goo *) (@Hoo *).*"/> <message kind="warning" line="38" text="@Persisted @Classified * *"/> <message kind="warning" line="44" text="@Oneway * *(..)"/> - <message kind="warning" line="17" text="@Transaction * (@Persisted org.xyz..*).*(..)"/> + <message kind="warning" line="18" text="@Transaction * (@Persisted org.xyz..*).*(..)"/> <message kind="warning" line="52" text="* *.*(@Immutable *,..)"/> <message kind="warning" line="53" text="* *.*(@Immutable *,..)"/> <message kind="warning" line="54" text="* *.*(@Immutable *,..)"/> @@ -1099,10 +1100,10 @@ <message kind="warning" line="62" text="within(@Secure *)"/> <message kind="warning" line="63" text="within(@Secure *)"/> <message kind="warning" line="66" text="staticinitialization(@Persisted *)"/> - <message kind="warning" line="16" text="staticinitialization(@Persisted *)"/> + <message kind="warning" line="17" text="staticinitialization(@Persisted *)"/> <message kind="warning" line="56" text="call(@Oneway * *(..))"/> - <message kind="warning" line="27" text="execution(public (@Immutable *) org.xyz..*.*(..))"/> - <message kind="warning" line="25" text="set(@Cachable * *)"/> + <message kind="warning" line="28" text="execution(public (@Immutable *) org.xyz..*.*(..))"/> + <message kind="warning" line="26" text="set(@Cachable * *)"/> <message kind="warning" line="80" text="handler(!@Catastrophic *)"/> </compile> diff --git a/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java index 20cdea8ab..022ba5570 100644 --- a/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java @@ -51,6 +51,11 @@ public class AndTypePattern extends TypePattern { return left.matchesExactly(type) && right.matchesExactly(type); } + protected boolean matchesExactly(ResolvedTypeX type, ResolvedTypeX annotatedType) { + return left.matchesExactly(type,annotatedType) && right.matchesExactly(type,annotatedType); + } + + public boolean matchesStatically(Class type) { return left.matchesStatically(type) && right.matchesStatically(type); } @@ -74,6 +79,22 @@ public class AndTypePattern extends TypePattern { right.setIsVarArgs(isVarArgs); } + public void setAnnotationTypePattern(AnnotationTypePattern annPatt) { + if (annPatt == AnnotationTypePattern.ANY) return; + if (left.annotationPattern == AnnotationTypePattern.ANY) { + left.setAnnotationTypePattern(annPatt); + } else { + left.setAnnotationTypePattern( + new AndAnnotationTypePattern(left.annotationPattern,annPatt)); + } + if (right.annotationPattern == AnnotationTypePattern.ANY) { + right.setAnnotationTypePattern(annPatt); + } else { + right.setAnnotationTypePattern( + new AndAnnotationTypePattern(right.annotationPattern,annPatt)); + } + } + public void write(DataOutputStream s) throws IOException { s.writeByte(TypePattern.AND); left.write(s); diff --git a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java index 5d948adca..b4e4ea7e3 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java @@ -92,10 +92,18 @@ public class ExactTypePattern extends TypePattern { protected boolean matchesExactly(ResolvedTypeX matchType) { boolean typeMatch = this.type.equals(matchType); + annotationPattern.resolve(matchType.getWorld()); boolean annMatch = this.annotationPattern.matches(matchType).alwaysTrue(); return (typeMatch && annMatch); } + protected boolean matchesExactly(ResolvedTypeX matchType, ResolvedTypeX annotatedType) { + boolean typeMatch = this.type.equals(matchType); + annotationPattern.resolve(matchType.getWorld()); + boolean annMatch = this.annotationPattern.matches(annotatedType).alwaysTrue(); + return (typeMatch && annMatch); + } + public TypeX getType() { return type; } public FuzzyBoolean matchesInstanceof(ResolvedTypeX matchType) { diff --git a/weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java index 772b4cdd4..4106af216 100644 --- a/weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java @@ -17,6 +17,7 @@ import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.AjAttribute; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.VersionedDataInputStream; @@ -51,7 +52,11 @@ public class NotTypePattern extends TypePattern { } protected boolean matchesExactly(ResolvedTypeX type) { - return !pattern.matchesExactly(type); + return (!pattern.matchesExactly(type) && annotationPattern.matches(type).alwaysTrue()); + } + + protected boolean matchesExactly(ResolvedTypeX type, ResolvedTypeX annotatedType) { + return (!pattern.matchesExactly(type,annotatedType) && annotationPattern.matches(annotatedType).alwaysTrue()); } public boolean matchesStatically(Class type) { @@ -70,14 +75,27 @@ public class NotTypePattern extends TypePattern { return !pattern.matchesStatically(type); } + public void setAnnotationTypePattern(AnnotationTypePattern annPatt) { + super.setAnnotationTypePattern(annPatt); + } + + public void setIsVarArgs(boolean isVarArgs) { + pattern.setIsVarArgs(isVarArgs); + } + + public void write(DataOutputStream s) throws IOException { s.writeByte(TypePattern.NOT); pattern.write(s); + annotationPattern.write(s); writeLocation(s); } public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { TypePattern ret = new NotTypePattern(TypePattern.read(s, context)); + if (s.getMajorVersion()>=AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) { + ret.annotationPattern = AnnotationTypePattern.read(s,context); + } ret.readLocation(context, s); return ret; } diff --git a/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java index 642f09ace..e5e372d80 100644 --- a/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java @@ -54,6 +54,11 @@ public class OrTypePattern extends TypePattern { //??? if these had side-effects, this sort-circuit could be a mistake return left.matchesExactly(type) || right.matchesExactly(type); } + + protected boolean matchesExactly(ResolvedTypeX type, ResolvedTypeX annotatedType) { + //??? if these had side-effects, this sort-circuit could be a mistake + return left.matchesExactly(type,annotatedType) || right.matchesExactly(type,annotatedType); + } public boolean matchesStatically(ResolvedTypeX type) { return left.matchesStatically(type) || right.matchesStatically(type); @@ -78,6 +83,22 @@ public class OrTypePattern extends TypePattern { right.setIsVarArgs(isVarArgs); } + public void setAnnotationTypePattern(AnnotationTypePattern annPatt) { + if (annPatt == AnnotationTypePattern.ANY) return; + if (left.annotationPattern == AnnotationTypePattern.ANY) { + left.setAnnotationTypePattern(annPatt); + } else { + left.setAnnotationTypePattern( + new AndAnnotationTypePattern(left.annotationPattern,annPatt)); + } + if (right.annotationPattern == AnnotationTypePattern.ANY) { + right.setAnnotationTypePattern(annPatt); + } else { + right.setAnnotationTypePattern( + new AndAnnotationTypePattern(right.annotationPattern,annPatt)); + } + } + public void write(DataOutputStream s) throws IOException { s.writeByte(TypePattern.OR); left.write(s); diff --git a/weaver/src/org/aspectj/weaver/patterns/TypePattern.java b/weaver/src/org/aspectj/weaver/patterns/TypePattern.java index 3e3446ab3..cf0aa4809 100644 --- a/weaver/src/org/aspectj/weaver/patterns/TypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/TypePattern.java @@ -169,6 +169,8 @@ public abstract class TypePattern extends PatternNode { } protected abstract boolean matchesExactly(ResolvedTypeX type); + + protected abstract boolean matchesExactly(ResolvedTypeX type, ResolvedTypeX annotatedType); protected boolean matchesSubtypes(ResolvedTypeX type) { //System.out.println("matching: " + this + " to " + type); @@ -180,7 +182,22 @@ public abstract class TypePattern extends PatternNode { // FuzzyBoolean ret = FuzzyBoolean.NO; // ??? -eh for (Iterator i = type.getDirectSupertypes(); i.hasNext(); ) { ResolvedTypeX superType = (ResolvedTypeX)i.next(); - if (matchesSubtypes(superType)) return true; + if (matchesSubtypes(superType,type)) return true; + } + return false; + } + + protected boolean matchesSubtypes(ResolvedTypeX superType, ResolvedTypeX annotatedType) { + //System.out.println("matching: " + this + " to " + type); + if (matchesExactly(superType,annotatedType)) { + //System.out.println(" true"); + return true; + } + + // FuzzyBoolean ret = FuzzyBoolean.NO; // ??? -eh + for (Iterator i = superType.getDirectSupertypes(); i.hasNext(); ) { + ResolvedTypeX superSuperType = (ResolvedTypeX)i.next(); + if (matchesSubtypes(superSuperType,annotatedType)) return true; } return false; } @@ -317,6 +334,10 @@ class EllipsisTypePattern extends TypePattern { protected boolean matchesExactly(ResolvedTypeX type) { return false; } + + protected boolean matchesExactly(ResolvedTypeX type, ResolvedTypeX annotatedType) { + return false; + } /** * @see org.aspectj.weaver.patterns.TypePattern#matchesInstanceof(IType) @@ -385,6 +406,10 @@ class AnyTypePattern extends TypePattern { return true; } + protected boolean matchesExactly(ResolvedTypeX type, ResolvedTypeX annotatedType) { + return true; + } + /** * @see org.aspectj.weaver.patterns.TypePattern#matchesInstanceof(IType) */ @@ -461,6 +486,11 @@ class AnyWithAnnotationTypePattern extends TypePattern { annotationPattern.resolve(type.getWorld()); return annotationPattern.matches(type).alwaysTrue(); } + + protected boolean matchesExactly(ResolvedTypeX type, ResolvedTypeX annotatedType) { + annotationPattern.resolve(type.getWorld()); + return annotationPattern.matches(annotatedType).alwaysTrue(); + } public FuzzyBoolean matchesInstanceof(ResolvedTypeX type) { return FuzzyBoolean.YES; @@ -531,6 +561,10 @@ class NoTypePattern extends TypePattern { protected boolean matchesExactly(ResolvedTypeX type) { return false; } + + protected boolean matchesExactly(ResolvedTypeX type, ResolvedTypeX annotatedType) { + return false; + } /** * @see org.aspectj.weaver.patterns.TypePattern#matchesInstanceof(IType) diff --git a/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java index 8ca0dd1b5..9019954e2 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java @@ -75,6 +75,7 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { public AnnotationTypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding) { + if (resolved) return this; this.typePattern = typePattern.resolveBindings(scope,bindings,false,false); resolved = true; if (typePattern instanceof ExactTypePattern) { diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java index 97a1ee019..0dff4aaad 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java @@ -117,6 +117,10 @@ public class WildTypePattern extends TypePattern { * @see org.aspectj.weaver.TypePattern#matchesExactly(IType) */ protected boolean matchesExactly(ResolvedTypeX type) { + return matchesExactly(type,type); + } + + protected boolean matchesExactly(ResolvedTypeX type, ResolvedTypeX annotatedType) { String targetTypeName = type.getName(); //System.err.println("match: " + targetTypeName + ", " + knownMatches); //Arrays.asList(importedPrefixes)); @@ -124,9 +128,10 @@ public class WildTypePattern extends TypePattern { annotationPattern.resolve(type.getWorld()); return matchesExactlyByName(targetTypeName) && - annotationPattern.matches(type).alwaysTrue(); + annotationPattern.matches(annotatedType).alwaysTrue(); } - + + /** * Used in conjunction with checks on 'isStar()' to tell you if this pattern represents '*' or '*[]' which are * different ! @@ -450,6 +455,7 @@ public class WildTypePattern extends TypePattern { } else { if (dim != 0) type = TypeX.makeArray(type, dim); TypePattern ret = new ExactTypePattern(type, includeSubtypes,isVarArgs); + ret.setAnnotationTypePattern(annotationPattern); ret.copyLocationFrom(this); return ret; } diff --git a/weaver/testdata/dummyAspect.jar b/weaver/testdata/dummyAspect.jar Binary files differindex 6937bff13..af35626c6 100644 --- a/weaver/testdata/dummyAspect.jar +++ b/weaver/testdata/dummyAspect.jar diff --git a/weaver/testdata/ltw-acaspects.jar b/weaver/testdata/ltw-acaspects.jar Binary files differindex 702daa9c6..7ee6e9888 100644 --- a/weaver/testdata/ltw-acaspects.jar +++ b/weaver/testdata/ltw-acaspects.jar diff --git a/weaver/testdata/ltw-aspects.jar b/weaver/testdata/ltw-aspects.jar Binary files differindex dc76dd816..f09ee3db1 100644 --- a/weaver/testdata/ltw-aspects.jar +++ b/weaver/testdata/ltw-aspects.jar diff --git a/weaver/testdata/ltw-classes.jar b/weaver/testdata/ltw-classes.jar Binary files differindex f5ba5080e..1dfcc034b 100644 --- a/weaver/testdata/ltw-classes.jar +++ b/weaver/testdata/ltw-classes.jar diff --git a/weaver/testdata/ltw-deaspects.jar b/weaver/testdata/ltw-deaspects.jar Binary files differindex e86ffbe18..186e49409 100644 --- a/weaver/testdata/ltw-deaspects.jar +++ b/weaver/testdata/ltw-deaspects.jar diff --git a/weaver/testdata/ltw-dwaspects.jar b/weaver/testdata/ltw-dwaspects.jar Binary files differindex 382f74857..791213a88 100644 --- a/weaver/testdata/ltw-dwaspects.jar +++ b/weaver/testdata/ltw-dwaspects.jar diff --git a/weaver/testdata/ltw-itdaspects.jar b/weaver/testdata/ltw-itdaspects.jar Binary files differindex a0a9b3798..eedfaf505 100644 --- a/weaver/testdata/ltw-itdaspects.jar +++ b/weaver/testdata/ltw-itdaspects.jar diff --git a/weaver/testdata/ltw-peraspects.jar b/weaver/testdata/ltw-peraspects.jar Binary files differindex aca77d231..53f31b7e6 100644 --- a/weaver/testdata/ltw-peraspects.jar +++ b/weaver/testdata/ltw-peraspects.jar diff --git a/weaver/testdata/ltw-woven.jar b/weaver/testdata/ltw-woven.jar Binary files differindex ec1fe6d06..c60f5c745 100644 --- a/weaver/testdata/ltw-woven.jar +++ b/weaver/testdata/ltw-woven.jar diff --git a/weaver/testdata/megatrace.jar b/weaver/testdata/megatrace.jar Binary files differindex 14ae666ee..23a58710d 100644 --- a/weaver/testdata/megatrace.jar +++ b/weaver/testdata/megatrace.jar diff --git a/weaver/testdata/megatrace0easy.jar b/weaver/testdata/megatrace0easy.jar Binary files differindex 7d076431f..4c025a67f 100644 --- a/weaver/testdata/megatrace0easy.jar +++ b/weaver/testdata/megatrace0easy.jar diff --git a/weaver/testdata/megatrace0hard.jar b/weaver/testdata/megatrace0hard.jar Binary files differindex 63842de96..15f34d5d3 100644 --- a/weaver/testdata/megatrace0hard.jar +++ b/weaver/testdata/megatrace0hard.jar diff --git a/weaver/testdata/megatraceNoweave.jar b/weaver/testdata/megatraceNoweave.jar Binary files differindex 772aafbd7..3d5b1fa08 100644 --- a/weaver/testdata/megatraceNoweave.jar +++ b/weaver/testdata/megatraceNoweave.jar diff --git a/weaver/testdata/tracing.jar b/weaver/testdata/tracing.jar Binary files differindex fc4aef974..8ce561163 100644 --- a/weaver/testdata/tracing.jar +++ b/weaver/testdata/tracing.jar diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java index 136ab98fa..47b6d46b6 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java @@ -170,18 +170,14 @@ public class AnnotationPatternTestCase extends TestCase { PatternParser p = new PatternParser("(@(Foo || Boo) (Foo || Boo))"); TypePattern t = p.parseTypePattern(); assertTrue("OrTypePattern",t instanceof OrTypePattern); - WildAnnotationTypePattern wtp = (WildAnnotationTypePattern) t.annotationPattern; - assertEquals("@((Foo || Boo))",wtp.toString()); - assertEquals("(@((Foo || Boo)) (Foo || Boo))",t.toString()); + assertEquals("((@((Foo || Boo)) Foo) || (@((Foo || Boo)) Boo))",t.toString()); } public void testNotSyntax() { PatternParser p = new PatternParser("!@Foo (Foo || Boo))"); TypePattern t = p.parseTypePattern(); assertTrue("OrTypePattern",t instanceof OrTypePattern); - NotAnnotationTypePattern natp = (NotAnnotationTypePattern) t.annotationPattern; - assertEquals("!@(Foo)",natp.toString()); - assertEquals("(!@(Foo) (Foo || Boo))",t.toString()); + assertEquals("((!@(Foo) Foo) || (!@(Foo) Boo))",t.toString()); } public void testParseMethodOrConstructorSigNoAP() { |