The java.lang.Deprecated annotation type specification says,
«Use of the @Deprecated annotation on a local variable declaration or on a parameter declaration or a package declaration has no effect on the warnings issued by a compiler.»
Note however that @Deprecated is allowed on package declarations for reasons of backward compatibility.
https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Deprecated.html
JLS 9.6.4.6 specifies requirements that warnings be generated when certain deprecated program elements are mentioned, and packages are omitted from the list of program elements.
https://docs.oracle.com/javase/specs/jls/se14/html/jls-9.html#jls-9.6.4.6
With these points in mind, consider the following source files:
p/package-info.java
===================
@Deprecated
package p;
p/P.java
========
package p;
public class P { }
q/Q.java
========
package q;
import p.*;
class Q {
Class<?> c1 = P.class; // **1**
Class<?> c2 = p.P.class; // **2**
}
Compiling all of files with "javac -Xlint:deprecation */*.java" results in:
==========
p/package-info.java:2: warning: [deprecation] @Deprecated annotation has no effect on this package declaration
package p;
^
q/Q.java:5: warning: [deprecation] p in has been deprecated
Class<?> c2 = p.P.class;
^
2 warnings
==========
The first warning is probably ok, as it warns that the deprecation has no effect. (See JDK-8140772.)
The second warning is very strange, as it *IS* an effect of deprecating package p. Note that using a member of package p via on-demand import, as in line **1**, does not issue a warning. However, line **2**, which mentions package p as part of a full qualification of a class name, does issue a warning. Note also the malformed warning message.
This is rather strange, and it ought to be straightened out.