8342466: Improve API documentation for java.lang.classfile.attribute

Reviewed-by: darcy, asotona
This commit is contained in:
Chen Liang 2025-01-15 02:04:01 +00:00
parent 9782bfdd27
commit 973c630777
70 changed files with 2443 additions and 967 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,30 +25,39 @@
package java.lang.classfile.attribute;
import java.lang.classfile.Annotation;
import java.lang.classfile.Attribute;
import java.lang.classfile.ClassElement;
import java.lang.classfile.FieldElement;
import java.lang.classfile.MethodElement;
import java.lang.annotation.ElementType;
import java.lang.annotation.RetentionPolicy;
import java.lang.classfile.*;
import java.lang.classfile.AttributeMapper.AttributeStability;
import java.lang.reflect.AnnotatedElement;
import java.util.List;
import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute;
/**
* Models the {@code RuntimeInvisibleAnnotations} attribute (JVMS {@jvms 4.7.17}), which
* can appear on classes, methods, and fields. Delivered as a
* {@link java.lang.classfile.ClassElement}, {@link java.lang.classfile.FieldElement}, or
* {@link java.lang.classfile.MethodElement} when traversing the corresponding model type.
* Models the {@link Attributes#runtimeInvisibleAnnotations()
* RuntimeInvisibleAnnotations} attribute (JVMS {@jvms 4.7.17}), which stores
* declaration annotations on this structure that are visible to {@code
* class} file consumers but are not visible to {@linkplain AnnotatedElement
* core reflection}.
* <p>
* The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation.
* This attribute appears on classes, fields, methods, and record components,
* and does not permit {@linkplain AttributeMapper#allowMultiple multiple
* instances} in one structure. It has a data dependency on the {@linkplain
* AttributeStability#CP_REFS constant pool}.
* <p>
* The attribute was introduced in the Java SE Platform version 5.0.
* The attribute was introduced in the Java SE Platform version 5.0, major
* version {@value ClassFile#JAVA_5_VERSION}.
*
* @see Attributes#runtimeInvisibleAnnotations()
* @see java.compiler/javax.lang.model.element.Element
* @see ElementType
* @see RetentionPolicy#CLASS
* @jvms 4.7.17 The {@code RuntimeInvisibleAnnotations} Attribute
* @since 24
*/
@SuppressWarnings("doclint:reference")
public sealed interface RuntimeInvisibleAnnotationsAttribute
extends Attribute<RuntimeInvisibleAnnotationsAttribute>,
ClassElement, MethodElement, FieldElement
@ -56,12 +65,13 @@ public sealed interface RuntimeInvisibleAnnotationsAttribute
UnboundAttribute.UnboundRuntimeInvisibleAnnotationsAttribute {
/**
* {@return the non-runtime-visible annotations on this class, field, or method}
* {@return the run-time invisible declaration annotations on this structure}
*/
List<Annotation> annotations();
/**
* {@return a {@code RuntimeInvisibleAnnotations} attribute}
*
* @param annotations the annotations
*/
static RuntimeInvisibleAnnotationsAttribute of(List<Annotation> annotations) {
@ -70,6 +80,7 @@ public sealed interface RuntimeInvisibleAnnotationsAttribute
/**
* {@return a {@code RuntimeInvisibleAnnotations} attribute}
*
* @param annotations the annotations
*/
static RuntimeInvisibleAnnotationsAttribute of(Annotation... annotations) {