Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 356612

Summary: Performance problem with @annotation(x) on field access
Product: [Tools] AspectJ Reporter: Missing name <maik.jablonski>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: aclement
Version: unspecified   
Target Milestone: 1.6.12   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Missing name CLA 2011-09-02 11:08:46 EDT
Build Identifier: 

Some time ago there was a bug report about slow performance with
@annotation on method level:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=296484

I want to report a similar issue with the @annotation on field access level.

Using something like the following advice which captures the use of a
@Bind-annotation on field set access results in poor performance:

       Object around(Object host, Bind bind, Object newGuest)
       : set(@Bind !java.util.Collection+ *.*)
                       && this(host) && args(newGuest) && @annotation(bind)
       {
               // ...
               return proceed(host, bind, newGuest);
       }

A workaround similar to the one descirbed in the bug reports performs
much better:

       Object around(Object host, Object newGuest)
       : set(@Bind !java.util.Collection+ *.*)
               && this(host) && args(newGuest)
       {
               Bind bind = ((FieldSignature)
thisJoinPointStaticPart.getSignature()).getField().getAnnotation(Bind.class);
               // ...
               return proceed(host, newGuest);
       }

Reproducible: Always
Comment 1 Andrew Clement CLA 2011-09-02 18:34:39 EDT
fixes are in.  Similar to 296484.  I also optimized it to try and share the cached field where possible (when @annotation is used for a kinded shadow, like field-get/field-set) - that should prevent a proliferation of fields (previously it was using one field per shadow).