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.xml 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <chapter id="miscellaneous" xreflabel="Miscellaneous Changes">
  2. <title>Other Changes in AspectJ 5</title>
  3. <sect1>
  4. <title>Pointcuts</title>
  5. <sect2>
  6. <title>Binding of formals</title>
  7. <para>
  8. AspectJ 5 is more liberal than AspectJ 1.2.1 in accepting pointcut expressions
  9. that bind context variables in more than one location. For example, AspectJ
  10. 1.2.1 does not allow:
  11. </para>
  12. <programlisting><![CDATA[
  13. pointcut foo(Foo foo) : (execution(* *(..)) && this(foo) ) ||
  14. (set(* *) && target(foo));
  15. ]]></programlisting>
  16. <para>
  17. whereas this expression is permitted in AspectJ 5. Each context variable must
  18. be bound exactly once in each branch of a disjunction, and the disjunctive branches
  19. must be mutually exclusive. In the above example for instance, no join point
  20. can be both an execution join point and a set join point so the two branches
  21. are mutually exclusive.
  22. </para>
  23. </sect2>
  24. <sect2>
  25. <title>Additional lint warnings</title>
  26. <para>
  27. Discuss detection of common errors -> warning/error, eg. conjunction of more than one
  28. kind of join point. Differing numbers of args in method signature / args / @args /
  29. @parameters.
  30. </para>
  31. </sect2>
  32. </sect1>
  33. <sect1 id="declare-soft">
  34. <title>Declare Soft</title>
  35. <para>
  36. The semantics of the <literal>declare soft</literal> statement have been
  37. refined in AspectJ 5 to only soften exceptions that are not already runtime
  38. exceptions. If the exception type specified in a declare soft statement is <literal>RuntimeException</literal>
  39. or a subtype of <literal>RuntimeException</literal> then a new XLint warning will be issued:</para>
  40. <programlisting><![CDATA[
  41. declare soft : SomeRuntimeException : execution(* *(..));
  42. &gt;&gt; "SomeRuntimeException will not be softened as it is already a RuntimeException" [XLint:runtimeExceptionNotSoftened]
  43. ]]></programlisting>
  44. <para>
  45. This XLint message can be controlled by setting the <literal>runtimeExceptionNotSoftened</literal> XLint parameter.
  46. </para>
  47. <para>
  48. If the exception type specified in a declare soft statement is a super type of <literal>RuntimeException</literal>
  49. (such as <literal>Exception</literal> for example) then any <i>checked</i> exception thrown at a matched join point,
  50. where the exception is an instance of the softened exception, will be softened to an
  51. <literal>org.aspectj.lang.SoftException</literal>.
  52. </para>
  53. <programlisting><![CDATA[
  54. public aspect SoftenExample {
  55. declare soft : Exception : execution(* Foo.*(..));
  56. }
  57. class Foo {
  58. public static void main(String[] args) {
  59. Foo foo = new Foo();
  60. foo.foo();
  61. foo.bar();
  62. }
  63. void foo() throws Exception {
  64. throw new Exception(); // this will be converted to a SoftException
  65. }
  66. void bar() throws Exception {
  67. throw new RuntimeException(); // this will remain a RuntimeException
  68. }
  69. }
  70. ]]></programlisting>
  71. </sect1>
  72. <sect1>
  73. <title>Tools</title>
  74. <sect2>
  75. <title>Aspectpath</title>
  76. <para>AspectJ 5 allows the specification of directories (containing .class files) on the aspectpath in
  77. addition to jar/zip files.</para>
  78. </sect2>
  79. </sect1>
  80. </chapter>