Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] RE: [aspectj-users] More precedence

Hi Erik,

I guess I should have waited, it looks like you answered my further
questions  on the users list. 

Regarding my comment about documentation, I believe that -Xlint warnings
are some of the best documentation. So I heartily approve of that
suggestion.

Just so the thread is resolved for anyone who hasn't followed it, the Q/A
pair is:

[Me]:
<<<
Would the situation change if Super was an (abstract) aspect?:
>>>

[Erik]:
<<<
In general, if you're dealing with a hierarchy of aspects,
you'll want to use the + operator.  So in your case just
saying

    declare dominates: Super, B;

won't do anything if Super is not a concrete aspect.  But
using

    declare dominates: Super+, B;

will be fine.

No error will be shown for putting a non-aspect type into
the list, specifically to allow using marker interfaces to
pick out aspects for the list.
>>>>

Cheers,
nick
--- Lesiecki Nicholas <ndlesiecki@xxxxxxxxx> wrote:
> Hi Erik,
> 
> Thanks for detailed response. I actually wrote the tests partly to
> confirm
> my understanding of the effects of placing unqualified supertypes in
> dominates (precedence) lists (the syntax is changing to "declare
> precedence" right?). It looks like my understanding was a little off. 
> 
> The general rule then seems to be that if I put a type which is not a
> concrete aspect into the precedence list, it will have no effect, yes?
> (even if aspect types implement/extend it).
> 
> In that case it would be nice to add tests such that the current behavior
> is verified. i.e. 
> 
>      declare dominates : Super, Unrelated, *;
>      declare dominates : Sub1, Sub2;
> 
> combined with:
> 
>      public void testSubaspects(){
>          driver.bar();
>          driver.assertLog("Sub1Sub2Unrelatedbar");
>      }
> 
> (correctly) yeilds: 
> 
>      UnrelatedSub1Sub2bar
> 
> shall I add them and resend, or would you like to add them?
> 
> > Even with plussing the marker, though, note that a legal
> > order is
> > 
> >     Implementor2
> >     Implementor1
> >     NonImplementor
> > 
> > since Implementer1 and Implementer2 are unrelated by subtype.
> 
> Yep, that's just my error. Thanks for catching it.
> 
> Would the situation change if Super was an (abstract) aspect?
> 
> A final thought:
> 
> I believe that this sort of issue is important to document since the use
> of
> TypePatterns sometimes result in subtype matching behavior which *feels*
> inconsistent (even if there are good reasons). An example from other
> areas:
> 
> target(Super)
> 
> would match Sub1 and Sub2.
> 
> call(void Super.xxx())
> 
> would not match Sub1.xxx()
> 
> Again, I understand these differences, I'm just eager to see these
> subtleties make it into the documentation (at some point).
> 
> Thanks again,
> nick
> --- hilsdale@xxxxxxxx wrote:
> > Hi, Nicholas,
> > 
> > These are cool dominates tests.  Currently when I run these
> > tests with the CVS code I'm getting two errors that I
> > believe are errors in the test.  I wanted to talk about these
> > (since that's what the dev list is for *smile*).
> > 
> > First, you have:
> > 
> >     declare dominates : Super, Unrelated, *;
> >     declare dominates : Sub1, Sub2;
> > 
> > with the test
> > 
> >     public void testSubaspects(){
> >         driver.bar();
> >         driver.assertLog("Sub1Sub2Unrelatedbar");
> >     }
> > 
> > Currently, in the CVS compiler, this fails, since the log
> > comes out as
> > 
> >     UnrelatedSub1Sub2bar
> > 
> > I believe this is an allowable order from the dominates
> > constraints.  However, if you instead write
> > 
> >     declare dominates : Super+, Unrelated, *;
> >     declare dominates : Sub1, Sub2;
> > 
> > (note the "and subtypes" operator in the first declaration)
> > then your order is used.  This is the version I'm planning
> > to check into the tests.
> > 
> > A similar difference shows up with the Marker interface
> > test, where you test for
> > 
> >     public void testInterfaces(){
> >         driver.qux();
> >         driver.assertLog("Implementor1Implementor2NonImplementorqux");
> >     }
> > 
> > Even with plussing the marker, though, note that a legal
> > order is
> > 
> >     Implementor2
> >     Implementor1
> >     NonImplementor
> > 
> > since Implementer1 and Implementer2 are unrelated by subtype.
> > 
> > I've appended below my signature a condensed test case with
> > only these two tests (with a couple of extra plusses and a
> > new constraint betweeen Implementor2 and Implementor1 to
> > make the asserts happy).
> > 
> > -erik
> > 
> > import junit.framework.Assert;
> > import junit.framework.Test;
> > import junit.framework.TestCase;
> > import junit.framework.TestSuite;
> > import junit.textui.TestRunner;
> > 
> > public class PrecedenceTest extends TestCase {
> >     private PrecedenceDriver driver;
> > 
> >     public PrecedenceTest(String arg0) {
> >         super(arg0);
> >     }
> > 
> >     protected void setUp() throws Exception {
> >         super.setUp();
> >         driver = new PrecedenceDriver();
> >     }
> > 
> >     public void testSubaspects(){
> >         driver.bar();
> >         driver.assertLog("Sub1Sub2Unrelatedbar");
> >     }
> > 
> >     public void testInterfaces(){
> >         driver.qux();
> >         driver.assertLog("Implementor1Implementor2NonImplementorqux");
> >     }
> > 
> >     public static void main(String[] args) {
> >         Test suite = new TestSuite(PrecedenceTest.class);
> >         TestRunner.run(suite);
> >     }
> > }
> > 
> > 
> > class PrecedenceDriver extends Assert {
> >     private StringBuffer _log = new StringBuffer();
> >     public void bar(){
> >         log("bar");
> >     }
> >     public void qux(){
> >         log("qux");
> >     }
> >     public void log(String s){
> >         _log.append(s);
> >     }
> >     public void assertLog(String comparison){
> >         assertEquals(comparison, _log.toString());
> >     }
> > }
> > 
> > 
> > aspect Coordinator {
> > 
> >     pointcut bar(PrecedenceDriver driver) :
> >         call(void bar()) && target(driver);
> >     declare dominates : Super+, Unrelated, *;
> >     declare dominates : Sub1, Sub2;
> > 
> >     pointcut qux(PrecedenceDriver driver) :
> >         call(void qux()) && target(driver);
> >     declare dominates : Marker+, NonImplementor, *;
> >     declare dominates : Implementor1, Implementor2;
> > }
> > 
> > class Super{}
> > 
> > aspect Sub1 extends Super{
> >     before(PrecedenceDriver d) : Coordinator.bar(d){
> >         d.log("Sub1");
> >     }
> > }
> > 
> > aspect Sub2 extends Super{
> >     before(PrecedenceDriver d) : Coordinator.bar(d){
> >         d.log("Sub2");
> >     }
> 
=== message truncated ===


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


Back to the top