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.

IntroErrorLocation.java 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package typepatternmatch.pack1;
  2. import org.aspectj.testing.Tester;
  3. import org.aspectj.testing.Tester;
  4. /**
  5. * FYI the compiler will not warn when a TypePattern matches no type/class.
  6. * From an email to user from Stefan
  7. */
  8. public class IntroErrorLocation {
  9. /** change to true if the compiler ever should weave in by finding type? */
  10. public static volatile boolean EXPECT_INIT = false;
  11. /** signifies that the initialization advice was run */
  12. public static final String INIT_SIGNAL = "init";
  13. static {
  14. if (EXPECT_INIT) Tester.event(INIT_SIGNAL);
  15. }
  16. public static void main(String[] args) {
  17. typepatternmatch.pack2.TargetClass target
  18. = new typepatternmatch.pack2.TargetClass();
  19. Tester.checkAllEvents();
  20. }
  21. }
  22. aspect MyIntroductionAspect {
  23. /** @testTarget typepattern.nonmatching.introduction.method */
  24. public String TargetClass.introMethod(String s) { // fails to match typepattern in other package
  25. return s;
  26. }
  27. /** @testTarget signature.nonmatching.advice.initialization */
  28. after (typepatternmatch.pack2.TargetClass c)
  29. : initialization(TargetClass.new()) && this(c) { // fails to match signature in other package
  30. final String test = IntroErrorLocation.INIT_SIGNAL;
  31. if (IntroErrorLocation.EXPECT_INIT) {
  32. //Tester.event(c.introMethod(test)); // todo add positive: passed
  33. }
  34. // compiler error here is correct: no such method; no introMethod b/c TargetClass not matched
  35. Tester.checkEqual(test, c.introMethod(test), "Round trip failed"); // correct compiler error
  36. }
  37. }