Bug 83939

Summary: [1.5][compiler] null is allowed as a legal element value in annotations
Product: [Eclipse Project] JDT Reporter: Jon Nall <nall>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Test case none

Description Jon Nall CLA 2005-01-28 10:52:10 EST
JLS3 states on page 283 that for annotations:
Note that null is not a legal element value for any element type.

However the following is allowed in eclipse 3.1M4:
public @interface Foo
{
    int[] bar() default null;
}


also, null is incorrectly allowed in the following context:
@Foo(bar=null)
int baz;

javac-1.5.0 fails in both of these cases.
Comment 1 Olivier Thomann CLA 2005-01-28 11:41:22 EST
With latest I get:
----------
1. ERROR in c:\tests_sources\X.java
 (at line 3)
	int[] bar() default null;
	                    ^^^^
The value for annotation attribute X.bar must be a constant expression
----------
1 problem
Comment 2 Olivier Thomann CLA 2005-01-28 11:59:29 EST
Closing as WORKSFORME.
Added regression test.
Thanks for reporting the problem.
Comment 3 Jon Nall CLA 2005-01-28 14:59:59 EST
well, that's what i get for trying to simplify my testcase without actually
checking in eclipse. here's the real reproducer. sorry for the confusion.

@interface Foo
{
    
}

@interface Bar
{
    Foo[] foo() default null;
}

@Bar(foo=null)
class Blah
{
    // ...
}
Comment 4 Olivier Thomann CLA 2005-01-28 16:50:21 EST
I'll try to reproduce.
Comment 5 Olivier Thomann CLA 2005-01-28 16:50:57 EST
Created attachment 17566 [details]
Test case
Comment 6 Philipe Mulet CLA 2005-01-28 18:59:38 EST
Indeed, we did not properly check the annotation value scenario.
Added AnnotationTest#test108-109.
Comment 7 Philipe Mulet CLA 2005-01-28 18:59:51 EST
Fixed
Comment 8 Jerome Lanneluc CLA 2005-02-15 06:35:12 EST
Verified in I20050214