Bug 563606 - @SuppressWarnings("deprecation") on method, field, variable is not removing the import deprecation warning
Summary: @SuppressWarnings("deprecation") on method, field, variable is not removing t...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.15   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-26 15:14 EDT by Frederic Boutin CLA
Modified: 2023-12-08 06:18 EST (History)
3 users (show)

See Also:


Attachments
Screenshot of the warning in imports (104.32 KB, image/png)
2020-05-26 15:14 EDT, Frederic Boutin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Boutin CLA 2020-05-26 15:14:48 EDT
Created attachment 283026 [details]
Screenshot of the warning in imports

When importing a deprecated class no warning should show up in imports if the enclosing scope were the class is actually used is annotated with a @SuppressWarnings("deprecation").

The only way to get rid of the warning right now is to annotate the whole class with @SuppressWarnings("deprecation"), but it might hide some other deprecation warning we would want to pop.
Comment 1 Stephan Herrmann CLA 2020-05-26 15:29:18 EDT
The same applies to @SuppressWarnings("restriction").

The consequence would perhaps be to *never* report deprecation or restriction warnings against imports, only against their usage. But that would be a fairly substantial change and we would need to dig into the history, why those warnings were implemented in the first place. In particular for "deprecation" we'd actually need to check if JLS requires us to raise the warning.

Note that there's an easy workaround: don't import, but use the qualified name at the declaration that has @SuppressWarnings("deprecation").
Comment 2 Christoph Laeubrich CLA 2021-12-17 04:18:36 EST
Any progress on this? This currently makes it a bit cumbersome to suppress warnings as local as possible.

I think the rule for imports should be that the warning is not shown if *all* references are marked as @Supress
Comment 3 Eclipse Genie CLA 2023-12-08 06:18:40 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.