Bug 155357

Summary: Pointcuts in Interfaces Should be Implicitly Public
Product: [Tools] AspectJ Reporter: Ron Bodkin <rbodkin+LISTS>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: NEW --- QA Contact:
Severity: minor    
Priority: P5 CC: aclement
Version: DEVELOPMENT   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Ron Bodkin CLA 2006-08-28 02:21:55 EDT
This fails on ajc 1.5.2 and a similar program failed on recent dev builds. Work-around: make the pointcut explicitly public.

Failing Program:
package sub;

public interface Interface {
    pointcut foo() : execution(* foo());
}

package user;

import sub.Interface;

public aspect Caller {
    before() : Interface.foo() {}
}

>ajc sub\Interface.java user\Caller.java
C:\devel\scratch\interfacePcd\user\Caller.java:7 [error] pointcut declaration po
intcut sub.Interface.foo() is not accessible
before() : Interface.foo() {}
           ^^^^^^^^^^

1 error
Comment 1 Wes Isberg CLA 2007-02-16 04:33:54 EST
The programming guide notes that methods defined on interfaces need not be public, so I'm not sure why pointcuts must be.
--------------------------------
Any intertype declaration of an abstract method on an interface must be specified as public, you will get a compile time error message indicating this is a compiler limitation if you do not specify public. A non-abstract method declared on an interface can use any access modifier except protected. Note that this is different to normal Java rules where all members declared in an interface are implicitly public.
---------------------------------