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.

StrictFpReceptions.java 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import org.aspectj.testing.*;
  2. public class StrictFpReceptions {
  3. // reception counter
  4. static int r_counter = 0;
  5. // call counter
  6. static int c_counter = 0;
  7. public static void main(String[] args) {
  8. StrictClass s = new StrictClass();
  9. StrictClassAbstract sa = s;
  10. cleanup();
  11. s.test1();
  12. Tester.check
  13. (r_counter==1 && c_counter==1,
  14. "test1 method call, " +
  15. "counters="+r_counter+","+c_counter);
  16. cleanup();
  17. sa.test2();
  18. Tester.check
  19. (r_counter==0 && c_counter==0,
  20. "test2 method call, " +
  21. "counters="+r_counter+","+c_counter);
  22. cleanup();
  23. sa.test3();
  24. Tester.check
  25. (r_counter==1 && c_counter==1,
  26. "test3 method call, " +
  27. "counters="+r_counter+","+c_counter);
  28. cleanup();
  29. sa.test4();
  30. Tester.check
  31. (r_counter==1 && c_counter==1,
  32. "test4 static method call, " +
  33. "counters="+r_counter+","+c_counter);
  34. cleanup();
  35. sa.test5();
  36. Tester.check
  37. (r_counter==0 && c_counter==0,
  38. "test5 static method call, " +
  39. "counters="+r_counter+","+c_counter);
  40. }
  41. private static void cleanup() {
  42. r_counter = c_counter = 0;
  43. }
  44. }
  45. aspect StrictFpWatcher {
  46. pointcut r_strict() : execution(strictfp * *(..));
  47. pointcut c_strict() : call(strictfp * *.*(..));
  48. before() : r_strict() { StrictFpReceptions.r_counter++; }
  49. before() : c_strict() { StrictFpReceptions.c_counter++; }
  50. }
  51. abstract class StrictClassAbstract {
  52. float f;
  53. double d;
  54. StrictClassAbstract() {}
  55. StrictClassAbstract(double _d) { d = _d; }
  56. public abstract float test1();
  57. public float test2() { return 0.f; }
  58. public strictfp float test3() { return 0.f; }
  59. public static strictfp float test4() { return 0.f; }
  60. public static float test5() { return 0.f; }
  61. };
  62. strictfp class StrictClass extends StrictClassAbstract {
  63. public float test1() { return 0.f; }
  64. }