Can I use "Declare Parents" to make an interface be the parent of another interface?

View: New views
3 Messages — Rating Filter:   Alert me  

Can I use "Declare Parents" to make an interface be the parent of another interface?

by João Gonçalves-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Greetings.

Can I use @DeclareParents this way:


interface A { }

interface B { }

@DeclareParents(value="B", defaultImpl=BImpl.class)
private A something;

class C implements A { }




Will class C have the methods declared in B?

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

Re: Can I use "Declare Parents" to make an interface be the parent of another interface?

by Andy Clement :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Does this do what you want?


interface A { }

interface B { void foo();}

class BImpl implements B { public void foo() {System.out.println("foo
running");}}

@Aspect
class X {
       
        @DeclareMixin("C")
        public static B createB() {
                return new BImpl();
        }
               
        public static void main(String[] args) {
                ((B)new C()).foo();
        }
}

class C implements A { }


2009/9/1 João Gonçalves <jocolimonada@...>:

> Greetings.
>
> Can I use @DeclareParents this way:
>
>
> interface A { }
>
> interface B { }
>
> @DeclareParents(value="B", defaultImpl=BImpl.class)
> private A something;
>
> class C implements A { }
>
>
>
>
> Will class C have the methods declared in B?
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@...
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@...
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Re: Can I use "Declare Parents" to make an interface be the parent of another interface?

by João Gonçalves-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What I wanted to know was if declaring an implementation for an interface, automatically declared the implementation for the implementing classes. But the answer is no.
I've filed an enhancement request (as suggested by other users): https://bugs.eclipse.org/bugs/show_bug.cgi?id=288713
Thanks.

On Thu, Sep 3, 2009 at 5:40 PM, Andy Clement <andrew.clement@...> wrote:
Does this do what you want?


interface A { }

interface B { void foo();}

class BImpl implements B { public void foo() {System.out.println("foo
running");}}

@Aspect
class X {

       @DeclareMixin("C")
       public static B createB() {
               return new BImpl();
       }

       public static void main(String[] args) {
               ((B)new C()).foo();
       }
}

class C implements A { }


2009/9/1 João Gonçalves <jocolimonada@...>:
> Greetings.
>
> Can I use @DeclareParents this way:
>
>
> interface A { }
>
> interface B { }
>
> @DeclareParents(value="B", defaultImpl=BImpl.class)
> private A something;
>
> class C implements A { }
>
>
>
>
> Will class C have the methods declared in B?
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@...
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@...
https://dev.eclipse.org/mailman/listinfo/aspectj-users


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