Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Is there any particular order in ITD?

Hello Mathew,

It seems that you actually managed to reproduce my problem. I have commited a bug, as you suggested: https://bugs.eclipse.org/bugs/show_bug.cgi?id=169699.

Thank you very much for your attention,

Paulo Zenida


Citando Matthew Webster <matthew_webster@xxxxxxxxxx>:

Paulo,

I believe declare statements, like inter-type declarations, should be
applied simultaneously or an error/warning is issued. For example if I ITD
a method that already exists, or that is ITD'd by another aspect, I will
get an error. If not it can be matched by pointcuts. However with declare
annotation it seems that the statements can affect each other. I cannot
find a statement on the semantics of this in the documentation. However I
think I have reproduced your problem

public aspect DeclareExclude {

        declare @method : !@Exclude public void main(..) : @Exclude ;

}

public aspect DeclareInclude {

        declare @method : !@Exclude public void main(..) : @Include;
}

public aspect Tracing {

        before () : execution(@Include * *(..)) {
                System.out.println("Tracing.before() " + thisJoinPoint);
        }
}

public class HelloWorld {

//      @Exclude
        public static void main(String[] args) {
                System.out.println("Hello World!");
        }

}

When I  turn on weaveInfo messages I get:

'public static void test.HelloWorld.main(String[])' (HelloWorld.java:6) is
annotated with @Exclude method annotation from 'test.DeclareExclude'
(DeclareExclude.aj:5)
'public static void test.HelloWorld.main(String[])' (HelloWorld.java:6) is
annotated with @Include method annotation from 'test.DeclareInclude'
(DeclareInclude.aj:5)
Join point 'method-execution(void
test.HelloWorld.main(java.lang.String[]))' in Type 'test.HelloWorld'
(HelloWorld.java:6) advised by before advice from 'test.Tracing'
(Tracing.aj:8)

which seems to suggest the first declare annotation is being ignored by
the second. If I comment out the @Exclude in HelloWorld.java I get no
weaving as expected.

You might like to open a bug and I will post the testcase.

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/



Paulo Alexandre Corigo Zenida <paulo.zenida@xxxxxxxx>
Sent by: aspectj-users-bounces@xxxxxxxxxxx
28/12/2006 23:42
Please respond to
aspectj-users@xxxxxxxxxxx


To
AspectJ Mailing List <aspectj-users@xxxxxxxxxxx>
cc

Subject
[aspectj-users] Is there any particular order in ITD?






Hello there,

I was wondering if there is any particular order when different
aspects inject annotations in particular constructors and methods or
if there are possible conflicts when more than one aspect perform
injection of annotations, when that injection depends on the existence
or absence of another annotation. Something like "declare foo() as
@AccessControlled if foo() is not already @AccessControlled nor
@NotAccessControlled".

I am facing a strange behaviour which, unfortunately, I wasn't able to
replicate in a small example... Anyway, I will try to explain the idea:

I have two projects: one project base, where I have a few generic
aspects deployed in a jar file which is used in another concrete
project.

In "base", I have an abstract aspect with the following declaration:

public abstract aspect AccessController<CurrentPrincipal> implements
IAccessController<CurrentPrincipal>, IAccessControllerForQuerying,
IAccessControllerForModifying {

   ...

     declare @constructor :
         !@AccessControlled !@NotAccessControlled !private
(@AccessControlled *..*.*+).new(..) :
         @AccessControlled(inherited = true);

   ...

}

In "concrete", we have the aspect that extends and thus enables the
aspect AccessController:

public aspect Concrete extends AccessController<User> {

   ...

}

Then, I create an aspect that injects annotations on my code, such as:

public aspect AccessControlRequirementsDeclarator {

     declare @type :
         pt.iscte.ciiscte.heliopolis.business.manager.AnnouncementManager
:
             @AccessControlled("manage_news");

     declare @type :
         pt.iscte.ciiscte.heliopolis.business.manager.PersonManager :
             @AccessControlled("manage_people");

}

The previous works fine. However, if I try to add @NotAccessControlled
annotations before those definitions, such as,

...

declare @constructor :
     public pt.iscte.ciiscte.heliopolis.business.manager.*.new(..) :
         @NotAccessControlled;

...

the result gets different each time I compile the application. E.g., I
created a custom message handler that counts all distinct affected
join points by AccessController, and the number of advised join points
gets different with each compilation (in my case, I had 41 and 35
different advised join points). Moreover, using reflection, I have
realized that sometimes, my methods have both annotations. Does this
means that the aspect Concrete was processed before? Still, I tried
another definition for the not access controlled points, like:

declare @constructor :
     !@NotAccessControlled !@AccessControlled public
pt.iscte.ciiscte.heliopolis.business.manager.*.new(..) :
         @NotAccessControlled;

but I had the same strange problems. Finally, something that also
sounds really strange is that the number or declare @xxxx seems to
have effect on the weaving result. Any ideas about what this might be?
(I have the latest stable version of the AspectJ compiler - AspectJ
1.5.3, November 23, 2006, in http://www.eclipse.org/ajdt/downloads/).

Thank you all for your interest.

By the way, happy new year to you all.

Paulo Zenida

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users





----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.




Back to the top