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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java (-2 / +11 lines)
Lines 291-297 Link Here
291
											IrritantSet tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
291
											IrritantSet tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
292
											if (tokenIrritants != null
292
											if (tokenIrritants != null
293
													&& !tokenIrritants.areAllSet() // no complaint against @SuppressWarnings("all")
293
													&& !tokenIrritants.areAllSet() // no complaint against @SuppressWarnings("all")
294
													&& options.isAnyEnabled(tokenIrritants) // if irritant is effectevely enabled
294
													&& options.isAnyEnabled(tokenIrritants) // if irritant is effectively enabled
295
													&& (foundIrritants[iSuppress] == null || !foundIrritants[iSuppress].isAnySet(tokenIrritants))) { // if irritant had no matching problem
295
													&& (foundIrritants[iSuppress] == null || !foundIrritants[iSuppress].isAnySet(tokenIrritants))) { // if irritant had no matching problem
296
												if (unusedWarningTokenIsWarning) {
296
												if (unusedWarningTokenIsWarning) {
297
													int start = value.sourceStart, end = value.sourceEnd;
297
													int start = value.sourceStart, end = value.sourceEnd;
Lines 477-485 Link Here
477
		System.arraycopy(this.suppressWarningAnnotations, 0,this.suppressWarningAnnotations = new Annotation[2*this.suppressWarningsCount], 0, this.suppressWarningsCount);
477
		System.arraycopy(this.suppressWarningAnnotations, 0,this.suppressWarningAnnotations = new Annotation[2*this.suppressWarningsCount], 0, this.suppressWarningsCount);
478
		System.arraycopy(this.suppressWarningScopePositions, 0,this.suppressWarningScopePositions = new long[2*this.suppressWarningsCount], 0, this.suppressWarningsCount);
478
		System.arraycopy(this.suppressWarningScopePositions, 0,this.suppressWarningScopePositions = new long[2*this.suppressWarningsCount], 0, this.suppressWarningsCount);
479
	}
479
	}
480
	final long scopePositions = ((long)scopeStart<<32) + scopeEnd;
481
	for (int i = 0, max = this.suppressWarningsCount; i < max; i++) {
482
		if (this.suppressWarningAnnotations[i] == annotation
483
				&& this.suppressWarningScopePositions[i] == scopePositions
484
				&& this.suppressWarningIrritants[i].isAllSet(irritants)) {
485
			// annotation data already recorded
486
			return;
487
		}
488
	}
480
	this.suppressWarningIrritants[this.suppressWarningsCount] = irritants;
489
	this.suppressWarningIrritants[this.suppressWarningsCount] = irritants;
481
	this.suppressWarningAnnotations[this.suppressWarningsCount] = annotation;
490
	this.suppressWarningAnnotations[this.suppressWarningsCount] = annotation;
482
	this.suppressWarningScopePositions[this.suppressWarningsCount++] = ((long)scopeStart<<32) + scopeEnd;
491
	this.suppressWarningScopePositions[this.suppressWarningsCount++] = scopePositions;
483
}
492
}
484
493
485
/*
494
/*
(-)compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java (+14 lines)
Lines 195-200 Link Here
195
		return false;
195
		return false;
196
	}
196
	}
197
197
198
	/**
199
	 * Returns true if all of the irritants in given other set is positionned in receiver
200
	 * @param other the given set of irritants
201
	 */
202
	public boolean isAllSet(IrritantSet other) {
203
		if (other == null)
204
			return false;
205
		for (int i = 0; i < GROUP_MAX; i++) {
206
			if (this.bits[i] != other.bits[i])
207
				return false;
208
		}
209
		return true;
210
	}
