Bug 220311

Summary: [1.5][compiler] package-info.java does not recognise duplicate annotations as a problem
Product: [Eclipse Project] JDT Reporter: Paul Cowan <cowan>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: david_audel, jerome_lanneluc
Version: 3.4   
Target Milestone: 3.5 M5   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Paul Cowan CLA 2008-02-25 21:20:16 EST
Build ID: I20080207-1530

Steps To Reproduce:
1. Create a new package, 'example'
2. Create a java file, 'example/package-info.java'
3. Include the following contents
   @Deprecated
   @Deprecated
   package example;


Expected result: this should be flagged as an error. On a class, this would (correctly) cause 'Duplicate annotation @Deprecated'; on package-info, however, Eclipse ignores it. However on trying to access the package annotations in the Sun JVM at runtime, you'll get:

java.lang.annotation.AnnotationFormatError: Duplicate annotation for class: interface java.lang.Deprecated: @java.lang.Deprecated()
	at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:75)
	at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
	at java.lang.Class.initAnnotationsIfNecessary(Class.java:3072)
	at java.lang.Class.getAnnotation(Class.java:3029)
	at java.lang.Class.isAnnotationPresent(Class.java:3042)
	at java.lang.Package.isAnnotationPresent(Package.java:376)


etc.

More information:
Comment 1 Kent Johnson CLA 2009-01-15 13:12:54 EST
Added AnnotationTest.test266()

Was fixed by the changes for bug 258906

Test released for 3.5M5
Comment 2 David Audel CLA 2009-01-27 05:58:20 EST
Verified for 3.5M5 using I20090126-1300