Hi,

I started playing with LTW, inter-type fields and pertarget() aspects and ran into an interesting problem. I was trying to use inter-type fields to carry some information I need on a per-object basis. But every time the advice using these inter- type fields got executed I got a NoSuchFieldException (the compiler gave me a typeNotExposedToWeaver warning, but I think that's ok, because I use LTW). So I changed my aspect to be pertarget() and it behaves like expected (aspect code below).

Now here are my questions:
- Shouldn't a pertarget/perthis aspect declare field pretty much the same way as an inter-type declaration in a singleton aspect? - I'm not sure if I should use a pertarget or perthis aspect for what I want to do. The content of the fields should be carried around with the advised object across the objects lifetime (which is why I originally wanted to use inter-types). - When running the LTW with -showWeaveInfo I get a log message for every jointpoint that gets woven. What should the message look like for weaving inter-type fields. Or should there be a message at all?

Thanks,
Jochen

P.S.: My aspect looks like this:

public aspect JspIdConsumerUnique pertarget( instanceCreation(UIComponentClassicTagBase) || setUniqueProperty(UIComponentClassicTagBase) ) {
        
        private boolean lumi_uniquePropertySet = false;
        private Object lumi_uniqueProperty = null;

pointcut instanceCreation( UIComponentClassicTagBase _consumer ): target(_consumer) && execution( UIComponentClassicTagBase+.new(..) );
                
after(UIComponentClassicTagBase _consumer) : instanceCreation( _consumer ) {
                safeAddObject( _consumer );
        }
        
pointcut setUniqueProperty( UIComponentClassicTagBase _consumer ): target(_consumer) &&
                call( * UIComponentClassicTagBase+.setJspId(..) );
        
before( UIComponentClassicTagBase _consumer ): setUniqueProperty( _consumer ) {
                uniqueProperty = _consumer.getJspId();
        }
        
after( UIComponentClassicTagBase _consumer ): setUniqueProperty( _consumer ) {
                if ( propertyHasChanged( _consumer.getJspId() ) ) {
                        lumi_uniquePropertySet = true;
                        updateContainer( uniqueProperty, _consumer );
                }
        }
        
        //private methods go here

}


_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to