Bug 79349 - [1.5] Annotation with default value
Summary: [1.5] Annotation with default value
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-23 16:20 EST by Bart Geraci CLA
Modified: 2004-12-14 17:47 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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