Bug 138017 - Compiling Java code > Warning options - needs revision and/or clarification
Summary: Compiling Java code > Warning options - needs revision and/or clarification
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Doc (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3   Edit
Assignee: JDT-Doc-Inbox CLA
QA Contact:
URL: http://help.eclipse.org/help31/index....
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-21 14:04 EDT by Nick Boldt CLA
Modified: 2009-08-30 02:18 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Boldt CLA 2006-04-21 14:04:28 EDT
After 3.2M6, JDT reports compilation warnings as part of the JUnit test results. This is a great new feature, but the documentation around how to suppress certain warnings seems out of date.

According to http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm  (JDT Plug-in Developer Guide > Programmer's Guide > JDT Core > Compiling Java code > Warning options) and its successor in the built-in help in Eclipse 3.2 (I'm using 3.2RC1a, I20060419-1640), I can use flags in combination, like:

-warn:-serial,+nls,-unusedLocal

However, in practice, using Sun JDK 1.4.2, this is not the case. (Do I have to use JDK5 for this to work?) 

Instead, I get:

    [javac] invalid warning: +nls
    [javac] Compile failed; see the compiler error output for details.

or

    [javac] invalid warning: -unusedLocal
    [javac] Compile failed; see the compiler error output for details.

Oh, an in related news (in the same document)...

  Set warning level.
  e.g. -warn:unusedLocals,deprecation

does not match 

  unusedLocal | unused local variable 

I presume that's just a typo (unusedLocal != unusedLocals)
Comment 1 Olivier Thomann CLA 2006-04-21 14:55:04 EDT
Are you using ant ?
If yes, you should specify the compiler's name in the compilerarg element.
Like this:
<compilerarg compiler="org.eclipse.jdt.core.JDTCompilerAdapter" .... />

This would prevent javac from using Eclipse batch compiler options.
Comment 2 Olivier Thomann CLA 2006-04-21 15:22:17 EDT
The doc says:

    -warn:<warnings separated by ,>    enable exactly the listed warnings
    -warn:+<warnings separated by ,>   enable additional warnings
    -warn:-<warnings separated by ,>   disable specific warnings

This doesn't mean that:
-warn:-serial,+nls,-unusedLocals
is valid.
-warn:-serial,unusedLocals is valid
-warn:+nls is valid

unusedLocals has been left for backward compatibility.
I changed the code sample to put unusedLocal instead of unusedLocals.

I don't see what you mean by "using Sun JDK 1.4.2". If you are using ant, you should specify the compiler's name.
If you are using a command line, then simply use Eclipse batch compiler options.
We don't plan to match the Sun's options. We have many more warnings than javac.
Comment 3 Olivier Thomann CLA 2006-04-21 15:28:41 EDT
You can use this syntax:
-warn:-serial,unusedLocal
-warn:+nls

Ok to close?
Comment 4 Olivier Thomann CLA 2006-04-25 10:44:21 EDT
Closing as REMIND.
Comment 5 Nick Boldt CLA 2006-04-25 20:26:45 EDT
What I meant was that we're invoking ant using a specific value for JAVA_HOME, but I'll try your combination of multiple -warn flags with <compilerarg compiler="org.eclipse.jdt.core.JDTCompilerAdapter" .... />

Thanks for the advice!
Comment 6 Olivier Thomann CLA 2006-04-25 21:16:18 EDT
Reopen to close as INVALID since no fix has been done.
Comment 7 Olivier Thomann CLA 2006-04-25 21:18:46 EDT
Closing as LATER.
I will revisit the warning option on the command line for 3.3. I think we could improve it with a syntax like this:
-warn:-serial,unusedLocal,+nls

All options after the '-' would be disabled and all the options after the + would be enabled.
Philippe,

Do you think this is worth being investigated for 3.3?
Comment 8 Philipe Mulet CLA 2006-04-26 04:57:38 EDT
+1
Comment 9 Nick Boldt CLA 2007-07-30 18:13:04 EDT
(In reply to comment #8)
> +1

Comparing [1] and [2] it looks like this wasn't done in time for 3.3, though formatting was updated.

[1]http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm
[2]http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm

Probably not worth wasting much effort on it if no one but me has complained. ;-)

Could downgrade to INVALID or CLOSED, if you agree.
Comment 10 Denis Roy CLA 2009-08-30 02:18:35 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.