gpt4 book ai didi

java - 使用 Java 8 中引入的 @Exported 注解标记的类型是否安全?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:05:26 26 4
gpt4 key购买 nike

Java 8 引入了 @Exported 注释,其文档说明如下:

Indicates whether or not a JDK specific type or package is an exported part of the JDK suitable for use outside of the JDK implementation itself.

什么是JDK 的导出部分?我应该使用标有此类注释的任何类型吗?它被认为是安全的吗?

例如,此注释出现在 com.sun.net.httpserver.HttpServer 类中。

最佳答案

参见 its javadoc :

Indicates whether or not a JDK specific type or package is an exported part of the JDK suitable for use outside of the JDK implementation itself. This annotation should only be applied to types and packages outside of the Java SE namespaces of java.* and javax.* packages. For example, certain portions of com.sun.* are official parts of the JDK meant to be generally usable while other portions of com.sun.* are not. This annotation type allows those portions to be easily and programmatically distinguished.

因此使用 JDK 提供的带有注释的类是安全的,但是您应该在您自己的类中使用该注释。

关于java - 使用 Java 8 中引入的 @Exported 注解标记的类型是否安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38609706/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com