Skip to content

Commit e7f0944

Browse files
committed
Update JDK
1 parent cedc80b commit e7f0944

File tree

105 files changed

+5405
-1978
lines changed

Some content is hidden

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

105 files changed

+5405
-1978
lines changed

jdk

Submodule jdk updated 173 files

src/main/java/io/github/dmlloyd/classfile/AccessFlags.java

Lines changed: 44 additions & 11 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
@@ -30,37 +30,70 @@
3030
import io.github.dmlloyd.classfile.impl.AccessFlagsImpl;
3131

3232
/**
33-
* Models the access flags for a class, method, or field. Delivered as a
34-
* {@link ClassElement}, {@link FieldElement}, or {@link MethodElement}
35-
* when traversing the corresponding model type.
33+
* Models the access flags for a class, method, or field. The access flags
34+
* appears exactly once in each class, method, or field; a {@link
35+
* ClassBuilder} and a {@link FieldBuilder} chooses an unspecified default value
36+
* if access flags are not provided, and a {@link MethodBuilder} is always
37+
* created with access flags.
38+
* <p>
39+
* {@code AccessFlags} cannot be created via a factory method directly; it can
40+
* be created with {@code withFlags} methods on the respective builders.
41+
* <p>
42+
* A {@link MethodBuilder} throws an {@link IllegalArgumentException} if it is
43+
* supplied an {@code AccessFlags} object that changes the preexisting
44+
* {@link ClassFile#ACC_STATIC ACC_STATIC} flag of the builder, because the
45+
* access flag change may invalidate previously supplied data to the builder.
3646
*
47+
* @apiNote
48+
* The access flags of classes, methods, and fields are modeled as a standalone
49+
* object to support streaming as elements for {@link ClassFileTransform}.
50+
* Other access flags are not elements of a {@link CompoundElement} and thus not
51+
* modeled by {@code AccessFlags}; they provide their own {@code flagsMask},
52+
* {@code flags}, and {@code has} methods.
53+
*
54+
* @see ClassModel#flags()
55+
* @see FieldModel#flags()
56+
* @see MethodModel#flags()
57+
* @see ClassBuilder#withFlags
58+
* @see FieldBuilder#withFlags
59+
* @see MethodBuilder#withFlags
3760
* @since 24
3861
*/
3962
public sealed interface AccessFlags
4063
extends ClassElement, MethodElement, FieldElement
4164
permits AccessFlagsImpl {
4265

4366
/**
44-
* {@return the access flags, as a bit mask}
67+
* {@return the access flags, as a bit mask} It is in the range of unsigned
68+
* short, {@code [0, 0xFFFF]}.
4569
*/
4670
int flagsMask();
4771

4872
/**
49-
* {@return the access flags}
73+
* {@return the access flags, as a set of flag enums}
74+
*
75+
* @throws IllegalArgumentException if the flags mask has any undefined bit set
76+
* @see #location()
5077
*/
5178
Set<AccessFlag> flags();
5279

5380
/**
54-
* {@return whether the specified flag is present} The specified flag
55-
* should be a valid flag for the classfile location associated with this
56-
* element otherwise false is returned.
81+
* {@return whether the specified flag is set} If the specified flag
82+
* is not available to this {@linkplain #location() location}, returns
83+
* {@code false}.
84+
*
5785
* @param flag the flag to test
86+
* @see #location()
5887
*/
5988
boolean has(AccessFlag flag);
6089

6190
/**
62-
* {@return the classfile location for this element, which is either class,
63-
* method, or field}
91+
* {@return the {@code class} file location for this element, which is
92+
* either class, method, or field}
93+
*
94+
* @see AccessFlag.Location#CLASS
95+
* @see AccessFlag.Location#FIELD
96+
* @see AccessFlag.Location#METHOD
6497
*/
6598
AccessFlag.Location location();
6699
}

src/main/java/io/github/dmlloyd/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/main/java/io/github/dmlloyd/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/main/java/io/github/dmlloyd/classfile/AnnotationValue.java

