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

Bug 515536

Summary: "Method parameter not used" warning incorrectly disappears when @param in javadoc
Product: [Eclipse Project] JDT Reporter: Shawn Heisey <eclipse>
Component: CoreAssignee: Till Brychcy <register.eclipse>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, register.eclipse, stephan.herrmann
Version: 4.6   
Target Milestone: 4.7 M7   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Error/Warning preferences screenshot none

Description Shawn Heisey CLA 2017-04-20 13:40:59 EDT
Eclipse 4.6.3, Java EE development package.

I have the setting turned on that marks unused method parameters with a warning.

I've discovered that if the method has javadoc and a parameter is referenced with the @param annotation in the javadoc, but is completely unused inside the method, the unused warning isn't shown.

I do not think that mention in javadoc @param should be enough to disable the warning about the parameter being unused.
Comment 1 Jay Arthanareeswaran CLA 2017-04-21 05:16:33 EDT
Stephan, what's your take here?
Comment 2 Shawn Heisey CLA 2017-04-21 10:12:22 EDT
When I opened this, I did realize that this isn't going to be a trivial change.  Likely what's happening is that the code is counting usages and the warning goes away when the number is above zero.

Best guess is that a fix would involve either having multiple usage counters or simply not counting @param usages.  It might be challenging with the latter solution to make sure they are still highlighted when the variable is clicked.  I have not examined the code at all, so this assessment could very well be wrong.
Comment 3 Till Brychcy CLA 2017-04-21 14:21:17 EDT
There's a setting for that:
Go to Preferences > Java > Compiler > Error / Warnings, Section "Unnecessary Code"
deselect "Ignore unused parameters documented with '@param' tag"
Comment 4 Shawn Heisey CLA 2017-04-21 16:03:26 EDT
Created attachment 267916 [details]
Error/Warning preferences screenshot

This shows that the @param-related checkbox is unchecked in the Errors/Warnings preferences screen.
Comment 5 Shawn Heisey CLA 2017-04-21 16:04:30 EDT
I found that @param setting in the preferences and unchecked it, then let it rebuild the workspace.  There's still not a warning on a parameter that is unused other than the @param mention.
Comment 6 Shawn Heisey CLA 2017-04-21 16:06:30 EDT
PEBCAK.  There were project-specific settings.  Changed that option there and now it's working.  Closing the bug.