Bug 124697 - @SuppressWarnings("deprecation") does not suppress deprecation warning on imports
Summary: @SuppressWarnings("deprecation") does not suppress deprecation warning on imp...
Status: VERIFIED DUPLICATE of bug 123522
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M5   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-20 13:53 EST by Willian Mitsuda CLA
Modified: 2006-02-16 10:53 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Willian Mitsuda CLA 2006-01-20 13:53:50 EST
Consider the following sample code:

------
DeprecatedClass.java:

package com.mycompany;

@Deprecated
public class DeprecatedClass {
...
}

------
MyClass.java:

package com.mycompany.myapp;

import com.mycompany.DeprecatedClass;

public class MyClass {
    public static void main(String[] args) {
        DeprecatedClass c = new DeprecatedClass();
        ....
    }
}

------

In MyClass.java, the Eclipse compiler warns about DeprecatedClass being, er, deprecated ;-)

Suppose I want intentionally to use DeprecatedClass, because it is legacy code and I don't have a drop-in replacement solution, but I don't want the deprecation warning in this method (or class), so I annotate it with @SuppressWarnings:

package com.mycompany.myapp;

import com.mycompany.DeprecatedClass;

public class MyClass {
    @SuppressWarnings("deprecation")
    public static void main(String[] args) {
        DeprecatedClass c = new DeprecatedClass();
        ....
    }
}

and the warning disappears from main method, but it still remains in the import clause!

Yes, I know that @SupressWarnings is not applicable to import statements, but I think the compiler should not warn a deprecated class in the import statement if the code block where it is used is annotated with @SuppressWarnings("deprecation")
Comment 1 Olivier Thomann CLA 2006-01-20 15:21:11 EST

*** This bug has been marked as a duplicate of 124522 ***
Comment 2 Olivier Thomann CLA 2006-01-20 15:22:27 EST
Reopen to close as dup og bug 123522 and not 124522.
Comment 3 Olivier Thomann CLA 2006-01-20 15:22:52 EST

*** This bug has been marked as a duplicate of 123522 ***
Comment 4 Willian Mitsuda CLA 2006-02-16 09:08:06 EST
This bug was marked as a DUPL of bug#123522, which was VERIFIED against I20060215-0010.

However, this bug still happens on I20060215-0010, so I'm reopening it.
Comment 5 Frederic Fusier CLA 2006-02-16 10:43:42 EST
Put back as duplicate as you need to put your @SuppressWarnings("deprecation") on class declaration and not on main method only.

So, following test case does not produce any deprecation warning:

package com.mycompany.myapp;

import com.mycompany.DeprecatedClass;

@SuppressWarnings("deprecation")
public class MyClass {
    public static void main(String[] args) {
        DeprecatedClass c = new DeprecatedClass();
        ....
    }
}

*** This bug has been marked as a duplicate of 123522 ***
Comment 6 Willian Mitsuda CLA 2006-02-16 10:53:38 EST
Ok, my fault... Sorry!