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

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java (-2 / +40 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 12-17 Link Here
12
12
13
import java.util.Map;
13
import java.util.Map;
14
14
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
16
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
16
17
17
import junit.framework.Test;
18
import junit.framework.Test;
Lines 24-30 Link Here
24
	// All specified tests which does not belong to the class are skipped...
25
	// All specified tests which does not belong to the class are skipped...
25
	static {
26
	static {
26
//		TESTS_NAMES = new String[] { "test127" };
27
//		TESTS_NAMES = new String[] { "test127" };
27
//		TESTS_NUMBERS = new int[] { 5 };
28
//		TESTS_NUMBERS = new int[] { 7 };
28
//		TESTS_RANGE = new int[] { 169, 180 };
29
//		TESTS_RANGE = new int[] { 169, 180 };
29
	}
30
	}
30
31
Lines 258-261 Link Here
258
			// javac options
259
			// javac options
259
			JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
260
			JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
260
	}
261
	}
262
	public void test007() {
263
		if (this.complianceLevel < ClassFileConstants.JDK1_5) {
264
			return;
265
		}
266
		Map customOptions = getCompilerOptions();
267
		customOptions.put(CompilerOptions.OPTION_FatalOptionalError,
268
				CompilerOptions.ENABLED);
269
		customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal,
270
				CompilerOptions.ERROR);
271
		customOptions.put(CompilerOptions.OPTION_SuppressWarnings,
272
				CompilerOptions.ENABLED);
273
		customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors,
274
				CompilerOptions.ENABLED);
275
		customOptions.put(CompilerOptions.OPTION_ReportUnusedWarningToken,
276
				CompilerOptions.ERROR);
277
		runConformTest(
278
				new String[] { /* test files */
279
						"X.java",
280
						"public class X {\n" +
281
								"        @SuppressWarnings(\"unused\")\n" +
282
								"        static void foo() {\n" +
283
								"            String s = null;\n" +
284
								"            System.out.println(\"SUCCESS\");\n" +
285
								"        }\n" +
286
								"        public static void main(String argv[]) {\n" +
287
								"            foo();\n" +
288
								"        }\n" +
289
								"}"
290
				},
291
				"SUCCESS" /* expected output string */,
292
				null /* no class libraries */,
293
				true,
294
				null,
295
				customOptions /* custom options */,
296
				// compiler results
297
				null /* do not check error string */);
298
	}
261
}
299
}
(-)a/org.eclipse.jdt.core/buildnotes_jdt-core.html (-1 / +3 lines)
Lines 52-58 Link Here
52
<h2>What's new in this drop</h2>
52
<h2>What's new in this drop</h2>
53
53
54
<h3>Problem Reports Fixed</h3>
54
<h3>Problem Reports Fixed</h3>
55
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=366544">366544</a>
55
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=346175">346175</a>
56
@SuppressWarnings should clear all errors including fatal optional errors
57
<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=366544">366544</a>
56
[index] Test testUseIndexInternalJarAfterRestart failed on Mac and Linux
58
[index] Test testUseIndexInternalJarAfterRestart failed on Mac and Linux
57
<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=302850">302850</a>
59
<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=302850">302850</a>
58
13 failures in JavaModel tests for the N20100214-2000 Mac OS X - Cocoa test machine
60
13 failures in JavaModel tests for the N20100214-2000 Mac OS X - Cocoa test machine
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java (-1 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 362-367 Link Here
362
		}
362
		}
363
	}
363
	}
364
364
365
	public CompilationUnitDeclaration getCompilationUnitDeclaration() {
366
		if (this.scope != null) {
367
			return this.scope.compilationUnitScope().referenceContext;
368
		}
369
		return null;
370
	}
371
365
	public boolean hasErrors() {
372
	public boolean hasErrors() {
366
		return this.ignoreFurtherInvestigation;
373
		return this.ignoreFurtherInvestigation;
367
	}
374
	}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java (-1 / +23 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 364-369 Link Here
364
	}
364
	}
365
}
365
}
366
366
367
public CompilationUnitDeclaration getCompilationUnitDeclaration() {
368
	return this;
369
}
370
367
public char[] getFileName() {
371
public char[] getFileName() {
368
	return this.compilationResult.getFileName();
372
	return this.compilationResult.getFileName();
369
}
373
}
Lines 394-399 Link Here
394
	return CharOperation.equals(getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME);
