View | Details | Raw Unified | Return to bug 295551 | Differences between
and this patch

Collapse All | Expand All

(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (-3 / +18 lines)
Lines 11-16 Link Here
11
 *     Tom Tromey - Contribution for bug 159641
11
 *     Tom Tromey - Contribution for bug 159641
12
 *     Benjamin Muskalla - Contribution for bug 239066
12
 *     Benjamin Muskalla - Contribution for bug 239066
13
 *     Stephan Herrmann  - Contribution for bug 236385
13
 *     Stephan Herrmann  - Contribution for bug 236385
14
 *     Stephan Herrmann  - Contribution for bug 295551
14
 *******************************************************************************/
15
 *******************************************************************************/
15
package org.eclipse.jdt.internal.compiler.batch;
16
package org.eclipse.jdt.internal.compiler.batch;
16
17
Lines 3339-3347 Link Here
3339
				setSeverity(CompilerOptions.OPTION_ReportMissingSerialVersion, severity, isEnabling);
3340
				setSeverity(CompilerOptions.OPTION_ReportMissingSerialVersion, severity, isEnabling);
3340
				return;
3341
				return;
3341
			} else if (token.equals("suppress")) {//$NON-NLS-1$
3342
			} else if (token.equals("suppress")) {//$NON-NLS-1$
3342
				this.options.put(
3343
				switch(severity) {
3343
					CompilerOptions.OPTION_SuppressWarnings,
3344
					case ProblemSeverities.Warning :
3344
					isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED);
3345
						this.options.put(
3346
								CompilerOptions.OPTION_SuppressWarnings,
3347
								isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED);
3348
						this.options.put(
3349
								CompilerOptions.OPTION_SuppressOptionalErrors,
3350
								CompilerOptions.DISABLED);
3351
						break;
3352
					case ProblemSeverities.Error :
3353
						this.options.put(
3354
								CompilerOptions.OPTION_SuppressWarnings,
3355
								isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED);
3356
						this.options.put(
3357
							CompilerOptions.OPTION_SuppressOptionalErrors,
3358
							isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED);
3359
				}
3345
				return;
3360
				return;
3346
			} else if (token.equals("static-access")) { //$NON-NLS-1$
3361
			} else if (token.equals("static-access")) { //$NON-NLS-1$
3347
				setSeverity(CompilerOptions.OPTION_ReportNonStaticAccessToStatic, severity, isEnabling);
3362
				setSeverity(CompilerOptions.OPTION_ReportNonStaticAccessToStatic, severity, isEnabling);
(-)batch/org/eclipse/jdt/internal/compiler/batch/messages.properties (+2 lines)
Lines 298-303 Link Here
298
\      staticReceiver     + non-static reference to static member\n\
298
\      staticReceiver     + non-static reference to static member\n\
299
\      super                overriding a method without making a super invocation\n\
299
\      super                overriding a method without making a super invocation\n\
300
\      suppress           + enable @SuppressWarnings\n\
300
\      suppress           + enable @SuppressWarnings\n\
301
\                           When used with -err:, it can also silent optional\n\
302
\                           errors and warnings\n\
301
\      syncOverride         missing synchronized in synchr. method override\n\
303
\      syncOverride         missing synchronized in synchr. method override\n\
302
\      syntheticAccess      synthetic access for innerclass\n\
304
\      syntheticAccess      synthetic access for innerclass\n\
303
\      tasks(<tags separated by |>) tasks identified by tags inside comments\n\
305
\      tasks(<tags separated by |>) tasks identified by tags inside comments\n\
(-)compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java (-4 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann  - Contribution for bug 295551
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.ast;
12
package org.eclipse.jdt.internal.compiler.ast;
12
13
Lines 217-232 Link Here
217
	nextProblem: for (int iProblem = 0, length = problemCount; iProblem < length; iProblem++) {
218
	nextProblem: for (int iProblem = 0, length = problemCount; iProblem < length; iProblem++) {
218
		CategorizedProblem problem = problems[iProblem];
219
		CategorizedProblem problem = problems[iProblem];
219
		int problemID = problem.getID();
220
		int problemID = problem.getID();
221
		int irritant = ProblemReporter.getIrritant(problemID);
220
		if (problem.isError()) {
222
		if (problem.isError()) {
221
			if (problemID != IProblem.UnusedWarningToken) {
223
			if (problemID != IProblem.UnusedWarningToken) {
222
			// tolerate unused warning tokens which were promoted as errors
224
				// tolerate unused warning tokens which were promoted as errors
223
				hasErrors = true;
225
				hasErrors = true;
224
			}
226
			}
225
			continue;
227
			if (irritant == 0 || !options.suppressOptionalErrors) {
228
				continue;
229
			}
226
		}
230
		}
227
		int start = problem.getSourceStart();
231
		int start = problem.getSourceStart();
228
		int end = problem.getSourceEnd();
232
		int end = problem.getSourceEnd();
229
		int irritant = ProblemReporter.getIrritant(problemID);
230
		nextSuppress: for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) {
233
		nextSuppress: for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) {
231
			long position = this.suppressWarningScopePositions[iSuppress];
234
			long position = this.suppressWarningScopePositions[iSuppress];
232
			int startSuppress = (int) (position >>> 32);
235
			int startSuppress = (int) (position >>> 32);
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (-1 / +17 lines)
Lines 9-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Muskalla - Contribution for bug 239066
10
 *     Benjamin Muskalla - Contribution for bug 239066
11
 *     Stephan Herrmann  - Contribution for bug 236385
11
 *     Stephan Herrmann  - Contribution for bug 236385
12
 *     Stephan Herrmann  - Contribution for bug 295551
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.jdt.internal.compiler.impl;
14
package org.eclipse.jdt.internal.compiler.impl;
14
15
Lines 112-117 Link Here
112
	public static final String OPTION_ReportForbiddenReference =  "org.eclipse.jdt.core.compiler.problem.forbiddenReference"; //$NON-NLS-1$
113
	public static final String OPTION_ReportForbiddenReference =  "org.eclipse.jdt.core.compiler.problem.forbiddenReference"; //$NON-NLS-1$
113
	public static final String OPTION_ReportDiscouragedReference =  "org.eclipse.jdt.core.compiler.problem.discouragedReference"; //$NON-NLS-1$
114
	public static final String OPTION_ReportDiscouragedReference =  "org.eclipse.jdt.core.compiler.problem.discouragedReference"; //$NON-NLS-1$
114
	public static final String OPTION_SuppressWarnings =  "org.eclipse.jdt.core.compiler.problem.suppressWarnings"; //$NON-NLS-1$
115
	public static final String OPTION_SuppressWarnings =  "org.eclipse.jdt.core.compiler.problem.suppressWarnings"; //$NON-NLS-1$
116
	public static final String OPTION_SuppressOptionalErrors = "org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors"; //$NON-NLS-1$
115
	public static final String OPTION_ReportUnhandledWarningToken =  "org.eclipse.jdt.core.compiler.problem.unhandledWarningToken"; //$NON-NLS-1$
117
	public static final String OPTION_ReportUnhandledWarningToken =  "org.eclipse.jdt.core.compiler.problem.unhandledWarningToken"; //$NON-NLS-1$
116
	public static final String OPTION_ReportUnusedWarningToken =  "org.eclipse.jdt.core.compiler.problem.unusedWarningToken"; //$NON-NLS-1$
118
	public static final String OPTION_ReportUnusedWarningToken =  "org.eclipse.jdt.core.compiler.problem.unusedWarningToken"; //$NON-NLS-1$
117
	public static final String OPTION_ReportUnusedLabel =  "org.eclipse.jdt.core.compiler.problem.unusedLabel"; //$NON-NLS-1$
119
	public static final String OPTION_ReportUnusedLabel =  "org.eclipse.jdt.core.compiler.problem.unusedLabel"; //$NON-NLS-1$
Lines 320-327 Link Here
320
	public boolean reportMissingJavadocCommentsOverriding;
322
	public boolean reportMissingJavadocCommentsOverriding;
321
	/** Indicate whether the JSR bytecode should be inlined to avoid its presence in classfile */
323
	/** Indicate whether the JSR bytecode should be inlined to avoid its presence in classfile */
322
	public boolean inlineJsrBytecode;
324
	public boolean inlineJsrBytecode;
323
	/** Indicate if @SuppressWarning annotation are activated */
325
	/** Indicate if @SuppressWarning annotations are activated */
324
	public boolean suppressWarnings;
326
	public boolean suppressWarnings;
327
	/** Indicate if @SuppressWarning annotations should also suppress optional errors */
328
	public boolean suppressOptionalErrors;
325
	/** Specify if should treat optional error as fatal or just like warning */
329
	/** Specify if should treat optional error as fatal or just like warning */
326
	public boolean treatOptionalErrorAsFatal;
330
	public boolean treatOptionalErrorAsFatal;
327
	/** Specify if parser should perform structural recovery in methods */
331
	/** Specify if parser should perform structural recovery in methods */
Lines 884-889 Link Here
884
		optionsMap.put(OPTION_ReportPotentialNullReference, getSeverityString(PotentialNullReference));
888
		optionsMap.put(OPTION_ReportPotentialNullReference, getSeverityString(PotentialNullReference));
885
		optionsMap.put(OPTION_ReportRedundantNullCheck, getSeverityString(RedundantNullCheck));
889
		optionsMap.put(OPTION_ReportRedundantNullCheck, getSeverityString(RedundantNullCheck));
886
		optionsMap.put(OPTION_SuppressWarnings, this.suppressWarnings ? ENABLED : DISABLED);
890
		optionsMap.put(OPTION_SuppressWarnings, this.suppressWarnings ? ENABLED : DISABLED);
891
		optionsMap.put(OPTION_SuppressOptionalErrors, this.suppressOptionalErrors ? ENABLED : DISABLED);
887
		optionsMap.put(OPTION_ReportUnhandledWarningToken, getSeverityString(UnhandledWarningToken));
892
		optionsMap.put(OPTION_ReportUnhandledWarningToken, getSeverityString(UnhandledWarningToken));
888
		optionsMap.put(OPTION_ReportUnusedWarningToken, getSeverityString(UnusedWarningToken));
893
		optionsMap.put(OPTION_ReportUnusedWarningToken, getSeverityString(UnusedWarningToken));
889
		optionsMap.put(OPTION_ReportParameterAssignment, getSeverityString(ParameterAssignment));
894
		optionsMap.put(OPTION_ReportParameterAssignment, getSeverityString(ParameterAssignment));
Lines 1014-1019 Link Here
1014
		// suppress warning annotation
1019
		// suppress warning annotation
1015
		this.suppressWarnings = true;
1020
		this.suppressWarnings = true;
1016
1021
1022
		// suppress also optional errors
1023
		this.suppressOptionalErrors = false;
1024
1017
		// treat optional error as non fatal
1025
		// treat optional error as non fatal
1018
		this.treatOptionalErrorAsFatal = false;
1026
		this.treatOptionalErrorAsFatal = false;
1019
1027
Lines 1225-1230 Link Here
1225
				this.suppressWarnings = false;
1233
				this.suppressWarnings = false;
1226
			}
1234
			}
1227
		}
1235
		}
