Bug 83939 - [1.5][compiler] null is allowed as a legal element value in annotations
Summary: [1.5][compiler] null is allowed as a legal element value in annotations
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-28 10:52 EST by Jon Nall CLA
Modified: 2005-02-15 06:35 EST (History)
0 users

See Also:


Attachments
Test case (104 bytes, text/plain)
2005-01-28 16:50 EST, Olivier Thomann CLA
no flags Details

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