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/DeprecatedTest.java (+39 lines)
Lines 731-736 Link Here
731
		false,
731
		false,
732
		false);
732
		false);
733
}
733
}
734
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191909 (1.4 variant)
735
public void test019() {
736
	Map customOptions = new HashMap();
737
	customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR);
738
	this.runNegativeTest(
739
		new String[] {
740
			"test1/E01.java",
741
			"package test1;\n" + 
742
			"public class E01 {\n" + 
743
			"	/** @deprecated */\n" + 
744
			"	public static int x = 5, y= 10;\n" + 
745
			"}",
746
			"test1/E02.java",
747
			"package test1;\n" + 
748
			"public class E02 {\n" + 
749
			"	public void foo() {\n" + 
750
			"		System.out.println(E01.x);\n" + 
751
			"		System.out.println(E01.y);\n" + 
752
			"	}\n" + 
753
			"}"
754
		}, 
755
		"----------\n" + 
756
		"1. ERROR in test1\\E02.java (at line 4)\n" + 
757
		"	System.out.println(E01.x);\n" + 
758
		"	                       ^\n" + 
759
		"The field E01.x is deprecated\n" + 
760
		"----------\n" + 
761
		"2. ERROR in test1\\E02.java (at line 5)\n" + 
762
		"	System.out.println(E01.y);\n" + 
763
		"	                       ^\n" + 
764
		"The field E01.y is deprecated\n" + 
765
		"----------\n",
766
		null,
767
		true,
768
		customOptions,
769
		true,
770
		false,
771
		false);
772
}
734
public static Class testClass() {
773
public static Class testClass() {
735
	return DeprecatedTest.class;
774
	return DeprecatedTest.class;
736
}
775
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java (+39 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=191909
191
public void test004() {
192
	Map customOptions = new HashMap();
193
	customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR);
194
	this.runNegativeTest(
195
		new String[] {
196
			"test1/E01.java",
197
			"package test1;\n" + 
198
			"public class E01 {\n" + 
199
			"	@Deprecated\n" + 
200
			"	public static int x = 5, y= 10;\n" + 
201
			"}",
202
			"test1/E02.java",
203
			"package test1;\n" + 
204
			"public class E02 {\n" + 
205
			"	public void foo() {\n" + 
206
			"		System.out.println(E01.x);\n" + 
207
			"		System.out.println(E01.y);\n" + 
208
			"	}\n" + 
209
			"}"
210
		}, 
211
		"----------\n" + 
212
		"1. ERROR in test1\\E02.java (at line 4)\n" + 
213
		"	System.out.println(E01.x);\n" + 
214
		"	                       ^\n" + 
215
		"The field E01.x is deprecated\n" + 
216
		"----------\n" + 
217
		"2. ERROR in test1\\E02.java (at line 5)\n" + 
218
		"	System.out.println(E01.y);\n" + 
219
		"	                       ^\n" + 
220
		"The field E01.y is deprecated\n" + 
221
		"----------\n",
222
		null,
223
		true,
224
		customOptions,
225
		true,
226
		false,
227
		false);
228
}
190
public static Class testClass() {
229
public static Class testClass() {
191
	return Deprecated15Test.class;
230
	return Deprecated15Test.class;
192
}
231
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-6 / +30 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
			final Binding annotationRecipient = annotation.recipient;
567
			annotationTypes[i] = annotation.resolveType(scope);
567
			if (annotationRecipient != null && recipient != null) {
568
568
				// only local and field can share annnotations
569
			// null if receiver is a package binding
569
				switch (recipient.kind()) {
570
			if (instances != null)
570
					case Binding.FIELD :
571
				instances[i] = annotation.getCompilerAnnotation();
571
						FieldBinding field = (FieldBinding) recipient;
572
						field.tagBits = ((FieldBinding) annotationRecipient).tagBits;
573
						break;
574
					case Binding.LOCAL :
575
						LocalVariableBinding local = (LocalVariableBinding) recipient;
576
						local.tagBits = ((LocalVariableBinding) annotationRecipient).tagBits;
577
						break;
578
				}
579
				if (instances != null) {
580
					// need to fill the instances array
581
					instances[0] = annotation.getCompilerAnnotation();
582
					for (int j = 1; j < length; j++) {
583
						Annotation annot = annotations[j];
584
						instances[j] = annot.getCompilerAnnotation();
585
					}
586
				}
587
				return;
588
			} else {
589
				annotation.recipient = recipient;
590
				annotationTypes[i] = annotation.resolveType(scope);
591
				// null if receiver is a package binding
592
				if (instances != null) {
593
					instances[i] = annotation.getCompilerAnnotation();
594
				}
595
			}
572
		}
596
		}
573
		// check duplicate annotations
597
		// check duplicate annotations
574
		for (int i = 0; i < length; i++) {
598
		for (int i = 0; i < length; i++) {
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-1 / +59 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, 275 };
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
	}
9128
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908
9129
	public void test0275() throws JavaModelException {
9130
		this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
9131
		String contents =
9132
			"public class X {\n" +
9133
			"	public void foo() {\n" +
9134
			"		@Deprecated\n" + 
9135
			"		int x= 5, y= 10;\n" + 
9136
			"	}\n" +
9137
			"}";
9138
		ASTNode node = buildAST(
9139
				contents,
9140
				this.workingCopy,
9141
				true);
9142
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
9143
		CompilationUnit unit = (CompilationUnit) node;
9144
		assertProblemsSize(unit, 0);
9145
		node = getASTNode(unit, 0, 0, 0);
9146
		assertEquals("Not a variable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType());
9147
		VariableDeclarationStatement statement = (VariableDeclarationStatement) node;
9148
		List fragments = statement.fragments();
9149
		assertEquals("Wrong size", 2, fragments.size());
9150
		VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
9151
		IVariableBinding binding = fragment.resolveBinding();
9152
		IAnnotationBinding[] annotations = binding.getAnnotations();
9153
		assertEquals("Wrong size", 1, annotations.length);
9154
		fragment = (VariableDeclarationFragment) fragments.get(1);
9155
		binding = fragment.resolveBinding();
9156
		annotations = binding.getAnnotations();
9157
		assertEquals("Wrong size", 1, annotations.length);
9158
	}
9101
}
9159
}

Return to bug 191908