Hi, Thanks for reporting this. As Alex wrote on the spec list [1] he has clarified the spec.
There is a bug filed for this but I don't have time to work on it at the moment. I'll get around to fixing it in the not too distant future though. [1]: http://mail.openjdk.java.net/pipermail/enhanced-metadata-spec-discuss/2013-June/000214.html cheers /Joel On 2013-06-05, Deven You wrote: > Hi All, > > I didn't see this mail in the mailing list for a long time, so I > just comment here to ensure everyone can receive this message. > > Thanks a lot! > On 06/04/2013 09:37 PM, Deven You wrote: > > > >Hi All, > > > >I have written a test case[1] to show this problem. (If it is > >confirmed a real bug, I will convert this test case to jtreg) > > > >My expected output is no any output but OpenJDK returns: > > > >@NonInheritedAnnotationRepeated(name=A) > >@NonInheritedAnnotationRepeated(name=B) > > > >The reasons are: > > > >1. From the spec, Inherited means: > > > >Indicates that an annotation type is automatically inherited. If > >an Inherited meta-annotation is present on an annotation type > >declaration, and the user queries the annotation type on a class > >declaration, and the class declaration has no annotation for this > >type, then the class's superclass will automatically be queried > >for the annotation type. This process will be repeated until an > >annotation for this type is found, or the top of the class > >hierarchy (Object) is reached. If no superclass has an annotation > >for this type, then the query will indicate that the class in > >question has no such annotation. > > > >2. For repeated annotations, according to the explanation of 1., > >If it is non-inherited, querying Child class of this annotation > >should return null. > > > >3. Now the problem is if the repeated annotation is non-inherited, > >but its container annotation is inherited, OpenJDK will return the > >repeated annotations of Parent class if we query the Child class. > > > >It seems according to the Inherited semantics, even when container > >annotation is inherited, we should not retrieve parent class > >non-inherited repeated annotation from a child class. > > > >[1] http://cr.openjdk.java.net/~youdwei/ojdk-810/NonInheritedTest/ > ><http://cr.openjdk.java.net/%7Eyoudwei/ojdk-810/NonInheritedTest/> >
