JDK-8006547 : Repeating annotations: No Target on container annotation with all targets on base annotation gives compiler error
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-01-18
  • Updated: 2013-06-11
  • Resolved: 2013-03-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b84Fixed
Related Reports
Relates :  
Relates :  
Description
Test case: Foo has @Target with all ElementType enum constants and FooContainer does not have @Target.

Based on this rule, the above test case should compile:
If an annotation is not meta-annotated with @Target, then the compiler treats the annotation as if it is meta-annotated with all of the ElementType enum constants that appear in Java 7: ANNOTATION_TYPE, CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, and TYPE

Expected: code should compile fine.
Actual behavior: Compiler error:
NoTargetonContainer.java:9: error: target of container annotation FooContainer is not a subset of target of repeated annotation Foo
@ContainedBy(FooContainer.class)
^
1 error

Test src code attached. 

Comments
Test name: tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java
14-02-2013

Similar to the above case, if Base has all 10 Targets, including the two new targets, TYPE_USE and TYPE_PARAMETER and ContainerAnno does not have @Target, the test goves compiler error. Test code attached.
08-02-2013