KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > impl > CompilerOptions


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.compiler.impl;
12
13 import java.io.ByteArrayInputStream JavaDoc;
14 import java.io.InputStreamReader JavaDoc;
15 import java.io.UnsupportedEncodingException JavaDoc;
16 import java.util.HashMap JavaDoc;
17 import java.util.Map JavaDoc;
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     /**
30      * Option IDs
31      */

32     public static final String JavaDoc OPTION_LocalVariableAttribute = "org.eclipse.jdt.core.compiler.debug.localVariable"; //$NON-NLS-1$
33
public static final String JavaDoc OPTION_LineNumberAttribute = "org.eclipse.jdt.core.compiler.debug.lineNumber"; //$NON-NLS-1$
34
public static final String JavaDoc OPTION_SourceFileAttribute = "org.eclipse.jdt.core.compiler.debug.sourceFile"; //$NON-NLS-1$
35
public static final String JavaDoc OPTION_PreserveUnusedLocal = "org.eclipse.jdt.core.compiler.codegen.unusedLocal"; //$NON-NLS-1$
36
public static final String JavaDoc OPTION_DocCommentSupport= "org.eclipse.jdt.core.compiler.doc.comment.support"; //$NON-NLS-1$
37
public static final String JavaDoc OPTION_ReportMethodWithConstructorName = "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
38
public static final String JavaDoc OPTION_ReportOverridingPackageDefaultMethod = "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
39
public static final String JavaDoc OPTION_ReportDeprecation = "org.eclipse.jdt.core.compiler.problem.deprecation"; //$NON-NLS-1$
40
public static final String JavaDoc OPTION_ReportDeprecationInDeprecatedCode = "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
41
public static final String JavaDoc OPTION_ReportDeprecationWhenOverridingDeprecatedMethod = "org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod"; //$NON-NLS-1$
42
public static final String JavaDoc OPTION_ReportHiddenCatchBlock = "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
43
public static final String JavaDoc OPTION_ReportUnusedLocal = "org.eclipse.jdt.core.compiler.problem.unusedLocal"; //$NON-NLS-1$
44
public static final String JavaDoc OPTION_ReportUnusedParameter = "org.eclipse.jdt.core.compiler.problem.unusedParameter"; //$NON-NLS-1$
45
public static final String JavaDoc OPTION_ReportUnusedParameterWhenImplementingAbstract = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
46
public static final String JavaDoc OPTION_ReportUnusedParameterWhenOverridingConcrete = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
47
public static final String JavaDoc OPTION_ReportUnusedParameterIncludeDocCommentReference = "org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference"; //$NON-NLS-1$
48
public static final String JavaDoc OPTION_ReportUnusedImport = "org.eclipse.jdt.core.compiler.problem.unusedImport"; //$NON-NLS-1$
49
public static final String JavaDoc OPTION_ReportSyntheticAccessEmulation = "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
50
public static final String JavaDoc OPTION_ReportNoEffectAssignment = "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"; //$NON-NLS-1$
51
public static final String JavaDoc OPTION_ReportLocalVariableHiding = "org.eclipse.jdt.core.compiler.problem.localVariableHiding"; //$NON-NLS-1$
52
public static final String JavaDoc OPTION_ReportSpecialParameterHidingField = "org.eclipse.jdt.core.compiler.problem.specialParameterHidingField"; //$NON-NLS-1$
53
public static final String JavaDoc OPTION_ReportFieldHiding = "org.eclipse.jdt.core.compiler.problem.fieldHiding"; //$NON-NLS-1$
54
public static final String JavaDoc OPTION_ReportTypeParameterHiding = "org.eclipse.jdt.core.compiler.problem.typeParameterHiding"; //$NON-NLS-1$
55
public static final String JavaDoc OPTION_ReportPossibleAccidentalBooleanAssignment = "org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment"; //$NON-NLS-1$
56
public static final String JavaDoc OPTION_ReportNonExternalizedStringLiteral = "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
57
public static final String JavaDoc OPTION_ReportIncompatibleNonInheritedInterfaceMethod = "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
58
public static final String JavaDoc OPTION_ReportUnusedPrivateMember = "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
59
public static final String JavaDoc OPTION_ReportNoImplicitStringConversion = "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
60
public static final String JavaDoc OPTION_ReportAssertIdentifier = "org.eclipse.jdt.core.compiler.problem.assertIdentifier"; //$NON-NLS-1$
61
public static final String JavaDoc OPTION_ReportEnumIdentifier = "org.eclipse.jdt.core.compiler.problem.enumIdentifier"; //$NON-NLS-1$
62
public static final String JavaDoc OPTION_ReportNonStaticAccessToStatic = "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
63
public static final String JavaDoc OPTION_ReportIndirectStaticAccess = "org.eclipse.jdt.core.compiler.problem.indirectStaticAccess"; //$NON-NLS-1$
64
public static final String JavaDoc OPTION_ReportEmptyStatement = "org.eclipse.jdt.core.compiler.problem.emptyStatement"; //$NON-NLS-1$
65
public static final String JavaDoc OPTION_ReportUnnecessaryTypeCheck = "org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck"; //$NON-NLS-1$
66
public static final String JavaDoc OPTION_ReportUnnecessaryElse = "org.eclipse.jdt.core.compiler.problem.unnecessaryElse"; //$NON-NLS-1$
67
public static final String JavaDoc OPTION_ReportUndocumentedEmptyBlock = "org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock"; //$NON-NLS-1$
68
public static final String JavaDoc OPTION_ReportInvalidJavadoc = "org.eclipse.jdt.core.compiler.problem.invalidJavadoc"; //$NON-NLS-1$
69
public static final String JavaDoc OPTION_ReportInvalidJavadocTags = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTags"; //$NON-NLS-1$
70
public static final String JavaDoc OPTION_ReportInvalidJavadocTagsDeprecatedRef = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef"; //$NON-NLS-1$
71
public static final String JavaDoc OPTION_ReportInvalidJavadocTagsNotVisibleRef = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef"; //$NON-NLS-1$
72
public static final String JavaDoc OPTION_ReportInvalidJavadocTagsVisibility = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility"; //$NON-NLS-1$
73
public static final String JavaDoc OPTION_ReportMissingJavadocTags = "org.eclipse.jdt.core.compiler.problem.missingJavadocTags"; //$NON-NLS-1$
74
public static final String JavaDoc OPTION_ReportMissingJavadocTagsVisibility = "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility"; //$NON-NLS-1$
75
public static final String JavaDoc OPTION_ReportMissingJavadocTagsOverriding = "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding"; //$NON-NLS-1$
76
public static final String JavaDoc OPTION_ReportMissingJavadocComments = "org.eclipse.jdt.core.compiler.problem.missingJavadocComments"; //$NON-NLS-1$
77
public static final String JavaDoc OPTION_ReportMissingJavadocCommentsVisibility = "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility"; //$NON-NLS-1$
78
public static final String JavaDoc OPTION_ReportMissingJavadocCommentsOverriding = "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding"; //$NON-NLS-1$
79
public static final String JavaDoc OPTION_ReportFinallyBlockNotCompletingNormally = "org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally"; //$NON-NLS-1$
80
public static final String JavaDoc OPTION_ReportUnusedDeclaredThrownException = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException"; //$NON-NLS-1$
81
public static final String JavaDoc OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding"; //$NON-NLS-1$
82
public static final String JavaDoc OPTION_ReportUnqualifiedFieldAccess = "org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess"; //$NON-NLS-1$
83
public static final String JavaDoc OPTION_ReportUncheckedTypeOperation = "org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation"; //$NON-NLS-1$
84
public static final String JavaDoc OPTION_ReportRawTypeReference = "org.eclipse.jdt.core.compiler.problem.rawTypeReference"; //$NON-NLS-1$
85
public static final String JavaDoc OPTION_ReportFinalParameterBound = "org.eclipse.jdt.core.compiler.problem.finalParameterBound"; //$NON-NLS-1$
86
public static final String JavaDoc OPTION_ReportMissingSerialVersion = "org.eclipse.jdt.core.compiler.problem.missingSerialVersion"; //$NON-NLS-1$
87
public static final String JavaDoc OPTION_ReportVarargsArgumentNeedCast = "org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast"; //$NON-NLS-1$
88
public static final String JavaDoc OPTION_Source = "org.eclipse.jdt.core.compiler.source"; //$NON-NLS-1$
89
public static final String JavaDoc OPTION_TargetPlatform = "org.eclipse.jdt.core.compiler.codegen.targetPlatform"; //$NON-NLS-1$
90
public static final String JavaDoc OPTION_Compliance = "org.eclipse.jdt.core.compiler.compliance"; //$NON-NLS-1$
91
public static final String JavaDoc OPTION_Encoding = "org.eclipse.jdt.core.encoding"; //$NON-NLS-1$
92
public static final String JavaDoc OPTION_MaxProblemPerUnit = "org.eclipse.jdt.core.compiler.maxProblemPerUnit"; //$NON-NLS-1$
93
public static final String JavaDoc OPTION_TaskTags = "org.eclipse.jdt.core.compiler.taskTags"; //$NON-NLS-1$
94
public static final String JavaDoc OPTION_TaskPriorities = "org.eclipse.jdt.core.compiler.taskPriorities"; //$NON-NLS-1$
95
public static final String JavaDoc OPTION_TaskCaseSensitive = "org.eclipse.jdt.core.compiler.taskCaseSensitive"; //$NON-NLS-1$
96
public static final String JavaDoc OPTION_InlineJsr = "org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode"; //$NON-NLS-1$
97
public static final String JavaDoc OPTION_ReportNullReference = "org.eclipse.jdt.core.compiler.problem.nullReference"; //$NON-NLS-1$
98
public static final String JavaDoc OPTION_ReportPotentialNullReference = "org.eclipse.jdt.core.compiler.problem.potentialNullReference"; //$NON-NLS-1$
99
public static final String JavaDoc OPTION_ReportRedundantNullCheck = "org.eclipse.jdt.core.compiler.problem.redundantNullCheck"; //$NON-NLS-1$
100
public static final String JavaDoc OPTION_ReportAutoboxing = "org.eclipse.jdt.core.compiler.problem.autoboxing"; //$NON-NLS-1$
101
public static final String JavaDoc OPTION_ReportAnnotationSuperInterface = "org.eclipse.jdt.core.compiler.problem.annotationSuperInterface"; //$NON-NLS-1$
102
public static final String JavaDoc OPTION_ReportMissingOverrideAnnotation = "org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation"; //$NON-NLS-1$
103
public static final String JavaDoc OPTION_ReportMissingDeprecatedAnnotation = "org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation"; //$NON-NLS-1$
104
public static final String JavaDoc OPTION_ReportIncompleteEnumSwitch = "org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch"; //$NON-NLS-1$
105
public static final String JavaDoc OPTION_ReportForbiddenReference = "org.eclipse.jdt.core.compiler.problem.forbiddenReference"; //$NON-NLS-1$
106
public static final String JavaDoc OPTION_ReportDiscouragedReference = "org.eclipse.jdt.core.compiler.problem.discouragedReference"; //$NON-NLS-1$
107
public static final String JavaDoc OPTION_SuppressWarnings = "org.eclipse.jdt.core.compiler.problem.suppressWarnings"; //$NON-NLS-1$
108
public static final String JavaDoc OPTION_ReportUnhandledWarningToken = "org.eclipse.jdt.core.compiler.problem.unhandledWarningToken"; //$NON-NLS-1$
109
public static final String JavaDoc OPTION_ReportUnusedLabel = "org.eclipse.jdt.core.compiler.problem.unusedLabel"; //$NON-NLS-1$
110
public static final String JavaDoc OPTION_FatalOptionalError = "org.eclipse.jdt.core.compiler.problem.fatalOptionalError"; //$NON-NLS-1$
111
public static final String JavaDoc OPTION_ReportParameterAssignment = "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; //$NON-NLS-1$
112
public static final String JavaDoc OPTION_ReportFallthroughCase = "org.eclipse.jdt.core.compiler.problem.fallthroughCase"; //$NON-NLS-1$
113
public static final String JavaDoc OPTION_ReportOverridingMethodWithoutSuperInvocation = "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$
114
public static final String JavaDoc OPTION_GenerateClassFiles = "org.eclipse.jdt.core.compiler.generateClassFiles"; //$NON-NLS-1$
115
public static final String JavaDoc OPTION_Process_Annotations = "org.eclipse.jdt.core.compiler.processAnnotations"; //$NON-NLS-1$
116

