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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java (+2 lines)
Lines 192-197 Link Here
192
							}
192
							}
193
						}
193
						}
194
					}
194
					}
195
				}  else {
196
					scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value, true);
195
				}
197
				}
196
				break checkAnnotationMethodType;
198
				break checkAnnotationMethodType;
197
			}
199
			}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java (+32 lines)
Lines 8792-8795 Link Here
8792
		"----------\n",
8792
		"----------\n",
8793
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
8793
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
8794
}
8794
}
8795
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=262304
8796
public void test268() {
8797
	this.runNegativeTest(
8798
		new String[] {
8799
			"X.java", // =================
8800
			"public class X {\n" + 
8801
			"	protected enum E {\n" + 
8802
			"		E1, E2\n" + 
8803
			"	}\n" + 
8804
			"	protected @interface Anno1 { E value(); }\n" + 
8805
			"	protected @interface Anno2 { E value(); }\n" + 
8806
			"	protected @interface Anno3 { E value(); }\n" + 
8807
			"	@Anno1(true ? E.E1 : E.E2)\n" + 
8808
			"	@Anno2(bar())\n" + 
8809
			"	@Anno3(((E.E1)))\n" + 
8810
			"	public void foo() {\n" + 
8811
			"	}\n" + 
8812
			"	public E bar() { return E.E1; }\n" + 
8813
			"}\n", // =================
8814
		},
8815
		"----------\n" + 
8816
		"1. ERROR in X.java (at line 8)\n" + 
8817
		"	@Anno1(true ? E.E1 : E.E2)\n" + 
8818
		"	       ^^^^^^^^^^^^^^^^^^\n" + 
8819
		"The value for annotation attribute X.Anno1.value must be an enum constant expression\n" + 
8820
		"----------\n" + 
8821
		"2. ERROR in X.java (at line 9)\n" + 
8822
		"	@Anno2(bar())\n" + 
8823
		"	       ^^^^^\n" + 
8824
		"The value for annotation attribute X.Anno2.value must be an enum constant expression\n" + 
8825
		"----------\n");
8826
}
8795
}
8827
}

Return to bug 262304