Index: src/org/aspectj/systemtest/ajc150/Ajc150Tests.java =================================================================== RCS file: /home/technology/org.aspectj/modules/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java,v retrieving revision 1.133 diff -u -r1.133 Ajc150Tests.java --- src/org/aspectj/systemtest/ajc150/Ajc150Tests.java 17 Nov 2005 12:45:23 -0000 1.133 +++ src/org/aspectj/systemtest/ajc150/Ajc150Tests.java 17 Nov 2005 13:47:21 -0000 @@ -713,6 +713,14 @@ runTest("no StackOverflowError with circular pcd in generic aspect - 2"); } + public void testXlintMessageForImproperAnnotationType_pr115252_Exact() {runTest("xlint message for improper exact annotation type");} + public void testXlintMessageForImproperAnnotationType_pr115252_OR() {runTest("xlint message for improper annotation type inside OR");} + public void testXlintMessageForImproperAnnotationType_pr115252_AND() {runTest("xlint message for improper annotation type inside AND");} + public void testXlintMessageForImproperAnnotationType_pr115252_Return() {runTest("xlint message for improper annotated return type");} + public void testXlintMessageForImproperAnnotationType_pr115252_Declaring() {runTest("xlint message for improper annotated declaring type");} + public void testXlintMessageForImproperAnnotationType_pr115252_Parameter() {runTest("xlint message for improper annotated parameter type");} + public void testXlintMessageForImproperAnnotationType_pr115252_Throws() {runTest("xlint message for improper annotated throws pattern");} + // helper methods..... public SyntheticRepository createRepos(File cpentry) { Index: src/org/aspectj/systemtest/ajc150/ajc150.xml =================================================================== RCS file: /home/technology/org.aspectj/modules/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml,v retrieving revision 1.212 diff -u -r1.212 ajc150.xml --- src/org/aspectj/systemtest/ajc150/ajc150.xml 17 Nov 2005 08:56:15 -0000 1.212 +++ src/org/aspectj/systemtest/ajc150/ajc150.xml 17 Nov 2005 13:47:26 -0000 @@ -1024,6 +1024,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2870,7 +2935,10 @@ - + + + + Index: bugs150/pr115252/AndTypePattern.java =================================================================== RCS file: bugs150/pr115252/AndTypePattern.java diff -N bugs150/pr115252/AndTypePattern.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ bugs150/pr115252/AndTypePattern.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target({ElementType.METHOD}) +@interface MethodAnnotation{} + +@Target({ElementType.FIELD}) +@interface FieldAnnotation{} + +public class AndTypePattern { + + public void method1() {} + + @FieldAnnotation + int field = 1; + +} + +aspect A { + + // should display an xlint message because @FieldAnnotation can't be + // applied to methods + pointcut andPointcut() : execution(@(FieldAnnotation && MethodAnnotation) * *(..)); + declare warning : andPointcut() : "andPointcut()"; + +} Index: bugs150/pr115252/AnnotationDeclaringType.java =================================================================== RCS file: bugs150/pr115252/AnnotationDeclaringType.java diff -N bugs150/pr115252/AnnotationDeclaringType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ bugs150/pr115252/AnnotationDeclaringType.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,29 @@ +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target({ElementType.TYPE}) +@interface TypeAnnotation{} + +@Target({ElementType.METHOD}) +@interface MethodAnnotation{} + +@TypeAnnotation +public class AnnotationDeclaringType { + + public void method1() { + } + +} + +aspect A { + + // matches the execution of any method where the declaring type + // has the @TypeAnnotation - should compile ok and get no xlint errors + pointcut pc() : execution(* (@TypeAnnotation *).*(..)); + declare warning : pc() : "* (@TypeAnnotation *).*(..)"; + + // should get an xlint warning because declaring types can only + // have the default @Target or @Target{ElementType.TYPE} target + pointcut pc2() : execution(* (@MethodAnnotation *).*(..)); + declare warning : pc2() : "* (@MethodAnnotation *).*(..)"; +} Index: bugs150/pr115252/AnnotationParameterType.java =================================================================== RCS file: bugs150/pr115252/AnnotationParameterType.java diff -N bugs150/pr115252/AnnotationParameterType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ bugs150/pr115252/AnnotationParameterType.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,34 @@ +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target({ElementType.TYPE}) +@interface TypeAnnotation{} + +@Target({ElementType.METHOD}) +@interface MethodAnnotation{} + +public class AnnotationParameterType { + + public void method1(MyClass m) { + } + +} + +@TypeAnnotation +class MyClass { + +} + +aspect A { + + // shouldn't get an xlint warning because looking method which + // takes an argument that has the @TypeAnnotation + pointcut pc() : execution(* *(@TypeAnnotation *)); + declare warning : pc() : "* *(@TypeAnnotation *)"; + + // should get an xlint warning because can only have the default, + // or @Target{ElementType.TYPE} as an argument type + pointcut incorrectArgumentType() : execution(* *(@MethodAnnotation *)); + declare warning : incorrectArgumentType() : "argument type can only have @Target{ElementType.TYPE}"; + +} Index: bugs150/pr115252/AnnotationReturnType.java =================================================================== RCS file: bugs150/pr115252/AnnotationReturnType.java diff -N bugs150/pr115252/AnnotationReturnType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ bugs150/pr115252/AnnotationReturnType.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,40 @@ +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target({ElementType.TYPE}) +@interface TypeAnnotation{} + +@Target({ElementType.METHOD}) +@interface MethodAnnotation{} + +public class AnnotationReturnType { + + public MyClass method1() { + return new MyClass(); + } + +} + +@TypeAnnotation +class MyClass { + +} + +aspect A { + + // shouldn't get an xlint warning because looking for a return type + // which has the @TypeAnnotation annotation + pointcut pc() : execution((@TypeAnnotation *) *(..)); + declare warning : pc() : "(@TypeAnnotation *) *(..)"; + + // should get an xlint warning because can only have the default, + // or @Target{ElementType.TYPE} as a return type + pointcut incorrectReturnType() : execution((@MethodAnnotation *) *(..)); + declare warning : incorrectReturnType() : "return type can only have @Target{ElementType.TYPE}"; + + // should get an xlint warning because @MethodAnnotation can never match + // but also get a declare warning because the @TypeAnnotation matches + pointcut orPointcut() : execution((@(TypeAnnotation || MethodAnnotation) *) *(..)); + declare warning : orPointcut() : "(@(TypeAnnotation || MethodAnnotation) *) *(..)"; + +} Index: bugs150/pr115252/AnnotationThrowsPattern.java =================================================================== RCS file: bugs150/pr115252/AnnotationThrowsPattern.java diff -N bugs150/pr115252/AnnotationThrowsPattern.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ bugs150/pr115252/AnnotationThrowsPattern.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,49 @@ +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target({ElementType.TYPE}) +@interface TypeAnnotation{} + +@Target({ElementType.METHOD}) +@interface MethodAnnotation{} + +public class AnnotationThrowsPattern { + + public void method1() throws MyException {} + + public void method2() throws MyNonAnnotatedException {} + +} + +@TypeAnnotation +class MyException extends Exception { + +} + +class MyNonAnnotatedException extends Exception { + +} + +aspect A { + + // shouldn't get xlint warnings because @TypeAnnotation is allowed + pointcut required() : execution(* *.*(..) throws (@TypeAnnotation *)); + declare warning : required() : "(* *.*(..) throws (@TypeAnnotation *))"; + + // shouldn't get xlint warnings because @TypeAnnotation is allowed + pointcut forbidden() : execution(* *.*(..) throws !(@TypeAnnotation *)); + declare warning : forbidden() : "(* *.*(..) throws !(@TypeAnnotation *))"; + + // should get an xlint warning here because can only have + // annotations with @Target{ElementType.TYPE} or the default + // @Target (which is everything) + pointcut required1() : execution(* *.*(..) throws (@MethodAnnotation *)); + declare warning : required1() : "* *.*(..) throws (@MethodAnnotation *)"; + + // should get an xlint warning here because can only have + // annotations with @Target{ElementType.TYPE} or the default + // @Target (which is everything) + pointcut forbidden1() : execution(* *.*(..) throws !(@MethodAnnotation *)); + declare warning : forbidden1() : "* *.*(..) throws !(@MethodAnnotation *)"; + +} Index: bugs150/pr115252/ExactAnnotationTypePattern.java =================================================================== RCS file: bugs150/pr115252/ExactAnnotationTypePattern.java diff -N bugs150/pr115252/ExactAnnotationTypePattern.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ bugs150/pr115252/ExactAnnotationTypePattern.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,54 @@ +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target({ElementType.TYPE}) +@interface TypeAnnotation{} + +@Target({ElementType.METHOD}) +@interface MethodAnnotation{} + +@Target({ElementType.FIELD}) +@interface FieldAnnotation{} + +@interface AnyAnnotation{} + +public class ExactAnnotationTypePattern { + + public void method1() {} + + @FieldAnnotation + int field = 1; + +} + +aspect A { + + // an xlint message should be displayed because @TypeAnnotation can only + // be applied to types, not methods + pointcut typePC() : execution(@TypeAnnotation * ExactAnnotationTypePattern.method1(..)); + declare warning : typePC() : "blah"; + + // should compile as normal, since @MethodAnnotation can be applied to methods + pointcut methodPC() : execution(@MethodAnnotation * ExactAnnotationTypePattern.method1(..)); + declare warning : methodPC() : "blah"; + + // an xlint message should be displayed because @FieldAnnotation can only + // be applied to fields, not methods + pointcut matchAll() : execution(@FieldAnnotation * *(..)); + declare warning : matchAll() : "blah"; + + // should compile as normal since @FieldAnnotation can be applied to fields + pointcut legalFieldPC() : set(@FieldAnnotation int ExactAnnotationTypePattern.field); + declare warning : legalFieldPC() : "field blah"; + + // an xlint message should be displayed because @MethodAnnotation can + // only be applied to methods, not fields + pointcut illegalFieldPC() : set(@MethodAnnotation int *); + declare warning : illegalFieldPC() : "field blah blah"; + + // no xlint message should be displayed here because @AnyAnnotation + // has the default target + pointcut anyAnnotation() : execution(@AnyAnnotation * *(..)); + declare warning : anyAnnotation() : "default target is allowed everywhere"; + +} Index: bugs150/pr115252/OrTypePattern.java =================================================================== RCS file: bugs150/pr115252/OrTypePattern.java diff -N bugs150/pr115252/OrTypePattern.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ bugs150/pr115252/OrTypePattern.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,34 @@ +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target({ElementType.TYPE}) +@interface TypeAnnotation{} + +@Target({ElementType.METHOD}) +@interface MethodAnnotation{} + +@Target({ElementType.FIELD}) +@interface FieldAnnotation{} + +public class OrTypePattern { + + public void method1() {} + + @FieldAnnotation + int field = 1; + +} + +aspect A { + + // should display an xlint message because @FieldAnnotation can't be + // applied to methods + pointcut orPointcut() : execution(@(FieldAnnotation || MethodAnnotation) * *(..)); + declare warning : orPointcut() : "orPointcut()"; + + // two xlint messages should be displayed because neither @FieldAnnotation + // or @TypeAnnotation can match methods + pointcut orPointcut2() : execution(@(FieldAnnotation || TypeAnnotation) * *(..)); + declare warning : orPointcut2() : "orPointcut2()"; + +}