Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351652 - Misleading 'unused' variable indicated by the code
Summary: Misleading 'unused' variable indicated by the code
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-10 06:25 EDT by Jonathan Camilleri CLA
Modified: 2011-07-11 04:10 EDT (History)
1 user (show)

See Also:


Attachments
Source code (2.49 KB, application/octet-stream)
2011-07-10 06:25 EDT, Jonathan Camilleri CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Camilleri CLA 2011-07-10 06:25:23 EDT
Build Identifier: M20110210-1200

A warning is displayed regarding the nBytes declaration: The local variable nBytes is never read:
...
@SuppressWarnings("unused")
int nBytes = socket.read(buf); //here's nBytes...
...

See (L129-L130 of attached file within NonBlockingServer.java.

Reproducible: Always
Comment 1 Jonathan Camilleri CLA 2011-07-10 06:25:59 EDT
Created attachment 199386 [details]
Source code
Comment 2 Dani Megert CLA 2011-07-11 03:01:55 EDT
Your example is broken because if you add a @SuppressWarnings("unused") then no warning will be shown.

Having said that, in 3.7 the warning says that the *value* is not used.
Comment 3 Jonathan Camilleri CLA 2011-07-11 03:28:52 EDT
(In reply to comment #2)
> Your example is broken because if you add a @SuppressWarnings("unused") then no
> warning will be shown.
> 
> Having said that, in 3.7 the warning says that the *value* is not used.

That's correct, I used @SuppessWarnings simply to avoid having the error being displayed temporarily. Having said that, I am not sure why my bug is invalid.
Comment 4 Dani Megert CLA 2011-07-11 04:00:46 EDT
(In reply to comment #3)
> (In reply to comment #2)
> > Your example is broken because if you add a @SuppressWarnings("unused") then no
> > warning will be shown.
> > 
> > Having said that, in 3.7 the warning says that the *value* is not used.
> 
> That's correct, I used @SuppessWarnings simply to avoid having the error being
> displayed temporarily.
When attaching a test case it would be easier if the test case by itself would show the problem that you try to report.

>Having said that, I am not sure why my bug is invalid.
Because the message is correct in 3.7.
Comment 5 Jonathan Camilleri CLA 2011-07-11 04:10:06 EDT
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> > > Your example is broken because if you add a @SuppressWarnings("unused") then no
> > > warning will be shown.
> > > 
> > > Having said that, in 3.7 the warning says that the *value* is not used.
> > 
> > That's correct, I used @SuppessWarnings simply to avoid having the error being
> > displayed temporarily.
> When attaching a test case it would be easier if the test case by itself would
> show the problem that you try to report.
> 
> >Having said that, I am not sure why my bug is invalid.
> Because the message is correct in 3.7.

I think you have not understood the issue from my point of view.