1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
31
31
import jdk .internal .classfile .impl .UnboundAttribute ;
32
32
33
33
/**
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
+ * Two special subtypes of {@code Attribute} are {@link CustomAttribute}, which
39
+ * all user-defined attributes should extend from, and {@link UnknownAttribute},
40
+ * representing attributes read from {@code class} file but are not recognized
41
+ * by the {@link ClassFile.AttributeMapperOption}.
42
+ * <p>
43
+ * Many attributes implement {@link ClassElement}, {@link FieldElement}, {@link
44
+ * MethodElement}, or {@link CodeElement} interfaces. They can be written to
45
+ * the {@code class} file as part of those enclosing structures via {@link
46
+ * ClassBuilder#with}, {@link FieldBuilder#with}, {@link MethodBuilder#with}, or
47
+ * {@link CodeBuilder#with}. If an attribute does not {@linkplain
48
+ * AttributeMapper#allowMultiple allow multiple instances} in one structure,
49
+ * the last supplied instance appears on the built structure. These interfaces
50
+ * also allow such attributes to be delivered in the traversal of corresponding
51
+ * {@link CompoundElement}; the exact rules are specified in the modeling
52
+ * subinterfaces.
53
+ * <p>
54
+ * Some attributes, like {@link BootstrapMethodsAttribute BootstrapMethods} and
55
+ * {@link LocalVariableTableAttribute LocalVariableTable}, are present in
56
+ * structures like {@link ClassModel} or {@link CodeModel}, but they do not
57
+ * implement {@link ClassElement} or {@link CodeElement}. Such attributes are
58
+ * usually modeled as an integral part to the declaring structure, specified
59
+ * in the modeling subinterfaces.
42
60
*
61
+ * @param <A> the attribute type
62
+ * @see java.lang.classfile.attribute
63
+ * @see AttributeMapper
64
+ * @see AttributedElement
65
+ * @see CustomAttribute
66
+ * @see UnknownAttribute
67
+ * @jvms 4.7 Attributes
43
68
* @sealedGraph
44
69
* @since 24
45
70
*/
@@ -62,7 +87,13 @@ public sealed interface Attribute<A extends Attribute<A>>
62
87
StackMapTableAttribute , SyntheticAttribute ,
63
88
UnknownAttribute , BoundAttribute , UnboundAttribute , CustomAttribute {
64
89
/**
65
- * {@return the name of the attribute}
90
+ * {@return the name of the attribute} The {@linkplain
91
+ * Utf8Entry#stringValue() string value} of the name is equivalent to the
92
+ * value of {@link AttributeMapper#name() attributeMapper().name()}.
93
+ * <p>
94
+ * If this attribute is read from a {@code class} file, this method returns
95
+ * the {@link Utf8Entry} indicating the attribute name in the {@code class}
96
+ * file.
66
97
*/
67
98
Utf8Entry attributeName ();
68
99
0 commit comments