【问题标题】:Why does aspect wants return type int?为什么方面想要返回类型 int?
【发布时间】:2023-04-07 01:37:01
【问题描述】:

以下方面给我一个“这个方法必须返回一个int的结果类型”

package CH.ifa.draw.framework;

public aspect Trace {

     after() returning (ConnectionFigure figure): call(*.new(..)) {
         System.out.println("test");
     }
}

我期望 void 作为结果类型。

更新

我希望每次创建一个实现 de ConnectionFigure 接口的类时都会调用这个切入点

更新 2

package CH.ifa.draw.framework;

public aspect Trace {

     after(): call(ConnectionFigure+.new(..)) {
         System.out.println("trace creation figure");
     }
}

【问题讨论】:

    标签: eclipse aspectj


    【解决方案1】:

    您的方面建议不正确,或者至少不完整。 returning (ConnectionFigure figure) 应该给你一个错误,因为参数在切入点表达式中是未绑定的。尝试删除该组件并查看它是否适合您。

    【讨论】:

    • 清理项目后,它工作正常。看看我的编辑
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-16
    相关资源
    最近更新 更多