2010-01-13 118 views
2

我有一些类实现接口,其中一些类的方法参数在特定的类实现中没有被使用。例如一个“Shape”接口可以定义一个“contains(point)”方法,但是我的特定类定义了一行,因为它是一维的,所以它不能包含任何东西,所以它总是返回false并且从不使用point。如何忽略使用GCJ的警告

但是,当我用GCJ进行编译时,我遇到了数百个“警告:参数x未使用”消息的攻击。

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

回答

1

尽管我没有找到直接使用gcj执行此操作的选项,但一种解决方法是将输出传输到grep并查找模式“error:”,然后仅显示该行和几条周围行。

例如 javac * .java 2> & 1 |的grep -B 3 -A 2“错误:”

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