117     // Backward compatibility
118
public static final String JavaDoc OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
119
public static final String JavaDoc OPTION_ReportMissingAnnotation = "org.eclipse.jdt.core.compiler.problem.missingAnnotation"; //$NON-NLS-1$
120
public static final String JavaDoc OPTION_ReportMissingJavadoc = "org.eclipse.jdt.core.compiler.problem.missingJavadoc"; //$NON-NLS-1$
121

122     /**
123      * Possible values for configurable options
124      */

125     public static final String JavaDoc GENERATE = "generate";//$NON-NLS-1$
126
public static final String JavaDoc DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
127
public static final String JavaDoc PRESERVE = "preserve"; //$NON-NLS-1$
128
public static final String JavaDoc OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
129
public static final String JavaDoc VERSION_1_1 = "1.1"; //$NON-NLS-1$
130
public static final String JavaDoc VERSION_1_2 = "1.2"; //$NON-NLS-1$
131
public static final String JavaDoc VERSION_1_3 = "1.3"; //$NON-NLS-1$
132
public static final String JavaDoc VERSION_1_4 = "1.4"; //$NON-NLS-1$
133
public static final String JavaDoc VERSION_JSR14 = "jsr14"; //$NON-NLS-1$
134
public static final String JavaDoc VERSION_1_5 = "1.5"; //$NON-NLS-1$
135
public static final String JavaDoc VERSION_1_6 = "1.6"; //$NON-NLS-1$
136
public static final String JavaDoc VERSION_1_7 = "1.7"; //$NON-NLS-1$
137
public static final String JavaDoc ERROR = "error"; //$NON-NLS-1$
138
public static final String JavaDoc WARNING = "warning"; //$NON-NLS-1$
139
public static final String JavaDoc IGNORE = "ignore"; //$NON-NLS-1$
140
public static final String JavaDoc ENABLED = "enabled"; //$NON-NLS-1$
141
public static final String JavaDoc DISABLED = "disabled"; //$NON-NLS-1$
142
public static final String JavaDoc PUBLIC = "public"; //$NON-NLS-1$
143
public static final String JavaDoc PROTECTED = "protected"; //$NON-NLS-1$
144
public static final String JavaDoc DEFAULT = "default"; //$NON-NLS-1$
145
public static final String JavaDoc PRIVATE = "private"; //$NON-NLS-1$
146

