JDK-8004823 : Add VM support for type annotation reflection
  • Type: New Feature
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Fix Versions: hs25
  • Submitted: 2012-12-10
  • Updated: 2017-05-17
  • Resolved: 2012-12-20
Related Reports
Relates :  
Relates :  
Relates :  
Description
JSR-308 brings annotation on type use (as opposed to annotations on type declarations only that we have today).

From the spec:

"JSR 308 introduces two new attributes: RuntimeVisibleTypeAnnotations and RuntimeInvisibleTypeAnnotations. These attributes are structurally identical to the RuntimeVisibleAnnotations and RuntimeInvisibleAnnotations attributes described above with one exception: rather than an array of annotation elements, RuntimeVisibleTypeAnnotations and RuntimeInvisibleTypeAnnotations contain an array of type_annotation elements, which are described in Section 3.1.

Runtime[In]VisibleTypeAnnotations_attribute {
   u2 attribute_name_index;  // "Runtime[In]VisibleTypeAnnotation"
   u2 attribute_length;
   u2 num_annotations;
   type_annotation annotations[num_annotations];
}

A type annotation is stored in a Runtime[In]visibleTypeAnnotations attribute on the smallest enclosing class, field, or method."

We need to add support in the VM for storing those TypeAnnotation attributes, and send them to Java-land to be parsed.