Skip to content

Commit c08f76c

Browse files
committed
Review comments, also simplify Attribute
1 parent 575712c commit c08f76c

File tree

8 files changed

+25
-32
lines changed

8 files changed

+25
-32
lines changed

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

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,19 @@
3535
* Attributes exist on certain {@code class} file structures modeled by {@link
3636
* AttributedElement}, which provides basic read access to the attributes.
3737
* <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}.
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}.
4245
* <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.
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.
6051
*
6152
* @param <A> the attribute type
6253
* @see java.lang.classfile.attribute

src/java.base/share/classes/java/lang/classfile/attribute/InnerClassInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public sealed interface InnerClassInfo
7979
* {@return a set of flag enums denoting access permissions and properties
8080
* of the nested class}
8181
*
82-
* @throws IllegalArgumentException if the flags mask has any unused bit set
82+
* @throws IllegalArgumentException if the flags mask has any undefined bit set
8383
* @see Class#accessFlags()
8484
* @see AccessFlag.Location#INNER_CLASS
8585
*/

src/java.base/share/classes/java/lang/classfile/attribute/MethodParameterInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public sealed interface MethodParameterInfo
6363
/**
6464
* {@return the access flags, as a set of flag enums}
6565
*
66-
* @throws IllegalArgumentException if the flags mask has any unused bit set
66+
* @throws IllegalArgumentException if the flags mask has any undefined bit set
6767
* @see Parameter#accessFlags()
6868
* @see AccessFlag.Location#METHOD_PARAMETER
6969
*/

src/java.base/share/classes/java/lang/classfile/attribute/ModuleAttribute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public sealed interface ModuleAttribute
9191
/**
9292
* {@return the module flags of the module, as a set of enum constants}
9393
*
94-
* @throws IllegalArgumentException if the flags mask has any unused bit set
94+
* @throws IllegalArgumentException if the flags mask has any undefined bit set
9595
* @see ModuleDescriptor#accessFlags()
9696
* @see AccessFlag.Location#MODULE
9797
*/

src/java.base/share/classes/java/lang/classfile/attribute/ModuleExportInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public sealed interface ModuleExportInfo
6868
* {@return the flags associated with this export declaration, as a set of
6969
* flag enums}
7070
*
71-
* @throws IllegalArgumentException if the flags mask has any unused bit set
71+
* @throws IllegalArgumentException if the flags mask has any undefined bit set
7272
* @see ModuleDescriptor.Exports#accessFlags()
7373
* @see AccessFlag.Location#MODULE_EXPORTS
7474
*/

src/java.base/share/classes/java/lang/classfile/attribute/ModuleOpenInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public sealed interface ModuleOpenInfo
7474
* {@return the flags associated with this open declaration, as a set of
7575
* flag enums}
7676
*
77-
* @throws IllegalArgumentException if the flags mask has any unused bit set
77+
* @throws IllegalArgumentException if the flags mask has any undefined bit set
7878
* @see ModuleDescriptor.Opens#accessFlags()
7979
* @see AccessFlag.Location#MODULE_OPENS
8080
*/

src/java.base/share/classes/java/lang/classfile/attribute/ModuleRequireInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public sealed interface ModuleRequireInfo
6565
* {@return the flags associated with this require declaration, as a set of
6666
* flag enums}
6767
*
68-
* @throws IllegalArgumentException if the flags mask has any unused bit set
68+
* @throws IllegalArgumentException if the flags mask has any undefined bit set
6969
* @see ModuleDescriptor.Requires#accessFlags()
7070
* @see AccessFlag.Location#MODULE_REQUIRES
7171
*/

src/java.base/share/classes/java/lang/classfile/attribute/package-info.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@
2626
/**
2727
* <h2>Provides interfaces describing {@code class} file attributes for the {@link java.lang.classfile} library.</h2>
2828
*
29-
* The {@code java.lang.classfile.attribute} package contains interfaces describing specific {@code class} file attributes.
30-
* General and user-defined attributes reside in {@link java.lang.classfile}, including {@link Attributes}, {@link
31-
* AttributeMapper}, and {@link CustomAttribute}.
29+
* The {@code java.lang.classfile.attribute} package contains interfaces describing specific {@code class} file
30+
* attributes, including predefined (JVMS {@jvms 4.7}) and JDK-specific nonstandard attributes, whose mappers are
31+
* defined in {@link Attributes}. This package summary provides an overview to the {@code class} file attribute system,
32+
* including {@link Attribute}, {@link AttributedElement}, {@link AttributeMapper}, and {@link CustomAttribute}, which
33+
* do not reside in this package.
3234
* <p>
3335
* Unless otherwise specified, passing {@code null} or an array or collection containing a {@code null} element as an
3436
* argument to a constructor or method of any Class-File API class or interface will cause a {@link NullPointerException}
3537
* to be thrown.
3638
*
37-
* <h2 id="reading">Reading attributes</h2>
39+
* <h2 id="reading">Reading Attributes</h2>
3840
* The general way to obtain attributes is through {@link AttributedElement}. In addition to that, many attributes
3941
* implement {@link ClassElement}, {@link FieldElement}, {@link MethodElement}, or {@link CodeElement}, and these
4042
* attributes are generally delivered when their enclosing elements are viewed as {@link CompoundElement}s in streaming
@@ -57,7 +59,7 @@
5759
* must be ignored silently if they are malformed per JVMS; as a result, attribute processing code should anticipate
5860
* {@link IllegalArgumentException} and skip, instead of propagating the failure, on such attributes.
5961
*
60-
* <h2 id="writing">Writing attributes</h2>
62+
* <h2 id="writing">Writing Attributes</h2>
6163
* Most attributes implement at least one of {@link ClassElement}, {@link FieldElement}, {@link MethodElement}, or
6264
* {@link CodeElement}, so they can be sent to the respective {@link ClassFileBuilder} to be written as part of those
6365
* structure. Attributes define if they can {@linkplain AttributeMapper#allowMultiple() appear multiple times} in one

0 commit comments

Comments
 (0)