Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Problem with interfaces in method's signature

I bumped into a compiler error when trying to make an privileged aspect call a method with a package-protected (default) access.

I was using j2sdk1.4.0_02, AspectJ 1.1, eclipse 2.1 (with AJDT 1.1.3).

I managed to isolate the problem into the following toy example, in which aspect concern.ContextUser tries to advise class core.Base. After a few experiments I got the impression that the error was triggered by the use of interfaces in the method's signature (notice the difference between the 2 package-protected methods from core.Base).

If you uncomment the call to base.packageprotected_interface(List) at the end of the advice the compiler complains that the method is not visible.

Is this an AspectJ bug, or am I missing something?

-----------------------------------------------------------------
package core;

import java.util.List;

public class Base {
   void packageprotected() {
      System.out.println("package-protected access.");
   }
   void packageprotected_interface(List list) {
      System.out.println("pack-protected access (interface)");     
   }
   public void trigger(Base argument) {
      System.out.println("doing something with " + argument);
   }
   public static void main(String[] args) {
      Base user = new Base();
      user.trigger(new Base());
   }
}
-----------------------------------------------------------------
package concern;

import java.util.ArrayList;
import core.Base;

public privileged aspect ContextUser {
   pointcut call2trigger(Base argument):
      execution(* core.Base.trigger(..))
      && args(argument);
   before(Base base): call2trigger(base) {
      System.out.println("Before trigger (" + base + ")");
      base.packageprotected();
      //base.packageprotected_interface(new ArrayList());
   }  
}
-----------------------------------------------------------------
Thanks,

--
Miguel J. T. Pessoa Monteiro
Ph.D. student Minho University, Portugal
eMail: mpm@xxxxxxxxxxx
URL: http://gec.di.uminho.pt/mpm/


Back to the top