Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Anonymous classes unaware of introductions into abstract classes

Matthew,

Perhaps I miss something, but I doubt it is the
"declare parents" statement. AbstractClassA implements
InterfaceA already - the "declare parents" does not
add anything new, imo. Moreover, the introduction
works for the concrete, named class (ConcreteClassA),
which extends AbstractClassA (note: the previous
version of the compiler reported errors for the
concrete class, too. The version 1.2 works fine.).
Thus, it's only the anonymous class that is unaware of
introduction.

BTW: does your aspect solution work for you?


Marius


--- Matthew Webster <matthew_webster@xxxxxxxxxx>
wrote:

> 
> 
> 
> 
> Marius,
> 
> You are missing something. Although you have an
> inter-type declared method
> for "a2()" on AbstractClassA the statement
> "AbstractClassA is a InterfaceA"
> is not true hence the compiler error:
> 
>       Type mismatch: cannot convert from <anonymous
> subclass of
> AbstractClassA> to InterfaceA
> 
> You also need a declare parents statement:
> 
> public aspect IntroAspectA {
> 
>       declare parents : AbstractClassA implements
> InterfaceA;
> 
>       public void AbstractClassA.a2() {
>             System.out.println("AbstractClassA.a2()
> from IntroAspectA");
>       }
> }
> 
> Matthew Webster
> AOSD Project
> Java Technology Centre, MP146
> IBM Hursley Park, Winchester,  SO21 2JN, England
> Telephone: +44 196 2816139 (external) 246139
> (internal)
> Email: Matthew Webster/UK/IBM @ IBMGB,
> matthew_webster@xxxxxxxxxx
> http://w3.hursley.ibm.com/~websterm/
> 
> 
> "Marius M." <marin_marius@xxxxxxxxx>@eclipse.org on
> 07/10/2004 13:21:06
> 
> Please respond to aspectj-users@xxxxxxxxxxx
> 
> Sent by:    aspectj-users-admin@xxxxxxxxxxx
> 
> 
> To:    aspectj-users@xxxxxxxxxxx
> cc:
> Subject:    [aspectj-users] Anonymous classes
> unaware of introductions into
>        abstract classes
> 
> 
> Hello,
> 
> 
>  I couldn't find this problem reported as a bug, but
> I think it is a
>  compiler bug. It seems that anonymous classes are
> not able to "see" the
>  methods introduced by aspects into abstract
> classes.
> 
> 
>  Apparently, the previous version of the ajc
> compiler had this problem for
>  concrete classes as well, but it was fixed in
> aspectj 1.2. Yet, it doesn't
>  work for anonymous classes:
> 
> 
> 
> 
> 
>  interface InterfaceA {
> 
> 
>   public void a1();
> 
>   public void a2();
> 
>  }
> 
> 
>  abstract class AbstractClassA implements InterfaceA
> {
> 
> 
>   public void a1() {
>    System.out.println("AbstractClassA.a()");
>   }
> 
>  }
> 
> 
> 
>  public class ConcreteClassA extends AbstractClassA
> {
> 
> 
>   public void someMethod() {
>    InterfaceA a = new AbstractClassA() {
>    };
>   }
> 
>  }
> 
> 
>  aspect IntroAspectA {
> 
> 
>   public void AbstractClassA.a2() {
>    System.out.println("AbstractClassA.a2() from
> IntroAspectA");
>   }
>  }
> 
> 
> 
> 
> 
>  The compiler will complain about the anonymous
> class as not having
>  implemented the method a2(). However, it will work
> if the AbstractClassA
>  is not abstract (or if the class is not anonymous
> :-)).
> 
> 
> 
> 
> 
>  Thanks,
> 
> 
>  Marius M.
> 
> 
> 
> 
> 
> Do you Yahoo!?
> Take Yahoo! Mail with you! Get it on your mobile
> phone.
> 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
>
http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 



		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com


Back to the top