Community
Participate
Working Groups
In cases where the body of advice refers to a non-statically evaluable portion of thisJoinPoint (so that it can't be optimized by the compiler to thisJoinPointStaticPart), the JoinPoint object is currently always created before entering the advice body - even if the JoinPoint object would never actually be accessed (because of a test within the advice for example). Since a) thisJoinPoint is often used in tracing applications b) tracing applications tend to be very pervasive, c) they must have low overhead when tracing is disabled, and d) creation of thisJoinPoint objects is expensive (v. expensive compared to just testing a flag) it would be nice if there was a way to create JoinPoint objects lazily on first actual reference within the advice body.
Implemented in tree with unit test in ajdt.core test sources under PerformanceTestCase. Speed-ups of 10-100X are measured even when running a small test case with minimal GC issues. The actual feature implemented is that thisJoinPoint objects are only created just before calling the method for advice that requires them. To take advantage of this feature you must use an if PCD or some other dynamic test that occurs in the PCD not the advice body to guard the expensive creation of the thisJoinPoint object. -XlazyTjp flag must be passed to compiler to enable this feature. If any around advice is present on the joinpoint then lazy instantiation will be disabled. An Xlint warning will be displayed in this case. As a related optimization, several helper methods were added to Factory.makeJP to reduce the code size when thisJoinPoint is used.
I discovered When trying to write a new logging aspect to exploit this enhancement that the new -X option is difficult to use. Although accepted by AJDT it is ignore and the Ant task also ignores it because it has its own option parsing. The only ways are to use the command line or an entry in an argfile. I was surprised at how many placed we police options.