Deprecated API
Deprecated Classes
java.security.Identity
This class is no longer used. Its functionality has been
replaced by java.security.KeyStore, the
java.security.cert package, and
java.security.Principal.
java.io.LineNumberInputStream
This class incorrectly assumes that bytes adequately represent
characters. As of JDK 1.1, the preferred way to operate on
character streams is via the new character-stream classes, which
include a class for counting line numbers.
java.security.Signer
This class is no longer used. Its functionality has been
replaced by java.security.KeyStore, the
java.security.cert package, and
java.security.Principal.
java.io.StringBufferInputStream
This class does not properly convert characters into bytes. As
of JDK 1.1, the preferred way to create a stream from a
string is via the StringReader class.
Deprecated Fields
Deprecated Methods
java.net.URLDecoder.decode(String)
The resulting string may vary depending on the platform's
default encoding. Instead, use the decode(String,String) method
to specify the encoding.
java.net.URLEncoder.encode(String)
The resulting string may vary depending on the platform's
default encoding. Instead, use the encode(String,String)
method to specify the encoding.
java.security.Security.getAlgorithmProperty(String, String)
This method used to return the value of a proprietary
property in the master file of the "SUN" Cryptographic Service
Provider in order to determine how to parse algorithm-specific
parameters. Use the new provider-based and algorithm-independent
AlgorithmParameters and KeyFactory engine
classes (introduced in the Java 2 platform) instead.
java.lang.System.getenv(String)
The preferred way to extract system-dependent information
is the system properties of the
java.lang.System.getProperty methods and the
corresponding getTypeName methods of
the Boolean, Integer, and
Long primitive types. For example:
String classPath = System.getProperty("java.class.path",".");
if (Boolean.getBoolean("myapp.exper.mode"))
enableExpertCommands();
java.io.DataInputStream.readLine()
This method does not properly convert bytes to characters.
As of JDK 1.1, the preferred way to read lines of text is via the
BufferedReader.readLine() method. Programs that use the
DataInputStream class to read lines can be converted to use
the BufferedReader class by replacing code of the form:
DataInputStream d = new DataInputStream(in);
with:
BufferedReader d
= new BufferedReader(new InputStreamReader(in));
java.lang.Runtime.runFinalizersOnExit(boolean)
This method is inherently unsafe. It may result in
finalizers being called on live objects while other threads are
concurrently manipulating those objects, resulting in erratic
behavior or deadlock.
java.lang.System.runFinalizersOnExit(boolean)
This method is inherently unsafe. It may result in
finalizers being called on live objects while other threads are
concurrently manipulating those objects, resulting in erratic
behavior or deadlock.
java.util.Properties.save(OutputStream, String)
This method does not throw an IOException if an I/O error
occurs while saving the property list. As of the Java 2 platform v1.2, the preferred
way to save a properties list is via the store(OutputStream out,
String header) method.
java.net.URLStreamHandler.setURL(URL, String, String, int, String, String)
Use setURL(URL, String, String, int, String, String, String,
String);
java.lang.Thread.stop()
This method is inherently unsafe. Stopping a thread with
Thread.stop causes it to unlock all of the monitors that it
has locked (as a natural consequence of the unchecked
ThreadDeath exception propagating up the stack). If
any of the objects previously protected by these monitors were in
an inconsistent state, the damaged objects become visible to
other threads, potentially resulting in arbitrary behavior. Many
uses of stop should be replaced by code that simply
modifies some variable to indicate that the target thread should
stop running. The target thread should check this variable
regularly, and return from its run method in an orderly fashion
if the variable indicates that it is to stop running. If the
target thread waits for long periods (on a condition variable,
for example), the interrupt method should be used to
interrupt the wait.
For more information, see
Why
are Thread.stop, Thread.suspend and Thread.resume Deprecated?.
java.lang.Thread.suspend()
This method has been deprecated, as it is
inherently deadlock-prone. If the target thread holds a lock on the
monitor protecting a critical system resource when it is suspended, no
thread can access this resource until the target thread is resumed. If
the thread that would resume the target thread attempts to lock this
monitor prior to calling resume, deadlock results. Such
deadlocks typically manifest themselves as "frozen" processes.
For more information, see
Why
are Thread.stop, Thread.suspend and Thread.resume Deprecated?.
java.io.ByteArrayOutputStream.toString(int)
This method does not properly convert bytes into characters.
As of JDK 1.1, the preferred way to do this is via the
toString(String enc) method, which takes an encoding-name
argument, or the toString() method, which uses the
platform's default character encoding.
java.util.Date.UTC(int, int, int, int, int, int)
As of JDK version 1.1,
replaced by Calendar.set(year + 1900, month, date,
hrs, min, sec) or GregorianCalendar(year + 1900,
month, date, hrs, min, sec), using a UTC
TimeZone, followed by Calendar.getTime().getTime().
java.io.ObjectOutputStream.PutField.write(ObjectOutput)
This method does not write the values contained by this
PutField object in a proper format, and may
result in corruption of the serialization stream. The
correct way to write PutField data is by
calling the java.io.ObjectOutputStream#writeFields()
method.
Deprecated Constructors
java.util.Date(int, int, int)
As of JDK version 1.1,
replaced by Calendar.set(year + 1900, month, date)
or GregorianCalendar(year + 1900, month, date).
java.util.Date(int, int, int, int, int)
As of JDK version 1.1,
replaced by Calendar.set(year + 1900, month, date,
hrs, min) or GregorianCalendar(year + 1900,
month, date, hrs, min).
java.util.Date(int, int, int, int, int, int)
As of JDK version 1.1,
replaced by Calendar.set(year + 1900, month, date,
hrs, min, sec) or GregorianCalendar(year + 1900,
month, date, hrs, min, sec).
java.io.StreamTokenizer(InputStream)
As of JDK version 1.1, the preferred way to tokenize an
input stream is to convert it into a character stream, for example:
Reader r = new BufferedReader(new InputStreamReader(is));
StreamTokenizer st = new StreamTokenizer(r);
java.lang.String(byte[], int)
This method does not properly convert bytes into characters.
As of JDK 1.1, the preferred way to do this is via the
String constructors that take a charset name or
that use the platform's default charset.
java.lang.String(byte[], int, int, int)
This method does not properly convert bytes into characters.
As of JDK 1.1, the preferred way to do this is via the
String constructors that take a charset name or that use
the platform's default charset.