简体   繁体   中英

Annotations on an initialization block???? static or not

I was just coding a Stripes action bean, starting with an annotated method.

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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