You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: news/4.38/jdt.md
+33-7Lines changed: 33 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ This behavior now more aligns with JPMS and OSGi semantics, where inherited publ
42
42
43
43
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.
@@ -52,27 +52,53 @@ Implementers of `IClasspathConainer` are advised to revisit their usage of acces
52
52
53
53
It was discovered that the Eclipse Compiler for Java (ECJ) was not conforming to JLS in several matters of deprecation warnings.
54
54
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).
56
56
57
57
#### Changes in problem reporting
58
58
* 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.
59
59
* 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.
60
61
* If previously such warnings were suppressed in the code, then this `@SuppressWarnings` annotation may be flagged as unnecessary.
61
62
* 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).
62
63
* 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.
64
65
* New warnings are also raised against usage of a deprecated **annotation element**.
65
66
* 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
+
67
69
#### New support for reacting to the above changes
68
70
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.
70
72
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).
72
74
73
75
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.
74
76
75
-
If this new hint is not desired, setting the option to "ignore" will turn it off.
77
+
#### Example
78
+
79
+

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
+

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.
0 commit comments