不使用 com.sun.xml.internal.*? [英] do not use com.sun.xml.internal.*?

查看:22
本文介绍了不使用 com.sun.xml.internal.*?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个说法是否正确:

com.sun.xml.internal 包顾名思义就是一个内部包.用户不应编写依赖于内部 JDK 实现类的代码.这些类是 JDK 的内部实现细节,如有更改,恕不另行通知

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 的回答说这是编译器的预期行为,因为用户不应使用该包.

One of my colleagues used one of the classes in his code, which caused javac task in Ant fail to compile our project as the compiler couldn't find the class. Answer from Sun/Oracle says that this is expected behavior of the compiler as user shouldn't use the package.

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

Question is why the classes in the package made public in the first place?

谢谢,

莎拉

推荐答案

JDK 中的 Sun 类以 sun.* 为前缀,并且不是公共支持接口的一部分,因此应谨慎使用.来自 Sun 常见问题解答:

Sun classes in the JDK are prefixed sun.* and are not part of the public supported interface so should be used with care. From the Sun FAQ:

Sun 包含的类Java 2 SDK,标准版,秋季到包组 java., javax.,org.* 和 sun.. 除了太阳.包是标准的一部分Java平台,将被支持到未来.一般来说,包比如太阳,在外面Java 平台,可以不同操作系统平台(Solaris、Windows、Linux、Macintosh 等)并且可以随时更改SDK 版本时间,恕不另行通知(1.2、1.2.1、1.2.3 等).程式包含对太阳的直接调用.包不是 100% 纯 Java.在换句话说:

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:

java., javax.和 org.* 包记录在 Java 2 平台中标准版 API 规范补官,支持,公共接口.

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

如果一个Java程序只直接调用这些包中的API,它会运行在所有与 Java 兼容的平台上,无论底层操作系统如何平台.

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.

sun.* 包不属于支持,公共接口.

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

一个直接调用的Java程序进入阳光.* 不保证包处理所有与 Java 兼容的平台.事实上,这样的程序是即使将来也不能保证工作同一平台上的版本.

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.

这篇关于不使用 com.sun.xml.internal.*?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