Question

I have some classes that implement interfaces, some of which have methods whose parameters are by definition unused in the particular class implementation. e.g. A "Shape" interface may define a "contains(point)" method, but my particular class defines a line, which cannot contain anything since it's 1-dimensional, so it always returns false and never uses point.

However, when I compile with GCJ, I'm assaulted with hundreds of "warning: parameter x is unused" messages.

I tried using the -Wno-all flag to disable warnings, as well as the others documented in gcj's manpage, but these have no effect. How do I instruct GCJ to not bother me with these trivial warnings?

Was it helpful?

Solution 2

Although I haven't found an option to do this directly with gcj, one workaround is to pipe the output into grep and look for the pattern "error:", and then only show that line and a few surrounding lines.

e.g. javac *.java 2>&1 | grep -B 3 -A 2 "error:"

OTHER TIPS

I've managed to disable all warnings affecting my source code using:

gcj -Wno-all -Wno-unchecked -Wno-raw *.java

You may want to add more -Wno-... flags to disable more warnings. To figure out the possible flags, I examined the body of the methods org.eclipse.jdt.internal.compiler.batch.Main.handleWarningToken and org.eclipse.jdt.internal.compiler.batch.Main.handleErrorOrWarningToken in the Eclipse Batch Compiler ecjsrc-3.5.2.zip and ecjsrc-3.8.zip.

Specify all these flags to get all warnings disabled:

-Wno-all
-Wno-allDeadCode
-Wno-allDeprecation
-Wno-allJavadoc
-Wno-allOver-ann
-Wno-all-static-method
-Wno-assertIdentifier
-Wno-boxing
-Wno-charConcat
-Wno-compareIdentical
-Wno-conditionAssign
-Wno-constructorName
-Wno-deadCode
-Wno-dep-ann
-Wno-deprecation
-Wno-discouraged
-Wno-emptyBlock
-Wno-enumIdentifier
-Wno-enumSwitch
-Wno-enumSwitchPedantic
-Wno-fallthrough
-Wno-fieldHiding
-Wno-finalBound
-Wno-finally
-Wno-forbidden
-Wno-hashCode
-Wno-hiding
-Wno-includeAssertNull
-Wno-incomplete-switch
-Wno-indirectStatic
-Wno-interfaceNonInherited
-Wno-intfAnnotation
-Wno-intfNonInherited
-Wno-intfRedundant
-Wno-javadoc
-Wno-localHiding
-Wno-maskedCatchBlock
-Wno-maskedCatchBlocks
-Wno-nls
-Wno-noEffectAssign
-Wno-noImplicitStringConversion
-Wno-null
-Wno-nullDereference
-Wno-over-ann
-Wno-over-sync
-Wno-packageDefaultMethod
-Wno-paramAssign
-Wno-pkgDefaultMethod
-Wno-raw
-Wno-redundantSuperinterface
-Wno-resource
-Wno-semicolon
-Wno-serial
-Wno-specialParamHiding
-Wno-static-access
-Wno-static-method
-Wno-staticReceiver
-Wno-super
-Wno-suppress
-Wno-switchDefault
-Wno-syncOverride
-Wno-synthetic-access
-Wno-syntheticAccess
-Wno-typeHiding
-Wno-unavoidableGenericProblems
-Wno-unchecked
-Wno-unnecessaryElse
-Wno-unqualifiedField
-Wno-unqualified-field-access
-Wno-unsafe
-Wno-unused
-Wno-unusedAllocation
-Wno-unusedArgument
-Wno-unusedArguments
-Wno-unusedImport
-Wno-unusedImports
-Wno-unusedLabel
-Wno-unusedLocal
-Wno-unusedLocals
-Wno-unusedPrivate
-Wno-unusedThrown
-Wno-unusedTypeArgs
-Wno-uselessTypeCheck
-Wno-varargsCast
-Wno-warningToken
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top