BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Removal of sun.misc.Sort and sun.misc.Compare in Java 8

Removal of sun.misc.Sort and sun.misc.Compare in Java 8

This item in japanese

Oracle is removing the sun.misc.Compare interface and sun.misc.Sort class in Java 8. These are old, residual classes that are no longer used within the JDK. sun.misc.Compare is an interface that allows you to compare two Objects and return an int. sun.misc.Sort is a class that takes in a sun.misc.Compare and sorts an Object array using the quicksort algorithm. The sun.misc package is internal to Sun/Oracle and should not be used as they are not publicly supported, and not portable across all JVMs.

These were initially proposed to be deprecated but are now being removed from the JDK after a consensus between the members of the OpenJDK Core Library Development mailing list. You can read the whole discussion from the Deprecate sun.misc.Sort and sun.misc.Compare thread. There is also JDK-6852936, a priority 4 bug in the Oracle JDK to remove unused classes from sun.misc.

Current users of sun.misc.Sort can use the sort() method of java.util.Arrays as better alternative. Users of sun.misc.Compare can use java.util.Comparator as a replacement.

As a side note, a new JDK command-line tool called jdeps is coming in Java 8. This is a tool that helps developers understand the static dependencies of their applications and libraries. This will also help identify the usage of non-standard and internal APIs, which is a complement to the warnings from the Java compiler. You can read more about this new tool from the Provide a command-line tool to find static dependencies thread.

For more information on why sun.* packages should not be used, read the official Oracle FAQ entry on the topic.

Rate this Article

Adoption
Style

BT