JDK-8007766 : Repeating annotations: No Target on base with two new targets on container compiles unexepectedly
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-02-08
  • Updated: 2014-02-06
  • Resolved: 2013-03-14
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
Duplicate :  
Relates :  
Relates :  
Description
If base annotation is not meta-annotated with @Target, the compiler assumes that it has the JDK7 targets by default.

If container annotation is now meta-annotated with @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) which are the new targets added in JDK8, the test code compiles unexpectedly.

Expected behavior: TYPE_USE and TYPE_PARAMETER are not default targets, so target set for container annotation is not a subset of target set for base and compilation should fail. 
Test code attached. 
Comments
verified in jdk8 b92
06-06-2013

This was fixed with the checkin for JDK-8006547 that also includes a test for this, setting noreg-other due to this
14-03-2013

This was fixed in with the checkin for JDK-8006547
14-03-2013

Some comment sample code: import java.lang.annotation.*; @Target(ElementType.TYPE_USE) @interface AContainer { A[] value(); } @Repeatable(AContainer.class) @interface A {} @Target(ElementType.TYPE_USE) @interface BContainer { B[] value(); } @Repeatable(BContainer.class) @interface B {} class NoTargetOnBase { //This compiles. @A and a @B container are present (@A as a RuntimeInvisibleAnnotation) @A @B @B NoTargetOnBase ntob = new NoTargetOnBase(); //This compiles. @A and a @B container are present (@A as a RuntimeInvisibleAnnotation) @A @B @B String name = "name"; //This fails with error noted below. //@A @A public void m1() {} //This compiles; has RuntimeInvisibleAnnotation @A @A public void m2() {} // This compiles. No @A in class file. There is a @Bcontainer NoTargetOnBase getMe() { @A @B @B NoTargetOnBase ntob = new NoTargetOnBase(); return ntob;} } /* Error for m1() above NoTargetOnBase.java:20: error: target of container annotation AContainer is not a subset of target of repeated annotation A @A @A public void m1() {} ^ 1 error */
13-02-2013

This test randomly gens 250 tests to run. That is why one test run might encounter this failure and other runs might not.
13-02-2013

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