Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 339188

Summary: @SuppressWarnings warningToken doesn't work
Product: [Eclipse Project] JDT Reporter: Heiko Böttger <heiko.boettger>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, stephan.herrmann
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Heiko Böttger CLA 2011-03-08 04:56:16 EST
Build Identifier: I20110127-2034

According to this website in the archive

http://archive.eclipse.org/eclipse/downloads/drops/R-3.1.2-200601181600/buildnotes/buildnotes_jdt-core.html

JDT should allow a "warningToken" to suppress the warning caused by unused tokens in @SuppressWarnings.





Reproducible: Always

Steps to Reproduce:
1. create a class
2. add @SuppressWarnings("unused,warningToken")
3. should not create a warnung
Comment 1 Ayushman Jain CLA 2011-03-08 06:07:28 EST
(In reply to comment #0)
> Steps to Reproduce:
> 1. create a class
> 2. add @SuppressWarnings("unused,warningToken")
> 3. should not create a warnung

The @SuppressWarnings annotation is working as it is intended to. I think you did not use it in the correct way. All the warning kinds that you need to suppress have to be specified in a string array as value for the annotation.
So, you would use @SuppressWarnings ({"unused", "null"}) to suppress unused warnings and null warnings.
You can also use quick fix (CTRL-1) on the warning that you don't want to see and chose "Add @SuppressWarnings.." and let JDT add the annotation for you.
Comment 2 Stephan Herrmann CLA 2011-03-08 10:57:00 EST
(In reply to comment #0)
> JDT should allow a "warningToken" to suppress the warning caused by unused
> tokens in @SuppressWarnings.

If indeed you want to suppress the warning 
   Unnecessary @SuppressWarnings("foo")
then this is not covered by the build notes you cite, but it looks like a
duplicate of enhancement request bug 252518.

Please confirm, thanks.
Comment 3 Heiko Böttger CLA 2011-03-08 14:31:57 EST
(In reply to comment #2)
> (In reply to comment #0)
> > JDT should allow a "warningToken" to suppress the warning caused by unused
> > tokens in @SuppressWarnings.
> 
> If indeed you want to suppress the warning 
>    Unnecessary @SuppressWarnings("foo")
> then this is not covered by the build notes you cite, but it looks like a
> duplicate of enhancement request bug 252518.
> 
> Please confirm, thanks.

Thanks Stephan.

Yes, I thought that there should be something like this
@SuppressWarnings({ "warningToken", "rawtypes", "unused" }).

I think I got confused because according to the table on this website
http://yottabyte.net/blog/?m=200806 and some other websites, there is a
real token named "warningToken". This means that the buildnotes only uses this as a placeholder.

And yes that was what I was looking for, I wonder why I didn't found it.
So you can mark this as an dupplicate of https://bugs.eclipse.org/bugs/show_bug.cgi?id=252518.

Do you see any chance to get that fixed in 3.7. The problem is, that we make use of code generation, which causes a bunch of warnings if there is an unused import. However if we suppress the warning, we get a new warning where ever the import is used :).


(In reply to comment #1)
> (In reply to comment #0)
> > Steps to Reproduce:
> > 1. create a class
> > 2. add @SuppressWarnings("unused,warningToken")
> > 3. should not create a warnung
> 
> The @SuppressWarnings annotation is working as it is intended to. I think you
> did not use it in the correct way. All the warning kinds that you need to
> suppress have to be specified in a string array as value for the annotation.
> So, you would use @SuppressWarnings ({"unused", "null"}) to suppress unused
> warnings and null warnings.
> You can also use quick fix (CTRL-1) on the warning that you don't want to see
> and chose "Add @SuppressWarnings.." and let JDT add the annotation for you.

Sorry for that, I must have had a blackout. Your are right the tokens have to be passed as an array.
Comment 4 Ayushman Jain CLA 2011-03-08 23:59:03 EST
Marking as dup as per above comment

*** This bug has been marked as a duplicate of bug 252518 ***