How Marker Interface is handled by JVM

后端 未结 7 674
清歌不尽
清歌不尽 2020-12-09 23:07

Marker interface doesn\'t has any thing. It contains only interface declarations, then how it is handled by the JVM for the classes which implements this marker interface?

7条回答
  •  执笔经年
    2020-12-09 23:36

    The marker interface helps identify that whether the object under inspection is actually a type (implemented interface) we are interested in. However it is not different than the other interfaces (except that they don't have any behavior obligation)

    For example, the ObjectOutputStream can find that if a class implements Serializable, then the user has explicitly shown his consent that the object can be serialized.

提交回复
热议问题