147     /**
148      * Bit mask for configurable problems (error/warning threshold)
149      */

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     // Map: String optionKey --> Long irritant>
204
private static Map JavaDoc OptionToIrritants;
205
206     // Default severity level for handlers
207
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         /*| NullReference -- keep JavaCore#getDefaultOptions comment in sync */;
236
237     // By default only lines and source attributes are generated.
238
public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES;
239
240     public long complianceLevel = ClassFileConstants.JDK1_4; // by default be compliant with 1.4
241
public long sourceLevel = ClassFileConstants.JDK1_3; //1.3 source behavior by default
242
public long targetJDK = ClassFileConstants.JDK1_2; // default generates for JVM1.2
243

244     // source encoding format
245
public String JavaDoc defaultEncoding = null; // will use the platform default encoding
246

247     // print what unit is being processed
248
public boolean verbose = Compiler.DEBUG;
249
250     // indicates if reference info is desired
251
public boolean produceReferenceInfo = false;
252
253     // indicates if unused/optimizable local variables need to be preserved (debugging purpose)
254
public boolean preserveAllLocalVariables = false;
255
256     // indicates whether literal expressions are inlined at parse-time or not
257
public boolean parseLiteralExpressionsAsConstants = true;
258
259     // max problems per compilation unit
260
public int maxProblemsPerUnit = 100; // no more than 100 problems per default
261

