Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 211404 Details for
Bug 371832
The preference "Suppress optional errors with '@SuppressWarnings'" ends up silencing warnings it shouldn't
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch under consideration
patch.txt (text/plain), 9.71 KB, created by
Satyam Kandula
on 2012-02-22 09:14:31 EST
(
hide
)
Description:
Patch under consideration
Filename:
MIME Type:
Creator:
Satyam Kandula
Created:
2012-02-22 09:14:31 EST
Size:
9.71 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java >index 4a8b0fa..d1ce499 100644 >--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java >+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java >@@ -47,7 +47,7 @@ > // Static initializer to specify tests subset using TESTS_* static variables > // All specified tests which do not belong to the class are skipped... > static { >-// TESTS_NAMES = new String[] { "testBug365437" }; >+// TESTS_NAMES = new String[] { "test135" }; > // TESTS_NUMBERS = new int[] { 297 }; > // TESTS_RANGE = new int[] { 294, -1 }; > } >@@ -10517,4 +10517,38 @@ > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=371832 >+//Unused imports should be reported even if other errors are suppressed. >+public void testBug371832() throws Exception { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); >+ customOptions.put(CompilerOptions.OPTION_ReportMissingSerialVersion, CompilerOptions.ERROR); >+ String testFiles [] = new String[] { >+ "A.java", >+ "import java.util.List;\n"+ >+ "@SuppressWarnings(\"serial\")\n" + >+ "public class A implements java.io.Serializable {\n" + >+ " void foo() { \n" + >+ " }\n"+ >+ "}\n" >+ }; >+ String expectedErrorString = >+ "----------\n" + >+ "1. ERROR in A.java (at line 1)\n" + >+ " import java.util.List;\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The import java.util.List is never used\n" + >+ "----------\n"; >+ runNegativeTest( >+ true, >+ testFiles, >+ null, >+ customOptions, >+ expectedErrorString, >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+ > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java >index d82de3c..684d2f6 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -73,6 +73,7 @@ > public char[][] packageName; > public boolean checkSecondaryTypes = false; // check for secondary types which were created after the initial buildTypeBindings call > private int numberOfErrors; >+ private boolean hasMandatoryErrors; > > private static final int[] EMPTY_LINE_ENDS = Util.EMPTY_INT_ARRAY; > private static final Comparator PROBLEM_COMPARATOR = new Comparator() { >@@ -274,6 +275,10 @@ > return this.numberOfErrors != 0; > } > >+public boolean hasMandatoryErrors() { >+ return this.hasMandatoryErrors; >+} >+ > public boolean hasProblems() { > return this.problemCount != 0; > } >@@ -324,6 +329,11 @@ > } > > public void record(CategorizedProblem newProblem, ReferenceContext referenceContext) { >+ record(newProblem, referenceContext, true); >+ return; >+} >+ >+public void record(CategorizedProblem newProblem, ReferenceContext referenceContext, boolean mandatoryError) { > //new Exception("VERBOSE PROBLEM REPORTING").printStackTrace(); > if(newProblem.getID() == IProblem.Task) { > recordTask(newProblem); >@@ -343,6 +353,7 @@ > } > if (newProblem.isError()) { > this.numberOfErrors++; >+ if (mandatoryError) this.hasMandatoryErrors = true; > if ((newProblem.getID() & IProblem.Syntax) != 0) { > this.hasSyntaxError = true; > } >@@ -409,4 +420,5 @@ > } > return buffer.toString(); > } >+ > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java >index cbe6196..00ff614 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -602,7 +602,7 @@ > 0, // source end > 0, // line number > 0),// column number >- unit); >+ unit, true); > > /* hand back the compilation result */ > if (!result.hasBeenAccepted) { >@@ -664,7 +664,7 @@ > if (distantProblem instanceof DefaultProblem) { // fixup filename TODO (philippe) should improve API to make this official > ((DefaultProblem) distantProblem).setOriginatingFileName(result.getFileName()); > } >- result.record(distantProblem, unit); >+ result.record(distantProblem, unit, true); > } > } else { > /* distant internal exception which could not be reported back there */ >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java >index 754305e..b2774fa 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java >@@ -561,7 +561,7 @@ > this.types[i].resolve(this.scope); > } > } >- if (!this.compilationResult.hasErrors()) checkUnusedImports(); >+ if (!this.compilationResult.hasMandatoryErrors()) checkUnusedImports(); > reportNLSProblems(); > } catch (AbortCompilationUnit e) { > this.ignoreFurtherInvestigation = true; >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java >index 970b9e0..e3613a5 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java >@@ -157,10 +157,11 @@ > > switch (severity & ProblemSeverities.Error) { > case ProblemSeverities.Error : >- record(problem, unitResult, referenceContext); >+ boolean mandatory = ((severity & ProblemSeverities.Optional) == 0); >+ record(problem, unitResult, referenceContext, mandatory); > if ((severity & ProblemSeverities.Fatal) != 0) { > // don't abort or tag as error if the error is suppressed >- if (!referenceContext.hasErrors() && (severity & ProblemSeverities.Optional) != 0 && this.options.suppressOptionalErrors) { >+ if (!referenceContext.hasErrors() && !mandatory && this.options.suppressOptionalErrors) { > CompilationUnitDeclaration unitDecl = referenceContext.getCompilationUnitDeclaration(); > if (unitDecl != null && unitDecl.isSuppressed(problem)) { > return; >@@ -175,7 +176,7 @@ > } > break; > case ProblemSeverities.Warning : >- record(problem, unitResult, referenceContext); >+ record(problem, unitResult, referenceContext, false); > break; > } > } >@@ -203,7 +204,7 @@ > referenceContext, > unitResult); > } >-public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext referenceContext) { >- unitResult.record(problem, referenceContext); >+public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext referenceContext, boolean optionalError) { >+ unitResult.record(problem, referenceContext, optionalError); > } > } >diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java >index e256566..58e476b 100644 >--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java >+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -86,8 +86,8 @@ > DefaultErrorHandlingPolicies.exitAfterAllProblems(), > options, > problemFactory) { >- public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext context) { >- unitResult.record(problem, context); // TODO (jerome) clients are trapping problems either through factory or requestor... is result storing needed? >+ public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext context, boolean mandatoryError) { >+ unitResult.record(problem, context, mandatoryError); // TODO (jerome) clients are trapping problems either through factory or requestor... is result storing needed? > SourceElementParser.this.requestor.acceptProblem(problem); > } > };
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 371832
:
211404
|
214363