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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java (+40 lines)
Lines 187-192 Link Here
187
		customOptions,
187
		customOptions,
188
		null);
188
		null);
189
}
189
}
190
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=159709
191
//guard variant for DeprecatedTest#test015 using an annotation 
192
public void test004() {
193
	Map customOptions = new HashMap();
194
	customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR);
195
	this.runNegativeTest(
196
		new String[] {
197
			"test1/E01.java",
198
			"package test1;\n" + 
199
			"public class E01 {\n" + 
200
			"	@Deprecated\n" + 
201
			"	public static int x = 5, y= 10;\n" + 
202
			"}",
203
			"test1/E02.java",
204
			"package test1;\n" + 
205
			"public class E02 {\n" + 
206
			"	public void foo() {\n" + 
207
			"		System.out.println(E01.x);\n" + 
208
			"		System.out.println(E01.y);\n" + 
209
			"	}\n" + 
210
			"}"
211
		}, 
212
		"----------\n" + 
213
		"1. ERROR in test1\\E02.java (at line 4)\n" + 
214
		"	System.out.println(E01.x);\n" + 
215
		"	                       ^\n" + 
216
		"The field E01.x is deprecated\n" + 
217
		"----------\n" + 
218
		"2. ERROR in test1\\E02.java (at line 5)\n" + 
219
		"	System.out.println(E01.y);\n" + 
220
		"	                       ^\n" + 
221
		"The field E01.y is deprecated\n" + 
222
		"----------\n",
223
		null,
224
		true,
225
		customOptions,
226
		true,
227
		false,
228
		false);
229
}
190
public static Class testClass() {
230
public static Class testClass() {
191
	return Deprecated15Test.class;
231
	return Deprecated15Test.class;
192
}
232
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-5 / +26 lines)
Lines 563-574 Link Here
563
		TypeBinding[] annotationTypes = new TypeBinding[length];
563
		TypeBinding[] annotationTypes = new TypeBinding[length];
564
		for (int i = 0; i < length; i++) {
564
		for (int i = 0; i < length; i++) {
565
			Annotation annotation = annotations[i];
565
			Annotation annotation = annotations[i];
566
			annotation.recipient = recipient;
566
			if (annotation.recipient != null) {
567
			annotationTypes[i] = annotation.resolveType(scope);
567
				// only local and field can share annnotations
568
				switch (recipient.kind()) {
569
					case Binding.FIELD :
570
						FieldBinding field = (FieldBinding) recipient;
571
						field.tagBits = ((FieldBinding) annotation.recipient).tagBits;
572
						/* now we can return since all tag bits have already
573
						 * been set and duplicate annotations detected
574
						 */
575
						return;
576
					case Binding.LOCAL :
577
						LocalVariableBinding local = (LocalVariableBinding) recipient;
578
						local.tagBits = ((LocalVariableBinding) annotation.recipient).tagBits;
579
						/* now we can return since all tag bits have already
580
						 * been set and duplicate annotations detected
581
						 */
582
						return;
583
				}
584
			} else {
585
				annotation.recipient = recipient;
586
				annotationTypes[i] = annotation.resolveType(scope);
568
587
569
			// null if receiver is a package binding
588
				// null if receiver is a package binding
570
			if (instances != null)
589
				if (instances != null) {
571
				instances[i] = annotation.getCompilerAnnotation();
590
					instances[i] = annotation.getCompilerAnnotation();
591
				}
592
			}
572
		}
593
		}
573
		// check duplicate annotations
594
		// check duplicate annotations
574
		for (int i = 0; i < length; i++) {
595
		for (int i = 0; i < length; i++) {
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-1 / +28 lines)
Lines 46-52 Link Here
46
	}
46
	}
47
47
48
	static {
48
	static {
49
//		TESTS_NUMBERS = new int[] { 272 };
49
//		TESTS_NUMBERS = new int[] { 274 };
50
//		TESTS_RANGE = new int[] { 253, -1 };
50
//		TESTS_RANGE = new int[] { 253, -1 };
51
//		TESTS_NAMES = new String[] {"test0204"};
51
//		TESTS_NAMES = new String[] {"test0204"};
52
	}
52
	}
Lines 9098-9101 Link Here
9098
		CompilationUnit unit = (CompilationUnit) node;
9098
		CompilationUnit unit = (CompilationUnit) node;
9099
		assertProblemsSize(unit, 1, "The type A is not generic; it cannot be parameterized with arguments <?>");
9099
		assertProblemsSize(unit, 1, "The type A is not generic; it cannot be parameterized with arguments <?>");
9100
	}
9100
	}
9101
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908
9102
	public void test0274() throws JavaModelException {
9103
		this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
9104
		String contents =
9105
			"public class X {\n" +
9106
			"	@Deprecated\n" + 
9107
			"	public static int x= 5, y= 10;\n" + 
9108
			"}";
9109
		ASTNode node = buildAST(
9110
				contents,
9111
				this.workingCopy,
9112
				true);
9113
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
9114
		CompilationUnit unit = (CompilationUnit) node;
9115
		assertProblemsSize(unit, 0);
9116
		node = getASTNode(unit, 0, 0);
9117
		assertEquals("Not a field declaration", ASTNode.FIELD_DECLARATION, node.getNodeType());
9118
		FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
9119
		List fragments = fieldDeclaration.fragments();
9120
		assertEquals("Wrong size", 2, fragments.size());
9121
		VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
9122
		IVariableBinding binding = fragment.resolveBinding();
9123
		assertTrue("Not deprecated", binding.isDeprecated());
9124
		fragment = (VariableDeclarationFragment) fragments.get(1);
9125
		binding = fragment.resolveBinding();
9126
		assertTrue("Not deprecated", binding.isDeprecated());
9127
	}
9101
}
9128
}

Return to bug 191908