Hmmm, I had to fix up some of your sample code there as it doesn't actually
work as it is. (Is Go an annotation or an aspect - you've used it as
both...)

I changed it to this:
=== Foo.java
@Go
public class Foo {
  public void go() { System.out.println("go"); }
}
=== Go.java
import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME)
@interface Go {}
=== GoA.java
public aspect GoA {
  public interface I {}
  declare parents: (@Go *) implements I;
  public void I.go() { System.out.println("aspect-go"); }
}
=== TestFoo.java
public class TestFoo {
  public static void main(String []argv) {
   new Foo().go();
  } // throws AbstractMethodError
}

Compiles and runs fine for me:

> ajc -1.5 *.java -showWeaveInfo
Type 'GoA$I' (GoA.java) has intertyped method from 'GoA' (GoA.java:'void
GoA$I.go()')
Extending interface set for type 'Foo' (Foo.java) to include 'GoA$I'
(GoA.java)

> java TestFoo
go

As we discussed a little the other day. An ITD on an interface is
considered a 'default implementation' as the implementation a class will
get that implements the interface if it does not provide its own.

If your ITD had been directly on the class then you would have gotten a
clash error:
GoA.java:5 [error] inter-type declaration from GoA conflicts with existing
member: void Foo.go()
public void Foo.go() { System.out.println("aspect-go"); }
                ^^
Foo.java:5 [error] inter-type declaration from GoA conflicts with existing
member: void Foo.go()
public void go() { System.out.println("go"); }

If I could recreate your problem I could investigate...

cheers,
Andy








On 28 March 2013 18:09, Matthew Adams <matt...@matthewadams.me> wrote:

> Hi all,
>
> I want to make sure I haven't misunderstood AspectJ's treatment of the
> following scenario, as I'm getting an AbstractMethodError in 1.7.2.
> Conceptual code example follows.
>
> @Go
> public class Foo {
>   public void go() { System.out.println("go"); }
> }
> =====
> public aspect Go {
>   public interface I {}
>   declare parents: (@Go *) implements I;
>   public void I.go() { System.out.println("aspect-go"); }
> }
> =====
> public void TestFoo {
>   @Test
>   public void testGo() { new Foo().go(); } // throws AbstractMethodError
> }
>
> My current understanding is that AspectJ sees that the method "public void
> go()" is already defined on a class matching the "declare parents" clause
> and simply doesn't introduce the method from the aspect.  If that's
> correct,
> then I think I'm seeing a bug.
>
> I'm getting no compiler warnings or errors from ajc, leading me to believe
> that everything is hunky dorey, then I get an AbstractMethodError upon the
> call to go().
>
> Thanks,
> Matthew
>
>
>
>
> --
> View this message in context:
> http://aspectj.2085585.n4.nabble.com/AbstractMethodError-calling-method-defined-on-class-receiving-ITD-of-same-method-tp4650821.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to