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

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 ...

    Irresistible.APIs.Designing.web.APIs.that.developers.will.love

    Designing Web APIs based on use cases allows an organization to develop irresistible APIs, which developers can consume easily and which support the business values of that organization. Purchase of...

    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 ...

    The internet of things

    there is an even greater need for this book,which explains the technology, the internetworking, and applications that are making IoT an everyday reality., The book begins with a discussion of IoT '...

    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.

    Java™ Servlet Specification

    We emphasize that this specification is not a user’s guide for servlet developers and is not intended to be used as such. References useful for this purpose are available from ...

    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 ...

    7 Rules Of Writing Good Code

    Good code — it’s a debatable mystery that plagues developers from all programming languages. It is often highly opinionated, vague, and at times conflicting. We all know we should write good code...

    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 ...

    塞班60 PYTHON API

    塞班60 PYTHON API ...This guide is intended for developers looking to create programs that use the native features and resources of the S60 phones. The reader should be familiar with the Python

    Cryptography for Developers_fordevelopers_cryptography_

    Cryprography for Developers

    Pro Node.js for Developers_1st ed. Edition

    You’ll learn how to create easily reusable modules that will save you time through code reuse, to log and debug your applications quickly and effectively and to write code that will scale easily and...

Global site tag (gtag.js) - Google Analytics