398
	return CharOperation.equals(getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME);
395
}
399
}
396
400
401
public boolean isSuppressed(CategorizedProblem problem) {
402
	if (this.suppressWarningsCount == 0) return false;
403
	int irritant = ProblemReporter.getIrritant(problem.getID());
404
	if (irritant == 0) return false;
405
	int start = problem.getSourceStart();
406
	int end = problem.getSourceEnd();
407
	nextSuppress: for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) {
408
		long position = this.suppressWarningScopePositions[iSuppress];
409
		int startSuppress = (int) (position >>> 32);
410
		int endSuppress = (int) position;
411
		if (start < startSuppress) continue nextSuppress;
412
		if (end > endSuppress) continue nextSuppress;
413
		if (this.suppressWarningIrritants[iSuppress].isSet(irritant))
414
			return true;
415
	}
416
	return false;
417
}
418
397
public boolean hasErrors() {
419
public boolean hasErrors() {
398
	return this.ignoreFurtherInvestigation;
420
	return this.ignoreFurtherInvestigation;
399
}
421
}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java (-1 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 490-495 Link Here
490
		if (typeDecl != null) {
490
		if (typeDecl != null) {
491
			return typeDecl;
491
			return typeDecl;
492
		}
492
		}
493
	}
494
	return null;
495
}
496
497
public CompilationUnitDeclaration getCompilationUnitDeclaration() {
498
	if (this.scope != null) {
499
		return this.scope.compilationUnitScope().referenceContext;
493
	}
500
	}
494
	return null;
501
	return null;
495
}
502
}
Lines 1464-1467 Link Here
1464
public boolean isSecondary() {
1471
public boolean isSecondary() {
1465
	return (this.bits & ASTNode.IsSecondaryType) != 0;
1472
	return (this.bits & ASTNode.IsSecondaryType) != 0;
1466
}
1473
}
1474
1467
}
1475
}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java (-1 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 18-23 Link Here
18
18
19
import org.eclipse.jdt.core.compiler.CategorizedProblem;
19
import org.eclipse.jdt.core.compiler.CategorizedProblem;
20
import org.eclipse.jdt.internal.compiler.CompilationResult;
20
import org.eclipse.jdt.internal.compiler.CompilationResult;
21
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
21
22
22
public interface ReferenceContext {
23
public interface ReferenceContext {
23
24
Lines 25-31 Link Here
25
26
26
	CompilationResult compilationResult();
27
	CompilationResult compilationResult();
27
28
29
	CompilationUnitDeclaration getCompilationUnitDeclaration();
30
28
	boolean hasErrors();
31
	boolean hasErrors();
29
32
30
	void tagAsHavingErrors();
33
	void tagAsHavingErrors();
34
31
}
35
}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java (-1 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 15-20 Link Here
15
import org.eclipse.jdt.internal.compiler.CompilationResult;
15
import org.eclipse.jdt.internal.compiler.CompilationResult;
16
import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
16
import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
17
import org.eclipse.jdt.internal.compiler.IProblemFactory;
17
import org.eclipse.jdt.internal.compiler.IProblemFactory;
18
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
18
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
19
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
19
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
20
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
20
import org.eclipse.jdt.internal.compiler.util.Util;
21
import org.eclipse.jdt.internal.compiler.util.Util;
Lines 150-155 Link Here
150
		case ProblemSeverities.Error :
151
		case ProblemSeverities.Error :
151
			record(problem, unitResult, referenceContext);
152
			record(problem, unitResult, referenceContext);
152
			if ((severity & ProblemSeverities.Fatal) != 0) {
153
			if ((severity & ProblemSeverities.Fatal) != 0) {
154
				// don't abort or tag as error if the error is suppressed
155
				if (!referenceContext.hasErrors() && (severity & ProblemSeverities.Optional) != 0 && this.options.suppressOptionalErrors) {
156
					CompilationUnitDeclaration unitDecl = referenceContext.getCompilationUnitDeclaration();
157
					if (unitDecl != null && unitDecl.isSuppressed(problem)) {
158
						return;
159
					}
160
				}
153
				referenceContext.tagAsHavingErrors();
161
				referenceContext.tagAsHavingErrors();
154
				// should abort ?
162
				// should abort ?
155
				int abortLevel;
163
				int abortLevel;

Return to bug 346175