简体   繁体   English

太阳之间的区别。* vs com.sun。*

[英]Difference between sun.* vs com.sun.*

I have recently migrated from Java 8 to Java 11. for jax.ws 我最近从Java 8迁移到Java 11. for jax.ws

I had to add following external dependency to my pom.xml as it's no longer available in Java 11. However, I came across some argument that com.sun.* package classes should not be used and should be avoided if possible. 我不得不在我的pom.xml添加以下外部依赖项,因为它在Java 11中不再可用。但是,我遇到了一些争论,即com.sun.*包类不应该被使用,如果可能的话应该避免。 So is it sun.* or com.sun.* ? sun.*com.sun.* If latter is true as well, what would be the best possible replacement for this? 如果后者也是如此,那么最好的替代品是什么呢?

One more thing, this dependency is not directly used by my code but it's referred by one of my other dependencies. 还有一件事,我的代码没有直接使用这种依赖,但是我的其他依赖项之一引用了它。

    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.2.10</version>
    </dependency>

Some com.sun.* classes are actual external API and may be used. 一些com.sun.*类是实际的外部API,可以使用。 The key is to check the official Javadoc to see if the classes you want to use are listed as API, and not marked @Deprecated or anything of that sort. 关键是检查官方Javadoc以查看您要使用的类是否列为API,并且未标记为@Deprecated或任何类似的类。

Here is the official javadoc page to check at: https://docs.oracle.com/en/java/javase/11/docs/api/index.html 以下是要查看的官方javadoc页面: https//docs.oracle.com/en/java/javase/11/docs/api/index.html

In general, sun.* API refers to some of the oldest Java APIs (such as sun.misc.Unsafe ) which predate the reverse-DNS package naming convention. 通常, sun.* API指的是一些最早的Java API(例如sun.misc.Unsafe ),这些API早于反向DNS包命名约定。 Most of the original sun.* APIs have either been removed, promoted to official javax.* API, or renamed to the more proper com.sun.* domain. 大多数原始sun.* API已被删除,升级为官方javax.* API,或重命名为更合适的com.sun.*域。

There is nothing inherently wrong with using com.sun.* APIs, provided the API is not a JDK internal or marked for deprecation/removal. 使用com.sun.* API没有任何内在错误,只要API不是JDK内部或标记为弃用/删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM