当方面在界面之外时,AspectJ不编织界面

时间:2017-07-25 13:16:43

标签: java aspectj

当我通过内部静态方面实现接口时Impl

public interface EventSpaceSupplement {
    String getEventSpace();
    EventSpaceSupplement setEventSpace(String name);
            ...
    static aspect Impl {
        private String EventSpaceSupplement.eventSpace;
        public String EventSpaceSupplement.getEventSpace() {
             return this.eventSpace;
        }
        public EventSpaceSupplement setEventSpace(String EventSpaceName) {
             this.baseSetEventSpace(EventSpaceName);
             return this;
        }
        public EventSpaceSupplement baseSetEventSpace(String EventSpaceName) 
        {
            this.eventSpace = EventSpaceName;
            this.eventManager = EventManager.getEventListenerForMe(this.getEventSpace(), this);
            return this;
         }        ...
    }

}

它工作正常。所有文件都正确编织。 但它并不起作用我试图将方面和界面分成两个文件:

public aspect EventSpaceSupplimentA {
    private String EventSpaceSupplement.eventSpace;
    public String EventSpaceSupplement.getEventSpace() {
        return this.eventSpace;
     }
    public EventSpaceSupplement setEventSpace(String EventSpaceName) {
        this.baseSetEventSpace(EventSpaceName);
    return this;
    }
    public EventSpaceSupplement baseSetEventSpace(String EventSpaceName) {
       this.eventSpace = EventSpaceName;
       this.eventManager = EventManager.getEventListenerForMe(this.getEventSpace(), this);
        return this;
}
    ...
}

public interface EventSpaceSupplement {
    String getEventSpace();
    EventSpaceSupplement setEventSpace(String name);
}

班级没有编织:

public class TestClass extends Timplements EventSpaceSupplement {
    @Override
    public EventSpaceSupplement setEventSpace(String eventSpaceName) {
        this.baseSetEventSpace(eventSpaceName);
        ...
        return this;
    }
}

Idea在两种情况下看起来都很好,它通过ctl +左键单击导航。但是类没有编织而且是ajc编译错误。 enter image description here

1 个答案:

答案 0 :(得分:0)

问题解决了神奇的手鼓。 我正在添加java默认实现存根。例如:

public interface EventSpaceSupplement {
    default String getEventSpace(){return null;}
}

重建。 EventSpaceSupplimentA导致compilaion覆盖错误。但然后我删除了默认实现。

代码完全相同。但在那之后,操纵方面莫名其妙地开始被编织。