RFR: JDK-8280745: Allow SuppressWarnings to be used in package declarations [v2]

Joe Darcy darcy at openjdk.java.net
Thu Jan 27 18:58:44 UTC 2022


On Thu, 27 Jan 2022 18:54:06 GMT, Joe Darcy <darcy at openjdk.org> wrote:

>> The SuppressWarnings annotation type is declared have multiple targets, including modules; however, "package" is left off of its target list. As package-info file are another kind of declaration where a compiler could give warnings, allowing SuppressWarnings in that case is reasonable. Wanting SuppressWarnings in package-info file came up while working on doclint warnings (JDK-8280534). 
>> 
>> Please also review the companion CSR:
>> https://bugs.openjdk.java.net/browse/JDK-8280745
>> 
>> While the SuppressWarnings annotation does have a JLS section (9.6.4.5. @SuppressWarnings), the section doesn't mention the target list therefore doesn't appear to need to be updated.
>
> Joe Darcy has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Respond to review feedback.

Furthering on a suggestion from Alex in the CSR review, I've reworked the change to remove the @Target meta-annotation from SuppressWarnings, which allows SuppressWarnings to be used in any declaration context. I've also synced the list of strings required to be recognized for suppressed warnings from JLS 9.6.4.5 @SuppressWarnings; the phrasing is such that any additions from  JLS 9.6.4.5 will be implicitly included even if the javadoc is not updated.

If, say, the jdk.compiler module listed the strings javac accepted for suppressed warnings, I'd like to that from the implNote, but until such a list is added, I just gave instructions from how to get a list.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7239


More information about the core-libs-dev mailing list