Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316639 - Privileged aspects can not import private/protected/default nested types
Summary: Privileged aspects can not import private/protected/default nested types
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.9   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-11 13:51 EDT by Kris De Volder CLA
Modified: 2010-06-11 13:51 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kris De Volder CLA 2010-06-11 13:51:17 EDT
Restricted (i.e. private, protected or package visible) nested types can be referred/used by ITDs in privileged aspects. Unfortunately, the imports section at the top of the .aj file is not considered part of the aspect, so while we are able to use/refer to them from the aspect by using fully qualified names, we can not import them into the aspect's compilation unit.

Technically, I guess this is an enhancement, not a bug, since the imports are not actually inside the aspect, so not "privileged". 

Nevertheless, it seems somewhat illogical to prohibit importing of types that can legitimately be used in the compilation unit. 

Example:

---- paspect/TestAspect.aj ---
package paspect;

import pclass.Klass;
import pclass.Klass.Default;           //  <-- Error (because of visibility)
import pclass.Klass.Protected;         //  <-- Error (because of visibility)
import pclass.Klass.Secret;            //  <-- Error (because of visibility)

public privileged aspect TestAspect {
    public void Klass.pullMe() {
        Secret s = null;               // <- Error (because import failed)
    	Protected p = null;            // <- Error (because import failed)
        Default d = null;              // <- Error (because import failed)
        System.out.println(""+s+p+d+prot+deflt+priv);
    }
}

---- pclass/Klass.java ---
package pclass;

public class Klass {
    private class Secret {}
    protected class Protected {}
    class Default {}
    private int priv;
    protected int prot;
    int deflt;
}