JDK-8037348 : RuntimeInvisibleAnnotations should not be generated for type annotation on anonymous innerclass creation
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-03-14
  • Updated: 2014-07-17
  • Resolved: 2014-06-06
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 9
9 b19Fixed
Related Reports
Relates :  
Relates :  
Description
Consider this source code:
---
import java.lang.annotation.*;
public class AnnotCopiedToAnonymous {
     private Object o = new @Annot Object() { };
}
@Target({ElementType.TYPE, ElementType.TYPE_USE})
@interface Annot { }
---

The generated anonymous innerclass (AnnotCopiedToAnonymous$1) has the Annot annotation as a declaration annotation in its RuntimeInvisibleAnnotations in addition to having it in its RuntimeInvisibleTypeAnnotations with a supertype target.

The annotation should not be listed in the RuntimeInvisibleAnnotations attribute, see:
http://mail.openjdk.java.net/pipermail/type-annotations-dev/2014-March/001663.html