转载:Why Developers Should Not Write Programs That Call 'sun' Packages

The java.*, javax.* and org.* packages documented in the Java Platform Standard Edition API Specification make up the official, supported, public interface. 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.

The sun.* packages are not part of the supported, public interface. 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.
Each company that implements the Java platform will do so in their own private way. The classes in sun.* are present in the JDK to support Oracle‘s implementation of the Java platform: the sun.* classes are what make the Java platform classes work "under the covers" for Oracle‘s JDK. These classes will not 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 will have lost a major advantage of developing in Java.
Technically, nothing prevents your program from calling into sun.* by name. From one release to another, these classes may be removed, or they may be moved from one package to another, and it‘s fairly likely that their interface (method names and signatures) will change. (From Oracle‘s point of view, since we are committed to maintaining the Java platform, we need to be able to change sun.* to refine and enhance the platform.) In this case, even if you are willing to run only on Oracle‘s implementation, you run the risk of a new version of the implementation breaking your program.
In general, writing java programs that rely on sun.* is risky: those classes are not portable, and are not supported.

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

转载:Why Developers Should Not Write Programs That Call 'sun' Packages

时间: 2024-11-05 01:01:58

转载:Why Developers Should Not Write Programs That Call 'sun' Packages的相关文章

[Maven]package com.sun.image.codec.jpeg does not exist

----------------------------------------------------------------- 原创博文,如需转载请注明出处! 博主:疲惫的豆豆 链接:http://www.cnblogs.com/dzblog/p/6971245.html ---------------------------------------------------------------- 环境 Maven:3.0.5 Java:1.8.0_45 OS:Linux 问题 拿到一个j

从JDK 1.7开始,java程序员不能够调用JDK系统包中以sun开头的类

从JDK 1.7开始,Oracle未将以sun开头的类包加载到JVM启动加载的类包中.所以,像 JPEGImageEncoder这样的类不能够默认使用.如果非要使用sun开头包中的类,只能够直接将源码复制到自己的项目中或者将rt.jar 放到项目的类路径下(不推荐此种做法).下面是Oracle官方声明,连接http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html. <strong>Why Developers Sho

Java加密解密(二) Base64编码

1. Base64的由来 Base64最早用于解决电子邮件传输问题.由于"历史问题",早期的电子邮件网关只允许传输ASCII(二进制为00000000-01111111)字符,如果有非ASCII字符经过这种网关时, 字符的二进制位可能会被篡改(如将10000001改为00000001).由此产生了Base64编码来保证非ASCII字符的传输. 2. 原理 Base64顾名思义是一种基于64个字符的编码算法.如下是Base64的字符映射表,详情参见RFC 2045 Value Encod

Python著名的lib和开发框架(均为转载)

第一,https://github.com/vinta/awesome-python Awesome Python A curated list of awesome Python frameworks, libraries, software and resources. Inspired by awesome-php. Awesome Python Admin Panels Algorithms and Design Patterns Anti-spam Asset Management A

且看如何以精致的方式展现,解析和分析GitHub上语言的发展趋势

GitHut网站原文连接:http://githut.info/,其实这是一个非常简单的只有一个页面的网站.做的事情就是去通过GitHub Archive来获取到GitHub代码仓库的大数据然后进行分析,并把Github上用到的各种语言的信息整理出来并呈现给大家. GITHUT GitHut is an attempt to visualize and explore the complexity of the universe of programming languages used acr

Object-Oriented Analysis and Design Using UML 翻译与学习 (目录)

Object-Oriented Analysis and Design Using UML 面向对象分析与使用UML设计 最近找了本书<Object-Oriented Analysis and Design Using UML>,这个书是Oracle培训里面的,同时也是获取scjd和scja可选的课程. 所以,我准备一边翻译,一边学习.嗯,只翻译重点. 转载请注明出处!!! Copyright 2010 Sun Microsystems, Inc., 4150 Network Circle,

Why Go? – Key advantages you may have overlooked

Why Go? – Key advantages you may have overlooked yourbasic.org/golang Go makes it easier (than Java or Python) to write correct, clear and efficient code. Minimalism Features for the future Code transparency Compatibility Performance Choosing a progr

我你就报报我好

http://www.tudou.com/programs/view/gws5_W9LBOY/e0878.htmlhttp://www.tudou.com/programs/view/svb2E3asrwo/j8744.htmlhttp://www.tudou.com/programs/view/iZs6vuetaJM/d542n.htmlhttp://www.tudou.com/programs/view/l2tsMkkhuzU/5FSAS.htmlhttp://www.tudou.com/p

Windows环境下ARM集成开发环境的搭建与使用

Windows环境下能够使用Eclipse IDE for C/C++ Developers来搭建ARM开发环境 本文地址:http://blog.csdn.net/u011833609/article/details/30290655 安装过程例如以下: 1. 安装Java SE 网址:http://www.oracle.com/technetwork/java/javase/downloads/jre-7u3-download-1501631.html 下载这个文件:jre-7u3-wind