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

Bug 375366

Summary: ECJ ignores unusedParameterIncludeDocCommentReference unless enableJavadoc option is set
Product: [Eclipse Project] JDT Reporter: Victor Lewis <victor>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jal, jarthana, Olivier_Thomann, satyam.kandula, srikanth_sankaran, stephan.herrmann
Version: 3.7.1Flags: srikanth_sankaran: review+
Target Milestone: 4.3 M3   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Archived Eclipse Project Demonstrating Bug
none
proposed patch none

Description Victor Lewis CLA 2012-03-26 17:12:00 EDT
Build Identifier: 20110916-0149

When you set unusedParameterIncludeDocCommentReference in the UI (Project Properties -> Java Compiler -> Errors/Warnings, set "Value of Parameter is not used" to Warning and set the check-boxes on "Ignore in overriding and implementing methods" and "Ignore parameters documented with '@param' tag" the value of unusedParameterIncludeDocCommentReference is set to enabled in .settings/org.eclipse.jdt.core.prefs but the UI interprets the setting as set in the dialog the way you would expect (i.e. unused parameters documented with @param are not flagged as warning).  However if you compile with ecj it interprets the setting in the file oppositely and flags the warning even though it is not reported in the UI.

Reproducible: Always

Steps to Reproduce:
1. Load attached example Eclipse Project.
2. Note setting of Project Properties -> Java Compiler -> Errors/Warnings setting for "Value of Parameter is not used," "Ignore in overriding and implementing methods," and "Ignore parameters documented with '@param' tag."
3. Note that the settings for these values in .settings\org.eclipse.jdt.core.prefs are as below and that has a value that is opposite from what would be expected from the UI settings.

org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled


4. Note that there are no warnings flagged on ShowBug class.
5. From the command line change directory to the workspace for this project and execute the following from the command line (you will have to supply your own ecj jar)

c:\dev\warningsBug\WarningBug>java -jar c:\tmp\ecj-3.7.jar -version
Eclipse Compiler for Java(TM) 0.B61, 3.7.0, Copyright IBM Corp 2000, 2010. All rights reserved.

c:\dev\warningsBug\WarningBug>java -jar c:\tmp\ecj-3.7.jar -d c:\tmp -properties .settings\org.eclipse.jdt.core.prefs src
----------
1. WARNING in c:\dev\warningsBug\WarningBug\src\bugs\warning\ShowBug.java (at line 8)
        public void foo(Object unusedParam) {
                               ^^^^^^^^^^^
The value of the parameter unusedParam is not used
----------
1 problem (1 warning)
c:\dev\warningsBug\WarningBug>

6. Note that the warning is generated from ecj even though it is not in the UI.
Comment 1 Victor Lewis CLA 2012-03-26 17:17:59 EDT
Created attachment 213202 [details]
Archived Eclipse Project Demonstrating Bug
Comment 2 Satyam Kandula CLA 2012-03-27 02:18:09 EDT
Actually this option works only if javadoc processing is turned on. Passing -enableJavadoc in the command line does fix the issue.
Comment 3 Victor Lewis CLA 2012-03-27 10:31:39 EDT
Satyam's suggestion works for me.  I will downgrade the priority and change the description of this bug and leave it to the Eclipse community to decide whether this is working as designed or not.  Seems to me that if ask for exceptions to Error/Warning settings that require javadoc processing then you should turn that on form me.
Comment 4 Olivier Thomann CLA 2012-03-27 10:37:07 EDT
I would be tempted to say that if the option is set using a properties file, -enableJavadoc should be enabled by default if options are used to process javadoc contents.
So when we process the properties file, we could enable the javadoc processing if any of the javadoc options are enabled.
Comment 5 Satyam Kandula CLA 2012-03-28 07:25:58 EDT
(In reply to comment #4)
> I would be tempted to say that if the option is set using a properties file,
> -enableJavadoc should be enabled by default if options are used to process
> javadoc contents.
> So when we process the properties file, we could enable the javadoc processing
> if any of the javadoc options are enabled.
I agree. Ayush, Can you take care of this?
Comment 6 Ayushman Jain CLA 2012-06-11 06:28:13 EDT
*** Bug 382012 has been marked as a duplicate of this bug. ***
Comment 7 Stephan Herrmann CLA 2012-08-24 18:03:24 EDT
IMHO, the bug is that org.eclipse.compiler.doc.comment.support is not interpreted when passing "-properties <file>" on the command line. Isn't that why -enableJavadoc is needed, too?
In a related bug it was discussed to simple let more compiler preferences pass, like all "org.eclipse.jdt.compiler.*" preferences (instead of only "org.eclipse.jdt.compiler.problem.*").

Doing so would have the nice side effect that also null annotations can be enabled using -properites :) (which currently is not possible).
Comment 8 Stephan Herrmann CLA 2012-08-24 19:51:46 EDT
I've pushed a proposed solution to https://git.eclipse.org/r/#/c/7421/

In addition to widening the filter in org.eclipse.jdt.internal.compiler.batch.Main.initializeWarnings(String) I also changed how absent properties are handled: 
- IF a property file is used, AND
- IF any of these properties is missing:
  - org.eclipse.jdt.core.compiler.debug.localVariable
  - org.eclipse.jdt.core.compiler.codegen.unusedLocal
  - org.eclipse.jdt.core.compiler.doc.comment.support
THEN the same default as in JavaCorePreferenceInitializer is used.

This ensures even better alignment of IDE and batch use with -properties.
Notably, null annotations work as expected.
Comment 9 Stephan Herrmann CLA 2012-09-16 09:18:06 EDT
Created attachment 221127 [details]
proposed patch

My current patch rebased on master.
Comment 10 Stephan Herrmann CLA 2012-09-16 09:22:41 EDT
Srikanth, could you please give your +1 for the direction of my patch (see comment 9)?
The change is really simple, just I want to know if you agree with the approach
- to read more options from the preference file, and
- to align defaults for missing options with IDE use (see comment 8).
Thanks.
Comment 11 Srikanth Sankaran CLA 2012-09-18 21:39:26 EDT
Patch looks fine to me. Please release next week for M3.
Comment 12 Stephan Herrmann CLA 2012-09-26 17:37:09 EDT
Code changes have been released for 4.3 M3 via commit 5a4a2929d0aaba1a7f6b87488d0054e129a55977.

Corresponding doc changes are in http://git.eclipse.org/c/platform/eclipse.platform.common.git/commit/?id=b5799e4c1b1404214da06f31ebd5a50d086a56a0
Comment 13 Jay Arthanareeswaran CLA 2012-10-30 12:06:50 EDT
Verified for 4.3 M3 with build I20121029-2000
Comment 14 Stephan Herrmann CLA 2013-04-02 10:24:50 EDT
*** Bug 404722 has been marked as a duplicate of this bug. ***