You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AnnotationParameterType.java 850B

12345678910111213141516171819202122232425262728293031323334
  1. import java.lang.annotation.Target;
  2. import java.lang.annotation.ElementType;
  3. @Target({ElementType.TYPE})
  4. @interface TypeAnnotation{}
  5. @Target({ElementType.METHOD})
  6. @interface MethodAnnotation{}
  7. public class AnnotationParameterType {
  8. public void method1(MyClass m) {
  9. }
  10. }
  11. @TypeAnnotation
  12. class MyClass {
  13. }
  14. aspect A {
  15. // shouldn't get an xlint warning because looking method which
  16. // takes an argument that has the @TypeAnnotation
  17. pointcut pc() : execution(* *(@TypeAnnotation *));
  18. declare warning : pc() : "* *(@TypeAnnotation *)";
  19. // should get an xlint warning because can only have the default,
  20. // or @Target{ElementType.TYPE} as an argument type
  21. pointcut incorrectArgumentType() : execution(* *(@MethodAnnotation *));
  22. declare warning : incorrectArgumentType() : "argument type can only have @Target{ElementType.TYPE}";
  23. }