Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
This section tells you how to convert programs that use deprecated API. This section does not tell you how to use the JDK's new features unless a new feature's API replaces deprecated API. For example, this section doesn't discuss substituting RMI for your existing networking code, since the original networking code is still valid. However, this section does tell you how to update to the new AWT event system, since the API for the old AWT event system is deprecated.This section has four subsections:
- General Instructions
Provides step-by-step instructions on how to convert your programs.- Special Coding Techniques
Describes a couple of techniques for writing code that works in both 1.0 and 1.1.- How to Convert Code that Uses I/O
Shows you how to convert code that uses deprecated API injava.io
.- How to Convert Code that Uses the AWT
Gives detailed directions on converting programs that have a GUI.
.java
files)
and the Java bytecodes
(.class
files).
You'll need the copy until all the Java runtime systems
the program might execute
in have been converted to 1.1 or a later release.
Here's an example of saving a copy of a program on a UNIX system:
% cp MyClass.java MyClass.java.orig % cp MyClass.class MyClass.class.orig
% javac -deprecation MyClass.java
If your program calls or overrides any deprecated methods, the compiler displays a warning. For example:
MyClass.java:18: Note: The method boolean handleEvent( java.awt.Event) in class java.awt.Component has been deprecated, and class MyClass overrides it. public boolean handleEvent(Event event) { ^ MyClass.java:26: Note: The method boolean handleEvent( java.awt.Event) in class java.awt.Component has been deprecated. return super.handleEvent(event); ^ Note: MyClass.java uses a deprecated API. Please consult the documentation for a better alternative. 2 warnings
Note: The original JDK 1.1 compiler warns you only when a program calls a deprecated method, not when it overrides it. Starting with 1.1.1, the Java compiler warns you of both overridden and called deprecated methods.
java.io
API.
java.lang
,
java.net
, and
java.util
,
for programs that use deprecated API in the remaining 1.0 packages.
(Note that java.applet
contains
no deprecated methods or classes.)
If your program doesn't work the way you expected it to, then you have probably either implemented a new feature incorrectly or encountered an incompatible change. See the relevant section in this tutorial for help implementing any new features. See JDK 1.1 Compatibility for a list of incompatible changes between 1.0 and 1.1.
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved.