Bug 79349

Summary: [1.5] Annotation with default value
Product: [Eclipse Project] JDT Reporter: Bart Geraci <BJGeraci>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Bart Geraci CLA 2004-11-23 16:20:43 EST
Eclipse build 200411230838

Annotation defined as: 
===========
@Documented
@Rentention(RententionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface MyAnn { 
  String value() default "Default Message"
}
===========

A method in some other class: 

============
public @MyAnn void something() { }
============

Compiler complains "The annotation @MyAnn must define the attribute value"

changing "@MyAnn" to "@MyAnn()" shows same error.
changing it to "@MyAnn(4)" correctly displays a type mismatch error.
changing it to "@MyAnn(null)" displays an error saying that value 
  must be a constant expression.
Comment 1 Philipe Mulet CLA 2004-11-30 10:18:52 EST
Works in latest, added regression test: AnnotationTest#test049.
Fixed.

Complete test case would actually be:
[import java.lang.annotation.*;

@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface MyAnn {
  String value() default "Default Message";
}

public class X {
	public @MyAnn void something() { }	
}]
Comment 2 Olivier Thomann CLA 2004-12-14 17:47:30 EST
Verified in 200412140800