BT

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

Bookmarks

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

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.