### 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.88 diff -u -r1.88 CompilationUnitDeclaration.java --- compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java 26 Feb 2010 18:35:51 -0000 1.88 +++ compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java 17 May 2010 17:50:54 -0000 @@ -291,7 +291,7 @@ IrritantSet tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue()); if (tokenIrritants != null && !tokenIrritants.areAllSet() // no complaint against @SuppressWarnings("all") - && options.isAnyEnabled(tokenIrritants) // if irritant is effectevely enabled + && options.isAnyEnabled(tokenIrritants) // if irritant is effectively enabled && (foundIrritants[iSuppress] == null || !foundIrritants[iSuppress].isAnySet(tokenIrritants))) { // if irritant had no matching problem if (unusedWarningTokenIsWarning) { int start = value.sourceStart, end = value.sourceEnd; @@ -477,9 +477,18 @@ System.arraycopy(this.suppressWarningAnnotations, 0,this.suppressWarningAnnotations = new Annotation[2*this.suppressWarningsCount], 0, this.suppressWarningsCount); System.arraycopy(this.suppressWarningScopePositions, 0,this.suppressWarningScopePositions = new long[2*this.suppressWarningsCount], 0, this.suppressWarningsCount); } + final long scopePositions = ((long)scopeStart<<32) + scopeEnd; + for (int i = 0, max = this.suppressWarningsCount; i < max; i++) { + if (this.suppressWarningAnnotations[i] == annotation + && this.suppressWarningScopePositions[i] == scopePositions + && this.suppressWarningIrritants[i].isAllSet(irritants)) { + // annotation data already recorded + return; + } + } this.suppressWarningIrritants[this.suppressWarningsCount] = irritants; this.suppressWarningAnnotations[this.suppressWarningsCount] = annotation; - this.suppressWarningScopePositions[this.suppressWarningsCount++] = ((long)scopeStart<<32) + scopeEnd; + this.suppressWarningScopePositions[this.suppressWarningsCount++] = scopePositions; } /* Index: compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java,v retrieving revision 1.9 diff -u -r1.9 IrritantSet.java --- compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java 13 Jan 2010 15:13:45 -0000 1.9 +++ compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java 17 May 2010 17:50:54 -0000 @@ -195,6 +195,20 @@ return false; } + /** + * Returns true if all of the irritants in given other set is positionned in receiver + * @param other the given set of irritants + */ + public boolean isAllSet(IrritantSet other) { + if (other == null) + return false; + for (int i = 0; i < GROUP_MAX; i++) { + if (this.bits[i] != other.bits[i]) + return false; + } + return true; + } + public boolean isSet(int singleGroupIrritants) { int group = (singleGroupIrritants & GROUP_MASK) >> GROUP_SHIFT; return (this.bits[group] & singleGroupIrritants) != 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.216 diff -u -r1.216 AnnotationTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 10 May 2010 20:48:02 -0000 1.216 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 17 May 2010 17:50:55 -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[] { 289 }; +// TESTS_NUMBERS = new int[] { 290, 291 }; // TESTS_RANGE = new int[] { 249, -1 }; } @@ -9606,4 +9606,86 @@ options, null); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=313109 +public void test290() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR); + options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.ERROR); + options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); + options.put(CompilerOptions.OPTION_ReportUnusedWarningToken, CompilerOptions.ERROR); + this.runConformTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "class X {\n" + + " @SuppressWarnings(\"rawtypes\")\n" + + " void foo(ArrayList arg) {\n" + + " @SuppressWarnings(\"unchecked\")\n" + + " boolean aa = arg.add(1), bb = arg.add(1);\n" + + " if (bb)\n" + + " System.out.println(\"hi\");\n" + + " }\n" + + "}" + }, + "", + null, + true, + null, + options, + null); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=313109 +public void test291() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR); + options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.ERROR); + options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); + options.put(CompilerOptions.OPTION_ReportUnusedWarningToken, CompilerOptions.ERROR); + this.runConformTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "class X {\n" + + " @SuppressWarnings(\"rawtypes\")\n" + + " void foo(ArrayList arg) {\n" + + " @SuppressWarnings(\"unchecked\")\n" + + " boolean aa = arg.add(1), bb = arg.add(1);\n" + + " if (aa)\n" + + " System.out.println(\"hi\");\n" + + " }\n" + + "}" + }, + "", + null, + true, + null, + options, + null); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=313109 +public void test292() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR); + options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.ERROR); + options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); + options.put(CompilerOptions.OPTION_ReportUnusedWarningToken, CompilerOptions.ERROR); + this.runConformTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "class X {\n" + + " @SuppressWarnings(\"rawtypes\")\n" + + " void foo(ArrayList arg) {\n" + + " @SuppressWarnings(\"unchecked\")\n" + + " boolean aa = arg.add(1), bb = arg.add(1);\n" + + " }\n" + + "}" + }, + "", + null, + true, + null, + options, + null); +} }