简体   繁体   English

初始化块上的注释???? 是否静态

[英]Annotations on an initialization block???? static or not

I was just coding a Stripes action bean, starting with an annotated method. 我只是从带注释的方法开始编写Stripes操作bean。

By mistake i wrote: 我写错了:

@After(stages = LifecycleStage.ActionBeanResolution) {
    // code here
}

The compiler is OK 编译器还可以

So it seems we can put annotations on static and nonstatic init blocks 所以看来我们可以在静态和非静态初始化块上添加注释

@After(stages = LifecycleStage.ActionBeanResolution) 
{
    // code here
}

@After(stages = LifecycleStage.ActionBeanResolution) 
static {
    // code here
}

Do you have any usecase idea of such a strange thing? 您对这种奇怪的事情有用例的想法吗?

抱歉,这是我的问题,它无法编译

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM