1 11 package org.eclipse.jdt.internal.compiler.impl; 12 13 import java.io.ByteArrayInputStream ; 14 import java.io.InputStreamReader ; 15 import java.io.UnsupportedEncodingException ; 16 import java.util.HashMap ; 17 import java.util.Map ; 18 19 import org.eclipse.jdt.core.compiler.CharOperation; 20 import org.eclipse.jdt.internal.compiler.Compiler; 21 import org.eclipse.jdt.internal.compiler.ast.ASTNode; 22 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; 23 import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; 24 import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; 25 import org.eclipse.jdt.internal.compiler.util.Util; 26 27 public class CompilerOptions { 28 29 32 public static final String OPTION_LocalVariableAttribute = "org.eclipse.jdt.core.compiler.debug.localVariable"; public static final String OPTION_LineNumberAttribute = "org.eclipse.jdt.core.compiler.debug.lineNumber"; public static final String OPTION_SourceFileAttribute = "org.eclipse.jdt.core.compiler.debug.sourceFile"; public static final String OPTION_PreserveUnusedLocal = "org.eclipse.jdt.core.compiler.codegen.unusedLocal"; public static final String OPTION_DocCommentSupport= "org.eclipse.jdt.core.compiler.doc.comment.support"; public static final String OPTION_ReportMethodWithConstructorName = "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"; public static final String OPTION_ReportOverridingPackageDefaultMethod = "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"; public static final String OPTION_ReportDeprecation = "org.eclipse.jdt.core.compiler.problem.deprecation"; public static final String OPTION_ReportDeprecationInDeprecatedCode = "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"; public static final String OPTION_ReportDeprecationWhenOverridingDeprecatedMethod = "org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod"; public static final String OPTION_ReportHiddenCatchBlock = "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"; public static final String OPTION_ReportUnusedLocal = "org.eclipse.jdt.core.compiler.problem.unusedLocal"; public static final String OPTION_ReportUnusedParameter = "org.eclipse.jdt.core.compiler.problem.unusedParameter"; public static final String OPTION_ReportUnusedParameterWhenImplementingAbstract = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"; public static final String OPTION_ReportUnusedParameterWhenOverridingConcrete = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"; public static final String OPTION_ReportUnusedParameterIncludeDocCommentReference = "org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference"; public static final String OPTION_ReportUnusedImport = "org.eclipse.jdt.core.compiler.problem.unusedImport"; public static final String OPTION_ReportSyntheticAccessEmulation = "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"; public static final String OPTION_ReportNoEffectAssignment = "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"; public static final String OPTION_ReportLocalVariableHiding = "org.eclipse.jdt.core.compiler.problem.localVariableHiding"; public static final String OPTION_ReportSpecialParameterHidingField = "org.eclipse.jdt.core.compiler.problem.specialParameterHidingField"; public static final String OPTION_ReportFieldHiding = "org.eclipse.jdt.core.compiler.problem.fieldHiding"; public static final String OPTION_ReportTypeParameterHiding = "org.eclipse.jdt.core.compiler.problem.typeParameterHiding"; public static final String OPTION_ReportPossibleAccidentalBooleanAssignment = "org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment"; public static final String OPTION_ReportNonExternalizedStringLiteral = "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"; public static final String OPTION_ReportIncompatibleNonInheritedInterfaceMethod = "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"; public static final String OPTION_ReportUnusedPrivateMember = "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"; public static final String OPTION_ReportNoImplicitStringConversion = "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"; public static final String OPTION_ReportAssertIdentifier = "org.eclipse.jdt.core.compiler.problem.assertIdentifier"; public static final String OPTION_ReportEnumIdentifier = "org.eclipse.jdt.core.compiler.problem.enumIdentifier"; public static final String OPTION_ReportNonStaticAccessToStatic = "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"; public static final String OPTION_ReportIndirectStaticAccess = "org.eclipse.jdt.core.compiler.problem.indirectStaticAccess"; public static final String OPTION_ReportEmptyStatement = "org.eclipse.jdt.core.compiler.problem.emptyStatement"; public static final String OPTION_ReportUnnecessaryTypeCheck = "org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck"; public static final String OPTION_ReportUnnecessaryElse = "org.eclipse.jdt.core.compiler.problem.unnecessaryElse"; public static final String OPTION_ReportUndocumentedEmptyBlock = "org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock"; public static final String OPTION_ReportInvalidJavadoc = "org.eclipse.jdt.core.compiler.problem.invalidJavadoc"; public static final String OPTION_ReportInvalidJavadocTags = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTags"; public static final String OPTION_ReportInvalidJavadocTagsDeprecatedRef = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef"; public static final String OPTION_ReportInvalidJavadocTagsNotVisibleRef = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef"; public static final String OPTION_ReportInvalidJavadocTagsVisibility = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility"; public static final String OPTION_ReportMissingJavadocTags = "org.eclipse.jdt.core.compiler.problem.missingJavadocTags"; public static final String OPTION_ReportMissingJavadocTagsVisibility = "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility"; public static final String OPTION_ReportMissingJavadocTagsOverriding = "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding"; public static final String OPTION_ReportMissingJavadocComments = "org.eclipse.jdt.core.compiler.problem.missingJavadocComments"; public static final String OPTION_ReportMissingJavadocCommentsVisibility = "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility"; public static final String OPTION_ReportMissingJavadocCommentsOverriding = "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding"; public static final String OPTION_ReportFinallyBlockNotCompletingNormally = "org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally"; public static final String OPTION_ReportUnusedDeclaredThrownException = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException"; public static final String OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding"; public static final String OPTION_ReportUnqualifiedFieldAccess = "org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess"; public static final String OPTION_ReportUncheckedTypeOperation = "org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation"; public static final String OPTION_ReportRawTypeReference = "org.eclipse.jdt.core.compiler.problem.rawTypeReference"; public static final String OPTION_ReportFinalParameterBound = "org.eclipse.jdt.core.compiler.problem.finalParameterBound"; public static final String OPTION_ReportMissingSerialVersion = "org.eclipse.jdt.core.compiler.problem.missingSerialVersion"; public static final String OPTION_ReportVarargsArgumentNeedCast = "org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast"; public static final String OPTION_Source = "org.eclipse.jdt.core.compiler.source"; public static final String OPTION_TargetPlatform = "org.eclipse.jdt.core.compiler.codegen.targetPlatform"; public static final String OPTION_Compliance = "org.eclipse.jdt.core.compiler.compliance"; public static final String OPTION_Encoding = "org.eclipse.jdt.core.encoding"; public static final String OPTION_MaxProblemPerUnit = "org.eclipse.jdt.core.compiler.maxProblemPerUnit"; public static final String OPTION_TaskTags = "org.eclipse.jdt.core.compiler.taskTags"; public static final String OPTION_TaskPriorities = "org.eclipse.jdt.core.compiler.taskPriorities"; public static final String OPTION_TaskCaseSensitive = "org.eclipse.jdt.core.compiler.taskCaseSensitive"; public static final String OPTION_InlineJsr = "org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode"; public static final String OPTION_ReportNullReference = "org.eclipse.jdt.core.compiler.problem.nullReference"; public static final String OPTION_ReportPotentialNullReference = "org.eclipse.jdt.core.compiler.problem.potentialNullReference"; public static final String OPTION_ReportRedundantNullCheck = "org.eclipse.jdt.core.compiler.problem.redundantNullCheck"; public static final String OPTION_ReportAutoboxing = "org.eclipse.jdt.core.compiler.problem.autoboxing"; public static final String OPTION_ReportAnnotationSuperInterface = "org.eclipse.jdt.core.compiler.problem.annotationSuperInterface"; public static final String OPTION_ReportMissingOverrideAnnotation = "org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation"; public static final String OPTION_ReportMissingDeprecatedAnnotation = "org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation"; public static final String OPTION_ReportIncompleteEnumSwitch = "org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch"; public static final String OPTION_ReportForbiddenReference = "org.eclipse.jdt.core.compiler.problem.forbiddenReference"; public static final String OPTION_ReportDiscouragedReference = "org.eclipse.jdt.core.compiler.problem.discouragedReference"; public static final String OPTION_SuppressWarnings = "org.eclipse.jdt.core.compiler.problem.suppressWarnings"; public static final String OPTION_ReportUnhandledWarningToken = "org.eclipse.jdt.core.compiler.problem.unhandledWarningToken"; public static final String OPTION_ReportUnusedLabel = "org.eclipse.jdt.core.compiler.problem.unusedLabel"; public static final String OPTION_FatalOptionalError = "org.eclipse.jdt.core.compiler.problem.fatalOptionalError"; public static final String OPTION_ReportParameterAssignment = "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; public static final String OPTION_ReportFallthroughCase = "org.eclipse.jdt.core.compiler.problem.fallthroughCase"; public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation = "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; public static final String OPTION_GenerateClassFiles = "org.eclipse.jdt.core.compiler.generateClassFiles"; public static final String OPTION_Process_Annotations = "org.eclipse.jdt.core.compiler.processAnnotations"; 117 public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; public static final String OPTION_ReportMissingAnnotation = "org.eclipse.jdt.core.compiler.problem.missingAnnotation"; public static final String OPTION_ReportMissingJavadoc = "org.eclipse.jdt.core.compiler.problem.missingJavadoc"; 122 125 public static final String GENERATE = "generate"; public static final String DO_NOT_GENERATE = "do not generate"; public static final String PRESERVE = "preserve"; public static final String OPTIMIZE_OUT = "optimize out"; public static final String VERSION_1_1 = "1.1"; public static final String VERSION_1_2 = "1.2"; public static final String VERSION_1_3 = "1.3"; public static final String VERSION_1_4 = "1.4"; public static final String VERSION_JSR14 = "jsr14"; public static final String VERSION_1_5 = "1.5"; public static final String VERSION_1_6 = "1.6"; public static final String VERSION_1_7 = "1.7"; public static final String ERROR = "error"; public static final String WARNING = "warning"; public static final String IGNORE = "ignore"; public static final String ENABLED = "enabled"; public static final String DISABLED = "disabled"; public static final String PUBLIC = "public"; public static final String PROTECTED = "protected"; public static final String DEFAULT = "default"; public static final String PRIVATE = "private"; 147 150 public static final long MethodWithConstructorName = ASTNode.Bit1; 151 public static final long OverriddenPackageDefaultMethod = ASTNode.Bit2; 152 public static final long UsingDeprecatedAPI = ASTNode.Bit3; 153 public static final long MaskedCatchBlock = ASTNode.Bit4; 154 public static final long UnusedLocalVariable = ASTNode.Bit5; 155 public static final long UnusedArgument = ASTNode.Bit6; 156 public static final long NoImplicitStringConversion = ASTNode.Bit7; 157 public static final long AccessEmulation = ASTNode.Bit8; 158 public static final long NonExternalizedString = ASTNode.Bit9; 159 public static final long AssertUsedAsAnIdentifier = ASTNode.Bit10; 160 public static final long UnusedImport = ASTNode.Bit11; 161 public static final long NonStaticAccessToStatic = ASTNode.Bit12; 162 public static final long Task = ASTNode.Bit13; 163 public static final long NoEffectAssignment = ASTNode.Bit14; 164 public static final long IncompatibleNonInheritedInterfaceMethod = ASTNode.Bit15; 165 public static final long UnusedPrivateMember = ASTNode.Bit16; 166 public static final long LocalVariableHiding = ASTNode.Bit17; 167 public static final long FieldHiding = ASTNode.Bit18; 168 public static final long AccidentalBooleanAssign = ASTNode.Bit19; 169 public static final long EmptyStatement = ASTNode.Bit20; 170 public static final long MissingJavadocComments = ASTNode.Bit21; 171 public static final long MissingJavadocTags = ASTNode.Bit22; 172 public static final long UnqualifiedFieldAccess = ASTNode.Bit23; 173 public static final long UnusedDeclaredThrownException = ASTNode.Bit24; 174 public static final long FinallyBlockNotCompleting = ASTNode.Bit25; 175 public static final long InvalidJavadoc = ASTNode.Bit26; 176 public static final long UnnecessaryTypeCheck = ASTNode.Bit27; 177 public static final long UndocumentedEmptyBlock = ASTNode.Bit28; 178 public static final long IndirectStaticAccess = ASTNode.Bit29; 179 public static final long UnnecessaryElse = ASTNode.Bit30; 180 public static final long UncheckedTypeOperation = ASTNode.Bit31; 181 public static final long FinalParameterBound = ASTNode.Bit32L; 182 public static final long MissingSerialVersion = ASTNode.Bit33L; 183 public static final long EnumUsedAsAnIdentifier = ASTNode.Bit34L; 184 public static final long ForbiddenReference = ASTNode.Bit35L; 185 public static final long VarargsArgumentNeedCast = ASTNode.Bit36L; 186 public static final long NullReference = ASTNode.Bit37L; 187 public static final long AutoBoxing = ASTNode.Bit38L; 188 public static final long AnnotationSuperInterface = ASTNode.Bit39L; 189 public static final long TypeHiding = ASTNode.Bit40L; 190 public static final long MissingOverrideAnnotation = ASTNode.Bit41L; 191 public static final long IncompleteEnumSwitch = ASTNode.Bit42L; 192 public static final long MissingDeprecatedAnnotation = ASTNode.Bit43L; 193 public static final long DiscouragedReference = ASTNode.Bit44L; 194 public static final long UnhandledWarningToken = ASTNode.Bit45L; 195 public static final long RawTypeReference = ASTNode.Bit46L; 196 public static final long UnusedLabel = ASTNode.Bit47L; 197 public static final long ParameterAssignment = ASTNode.Bit48L; 198 public static final long FallthroughCase = ASTNode.Bit49L; 199 public static final long OverridingMethodWithoutSuperInvocation = ASTNode.Bit50L; 200 public static final long PotentialNullReference = ASTNode.Bit51L; 201 public static final long RedundantNullCheck = ASTNode.Bit52L; 202 203 private static Map OptionToIrritants; 205 206 public long errorThreshold = 0; 208 209 public long warningThreshold = 210 MethodWithConstructorName 211 | UsingDeprecatedAPI 212 | MaskedCatchBlock 213 | OverriddenPackageDefaultMethod 214 | UnusedImport 215 | NonStaticAccessToStatic 216 | NoEffectAssignment 217 | IncompatibleNonInheritedInterfaceMethod 218 | NoImplicitStringConversion 219 | FinallyBlockNotCompleting 220 | AssertUsedAsAnIdentifier 221 | EnumUsedAsAnIdentifier 222 | UncheckedTypeOperation 223 | RawTypeReference 224 | MissingSerialVersion 225 | VarargsArgumentNeedCast 226 | ForbiddenReference 227 | DiscouragedReference 228 | AnnotationSuperInterface 229 | TypeHiding 230 | FinalParameterBound 231 | UnhandledWarningToken 232 | UnusedLocalVariable 233 | UnusedPrivateMember 234 | UnusedLabel 235 ; 236 237 public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES; 239 240 public long complianceLevel = ClassFileConstants.JDK1_4; public long sourceLevel = ClassFileConstants.JDK1_3; public long targetJDK = ClassFileConstants.JDK1_2; 244 public String defaultEncoding = null; 247 public boolean verbose = Compiler.DEBUG; 249 250 public boolean produceReferenceInfo = false; 252 253 public boolean preserveAllLocalVariables = false; 255 256 public boolean parseLiteralExpressionsAsConstants = true; 258 259 public int maxProblemsPerUnit = 100; 262 public char[][] taskTags = null; 264 public char[][] taskPriorites = null; 265 public boolean isTaskCaseSensitive = true; 266 267 public boolean reportDeprecationInsideDeprecatedCode = false; 269 public boolean reportDeprecationWhenOverridingDeprecatedMethod = false; 270 271 public boolean reportUnusedParameterWhenImplementingAbstract = false; 273 public boolean reportUnusedParameterWhenOverridingConcrete = false; 274 public boolean reportUnusedParameterIncludeDocCommentReference = true; 275 276 public boolean reportUnusedDeclaredThrownExceptionWhenOverriding = false; 278 279 public boolean reportSpecialParameterHidingField = false; 281 282 public int reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic; 284 public boolean reportInvalidJavadocTags = false; 285 public boolean reportInvalidJavadocTagsDeprecatedRef = false; 286 public boolean reportInvalidJavadocTagsNotVisibleRef = false; 287 288 public int reportMissingJavadocTagsVisibility = ClassFileConstants.AccPublic; 290 public boolean reportMissingJavadocTagsOverriding = false; 291 292 public int reportMissingJavadocCommentsVisibility = ClassFileConstants.AccPublic; 294 public boolean reportMissingJavadocCommentsOverriding = false; 295 296 public boolean inlineJsrBytecode = false; 298 299 public boolean docCommentSupport = false; 301 302 public boolean suppressWarnings = true; 304 305 public boolean treatOptionalErrorAsFatal = true; 307 308 public boolean performMethodsFullRecovery = true; 310 311 public boolean performStatementsRecovery = true; 313 314 public boolean storeAnnotations = false; 316 317 public boolean generateClassFiles = true; 319 320 public boolean processAnnotations = false; 322 323 326 public CompilerOptions(){ 327 } 329 330 334 public CompilerOptions(Map settings){ 335 336 if (settings == null) return; 337 set(settings); 338 } 339 340 343 public CompilerOptions(Map settings, boolean parseLiteralExpressionsAsConstants){ 344 this(settings); 345 this.parseLiteralExpressionsAsConstants = parseLiteralExpressionsAsConstants; 346 } 347 348 public Map getMap() { 349 Map optionsMap = new HashMap (30); 350 optionsMap.put(OPTION_LocalVariableAttribute, (this.produceDebugAttributes & ClassFileConstants.ATTR_VARS) != 0 ? GENERATE : DO_NOT_GENERATE); 351 optionsMap.put(OPTION_LineNumberAttribute, (this.produceDebugAttributes & ClassFileConstants.ATTR_LINES) != 0 ? GENERATE : DO_NOT_GENERATE); 352 optionsMap.put(OPTION_SourceFileAttribute, (this.produceDebugAttributes & ClassFileConstants.ATTR_SOURCE) != 0 ? GENERATE : DO_NOT_GENERATE); 353 optionsMap.put(OPTION_PreserveUnusedLocal, this.preserveAllLocalVariables ? PRESERVE : OPTIMIZE_OUT); 354 optionsMap.put(OPTION_DocCommentSupport, this.docCommentSupport ? ENABLED : DISABLED); 355 optionsMap.put(OPTION_ReportMethodWithConstructorName, getSeverityString(MethodWithConstructorName)); 356 optionsMap.put(OPTION_ReportOverridingPackageDefaultMethod, getSeverityString(OverriddenPackageDefaultMethod)); 357 optionsMap.put(OPTION_ReportDeprecation, getSeverityString(UsingDeprecatedAPI)); 358 optionsMap.put(OPTION_ReportDeprecationInDeprecatedCode, this.reportDeprecationInsideDeprecatedCode ? ENABLED : DISABLED); 359 optionsMap.put(OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, this.reportDeprecationWhenOverridingDeprecatedMethod ? ENABLED : DISABLED); 360 optionsMap.put(OPTION_ReportHiddenCatchBlock, getSeverityString(MaskedCatchBlock)); 361 optionsMap.put(OPTION_ReportUnusedLocal, getSeverityString(UnusedLocalVariable)); 362 optionsMap.put(OPTION_ReportUnusedParameter, getSeverityString(UnusedArgument)); 363 optionsMap.put(OPTION_ReportUnusedImport, getSeverityString(UnusedImport)); 364 optionsMap.put(OPTION_ReportSyntheticAccessEmulation, getSeverityString(AccessEmulation)); 365 optionsMap.put(OPTION_ReportNoEffectAssignment, getSeverityString(NoEffectAssignment)); 366 optionsMap.put(OPTION_ReportNonExternalizedStringLiteral, getSeverityString(NonExternalizedString)); 367 optionsMap.put(OPTION_ReportNoImplicitStringConversion, getSeverityString(NoImplicitStringConversion)); 368 optionsMap.put(OPTION_ReportNonStaticAccessToStatic, getSeverityString(NonStaticAccessToStatic)); 369 optionsMap.put(OPTION_ReportIndirectStaticAccess, getSeverityString(IndirectStaticAccess)); 370 optionsMap.put(OPTION_ReportIncompatibleNonInheritedInterfaceMethod, getSeverityString(IncompatibleNonInheritedInterfaceMethod)); 371 optionsMap.put(OPTION_ReportUnusedPrivateMember, getSeverityString(UnusedPrivateMember)); 372 optionsMap.put(OPTION_ReportLocalVariableHiding, getSeverityString(LocalVariableHiding)); 373 optionsMap.put(OPTION_ReportFieldHiding, getSeverityString(FieldHiding)); 374 optionsMap.put(OPTION_ReportTypeParameterHiding, getSeverityString(TypeHiding)); 375 optionsMap.put(OPTION_ReportPossibleAccidentalBooleanAssignment, getSeverityString(AccidentalBooleanAssign)); 376 optionsMap.put(OPTION_ReportEmptyStatement, getSeverityString(EmptyStatement)); 377 optionsMap.put(OPTION_ReportAssertIdentifier, getSeverityString(AssertUsedAsAnIdentifier)); 378 optionsMap.put(OPTION_ReportEnumIdentifier, getSeverityString(EnumUsedAsAnIdentifier)); 379 optionsMap.put(OPTION_ReportUndocumentedEmptyBlock, getSeverityString(UndocumentedEmptyBlock)); 380 optionsMap.put(OPTION_ReportUnnecessaryTypeCheck, getSeverityString(UnnecessaryTypeCheck)); 381 optionsMap.put(OPTION_ReportUnnecessaryElse, getSeverityString(UnnecessaryElse)); 382 optionsMap.put(OPTION_ReportAutoboxing, getSeverityString(AutoBoxing)); 383 optionsMap.put(OPTION_ReportAnnotationSuperInterface, getSeverityString(AnnotationSuperInterface)); 384 optionsMap.put(OPTION_ReportIncompleteEnumSwitch, getSeverityString(IncompleteEnumSwitch)); 385 optionsMap.put(OPTION_ReportInvalidJavadoc, getSeverityString(InvalidJavadoc)); 386 optionsMap.put(OPTION_ReportInvalidJavadocTagsVisibility, getVisibilityString(this.reportInvalidJavadocTagsVisibility)); 387 optionsMap.put(OPTION_ReportInvalidJavadocTags, this.reportInvalidJavadocTags ? ENABLED : DISABLED); 388 optionsMap.put(OPTION_ReportInvalidJavadocTagsDeprecatedRef, this.reportInvalidJavadocTagsDeprecatedRef ? ENABLED : DISABLED); 389 optionsMap.put(OPTION_ReportInvalidJavadocTagsNotVisibleRef, this.reportInvalidJavadocTagsNotVisibleRef ? ENABLED : DISABLED); 390 optionsMap.put(OPTION_ReportMissingJavadocTags, getSeverityString(MissingJavadocTags)); 391 optionsMap.put(OPTION_ReportMissingJavadocTagsVisibility, getVisibilityString(this.reportMissingJavadocTagsVisibility)); 392 optionsMap.put(OPTION_ReportMissingJavadocTagsOverriding, this.reportMissingJavadocTagsOverriding ? ENABLED : DISABLED); 393 optionsMap.put(OPTION_ReportMissingJavadocComments, getSeverityString(MissingJavadocComments)); 394 optionsMap.put(OPTION_ReportMissingJavadocCommentsVisibility, getVisibilityString(this.reportMissingJavadocCommentsVisibility)); 395 optionsMap.put(OPTION_ReportMissingJavadocCommentsOverriding, this.reportMissingJavadocCommentsOverriding ? ENABLED : DISABLED); 396 optionsMap.put(OPTION_ReportFinallyBlockNotCompletingNormally, getSeverityString(FinallyBlockNotCompleting)); 397 optionsMap.put(OPTION_ReportUnusedDeclaredThrownException, getSeverityString(UnusedDeclaredThrownException)); 398 optionsMap.put(OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding, this.reportUnusedDeclaredThrownExceptionWhenOverriding ? ENABLED : DISABLED); 399 optionsMap.put(OPTION_ReportUnqualifiedFieldAccess, getSeverityString(UnqualifiedFieldAccess)); 400 optionsMap.put(OPTION_ReportUncheckedTypeOperation, getSeverityString(UncheckedTypeOperation)); 401 optionsMap.put(OPTION_ReportRawTypeReference, getSeverityString(RawTypeReference)); 402 optionsMap.put(OPTION_ReportFinalParameterBound, getSeverityString(FinalParameterBound)); 403 optionsMap.put(OPTION_ReportMissingSerialVersion, getSeverityString(MissingSerialVersion)); 404 optionsMap.put(OPTION_ReportForbiddenReference, getSeverityString(ForbiddenReference)); 405 optionsMap.put(OPTION_ReportDiscouragedReference, getSeverityString(DiscouragedReference)); 406 optionsMap.put(OPTION_ReportVarargsArgumentNeedCast, getSeverityString(VarargsArgumentNeedCast)); 407 optionsMap.put(OPTION_ReportMissingOverrideAnnotation, getSeverityString(MissingOverrideAnnotation)); 408 optionsMap.put(OPTION_ReportMissingDeprecatedAnnotation, getSeverityString(MissingDeprecatedAnnotation)); 409 optionsMap.put(OPTION_ReportIncompleteEnumSwitch, getSeverityString(IncompleteEnumSwitch)); 410 optionsMap.put(OPTION_ReportUnusedLabel, getSeverityString(UnusedLabel)); 411 optionsMap.put(OPTION_Compliance, versionFromJdkLevel(this.complianceLevel)); 412 optionsMap.put(OPTION_Source, versionFromJdkLevel(this.sourceLevel)); 413 optionsMap.put(OPTION_TargetPlatform, versionFromJdkLevel(this.targetJDK)); 414 optionsMap.put(OPTION_FatalOptionalError, this.treatOptionalErrorAsFatal ? ENABLED : DISABLED); 415 if (this.defaultEncoding != null) { 416 optionsMap.put(OPTION_Encoding, this.defaultEncoding); 417 } 418 optionsMap.put(OPTION_TaskTags, this.taskTags == null ? Util.EMPTY_STRING : new String (CharOperation.concatWith(this.taskTags,','))); 419 optionsMap.put(OPTION_TaskPriorities, this.taskPriorites == null ? Util.EMPTY_STRING : new String (CharOperation.concatWith(this.taskPriorites,','))); 420 optionsMap.put(OPTION_TaskCaseSensitive, this.isTaskCaseSensitive ? ENABLED : DISABLED); 421 optionsMap.put(OPTION_ReportUnusedParameterWhenImplementingAbstract, this.reportUnusedParameterWhenImplementingAbstract ? ENABLED : DISABLED); 422 optionsMap.put(OPTION_ReportUnusedParameterWhenOverridingConcrete, this.reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED); 423 optionsMap.put(OPTION_ReportUnusedParameterIncludeDocCommentReference, this.reportUnusedParameterIncludeDocCommentReference ? ENABLED : DISABLED); 424 optionsMap.put(OPTION_ReportSpecialParameterHidingField, this.reportSpecialParameterHidingField ? ENABLED : DISABLED); 425 optionsMap.put(OPTION_MaxProblemPerUnit, String.valueOf(this.maxProblemsPerUnit)); 426 optionsMap.put(OPTION_InlineJsr, this.inlineJsrBytecode ? ENABLED : DISABLED); 427 optionsMap.put(OPTION_ReportNullReference, getSeverityString(NullReference)); 428 optionsMap.put(OPTION_ReportPotentialNullReference, getSeverityString(PotentialNullReference)); 429 optionsMap.put(OPTION_ReportRedundantNullCheck, getSeverityString(RedundantNullCheck)); 430 optionsMap.put(OPTION_SuppressWarnings, this.suppressWarnings ? ENABLED : DISABLED); 431 optionsMap.put(OPTION_ReportUnhandledWarningToken, getSeverityString(UnhandledWarningToken)); 432 optionsMap.put(OPTION_ReportParameterAssignment, getSeverityString(ParameterAssignment)); 433 optionsMap.put(OPTION_ReportFallthroughCase, getSeverityString(FallthroughCase)); 434 optionsMap.put(OPTION_ReportOverridingMethodWithoutSuperInvocation, getSeverityString(OverridingMethodWithoutSuperInvocation)); 435 optionsMap.put(OPTION_GenerateClassFiles, this.generateClassFiles ? ENABLED : DISABLED); 436 optionsMap.put(OPTION_Process_Annotations, this.processAnnotations ? ENABLED : DISABLED); 437 return optionsMap; 438 } 439 440 445 public static String optionKeyFromIrritant(long irritant) { 446 int irritantInt = (int) irritant; 448 if (irritantInt == irritant) { 449 switch (irritantInt) { 450 case (int) MethodWithConstructorName : 451 return OPTION_ReportMethodWithConstructorName; 452 case (int) OverriddenPackageDefaultMethod : 453 return OPTION_ReportOverridingPackageDefaultMethod; 454 case (int) UsingDeprecatedAPI : 455 case (int) (InvalidJavadoc | UsingDeprecatedAPI) : 456 return OPTION_ReportDeprecation; 457 case (int) MaskedCatchBlock : 458 return OPTION_ReportHiddenCatchBlock; 459 case (int) UnusedLocalVariable : 460 return OPTION_ReportUnusedLocal; 461 case (int) UnusedArgument : 462 return OPTION_ReportUnusedParameter; 463 case (int) NoImplicitStringConversion : 464 return OPTION_ReportNoImplicitStringConversion; 465 case (int) AccessEmulation : 466 return OPTION_ReportSyntheticAccessEmulation; 467 case (int) NonExternalizedString : 468 return OPTION_ReportNonExternalizedStringLiteral; 469 case (int) AssertUsedAsAnIdentifier : 470 return OPTION_ReportAssertIdentifier; 471 case (int) UnusedImport : 472 return OPTION_ReportUnusedImport; 473 case (int) NonStaticAccessToStatic : 474 return OPTION_ReportNonStaticAccessToStatic; 475 case (int) Task : 476 return OPTION_TaskTags; 477 case (int) NoEffectAssignment : 478 return OPTION_ReportNoEffectAssignment; 479 case (int) IncompatibleNonInheritedInterfaceMethod : 480 return OPTION_ReportIncompatibleNonInheritedInterfaceMethod; 481 case (int) UnusedPrivateMember : 482 return OPTION_ReportUnusedPrivateMember; 483 case (int) LocalVariableHiding : 484 return OPTION_ReportLocalVariableHiding; 485 case (int) FieldHiding : 486 return OPTION_ReportFieldHiding; 487 case (int) AccidentalBooleanAssign : 488 return OPTION_ReportPossibleAccidentalBooleanAssignment; 489 case (int) EmptyStatement : 490 return OPTION_ReportEmptyStatement; 491 case (int) MissingJavadocComments : 492 return OPTION_ReportMissingJavadocComments; 493 case (int) MissingJavadocTags : 494 return OPTION_ReportMissingJavadocTags; 495 case (int) UnqualifiedFieldAccess : 496 return OPTION_ReportUnqualifiedFieldAccess; 497 case (int) UnusedDeclaredThrownException : 498 return OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding; 499 case (int) FinallyBlockNotCompleting : 500 return OPTION_ReportFinallyBlockNotCompletingNormally; 501 case (int) InvalidJavadoc : 502 return OPTION_ReportInvalidJavadoc; 503 case (int) UnnecessaryTypeCheck : 504 return OPTION_ReportUnnecessaryTypeCheck; 505 case (int) UndocumentedEmptyBlock : 506 return OPTION_ReportUndocumentedEmptyBlock; 507 case (int) IndirectStaticAccess : 508 return OPTION_ReportIndirectStaticAccess; 509 case (int) UnnecessaryElse : 510 return OPTION_ReportUnnecessaryElse; 511 case (int) UncheckedTypeOperation : 512 return OPTION_ReportUncheckedTypeOperation; 513 case (int) FinalParameterBound : 514 return OPTION_ReportFinalParameterBound; 515 } 516 } else { 517 irritantInt = (int)(irritant >>> 32); 518 switch (irritantInt) { 519 case (int)(MissingSerialVersion >>> 32) : 520 return OPTION_ReportMissingSerialVersion ; 521 case (int)(EnumUsedAsAnIdentifier >>> 32) : 522 return OPTION_ReportEnumIdentifier; 523 case (int)(ForbiddenReference >>> 32) : 524 return OPTION_ReportForbiddenReference; 525 case (int)(VarargsArgumentNeedCast >>> 32) : 526 return OPTION_ReportVarargsArgumentNeedCast; 527 case (int)(NullReference >>> 32) : 528 return OPTION_ReportNullReference; 529 case (int)(PotentialNullReference >>> 32) : 530 return OPTION_ReportPotentialNullReference; 531 case (int)(RedundantNullCheck >>> 32) : 532 return OPTION_ReportRedundantNullCheck; 533 case (int)(AutoBoxing >>> 32) : 534 return OPTION_ReportAutoboxing; 535 case (int)(AnnotationSuperInterface >>> 32) : 536 return OPTION_ReportAnnotationSuperInterface; 537 case (int)(TypeHiding >>> 32) : 538 return OPTION_ReportTypeParameterHiding; 539 case (int)(MissingOverrideAnnotation >>> 32) : 540 return OPTION_ReportMissingOverrideAnnotation; 541 case (int)(IncompleteEnumSwitch >>> 32) : 542 return OPTION_ReportIncompleteEnumSwitch; 543 case (int)(MissingDeprecatedAnnotation >>> 32) : 544 return OPTION_ReportMissingDeprecatedAnnotation; 545 case (int)(DiscouragedReference >>> 32) : 546 return OPTION_ReportDiscouragedReference; 547 case (int)(UnhandledWarningToken >>> 32) : 548 return OPTION_ReportUnhandledWarningToken; 549 case (int)(RawTypeReference >>> 32) : 550 return OPTION_ReportRawTypeReference; 551 case (int)(UnusedLabel >>> 32) : 552 return OPTION_ReportUnusedLabel; 553 case (int)(ParameterAssignment>>> 32) : 554 return OPTION_ReportParameterAssignment; 555 case (int)(FallthroughCase >>> 32) : 556 return OPTION_ReportFallthroughCase; 557 case (int)(OverridingMethodWithoutSuperInvocation >>> 32) : 558 return OPTION_ReportOverridingMethodWithoutSuperInvocation; 559 } 560 } 561 return null; 562 } 563 564 public static long optionKeyToIrritant(String optionName) { 565 if (OptionToIrritants == null) { 566 long irritant = 0; 567 for (int i = 0; i < 64; i++) { 568 irritant <<= 1; 569 String optionKey = optionKeyFromIrritant(irritant); 570 if (optionKey == null) continue; 571 OptionToIrritants.put(optionKey, new Long (irritant)); 572 } 573 } 574 Long irritant = (Long )OptionToIrritants.get(optionName); 575 return irritant == null ? 0 : irritant.longValue(); 576 } 577 578 public int getSeverity(long irritant) { 579 if((this.errorThreshold & irritant) != 0) { 580 return this.treatOptionalErrorAsFatal 581 ? ProblemSeverities.Error | ProblemSeverities.Optional | ProblemSeverities.Fatal 582 : ProblemSeverities.Error | ProblemSeverities.Optional; 583 } 584 if((this.warningThreshold & irritant) != 0) 585 return ProblemSeverities.Warning | ProblemSeverities.Optional; 586 return ProblemSeverities.Ignore; 587 } 588 589 public String getSeverityString(long irritant) { 590 if((this.warningThreshold & irritant) != 0) 591 return WARNING; 592 if((this.errorThreshold & irritant) != 0) 593 return ERROR; 594 return IGNORE; 595 } 596 597 public String getVisibilityString(int level) { 598 switch (level & ExtraCompilerModifiers.AccVisibilityMASK) { 599 case ClassFileConstants.AccPublic: 600 return PUBLIC; 601 case ClassFileConstants.AccProtected: 602 return PROTECTED; 603 case ClassFileConstants.AccPrivate: 604 return PRIVATE; 605 default: 606 return DEFAULT; 607 } 608 } 609 610 public void set(Map optionsMap) { 611 612 Object optionValue; 613 if ((optionValue = optionsMap.get(OPTION_LocalVariableAttribute)) != null) { 614 if (GENERATE.equals(optionValue)) { 615 this.produceDebugAttributes |= ClassFileConstants.ATTR_VARS; 616 } else if (DO_NOT_GENERATE.equals(optionValue)) { 617 this.produceDebugAttributes &= ~ClassFileConstants.ATTR_VARS; 618 } 619 } 620 if ((optionValue = optionsMap.get(OPTION_LineNumberAttribute)) != null) { 621 if (GENERATE.equals(optionValue)) { 622 this.produceDebugAttributes |= ClassFileConstants.ATTR_LINES; 623 } else if (DO_NOT_GENERATE.equals(optionValue)) { 624 this.produceDebugAttributes &= ~ClassFileConstants.ATTR_LINES; 625 } 626 } 627 if ((optionValue = optionsMap.get(OPTION_SourceFileAttribute)) != null) { 628 if (GENERATE.equals(optionValue)) { 629 this.produceDebugAttributes |= ClassFileConstants.ATTR_SOURCE; 630 } else if (DO_NOT_GENERATE.equals(optionValue)) { 631 this.produceDebugAttributes &= ~ClassFileConstants.ATTR_SOURCE; 632 } 633 } 634 if ((optionValue = optionsMap.get(OPTION_PreserveUnusedLocal)) != null) { 635 if (PRESERVE.equals(optionValue)) { 636 this.preserveAllLocalVariables = true; 637 } else if (OPTIMIZE_OUT.equals(optionValue)) { 638 this.preserveAllLocalVariables = false; 639 } 640 } 641 if ((optionValue = optionsMap.get(OPTION_ReportDeprecationInDeprecatedCode)) != null) { 642 if (ENABLED.equals(optionValue)) { 643 this.reportDeprecationInsideDeprecatedCode = true; 644 } else if (DISABLED.equals(optionValue)) { 645 this.reportDeprecationInsideDeprecatedCode = false; 646 } 647 } 648 if ((optionValue = optionsMap.get(OPTION_ReportDeprecationWhenOverridingDeprecatedMethod)) != null) { 649 if (ENABLED.equals(optionValue)) { 650 this.reportDeprecationWhenOverridingDeprecatedMethod = true; 651 } else if (DISABLED.equals(optionValue)) { 652 this.reportDeprecationWhenOverridingDeprecatedMethod = false; 653 } 654 } 655 if ((optionValue = optionsMap.get(OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding)) != null) { 656 if (ENABLED.equals(optionValue)) { 657 this.reportUnusedDeclaredThrownExceptionWhenOverriding = true; 658 } else if (DISABLED.equals(optionValue)) { 659 this.reportUnusedDeclaredThrownExceptionWhenOverriding = false; 660 } 661 } 662 if ((optionValue = optionsMap.get(OPTION_Compliance)) != null) { 663 long level = versionToJdkLevel(optionValue); 664 if (level != 0) this.complianceLevel = level; 665 } 666 if ((optionValue = optionsMap.get(OPTION_Source)) != null) { 667 long level = versionToJdkLevel(optionValue); 668 if (level != 0) this.sourceLevel = level; 669 } 670 if ((optionValue = optionsMap.get(OPTION_TargetPlatform)) != null) { 671 long level = versionToJdkLevel(optionValue); 672 if (level != 0) this.targetJDK = level; 673 if (this.targetJDK >= ClassFileConstants.JDK1_5) this.inlineJsrBytecode = true; } 675 if ((optionValue = optionsMap.get(OPTION_Encoding)) != null) { 676 if (optionValue instanceof String ) { 677 this.defaultEncoding = null; 678 String stringValue = (String ) optionValue; 679 if (stringValue.length() > 0){ 680 try { 681 new InputStreamReader (new ByteArrayInputStream (new byte[0]), stringValue); 682 this.defaultEncoding = stringValue; 683 } catch(UnsupportedEncodingException e){ 684 } 686 } 687 } 688 } 689 if ((optionValue = optionsMap.get(OPTION_ReportUnusedParameterWhenImplementingAbstract)) != null) { 690 if (ENABLED.equals(optionValue)) { 691 this.reportUnusedParameterWhenImplementingAbstract = true; 692 } else if (DISABLED.equals(optionValue)) { 693 this.reportUnusedParameterWhenImplementingAbstract = false; 694 } 695 } 696 if ((optionValue = optionsMap.get(OPTION_ReportUnusedParameterWhenOverridingConcrete)) != null) { 697 if (ENABLED.equals(optionValue)) { 698 this.reportUnusedParameterWhenOverridingConcrete = true; 699 } else if (DISABLED.equals(optionValue)) { 700 this.reportUnusedParameterWhenOverridingConcrete = false; 701 } 702 } 703 if ((optionValue = optionsMap.get(OPTION_ReportUnusedParameterIncludeDocCommentReference)) != null) { 704 if (ENABLED.equals(optionValue)) { 705 this.reportUnusedParameterIncludeDocCommentReference = true; 706 } else if (DISABLED.equals(optionValue)) { 707 this.reportUnusedParameterIncludeDocCommentReference = false; 708 } 709 } 710 if ((optionValue = optionsMap.get(OPTION_ReportSpecialParameterHidingField)) != null) { 711 if (ENABLED.equals(optionValue)) { 712 this.reportSpecialParameterHidingField = true; 713 } else if (DISABLED.equals(optionValue)) { 714 this.reportSpecialParameterHidingField = false; 715 } 716 } 717 if ((optionValue = optionsMap.get(OPTION_MaxProblemPerUnit)) != null) { 718 if (optionValue instanceof String ) { 719 String stringValue = (String ) optionValue; 720 try { 721 int val = Integer.parseInt(stringValue); 722 if (val >= 0) this.maxProblemsPerUnit = val; 723 } catch(NumberFormatException e){ 724 } 726 } 727 } 728 if ((optionValue = optionsMap.get(OPTION_TaskTags)) != null) { 729 if (optionValue instanceof String ) { 730 String stringValue = (String ) optionValue; 731 if (stringValue.length() == 0) { 732 this.taskTags = null; 733 } else { 734 this.taskTags = CharOperation.splitAndTrimOn(',', stringValue.toCharArray()); 735 } 736 } 737 } 738 if ((optionValue = optionsMap.get(OPTION_TaskPriorities)) != null) { 739 if (optionValue instanceof String ) { 740 String stringValue = (String ) optionValue; 741 if (stringValue.length() == 0) { 742 this.taskPriorites = null; 743 } else { 744 this.taskPriorites = CharOperation.splitAndTrimOn(',', stringValue.toCharArray()); 745 } 746 } 747 } 748 if ((optionValue = optionsMap.get(OPTION_TaskCaseSensitive)) != null) { 749 if (ENABLED.equals(optionValue)) { 750 this.isTaskCaseSensitive = true; 751 } else if (DISABLED.equals(optionValue)) { 752 this.isTaskCaseSensitive = false; 753 } 754 } 755 if ((optionValue = optionsMap.get(OPTION_InlineJsr)) != null) { 756 if (this.targetJDK < ClassFileConstants.JDK1_5) { if (ENABLED.equals(optionValue)) { 758 this.inlineJsrBytecode = true; 759 } else if (DISABLED.equals(optionValue)) { 760 this.inlineJsrBytecode = false; 761 } 762 } 763 } 764 if ((optionValue = optionsMap.get(OPTION_SuppressWarnings)) != null) { 765 if (ENABLED.equals(optionValue)) { 766 this.suppressWarnings = true; 767 } else if (DISABLED.equals(optionValue)) { 768 this.suppressWarnings = false; 769 } 770 } 771 if ((optionValue = optionsMap.get(OPTION_FatalOptionalError)) != null) { 772 if (ENABLED.equals(optionValue)) { 773 this.treatOptionalErrorAsFatal = true; 774 } else if (DISABLED.equals(optionValue)) { 775 this.treatOptionalErrorAsFatal = false; 776 } 777 } 778 if ((optionValue = optionsMap.get(OPTION_ReportMethodWithConstructorName)) != null) updateSeverity(MethodWithConstructorName, optionValue); 779 if ((optionValue = optionsMap.get(OPTION_ReportOverridingPackageDefaultMethod)) != null) updateSeverity(OverriddenPackageDefaultMethod, optionValue); 780 if ((optionValue = optionsMap.get(OPTION_ReportDeprecation)) != null) updateSeverity(UsingDeprecatedAPI, optionValue); 781 if ((optionValue = optionsMap.get(OPTION_ReportHiddenCatchBlock)) != null) updateSeverity(MaskedCatchBlock, optionValue); 782 if ((optionValue = optionsMap.get(OPTION_ReportUnusedLocal)) != null) updateSeverity(UnusedLocalVariable, optionValue); 783 if ((optionValue = optionsMap.get(OPTION_ReportUnusedParameter)) != null) updateSeverity(UnusedArgument, optionValue); 784 if ((optionValue = optionsMap.get(OPTION_ReportUnusedImport)) != null) updateSeverity(UnusedImport, optionValue); 785 if ((optionValue = optionsMap.get(OPTION_ReportUnusedPrivateMember)) != null) updateSeverity(UnusedPrivateMember, optionValue); 786 if ((optionValue = optionsMap.get(OPTION_ReportUnusedDeclaredThrownException)) != null) updateSeverity(UnusedDeclaredThrownException, optionValue); 787 if ((optionValue = optionsMap.get(OPTION_ReportNoImplicitStringConversion)) != null) updateSeverity(NoImplicitStringConversion, optionValue); 788 if ((optionValue = optionsMap.get(OPTION_ReportSyntheticAccessEmulation)) != null) updateSeverity(AccessEmulation, optionValue); 789 if ((optionValue = optionsMap.get(OPTION_ReportLocalVariableHiding)) != null) updateSeverity(LocalVariableHiding, optionValue); 790 if ((optionValue = optionsMap.get(OPTION_ReportFieldHiding)) != null) updateSeverity(FieldHiding, optionValue); 791 if ((optionValue = optionsMap.get(OPTION_ReportTypeParameterHiding)) != null) updateSeverity(TypeHiding, optionValue); 792 if ((optionValue = optionsMap.get(OPTION_ReportPossibleAccidentalBooleanAssignment)) != null) updateSeverity(AccidentalBooleanAssign, optionValue); 793 if ((optionValue = optionsMap.get(OPTION_ReportEmptyStatement)) != null) updateSeverity(EmptyStatement, optionValue); 794 if ((optionValue = optionsMap.get(OPTION_ReportNonExternalizedStringLiteral)) != null) updateSeverity(NonExternalizedString, optionValue); 795 if ((optionValue = optionsMap.get(OPTION_ReportAssertIdentifier)) != null) updateSeverity(AssertUsedAsAnIdentifier, optionValue); 796 if ((optionValue = optionsMap.get(OPTION_ReportEnumIdentifier)) != null) updateSeverity(EnumUsedAsAnIdentifier, optionValue); 797 if ((optionValue = optionsMap.get(OPTION_ReportNonStaticAccessToStatic)) != null) updateSeverity(NonStaticAccessToStatic, optionValue); 798 if ((optionValue = optionsMap.get(OPTION_ReportIndirectStaticAccess)) != null) updateSeverity(IndirectStaticAccess, optionValue); 799 if ((optionValue = optionsMap.get(OPTION_ReportIncompatibleNonInheritedInterfaceMethod)) != null) updateSeverity(IncompatibleNonInheritedInterfaceMethod, optionValue); 800 if ((optionValue = optionsMap.get(OPTION_ReportUndocumentedEmptyBlock)) != null) updateSeverity(UndocumentedEmptyBlock, optionValue); 801 if ((optionValue = optionsMap.get(OPTION_ReportUnnecessaryTypeCheck)) != null) updateSeverity(UnnecessaryTypeCheck, optionValue); 802 if ((optionValue = optionsMap.get(OPTION_ReportUnnecessaryElse)) != null) updateSeverity(UnnecessaryElse, optionValue); 803 if ((optionValue = optionsMap.get(OPTION_ReportFinallyBlockNotCompletingNormally)) != null) updateSeverity(FinallyBlockNotCompleting, optionValue); 804 if ((optionValue = optionsMap.get(OPTION_ReportUnqualifiedFieldAccess)) != null) updateSeverity(UnqualifiedFieldAccess, optionValue); 805 if ((optionValue = optionsMap.get(OPTION_ReportNoEffectAssignment)) != null) updateSeverity(NoEffectAssignment, optionValue); 806 if ((optionValue = optionsMap.get(OPTION_ReportUncheckedTypeOperation)) != null) updateSeverity(UncheckedTypeOperation, optionValue); 807 if ((optionValue = optionsMap.get(OPTION_ReportRawTypeReference)) != null) updateSeverity(RawTypeReference, optionValue); 808 if ((optionValue = optionsMap.get(OPTION_ReportFinalParameterBound)) != null) updateSeverity(FinalParameterBound, optionValue); 809 if ((optionValue = optionsMap.get(OPTION_ReportMissingSerialVersion)) != null) updateSeverity(MissingSerialVersion, optionValue); 810 if ((optionValue = optionsMap.get(OPTION_ReportForbiddenReference)) != null) updateSeverity(ForbiddenReference, optionValue); 811 if ((optionValue = optionsMap.get(OPTION_ReportDiscouragedReference)) != null) updateSeverity(DiscouragedReference, optionValue); 812 if ((optionValue = optionsMap.get(OPTION_ReportVarargsArgumentNeedCast)) != null) updateSeverity(VarargsArgumentNeedCast, optionValue); 813 if ((optionValue = optionsMap.get(OPTION_ReportNullReference)) != null) updateSeverity(NullReference, optionValue); 814 if ((optionValue = optionsMap.get(OPTION_ReportPotentialNullReference)) != null) updateSeverity(PotentialNullReference, optionValue); 815 if ((optionValue = optionsMap.get(OPTION_ReportRedundantNullCheck)) != null) updateSeverity(RedundantNullCheck, optionValue); 816 if ((optionValue = optionsMap.get(OPTION_ReportAutoboxing)) != null) updateSeverity(AutoBoxing, optionValue); 817 if ((optionValue = optionsMap.get(OPTION_ReportAnnotationSuperInterface)) != null) updateSeverity(AnnotationSuperInterface, optionValue); 818 if ((optionValue = optionsMap.get(OPTION_ReportMissingOverrideAnnotation)) != null) updateSeverity(MissingOverrideAnnotation, optionValue); 819 if ((optionValue = optionsMap.get(OPTION_ReportMissingDeprecatedAnnotation)) != null) updateSeverity(MissingDeprecatedAnnotation, optionValue); 820 if ((optionValue = optionsMap.get(OPTION_ReportIncompleteEnumSwitch)) != null) updateSeverity(IncompleteEnumSwitch, optionValue); 821 if ((optionValue = optionsMap.get(OPTION_ReportUnhandledWarningToken)) != null) updateSeverity(UnhandledWarningToken, optionValue); 822 if ((optionValue = optionsMap.get(OPTION_ReportUnusedLabel)) != null) updateSeverity(UnusedLabel, optionValue); 823 if ((optionValue = optionsMap.get(OPTION_ReportParameterAssignment)) != null) updateSeverity(ParameterAssignment, optionValue); 824 if ((optionValue = optionsMap.get(OPTION_ReportFallthroughCase)) != null) updateSeverity(FallthroughCase, optionValue); 825 if ((optionValue = optionsMap.get(OPTION_ReportOverridingMethodWithoutSuperInvocation)) != null) updateSeverity(OverridingMethodWithoutSuperInvocation, optionValue); 826 827 if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) { 829 if (ENABLED.equals(optionValue)) { 830 this.docCommentSupport = true; 831 } else if (DISABLED.equals(optionValue)) { 832 this.docCommentSupport = false; 833 } 834 } 835 if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadoc)) != null) { 836 updateSeverity(InvalidJavadoc, optionValue); 837 } 838 if ( (optionValue = optionsMap.get(OPTION_ReportInvalidJavadocTagsVisibility)) != null) { 839 if (PUBLIC.equals(optionValue)) { 840 this.reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic; 841 } else if (PROTECTED.equals(optionValue)) { 842 this.reportInvalidJavadocTagsVisibility = ClassFileConstants.AccProtected; 843 } else if (DEFAULT.equals(optionValue)) { 844 this.reportInvalidJavadocTagsVisibility = ClassFileConstants.AccDefault; 845 } else if (PRIVATE.equals(optionValue)) { 846 this.reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPrivate; 847 } 848 } 849 if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadocTags)) != null) { 850 if (ENABLED.equals(optionValue)) { 851 this.reportInvalidJavadocTags = true; 852 } else if (DISABLED.equals(optionValue)) { 853 this.reportInvalidJavadocTags = false; 854 } 855 } 856 if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadocTagsDeprecatedRef)) != null) { 857 if (ENABLED.equals(optionValue)) { 858 this.reportInvalidJavadocTagsDeprecatedRef = true; 859 } else if (DISABLED.equals(optionValue)) { 860 this.reportInvalidJavadocTagsDeprecatedRef = false; 861 } 862 } 863 if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadocTagsNotVisibleRef)) != null) { 864 if (ENABLED.equals(optionValue)) { 865 this.reportInvalidJavadocTagsNotVisibleRef = true; 866 } else if (DISABLED.equals(optionValue)) { 867 this.reportInvalidJavadocTagsNotVisibleRef = false; 868 } 869 } 870 if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocTags)) != null) { 871 updateSeverity(MissingJavadocTags, optionValue); 872 } 873 if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocTagsVisibility)) != null) { 874 if (PUBLIC.equals(optionValue)) { 875 this.reportMissingJavadocTagsVisibility = ClassFileConstants.AccPublic; 876 } else if (PROTECTED.equals(optionValue)) { 877 this.reportMissingJavadocTagsVisibility = ClassFileConstants.AccProtected; 878 } else if (DEFAULT.equals(optionValue)) { 879 this.reportMissingJavadocTagsVisibility = ClassFileConstants.AccDefault; 880 } else if (PRIVATE.equals(optionValue)) { 881 this.reportMissingJavadocTagsVisibility = ClassFileConstants.AccPrivate; 882 } 883 } 884 if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocTagsOverriding)) != null) { 885 if (ENABLED.equals(optionValue)) { 886 this.reportMissingJavadocTagsOverriding = true; 887 } else if (DISABLED.equals(optionValue)) { 888 this.reportMissingJavadocTagsOverriding = false; 889 } 890 } 891 if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocComments)) != null) { 892 updateSeverity(MissingJavadocComments, optionValue); 893 } 894 if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocCommentsVisibility)) != null) { 895 if (PUBLIC.equals(optionValue)) { 896 this.reportMissingJavadocCommentsVisibility = ClassFileConstants.AccPublic; 897 } else if (PROTECTED.equals(optionValue)) { 898 this.reportMissingJavadocCommentsVisibility = ClassFileConstants.AccProtected; 899 } else if (DEFAULT.equals(optionValue)) { 900 this.reportMissingJavadocCommentsVisibility = ClassFileConstants.AccDefault; 901 } else if (PRIVATE.equals(optionValue)) { 902 this.reportMissingJavadocCommentsVisibility = ClassFileConstants.AccPrivate; 903 } 904 } 905 if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocCommentsOverriding)) != null) { 906 if (ENABLED.equals(optionValue)) { 907 this.reportMissingJavadocCommentsOverriding = true; 908 } else if (DISABLED.equals(optionValue)) { 909 this.reportMissingJavadocCommentsOverriding = false; 910 } 911 } 912 if ((optionValue = optionsMap.get(OPTION_GenerateClassFiles)) != null) { 913 if (ENABLED.equals(optionValue)) { 914 this.generateClassFiles = true; 915 } else if (DISABLED.equals(optionValue)) { 916 this.generateClassFiles = false; 917 } 918 } 919 if ((optionValue = optionsMap.get(OPTION_Process_Annotations)) != null) { 920 if (ENABLED.equals(optionValue)) { 921 this.processAnnotations = true; 922 this.storeAnnotations = true; this.docCommentSupport = true; } else if (DISABLED.equals(optionValue)) { 925 this.processAnnotations = false; 926 this.storeAnnotations = false; 927 } 928 } 929 } 930 931 public String toString() { 932 933 StringBuffer buf = new StringBuffer ("CompilerOptions:"); buf.append("\n\t- local variables debug attributes: ").append((this.produceDebugAttributes & ClassFileConstants.ATTR_VARS) != 0 ? "ON" : " OFF"); buf.append("\n\t- line number debug attributes: ").append((this.produceDebugAttributes & ClassFileConstants.ATTR_LINES) != 0 ? "ON" : " OFF"); buf.append("\n\t- source debug attributes: ").append((this.produceDebugAttributes & ClassFileConstants.ATTR_SOURCE) != 0 ? "ON" : " OFF"); buf.append("\n\t- preserve all local variables: ").append(this.preserveAllLocalVariables ? "ON" : " OFF"); buf.append("\n\t- method with constructor name: ").append(getSeverityString(MethodWithConstructorName)); buf.append("\n\t- overridden package default method: ").append(getSeverityString(OverriddenPackageDefaultMethod)); buf.append("\n\t- deprecation: ").append(getSeverityString(UsingDeprecatedAPI)); buf.append("\n\t- masked catch block: ").append(getSeverityString(MaskedCatchBlock)); buf.append("\n\t- unused local variable: ").append(getSeverityString(UnusedLocalVariable)); buf.append("\n\t- unused parameter: ").append(getSeverityString(UnusedArgument)); buf.append("\n\t- unused import: ").append(getSeverityString(UnusedImport)); buf.append("\n\t- synthetic access emulation: ").append(getSeverityString(AccessEmulation)); buf.append("\n\t- assignment with no effect: ").append(getSeverityString(NoEffectAssignment)); buf.append("\n\t- non externalized string: ").append(getSeverityString(NonExternalizedString)); buf.append("\n\t- static access receiver: ").append(getSeverityString(NonStaticAccessToStatic)); buf.append("\n\t- indirect static access: ").append(getSeverityString(IndirectStaticAccess)); buf.append("\n\t- incompatible non inherited interface method: ").append(getSeverityString(IncompatibleNonInheritedInterfaceMethod)); buf.append("\n\t- unused private member: ").append(getSeverityString(UnusedPrivateMember)); buf.append("\n\t- local variable hiding another variable: ").append(getSeverityString(LocalVariableHiding)); buf.append("\n\t- field hiding another variable: ").append(getSeverityString(FieldHiding)); buf.append("\n\t- type hiding another type: ").append(getSeverityString(TypeHiding)); buf.append("\n\t- possible accidental boolean assignment: ").append(getSeverityString(AccidentalBooleanAssign)); buf.append("\n\t- superfluous semicolon: ").append(getSeverityString(EmptyStatement)); buf.append("\n\t- uncommented empty block: ").append(getSeverityString(UndocumentedEmptyBlock)); buf.append("\n\t- unnecessary type check: ").append(getSeverityString(UnnecessaryTypeCheck)); buf.append("\n\t- javadoc comment support: ").append(this.docCommentSupport ? "ON" : " OFF"); buf.append("\n\t\t+ invalid javadoc: ").append(getSeverityString(InvalidJavadoc)); buf.append("\n\t\t+ report invalid javadoc tags: ").append(this.reportInvalidJavadocTags ? ENABLED : DISABLED); buf.append("\n\t\t\t* deprecated references: ").append(this.reportInvalidJavadocTagsDeprecatedRef ? ENABLED : DISABLED); buf.append("\n\t\t\t* not visible references: ").append(this.reportInvalidJavadocTagsNotVisibleRef ? ENABLED : DISABLED); buf.append("\n\t\t+ visibility level to report invalid javadoc tags: ").append(getVisibilityString(this.reportInvalidJavadocTagsVisibility)); buf.append("\n\t\t+ missing javadoc tags: ").append(getSeverityString(MissingJavadocTags)); buf.append("\n\t\t+ visibility level to report missing javadoc tags: ").append(getVisibilityString(this.reportMissingJavadocTagsVisibility)); buf.append("\n\t\t+ report missing javadoc tags in overriding methods: ").append(this.reportMissingJavadocTagsOverriding ? ENABLED : DISABLED); buf.append("\n\t\t+ missing javadoc comments: ").append(getSeverityString(MissingJavadocComments)); buf.append("\n\t\t+ visibility level to report missing javadoc comments: ").append(getVisibilityString(this.reportMissingJavadocCommentsVisibility)); buf.append("\n\t\t+ report missing javadoc comments in overriding methods: ").append(this.reportMissingJavadocCommentsOverriding ? ENABLED : DISABLED); buf.append("\n\t- finally block not completing normally: ").append(getSeverityString(FinallyBlockNotCompleting)); buf.append("\n\t- unused declared thrown exception: ").append(getSeverityString(UnusedDeclaredThrownException)); buf.append("\n\t- unused declared thrown exception when overriding: ").append(this.reportUnusedDeclaredThrownExceptionWhenOverriding ? ENABLED : DISABLED); buf.append("\n\t- unnecessary else: ").append(getSeverityString(UnnecessaryElse)); buf.append("\n\t- JDK compliance level: "+ versionFromJdkLevel(this.complianceLevel)); buf.append("\n\t- JDK source level: "+ versionFromJdkLevel(this.sourceLevel)); buf.append("\n\t- JDK target level: "+ versionFromJdkLevel(this.targetJDK)); buf.append("\n\t- verbose : ").append(this.verbose ? "ON" : "OFF"); buf.append("\n\t- produce reference info : ").append(this.produceReferenceInfo ? "ON" : "OFF"); buf.append("\n\t- parse literal expressions as constants : ").append(this.parseLiteralExpressionsAsConstants ? "ON" : "OFF"); buf.append("\n\t- encoding : ").append(this.defaultEncoding == null ? "<default>" : this.defaultEncoding); buf.append("\n\t- task tags: ").append(this.taskTags == null ? Util.EMPTY_STRING : new String (CharOperation.concatWith(this.taskTags,','))); buf.append("\n\t- task priorities : ").append(this.taskPriorites == null ? Util.EMPTY_STRING : new String (CharOperation.concatWith(this.taskPriorites,','))); buf.append("\n\t- report deprecation inside deprecated code : ").append(this.reportDeprecationInsideDeprecatedCode ? ENABLED : DISABLED); buf.append("\n\t- report deprecation when overriding deprecated method : ").append(this.reportDeprecationWhenOverridingDeprecatedMethod ? ENABLED : DISABLED); buf.append("\n\t- report unused parameter when implementing abstract method : ").append(this.reportUnusedParameterWhenImplementingAbstract ? ENABLED : DISABLED); buf.append("\n\t- report unused parameter when overriding concrete method : ").append(this.reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED); buf.append("\n\t- report unused parameter include doc comment reference : ").append(this.reportUnusedParameterIncludeDocCommentReference ? ENABLED : DISABLED); buf.append("\n\t- report constructor/setter parameter hiding existing field : ").append(this.reportSpecialParameterHidingField ? ENABLED : DISABLED); buf.append("\n\t- inline JSR bytecode : ").append(this.inlineJsrBytecode ? ENABLED : DISABLED); buf.append("\n\t- unsafe type operation: ").append(getSeverityString(UncheckedTypeOperation)); buf.append("\n\t- unsafe raw type: ").append(getSeverityString(RawTypeReference)); buf.append("\n\t- final bound for type parameter: ").append(getSeverityString(FinalParameterBound)); buf.append("\n\t- missing serialVersionUID: ").append(getSeverityString(MissingSerialVersion)); buf.append("\n\t- varargs argument need cast: ").append(getSeverityString(VarargsArgumentNeedCast)); buf.append("\n\t- forbidden reference to type with access restriction: ").append(getSeverityString(ForbiddenReference)); buf.append("\n\t- discouraged reference to type with access restriction: ").append(getSeverityString(DiscouragedReference)); buf.append("\n\t- null reference: ").append(getSeverityString(NullReference)); buf.append("\n\t- potential null reference: ").append(getSeverityString(PotentialNullReference)); buf.append("\n\t- redundant null check: ").append(getSeverityString(RedundantNullCheck)); buf.append("\n\t- autoboxing: ").append(getSeverityString(AutoBoxing)); buf.append("\n\t- annotation super interface: ").append(getSeverityString(AnnotationSuperInterface)); buf.append("\n\t- missing @Override annotation: ").append(getSeverityString(MissingOverrideAnnotation)); buf.append("\n\t- missing @Deprecated annotation: ").append(getSeverityString(MissingDeprecatedAnnotation)); buf.append("\n\t- incomplete enum switch: ").append(getSeverityString(IncompleteEnumSwitch)); buf.append("\n\t- suppress warnings: ").append(this.suppressWarnings ? ENABLED : DISABLED); buf.append("\n\t- unhandled warning token: ").append(getSeverityString(UnhandledWarningToken)); buf.append("\n\t- unused label: ").append(getSeverityString(UnusedLabel)); buf.append("\n\t- treat optional error as fatal: ").append(this.treatOptionalErrorAsFatal ? ENABLED : DISABLED); buf.append("\n\t- parameter assignment: ").append(getSeverityString(ParameterAssignment)); buf.append("\n\t- generate class files: ").append(this.generateClassFiles ? ENABLED : DISABLED); buf.append("\n\t- process annotations: ").append(this.processAnnotations ? ENABLED : DISABLED); return buf.toString(); 1014 } 1015 1016 void updateSeverity(long irritant, Object severityString) { 1017 if (ERROR.equals(severityString)) { 1018 this.errorThreshold |= irritant; 1019 this.warningThreshold &= ~irritant; 1020 } else if (WARNING.equals(severityString)) { 1021 this.errorThreshold &= ~irritant; 1022 this.warningThreshold |= irritant; 1023 } else if (IGNORE.equals(severityString)) { 1024 this.errorThreshold &= ~irritant; 1025 this.warningThreshold &= ~irritant; 1026 } 1027 } 1028 public static long versionToJdkLevel(Object versionID) { 1029 if (versionID instanceof String ) { 1030 String version = (String ) versionID; 1031 if (version.length() == 3 && version.charAt(0) == '1' && version.charAt(1) == '.') { 1033 switch (version.charAt(2)) { 1034 case '1': 1035 return ClassFileConstants.JDK1_1; 1036 case '2': 1037 return ClassFileConstants.JDK1_2; 1038 case '3': 1039 return ClassFileConstants.JDK1_3; 1040 case '4': 1041 return ClassFileConstants.JDK1_4; 1042 case '5': 1043 return ClassFileConstants.JDK1_5; 1044 case '6': 1045 return ClassFileConstants.JDK1_6; 1046 case '7': 1047 return ClassFileConstants.JDK1_7; 1048 default: 1049 return 0; } 1051 } 1052 if (VERSION_JSR14.equals(versionID)) { 1053 return ClassFileConstants.JDK1_4; 1054 } 1055 } 1056 return 0; } 1058 1059 public static String versionFromJdkLevel(long jdkLevel) { 1060 switch ((int)(jdkLevel>>16)) { 1061 case ClassFileConstants.MAJOR_VERSION_1_1 : 1062 if (jdkLevel == ClassFileConstants.JDK1_1) 1063 return VERSION_1_1; 1064 break; 1065 case ClassFileConstants.MAJOR_VERSION_1_2 : 1066 if (jdkLevel == ClassFileConstants.JDK1_2) 1067 return VERSION_1_2; 1068 break; 1069 case ClassFileConstants.MAJOR_VERSION_1_3 : 1070 if (jdkLevel == ClassFileConstants.JDK1_3) 1071 return VERSION_1_3; 1072 break; 1073 case ClassFileConstants.MAJOR_VERSION_1_4 : 1074 if (jdkLevel == ClassFileConstants.JDK1_4) 1075 return VERSION_1_4; 1076 break; 1077 case ClassFileConstants.MAJOR_VERSION_1_5 : 1078 if (jdkLevel == ClassFileConstants.JDK1_5) 1079 return VERSION_1_5; 1080 break; 1081 case ClassFileConstants.MAJOR_VERSION_1_6 : 1082 if (jdkLevel == ClassFileConstants.JDK1_6) 1083 return VERSION_1_6; 1084 break; 1085 case ClassFileConstants.MAJOR_VERSION_1_7 : 1086 if (jdkLevel == ClassFileConstants.JDK1_7) 1087 return VERSION_1_7; 1088 break; 1089 } 1090 return Util.EMPTY_STRING; } 1092 1093 1098 public static String [] warningOptionNames() { 1099 String [] result = { 1100 OPTION_ReportAnnotationSuperInterface, 1101 OPTION_ReportAssertIdentifier, 1102 OPTION_ReportAutoboxing, 1103 OPTION_ReportDeprecation, 1104 OPTION_ReportDiscouragedReference, 1105 OPTION_ReportEmptyStatement, 1106 OPTION_ReportEnumIdentifier, 1107 OPTION_ReportFallthroughCase, 1108 OPTION_ReportFieldHiding, 1109 OPTION_ReportFinalParameterBound, 1110 OPTION_ReportFinallyBlockNotCompletingNormally, 1111 OPTION_ReportForbiddenReference, 1112 OPTION_ReportHiddenCatchBlock, 1113 OPTION_ReportIncompatibleNonInheritedInterfaceMethod, 1114 OPTION_ReportIncompleteEnumSwitch, 1115 OPTION_ReportIndirectStaticAccess, 1116 OPTION_ReportInvalidJavadoc, 1117 OPTION_ReportLocalVariableHiding, 1118 OPTION_ReportMethodWithConstructorName, 1119 OPTION_ReportMissingDeprecatedAnnotation, 1120 OPTION_ReportMissingJavadocComments, 1121 OPTION_ReportMissingJavadocTags, 1122 OPTION_ReportMissingOverrideAnnotation, 1123 OPTION_ReportMissingSerialVersion, 1124 OPTION_ReportNoEffectAssignment, 1125 OPTION_ReportNoImplicitStringConversion, 1126 OPTION_ReportNonExternalizedStringLiteral, 1127 OPTION_ReportNonStaticAccessToStatic, 1128 OPTION_ReportNullReference, 1129 OPTION_ReportPotentialNullReference, 1130 OPTION_ReportRedundantNullCheck, 1131 OPTION_ReportOverridingPackageDefaultMethod, 1132 OPTION_ReportParameterAssignment, 1133 OPTION_ReportPossibleAccidentalBooleanAssignment, 1134 OPTION_ReportSyntheticAccessEmulation, 1135 OPTION_ReportTypeParameterHiding, 1136 OPTION_ReportUncheckedTypeOperation, 1137 OPTION_ReportUndocumentedEmptyBlock, 1138 OPTION_ReportUnnecessaryElse, 1139 OPTION_ReportUnnecessaryTypeCheck, 1140 OPTION_ReportUnqualifiedFieldAccess, 1141 OPTION_ReportUnusedDeclaredThrownException, 1142 OPTION_ReportUnusedImport, 1143 OPTION_ReportUnusedLocal, 1144 OPTION_ReportUnusedParameter, 1145 OPTION_ReportUnusedPrivateMember, 1146 OPTION_ReportVarargsArgumentNeedCast, 1147 OPTION_ReportUnhandledWarningToken, 1148 OPTION_ReportOverridingMethodWithoutSuperInvocation 1149 }; 1150 return result; 1151 } 1152 1153 public static String warningTokenFromIrritant(long irritant) { 1154 int irritantInt = (int) irritant; 1156 if (irritantInt == irritant) { 1157 switch (irritantInt) { 1158 case (int) (InvalidJavadoc | UsingDeprecatedAPI) : 1159 case (int) UsingDeprecatedAPI : 1160 return "deprecation"; case (int) FinallyBlockNotCompleting : 1162 return "finally"; case (int) FieldHiding : 1164 case (int) LocalVariableHiding : 1165 case (int) MaskedCatchBlock : 1166 return "hiding"; case (int) NonExternalizedString : 1168 return "nls"; case (int) UnnecessaryTypeCheck : 1170 return "cast"; case (int) UnusedLocalVariable : 1172 case (int) UnusedArgument : 1173 case (int) UnusedImport : 1174 case (int) UnusedPrivateMember: 1175 case (int) UnusedDeclaredThrownException: 1176 return "unused"; case (int) IndirectStaticAccess : 1178 case (int) NonStaticAccessToStatic : 1179 return "static-access"; case (int) AccessEmulation : 1181 return "synthetic-access"; case (int) UnqualifiedFieldAccess : 1183 return "unqualified-field-access"; case (int) UncheckedTypeOperation : 1185 return "unchecked"; } 1187 } else { 1188 irritantInt = (int)(irritant >>> 32); 1189 switch (irritantInt) { 1190 case (int)(MissingSerialVersion >>> 32) : 1191 return "serial"; case (int)(AutoBoxing >>> 32) : 1193 return "boxing"; case (int)(TypeHiding >>> 32) : 1195 return "hiding"; case (int)(IncompleteEnumSwitch >>> 32) : 1197 return "incomplete-switch"; case (int)(MissingDeprecatedAnnotation >>> 32) : 1199 return "dep-ann"; case (int)(RawTypeReference >>> 32): 1201 return "unchecked"; case (int) (UnusedLabel >>> 32): 1203 return "unused"; case (int) (DiscouragedReference >>> 32) : 1205 case (int) (ForbiddenReference >>> 32) : 1206 return "restriction"; case (int) (NullReference >>> 32) : 1208 case (int) (PotentialNullReference >>> 32) : 1209 case (int) (RedundantNullCheck >>> 32) : 1210 return "null"; case (int) (FallthroughCase >>> 32) : 1212 return "fallthrough"; case (int) (OverridingMethodWithoutSuperInvocation >>> 32) : 1214 return "super"; } 1216 } 1217 return null; 1218 } 1219 public final static String [] warningTokens = { 1221 "all", "boxing", "cast", "dep-ann", "deprecation", "fallthrough", "finally", "hiding", "incomplete-switch", "nls", "null", "restriction", "serial", "static-access", "super", "synthetic-access", "unchecked", "unqualified-field-access", "unused", }; 1241 public static long warningTokenToIrritant(String warningToken) { 1242 if (warningToken == null || warningToken.length() == 0) return 0; 1244 switch (warningToken.charAt(0)) { 1245 case 'a' : 1246 if ("all".equals(warningToken)) return 0xFFFFFFFFFFFFFFFFl; break; 1249 case 'b' : 1250 if ("boxing".equals(warningToken)) return AutoBoxing; 1252 break; 1253 case 'c' : 1254 if ("cast".equals(warningToken)) return UnnecessaryTypeCheck; 1256 break; 1257 case 'd' : 1258 if ("deprecation".equals(warningToken)) return UsingDeprecatedAPI; 1260 if ("dep-ann".equals(warningToken)) return MissingDeprecatedAnnotation; 1262 break; 1263 case 'f' : 1264 if ("fallthrough".equals(warningToken)) return FallthroughCase; 1266 if ("finally".equals(warningToken)) return FinallyBlockNotCompleting; 1268 break; 1269 case 'h' : 1270 if ("hiding".equals(warningToken)) return FieldHiding | LocalVariableHiding | MaskedCatchBlock | TypeHiding; 1272 case 'i' : 1273 if ("incomplete-switch".equals(warningToken)) return IncompleteEnumSwitch; 1275 break; 1276 case 'n' : 1277 if ("nls".equals(warningToken)) return NonExternalizedString; 1279 if ("null".equals(warningToken)) return NullReference | PotentialNullReference | RedundantNullCheck; 1281 break; 1282 case 'r' : 1283 if ("restriction".equals(warningToken)) return DiscouragedReference | ForbiddenReference; 1285 break; 1286 case 's' : 1287 if ("serial".equals(warningToken)) return MissingSerialVersion; 1289 if ("static-access".equals(warningToken)) return IndirectStaticAccess | NonStaticAccessToStatic; 1291 if ("synthetic-access".equals(warningToken)) return AccessEmulation; 1293 if ("super".equals(warningToken)) { return OverridingMethodWithoutSuperInvocation; 1295 } 1296 break; 1297 case 'u' : 1298 if ("unused".equals(warningToken)) return UnusedLocalVariable | UnusedArgument | UnusedPrivateMember | UnusedDeclaredThrownException | UnusedLabel | UnusedImport; 1300 if ("unchecked".equals(warningToken)) return UncheckedTypeOperation | RawTypeReference; 1302 if ("unqualified-field-access".equals(warningToken)) return UnqualifiedFieldAccess; 1304 break; 1305 } 1306 return 0; 1307 } 1308} 1309 | Popular Tags |