Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Re: declare parents and inheritance

This is getting weirder and weirder. Run from the console it works. So it seems, something wrong with the IDE. But I really don't have the slightest idea what may be wrong. Any ideas?

./alex
--
.w( the_mindstorm )p.


On 3/15/06, Alexandru Popescu <the.mindstorm.mailinglist@xxxxxxxxx> wrote:
The following tests are failing with the last AJDT build:

public class DeclareParentsTestCase extends TestCase {
    protected Parent m_parent;
    protected ChildA m_childA;
    protected ChildB m_childB;
   
   
    protected void setUp() throws Exception {
        super.setUp();
        m_parent= new Parent();
        m_childA= new ChildA();
        m_childB= new ChildB();
    }


    public void testParent() {
        assertTrue("expected inheritance", (m_parent instanceof IInterfaceA));
        assertTrue("expected inheritance", (m_parent instanceof IInterfaceB));
    }
   
    public void testChildA() {
        assertTrue("expected inheritance", (m_childA instanceof IInterfaceA));
        assertTrue("expected inheritance", (m_childA instanceof IInterfaceB));
    }
   
    public void testChildB() {
        assertTrue("expected inheritance", (m_childB instanceof IInterfaceA));
        assertTrue("expected inheritance", (m_childB instanceof IInterfaceB));
    }
}

public class Parent {}

public class ChildA extends Parent {}

public class ChildB extends Parent {}

public interface IInterfaceA {}

public interface IInterfaceB {}

public aspect DeclareParents {
    declare parents: Parent implements IInterfaceA;

    declare parents: Parent+ implements IInterfaceB;
}

This is very very weird. The gutter shows that Parent class implements both IInterfaceA, IInterfaceB. What is going on? :-S.

./alex
--
.w( the_mindstorm )p.


On 3/15/06, Ron Bodkin < rbodkin@xxxxxxxxxxxxxx> wrote:

It works for me. Maybe you aren't weaving into Parents and/or Child?

 

public aspect DeclareParents {

    declare parents: Parent implements IInterface;

 

    private boolean IInterface.isInterface() {

        return true;

    }

 

    public static void main(String args[]) {

        System.out.println(new Child().isInterface());

    }

}

 

interface IInterface {}

class Parent {}

class Child extends Parent {}

 

C:\devel\scratch>ajc DeclareParents.aj

 

C:\devel\scratch>java DeclareParents

true

 


From: aspectj-users-bounces@xxxxxxxxxxx [mailto: aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Alexandru Popescu
Sent: Tuesday, March 14, 2006 5:28 PM
To: userAJ
Subject: [aspectj-users] Re: declare parents and inheritance

 

I have tried also with declare parents Parent+ implements IInterface, but no good result. I am definitely doing something wrong.

./alex
--
.w( the_mindstorm )p.

On 3/15/06, Alexandru Popescu <the.mindstorm.mailinglist@xxxxxxxxx> wrote:

Hi!

Maybe this is a stupid question, but at this moment I don't have a good answer for it (sorry 3am):

if Child extends Parent and declare parents Parent implements IInterface, isn't supposed to have the condition (Child instanceof IInterface) true? Or should I declare parents with:

declare parents Parent+ implements IInterface?

thanks and sorry for the "stupid" question,

./alex
--
.w( the_mindstorm )p.

 


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





Back to the top