RFR: 8343479: Remove unnecessary @SuppressWarnings annotations (hotspot) [v2]
Archie Cobbs
acobbs at openjdk.org
Thu Nov 7 15:46:45 UTC 2024
On Thu, 7 Nov 2024 07:48:43 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> Archie Cobbs has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>>
>> - Update copyright years.
>> - Merge branch 'master' into SuppressWarningsCleanup-hotspot
>> - Merge branch 'master' into SuppressWarningsCleanup-graal
>> - Remove unnecessary @SuppressWarnings annotations.
>
> Hi @archiecobbs can you please give some more info about why these were introduced, and why they are now not needed any more?
Hi @eme64,
> Hi @archiecobbs can you please give some more info about why these were introduced, and why they are now not needed any more?
FYI there are [several other](https://github.com/openjdk/jdk/pulls?q=author%3Aarchiecobbs+is%3Apr+%22Remove+unnecessary%22+in%3Atitle+) PR's like this one. I haven't checked exhaustively, but all of the ones I've checked appear to be due to either (a) the warning was never needed, or (b) a subsequent refinement of the warning itself which made the code no longer qualify as "warnable".
For an example of (a) see commit 8fb70c710afa which added `@SuppressWarnings("unchecked")` for a cast to type `Key`, even though `Key` is not a generic type and so the cast was never unchecked in the first place.
For an example of (b), see commit b431c6929d12 which added `@SuppressWarnings("serial")` because an anonymous class did not declare `serialVersionUID`, but then later the warning was was changed to no longer trigger in that situation by [JDK-7152104](https://bugs.openjdk.org/browse/JDK-7152104), but the annotation was not removed as part of that commit.
In this particular PR, it looks like (for example) the useless `@SuppressWarnings("try")` annotations on `compileMethod()` was [added in this commit](https://github.com/openjdk/jdk/commit/3b0ee5a6d8b89a52b0dacc51399955631d6aa597#diff-4d3a3b7e7e12e1d5b4cf3e4677d9e0de5e9df3bbf1bbfa0d8d43d12098d67dc4) - probably a copy & paste error. This is typical.
I guess the only other possibility is that the warning stopped working at some point due to a bug, but I haven't seen any examples of that.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21853#issuecomment-2462566874
More information about the hotspot-compiler-dev
mailing list