`
guanghuiqq
  • 浏览: 951 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

Why Developers Should Not Write Programs That Call 'sun' Packages

阅读更多
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.
分享到:
评论

相关推荐

    The Problem With Software: Why Smart Engineers Write Bad Code

    Is software development really hard, or are software developers just not that good at it? In The Problem with Software, Adam Barr examines the proliferation of bad software, explains what causes it, ...

    Reactive Programming with RxJava

    With this practical book, Java developers will first learn how to view problems in the reactive way, and then build programs that leverage the best features of this exciting new programming paradigm....

    Sun - The Java Developers Almanac 1.4.exe

    Sun - The Java Developers Almanac 1.4.exe

    Java.Threads.3rd.Edition(chm)

    Though the material presented in this book does not assume any prior knowledge of threads, it does assume that the reader has knowledge of other areas of the Java API and can write simple Java ...

    Lean Publishing Software Architecture for Developers(2014).rar

    Software Architecture for Developers is a practical and pragmatic guide to modern software architecture, specifically aimed at software developers. You'll learn: The essence of software ...

    Linux for Developers: Jumpstart Your Linux Programming Skills

    Write Bash scripts that interact with users or other shell features Program with Python and Perl: flow control, variables, and more Understand Linux features related to building C, C++, and Java ...

    R.Packages.1491910593

    Turn your R code into packages that others can easily download and use. This practical book shows you how to bundle reusable R functions, sample data, and documentation together by applying author ...

    AUTOSAR Training for Software Developers - 01-Why AUTOSAR-Part1.pdf

    AUTOSAR Training for Software Developers - 01-Why AUTOSAR-Part1.pdf

    Modular Programming with Python

    They should not only be able to understand the way modules help in improving development, but they should also be able to improvise on their techniques of writing concise and effective code.

    advanced oracle pl-sql

    Chapter 1, PL/SQL Packages describes how and when you should create packages and explains why PL/SQL developers should learn to center their entire development process around packages Chapter 2, Best...

    Python: Penetration Testing for Developers

    "Python: Penetration Testing for Developers" | 2016 English | ISBN-13: 9781787128187, ASIN: B01M5FAV4Q Unleash the power of Python scripting to execute effective and efficient penetration tests ...

    rubygems-update-3.1.3.gem

    We call these packages 'gems' and RubyGems is a tool to install, create, manage and load these packages in your Ruby environment. RubyGems is also a client for RubyGems.org, a public repository of ...

    Practical Quantum Computing for Developers

    Practical Quantum Computing for Developers: Programming Quantum Rigs in the Cloud using Python, Quantum Assembly Language and IBM QExperience By 作者: Vladimir Silva ISBN-10 书号: 1484242173 ISBN-13 ...

    Concurrency in Go: Tools and Techniques for Developers

    Concurrency in Go: Tools and Techniques for Developers by Katherine Cox-Buday English | 19 July 2017 | ISBN: 1491941197 | ASIN: B0742NH2SG | 240 Pages | AZW3 | 1.15 MB Concurrency can be notoriously...

    Oracle Core - Essential Internals for DBAs and Developers.(Jonathan Lewis)

    Oracle Core: Essential Internals for DBAs and Developers by Jonathan Lewis provides just the essential information about Oracle Database internals that every database administrator needs for ...

    Android代码-SugarLoader

    to duplicate calls, lose result on config changes, or deliver data to a view that is not concerned by the call. With loader API, on a fragment that needs one call to display data, developers can ...

Global site tag (gtag.js) - Google Analytics