262     // tags used to recognize tasks in comments
263
public char[][] taskTags = null;
264     public char[][] taskPriorites = null;
265     public boolean isTaskCaseSensitive = true;
266
267     // deprecation report
268
public boolean reportDeprecationInsideDeprecatedCode = false;
269     public boolean reportDeprecationWhenOverridingDeprecatedMethod = false;
270
271     // unused parameters report
272
public boolean reportUnusedParameterWhenImplementingAbstract = false;
273     public boolean reportUnusedParameterWhenOverridingConcrete = false;
274     public boolean reportUnusedParameterIncludeDocCommentReference = true;
275
276     // unused declaration of thrown exception
277
public boolean reportUnusedDeclaredThrownExceptionWhenOverriding = false;
278
279     // constructor/setter parameter hiding
280
public boolean reportSpecialParameterHidingField = false;
281
282     // check javadoc comments tags
283
public int reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic;
284     public boolean reportInvalidJavadocTags = false;
285     public boolean reportInvalidJavadocTagsDeprecatedRef = false;
286     public boolean reportInvalidJavadocTagsNotVisibleRef = false;
287
288     // check missing javadoc tags
289
public int reportMissingJavadocTagsVisibility = ClassFileConstants.AccPublic;
290     public boolean reportMissingJavadocTagsOverriding = false;
291
292     // check missing javadoc comments
293
public int reportMissingJavadocCommentsVisibility = ClassFileConstants.AccPublic;
294     public boolean reportMissingJavadocCommentsOverriding = false;
295
296     // JSR bytecode inlining
297
public boolean inlineJsrBytecode = false;
298
299     // javadoc comment support
300
public boolean docCommentSupport = false;
301
302     // suppress warning annotation
303
public boolean suppressWarnings = true;
304
305     // treat optional error as fatal or just like warning?
306
public boolean treatOptionalErrorAsFatal = true;
307
308     // parser perform statements recovery
309
public boolean performMethodsFullRecovery = true;
310
311     // parser perform statements recovery
312
public boolean performStatementsRecovery = true;
313
314     // store annotations
315
public boolean storeAnnotations = false;
316
317     // annotation processing
318
public boolean generateClassFiles = true;
319
320     // Enable annotation processing by default only in batch mode
321
public boolean processAnnotations = false;
322
323     /**
324      * Initializing the compiler options with defaults
325      */

326     public CompilerOptions(){
327         // use default options
328
}
329
330     /**
331      * Initializing the compiler options with external settings
332      * @param settings
333      */

334     public CompilerOptions(Map JavaDoc settings){
335
336         if (settings == null) return;
337         set(settings);
338     }
339
340     /**
341      * @deprecated used to preserve 3.1 and 3.2M4 compatibility of some Compiler constructors
342      */

