ant - 不要使用 com.sun.xml.internal.*?

标签 ant javac

这种说法是否属实:

com.sun.xml.internal package is an internal package as the name suggestes. Users should not write code that depends on internal JDK implementation classes. Such classes are internal implementation details of the JDK and subject to change without notice



我的一位同事在他的代码中使用了其中一个类,这导致 Ant 中的 javac 任务无法编译我们的项目,因为编译器找不到该类。 Sun/Oracle 的回答说这是编译器的预期行为,因为用户不应使用该包。

问题是为什么包中的类首先公开?

谢谢,

莎拉

最佳答案

JDK 中的 Sun 类以 sun.* 为前缀,并且不是公共(public)支持接口(interface)的一部分,因此应谨慎使用。来自 Sun FAQ :

The classes that Sun includes with the Java 2 SDK, Standard Edition, fall into package groups java., javax., org.* and sun.. All but the sun. packages are a standard part of the Java platform and will be supported into the future. In general, packages such as sun., that are outside of the Java platform, can be different across OS platforms (Solaris, Windows, Linux, Macintosh, etc.) and can change at any time without notice with SDK versions (1.2, 1.2.1, 1.2.3, etc). Programs that contain direct calls to the sun. packages are not 100% Pure Java. In other words:

The java., javax. and org.* packages documented in the Java 2 Platform Standard Edition API Specification make up the official, supported, public interface.

If a Java program directly calls only API in these packages, it will operate on all Java-compatible platforms, regardless of the underlying OS platform.

The sun.* packages are not part of the supported, public interface.

A Java program that directly calls into sun.* packages is not guaranteed to work on all Java-compatible platforms. In fact, such a program is not guaranteed to work even in future versions on the same platform.

关于ant - 不要使用 com.sun.xml.internal.*?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2863043/

相关文章:

java - 编译java类 ".class"ANT

eclipse - 将eclipse项目.classpath依赖项提取到ant脚本中

ruby - <echo> rakefile 中的 ant 任务是否等效?

java - ANT build.xml 删除目录任务不起作用

java - 如何运行已粘贴到我的程序中的 Java 代码

java - 为什么java编译器不提示这个:

java - 在 AnnotationProcessor 中访问 javac 选项

eclipse - 如何增加 Ant 'Javadoc' 任务的内存?

java - Ant -e 仅用于 java 任务

java - 如何使用 Ant 将 Classpath Jas 包含在 war 文件中