Reprint: Why developers should not Write Programs that call ' Sun ' Packages

Source: Internet
Author: User

The java.*, javax.* and org.* packages documented in the Java Platform Standard Edition API specification make up the Offi Cial, supported, public interface. If a Java program directly calls only API in these packages, it'll operate on all java-compatible platforms, regardless of the underlying OS platform.

The sun.* packages is not part of the supported, public interface. A Java Program This directly calls into sun.* packages are not guaranteed to work on all java-compatible platforms. In fact, such a program was not guaranteed to work even in the future versions on the same platform.
Each company, that implements the Java platform would do so in their own private. The classes in sun.* is present in the JDK to support Oracle's implementation of the Java platform:the sun.* classes are What does the Java platform classes work "under the covers" for Oracle's JDK. These classes won't in general be present on another vendor ' s Java platform. If your Java program asks for a class ' Sun.package.Foo ' by name, it may fail with classnotfounderror, and you'll have the LO St A major advantage of developing in Java.
Technically, nothing prevents your program from calling to Sun.* by name. From one release to another, these classes is removed, or they may is moved from the one package to another, and it ' s fair Ly likely that their interface (method names and signatures) would change. (from Oracle's point of view, since we is committed to maintaining the Java platform, we need to is able to change sun.* To refine and enhance the platform.) In this case, even if is willing to run only on Oracle's implementation, you run the risk of a new version of the Imp Lementation breaking your program.
In general, writing Java programs This rely on sun.* was risky:those classes is not portable, and was not supported.

Http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html

Reprint: Why developers should not Write Programs that call ' Sun ' Packages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.