211
198
	public boolean isSet(int singleGroupIrritants) {
212
	public boolean isSet(int singleGroupIrritants) {
199
		int group = (singleGroupIrritants & GROUP_MASK) >> GROUP_SHIFT;
213
		int group = (singleGroupIrritants & GROUP_MASK) >> GROUP_SHIFT;
200
		return (this.bits[group] & singleGroupIrritants) != 0;
214
		return (this.bits[group] & singleGroupIrritants) != 0;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java (-1 / +83 lines)
Lines 45-51 Link Here
45
	// All specified tests which do not belong to the class are skipped...
45
	// All specified tests which do not belong to the class are skipped...
46
	static {
46
	static {
47
//		TESTS_NAMES = new String[] { "test127" };
47
//		TESTS_NAMES = new String[] { "test127" };
48
//		TESTS_NUMBERS = new int[] { 289 };
48
//		TESTS_NUMBERS = new int[] { 290, 291 };
49
//		TESTS_RANGE = new int[] { 249, -1 };
49
//		TESTS_RANGE = new int[] { 249, -1 };
50
	}
50
	}
51
51
Lines 9606-9609 Link Here
9606
		options,
9606
		options,
9607
		null);
9607
		null);
9608
}
9608
}
9609
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=313109
9610
public void test290() {
9611
	Map options = getCompilerOptions();
9612
	options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR);
9613
	options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.ERROR);
9614
	options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED);
9615
	options.put(CompilerOptions.OPTION_ReportUnusedWarningToken, CompilerOptions.ERROR);
9616
	this.runConformTest(
9617
		new String[] {
9618
				"X.java",
9619
				"import java.util.ArrayList;\n" + 
9620
				"class X {\n" + 
9621
				"	@SuppressWarnings(\"rawtypes\")\n" + 
9622
				"	void foo(ArrayList arg) {\n" + 
9623
				"		@SuppressWarnings(\"unchecked\")\n" + 
9624
				"		boolean aa = arg.add(1), bb = arg.add(1);\n" + 
9625
				"		if (bb)\n" + 
9626
				"			System.out.println(\"hi\");\n" + 
9627
				"	}\n" + 
9628
				"}"
9629
		},
9630
		"",
9631
		null,
9632
		true,
9633
		null,
9634
		options,
9635
		null);
9636
}
9637
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=313109
9638
public void test291() {
9639
	Map options = getCompilerOptions();
9640
	options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR);
9641
	options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.ERROR);
9642
	options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED);
9643
	options.put(CompilerOptions.OPTION_ReportUnusedWarningToken, CompilerOptions.ERROR);
9644
	this.runConformTest(
9645
		new String[] {
9646
				"X.java",
9647
				"import java.util.ArrayList;\n" + 
9648
				"class X {\n" + 
9649
				"	@SuppressWarnings(\"rawtypes\")\n" + 
9650
				"	void foo(ArrayList arg) {\n" + 
9651
				"		@SuppressWarnings(\"unchecked\")\n" + 
9652
				"		boolean aa = arg.add(1), bb = arg.add(1);\n" + 
9653
				"		if (aa)\n" + 
9654
				"			System.out.println(\"hi\");\n" + 
9655
				"	}\n" + 
9656
				"}"
9657
		},
9658
		"",
9659
		null,
9660
		true,
9661
		null,
9662
		options,
9663
		null);
9664
}
9665
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=313109
9666
public void test292() {
9667
	Map options = getCompilerOptions();
9668
	options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR);
9669
	options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.ERROR);
9670
	options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED);
9671
	options.put(CompilerOptions.OPTION_ReportUnusedWarningToken, CompilerOptions.ERROR);
9672
	this.runConformTest(
9673
		new String[] {
9674
				"X.java",
9675
				"import java.util.ArrayList;\n" + 
9676
				"class X {\n" + 
9677
				"	@SuppressWarnings(\"rawtypes\")\n" + 
9678
				"	void foo(ArrayList arg) {\n" + 
9679
				"		@SuppressWarnings(\"unchecked\")\n" + 
9680
				"		boolean aa = arg.add(1), bb = arg.add(1);\n" + 
9681
				"	}\n" + 
9682
				"}"
9683
		},
9684
		"",
9685
		null,
9686
		true,
9687
		null,
9688
		options,
9689
		null);
9690
}
9609
}
9691
}

Return to bug 313109