Skip to main content

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

This is a great email/test case, which I built up and confirmed.
Would you care to submit a bug, listing test: tests/bugs/privilege?
Copying this email to the bug would probably be enough.

The compiler gives incorrect errors whenever it would have to
implement privilege for methods with any parameters:
(1) when accessing non-public methods from another package
(2) when accessing private methods from the same package

True also for static methods, but not for fields.  The parameter
type need not be an interface.  Since the problem seems so
widespread, there may be a cascade effect happening, where
one condition causes all such errors (I haven't found the
condition).

I'm very surprised this wasn't covered in our test suite,
and wasn't found before.  Perhaps that means users generally
follow our advice in not using privileged aspects.

In any case, thank you very much!
Wes


Mpm wrote:
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/

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



Back to the top