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-1.6.12.adoc 8.4KB

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