Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

DeclareWarningAndInterfaceMethodCW.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * ajc fails to detect call join points using the
  3. * declaring interface as the type when the method
  4. * was declared in the aspect.
  5. */
  6. public class DeclareWarningAndInterfaceMethodCW {
  7. public static void main(String[] args) {
  8. new C().doSomething();
  9. }
  10. }
  11. interface ICanGetSomething {
  12. Object getSomething();
  13. }
  14. class B implements ICanGetSomething {
  15. public Object getSomething() { // CE conflict here?
  16. return new Object();
  17. }
  18. }
  19. class C {
  20. C() {
  21. new B().getSomething(); // 2 CW declared here
  22. }
  23. static void staticMethod() {
  24. new B().getSomething(); // 2 CW declared here
  25. B b = new B();
  26. b.getSomething(); // 2 CW declared here
  27. ICanGetSomething i = new B();
  28. i.getSomething(); // 2 CW declared here
  29. }
  30. void doSomething() {
  31. Object result = new B().getSomething(); // 2 CW here
  32. if (null == result) {
  33. throw new Error("no result");
  34. }
  35. }
  36. }
  37. /** @testcase PR#40805 interface call signatures when declaring method in aspect */
  38. aspect A {
  39. // comment this out to get correct warnings
  40. public Object ICanGetSomething.getSomething() {
  41. return null;
  42. }
  43. declare warning : call(Object ICanGetSomething.getSomething())
  44. : "call ICanGetSomething.getSomething()";
  45. declare warning : call(Object getSomething())
  46. : "call getSomething()";
  47. }