Bug 354470

Summary: perthis inserts perObjectField to all compiled classes
Product: [Tools] AspectJ Reporter: Viktor Kuzmin <kva>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aclement
Version: 1.6.11   
Target Milestone: 1.6.12   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Viktor Kuzmin CLA 2011-08-11 05:35:28 EDT
I need to have perthis aspect for classes which have annotated methods:

@Aspect("perthis(transactional())
public class TransactionalAspect
{
   @Pointcut("execution(@Transactional * * (..))")
   public void transactional()
   {
   }
}

It is supposed that perObjectField should be created only for classes which have annotated methods, but currently perObjectField is added to each class.
Comment 1 Andrew Clement CLA 2011-09-13 20:08:19 EDT
The current implementation is working 'as designed'.  But I agree it isn't optimal.  I've made the changes to cope with this specific situation (a method execution pointcut that specifies annotations), it is a little ugly because the weaver is not intended to do matching in this way (it usually uses a vague test up front to determine which types might have an aspect, giving them the field, then does more accurate matching later - the extra field is unused when the accurate match actually fails).

So 1.6.12 will do a better job here.  

Do you find the extra field actually breaks something? Or are you just observing that it exists where you don't want it?
Comment 2 Viktor Kuzmin CLA 2011-09-20 07:43:05 EDT
(In reply to comment #1)

> Do you find the extra field actually breaks something? Or are you just
> observing that it exists where you don't want it?

Extra fields are added to all objects -> they eat a little bit more space but the main problem is that they make harder to do introspection.