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.

DeclaringTypeWarning.java 937B

123456789101112131415161718192021222324252627
  1. class A { void run() {} }
  2. class B extends A {}
  3. aspect C {
  4. before() : runB() { }
  5. pointcut runB(): call(void B.run()); // CW 6 XLint, for each shadow (12, 14)
  6. before() : call(int B.run()) {} // pointcut not matched
  7. }
  8. public class DeclaringTypeWarning {
  9. public static void main(String[] args) {
  10. // ok with -1.4; otherwise, becomes A.run in bytecode
  11. new B().run(); // CW 12 DW
  12. // never works - compile-time type of reference is A, not B
  13. ((A) new B()).run();
  14. }
  15. }
  16. aspect D {
  17. // produces CW 12 DW only under 1.4 (correct method signature)
  18. declare warning : call(void B.run()) : // no XLint warning here (?)
  19. "declare warning : call(void B.run())";
  20. // should never produce a warning
  21. declare warning : call(int B.run()) :
  22. "declare warning : call(int B.run())";
  23. }
  24. /** @testcase PR#41952 XLint when call declaring type is not defining type */