JDK-8065613 : 9.6.4.6: Don't issue deprecation warnings on import statements
  • Type: Sub-task
  • Component: specification
  • Sub-Component: language
  • Affected Version: 7,8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-11-20
  • Updated: 2018-08-03
  • Resolved: 2016-09-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Fixed
Description
JLS changes are needed.
Comments
I believe that the treatment of nested types in @Deprecated enclosing classes is addressed by the 2014-10-22 comment in JDK-8032211, which led to a sharpening of the spec so that some imports do continue to generate warnings.
25-05-2016

Consider a nested type, with no annotations, inside a type with @Deprecated. Currently (JDK 8 etc) the use of the nested type will trigger deprecation warnings via the use of the enclosing deprecated type. If we allow imports to not generate warnings, that will be a visible change in behavior for the case of an import of a nested type. There will no longer be any warning due to the use of a nested type contained in a deprecated type. I'm not suggesting we don't update the spec w.r.t. imports, but I am suggesting we should clarify the rules for nested types in deprecated enclosing classes.
25-05-2016

The currently proposed JLS change is: From JLS, the section on @Deprecated states: "A Java compiler must produce a deprecation warning when a type, method, field, or constructor whose declaration is annotated with the annotation @Deprecated is used (i.e. overridden, invoked, or referenced by name), unless: * The use is within an entity that is itself annotated with the annotation @Deprecated; or * The use is within an entity that is annotated to suppress the warning with the annotation @SuppressWarnings("deprecation"); or * The use and declaration are both within the same outermost class." http://docs.oracle.com/javase/specs/jls/se7/html/jls-9.html#jls-9.6.3.6 The specification change is adding another bullet * The use is within an import statement that imports the type or member whose declaration is annotated with @Deprecated.
21-11-2014