开发者

What is the static keyword for in annotation class "public static @interface"?

I found a strange annotation:

public static @interface WebResult { }

Why is 开发者_Go百科static there? How do they compile it? My IDE does not allow such modifier there!

The class this is contained in is javax.jws.WebResult.


It's valid (but not required) when it's nested inside another class:

public class Foo {   
    public static @interface Bar {
    }    
}

From the Java language specification section 8.5.2:

Member interfaces are always implicitly static. It is permitted but not required for the declaration of a member interface to explicitly list the static modifier.

If you've seen it on a top-level class, please show where you've found it like that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