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.

README-1612.html 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  2. <html> <head>
  3. <title>AspectJ 1.6.12 Readme</title>
  4. <style type="text/css">
  5. <!--
  6. P { margin-left: 20px; }
  7. PRE { margin-left: 20px; }
  8. LI { margin-left: 20px; }
  9. H4 { margin-left: 20px; }
  10. H3 { margin-left: 10px; }
  11. -->
  12. </style>
  13. </head>
  14. <body>
  15. <div align="right"><small>
  16. &copy; Copyright 2010-2011 Contributors.
  17. All rights reserved.
  18. </small></div>
  19. <h1>AspectJ 1.6.12 Readme</h1>
  20. <p>The full list of resolved issues in 1.6.12 is available
  21. <a href="https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced;bug_status=RESOLVED;bug_status=VERIFIED;bug_status=CLOSED;product=AspectJ;target_milestone=1.6.12;">here</a></h2>.</p>
  22. <h4>1.6.12 released 18-Oct-2011</h4>
  23. <h4>1.6.12.RC1 available 3-Oct-2011</h4>
  24. <h4>1.6.12.M2 available 18-Aug-2011</h4>
  25. <h4>1.6.12.M1 available 7-Jun-2011</h4>
  26. <h2>Notable Changes</h2>
  27. <h3>RC1 - annotation value matching and !=</h3>
  28. <p>
  29. Prior to this change it was only possible to specify an annotation match like this:<br><br>
  30. <tt>get(@Anno(someValue=1) * *) || get(@Anno(someValue=3) * *)</tt><br>
  31. <p>Now it is possible to use != and write this:<br><br>
  32. <tt>get(@Anno(someValue!=2) * *)</tt><br>
  33. <p>This can enable a group of annotated elements to be more easily identified.<br>
  34. <br>
  35. <h3>RC1 - More flexible pointcut/code wiring in aop.xml</h3>
  36. <p>
  37. Prior to this version the wiring was quite limited. In order to wire a pointcut to a piece of code the user
  38. needed to write an abstract aspect that included an abstract pointcut and some advice attached to that
  39. abstract pointcut. Then compile this aspect and finally write the XML to concretize the abstract pointcut. With 1.6.12
  40. more flexibility has been added and for some cases there can be no need for that abstract aspect.
  41. <p>This is a work in progress but now you can write this in the aop.xml:
  42. <pre><code>
  43. &lt;concrete-aspect name="MyAspect"&gt;
  44. &lt;before pointcut="execution(* Hello.say2(..)) AND args(message)"
  45. invokeClass="SomeRegularJavaClass"
  46. invokeMethod="someMethod(JoinPoint tjp, java.lang.String message)"/&gt;
  47. &lt;after pointcut="execution(* Hello.say2(..)) AND args(message)"
  48. invokeClass="SomeRegularJavaClass"
  49. invokeMethod="someOtherMethod(JoinPoint tjp, java.lang.String message)"/&gt;
  50. &lt;/concrete-aspect&gt;
  51. public class SomeRegularJavaClass {
  52. public static void someMethod(org.aspectj.lang.JoinPoint tjp, String s) {
  53. System.out.println("in advice4: s="+s+" at "+tjp);
  54. }
  55. public static void someOtherMethod(org.aspectj.lang.JoinPoint tjp, String s) {
  56. System.out.println("in advice5: s="+s+" at "+tjp);
  57. }
  58. }
  59. </code></pre>
  60. <p>In this example there is a simple regular java class containing some static methods. In the XML these
  61. can be joined to pointcuts, kind as if they were advice. Notice in the XML it specifies:
  62. <ul>
  63. <li>The pointcut
  64. <li>The <tt>invokeClass</tt> - the fully qualified name of the class containing the Java method
  65. <li>The <tt>invokeMethod</tt> - the method, including signature in the specified class.
  66. </ul>
  67. <p>
  68. Due to the method specification being in XML the parameter types must be fully specified. The only
  69. exception to this rule is that the AspectJ core types JoinPoint (and JoinPoint.StaticPart) do not
  70. have to be fully qualified (see the example above).
  71. <b>Important:</b> notice that in the case above which does argument binding, the names are
  72. bound according to the XML specification, not according to the parameter names in the Java code.
  73. <p>Around advice is also supported (the return type of the method must match the joinpoint return
  74. type). The example shows after advice, currently there is no way to specify either after returning
  75. or after finally, there is only after.
  76. <p>Expanding this further would enable support for all the code style features in the XML. Some
  77. of the language features like declare annotation cannot be done in annotation style aspects but the
  78. XML doesn't have the same kind of restrictions. If anyone wants to help out by fleshing this area
  79. of the weaver out, let me know and I'll help you get started!
  80. <hr>
  81. <h3>M2 - thisAspectInstance (<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=239649">bug239649</a>)</h3>
  82. <p>
  83. There is now a new well known name that you can use in the if clauses in your aspects. <tt>thisAspectInstance</tt> provides access to the aspect instance.
  84. Here is an example:
  85. <code><pre>aspect X {
  86. boolean doit() {
  87. System.out.println("In instance check method doit()");
  88. return true;
  89. }
  90. before():execution(* m(..)) && if(thisAspectInstance.doit()){
  91. System.out.println(thisJoinPoint);
  92. }
  93. }</pre></code>
  94. <p>Now why not just use <tt>X.aspectOf()</tt> instead of <tt>thisAspectInstance</tt>? Well <tt>thisAspectInstance</tt> is quite useful
  95. when working with abstract/concrete aspects:
  96. <code><pre>
  97. abstract aspect X {
  98. abstract pointcut p();
  99. boolean doit() {
  100. return true;
  101. }
  102. before():p() && if(thisAspectInstance.doit()){
  103. System.out.println(thisJoinPoint);
  104. }
  105. }
  106. aspect Y extends X {
  107. pointcut p(): execution(* m(..));
  108. }</pre></code>
  109. <p>Now <tt>thisAspectInstance</tt> will be an instance of the Y, not X.
  110. It enables the aspect instance to be used in some kind of check/guard that will avoid the costly creation of a thisJoinPoint object if
  111. the advice isn't going to run.
  112. <b>Note:</b> right now this only works for singleton aspects. If you have need of it with other instantiation models, please comment on
  113. <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=239649">https://bugs.eclipse.org/bugs/show_bug.cgi?id=239649</a>
  114. </p>
  115. <h3>M2 - weaving groovy</h3>
  116. <p>
  117. Although we have been successfully weaving groovy for a long time, it is becoming more popular and a few issues have been uncovered
  118. when using non-singleton aspects with groovy code. These have been fixed.
  119. </p>
  120. <h3>M2 - AJDT memory</h3>
  121. <p>
  122. The release notes for the last few versions of AspectJ have mentioned two options (minimalModel and typeDemotion) which can be
  123. switched on to reduce memory consumption. They have had enough field testing now and from 1.6.12.M2 onwards they are on by default.
  124. Users should see a reduction in memory consumed by AspectJ projects in AJDT. It won't affect load time weaving. It may also help
  125. command line (or Ant) compile time weaving. If these options cause a problem then please raise a bugzilla but in the interim you could
  126. work around the problem by actively turning them off by
  127. specifying <tt>-Xset:minimalModel=false,typeDemotion=false</tt> in the project properties for your AspectJ project.
  128. </p>
  129. <h3>M2 - Java7 weaving support</h3>
  130. <p>Some preliminary work has been done to support Java7. Java7 class files must contain the necessary extra verifier support attributes
  131. in order to load successfully on a Java7 VM - the attributes were only optional in Java6. It is possible to force loading of classes missing
  132. the attributes but that requires use of a -XX option. AspectJ 1.6.12.M2 should create these for you if you weave Java7 level class
  133. files. Nothing has been done yet to rebase AspectJ on a version of the Eclipse compiler that supports Java7 language constructs -
  134. that will happen after Eclipse 3.7.1 is out.
  135. </p>
  136. <hr>
  137. <h3>M1 - synthetic is supported in pointcut modifiers <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=327867">327867</a></h3>
  138. <p>It is now possible to specify synthetic in pointcuts:
  139. </p>
  140. <pre><code>pointcut p(): execution(!synthetic * *(..));
  141. </code></pre>
  142. <h3>M1 - respect protection domain when generating types during weaving <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=328099">328099</a></h3>
  143. <p>This enables us to weave signed jars correctly. AspectJ sometimes generates closure classes during weaving and
  144. these must be defined with the same protection domain as the jar that gave rise to them. In 1.6.12.M1 this should
  145. now work correctly.
  146. </p>
  147. <h3>M1 - Suppressions inline with the JDT compiler <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=335810">335810</a></h3>
  148. <p>Starting with Eclipse 3.6, the Eclipse compiler no longer suppresses raw type
  149. warnings with @SuppressWarnings("unchecked"). You need to use
  150. @SuppressWarnings("rawtypes") for that. AspectJ has now been updated with this rule too.
  151. </p>
  152. <h3>M1 - Optimized annotation value binding for ints <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=347684">347684</a></h3>
  153. <p>The optimized annotation value binding now supports ints - this is for use when you want to match upon the existence of an annotation but
  154. you don't need the annotation, you just need a value from it. This code snippet shows an example:</p>
  155. <pre><code>@interface SomeAnnotation {
  156. int i();
  157. }
  158. before(int i): execution(* *(..)) && @annotation(SomeAnnotation(i)) {
  159. </code></pre>
  160. <p>
  161. Binding values in this way will result in code that runs *much* faster than using pointcuts that
  162. bind the annotation itself then pull out the value.
  163. </p>
  164. <p>Under that same bug some changes were made to match values by name when binding too. Suppose the annotation
  165. had multiple int values, how would we select which int to bind? AspectJ will now use the name (if it can) to select
  166. the right value:
  167. <pre><code>@interface SomeAnnotation {
  168. int mods();
  169. int flags();
  170. }
  171. before(int flags): execution(* *(..)) && @annotation(SomeAnnotation(flags)) {
  172. </code></pre>
  173. <p>Here the use of 'flags' as the name of the value being bound will ensure the 'flags' value from any SomeAnnotation is
  174. bound and not the 'mods' value.</p>
  175. <h4>
  176. <!-- ============================== -->
  177. </body>
  178. </html>