Bug 354470 - perthis inserts perObjectField to all compiled classes
Summary: perthis inserts perObjectField to all compiled classes
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.11   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.6.12   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-11 05:35 EDT by Viktor Kuzmin CLA
Modified: 2011-09-20 07:43 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.