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.

ThreadSub.java 980B

123456789101112131415161718192021222324252627282930313233
  1. public class ThreadSub {
  2. public static void main (String[] args) {
  3. Target.main(args);
  4. }
  5. }
  6. // need subclass - introduction fails on Thread as outside CCC
  7. class ThreadSubclass extends Thread {
  8. int result;
  9. }
  10. aspect Aspect {
  11. static final String[] SIGNALS = new String[]
  12. { "around - start"
  13. , "around - run - before proceed"
  14. , "around - run - after proceed"
  15. };
  16. /** @testcase PR#620 around advice inner Thread subclass running proceed and writing field */
  17. int around(): Target.pointcutTarget() {
  18. ThreadSubclass runner = new ThreadSubclass() {
  19. public void run() {
  20. Common.signal(SIGNALS[1]);
  21. result = proceed(); // remove to avoid bug
  22. Common.signal(SIGNALS[2]);
  23. }
  24. };
  25. runner.start();
  26. Common.joinWith(runner);
  27. Common.signal(SIGNALS[0]);
  28. return runner.result; // remove to avoid bug
  29. }
  30. }