Skip to content

Commit b6163b0

Browse files
stephan-herrmanniloveeclipse
authored andcommitted
React to review comments
Rephrase in active voice ("you") Add example: pictures and explanation
1 parent 78996e8 commit b6163b0

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed
49.8 KB
Loading
78.7 KB
Loading

news/4.38/jdt.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ This behavior now more aligns with JPMS and OSGi semantics, where inherited publ
4242

4343
Implementers of `IClasspathConainer` are advised to revisit their usage of access restrictions to see if this new concepts still meets their expectations or possibly need adaption.
4444

45-
### Changed concerning Deprecation Warnings
45+
### Changes concerning Deprecation Warnings
4646
<!-- https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4572 -->
4747
<details>
4848
<summary>Contributors</summary>
@@ -52,27 +52,53 @@ Implementers of `IClasspathConainer` are advised to revisit their usage of acces
5252

5353
It was discovered that the Eclipse Compiler for Java (ECJ) was not conforming to JLS in several matters of deprecation warnings.
5454

55-
Therefore a significant overhaul in this area was performed. As a result users may experience fewer or more deprecation warnings in their code, depending on how `@Deprecated` and `@SuppressWarnings("deprecation")` are used in their code.
55+
Therefore a significant overhaul in this area was performed. As a result you may experience fewer or more deprecation warnings in your code, depending on how `@Deprecated` and `@SuppressWarnings("deprecation")` are used in your code (in these regards the old javadoc tag `@deprecated` has the same effect as the annotation).
5656

5757
#### Changes in problem reporting
5858
* Previously, ECJ regarded all **members** (fields, methods, member types) of a deprecated type as **"implicitly deprecated"**. This concept is not backed by JLS and has been corrected, such that ECJ now reports fewer warnings.
5959
* In this situation deprecation warnings will only be raised against references to the deprecated type, not at locations where only its members are referenced.
60+
* Invocations of a default constructor count as a reference to the type, i.e., those get a warning, too.
6061
* If previously such warnings were suppressed in the code, then this `@SuppressWarnings` annotation may be flagged as unnecessary.
6162
* If a deprecated type is extended or implemented by a non-deprecated type, clients of the subtype may now freely use its inherited members without triggering a warning. In this situation the `extends` or `implements` clauses are now the only location where deprecation will cause a warning (unless suppressed there).
6263
* Previously, ECJ did not raise any deprecation warnings when using deprecated elements from **within the same compilation unit** (file). JLS specifies this slightly different: not a compilation unit is the point of reference, but declaration and use must be located within the same **top-level type** in order to be exempted from deprecation warnings.
63-
* This will bring about more warnings in situations where users assumed that code within the same compilation unit is **"friendly"** and thus privileged to use deprecated elements.
64+
* This will bring about more warnings in situations where you may have assumed that code within the same compilation unit is **"friendly"** and thus privileged to use deprecated elements.
6465
* New warnings are also raised against usage of a deprecated **annotation element**.
6566
* This is relevant when an annotation type itself is not deprecated, but the way how annotation details are specified is changing and deprecation is used for guiding users during migration.
66-
67+
68+
6769
#### New support for reacting to the above changes
6870

69-
Users may have gotten used to warnings regarding "implicitly deprecated" members, and thus feel the correction of ECJ to be a loss in visibility of pending migration issues.
71+
You may have gotten used to warnings regarding "implicitly deprecated" members, and thus feel the correction of ECJ to be a loss in visibility of pending migration issues.
7072

71-
For this situation a new configurable warning (severity is info by default) has been implemented that will alert the user when a deprecated type contains members that are not marked as deprecated (private members are exempted).
73+
For this situation a new configurable warning (severity is `info` by default) has been implemented that will alert you when a deprecated type contains members that are not marked as deprecated (private members are exempted).
7274

7375
Along with the new warning a quickfix is provided that allows to mechanically add `@Deprecated` to all affected members, thus restoring warnings regarding the use of any of these members.
7476

75-
If this new hint is not desired, setting the option to "ignore" will turn it off.
77+
#### Example
78+
79+
![Classes with deprecation](images/DeprecationWarnings.png)
80+
81+
**Explanations:**
82+
* DeprecatedClass.java
83+
* Members of this class are no longer considered as deprecated. See Client1.java.
84+
* Members, however, raise the new info warning: "The enclosing type DeprecatedClass is deprecated, perhaps this member should be marked as deprecated, too?"
85+
* Class `NotAFriend` gets a deprecation warning against its superclass, despite being stored in the same compilation unit.
86+
* Client1.java
87+
* This class no longer gets any deprecation warnings, as none of the referenced elements are deprecated.
88+
* Client2.java
89+
* This class shows two applications of the annotation `Ann`.
90+
* At class level the annotation is used without detail and hence does not raise a warning.
91+
* At method level the annotation detail `value` triggers the deprecation warning.
92+
93+
**Quick fixes are offered for the new info warning:**
94+
95+
![Classes with deprecation](images/DeprecationQuickFixes.png)
96+
97+
* You may add `@Deprecated` annotations to individual members.
98+
* This fix can also be applied to several members together (via this hover or when invoked from the Problems view)
99+
* The link `Configure problem severity` will take you to the exact location in compiler preferences, where you can select the severity of this warning among "error", "warning", "info" or "ignore". Obviously, "ignore" will turn it of for the scope of that project or workspace.
100+
101+
Adding `@Deprecated` as suggested by the quickfix will bring back the warnings in Client1.java that previous versions of ECJ reported.
76102

77103
### Multi-Release JAR Compilation Support
78104
<!-- https://github.com/eclipse-jdt/eclipse.jdt.core/pull/3900 -->

0 commit comments

Comments
 (0)