Why does Eclipse warn about Java "unused variables" but javac doesn't?

For the same code, Eclipse shows warnings about unused variables, but compilation with "javac" (v1.6) fails. Is Eclipse using a different compiler or parser? How can I get javac to display the same warnings?

+3


source to share


5 answers


Quoting from JDT Core (Eclipse Editor Framework)

JDT Core is a Java IDE framework. It includes:

Java incremental compiler. Implemented as an Eclipse builder, it is based on technology developed from VisualAge for the Java compiler. In particular, it allows you to run and debug code that still contains unresolved errors.



This is an incremental java compiler that shows waraning.

Cannot enable this warning in Sun / Oracle javac

+5


source


Eclipse uses its own compiler. You can enable / disable various messages by going to Window-> Preferences-> Java-> Compiler-> Errors / Warnings.



+6


source


From the javadoc:

-Xlint Turn on all recommended warnings. We recommend that you use all available warnings in this release.

And yes, eclispe uses its own compiler

+3


source


This is a native Eclipse functionality.

+2


source


This is part of the validation in eclipse. If you want your own rules to be similar to what eclipse does, you can use something like PMD.

http://pmd.sourceforge.net/rules/unusedcode.html

+2


source







All Articles