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

Bug 276151

Summary: [quick fix] Suggestion to add @SuppressWarnings is confusing
Product: [Eclipse Project] JDT Reporter: Jonathan Camilleri <camilleri.jon>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, markus.kell.r
Version: 3.4.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

Description Jonathan Camilleri CLA 2009-05-13 13:48:02 EDT
Build ID: Build id: M20090211-1700

Steps To Reproduce:
1.Write some code
Employee.java
public class Employee
...
try
		{
			@SuppressWarnings("unused")
			Employee _object1 = (Employee) employee;
			Employee _object2 = (Employee) this;
//Warning is displayed about unused object //"_object2".  
//My best option (since I already have a @SuppressWarnings, is to ignore this message.
So might as well have an option to 'Ignore'.		
}
		catch (Exception ex) 
		{
			throw new InvalidCastException();
		}
...
}

NOTE: It would be helpful to have html tags for clearly distinguishing code from other tags (e.g. [CODE] [/CODE])

NOTE 2: Cosmetic issue.

More information:
Comment 1 Jonathan Camilleri CLA 2009-05-13 13:48:58 EDT
NOTE 1: Not sure of the component.
NOTE 2: OS is Windows Server 2008 64 bit not Windows Vista.
Comment 2 Dani Megert CLA 2009-05-14 02:58:18 EDT
You can either suppress each variable or you can suppress all of them by adding the annotation to their containing member. That is how Java works. What exactly is confusing you?

>NOTE: It would be helpful to have html tags for clearly distinguishing code
>from other tags (e.g. [CODE] [/CODE])
Not sure what you mean here.
Comment 3 Jonathan Camilleri CLA 2009-05-14 03:09:38 EDT
Well, it might be a bit of a subtle point and of an ad-hoc nature but just by following the prompts, I would have to be aware that only one @Suppresswarnings is necessary to suppress the warning, whilst the IDE pro-actively prompts again for the next "unused" object which was expected:

 @SuppressWarnings("unused") //good enough for both, right?
 Employee _object1 = (Employee) employee;
 Employee _object2 = (Employee) this; // when warning me about this, I could have the option to 'Ignore' or 'Ignore further warnings on this class'.

I tend to assume that the user usually follows the prompts if s/he doesn't know any better or s/he's busy.

It is of course up to you to decide whether they think it is worth implementing this.
Comment 4 Dani Megert CLA 2009-05-14 03:16:07 EDT
So, if I get you right, you would like to see an addition quick fix that allows to suppress the warning for the whole containing member and/or for the whole type, right?
Comment 5 Jonathan Camilleri CLA 2009-05-14 03:25:37 EDT
Well on second thoughts I had a second look at the IDE.

I have had a quick look at Project > Preferences > Java > Compiler > Errors/Warnings > Annotations and there are options to flag the warnings to ignore, so I think I'll close this ticket.

Comment 6 Markus Keller CLA 2009-05-29 09:05:19 EDT
.
Comment 7 Jonathan Camilleri CLA 2009-05-29 09:08:17 EDT
Eclipse say it's invalid.