Lines changed: 15 additions & 14 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
@@ -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
@@ -53,7 +54,7 @@ public sealed interface AnnotationValue {
5354

5455
/**
5556
* Models an annotation value of an element-value pair.
56-
* The {@linkplain #tag tag} of this value is {@value TAG_ANNOTATION}.
57+
* The {@linkplain #tag tag} of this value is {@value %c TAG_ANNOTATION}.
5758
*
5859
* @since 24
5960
*/
@@ -65,7 +66,7 @@ sealed interface OfAnnotation extends AnnotationValue
6566

6667
/**
6768
* Models an array value of an element-value pair.
68-
* The {@linkplain #tag tag} of this value is {@value TAG_ARRAY}.
69+
* The {@linkplain #tag tag} of this value is {@value %c TAG_ARRAY}.
6970
*
7071
* @since 24
7172
*/
@@ -121,7 +122,7 @@ sealed interface OfConstant extends AnnotationValue {
121122

122123
/**
123124
* Models a string value of an element-value pair.
124-
* The {@linkplain #tag tag} of this value is {@value TAG_STRING}.
125+
* The {@linkplain #tag tag} of this value is {@value %c TAG_STRING}.
125126
*
126127
* @since 24
127128
*/
@@ -148,7 +149,7 @@ default String resolvedValue() {
148149

149150
/**
150151
* Models a double value of an element-value pair.
151-
* The {@linkplain #tag tag} of this value is {@value TAG_DOUBLE}.
152+
* The {@linkplain #tag tag} of this value is {@value %c TAG_DOUBLE}.
152153
*
153154
* @since 24
154155
*/
@@ -175,7 +176,7 @@ default Double resolvedValue() {
175176

176177
/**
177178
* Models a float value of an element-value pair.
178-
* The {@linkplain #tag tag} of this value is {@value TAG_FLOAT}.
179+
* The {@linkplain #tag tag} of this value is {@value %c TAG_FLOAT}.
179180
*
180181
* @since 24
181182
*/
@@ -202,7 +203,7 @@ default Float resolvedValue() {
202203

203204
/**
204205
* Models a long value of an element-value pair.
205-
* The {@linkplain #tag tag} of this value is {@value TAG_LONG}.
206+
* The {@linkplain #tag tag} of this value is {@value %c TAG_LONG}.
206207
*
207208
* @since 24
208209
*/
@@ -229,7 +230,7 @@ default Long resolvedValue() {
229230

230231
/**
231232
* Models an int value of an element-value pair.
232-
* The {@linkplain #tag tag} of this value is {@value TAG_INT}.
233+
* The {@linkplain #tag tag} of this value is {@value %c TAG_INT}.
233234
*
234235
* @since 24
235236
*/
@@ -256,7 +257,7 @@ default Integer resolvedValue() {
256257

257258
/**
258259
* Models a short value of an element-value pair.
259-
* The {@linkplain #tag tag} of this value is {@value TAG_SHORT}.
260+
* The {@linkplain #tag tag} of this value is {@value %c TAG_SHORT}.
260261
*
261262
* @since 24
262263
*/
@@ -286,7 +287,7 @@ default Short resolvedValue() {
286287

287288
/**
288289
* Models a char value of an element-value pair.
289-
* The {@linkplain #tag tag} of this value is {@value TAG_CHAR}.
290+
* The {@linkplain #tag tag} of this value is {@value %c TAG_CHAR}.
290291
*
291292
* @since 24
292293
*/
@@ -316,7 +317,7 @@ default Character resolvedValue() {
316317

317318
/**
318319
* Models a byte value of an element-value pair.
319-
* The {@linkplain #tag tag} of this value is {@value TAG_BYTE}.
320+
* The {@linkplain #tag tag} of this value is {@value %c TAG_BYTE}.
320321
*
321322
* @since 24
322323
*/
@@ -346,7 +347,7 @@ default Byte resolvedValue() {
346347

347348
/**
348349
* Models a boolean value of an element-value pair.
349-
* The {@linkplain #tag tag} of this value is {@value TAG_BOOLEAN}.
350+
* The {@linkplain #tag tag} of this value is {@value %c TAG_BOOLEAN}.
350351
*
351352
* @since 24
352353
*/
@@ -376,7 +377,7 @@ default Boolean resolvedValue() {
376377

377378
/**
378379
* Models a class value of an element-value pair.
379-
* The {@linkplain #tag tag} of this value is {@value TAG_CLASS}.
380+
* The {@linkplain #tag tag} of this value is {@value %c TAG_CLASS}.
380381
*
381382
* @since 24
382383
*/
@@ -393,7 +394,7 @@ default ClassDesc classSymbol() {
393394

394395
/**
395396
* Models an enum value of an element-value pair.
396-
* The {@linkplain #tag tag} of this value is {@value TAG_ENUM}.
397+
* The {@linkplain #tag tag} of this value is {@value %c TAG_ENUM}.
397398
*
398399
* @since 24
399400
*/

src/main/java/io/github/dmlloyd/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 io.github.dmlloyd.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 io.github.dmlloyd.classfile.attribute##reading Reading Attributes}
49+
* and {@linkplain io.github.dmlloyd.classfile.attribute##writing Writing Attributes}
50+
* for more details.
4251
*
52+
* @param <A> the attribute type
53+
* @see io.github.dmlloyd.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)