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.

miscellaneous.adoc 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. [[miscellaneous]]
  2. = Other Changes in AspectJ 5
  3. [[pointcuts-change]]
  4. == Pointcuts
  5. AspectJ 5 is more liberal than AspectJ 1.2.1 in accepting pointcut
  6. expressions that bind context variables in more than one location. For
  7. example, AspectJ 1.2.1 does not allow:
  8. [source, java]
  9. ....
  10. pointcut foo(Foo foo) :
  11. (execution(* *(..)) && this(foo) ) ||
  12. (set(* *) && target(foo));
  13. ....
  14. whereas this expression is permitted in AspectJ 5. Each context variable
  15. must be bound exactly once in each branch of a disjunction, and the
  16. disjunctive branches must be mutually exclusive. In the above example
  17. for instance, no join point can be both an execution join point and a
  18. set join point so the two branches are mutually exclusive.
  19. [[declare-soft-change]]
  20. == Declare Soft
  21. The semantics of the `declare soft` statement have been refined in
  22. AspectJ 5 to only soften exceptions that are not already runtime
  23. exceptions. If the exception type specified in a declare soft statement
  24. is `RuntimeException` or a subtype of `RuntimeException` then a new
  25. XLint warning will be issued:
  26. [source, java]
  27. ....
  28. declare soft : SomeRuntimeException : execution(* *(..));
  29. // "SomeRuntimeException will not be softened as it is already a
  30. // RuntimeException" [XLint:runtimeExceptionNotSoftened]
  31. ....
  32. This XLint message can be controlled by setting the
  33. `runtimeExceptionNotSoftened` XLint parameter.
  34. If the exception type specified in a declare soft statement is a super
  35. type of `RuntimeException` (such as `Exception` for example) then any
  36. _checked_ exception thrown at a matched join point, where the exception
  37. is an instance of the softened exception, will be softened to an
  38. `org.aspectj.lang.SoftException`.
  39. [source, java]
  40. ....
  41. public aspect SoftenExample {
  42. declare soft : Exception : execution(* Foo.*(..));
  43. }
  44. class Foo {
  45. public static void main(String[] args) {
  46. Foo foo = new Foo();
  47. foo.foo();
  48. foo.bar();
  49. }
  50. void foo() throws Exception {
  51. throw new Exception(); // this will be converted to a SoftException
  52. }
  53. void bar() throws Exception {
  54. throw new RuntimeException(); // this will remain a RuntimeException
  55. }
  56. }
  57. ....