Skip to content

Commit 564e0a2

Browse files
committed
8342466: Improve API documentation for java.lang.classfile.attribute
8347762: ClassFile attribute specification refers to non-SE modules Reviewed-by: asotona Backport-of: 973c630
1 parent 53aa9f2 commit 564e0a2

File tree

70 files changed

+2436
-967
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2436
-967
lines changed

src/java.base/share/classes/java/lang/classfile/Annotation.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -41,8 +41,9 @@
4141
* type_annotation} structure (JVMS {@jvms 4.7.20}). This model indicates the
4242
* interface of the annotation and a set of element-value pairs.
4343
* <p>
44-
* This model can reconstruct an annotation, given the location of the modeled structure
45-
* in the class file and the definition of the annotation interface.
44+
* This model can reconstruct an annotation, given the location of the modeled
45+
* structure in the {@code class} file and the definition of the annotation
46+
* interface.
4647
* <p>
4748
* Two {@code Annotation} objects should be compared using the {@link
4849
* Object#equals(Object) equals} method.
@@ -54,8 +55,8 @@
5455
* elements with default values (JLS {@jls 9.6.2}), and whether the reconstructed annotation
5556
* is a container annotation for multiple annotations (JLS {@jls 9.7.5}).
5657
*
57-
* @see AnnotationElement
58-
* @see AnnotationValue
58+
* @see java.lang.annotation.Annotation
59+
* @see java.lang.reflect.AnnotatedElement Annotations in core reflection
5960
* @see TypeAnnotation
6061
* @see RuntimeVisibleAnnotationsAttribute
6162
* @see RuntimeInvisibleAnnotationsAttribute
@@ -70,11 +71,15 @@ public sealed interface Annotation
7071
/**
7172
* {@return the constant pool entry holding the {@linkplain Class#descriptorString
7273
* descriptor string} of the annotation interface}
74+
*
75+
* @see java.lang.annotation.Annotation#annotationType()
7376
*/
7477
Utf8Entry className();
7578

7679
/**
7780
* {@return the annotation interface, as a symbolic descriptor}
81+
*
82+
* @see java.lang.annotation.Annotation#annotationType()
7883
*/
7984
default ClassDesc classSymbol() {
8085
return Util.fieldTypeSymbol(className());

src/java.base/share/classes/java/lang/classfile/AnnotationElement.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -40,8 +40,8 @@
4040
* {@link Object#equals(Object) equals} method.
4141
*
4242
* @see Annotation
43-
* @see AnnotationValue
44-
*
43+
* @see java.lang.reflect.AnnotatedElement Annotations in core reflection
44+
* @jvms 4.7.16.1 The {@code element_value} structure
4545
* @since 24
4646
*/
4747
public sealed interface AnnotationElement

src/java.base/share/classes/java/lang/classfile/AnnotationValue.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -45,6 +45,7 @@
4545
*
4646
* @see Annotation
4747
* @see AnnotationElement
48+
* @see java.lang.reflect.AnnotatedElement Annotations in core reflection
4849
*
4950
* @sealedGraph
5051
* @since 24

src/java.base/share/classes/java/lang/classfile/Attribute.java

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,15 +31,31 @@
3131
import jdk.internal.classfile.impl.UnboundAttribute;
3232

3333
/**
34-
* Models a classfile attribute (JVMS {@jvms 4.7}). Many, though not all, subtypes of
35-
* {@linkplain Attribute} will implement {@link ClassElement}, {@link
36-
* MethodElement}, {@link FieldElement}, or {@link CodeElement}; attributes that
37-
* are also elements will be delivered when traversing the elements of the
38-
* corresponding model type. Additionally, all attributes are accessible
39-
* directly from the corresponding model type through {@link
40-
* AttributedElement#findAttribute(AttributeMapper)}.
41-
* @param <A> the attribute type
34+
* Models an attribute (JVMS {@jvms 4.7}) in the {@code class} file format.
35+
* Attributes exist on certain {@code class} file structures modeled by {@link
36+
* AttributedElement}, which provides basic read access to the attributes.
37+
* <p>
38+
* This sealed interface hierarchy includes attributes predefined in the JVMS
39+
* and JDK-specific nonstandard attributes. Their {@linkplain #attributeMapper()
40+
* mappers} are available in {@link Attributes}. Two special subtypes of {@code
41+
* Attribute} are {@link CustomAttribute}, which all user-defined attributes
42+
* should extend from, and {@link UnknownAttribute}, representing attributes
43+
* read from {@code class} file but are not recognized by the {@link
44+
* ClassFile.AttributeMapperOption}.
45+
* <p>
46+
* Attributes are read through {@link AttributedElement} or element traversal of
47+
* a {@link CompoundElement}; they are written through {@link ClassFileBuilder}.
48+
* See {@linkplain java.lang.classfile.attribute##reading Reading Attributes}
49+
* and {@linkplain java.lang.classfile.attribute##writing Writing Attributes}
50+
* for more details.
4251
*
52+
* @param <A> the attribute type
53+
* @see java.lang.classfile.attribute
54+
* @see AttributeMapper
55+
* @see AttributedElement
56+
* @see CustomAttribute
57+
* @see UnknownAttribute
58+
* @jvms 4.7 Attributes
4359
* @sealedGraph
4460
* @since 24
4561
*/
@@ -62,7 +78,13 @@ public sealed interface Attribute<A extends Attribute<A>>
6278
StackMapTableAttribute, SyntheticAttribute,
6379
UnknownAttribute, BoundAttribute, UnboundAttribute, CustomAttribute {
6480
/**
65-
* {@return the name of the attribute}
81+
* {@return the name of the attribute} The {@linkplain
82+
* Utf8Entry#stringValue() string value} of the name is equivalent to the
83+
* value of {@link AttributeMapper#name() attributeMapper().name()}.
84+
* <p>
85+
* If this attribute is read from a {@code class} file, this method returns
86+
* the {@link Utf8Entry} indicating the attribute name in the {@code class}
87+
* file.
6688
*/
6789
Utf8Entry attributeName();
6890

0 commit comments

Comments
 (0)