[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-dev] RE: [aspectj-users] More precedence
|
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");
}
}
aspect Unrelated {
before(PrecedenceDriver d) : Coordinator.bar(d){
d.log("Unrelated");
}
}
interface Marker{}
aspect Implementor1 implements Marker{
before(PrecedenceDriver d) : Coordinator.qux(d){
d.log("Implementor1");
}
}
interface SubMarker extends Marker{}
aspect Implementor2 implements SubMarker{
before(PrecedenceDriver d) : Coordinator.qux(d){
d.log("Implementor2");
}
}
aspect NonImplementor{
before(PrecedenceDriver d) : Coordinator.qux(d){
d.log("NonImplementor");
}
}
> -----Original Message-----
> From: Lesiecki Nicholas [mailto:ndlesiecki@xxxxxxxxx]
> Sent: Sunday, 5 January, 2003 8:52 pm
> To: Jim.Hugunin@xxxxxxxx; isberg@xxxxxxxx
> Cc: support@xxxxxxxxxxx
> Subject: RE: [aspectj-users] More precedence
>
>
> Wes and Jim,
>
> I thought of another test case. Given a marker interface Marker,
>
> declare precedence : Marker, *;
>
> should give aspects which implement Marker precedence over
> non-"Marked"
> aspects. It's really just a sub-case of the Super case I sent
> in, but I
> implemented it anyway.
>
> Cheers,
> Nick
>
> --- Jim.Hugunin@xxxxxxxx wrote:
> > This is a bug as Wes says. It's fixed in the current version of the
> > compiler in cvs. It was a simple matter of using the wrong
> API for type
> > pattern matching in the implementation of declare dominates.
> >
> > The test suite would benefit from a more extensive test
> than we currently
> > have for this precedence case. If Nick could turn his example into
> > something that would throw an exception if the precedence
> was wrong that
> > would be good.
> >
> > -Jim
> >
> > > -----Original Message-----
> > > From: isberg@xxxxxxxx [mailto:isberg@xxxxxxxx]
> > > Sent: Tuesday, December 31, 2002 9:36 AM
> > > To: ndlesiecki@xxxxxxxxx; aspectj-users@xxxxxxxxxxx
> > > Cc: support@xxxxxxxxxxx
> > > Subject: RE: [aspectj-users] More precedence
> > >
> > > It looks to me like
> > >
> > > declare dominates : Super+, ...
> > >
> > > is just broken now. Anyone care to submit a bug?
> > >
> > > Wes
> > > ------------- DominatesAdvice.java
> > >
> > > public class DominatesAdvice {
> > > public static void main (String[] args) {
> > > new C().run();
> > > }
> > > pointcut run() : target(C) && call(void run());
> > > static void log(String s) {
> > > System.out.println(""+s);
> > > }
> > > }
> > >
> > > class C { void run() {}}
> > > class Super {}
> > > aspect A extends Super {
> > > before () : DominatesAdvice.run() {
> > > DominatesAdvice.log("A");
> > > }
> > > }
> > > aspect B {
> > > before () : DominatesAdvice.run() {
> > > DominatesAdvice.log("B");
> > > }
> > >
> > > aspect Dominates {
> > > declare dominates : Super+, B; // BUG: produces B, A
> > > //declare dominates : A, B; // ok: produces A, B
> > > }
> > >
> > >
> > > > -----Original Message-----
> > > > From: Lesiecki Nicholas [mailto:ndlesiecki@xxxxxxxxx]
> > > > Sent: Tuesday, December 31, 2002 8:36 AM
> > > > To: isberg@xxxxxxxx; aspectj-users@xxxxxxxxxxx
> > > > Cc: support@xxxxxxxxxxx
> > > > Subject: RE: [aspectj-users] More precedence
> > > >
> > > >
> > > > Hello All,
> > > >
> > > > Sorry, my message got truncated. Unfortunately I've left the
> > > > sample code at
> > > > home.
> > > >
> > > > The upshot is that for:
> > > >
> > > > declare dominates : Security+, *;
> > > >
> > > > the precedence appears to be:
> > > >
> > > > Tracing
> > > > Notification
> > > > MoreSecurity
> > > > CustomSecurity
> > > > Security (abstract)
> > > > Security (a second time)
> > > > (JoinPoint)
> > > >
> > > > i.e. Security LAST.
> > > >
> > > > For:
> > > >
> > > > declare dominates : *Security*, *;
> > > >
> > > > The order is:
> > > >
> > > > MoreSecurity
> > > > CustomSecurity
> > > > Security (abstract)
> > > > Security (a second time)
> > > > Tracing
> > > > Notification
> > > > (JoinPoint)
> > > >
> > > > i.e. Security FIRST.
> > > >
> > > > Why should Security+ and *Security* produce different
> > > > results? They both
> > > > (should) select the same set of Concrete aspects
> (CustomSecurity and
> > > > MoreSecurity). Am I missing something?
> > > >
> > > > BTW, the sample code is ridiculously simple. Each aspect has
> > > > a single piece
> > > > of before advice that prints what it's doing to the console.
> > > > All of the
> > > > advice affects call(void doSomething()). The only
> > > > doSomething() method in
> > > > the compilation unit appears in SomeObject.
> > > >
> > > > SomeObject's main:
> > > > main(){
> > > > new SomeObject().doSomething();
> > > > }
> > > >
> > > > Cheers,
> > > > nick
> > > > --- isberg@xxxxxxxx wrote:
> > > > > Did the mailing list clip this question?
> > > > > Did you decide against it, after accidental send?
> > > > >
> > > > > (btw, thanks for the bugs)
> > > > >
> > > > > Wes
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Lesiecki Nicholas [mailto:
> > > > > > Sent: Monday, December 30, 2002 9:16 PM
> > > > > > To: aspectj-users@xxxxxxxxxxx
> > > > > > Subject: [aspectj-users] More precedence
> > > > > >
> > > > > >
> > > > > > Ok, I have several aspects that affect a single join point.
> > > > > > They all define
> > > > > > a single piece of before advice that prints a message about
> > > > > > what they're
> > > > > > doing.
> > > > > >
> > > > > > Aspects:
> > > > > >
> > > > > > Security (abstract)
> > > > > > |
> > > > > > --CustomSecurity
> > > > > > |
> > > > > > --MoreSecurity
> > > > > >
> > > > > > Tracing
> > > > > >
> > > > > > Notification
> > > > > >
> > > > > > I have the following declaration:
> > > > > >
> > > > > > declare dominates : Security+, *;
> > > > > >
> > > > > > __________________________________________________
> > > > > > Do you Yahoo!?
> > > > > > Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> > > > > > http://mailplus.yahoo.com
> > > > > > _______________________________________________
> > > > > > aspectj-users mailing list
> > > > > > aspectj-users@xxxxxxxxxxx
> > > > > > http://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > > > >
> > > >
> > > > __________________________________________________
> > > > Do you Yahoo!?
> > > > Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> > > > http://mailplus.yahoo.com
> > > >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/aspectj-users
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>