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.

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