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.

Driver.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import org.aspectj.testing.Tester;
  2. // PR#275 & 276 cast error generated by ajc when type not in signature
  3. public class Driver {
  4. public static void main(String[] args) { test(); }
  5. public static void test() {
  6. Tester.checkEqual(new SourcePane().go(), -10);
  7. }
  8. }
  9. class SourcePane {
  10. public int go() {
  11. Location location = new Location();
  12. return location.lineNumber();
  13. }
  14. }
  15. class Location {
  16. public int lineNumber() {
  17. return 10;
  18. }
  19. }
  20. aspect DriverAspect {
  21. pointcut locationLineNumber(Location loc):
  22. //XXX Fails with a star
  23. //calls(int *.lineNumber()) && within(SourcePane);
  24. //calls(int loc.lineNumber()) && within(SourcePane);
  25. target(loc) && call(int Location.lineNumber()) && within(SourcePane);
  26. int around(Location loc): locationLineNumber(loc) {
  27. int result = proceed(loc);
  28. return result * -1;
  29. }
  30. // The following code won't report the cast error and will work:
  31. /*
  32. pointcut locationLineNumber(SourcePane s, Location loc):
  33. calls(loc, int lineNumber()) & within(s);
  34. static around(SourcePane s, Location loc) returns int: locationLineNumber(s, loc) {
  35. int result = proceed(s, loc);
  36. return result * -1;
  37. }
  38. */
  39. }