123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <chapter id="miscellaneous" xreflabel="Miscellaneous Changes">
-
- <title>Other Changes in AspectJ 5</title>
-
- <sect1>
- <title>Pointcuts</title>
-
- <sect2>
- <title>Binding of formals</title>
- <para>
- AspectJ 5 is more liberal than AspectJ 1.2.1 in accepting pointcut expressions
- that bind context variables in more than one location. For example, AspectJ
- 1.2.1 does not allow:
- </para>
-
- <programlisting><![CDATA[
- pointcut foo(Foo foo) : (execution(* *(..)) && this(foo) ) ||
- (set(* *) && target(foo));
- ]]></programlisting>
-
- <para>
- whereas this expression is permitted in AspectJ 5. Each context variable must
- be bound exactly once in each branch of a disjunction, and the disjunctive branches
- must be mutually exclusive. In the above example for instance, no join point
- can be both an execution join point and a set join point so the two branches
- are mutually exclusive.
- </para>
-
- </sect2>
-
- <sect2>
- <title>Additional lint warnings</title>
- <para>
- Discuss detection of common errors -> warning/error, eg. conjunction of more than one
- kind of join point. Differing numbers of args in method signature / args / @args /
- @parameters.
- </para>
- </sect2>
- </sect1>
-
- <sect1 id="declare-soft">
- <title>Declare Soft</title>
- <para>
- The semantics of the <literal>declare soft</literal> statement have been
- refined in AspectJ 5 to only soften exceptions that are not already runtime
- exceptions. If the exception type specified in a declare soft statement is <literal>RuntimeException</literal>
- or a subtype of <literal>RuntimeException</literal> then a new XLint warning will be issued:</para>
-
- <programlisting><![CDATA[
- declare soft : SomeRuntimeException : execution(* *(..));
-
- >> "SomeRuntimeException will not be softened as it is already a RuntimeException" [XLint:runtimeExceptionNotSoftened]
- ]]></programlisting>
-
- <para>
- This XLint message can be controlled by setting the <literal>runtimeExceptionNotSoftened</literal> XLint parameter.
- </para>
-
- <para>
- If the exception type specified in a declare soft statement is a super type of <literal>RuntimeException</literal>
- (such as <literal>Exception</literal> for example) then any <i>checked</i> exception thrown at a matched join point,
- where the exception is an instance of the softened exception, will be softened to an
- <literal>org.aspectj.lang.SoftException</literal>.
- </para>
-
- <programlisting><![CDATA[
- public aspect SoftenExample {
-
- declare soft : Exception : execution(* Foo.*(..));
-
- }
-
- class Foo {
-
- public static void main(String[] args) {
- Foo foo = new Foo();
- foo.foo();
- foo.bar();
- }
-
- void foo() throws Exception {
- throw new Exception(); // this will be converted to a SoftException
- }
-
- void bar() throws Exception {
- throw new RuntimeException(); // this will remain a RuntimeException
- }
-
- }
- ]]></programlisting>
-
-
- </sect1>
-
- <sect1>
- <title>Tools</title>
-
- <sect2>
- <title>Aspectpath</title>
-
- <para>AspectJ 5 allows the specification of directories (containing .class files) on the aspectpath in
- addition to jar/zip files.</para>
- </sect2>
-
- </sect1>
- </chapter>
|