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 160347 Details for
Bug 304031
Unused @SuppressWarnings(..) not flagged when suppressed problem is set to Error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + regression tests
patch_304031.txt (text/plain), 16.75 KB, created by
Olivier Thomann
on 2010-02-26 13:34:29 EST
(
hide
)
Description:
Proposed fix + regression tests
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2010-02-26 13:34:29 EST
Size:
16.75 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java,v >retrieving revision 1.87 >diff -u -r1.87 CompilationUnitDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java 25 Feb 2010 19:17:03 -0000 1.87 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java 26 Feb 2010 18:33:56 -0000 >@@ -16,7 +16,6 @@ > > import org.eclipse.jdt.core.compiler.CategorizedProblem; > import org.eclipse.jdt.core.compiler.CharOperation; >-import org.eclipse.jdt.core.compiler.IProblem; > import org.eclipse.jdt.internal.compiler.ASTVisitor; > import org.eclipse.jdt.internal.compiler.ClassFile; > import org.eclipse.jdt.internal.compiler.CompilationResult; >@@ -214,17 +213,18 @@ > int problemCount = this.compilationResult.problemCount; > IrritantSet[] foundIrritants = new IrritantSet[this.suppressWarningsCount]; > CompilerOptions options = this.scope.compilerOptions(); >- boolean hasErrors = false; >+ boolean hasMandatoryErrors = false; > nextProblem: for (int iProblem = 0, length = problemCount; iProblem < length; iProblem++) { > CategorizedProblem problem = problems[iProblem]; > int problemID = problem.getID(); > int irritant = ProblemReporter.getIrritant(problemID); > if (problem.isError()) { >- if (problemID != IProblem.UnusedWarningToken) { >- // tolerate unused warning tokens which were promoted as errors >- hasErrors = true; >+ if (irritant == 0) { >+ // tolerate unused warning tokens when mandatory errors >+ hasMandatoryErrors = true; >+ continue; > } >- if (irritant == 0 || !options.suppressOptionalErrors) { >+ if (!options.suppressOptionalErrors) { > continue; > } > } >@@ -266,7 +266,7 @@ > this.compilationResult.problemCount -= removed; > } > // flag SuppressWarnings which had no effect (only if no (mandatory) error got detected within unit >- if (!hasErrors) { >+ if (!hasMandatoryErrors) { > int severity = options.getSeverity(CompilerOptions.UnusedWarningToken); > if (severity != ProblemSeverities.Ignore) { > boolean unusedWarningTokenIsWarning = (severity & ProblemSeverities.Error) == 0; >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java,v >retrieving revision 1.211 >diff -u -r1.211 AnnotationTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 25 Feb 2010 19:16:59 -0000 1.211 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 26 Feb 2010 18:33:57 -0000 >@@ -45,7 +45,7 @@ > // All specified tests which do not belong to the class are skipped... > static { > // TESTS_NAMES = new String[] { "test127" }; >-// TESTS_NUMBERS = new int[] { 278 }; >+// TESTS_NUMBERS = new int[] { 286 }; > // TESTS_RANGE = new int[] { 249, -1 }; > } > >@@ -998,7 +998,7 @@ > this.runConformTest( > new String[] { > "X.java", >- "@Foo(type=String.class) public class X {\r\n" + >+ "@Foo(type=String.class) public class X {\n" + > "}" > }, > "", >@@ -1247,8 +1247,8 @@ > "}\n" > }, > "----------\n" + >- "1. ERROR in X.java (at line 12)\r\n" + >- " public @MyAnn void something() { } \r\n" + >+ "1. ERROR in X.java (at line 12)\n" + >+ " public @MyAnn void something() { } \n" + > " ^^^^^^\n" + > "The annotation @MyAnn is disallowed for this location\n" + > "----------\n"); >@@ -2724,8 +2724,8 @@ > "}\n" > }, > "----------\n" + >- "1. ERROR in X.java (at line 4)\r\n" + >- " @Inherited\r\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " @Inherited\n" + > " ^^^^^^^^^^\n" + > "The annotation @Inherited is disallowed for this location\n" + > "----------\n"); >@@ -2959,8 +2959,8 @@ > "}\n", > }, > "----------\n" + >- "1. ERROR in X.java (at line 3)\r\n" + >- " @Target(Element)\r\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " @Target(Element)\n" + > " ^^^^^^^\n" + > "Element cannot be resolved to a variable\n" + > "----------\n"); >@@ -4369,8 +4369,8 @@ > public void test140() { > String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 > ? "----------\n" + >- "1. ERROR in X.java (at line 6)\r\n" + >- " static void foo(){} \r\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " static void foo(){} \n" + > " ^^^^^\n" + > "The method foo() of type Bar must override a superclass method\n" + > "----------\n" >@@ -4504,6 +4504,8 @@ > true, > raiseInvalidJavadocSeverity); > } >+// check that @SuppressWarning is reported as unused when corresponding warning is moved from >+// warning to error > public void test142c() { > Map raiseDeprecationReduceInvalidJavadocSeverity = > new HashMap(2); >@@ -4535,16 +4537,21 @@ > }, > null, > raiseDeprecationReduceInvalidJavadocSeverity, >- "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >- " public class X extends p.OldStuff {\n" + >- " ^^^^^^^^^^\n" + >- "The type OldStuff is deprecated\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 8)\n" + >- " super.foo();\n" + >- " ^^^^^^^^^^^\n" + >- "The method foo() from the type OldStuff is deprecated\n" + >+ "----------\n" + >+ "1. WARNING in X.java (at line 1)\n" + >+ " @SuppressWarnings(\"deprecation\")\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "Unnecessary @SuppressWarnings(\"deprecation\")\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 2)\n" + >+ " public class X extends p.OldStuff {\n" + >+ " ^^^^^^^^^^\n" + >+ "The type OldStuff is deprecated\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 8)\n" + >+ " super.foo();\n" + >+ " ^^^^^^^^^^^\n" + >+ "The method foo() from the type OldStuff is deprecated\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -5832,10 +5839,10 @@ > "import static java.lang.annotation.RetentionPolicy.*;\n" + > "import java.lang.annotation.Retention;\n" + > "import java.lang.annotation.Target;\n" + >- "@Target({TYPE, FIELD, METHOD,\r\n" + >- " PARAMETER, CONSTRUCTOR,\r\n" + >- " LOCAL_VARIABLE, PACKAGE,})\r\n" + >- "@Retention(CLASS)\r\n" + >+ "@Target({TYPE, FIELD, METHOD,\n" + >+ " PARAMETER, CONSTRUCTOR,\n" + >+ " LOCAL_VARIABLE, PACKAGE,})\n" + >+ "@Retention(CLASS)\n" + > "public @interface X {}" > }, > "", >@@ -6328,8 +6335,8 @@ > "}" > }, > "----------\n" + >- "1. ERROR in A.java (at line 2)\r\n" + >- " A circular1();\r\n" + >+ "1. ERROR in A.java (at line 2)\n" + >+ " A circular1();\n" + > " ^\n" + > "Cycle detected: the annotation type A cannot contain attributes of the annotation type itself\n" + > "----------\n" >@@ -6346,18 +6353,18 @@ > "}" > }, > "----------\n" + >- "1. ERROR in A.java (at line 2)\r\n" + >- " B circular2();\r\n" + >+ "1. ERROR in A.java (at line 2)\n" + >+ " B circular2();\n" + > " ^\n" + > "Cycle detected: a cycle exists between annotation attributes of A and B\n" + > "----------\n" + >- "2. ERROR in A.java (at line 3)\r\n" + >- " A circular1();\r\n" + >+ "2. ERROR in A.java (at line 3)\n" + >+ " A circular1();\n" + > " ^\n" + > "Cycle detected: the annotation type A cannot contain attributes of the annotation type itself\n" + > "----------\n" + >- "3. ERROR in A.java (at line 6)\r\n" + >- " A circular();\r\n" + >+ "3. ERROR in A.java (at line 6)\n" + >+ " A circular();\n" + > " ^\n" + > "Cycle detected: a cycle exists between annotation attributes of B and A\n" + > "----------\n" >@@ -6374,18 +6381,18 @@ > "}" > }, > "----------\n" + >- "1. ERROR in A.java (at line 2)\r\n" + >- " A circular1();\r\n" + >+ "1. ERROR in A.java (at line 2)\n" + >+ " A circular1();\n" + > " ^\n" + > "Cycle detected: the annotation type A cannot contain attributes of the annotation type itself\n" + > "----------\n" + >- "2. ERROR in A.java (at line 3)\r\n" + >- " B circular2();\r\n" + >+ "2. ERROR in A.java (at line 3)\n" + >+ " B circular2();\n" + > " ^\n" + > "Cycle detected: a cycle exists between annotation attributes of A and B\n" + > "----------\n" + >- "3. ERROR in A.java (at line 6)\r\n" + >- " A circular();\r\n" + >+ "3. ERROR in A.java (at line 6)\n" + >+ " A circular();\n" + > " ^\n" + > "Cycle detected: a cycle exists between annotation attributes of B and A\n" + > "----------\n" >@@ -7092,8 +7099,8 @@ > if (new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6) { > this.runNegativeTest(sources, > "----------\n" + >- "1. ERROR in Y.java (at line 3)\r\n" + >- " public void foo() {}\r\n" + >+ "1. ERROR in Y.java (at line 3)\n" + >+ " public void foo() {}\n" + > " ^^^^^\n" + > "The method foo() of type Y must override a superclass method\n" + > "----------\n"); >@@ -8148,8 +8155,8 @@ > "}" > }, > "----------\n" + >- "1. ERROR in TestAnnotation.java (at line 2)\r\n" + >- " String targetItem() default void.class;\r\n" + >+ "1. ERROR in TestAnnotation.java (at line 2)\n" + >+ " String targetItem() default void.class;\n" + > " ^^^^^^^^^^\n" + > "Type mismatch: cannot convert from Class<Void> to String\n" + > "----------\n"); >@@ -9403,4 +9410,108 @@ > expectedErrorString, > JavacTestOptions.SKIP); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=304031 >+public void test284() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.WARNING); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedWarningToken, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); >+ String testFiles [] = new String[] { >+ "X.java", >+ "public class X {\n" + >+ " void m() {\n" + >+ " @SuppressWarnings(\"cast\")\n" + >+ " int i= (int) 0;\n" + >+ " @SuppressWarnings(\"cast\")\n" + >+ " byte b= (byte) i;\n" + >+ " System.out.println(b);\n" + >+ " }\n" + >+ "}" >+ }; >+ String expectedErrorString = >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " @SuppressWarnings(\"cast\")\n" + >+ " ^^^^^^\n" + >+ "Unnecessary @SuppressWarnings(\"cast\")\n" + >+ "----------\n"; >+ runNegativeTest( >+ true, >+ testFiles, >+ null, >+ customOptions, >+ expectedErrorString, >+ JavacTestOptions.SKIP); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=304031 >+public void test285() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedWarningToken, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); >+ String testFiles [] = new String[] { >+ "X.java", >+ "public class X {\n" + >+ " void m() {\n" + >+ " @SuppressWarnings(\"cast\")\n" + >+ " int i= (int) 0;\n" + >+ " @SuppressWarnings(\"cast\")\n" + >+ " byte b= (byte) i;\n" + >+ " System.out.println(b);\n" + >+ " }\n" + >+ "}" >+ }; >+ String expectedErrorString = >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " @SuppressWarnings(\"cast\")\n" + >+ " ^^^^^^\n" + >+ "Unnecessary @SuppressWarnings(\"cast\")\n" + >+ "----------\n"; >+ runNegativeTest( >+ true, >+ testFiles, >+ null, >+ customOptions, >+ expectedErrorString, >+ JavacTestOptions.SKIP); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=304031 >+public void test286() { >+ Map raiseDeprecationReduceInvalidJavadocSeverity = >+ new HashMap(2); >+ raiseDeprecationReduceInvalidJavadocSeverity.put( >+ CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); >+ raiseDeprecationReduceInvalidJavadocSeverity.put( >+ CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); >+ raiseDeprecationReduceInvalidJavadocSeverity.put( >+ CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.WARNING); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "@SuppressWarnings(\"deprecation\")\n" + >+ "public class X extends p.OldStuff {\n" + >+ " /**\n" + >+ " * @see p.OldStuff#foo()\n" + >+ " */\n" + >+ " @Override\n" + >+ " public void foo() {\n" + >+ " super.foo();\n" + >+ " }\n" + >+ "}\n", >+ "p/OldStuff.java", >+ "package p;\n" + >+ "@Deprecated\n" + >+ "public class OldStuff {\n" + >+ " public void foo() {\n" + >+ " } \n" + >+ "}\n", >+ }, >+ "", >+ null, >+ true, >+ null, >+ raiseDeprecationReduceInvalidJavadocSeverity, >+ null); >+} > } >Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v >retrieving revision 1.203 >diff -u -r1.203 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 25 Feb 2010 19:16:59 -0000 1.203 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 26 Feb 2010 18:33:57 -0000 >@@ -11246,12 +11246,17 @@ > + " -proceedOnError -err:+unused -d \"" + OUTPUT_DIR + "\"", > "", > "----------\n" + >- "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + >+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 2)\n" + >+ " @SuppressWarnings(\"unused\")\n" + >+ " ^^^^^^^^\n" + >+ "Unnecessary @SuppressWarnings(\"unused\")\n" + >+ "----------\n" + >+ "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private int i;\n" + > " ^\n" + > "The field X.i is never read locally\n" + > "----------\n" + >- "1 problem (1 error)", >+ "2 problems (1 error, 1 warning)", > true); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551 >@@ -11332,12 +11337,17 @@ > + " -proceedOnError -warn:-suppress -err:+suppress,unused -warn:+suppress -d \"" + OUTPUT_DIR + "\"", > "", > "----------\n" + >- "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + >+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 2)\n" + >+ " @SuppressWarnings(\"unused\")\n" + >+ " ^^^^^^^^\n" + >+ "Unnecessary @SuppressWarnings(\"unused\")\n" + >+ "----------\n" + >+ "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" + > " private int i;\n" + > " ^\n" + > "The field X.i is never read locally\n" + > "----------\n" + >- "1 problem (1 error)", >+ "2 problems (1 error, 1 warning)", > true); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551 >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ExternalizeStringLiterals15Test.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExternalizeStringLiterals15Test.java,v >retrieving revision 1.11 >diff -u -r1.11 ExternalizeStringLiterals15Test.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ExternalizeStringLiterals15Test.java 27 Jun 2008 16:04:45 -0000 1.11 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ExternalizeStringLiterals15Test.java 26 Feb 2010 18:33:57 -0000 >@@ -68,8 +68,8 @@ > "class X {\n" + > " String s2 = \"test1\"; //$NON-NLS-1$\n" + > " String s3 = \"test2\"; //$NON-NLS-1$//$NON-NLS-2$\n" + >- " \n" + >- " @SuppressWarnings(\"nls\")\n" + >+ "\n" + >+ "\n" + > " void foo() {\n" + > " String s4 = null;\n" + > " String s5 = \"test3\";\n" + >@@ -112,8 +112,8 @@ > "class X {\n" + > " String s2 = \"test1\"; //$NON-NLS-1$\n" + > " String s3 = \"test2\"; //$NON-NLS-1$//$NON-NLS-2$\n" + >- " \n" + >- " @SuppressWarnings(\"nls\")\n" + >+ "\n" + >+ "\n" + > " void foo() {\n" + > " String s4 = null;\n" + > " String s5 = null;//$NON-NLS-1$\n" + >@@ -184,7 +184,7 @@ > new String[] { > "X.java", > "class X {\n" + >- " @SuppressWarnings(\"nls\")\n" + >+ "\n" + > " void foo() {\n" + > " String s6 = \"SUCCESS\";\n" + > " System.out.println(s6);\n" +
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 304031
:
160333
|
160334
| 160347