Brought to you by EarthWeb
ITKnowledge Logo Login Graphic Click Here!
Click Here!
ITKnowledge
Find:
 
EXPERT SEARCH ----- nav

EarthWeb Direct

EarthWeb sites: other sites

Previous Table of Contents Next


FUD (fear, uncertainty, and doubt)

There is a certain amount of fear, uncertainty, and doubt about using undocumented Java classes. Is it safe? To borrow terminology from AIDS educators, there’s no such thing as safe or unsafe Java. All Java programs are safe or less safe with varying degrees of safety. Naturally you should always strive to have safer Java.

First of all, remember that Java has more built-in safeguards than almost any other language. A Java program is not going to work today and crash your system tomorrow. Further, as long as users don’t change their Java environments, the programs that run today should still run tomorrow.

Java will change. Methods that work today may not be present in future releases. Worse yet, they may be changed in future releases. Early adopters have already been through several gut-wrenching transitions — worst of all the transition from alpha to beta — and they survived. Time simply needs to be allotted for code to be rewritten.

There are many ways to guard against these problems. Java’s robust exception-handling mechanism provides an easy means to deal with classes or methods that unexpectedly disappear between versions of Java. Code from the sun classes can be copied into your own package or placed on your server so that it’s guaranteed to be available to an applet. Native methods can be backed up by Java-only alternatives that are invoked if the native methods can’t be found. Versions can be checked to make sure an application is running in a known environment.

However, that’s all in the future. Today, the programs that you write with the Sun classes and native code are safe. You should of course try to use garden-variety, safe Java whenever possible, but don’t not write the next killer application simply because it requires you to use a native method or to instantiate a sun class.

How secret is this, anyway?

Some people have questioned whether the title Java SECRETS is truly appropriate for this book. Certainly a lot of the material here is less secret than the internals of Microsoft Windows. Sun licenses the source code very freely (at least the code prior to Java 1.1), and, as you’ll learn, the byte code is comparatively trivial to disassemble.

Source code may be a precise form of documentation, but it is hardly the easiest form to understand. Java source code has been available since the earliest days, but it’s still left many people confused about exactly how to accomplish their goals. The content of this book may not exactly be secret, but it certainly contains information that is not widely known. Frankly, given the quality of information about these topics that is available, many of them might as well be secret. I expect this book to generate a phenomenal level of interest among Java programmers, most of whom have only a vague idea that this sort of programming is possible in Java, much less the knowledge to do it.

Summary

In this chapter, you learn about the following:

  A deeper understanding of how the Java runtime operates helps you write better programs, even if you don’t use that knowledge explicitly in your source code.
  The sun packages are a group of classes included in Sun’s JDK and many other Java implementations that provide extra capabilities to Java programs. They also support much of the Java infrastructure that applet programmers don’t always need to think about.
  Native methods may not be pleasant, but they are often necessary. If you want to write classic, stand-alone applications in Java that can compete with applications written in C and C++ in both speed and features, you will need to use native methods.
  The techniques described in this book are powerful tools, but they are also more than a little dangerous. Using them naïvely can and will produce unintended consequences. But with proper forethought and planning, you can prepare for these problems and avoid them.


Previous Table of Contents Next
HomeAbout UsSearchSubscribeAdvertising InfoContact UsFAQs
Use of this site is subject to certain Terms & Conditions.
Copyright (c) 1996-1999 EarthWeb Inc. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.