2023-05-03 11:06:20 +02:00
== Why is this an issue?
2020-12-21 15:38:52 +01:00
Deprecated classes and interfaces should be avoided, rather than used, inherited or extended. Deprecation is a warning that the class or interface has been superseded, and will eventually be removed. The deprecation period allows you to make a smooth transition away from the aging, soon-to-be-retired technology.
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2020-12-21 15:38:52 +01:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-12-21 15:38:52 +01:00
----
/**
* @deprecated As of release 1.3, replaced by {@link #Fee}
*/@Deprecated
class Foo { ... }
class Bar extends Foo { ... }
----
2023-05-03 11:06:20 +02:00
=== Compliant solution
2020-12-21 15:38:52 +01:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-12-21 15:38:52 +01:00
----
class Bar extends Fee { ... }
----
2023-05-03 11:06:20 +02:00
=== Exceptions
2020-12-21 15:38:52 +01:00
When the class that extends a deprecated class is itself deprecated, the extending class will be ignored.
2023-05-25 14:18:12 +02:00
[source,text]
2020-12-21 15:38:52 +01:00
----
@Deprecated
class Bar extends Foo { ... } // compliant Bar is deprecated.
----
2023-05-03 11:06:20 +02:00
== Resources
2020-12-21 15:38:52 +01:00
2024-01-15 17:15:56 +01:00
* CWE - https://cwe.mitre.org/data/definitions/477[CWE-477 - Use of Obsolete Functions]
2020-12-21 15:38:52 +01:00
2022-01-25 18:36:46 +01:00
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== Message
"XXX" is deprecated, [extend|implement] the suggested replacement instead.
2022-01-25 18:36:46 +01:00
'''
== Comments And Links
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== is related to: S2214
2022-01-25 18:36:46 +01:00
endif::env-github,rspecator-view[]