Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Never use deprecated fields, methods, or classes in new code. Java provides an @deprecated annotation to indicate the deprecation of specific fields, methods, and classes. For example, many methods of java.util.Date, such as Date.getYear(), have been explicitly deprecated. THI05-J. Do not use Thread.stop() to terminate threads describes issues that can result from using the deprecated Thread.stop() method. 

The Java SE documentation provides a list of deprecated APIs for each version of the language:

...

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

MET02-J

Low

Unlikely

Medium

P2

L3

Automated Detection

Detecting uses of deprecated methods is straightforward. Obsolete methods have no automatic means of detection.

ToolVersionCheckerDescription
Parasoft Jtest
Include Page
Parasoft_V
Parasoft_V
CERT.MET02.DPRAPI
CERT.MET02.THRD
Do not use deprecated APIs
Avoid calling unsafe deprecated methods of 'Thread' and 'Runtime'
SonarQube
Include Page
SonarQube_V
SonarQube_V
S1874"@Deprecated" code should not be used

Related Guidelines

ISO/IEC TR 24772:2010

Deprecated Language Features [MEM]

MITRE CWE

CWE-589, Call to Non-ubiquitous API

...