如何忽略GCJ的警告

时间:2010-01-13 15:25:45

标签: java compiler-warnings gcj

我有一些实现接口的类,其中一些方法的参数根据定义在特定的类实现中未使用。例如“Shape”接口可以定义“contains(point)”方法,但我的特定类定义了一条线,由于它是1维的,因此它不能包含任何内容,因此它总是返回false并且从不使用point。

然而,当我使用GCJ进行编译时,我遭到了数百次“警告:参数x未使用”消息的攻击。<​​/ p>

我尝试使用-Wno-all标志来禁用警告,以及gcj的联机帮助页中记录的其他警告,但这些都没有效果。我如何指示GCJ不要因这些琐碎的警告而烦扰我?

2 个答案:

答案 0 :(得分:2)

我设法使用以下方法禁用所有影响我源代码的警告:

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

您可能希望添加更多-Wno-...标记以禁用更多警告。为了找出可能的标志,我检查了Eclipse批处理编译器中方法org.eclipse.jdt.internal.compiler.batch.Main.handleWarningToken和org.eclipse.jdt.internal.compiler.batch.Main.handleErrorOrWarningToken方法的主体。 ecjsrc-3.5.2.zipecjsrc-3.8.zip

指定所有这些标志以禁用所有警告:

-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

答案 1 :(得分:1)

虽然我没有找到直接使用gcj执行此操作的选项,但一种解决方法是将输出通过管道传输到grep并查找模式“error:”,然后只显示该行和一些周围的行。 / p>

e.g。 javac * .java 2&gt;&amp; 1 | grep -B 3 -A 2“错误:”

相关问题