1236
		if ((optionValue = optionsMap.get(OPTION_SuppressOptionalErrors)) != null) {
1237
			if (ENABLED.equals(optionValue)) {
1238
				this.suppressOptionalErrors = true;
1239
			} else if (DISABLED.equals(optionValue)) {
1240
				this.suppressOptionalErrors = false;
1241
			}
1242
		}
1228
		if ((optionValue = optionsMap.get(OPTION_FatalOptionalError)) != null) {
1243
		if ((optionValue = optionsMap.get(OPTION_FatalOptionalError)) != null) {
1229
			if (ENABLED.equals(optionValue)) {
1244
			if (ENABLED.equals(optionValue)) {
1230
				this.treatOptionalErrorAsFatal = true;
1245
				this.treatOptionalErrorAsFatal = true;
Lines 1482-1487 Link Here
1482
		buf.append("\n\t- missing @Deprecated annotation: ").append(getSeverityString(MissingDeprecatedAnnotation)); //$NON-NLS-1$
1497
		buf.append("\n\t- missing @Deprecated annotation: ").append(getSeverityString(MissingDeprecatedAnnotation)); //$NON-NLS-1$
1483
		buf.append("\n\t- incomplete enum switch: ").append(getSeverityString(IncompleteEnumSwitch)); //$NON-NLS-1$
1498
		buf.append("\n\t- incomplete enum switch: ").append(getSeverityString(IncompleteEnumSwitch)); //$NON-NLS-1$
1484
		buf.append("\n\t- suppress warnings: ").append(this.suppressWarnings ? ENABLED : DISABLED); //$NON-NLS-1$
1499
		buf.append("\n\t- suppress warnings: ").append(this.suppressWarnings ? ENABLED : DISABLED); //$NON-NLS-1$
1500
		buf.append("\n\t- suppress optional errors: ").append(this.suppressOptionalErrors ? ENABLED : DISABLED); //$NON-NLS-1$
1485
		buf.append("\n\t- unhandled warning token: ").append(getSeverityString(UnhandledWarningToken)); //$NON-NLS-1$
1501
		buf.append("\n\t- unhandled warning token: ").append(getSeverityString(UnhandledWarningToken)); //$NON-NLS-1$
1486
		buf.append("\n\t- unused warning token: ").append(getSeverityString(UnusedWarningToken)); //$NON-NLS-1$
1502
		buf.append("\n\t- unused warning token: ").append(getSeverityString(UnusedWarningToken)); //$NON-NLS-1$
1487
		buf.append("\n\t- unused label: ").append(getSeverityString(UnusedLabel)); //$NON-NLS-1$
1503
		buf.append("\n\t- unused label: ").append(getSeverityString(UnusedLabel)); //$NON-NLS-1$
(-)model/org/eclipse/jdt/core/JavaCore.java (+16 lines)
Lines 82-87 Link Here
82
 *     IBM Corporation - added getOptionForConfigurableSeverity(int)
82
 *     IBM Corporation - added getOptionForConfigurableSeverity(int)
83
 *     Benjamin Muskalla - added COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD
83
 *     Benjamin Muskalla - added COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD
84
 *     Stephan Herrmann  - added COMPILER_PB_UNUSED_OBJECT_ALLOCATION
84
 *     Stephan Herrmann  - added COMPILER_PB_UNUSED_OBJECT_ALLOCATION
85
 *     Stephan Herrmann  - added COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS
85
 *******************************************************************************/
86
 *******************************************************************************/
86
87
87
package org.eclipse.jdt.core;
88
package org.eclipse.jdt.core;
Lines 1420-1425 Link Here
1420
	 */
1421
	 */
1421
	public static final String COMPILER_PB_SUPPRESS_WARNINGS = PLUGIN_ID + ".compiler.problem.suppressWarnings"; //$NON-NLS-1$
1422
	public static final String COMPILER_PB_SUPPRESS_WARNINGS = PLUGIN_ID + ".compiler.problem.suppressWarnings"; //$NON-NLS-1$
1422
	/**
1423
	/**
1424
	 * Compiler option ID: Further Determining the Effect of <code>@SuppressWarnings</code> if also
1425
	 * {@link #COMPILER_PB_SUPPRESS_WARNINGS} is enabled.
1426
	 * <p>When enabled, the <code>@SuppressWarnings</code> annotation can additionally be used to suppress 
1427
	 * optional compiler diagnostics that have been configured as {@link #ERROR}.
1428
	 * <p>When disabled, all <code>@SuppressWarnings</code> annotations only affects warnings.
1429
	 * <dl>
1430
	 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors"</code></dd>
1431
	 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd>
1432
	 * <dt>Default:</dt><dd><code>"disabled"</code></dd>
1433
	 * </dl>
1434
	 * @since 3.6
1435
	 * @category CompilerOptionID
1436
	 */
1437
	public static final String COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS = PLUGIN_ID + ".compiler.problem.suppressOptionalErrors"; //$NON-NLS-1$
1438
	/**
1423
	 * Compiler option ID: Reporting Unhandled Warning Token for <code>@SuppressWarnings</code>.
1439
	 * Compiler option ID: Reporting Unhandled Warning Token for <code>@SuppressWarnings</code>.
1424
	 * <p>When enabled, the compiler will issue an error or a warning when encountering a token
1440
	 * <p>When enabled, the compiler will issue an error or a warning when encountering a token
1425
	 *    it cannot handle inside a <code>@SuppressWarnings</code> annotation.
1441
	 *    it cannot handle inside a <code>@SuppressWarnings</code> annotation.
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java (+99 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann  - Contribution for bug 295551
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
13
Lines 9304-9307 Link Here
9304
			expectedOutput,
9305
			expectedOutput,
9305
			JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
9306
			JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
9306
}
9307
}
9308
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551
9309
public void test280() {
9310
	Map customOptions = getCompilerOptions();
9311
	customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);
9312
	customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED);
9313
	String testFiles [] = new String[] {
9314
			"A.java",
9315
			"public class A {\n" +
9316
			"	@SuppressWarnings(\"unused\")\n" +
9317
			"	private int i;\n" + // problem configured as warning but still suppressed
9318
			"}\n"
9319
			};
9320
	runConformTest(
9321
			testFiles,
9322
			null,
9323
			null,
9324
			true,
9325
			null,
9326
			customOptions,
9327
			null);
9328
}
9329
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551
9330
public void test281() {
9331
	Map customOptions = getCompilerOptions();
9332
	customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);
9333
	customOptions.put(CompilerOptions.OPTION_SuppressWarnings, CompilerOptions.DISABLED); // this option overrides the next
9334
	customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED);
9335
	String testFiles [] = new String[] {
9336
			"A.java",
9337
			"public class A {\n" +
9338
			"	@SuppressWarnings(\"unused\")\n" +
9339
			"	private int i;\n" +
9340
			"}\n"
9341
			};
9342
	String expectedErrorString = 
9343
			"----------\n" + 
9344
			"1. ERROR in A.java (at line 3)\n" + 
9345
			"	private int i;\n" + 
9346
			"	            ^\n" + 
9347
			"The field A.i is never read locally\n" + 
9348
			"----------\n";
9349
	runNegativeTest(
9350
			true,
9351
			testFiles,
9352
			null, 
9353
			customOptions,
9354
			expectedErrorString,
9355
			JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
9356
}
9357
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551
9358
public void test282() {
9359
	Map customOptions = getCompilerOptions();
9360
	customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);
9361
	customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED);
9362
	String testFiles [] = new String[] {
9363
			"A.java",
9364
			"import java.util.Map;\n" +
9365
			"public class A {\n" +
9366
			"	@SuppressWarnings({\"rawtypes\", \"unused\"})\n" + //suppress a warning and an error
9367
			"	private Map i;\n" + 
9368
			"}\n"
9369
			};
9370
	runConformTest(
9371
			testFiles,
9372
			null,
9373
			null,
9374
			true,
9375
			null,
9376
			customOptions,
9377
			null);
9378
}
9379
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551
9380
public void test283() {
9381
	Map customOptions = getCompilerOptions();
9382
	customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);
9383
	customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED);
9384
	String testFiles [] = new String[] {
9385
			"A.java",
9386
			"public class A {\n" +
9387
			"	@SuppressWarnings(\"all\")\n" +
9388
			"	private void i;\n" + // cannot suppress mandatory error
9389
			"}\n"
9390
			};
9391
	String expectedErrorString = 
9392
			"----------\n" + 
9393
			"1. ERROR in A.java (at line 3)\n" + 
9394
			"	private void i;\n" + 
9395
			"	             ^\n" + 
9396
			"void is an invalid type for the variable i\n" + 
9397
			"----------\n";
9398
	runNegativeTest(
9399
			true,
9400
			testFiles,
9401
			null, 
9402
			customOptions,
9403
			expectedErrorString,
9404
			JavacTestOptions.SKIP);
9405
}
9307
}
9406
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (-3 / +156 lines)
Lines 9-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Muskalla - Contribution for bug 239066
10
 *     Benjamin Muskalla - Contribution for bug 239066
11
 *     Stephan Herrmann  - Contribution for bug 236385
11
 *     Stephan Herrmann  - Contribution for bug 236385
12
 *     Stephan Herrmann  - Contribution for bug 295551
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.jdt.core.tests.compiler.regression;
14
package org.eclipse.jdt.core.tests.compiler.regression;
14
15
Lines 47-54 Link Here
47
48
48
	static {
49
	static {
49
//		TESTS_NAMES = new String[] { "test292_warn_options" };
50
//		TESTS_NAMES = new String[] { "test292_warn_options" };
50
//		TESTS_NUMBERS = new int[] { 295 };
51
//		TESTS_NUMBERS = new int[] { 298 };
51
//		TESTS_RANGE = new int[] { 107, -1 };
52
//		TESTS_RANGE = new int[] { 298, -1 };
52
	}
53
	}
53
public BatchCompilerTest(String name) {
54
public BatchCompilerTest(String name) {
54
	super(name);
55
	super(name);
Lines 1696-1702 Link Here
1696
        "      static-access        macro for indirectStatic and staticReceiver\n" +
1697
        "      static-access        macro for indirectStatic and staticReceiver\n" +
1697
        "      staticReceiver     + non-static reference to static member\n" +
1698
        "      staticReceiver     + non-static reference to static member\n" +
1698
        "      super                overriding a method without making a super invocation\n" +
1699
        "      super                overriding a method without making a super invocation\n" +
1699
        "      suppress           + enable @SuppressWarnings\n" +
1700
        "      suppress           + enable @SuppressWarnings\n" + 
1701
        "                           When used with -err:, it can also silent optional\n" +
1702
        "                           errors and warnings\n" + 
1700
        "      syncOverride         missing synchronized in synchr. method override\n" +
1703
        "      syncOverride         missing synchronized in synchr. method override\n" +
1701
        "      syntheticAccess      synthetic access for innerclass\n" +
1704
        "      syntheticAccess      synthetic access for innerclass\n" +
1702
        "      tasks(<tags separated by |>) tasks identified by tags inside comments\n" +
1705
        "      tasks(<tags separated by |>) tasks identified by tags inside comments\n" +
Lines 1843-1848 Link Here
1843
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.redundantSuperinterface\" value=\"ignore\"/>\n" +
1846
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.redundantSuperinterface\" value=\"ignore\"/>\n" +
1844
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.specialParameterHidingField\" value=\"disabled\"/>\n" +
1847
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.specialParameterHidingField\" value=\"disabled\"/>\n" +
1845
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.staticAccessReceiver\" value=\"warning\"/>\n" +
1848
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.staticAccessReceiver\" value=\"warning\"/>\n" +
1849
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors\" value=\"disabled\"/>\n" +
1846
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.suppressWarnings\" value=\"enabled\"/>\n" +
1850
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.suppressWarnings\" value=\"enabled\"/>\n" +
1847
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation\" value=\"ignore\"/>\n" +
1851
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation\" value=\"ignore\"/>\n" +
1848
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.tasks\" value=\"warning\"/>\n" + 
1852
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.tasks\" value=\"warning\"/>\n" + 
Lines 11210-11213 Link Here
11210
		"invalid error configuration: \'-err\'\n",
11214
		"invalid error configuration: \'-err\'\n",
11211
		true);
11215
		true);
11212
}
11216
}
11217
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551
11218
public void test298(){
11219
	this.runConformTest(
11220
		new String[] {
11221
			"X.java",
11222
			"public class X {\n" +
11223
			"	@SuppressWarnings(\"unused\")\n" +
11224
			"	private int i;\n" +
11225
			"}",
11226
		},
11227
		"\"" + OUTPUT_DIR + File.separator + "X.java\""
11228
		+ " -1.5 -g -preserveAllLocals"
11229
		+ " -proceedOnError -err:+unused,suppress -d \"" + OUTPUT_DIR + "\"",
11230
		"",
11231
		"",
11232
		true);
11233
}
11234
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551
11235
public void test299(){
11236
	this.runNegativeTest(
11237
		new String[] {
11238
			"X.java",
11239
			"public class X {\n" +
11240
			"	@SuppressWarnings(\"unused\")\n" +
11241
			"	private int i;\n" +
11242
			"}",
11243
		},
11244
		"\"" + OUTPUT_DIR + File.separator + "X.java\""
11245
		+ " -1.5 -g -preserveAllLocals"
11246
		+ " -proceedOnError -err:+unused -d \"" + OUTPUT_DIR + "\"",
11247
		"",
11248
		"----------\n" + 
11249
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11250
		"	private int i;\n" + 
11251
		"	            ^\n" + 
11252
		"The field X.i is never read locally\n" + 
11253
		"----------\n" + 
11254
		"1 problem (1 error)",
11255
		true);
11256
}
11257
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551
11258
public void test300(){
11259
	this.runConformTest(
11260
		new String[] {
11261
			"X.java",
11262
			"public class X {\n" +
11263
			"	@SuppressWarnings(\"unused\")\n" +
11264
			"	private int i;\n" +
11265
			"}",
11266
		},
11267
		"\"" + OUTPUT_DIR + File.separator + "X.java\""
11268
		+ " -1.5 -g -preserveAllLocals"
11269
		+ " -proceedOnError -warn:-suppress -err:+suppress,unused -d \"" + OUTPUT_DIR + "\"",
11270
		"",
11271
		"",
11272
		true);
11273
}
11274
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551
11275
public void test301(){
11276
	this.runNegativeTest(
11277
		new String[] {
11278
			"X.java",
11279
			"public class X {\n" +
11280
			"	@SuppressWarnings(\"unused\")\n" +
11281
			"	private int i;\n" +
11282
			"}",
11283
		},
11284
		"\"" + OUTPUT_DIR + File.separator + "X.java\""
11285
		+ " -1.5 -g -preserveAllLocals"
11286
		+ " -proceedOnError -warn:-suppress -err:+unused -d \"" + OUTPUT_DIR + "\"",
11287
		"",
11288
		"----------\n" + 
11289
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11290
		"	private int i;\n" + 
11291
		"	            ^\n" + 
11292
		"The field X.i is never read locally\n" + 
11293
		"----------\n" + 
11294
		"1 problem (1 error)",
11295
		true);
11296
}
11297
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551
11298
public void test302(){
11299
	this.runNegativeTest(
11300
		new String[] {
11301
			"X.java",
11302
			"public class X {\n" +
11303
			"	@SuppressWarnings(\"unused\")\n" +
11304
			"	private int i;\n" +
11305
			"}",
11306
		},
11307
		"\"" + OUTPUT_DIR + File.separator + "X.java\""
11308
		+ " -1.5 -g -preserveAllLocals"
11309
		+ " -proceedOnError -warn:-suppress -err:+suppress,unused -warn:-suppress -d \"" + OUTPUT_DIR + "\"",
11310
		"",
11311
		"----------\n" + 
11312
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11313
		"	private int i;\n" + 
11314
		"	            ^\n" + 
11315
		"The field X.i is never read locally\n" + 
11316
		"----------\n" + 
11317
		"1 problem (1 error)",
11318
		true);
11319
}
11320
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551
11321
public void test303(){
11322
	this.runNegativeTest(
11323
		new String[] {
11324
			"X.java",
11325
			"public class X {\n" +
11326
			"	@SuppressWarnings(\"unused\")\n" +
11327
			"	private int i;\n" +
11328
			"}",
11329
		},
11330
		"\"" + OUTPUT_DIR + File.separator + "X.java\""
11331
		+ " -1.5 -g -preserveAllLocals"
11332
		+ " -proceedOnError -warn:-suppress -err:+suppress,unused -warn:+suppress -d \"" + OUTPUT_DIR + "\"",
11333
		"",
11334
		"----------\n" + 
11335
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11336
		"	private int i;\n" + 
11337
		"	            ^\n" + 
11338
		"The field X.i is never read locally\n" + 
11339
		"----------\n" + 
11340
		"1 problem (1 error)",
11341
		true);
11342
}
11343
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551
11344
public void test304(){
11345
	this.runNegativeTest(
11346
		new String[] {
11347
			"X.java",
11348
			"public class X {\n" +
11349
			"	@SuppressWarnings(\"unused\")\n" +
11350
			"	private int i;\n" +
11351
			"}",
11352
		},
11353
		"\"" + OUTPUT_DIR + File.separator + "X.java\""
11354
		+ " -1.5 -g -preserveAllLocals"
11355
		+ " -proceedOnError -err:+suppress,unused -warn:-suppress -d \"" + OUTPUT_DIR + "\"",
11356
		"",
11357
		"----------\n" + 
11358
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + 
11359
		"	private int i;\n" + 
11360
		"	            ^\n" + 
11361
		"The field X.i is never read locally\n" + 
11362
		"----------\n" + 
11363
		"1 problem (1 error)",
11364
		true);
11365
}
11213
}
11366
}

Return to bug 295551