diff options
38 files changed, 143 insertions, 1 deletions
diff --git a/ajde/testdata/DuplicateManifestTest/aspectjar.jar b/ajde/testdata/DuplicateManifestTest/aspectjar.jar Binary files differindex d6137caa2..e5b2b9c35 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 f04d007f6..c2c1326a7 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 c279f9855..5fdde02e1 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 5cedfb19b..5fdde02e1 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 7a3e7e3c1..21811a56d 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 8cfc58e2b..10e68750c 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 8cfc58e2b..10e68750c 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 e8a6753f6..21811a56d 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 101180b06..f03c54b6b 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 101180b06..e4a938a61 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 aa6129258..596257ca8 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 955795b30..966f8dc1e 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 db375005f..5b0b23450 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 93628a6b3..d921175b2 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 4c588d84e..2112135d4 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 ca9170c2c..27c6d742b 100644 --- a/tests/bugs/serialVersionUID/injar.jar +++ b/tests/bugs/serialVersionUID/injar.jar diff --git a/tests/new/options11/aspectlib1.jar b/tests/new/options11/aspectlib1.jar Binary files differindex c0a824e75..2f832f0e3 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 3a1f8b2ba..c0de74f53 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 a70a43a12..53c0a1407 100644 --- a/tests/new/options11/injar.jar +++ b/tests/new/options11/injar.jar diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java index a4234982f..b1fbba5ed 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java @@ -36,6 +36,102 @@ import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; //XXX need to use dim in matching +/** + * The PatternParser always creates WildTypePatterns for type patterns in pointcut + * expressions (apart from *, which is sometimes directly turned into TypePattern.ANY). + * resolveBindings() tries to work out what we've really got and turn it into a type + * pattern that we can use for matching. This will normally be either an ExactTypePattern + * or a WildTypePattern. + * + * Here's how the process pans out for various generic and parameterized patterns: + * (see GenericsWildTypePatternResolvingTestCase) + * + * Foo where Foo exists and is generic + * Parser creates WildTypePattern namePatterns={Foo} + * resolveBindings resolves Foo to RT(Foo - raw) + * return ExactTypePattern(LFoo;) + * + * <E>... Foo<E> where Foo exists and has one unbound type var + * Parser creates WildTypePattern namePatterns = {Foo}, typeParameters=WTP{E} + * resolveBindings requireExactType = true | false + * resolves typeParameters to ExactTypePattern(TVRT(E)) + * resolves Foo to RT(Foo - raw) + * returns ExactTypePattern(<1:>LFoo; - generic) 1=E + * + * <E>... Foo<E> where Foo exists and is not generic (or has different bounds) + * Parser creates WildTypePattern namePatterns = {Foo}, typeParameters=WTP{E} + * resolveBindings resolves typeParameters to ExactTypePattern(TVRT(E)) + * resolves Foo to RT(Foo) + * finds that Foo is not generic / type var mismatch + * requireExactType = true ->returns TypePattern.NO (and issues error) + * = false -> XLint then return ExactTypePattern(<1:>LFoo;) + * + * <E>... Foo<E extends Number> where Foo exists and bounds match + * Parser creates WildTypePattern namePatterns = {Foo}, typeParameters=WTP{E},uB=WTP{Number} + * resolveBindings resolves typeParameters to ExactTypePattern(TVRT(E extends Number)) + * resolves Foo to RT(Foo) + * returns ExactTypePattern(<1:Ljava/lang/Number;>LFoo;) 1=E + * + * Foo<String> where Foo exists and String meets the bounds + * Parser creates WildTypePattern namePatterns = {Foo}, typeParameters=WTP{String} + * resolveBindings resolves typeParameters to ExactTypePattern(String) + * resolves Foo to RT(Foo) + * returns ExactTypePattern(PFoo<String>; - parameterized) + * + * Foo<Str*> where Foo exists and takes one bound + * Parser creates WildTypePattern namePatterns = {Foo}, typeParameters=WTP{Str*} + * resolveBindings resolves typeParameters to WTP{Str*} + * resolves Foo to RT(Foo) + * returns WildTypePattern(name = Foo, typeParameters = WTP{Str*} isGeneric=false) + * + * Fo*<String> + * Parser creates WildTypePattern namePatterns = {Fo*}, typeParameters=WTP{String} + * resolveBindings resolves typeParameters to ETP{String} + * returns WildTypePattern(name = Fo*, typeParameters = ETP{String} isGeneric=false) + * + * <E>... Fo*<E> + * Parser creates WildTypePattern namePatterns = {Fo*}, typeParameters=WTP{E} + * resolveBindings resolves typeParameters to ETP{TVRT(E)} + * returns WildTypePattern(name = Fo*, typeParameters = ETP{TVRT(E)} isGeneric=true) + * + * <E>... Fo*<E extends Number> + * Parser creates WildTypePattern namePatterns = {Fo*}, typeParameters=WTP{E,uB=WTP(Number)} + * resolveBindings resolves typeParameters to ETP{TVRT(E extends Number)} + * returns WildTypePattern(name = Fo*, typeParameters = ETP{TVRT(E extends Number)} isGeneric=true) + * + * <E>... Foo<E extends Number+> where Foo exists and takes one bound + * Parser creates WildTypePattern namePatterns = {Foo}, typeParameters=WTP{E,uB=WTP(Number+)} + * resolveBindings resolves typeParameters to WildTypeVariableReferencePattern{TVP(name="E",uB=Number+)} + * resolves Foo to RT(Foo) + * if requireExactType (but this doesn't allow + ? ) + * if typeParameters.matches(RT(Foo - generic).getTypeVariables() + * return ETP(<1:Ljava/lang/Number;>LFoo;) + * else return TypePattern.NO and issue warning + * else + * if !typeParameters.matches(RT(Foo - generic).getTypeVariables() + * issue warning (XLint?) + * return WildTypePattern(name=Foo, typeParameters=WTVRP{TVP(E,Number+)} isGeneric=true + * + * <E>... Fo*<E extends Number+> + * Parser creates WildTypePattern namePatterns = {Fo*}, typeParameters=WTP{E,uB=WTP(Number+)} + * resolveBindings resolves typeParameters to WildTypeVariableReferencePattern{TVP(name="E",uB=Number+)} + * returns WildTypePattern(name=Fo*, typeParamters = WTVRP{TVP(name="E" ub=Number+)} isGeneric=true) + * + * TODO: + * + * <E>... Foo<E,String> + * + * <S,T>... Foo<S,T extends S> + * + * Foo<?> + * + * Foo<? extends Number> + * + * Foo<? extends Number+> + * + * Foo<? super Number> + * + */ public class WildTypePattern extends TypePattern { private NamePattern[] namePatterns; int ellipsisCount; @@ -168,10 +264,25 @@ public class WildTypePattern extends TypePattern { annotationPattern.resolve(type.getWorld()); return matchesExactlyByName(targetTypeName) && + // matchesParameters(type) && annotationPattern.matches(annotatedType).alwaysTrue(); } + // we've matched against the base (or raw) type, but if this type pattern specifies parameters or + // type variables we need to make sure we match against them too + private boolean matchesParameters(ResolvedType aType) { + if (isGeneric) { + if (!aType.isGenericType()) return false; + // we have to match type variables + + } else if (typeParameters.size() > 0) { + if(!aType.isParameterizedType()) return false; + // we have to match type parameters + } + return true; + } + /** * Used in conjunction with checks on 'isStar()' to tell you if this pattern represents '*' or '*[]' which are * different ! @@ -479,7 +590,7 @@ public class WildTypePattern extends TypePattern { // use a special variant of Any TypePattern called // AnyWithAnnotation if (annotationPattern == AnnotationTypePattern.ANY) { - if (dim == 0 && !isVarArgs) { // pr72531 + if (dim == 0 && !isVarArgs && upperBound == null && lowerBound == null && (additionalInterfaceBounds == null || additionalInterfaceBounds.length==0)) { // pr72531 return TypePattern.ANY; //??? loses source location } } else { @@ -889,6 +1000,18 @@ public class WildTypePattern extends TypePattern { FileUtil.writeStringArray(importedPrefixes, s); writeLocation(s); annotationPattern.write(s); + // generics info, new in M3 + s.writeBoolean(isGeneric); + s.writeBoolean(upperBound != null); + if (upperBound != null) upperBound.write(s); + s.writeBoolean(lowerBound != null); + if (lowerBound != null) lowerBound.write(s); + s.writeInt(additionalInterfaceBounds == null ? 0 : additionalInterfaceBounds.length); + if (additionalInterfaceBounds != null) { + for (int i = 0; i < additionalInterfaceBounds.length; i++) { + additionalInterfaceBounds[i].write(s); + } + } } public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { @@ -918,6 +1041,21 @@ public class WildTypePattern extends TypePattern { ret.importedPrefixes = FileUtil.readStringArray(s); ret.readLocation(context, s); ret.setAnnotationTypePattern(AnnotationTypePattern.read(s,context)); + // generics info, new in M3 + ret.isGeneric = s.readBoolean(); + if (s.readBoolean()) { + ret.upperBound = TypePattern.read(s,context); + } + if (s.readBoolean()) { + ret.lowerBound = TypePattern.read(s,context); + } + int numIfBounds = s.readInt(); + if (numIfBounds > 0) { + ret.additionalInterfaceBounds = new TypePattern[numIfBounds]; + for (int i = 0; i < numIfBounds; i++) { + ret.additionalInterfaceBounds[i] = TypePattern.read(s,context); + } + } return ret; } diff --git a/weaver/testdata/AfterReturningFancyHelloWorld.txt b/weaver/testdata/AfterReturningFancyHelloWorld.txt index 1bcdad132..f2447b509 100644 --- a/weaver/testdata/AfterReturningFancyHelloWorld.txt +++ b/weaver/testdata/AfterReturningFancyHelloWorld.txt @@ -98,4 +98,5 @@ public abstract class FancyHelloWorld extends java.lang.Object: | ARETURN method-execution(java.lang.String FancyHelloWorld.getName()) end public static String getName() + end public abstract class FancyHelloWorld diff --git a/weaver/testdata/AfterReturningHelloWorld.txt b/weaver/testdata/AfterReturningHelloWorld.txt index 271a34b38..6f58d2f3d 100644 --- a/weaver/testdata/AfterReturningHelloWorld.txt +++ b/weaver/testdata/AfterReturningHelloWorld.txt @@ -27,4 +27,5 @@ public class HelloWorld extends java.lang.Object: | RETURN method-execution(void HelloWorld.main(java.lang.String[])) end public static void main(String[]) + end public class HelloWorld diff --git a/weaver/testdata/BeforeFancyHelloWorld.txt b/weaver/testdata/BeforeFancyHelloWorld.txt index 18136b693..bc2ef49ba 100644 --- a/weaver/testdata/BeforeFancyHelloWorld.txt +++ b/weaver/testdata/BeforeFancyHelloWorld.txt @@ -87,4 +87,5 @@ public abstract class FancyHelloWorld extends java.lang.Object: | ARETURN method-execution(java.lang.String FancyHelloWorld.getName()) end public static String getName() + end public abstract class FancyHelloWorld diff --git a/weaver/testdata/BeforeHelloWorld.txt b/weaver/testdata/BeforeHelloWorld.txt index 3fc3fa818..d89b5acd9 100644 --- a/weaver/testdata/BeforeHelloWorld.txt +++ b/weaver/testdata/BeforeHelloWorld.txt @@ -23,4 +23,5 @@ public class HelloWorld extends java.lang.Object: | RETURN (line 11) method-execution(void HelloWorld.main(java.lang.String[])) end public static void main(String[]) + end public class HelloWorld diff --git a/weaver/testdata/dummyAspect.jar b/weaver/testdata/dummyAspect.jar Binary files differindex 8095fddf4..bc1212450 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 ed55e51bc..27c112671 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 2e1e86fb1..436e5a225 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 014510d57..b79e963fc 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 853e7147b..6dd510a5a 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 7ca214cf3..5e9d88bd8 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 6144a3f6f..cf998df73 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 2c37baeb7..25ad702c7 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 d4f117eea..6db485722 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 8735641c5..39c09bf90 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 11deb555c..7f39269ca 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 84f4a7b1e..cac0d6b18 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 4f8d26a4a..6ee827fc1 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 1a50581b1..ebd414b1c 100644 --- a/weaver/testdata/tracing.jar +++ b/weaver/testdata/tracing.jar |