Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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.

Back to the top