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.

CallsToArray.java 720B

1234567891011121314151617181920212223242526272829
  1. import org.aspectj.testing.Tester;
  2. public class CallsToArray {
  3. public static void main(String[] args) {
  4. byte[] a = new byte[] {0, 1};
  5. byte[] b = (byte[])a.clone();
  6. Tester.check(a != b, "cloned array is different");
  7. Tester.check(a[0] == b[0] && a[1] == b[1], "but compares equal");
  8. Tester.check(A.returnedClone == b, "advice did right thing");
  9. }
  10. }
  11. aspect A {
  12. static Object returnedClone;
  13. after () returning(Object cloned): call(Object Object.clone()) {
  14. System.out.println("running advice");
  15. A.returnedClone = cloned;
  16. }
  17. /*
  18. static after () returning(Object cloned): calls(Object .clone()) {
  19. System.out.println("running advice on byte[]");
  20. A.returnedClone = cloned;
  21. }
  22. */
  23. }