APIdia Launch Partner
Top Description Methods
java.lang.classfile.attribute

public sealed Interface RuntimeVisibleAnnotationsAttribute

extends Attribute<RuntimeVisibleAnnotationsAttribute>, ClassElement, MethodElement, FieldElement
permits BoundRuntimeVisibleAnnotationsAttribute, UnboundRuntimeVisibleAnnotationsAttribute
Known Direct Implementers
jdk.internal.classfile.impl.BoundAttribute.BoundRuntimeVisibleAnnotationsAttribute, jdk.internal.classfile.impl.UnboundAttribute.UnboundRuntimeVisibleAnnotationsAttribute
Annotations
@SuppressWarnings:doclint:reference
Imports
java.lang.annotation.ElementType, .RetentionPolicy, java.lang.classfile.*, .AttributeMapper.AttributeStability, java.lang.reflect.AnnotatedElement, java.util.List, jdk.internal.classfile.impl.BoundAttribute, .UnboundAttribute

Models the RuntimeVisibleAnnotations attribute (JVMS 4.7.16), which stores declaration annotations on this structure that are visible to both class file consumers and core reflection.

This attribute appears on classes, fields, methods, and record components, and does not permit multiple instances in one structure. It has a data dependency on the constant pool.

The attribute was introduced in the Java SE Platform version 5.0, major version 49.

Since
24
Java Virtual Machine Specification
4.7.16 The RuntimeVisibleAnnotations Attribute
See Also
Attributes#runtimeVisibleAnnotations(), java.compiler/javax.lang.model.element.Element, AnnotatedElement, ElementType, RetentionPolicy#RUNTIME

Method Summary

Modifier and TypeMethod and Description
public List<Annotation>

Returns:

the run-time visible declaration annotations on this structure
annotations
()

Returns the run-time visible declaration annotations on this structure.

public static RuntimeVisibleAnnotationsAttribute

Returns:

a RuntimeVisibleAnnotations attribute
of
(List<Annotation>
the annotations
annotations
)

Returns a RuntimeVisibleAnnotations attribute.

public static RuntimeVisibleAnnotationsAttribute

Returns:

a RuntimeVisibleAnnotations attribute
of
(Annotation...
the annotations
annotations
)

Returns a RuntimeVisibleAnnotations attribute.

Inherited from java.lang.classfile.Attribute:
attributeMapperattributeName

Method Detail

annotationsback to summary
public List<Annotation> annotations()

Returns the run-time visible declaration annotations on this structure.

Returns:List<Annotation>

the run-time visible declaration annotations on this structure

ofback to summary
public static RuntimeVisibleAnnotationsAttribute of(List<Annotation> annotations)

Returns a RuntimeVisibleAnnotations attribute.

Parameters
annotations:List<Annotation>

the annotations

Returns:RuntimeVisibleAnnotationsAttribute

a RuntimeVisibleAnnotations attribute

Exceptions
IllegalArgumentException:
if the number of annotations exceeds the limit of u2
ofback to summary
public static RuntimeVisibleAnnotationsAttribute of(Annotation... annotations)

Returns a RuntimeVisibleAnnotations attribute.

Parameters
annotations:Annotation[]

the annotations

Returns:RuntimeVisibleAnnotationsAttribute

a RuntimeVisibleAnnotations attribute

Exceptions
IllegalArgumentException:
if the number of annotations exceeds the limit of u2