Bug 357902 - JDT compiler unnecessarily complains about unused methods
Summary: JDT compiler unnecessarily complains about unused methods
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.8 M3   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-15 23:49 EDT by Marcel Bruch CLA
Modified: 2011-10-24 03:27 EDT (History)
4 users (show)

See Also:


Attachments
Example Code Snippet illustrating unnecessary compiler warning about unused methods (25.96 KB, image/png)
2011-09-15 23:49 EDT, Marcel Bruch CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel Bruch CLA 2011-09-15 23:49:29 EDT
Created attachment 203468 [details]
Example Code Snippet illustrating unnecessary compiler warning about unused methods
Comment 1 Ayushman Jain CLA 2011-09-16 00:38:34 EDT
Strange. The warning is only meant for private unused methods. I'll investigate.
Comment 2 Dani Megert CLA 2011-09-16 03:40:38 EDT
A picture is not so good for pasting into the Package Explorer ;-). A simple working snippet would be good.

It might well be that the warning is correct: if the #provideAnalysisFixture method is not defined in an interface as abstract in a super class then it is indeed not needed.
Comment 3 Marcel Bruch CLA 2011-09-16 03:56:41 EDT
Dani, it's not overriding any method. The method is called by Google Guice. It finds this method via reflection when the Module is registered. So, if the compiler does the overrides check this may well be an intended behavior and thus not a bug.

For my defense: I asked before filing this bug: http://www.eclipse.org/forums/index.php/t/240171/ :)
Comment 4 Dani Megert CLA 2011-09-16 03:59:07 EDT
The unused detection assumes that no reflection is used. Otherwise nothing could be flagged.
Comment 5 Sebastian Zarnekow CLA 2011-09-18 17:47:44 EDT
I think it is reasonable to take some common annotations into account for this inspection.
Comment 6 Srikanth Sankaran CLA 2011-10-24 02:51:15 EDT
Verified INVALID for 3.8 M3
Comment 7 Sebastian Zarnekow CLA 2011-10-24 02:55:13 EDT
(In reply to comment #6)
> Verified INVALID for 3.8 M3

That's it? No additional comment about the previous suggestion? Would you even consider to accept a patch or something?
Comment 8 Srikanth Sankaran CLA 2011-10-24 03:11:56 EDT
> Would you even
> consider to accept a patch or something?

While it cannot be guaranteed ahead of time that it will make it,
we can certainly consider it. In the end it would depend upon how generally
useful this is going to be.

For a starting point of your fix and test, you can take a look
https://bugs.eclipse.org/bugs/show_bug.cgi?id=356417 and the
attached patch there.

I'll leave this defects as INVALID for the time being as in general
a reflective usage doesn't count. At the appropriate time, we can
consider reopening it.
Comment 9 Sebastian Zarnekow CLA 2011-10-24 03:17:13 EDT
(In reply to comment #8)
> For a starting point of your fix and test, you can take a look
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=356417 and the
> attached patch there.

I'm afraid bug 356417 does not have any attachments.

> 
> I'll leave this defects as INVALID for the time being as in general
> a reflective usage doesn't count. At the appropriate time, we can
> consider reopening it.

I understand.
Comment 10 Srikanth Sankaran CLA 2011-10-24 03:27:41 EDT
(In reply to comment #9)
> (In reply to comment #8)
> > For a starting point of your fix and test, you can take a look
> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=356417 and the
> > attached patch there.
> 
> I'm afraid bug 356417 does not have any attachments.

Sorry, cut & paste problem. Please take a look at:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=346529

(Don't know if this bug maps totally to the current issue,
but should be good starting point.)