343     public CompilerOptions(Map JavaDoc settings, boolean parseLiteralExpressionsAsConstants){
344         this(settings);
345         this.parseLiteralExpressionsAsConstants = parseLiteralExpressionsAsConstants;
346     }
347
348     public Map JavaDoc getMap() {
349         Map JavaDoc optionsMap = new HashMap JavaDoc(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 JavaDoc(CharOperation.concatWith(this.taskTags,',')));
419         optionsMap.put(OPTION_TaskPriorities, this.taskPriorites == null ? Util.EMPTY_STRING : new String JavaDoc(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     /**
441      * Return the most specific option key controlling this irritant. Note that in some case, some irritant is controlled by
442      * other master options (e.g. javadoc, deprecation, etc.).
443      * This information is intended for grouping purpose (several problems governed by a rule)
444      */

445     public static String JavaDoc optionKeyFromIrritant(long irritant) {
446         // keep in sync with warningTokens and warningTokenToIrritant
447
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 JavaDoc optionName) {
565         if (OptionToIrritants == null) {
566             long irritant = 0;
567             for (int i = 0; i < 64; i++) {
568                 irritant <<= 1;
569                 String JavaDoc optionKey = optionKeyFromIrritant(irritant);
570                 if (optionKey == null) continue;
571                 OptionToIrritants.put(optionKey, new Long JavaDoc(irritant));
572             }
573         }
574         Long JavaDoc irritant = (Long JavaDoc)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 JavaDoc 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 JavaDoc 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 JavaDoc optionsMap) {
611
612         Object JavaDoc 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; // forced from 1.5 mode on
674
}
675         if ((optionValue = optionsMap.get(OPTION_Encoding)) != null) {
676             if (optionValue instanceof String JavaDoc) {
677                 this.defaultEncoding = null;
678                 String JavaDoc stringValue = (String JavaDoc) optionValue;
679                 if (stringValue.length() > 0){
680                     try {
681                         new InputStreamReader JavaDoc(new ByteArrayInputStream JavaDoc(new byte[0]), stringValue);
682                         this.defaultEncoding = stringValue;
683                     } catch(UnsupportedEncodingException JavaDoc e){
684                         // ignore unsupported encoding
685
}
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 JavaDoc) {
719                 String JavaDoc stringValue = (String JavaDoc) optionValue;
720                 try {
721                     int val = Integer.parseInt(stringValue);
722                     if (val >= 0) this.maxProblemsPerUnit = val;
723                 } catch(NumberFormatException JavaDoc e){
724                     // ignore ill-formatted limit
725
}
726             }
727         }
728         if ((optionValue = optionsMap.get(OPTION_TaskTags)) != null) {
729             if (optionValue instanceof String JavaDoc) {
730                 String JavaDoc stringValue = (String JavaDoc) 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 JavaDoc) {
740                 String JavaDoc stringValue = (String JavaDoc) 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) { // only optional if target < 1.5 (inlining on from 1.5 on)
757
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         // Javadoc options
828
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; // annotation processing requires annotation to be stored
923
this.docCommentSupport = true; // annotation processing requires javadoc processing
924
} else if (DISABLED.equals(optionValue)) {
925                 this.processAnnotations = false;
926                 this.storeAnnotations = false;
927             }
928         }
929     }
930
931     public String JavaDoc toString() {
932
933         StringBuffer JavaDoc buf = new StringBuffer JavaDoc("CompilerOptions:"); //$NON-NLS-1$
934
buf.append("\n\t- local variables debug attributes: ").append((this.produceDebugAttributes & ClassFileConstants.ATTR_VARS) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
935
buf.append("\n\t- line number debug attributes: ").append((this.produceDebugAttributes & ClassFileConstants.ATTR_LINES) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
936
buf.append("\n\t- source debug attributes: ").append((this.produceDebugAttributes & ClassFileConstants.ATTR_SOURCE) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
937
buf.append("\n\t- preserve all local variables: ").append(this.preserveAllLocalVariables ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
938
buf.append("\n\t- method with constructor name: ").append(getSeverityString(MethodWithConstructorName)); //$NON-NLS-1$
939
buf.append("\n\t- overridden package default method: ").append(getSeverityString(OverriddenPackageDefaultMethod)); //$NON-NLS-1$
940
buf.append("\n\t- deprecation: ").append(getSeverityString(UsingDeprecatedAPI)); //$NON-NLS-1$
941
buf.append("\n\t- masked catch block: ").append(getSeverityString(MaskedCatchBlock)); //$NON-NLS-1$
942
buf.append("\n\t- unused local variable: ").append(getSeverityString(UnusedLocalVariable)); //$NON-NLS-1$
943
buf.append("\n\t- unused parameter: ").append(getSeverityString(UnusedArgument)); //$NON-NLS-1$
944
buf.append("\n\t- unused import: ").append(getSeverityString(UnusedImport)); //$NON-NLS-1$
945
buf.append("\n\t- synthetic access emulation: ").append(getSeverityString(AccessEmulation)); //$NON-NLS-1$
946
buf.append("\n\t- assignment with no effect: ").append(getSeverityString(NoEffectAssignment)); //$NON-NLS-1$
947
buf.append("\n\t- non externalized string: ").append(getSeverityString(NonExternalizedString)); //$NON-NLS-1$
948
buf.append("\n\t- static access receiver: ").append(getSeverityString(NonStaticAccessToStatic)); //$NON-NLS-1$
949
buf.append("\n\t- indirect static access: ").append(getSeverityString(IndirectStaticAccess)); //$NON-NLS-1$
950
buf.append("\n\t- incompatible non inherited interface method: ").append(getSeverityString(IncompatibleNonInheritedInterfaceMethod)); //$NON-NLS-1$
951
buf.append("\n\t- unused private member: ").append(getSeverityString(UnusedPrivateMember)); //$NON-NLS-1$
952
buf.append("\n\t- local variable hiding another variable: ").append(getSeverityString(LocalVariableHiding)); //$NON-NLS-1$
953
buf.append("\n\t- field hiding another variable: ").append(getSeverityString(FieldHiding)); //$NON-NLS-1$
954
buf.append("\n\t- type hiding another type: ").append(getSeverityString(TypeHiding)); //$NON-NLS-1$
955
buf.append("\n\t- possible accidental boolean assignment: ").append(getSeverityString(AccidentalBooleanAssign)); //$NON-NLS-1$
956
buf.append("\n\t- superfluous semicolon: ").append(getSeverityString(EmptyStatement)); //$NON-NLS-1$
957
buf.append("\n\t- uncommented empty block: ").append(getSeverityString(UndocumentedEmptyBlock)); //$NON-NLS-1$
958
buf.append("\n\t- unnecessary type check: ").append(getSeverityString(UnnecessaryTypeCheck)); //$NON-NLS-1$
959
buf.append("\n\t- javadoc comment support: ").append(this.docCommentSupport ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
960
buf.append("\n\t\t+ invalid javadoc: ").append(getSeverityString(InvalidJavadoc)); //$NON-NLS-1$
961
buf.append("\n\t\t+ report invalid javadoc tags: ").append(this.reportInvalidJavadocTags ? ENABLED : DISABLED); //$NON-NLS-1$
962
buf.append("\n\t\t\t* deprecated references: ").append(this.reportInvalidJavadocTagsDeprecatedRef ? ENABLED : DISABLED); //$NON-NLS-1$
963
buf.append("\n\t\t\t* not visible references: ").append(this.reportInvalidJavadocTagsNotVisibleRef ? ENABLED : DISABLED); //$NON-NLS-1$
964
buf.append("\n\t\t+ visibility level to report invalid javadoc tags: ").append(getVisibilityString(this.reportInvalidJavadocTagsVisibility)); //$NON-NLS-1$
965
buf.append("\n\t\t+ missing javadoc tags: ").append(getSeverityString(MissingJavadocTags)); //$NON-NLS-1$
966
buf.append("\n\t\t+ visibility level to report missing javadoc tags: ").append(getVisibilityString(this.reportMissingJavadocTagsVisibility)); //$NON-NLS-1$
967
buf.append("\n\t\t+ report missing javadoc tags in overriding methods: ").append(this.reportMissingJavadocTagsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
968
buf.append("\n\t\t+ missing javadoc comments: ").append(getSeverityString(MissingJavadocComments)); //$NON-NLS-1$
969
buf.append("\n\t\t+ visibility level to report missing javadoc comments: ").append(getVisibilityString(this.reportMissingJavadocCommentsVisibility)); //$NON-NLS-1$
970
buf.append("\n\t\t+ report missing javadoc comments in overriding methods: ").append(this.reportMissingJavadocCommentsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
971
buf.append("\n\t- finally block not completing normally: ").append(getSeverityString(FinallyBlockNotCompleting)); //$NON-NLS-1$
972
buf.append("\n\t- unused declared thrown exception: ").append(getSeverityString(UnusedDeclaredThrownException)); //$NON-NLS-1$
973
buf.append("\n\t- unused declared thrown exception when overriding: ").append(this.reportUnusedDeclaredThrownExceptionWhenOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
974
buf.append("\n\t- unnecessary else: ").append(getSeverityString(UnnecessaryElse)); //$NON-NLS-1$
975
buf.append("\n\t- JDK compliance level: "+ versionFromJdkLevel(this.complianceLevel)); //$NON-NLS-1$
976
buf.append("\n\t- JDK source level: "+ versionFromJdkLevel(this.sourceLevel)); //$NON-NLS-1$
977
buf.append("\n\t- JDK target level: "+ versionFromJdkLevel(this.targetJDK)); //$NON-NLS-1$
978
buf.append("\n\t- verbose : ").append(this.verbose ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
979
buf.append("\n\t- produce reference info : ").append(this.produceReferenceInfo ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
980
buf.append("\n\t- parse literal expressions as constants : ").append(this.parseLiteralExpressionsAsConstants ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
981
buf.append("\n\t- encoding : ").append(this.defaultEncoding == null ? "<default>" : this.defaultEncoding); //$NON-NLS-1$ //$NON-NLS-2$
982
buf.append("\n\t- task tags: ").append(this.taskTags == null ? Util.EMPTY_STRING : new String JavaDoc(CharOperation.concatWith(this.taskTags,','))); //$NON-NLS-1$
983
buf.append("\n\t- task priorities : ").append(this.taskPriorites == null ? Util.EMPTY_STRING : new String JavaDoc(CharOperation.concatWith(this.taskPriorites,','))); //$NON-NLS-1$
984
buf.append("\n\t- report deprecation inside deprecated code : ").append(this.reportDeprecationInsideDeprecatedCode ? ENABLED : DISABLED); //$NON-NLS-1$
985
buf.append("\n\t- report deprecation when overriding deprecated method : ").append(this.reportDeprecationWhenOverridingDeprecatedMethod ? ENABLED : DISABLED); //$NON-NLS-1$
986
buf.append("\n\t- report unused parameter when implementing abstract method : ").append(this.reportUnusedParameterWhenImplementingAbstract ? ENABLED : DISABLED); //$NON-NLS-1$
987
buf.append("\n\t- report unused parameter when overriding concrete method : ").append(this.reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED); //$NON-NLS-1$
988
buf.append("\n\t- report unused parameter include doc comment reference : ").append(this.reportUnusedParameterIncludeDocCommentReference ? ENABLED : DISABLED); //$NON-NLS-1$
989
buf.append("\n\t- report constructor/setter parameter hiding existing field : ").append(this.reportSpecialParameterHidingField ? ENABLED : DISABLED); //$NON-NLS-1$
990
buf.append("\n\t- inline JSR bytecode : ").append(this.inlineJsrBytecode ? ENABLED : DISABLED); //$NON-NLS-1$
991
buf.append("\n\t- unsafe type operation: ").append(getSeverityString(UncheckedTypeOperation)); //$NON-NLS-1$
992
buf.append("\n\t- unsafe raw type: ").append(getSeverityString(RawTypeReference)); //$NON-NLS-1$
993
buf.append("\n\t- final bound for type parameter: ").append(getSeverityString(FinalParameterBound)); //$NON-NLS-1$
994
buf.append("\n\t- missing serialVersionUID: ").append(getSeverityString(MissingSerialVersion)); //$NON-NLS-1$
995
buf.append("\n\t- varargs argument need cast: ").append(getSeverityString(VarargsArgumentNeedCast)); //$NON-NLS-1$
996
buf.append("\n\t- forbidden reference to type with access restriction: ").append(getSeverityString(ForbiddenReference)); //$NON-NLS-1$
997
buf.append("\n\t- discouraged reference to type with access restriction: ").append(getSeverityString(DiscouragedReference)); //$NON-NLS-1$
998
buf.append("\n\t- null reference: ").append(getSeverityString(NullReference)); //$NON-NLS-1$
999
buf.append("\n\t- potential null reference: ").append(getSeverityString(PotentialNullReference)); //$NON-NLS-1$
1000
buf.append("\n\t- redundant null check: ").append(getSeverityString(RedundantNullCheck)); //$NON-NLS-1$
1001
buf.append("\n\t- autoboxing: ").append(getSeverityString(AutoBoxing)); //$NON-NLS-1$
1002
buf.append("\n\t- annotation super interface: ").append(getSeverityString(AnnotationSuperInterface)); //$NON-NLS-1$
1003
buf.append("\n\t- missing @Override annotation: ").append(getSeverityString(MissingOverrideAnnotation)); //$NON-NLS-1$
1004
buf.append("\n\t- missing @Deprecated annotation: ").append(getSeverityString(MissingDeprecatedAnnotation)); //$NON-NLS-1$
1005
buf.append("\n\t- incomplete enum switch: ").append(getSeverityString(IncompleteEnumSwitch)); //$NON-NLS-1$
1006
buf.append("\n\t- suppress warnings: ").append(this.suppressWarnings ? ENABLED : DISABLED); //$NON-NLS-1$
1007
buf.append("\n\t- unhandled warning token: ").append(getSeverityString(UnhandledWarningToken)); //$NON-NLS-1$
1008
buf.append("\n\t- unused label: ").append(getSeverityString(UnusedLabel)); //$NON-NLS-1$
1009
buf.append("\n\t- treat optional error as fatal: ").append(this.treatOptionalErrorAsFatal ? ENABLED : DISABLED); //$NON-NLS-1$
1010
buf.append("\n\t- parameter assignment: ").append(getSeverityString(ParameterAssignment)); //$NON-NLS-1$
1011
buf.append("\n\t- generate class files: ").append(this.generateClassFiles ? ENABLED : DISABLED); //$NON-NLS-1$
1012
buf.append("\n\t- process annotations: ").append(this.processAnnotations ? ENABLED : DISABLED); //$NON-NLS-1$
1013
return buf.toString();
1014    }
1015
1016    void updateSeverity(long irritant, Object JavaDoc 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 JavaDoc versionID) {
1029        if (versionID instanceof String JavaDoc) {
1030            String JavaDoc version = (String JavaDoc) versionID;
1031            // verification is optimized for all versions with same length and same "1." prefix
1032
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; // unknown
1050
}
1051            }
1052            if (VERSION_JSR14.equals(versionID)) {
1053                return ClassFileConstants.JDK1_4;
1054            }
1055        }
1056        return 0; // unknown
1057
}
1058
1059    public static String JavaDoc 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; // unknown version
1091
}
1092
1093    /**
1094     * Return all warning option names for use as keys in compiler options maps.
1095     * @return all warning option names
1096     * TODO (maxime) revise for ensuring completeness
1097     */

1098    public static String JavaDoc[] warningOptionNames() {
1099        String JavaDoc[] 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 JavaDoc warningTokenFromIrritant(long irritant) {
1154        // keep in sync with warningTokens and warningTokenToIrritant
1155
int irritantInt = (int) irritant;
1156        if (irritantInt == irritant) {
1157            switch (irritantInt) {
1158                case (int) (InvalidJavadoc | UsingDeprecatedAPI) :
1159                case (int) UsingDeprecatedAPI :
1160                    return "deprecation"; //$NON-NLS-1$
1161
case (int) FinallyBlockNotCompleting :
1162                    return "finally"; //$NON-NLS-1$
1163
case (int) FieldHiding :
1164                case (int) LocalVariableHiding :
1165                case (int) MaskedCatchBlock :
1166                    return "hiding"; //$NON-NLS-1$
1167
case (int) NonExternalizedString :
1168                    return "nls"; //$NON-NLS-1$
1169
case (int) UnnecessaryTypeCheck :
1170                    return "cast"; //$NON-NLS-1$
1171
case (int) UnusedLocalVariable :
1172                case (int) UnusedArgument :
1173                case (int) UnusedImport :
1174                case (int) UnusedPrivateMember:
1175                case (int) UnusedDeclaredThrownException:
1176                    return "unused"; //$NON-NLS-1$
1177
case (int) IndirectStaticAccess :
1178                case (int) NonStaticAccessToStatic :
1179                    return "static-access"; //$NON-NLS-1$
1180
case (int) AccessEmulation :
1181                    return "synthetic-access"; //$NON-NLS-1$
1182
case (int) UnqualifiedFieldAccess :
1183                    return "unqualified-field-access"; //$NON-NLS-1$
1184
case (int) UncheckedTypeOperation :
1185                    return "unchecked"; //$NON-NLS-1$
1186
}
1187        } else {
1188            irritantInt = (int)(irritant >>> 32);
1189            switch (irritantInt) {
1190                case (int)(MissingSerialVersion >>> 32) :
1191                    return "serial"; //$NON-NLS-1$
1192
case (int)(AutoBoxing >>> 32) :
1193                    return "boxing"; //$NON-NLS-1$
1194
case (int)(TypeHiding >>> 32) :
1195                    return "hiding"; //$NON-NLS-1$
1196
case (int)(IncompleteEnumSwitch >>> 32) :
1197                    return "incomplete-switch"; //$NON-NLS-1$
1198
case (int)(MissingDeprecatedAnnotation >>> 32) :
1199                    return "dep-ann"; //$NON-NLS-1$
1200
case (int)(RawTypeReference >>> 32):
1201                    return "unchecked"; //$NON-NLS-1$
1202
case (int) (UnusedLabel >>> 32):
1203                    return "unused"; //$NON-NLS-1$
1204
case (int) (DiscouragedReference >>> 32) :
1205                case (int) (ForbiddenReference >>> 32) :
1206                    return "restriction"; //$NON-NLS-1$
1207
case (int) (NullReference >>> 32) :
1208                case (int) (PotentialNullReference >>> 32) :
1209                case (int) (RedundantNullCheck >>> 32) :
1210                    return "null"; //$NON-NLS-1$
1211
case (int) (FallthroughCase >>> 32) :
1212                    return "fallthrough"; //$NON-NLS-1$
1213
case (int) (OverridingMethodWithoutSuperInvocation >>> 32) :
1214                    return "super"; //$NON-NLS-1$
1215
}
1216        }
1217        return null;
1218    }
1219    // keep in sync with warningTokenToIrritant and warningTokenFromIrritant
1220
public final static String JavaDoc[] warningTokens = {
1221        "all", //$NON-NLS-1$
1222
"boxing", //$NON-NLS-1$
1223
"cast", //$NON-NLS-1$
1224
"dep-ann", //$NON-NLS-1$
1225
"deprecation", //$NON-NLS-1$
1226
"fallthrough", //$NON-NLS-1$
1227
"finally", //$NON-NLS-1$
1228
"hiding", //$NON-NLS-1$
1229
"incomplete-switch", //$NON-NLS-1$
1230
"nls", //$NON-NLS-1$
1231
"null", //$NON-NLS-1$
1232
"restriction", //$NON-NLS-1$
1233
"serial", //$NON-NLS-1$
1234
"static-access", //$NON-NLS-1$
1235
"super", //$NON-NLS-1$
1236
"synthetic-access", //$NON-NLS-1$
1237
"unchecked", //$NON-NLS-1$
1238
"unqualified-field-access", //$NON-NLS-1$
1239
"unused", //$NON-NLS-1$
1240
};
1241    public static long warningTokenToIrritant(String JavaDoc warningToken) {
1242        // keep in sync with warningTokens and warningTokenFromIrritant
1243
if (warningToken == null || warningToken.length() == 0) return 0;
1244        switch (warningToken.charAt(0)) {
1245            case 'a' :
1246                if ("all".equals(warningToken)) //$NON-NLS-1$
1247
return 0xFFFFFFFFFFFFFFFFl; // suppress all warnings
1248
break;
1249            case 'b' :
1250                if ("boxing".equals(warningToken)) //$NON-NLS-1$
1251
return AutoBoxing;
1252                break;
1253            case 'c' :
1254                if ("cast".equals(warningToken)) //$NON-NLS-1$
1255
return UnnecessaryTypeCheck;
1256                break;
1257            case 'd' :
1258                if ("deprecation".equals(warningToken)) //$NON-NLS-1$
1259
return UsingDeprecatedAPI;
1260                if ("dep-ann".equals(warningToken)) //$NON-NLS-1$
1261
return MissingDeprecatedAnnotation;
1262                break;
1263            case 'f' :
1264                if ("fallthrough".equals(warningToken)) //$NON-NLS-1$
1265
return FallthroughCase;
1266                if ("finally".equals(warningToken)) //$NON-NLS-1$
1267
return FinallyBlockNotCompleting;
1268                break;
1269            case 'h' :
1270                if ("hiding".equals(warningToken)) //$NON-NLS-1$
1271
return FieldHiding | LocalVariableHiding | MaskedCatchBlock | TypeHiding;
1272            case 'i' :
1273                if ("incomplete-switch".equals(warningToken)) //$NON-NLS-1$
1274
return IncompleteEnumSwitch;
1275                break;
1276            case 'n' :
1277                if ("nls".equals(warningToken)) //$NON-NLS-1$
1278
return NonExternalizedString;
1279                if ("null".equals(warningToken)) //$NON-NLS-1$
1280
return NullReference | PotentialNullReference | RedundantNullCheck;
1281                break;
1282            case 'r' :
1283                if ("restriction".equals(warningToken)) //$NON-NLS-1$
1284
return DiscouragedReference | ForbiddenReference;
1285                break;
1286            case 's' :
1287                if ("serial".equals(warningToken)) //$NON-NLS-1$
1288
return MissingSerialVersion;
1289                if ("static-access".equals(warningToken)) //$NON-NLS-1$
1290
return IndirectStaticAccess | NonStaticAccessToStatic;
1291                if ("synthetic-access".equals(warningToken)) //$NON-NLS-1$
1292
return AccessEmulation;
1293                if ("super".equals(warningToken)) { //$NON-NLS-1$
1294
return OverridingMethodWithoutSuperInvocation;
1295                }
1296                break;
1297            case 'u' :
1298                if ("unused".equals(warningToken)) //$NON-NLS-1$
1299
return UnusedLocalVariable | UnusedArgument | UnusedPrivateMember | UnusedDeclaredThrownException | UnusedLabel | UnusedImport;
1300                if ("unchecked".equals(warningToken)) //$NON-NLS-1$
1301
return UncheckedTypeOperation | RawTypeReference;
1302                if ("unqualified-field-access".equals(warningToken)) //$NON-NLS-1$
1303
return UnqualifiedFieldAccess;
1304                break;
1305        }
1306        return 0;
1307    }
1308}
1309
Popular Tags